#mangle8582

1 messages · Page 1 of 1 (latest)

mellow pathBOT
#

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.

versed helm
#

You could use an idempotency key per customer to create checkout sessions

#

To ensure per customer not more than 1 session is created

tawny plinth
#

Doesn't that come on webhook?

versed helm
#

What do you mean

#

What does this have to do with webhooks

tawny plinth
#

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?

#
  1. 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?
  2. "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: ? })

versed helm
#

That solves your issue

tawny plinth
#

And i need to generate one each request right?

#

a random one

versed helm
#

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

tawny plinth
#

So i need to save it in my database right?

#

Can i attach it to customer?

versed helm
#

up to you

versed helm
tawny plinth
#

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:

  1. User creates account, attached generated UUID idepotency key to the customer object in stripe, i save the idepotency key to my database.
  2. When user wants to subscribe, i create checkout session with the same idempotency key that was created when user was created right?
versed helm
#

No don't pass it for creating a customer

#

Unless you want that operation to be idempotent as well

tawny plinth
#

I understand so i only save it in my database

versed helm
#

Yeah if you want

#

Up to you

#

Save it wherever

#

Just use the same key for a customer when creating each session

tawny plinth
#

Thank you!