#AlejandroHN_21 - PHP PaymentIntents
1 messages · Page 1 of 1 (latest)
PaymentIntent Stripe makes duplicate payments
Can you share some more info about your request? A request id can help me troubleshoot for you further
When I go back to the browser and then I go back to the gateway as it stores 2 paymentIntent
This sounds like it could be a bug in your code. Can you share some request id's or code snippets where you are creating the payment intents?
I speak Spanish and I'm using the translator to talk to you, that's why I'm slow to answer I'm sorry I hope your understanding
in a moment I share pieces of my code explaining the problem
Ok thank you. Also if you can share the request IDs that would help (they look like: req_****)
images
My problem is that the asynchronous function initialize (); it reads me 2 paymentIntent when I go back in the browser
The asynchronous function initialize (); in the code Checkout JS load asynchronously it is triggered once the page loads and at the same time it helps to load the stripe elements in the checkout
Are the duplicate payment intents just incomplete? Or are you seeing duplicate fulfilled payments? Once the card details are submitted, are you actually charged twice or just once?
It would be expected if you are just seeing multiple payment intents, since your code creates a new one every time you refresh the page
However, it wouldn't be expected if you are actually being charged twice
for example if I have a paymentIntent loaded in the PHP code, the function initialize (); it is in charge of reading the payment and brings me the clientSecret to enable the stripe elements
if I go back in the browser histoy.back native browser function
the function initialize (); you already have a PaymentIntent loaded
and then I go back to the checkout page, it reloads me another paymentIntent, when the sending process is done in my stripe dashboard I get that 2 payments were made
Ok I see. I will need your paymentintent IDs to look into this then
They start with pi_
I could write to your discord in private channel
PaymentIntent id's and request id's aren't sensitive info, so it's ok if you share here. We ask to not share secrets though
@orchid vortex Is there a reason you're not sharing the Payment Intent IDs (pi_xxx) we asked for? While your code is helpful, the object IDs are really what we need to be looking at in order to understand what's happenign in your integration.
I'm so sorry this is my first time programming with Stripe, I feel embarrassed for causing annoyance.
But to see the truth, I do not know where to extract the Payment Id, I do not know if the paymentIntent IDs are generated automatically or I think they are on the dashboard?
I'm sorry I can't help you but it's my first time programming with stripe
No worries at all! We just weren't sure if there was a specific reason you weren't sharing them 🙂
You should be able to find all your payment intents on the dashboard https://dashboard.stripe.com/test/payments. When you click on any of the payments, you should be able to find the pi_xxx ID
Sorry for the delay, I had a connection problem
"id": "pi_3KEaq8BMcOwqphyo090ozSvE",
"id": "pi_3KEapkBMcOwqphyo1O8BEnvZ",
These are the duplicate PaymentIntent Id at the same time
here I am
Apologies for missing this thread for a bit. karbi had to step away, I am catching up now
It looks like those were created with two separate calls with two separate idempotency keys 61d5b06a843e37.11773114 and 61d5b082b9e9b7.55565968 .
If you are loading them from a file, can you tell what file each of those came from?
But that only happens when I go back in the browser, for example if I charge the Checkout once the payment is successful.
But if I reload the checkout page 2 times the initialize () function stores the first PaymentIntent and is sent duplicate
I generate the id with the PHP function uniqid ('', true) that generates them randomly
If you don't want to create the payment intent again, you will need to reuse the first idempotency key
Though also this can be fine behavior, we don't charge the payment intent until you confirm it. The user will only be charged once if you only confirm one of the payment intents from that scenario
Ok what you are telling me is that if I charge once the PaymentIntent and if a second PaymentIntent is charged for reasons that the user recharged the page or gave back on the page
the solution would be a PayementIntent Update that replaces the first PaymentIntent with the second PaymentIntent
$stripe->paymentIntents->update(
'pi_1DpeUP2eZvKYlo2CqDKio8pl',
['metadata' => ['order_id' => '6735']]
);
I appreciate that you are helping me with my problem, I think I have to work to fix it.
Glad that helped, yes the charge will only happen on the PI you confirm it for so that can be the one you associate with the order