I keep receiving DUPLICATE_REQUEST_ID in Sandbox but works in Live
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sing the .NET PayPal SDK, I keep getting this 400 response every time I try to process a payment using a credit card in the sandbox environment. Exact same code works in the production. I've tried all different kinds of generated credit card number, and real ones. I've tried calling apiContext.ResetRequestId(). Still same error response. Here's my code:
var config = ConfigManager.Instance.GetProperties(); var accessToken = new OAuthTokenCredential(config).GetAccessToken(); var apiContext = new APIContext(accessToken); apiContext.Config = ConfigManager.Instance.GetProperties(); var transaction = new Transaction(); transaction.amount = new Amount() { currency = "USD", total = string.Format("{0:N}", amount), details = new Details() { subtotal = string.Format("{0:N}", amount) } }; transaction.invoice_number = invoiceNumber; var payer = new Payer(); payer.payment_method = "credit_card"; payer.funding_instruments = new List<FundingInstrument>() { new FundingInstrument() { credit_card = new CreditCard() { cvv2 = cvv2, expire_month = expireMonth, expire_year = expireYear + 2000, first_name = firstName, last_name = lastName, number = cardNumber, type = GetCreditCardType(cardNumber) } } }; var payment = new Payment(); payment.intent = "sale"; payment.payer = payer; payment.transactions = new List<Transaction>() { transaction }; try { apiContext.ResetRequestId(); var createdPayment = payment.Create(apiContext); if (createdPayment.state == "failed") throw new Exception("Transaction not approved"); if (createdPayment.transactions.Count > 0 && createdPayment.transactions[0].related_resources.Count > 0) { string d = createdPayment.transactions[0].related_resources[0].sale.create_time; // https://stackoverflow.com/questions/3556144/how-to-create-a-net-datetime-from-iso-8601-format DateTime create_time = DateTime.Parse(d, null, System.Globalization.DateTimeStyles.RoundtripKind); d = createdPayment.transactions[0].related_resources[0].sale.update_time; DateTime update_time = DateTime.Parse(d, null, System.Globalization.DateTimeStyles.RoundtripKind); return new Domain.Models.Payment() { PaymentID = createdPayment.id, CreateTime = create_time, UpdateTime = update_time, TransactionID = createdPayment.transactions[0].related_resources[0].sale.id }; } else { //return createdPayment.id; throw new Exception("No sale for payment"); } } catch (PayPal.PaymentsException ex) { // TODO figure out what the problem was so we can add it to the log and error message. //ex. if (ex.Details != null) { string msg = ex.Details.message; if (ex.Details.details != null) { foreach (var d in ex.Details.details) { msg += string.Format(" (field = {0}, issue = {1}, code = {2}, purchase_unit_reference_id = {3}) (invoice: {4}) ", d.field, d.issue, d.code, d.purchase_unit_reference_id, invoiceNumber); } } throw new Exception(msg, ex); } throw ex; } catch (Exception ex) { throw ex; }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you have duplicate suppression turned on in the Sandbox Account, and you pass in an invoice number that was previously used, the payment will be blocked as a duplicate payment.
There are a few ways to resolve this. Update your Invoices to include letters and numbers in your Payment Request.
The other way you can resolve this is to turn off the duplicate suppression in the sandbox account.
Turning off the feature requires logging into the PayPal Sandbox Portal and not the PayPal Developer Portal.
The option of blocking accidental payments is already set as a default in your PayPal account. You can change this setting by following these steps:
- Go to www.sandbox.paypal.com and log in to your sandbox account.
- Click Profile at the top of the page.
- Click My selling tools.
- Under 'Getting paid and managing my risk' click Update beside 'Block payments.'
- Select No in the Block Accidental Payments section and click Save.
Thank you,
Jennifer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Jennifer for suggestions, however, I tried changing the settings and I'm still getting the same error responses from the API. It's refusing to accept any credit card payments. I've tried setting up a brand new sandbox account and app with a new clientId and clientSecret. I also applied the settings you suggested above to the new sandbox account. Still, I receive this exact same error every time I try to create a credit card payment using the code from before. Is there something else I can try?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Same thing happening to me. I have set : No, allow multiple payments per invoice ID
Should we raised a tech ticket for this issue ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have same issue , payment accepted once using credit card then for the same code it gives error of DUPLICATE_REQUEST_ID , even if card and payment details are changed.
I am using PayPal SDK in MVC.
did you got any solution ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did submit a support "question" over at https://www.paypal-techsupport.com. I was asked to provide a request/response to the API that produces the error. I chose to bypass the SDK and communicate directly with the API. Below is the request/response, where I am now getting a HTTP 500 response.
REQUEST:
curl -v -X POST https://api.sandbox.paypal.com/v1/payments/payment \
-H "Content-Type: application/json" \
-H "Authorization: Bearer MYTOKEN" \
-d '{
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [{
"credit_card": {
"cvv2": "123",
"expire_month": 12,
"expire_year": 2019,
"first_name": "Foo",
"last_name": "Bar",
"number": "VALID CC NUMBER",
"type": "visa"
}
}]
},
"transactions": [{
"amount": {
"currency": "USD",
"total": "2.54",
"details": {
"subtotal": "2.54"
}
},
"invoice_number": "asdf1234"
}]
}'
RESPONSE:
{"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error occurred.","information_link":"https://developer.paypal.com/docs/api/payments/#errors","debug_id":"170497ba1b4"}
The answer I got from Merchant Technical Support was:
Direct credit card transactions are restricted using the PayPal REST integration. You will need to leverage either the Payflow gateway or Braintree Direct to process direct card transactions. You can find the notice on the following link:-
https://developer.paypal.com/docs/api/payments/
Get in touch with you account manager at PayPal to discuss your business requirements and make a decision based on your use cases.
I did submit a support "question" over at https://www.paypal-techsupport.com. I was asked to provide a request/response to the API that produces the error. I chose to bypass the SDK and communicate directly with the API. Below is the request/response, where I am now getting a HTTP 500 response.
REQUEST:
curl -v -X POST https://api.sandbox.paypal.com/v1/payments/payment \
-H "Content-Type: application/json" \
-H "Authorization: Bearer MYTOKEN" \
-d '{
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [{
"credit_card": {
"cvv2": "123",
"expire_month": 12,
"expire_year": 2019,
"first_name": "Foo",
"last_name": "Bar",
"number": "VALID CC NUMBER",
"type": "visa"
}
}]
},
"transactions": [{
"amount": {
"currency": "USD",
"total": "2.54",
"details": {
"subtotal": "2.54"
}
},
"invoice_number": "asdf1234"
}]
}'
RESPONSE:
{"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error occurred.","information_link":"https://developer.paypal.com/docs/api/payments/#errors","debug_id":"170497ba1b4"}
The answer I got from Merchant Technical Support was:
I'm not seeing these errors in my Live account because that account is not restricted, and I've been using credit cards via the REST API for quite some time now. For some reason this un-restricted ability does not flow through to my sandbox accounts. When I create new sandbox accounts they must simply default to restricted.
My guess is that PayPal is going to phase out credit card payments via the REST API in favor of some of their other offerings: Payflow or Braintree? Would be nice to have some clarification on that, or any sort of timeline. Certainly don't want this capability dissapearing from my Live account without some sort of advanced notice! Furthering my speculations it appears that the credit card samples have been removed from the .NET SDK source code in github GitHub (https://github.com/paypal/PayPal-NET-SDK/pull/276). Perhaps pp-randy knows what's up?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Not receiving any confirmation emails for sandbox account in Sandbox Environment
- Authorization failed due to insufficient permissions in Sandbox Environment
- Compliance violation. flag based on the account origin ? in Sandbox Environment
- Please return to the merchant and choose another way to pay in PayPal Reporting
- Things don't appear to be working at the moment. Please try again later in Sandbox Environment