#omg_ketchup-checkout-creates-customer
1 messages ยท Page 1 of 1 (latest)
Hello ๐
Checkout usually creates a new customer if needed.
do you have an example request ID I can take a look at?
I actually just deleted all my test customers, but I can try again, it should give the same behavior as I haven't updated the code yet this morning. Also, I'm still working in sandbox mode- does that impact anything
I'm using "checkout" to add subscriptions. I'm properly handling the payment_intent.succeeded webhook event, saving the returned "customer" ID into my database, and then any time that user attempts to create a new session, I use that "customer" value as the customer param in the session object I create.
Give me 1 second, I'll get you some data to look at.
No worries ๐
evt_1Kj3cdFSQeVFcrWo5XpzFal3 "sam@lavamap is a new customer"
evt_1Kj3e6FSQeVFcrWo0FrX0fRk "sam@lavamap is a new customer"
Also, thanks for responding incredibly quickly, I appreciate your time. Let me know if there's anything else I can provide to make this easier.
All good ๐ Looking into it
Are you sure you're passing the customer ID correctly when you create a checkout session?
I thought I was? Let me double check, I just got an error when sending both customer and customer_email at the same time, which I wasn't getting previously, so... maybe there's something there? Give me a min to check this out.
No worries! A checkout session in subscription mode will always create a customer if one isn't provided.
Hmmm... I reset my user database, so it tried to create a session with an empty customer value and I got an error telling me that... previously I definitely had a value there, but I think I'm honing in on the issue here, thank you so much.
NP! Happy to help ๐
YUP! That was it! Looks like I had an issue with writing code and the --watch thing not picking it up, so I was actually sending old requests, even though I was looking at new code in my editor.
One small question though, semi-related.
Now that I have it working properly, it took me to the checkout page (with my details filled), and it allowed me to pay for that subscription twice. I thought I had the subscription price set to only allow one at a time, and I definitely don't want to charge customers 2x in case they mess something up. Should I be handling that on my end, or is there a way to bump them from checkout to the billing portal without writing my own logic for that?
(maybe not that small of a question, sorry)
If you need a customer ID to see what happened- cus_LPtdkDhbslulho
No worries. I think that's something you'd handle on your end as checkout doesn't look at previous payments related to a customer.
Gotcha, OK. I'm only offering subscriptions, so in theory, I would just check to see if they have a stripeCustomerId set on their profile, and if they do, I'd send them to the billing portal, and if they don't, send them to checkout?
You can actually just list the current subscriptions for a customer and check what they're currently subscribed to
https://stripe.com/docs/api/customers/object#customer_object-subscriptions
So you think it makes sense to make an outbound request to the stripe API there? I was trying to avoid hitting the API too frequently.