#arjun.maniyar-payments
1 messages · Page 1 of 1 (latest)
Let me check
$request_headers = [
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Bearer '.TEST_STRIPE_SECRET_KEY,
'Idempotent-Replayed: true',
];
$url = "https://api.stripe.com/v1/payment_intents";
$fields = array(
'amount' => $amount,
'currency' => 'usd',
'customer' => $customer_id,
'payment_method' => $paymentMethodId,
'off_session' => 'true',
'confirm' => 'true',
);
$request_payload = http_build_query($fields);
$response_body = curlPost($url , $request_payload , $request_headers);
$output = json_decode($response_body, true);
return $output;
This is the code I am using
Thanks for sending that, but really I need actual payment method IDs (like pi_xxx) to see what's happening. From a quick glance at the code I don't see anything wrong with it, so the object IDs will give us more context
I took a look and have a couple of questions:
- How/when is this payment intent creation code being triggered on your end?
- What is the purpose of you setting
Idempotent-Replayedas a request header? Are you trying to make an idempotent request?
- Right now I am calling it manually only once by passing PaymentMethodID
- I got that value on Google to avoid the double charge
If you want to be making idempotent requests then the Idempotent-Replayed header is not what you want. You want the Idempotency-Key header instead (see https://stripe.com/docs/idempotency#sending-idempotency-keys).
Idempotency allows safe API retry requests.
I just want to avoid double charge
Right now ever transaction is getting charged double
Yes, the idempotency key will help with that. But also, these duplicate charges are coming from your own code - you need to dig into your codebase and determine how it's possible you're sending the same request multiplet imes
I am trying but I don't see any double call, the above code I sent you is the only code I am calling once
Have you tried putting logs in your code to see if the code is being called multiple times?
Yes, I checked. No luck with that. Logs showing only one call
Hmmm, that's very strange - for context, we wouldn't just be making duplicate requests like this. Something on your end is making these requests.
If you can't find the root issue, then I would definitely suggest looking into the idempotency link I sent earlier