Refund API
Use a refund to return a payment to a customer.
Note: We do not currently support partial refunds. The original charge will therefore be fully refunded.
Request
https://online.yoco.com/v1/refunds/
Headers
Parameter | Type | Description |
---|---|---|
X-Auth-Secret-Key | string | The secret key for your account |
Body
Parameter | Type | Description |
---|---|---|
chargeId | string | The charge id returned when you originally did the charge. eg: ch_xpnGTFDSnlvksdnvkbkfvd |
metadata | json | A set of key-value pairs that you can attach to a Refund object. |
Example
- Python
- Node.js
- PHP
- cURL
import json
import requests
# Anonymous test key. Replace with your key.
SECRET_KEY = 'sk_test_960bfde0VBrLlpK098e4ffeb53e1'
response = requests.post(
'https://online.yoco.com/v1/refunds/',
headers={
'X-Auth-Secret-Key': SECRET_KEY,
},
json={
'chargeId': 'ch_xpnGtOMMObOw',
},
)
# response.status_code will contain the HTTP status code
# response.json() will contain the response body
Response
- Successful
- Created
- Declined
- Error
HTTP: 200 OK
{
"id": "rfd_kaA15fAoB0JEwQHLXPUWBXhYwr",
"status": "successful",
"message": "Your refund has been processed",
"metadata": {}
}