#KoalaKey-customerportal

1 messages · Page 1 of 1 (latest)

pure lintel
#

hello! so I'm not the most familiar with Next.js but your question comes down to - you have an oauth ID in metadata on the Customer object and you want to just "search" the Customers endpoint by that metadata key?

dry breach
#

Yeah. and then I want to pass it to the customer portal code that is in the documentation so that only the customer that is logged in can access their own portal. Does that make sense?```
export default function create_customer_portal_session(req, res) {

const  customerId = 'this would be the customer id obtained from querying the auth0 metadata';
const returnUrl = 'someURL';
const portalSession = async () => await stripe.billingPortal.sessions.create({
    customer: customerId,
    return_url: returnUrl,
});
res.redirect(303, portalSession.url);

};

#

I guess I am just a little confused on how to obtain the logged in users customer ID for the customer portal

deep summit
#

Hey @dry breach! Stepping in here for @pure lintel as they needed to step away. It sounds to me like you want to list your Stripe Customers via https://stripe.com/docs/api/customers/list when your customer logs in so you can examine the metadata and grab their Customer ID for the customer portal

dry breach
#

Hey thanks for the response! I think I understand how to get the user info from stripe. I've been able to do that in a practice file. But where I am stuck is actually doing that from an API route. So grabbing the user data from the frontend and then passing it to the stripe API call. Not sure if that makes sense