duplicate_transaction HTTP 402 Stripe Declines Stripe Error: duplicate_transaction –
The duplicate_transaction error is triggered when a transaction with identical amount and credit card information is submitted very recently. This occurs at the API level during payment processing. It does not mean that the transaction was declined due to insufficient funds or other reasons.
Root Causes
Recent duplicate transactions
Stripe's system detects and prevents duplicate transactions within a short time frame.
Identical credit card information
The transaction's credit card details match an earlier submission.
Resolution
1.Verify transaction data
Check the payment method and amount for any discrepancies.
2.Wait before resubmitting
Allow sufficient time to pass between transactions with identical details.
Code Examples
stripe.api_key = 'YOUR_TEST_SECRET_KEY'
try: stripe.Charge.create(amount=1000, currency='usd', source='tok_visa')
except stripe.error.CardError as e:
print(e)
const stripe = require('stripe')('YOUR_TEST_SECRET_KEY');
try {
const charge = await stripe.charges.create({ amount: 1000, currency: 'usd', source: 'tok_visa' });
} catch (error) {
console.log(error);
}
require_once('/path/to/Stripe.php');
try {
$charge = Stripe_Charge::create(array('amount' => 1000, 'currency' => 'usd', 'source' => 'tok_visa'));
} catch (Stripe_CardError $e) {
print($e->getMessage());
}
curl -X POST https://api.stripe.com/v1/charges \
-H 'Authorization: Bearer YOUR_TEST_SECRET_KEY' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'amount=1000¤cy=usd&source=tok_visa'
FAQ
What causes the duplicate_transaction error? ▾
This error occurs when Stripe's system detects and prevents duplicate transactions within a short time frame.
How can I prevent this error? ▾
Verify transaction data for any discrepancies, and wait before resubmitting identical transactions.
What if the error persists after trying the above solutions? ▾
Contact Stripe support for further assistance.
Independent reference. Always verify against the official Stripe Declines documentation.