#JacquesVivi

1 messages · Page 1 of 1 (latest)

ripe schoonerBOT
boreal breach
#

Hi! Let me help you with this.

#

You shoud use the same idempotency key for one operation, but not per customer/payment etc.

#

What's your usecase exactly?

visual bough
#

Customer make a payment of 120€. With "off_session" option. Then it will be charged of 100€ the 01 december then the 01 march

#

ON the link I don't see "idempotent_requests"

#

Sorry I d'ont see "idempotency_key" option

boreal breach
#

You can add idempotency_key to any request. But what you're trying to do should have 2 different idempotency keys, as it's 2 different operations.

visual bough
#

Yes

#

to "any request" you mean shoul I do it on customer creation

#

or payement intent creation ?

#

Exemple 1 :

#
  1. Creta a customer with idempotency_key cart id
  2. make a paymentIntent of 120€
  3. Update the customer idempotency_key
  4. Then make a 100€ paymentINtent
#

Or

  1. Create a customer
  2. make a paymentIntent of 120€ with idempotency_key cart id
  3. Then make a 100€ paymentIntent with another idempotency_key
boreal breach
#

Do you have a strong reason to use an idempotency_key in the first place? (e.g. do you have a complex retry strategy?)

visual bough
#

I have a few carts that sometimes have two payments. I do not know why. Could be a connection issue. The idempotency_key seemed like a good technique to implement and avoid this.

boreal breach
#

It can create more issues and not solve the double charging problem, if you don't know where the problem lies.

visual bough
#

hum ok

boreal breach
#

First you need to identify why this happens and then see if idempotency_key can help you solve this problem.

visual bough
#

I will remove It

boreal breach
#

Do you create 2 PaymentIntents? Because you can only charge the customer once with 1 PaymentIntent.

visual bough
#

Yes. When he reloads the payment page. I create a new PaymentIntent

boreal breach
#

You can check if the customer has a PaymentIntent, and if yes, you can just reuse the existing one.

visual bough
#

ok

#

i will try this

#

I have implemented the idempotency_key for some customers

#

I will remove it

#

But could I have trouble with this for their subscriptions ?

#

On the next month

#

?

boreal breach
#

I think every request gets an idempotency key automatically, but you can set it yourself if you want 2 requests to be idempotent.

#

Again, it's important to remember that it's just one tool that can help solve some problems, but it has to be used correctly to be effective and not cause more trouble.

visual bough
#

If I used it on creating customers. Shouldn't this create a problem for their next paymentIntents ? Exact ?

boreal breach
#

idempotency_key is not business-logic related. It only acts if you add it to a specific request.

boreal breach
visual bough
#

I don't see it

#

But I have used it on

#

or

#

I have created this customers with $customer = \Stripe\Customer::create([
'email' => $email,
"preferred_locales" => ['fr', 'en']
], [
'idempotency_key' => $idempotency_key,
]);

boreal breach
#

It's not persisted on the Customer object, so it won't affect any future requests.

visual bough
#

Ok thanks

boreal breach
#

Happy to help!