I'm working on the code to cover negative scenarios like card declined and similar. According to the documentation the only way to do it for Orders is to use the header PayPal-Mock-Response https://developer.paypal.com/tools/sandbox/negative-testing/request-headers/
However, it doesn't work for me, I'm getting the 403 error with an empty response every time I try to add the "PayPal-Mock-Response" header with any error, can't get it working at all
Example, request:
POST https://api-m.sandbox.paypal.com/v2/checkout/orders
params:
{
"method": "post",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer A21[reducted]",
"PayPal-Mock-Response": "{\"mock_application_codes\":\"DUPLICATE_INVOICE_ID\"}"
},
"body": "{\"intent\":\"CAPTURE\",\"purchase_units\":[{\"custom_id\":89534,\"description\":\"my item name\",\"reference_id\":648,\"amount\":{\"currency_code\":\"USD\",\"value\":\"5.01\"}}]}"
}
Response:
{
"statusCode": 403,
"responseText": ""
}
I'm using nodejs, node-fetch package, the auth token is correct as I've got positive scenario working, the 403 error is only being thrown when I add the "PayPal-Mock-Response" header.
what am I doing wrong or is there any other way to make a failed payment on sandbox?