PayPal-Mock-Response header not working -- got 403 error instead. Help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm following the guide here to simulate a negative/declined response: https://developer.paypal.com/tools/sandbox/negative-testing/request-headers/
Here's a sample request I made using Python:
order_id = 'SOME_VALID_ORDER_ID'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer THIS_IS_MY_ACCESS_TOKEN',
'PayPal-Mock-Response': '{"mock_application_codes": "INSTRUMENT_DECLINED"}'
}
response = requests.post(f'https://api-m.sandbox.paypal.com/v2/checkout/orders/{ order_id }/capture/', headers = headers)
It returns an empty response body, with status code 403.
What can I be doing wrong here?
- Labels:
-
REST

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @zylvie ,
Thank you for posting to the PayPal Sandbox Community.
I tested in Postman, putting all the values in the header and was able to get the correct response.
Here is what I passed in:
Post to this endpoint (with any order id you can even use this one 5O190127TN364715T)
https://api.sandbox.paypal.com/v2/checkout/orders/{{order_id}}/capture
Here are the header Key and Values:
Content-Type Value: application/json
Authorization Value: Bearer{{access_token}}
PayPal-Mock-Response Value: {"mock_application_codes": "INSTRUMENT_DECLINED"}
Here is the response:
Response:
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"issue": "INSTRUMENT_DECLINED",
"description": "The instrument presented was either declined by the processor or bank, or it can't be used for this payment."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-INSTRUMENT_DECLINED",
"rel": "information_link",
"method": "GET"
}
]
}
As long as you have an order id being passed into the endpoint you should get the valid Instrument Decline error.
Thank you,
Jennifer
MTS
PayPal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @MTS_Jennifer, thank you for your quick response.
Unfortunately I tried the same in Postman, and it still gave me a 403 error.
I generated my access token 3 times (to get 3 different bearer tokens for my Authorization header), and all 3 times it returned a 403 error.
Every other API call works using my bearer token (e.g. creating orders, capturing orders without the "PayPal-Mock-Response" header, etc.), so I don't understand why this particular API call fails.
Is there anything else I should troubleshoot?
Can I provide you with my credentials so you can look into it?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @zylvie ,
Thank you for contributing to this post. Can you please open a ticket so we can troubleshoot this further with you.
Here is how:
- Go to https://paypal.com/mts
- Click Contact Us
- Click Log in with PayPal
- Log into your PayPal Account
- Click Contact Us
- Fill in the details including the Client ID and any debug ids
Once you open the case we can work directly with you to resolve this issue.
Thank you,
Jennifer
MTS
PayPal

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Things don’t appear to be working at the moment in PayPal Payments Standard
- p is not a function error using the example downloaded from Paypal in SDKs
- How to enable on-demand / recurring payments to existing PayPal checkout? in SDKs
- Unable to issue a refund from our business sandbox account in Sandbox Environment
- WooCommerce and PayPal GENERIC_ERROR dring CheckOut in PayPal Payments Standard