#mangle8582
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- mangle8582, 2 days ago, 94 messages
- mangle8582, 5 days ago, 2 messages
You could use an idempotency key per customer to create checkout sessions
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
To ensure per customer not more than 1 session is created
Doesn't that come on webhook?
I know i had work with idepotency to avoid duplicate webhook requests.
But how would i know idepotency idwhen creating customer?
Or i just generate a random uuid?
- I need to provide the UUID as idepotency when a customer is created? When user creates the account? Would that be enough to avoid duplicate checkouts?
- "You can remove keys from the system automatically after they’re at least 24 hours old. We generate a new request if a key is reused after the original is pruned. The idempotency layer compares incoming parameters to those of the original request and errors if they’re the same to prevent accidental misuse." This is confusing a bit, what do you mean remove keys from the system, they are already attached to the Customer when customer was created.
Isn't there a easier solution to avoid duplicate subscriptions? The above setting from my screenshot should've done that. What is it's purpose anyway?
Oh it redirects you when you try to create the link again ok.
But if you already have 2 links created before the subscription is paid, i believe another solution is needed
I think you can send it to
const session = await stripe.checkout.sessions.create({ idempotencyKey: ? })
This is exactly what I told you to do above
That solves your issue
No
You need to use the same one for each customer id
To avoid duplicates being created
That's the whole point of an idempotency key
or make it formulaic
up to you
what do you mean?
When user creates the customer i saw that you can attach a idepotency key directly to the Stripe Customer Object
So my flow would be:
- User creates account, attached generated UUID idepotency key to the customer object in stripe, i save the idepotency key to my database.
- When user wants to subscribe, i create checkout session with the same idempotency key that was created when user was created right?
No don't pass it for creating a customer
Unless you want that operation to be idempotent as well
I understand so i only save it in my database
Yeah if you want
Up to you
Save it wherever
Just use the same key for a customer when creating each session
Thank you!