To refund an order, use the /v2/payments/captures/capture_id/refund
endpoint. The capture_id
can be read from the purchase_units/payments/captures/id
field of the order you want to refund.
Modify the code
Copy the code and modify it as follows:
- Replace
ACCESS-TOKEN
with your access token. - Replace
YOUR-PAYPAL-REQUEST-ID
with your PayPal request ID. - Replace
PAYPAL-AUTH-ASSERTION
with your PayPal auth assertion generated from Step 1. - Replace
BN-CODE
with your PayPal attribution ID to receive revenue attribution.To find your BN code, see Code and Credential Reference.
Fully refund an order
For a full refund, include an empty payload in the JSON request body.
1curl -v -X POST https://api-m.sandbox.paypal.com/v2/payments/captures/2GG279541U471931P/refund
2 -H "Content-Type: application/json"
3 -H "Authorization: Bearer ACCESS-TOKEN"
4 -H "PayPal-Request-Id: YOUR-PAYPAL-REQUEST-ID"
5 -H "PayPal-Auth-Assertion: PAYPAL-AUTH-ASSERTION"
6 -H "PayPal-Partner-Attribution-Id: BN-CODE"
7 -d '{}'
Partially refund an order
For a partial refund, include an amount object in the JSON request body. You can also issue multiple partial refunds up to the total captured amount. If you are unsure how much captured amount is remaining to be refunded after one or more partial refunds, make the API call with the total captured amount or leave the amount field blank. The API will automatically calculate and issue the refund for the remaining value.
1curl -v -X POST https://api-m.sandbox.paypal.com/v2/payments/captures/2GG279541U471931P/refund
2-H "Content-Type: application/json"
3-H "Authorization: Bearer ACCESS-TOKEN"
4-H "PayPal-Request-Id: YOUR-PAYPAL-REQUEST-ID"
5-H "PayPal-Auth-Assertion: PAYPAL-AUTH-ASSERTION"
6-H "PayPal-Partner-Attribution-Id: BN-CODE"
7-d '{
8 "amount": {
9 "value": "10.99",
10 "currency_code": "USD"
11 }
12}'
Step result
A successful request returns the HTTP 201 Created
status code. If you didn't receive a response, making the same API call without changing the request should result in an HTTP 200 OK
with a confirmation of the refund.