#fiery_papaya_08623
1 messages · Page 1 of 1 (latest)
Hi there, so it seems like your system are creating duplicate payment intents. You should consider making your request idempotent (https://docs.stripe.com/api/idempotent_requests) to avoid accidentally performing the same operation twice.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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?
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.
Okay well I already do this then
In your opinion would it be better to create payment intent after collecting the payment?
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.
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?
All kinds of operations
Idempotency key is a indicator from your system that tell Stripe to "try again", or "perform a new operation"
So if I create a payment intent with an idempotency key, and update this payment intent later, should i change the idempotency key?
Yes you should
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”
Which part you need to clarify further?
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
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./
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?
It doesn't make any difference, what you need to do here is to prevent duplicate payment intent creations