#_kevinx
1 messages · Page 1 of 1 (latest)
Hello Karbi
Hello!
Can you give me some more details here? I'm not exactly sure what you mean thwne you say the customer ID keeps changing?
Yes, so in order to set up this billing portal I just linked, it requires a customer id,
const session = await stripe.billingPortal.sessions.create({
customer: '{{CUSTOMER_ID}}',
return_url: 'https://example.com/account',
});
which is from the payment webhooks, such as charge succeed or payment intent succeed, for the same customer logged into our account, I noticed that if they make few different purchases, this customer id is unique each time, so the question is how to keep this cusomter id consistent for a unique customer so that they can come back and get all of their receipts, invoices, billing changes etc
Gotcha
and how are your customers making purchases? Are you using Checkout? Are you creating the Customers yourself?
If you give me two examples of customer IDs I can also take a look at that
we are using Checkout
sure
cus_OWdu4dJ6mmWEjD
cus_OYOnLumdOaLupN
cus_OZtxcCLi6ajI8h
cus_OZuBdfhD50BeG6
So right off the bat I want to clarify - Checkout typically doesn't do any customer deduplication by default for one-time payments. Since you've created your Checkout Sessions with customer_creation: always and mode: payment we're always going to create a new Customer for each Checkout Session.
If you want to use the same Customer across multiple sessions, you need to be passing in customer when you create the Checkout Session
If you were doing mode: subscription checkout sessions, then we do offer the ability to limit customer duplication (https://stripe.com/docs/payments/checkout/limit-subscriptions) but that wouldn't apply to one-time payments
Oh, got you, so in order to make the customer id consistent for retail, we need to pass in the customer id when creating checkout sessions? this is not a subscription based model
that makes sense, but let me check out how to implement this
👋 stepping in as karbi needs to step away
Hello, Bismarck
Yep you got it -- you pass the Customer ID to https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer if you want to re-use a previously created Customer object for the Checkout Session
Got you, thank you!
so we need to capture this customer id the first time they use the checkout session¿ ?
Yep that works or you can create the Customer object yourself via https://stripe.com/docs/api/customers/create when a new customer visits your site and then pass that Customer ID to Checkout just like you would for a returning customer where you would grab their stored Customer ID