#fiery_papaya_08623

1 messages · Page 1 of 1 (latest)

slate caveBOT
granite quail
rare sequoia
#

I do use it, but is it ok if i create a new idempotency key when creating a payment intent and create a new idempotency key when updating it the same payment intent?

granite quail
#

The idempotency key is provided by your system, so it's entirely up to your system. You should use the same key for the same operation, and use a different key for a different operation.

rare sequoia
#

Okay well I already do this then

#

In your opinion would it be better to create payment intent after collecting the payment?

granite quail
#

I think you should review your code where you use the same idempotency key for the same operation. If you use a different idempotency key, a sperate payment intent object is created, which results in duplicate charges.

rare sequoia
#

When you say an operation, you mean a payment intent? Or it means the creation of a payment intent or an update of a payment intent?

granite quail
#

All kinds of operations

#

Idempotency key is a indicator from your system that tell Stripe to "try again", or "perform a new operation"

rare sequoia
#

So if I create a payment intent with an idempotency key, and update this payment intent later, should i change the idempotency key?

granite quail
#

Yes you should

rare sequoia
#

Ok thats what I’m doing

#

I’m not sure ai understand what you said here:

I think you should review your code where you use the same idempotency key for the same operation. If you use a different idempotency key, a sperate payment intent object is created, which results in duplicate charges.

#

You just said “If you use a different idempotency key, a separate payment intent object is created which results in duplicate charges”

granite quail
#

Which part you need to clarify further?

rare sequoia
#

Well you just contradicted yourself. In this text it says that I should not use a different idempotency key

#

So I’m a little confused haha

granite quail
#

Let me explain again. After creating an API request to Stripe, if your system doesn't receive an response from Stripe (i.e., connection error ), then you should use the same idempotency key to create the same request, this will not result in creating a duplicate object./

rare sequoia
#

Ok I get it now, thanks!

#

But for my current flow, do you recommend to create the intent after the payment details are entered and sent to stripe?

granite quail
#

It doesn't make any difference, what you need to do here is to prevent duplicate payment intent creations