curl -X POST https://api.swiftpay.cx/api/refunds \
-H "Authorization: Bearer mp_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"checkoutSessionId": "sess_abc123",
"reason": "Customer requested refund"
}'
const response = await fetch("https://api.swiftpay.cx/api/refunds", {
method: "POST",
headers: {
Authorization: "Bearer mp_live_your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
checkoutSessionId: "sess_abc123",
reason: "Customer requested refund",
}),
});
const refund = await response.json();
console.log(
`Refund ${refund.data.id} created with status: ${refund.data.status}`
);
import requests
response = requests.post(
'https://api.swiftpay.cx/api/refunds',
headers={
'Authorization': 'Bearer mp_live_your_api_key',
'Content-Type': 'application/json'
},
json={
'checkoutSessionId': 'sess_abc123',
'reason': 'Customer requested refund'
}
)
refund = response.json()
print(f"Refund {refund['data']['id']} created")
{
"success": true,
"data": {
"id": "ref_xyz789",
"checkoutSessionId": "sess_abc123",
"amountInCents": 2999,
"reason": "Customer requested refund",
"status": "pending",
"createdAt": "2024-01-15T10:30:00Z"
}
}
{
"success": false,
"error": {
"type": "validation_error",
"message": "Can only refund completed sessions",
"requestId": "req_abc123"
}
}
{
"success": false,
"error": {
"type": "validation_error",
"message": "Insufficient balance for refund",
"requestId": "req_abc123"
}
}
Refunds
Create Refund
Create a refund for a completed checkout session
POST
/
api
/
refunds
curl -X POST https://api.swiftpay.cx/api/refunds \
-H "Authorization: Bearer mp_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"checkoutSessionId": "sess_abc123",
"reason": "Customer requested refund"
}'
const response = await fetch("https://api.swiftpay.cx/api/refunds", {
method: "POST",
headers: {
Authorization: "Bearer mp_live_your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
checkoutSessionId: "sess_abc123",
reason: "Customer requested refund",
}),
});
const refund = await response.json();
console.log(
`Refund ${refund.data.id} created with status: ${refund.data.status}`
);
import requests
response = requests.post(
'https://api.swiftpay.cx/api/refunds',
headers={
'Authorization': 'Bearer mp_live_your_api_key',
'Content-Type': 'application/json'
},
json={
'checkoutSessionId': 'sess_abc123',
'reason': 'Customer requested refund'
}
)
refund = response.json()
print(f"Refund {refund['data']['id']} created")
{
"success": true,
"data": {
"id": "ref_xyz789",
"checkoutSessionId": "sess_abc123",
"amountInCents": 2999,
"reason": "Customer requested refund",
"status": "pending",
"createdAt": "2024-01-15T10:30:00Z"
}
}
{
"success": false,
"error": {
"type": "validation_error",
"message": "Can only refund completed sessions",
"requestId": "req_abc123"
}
}
{
"success": false,
"error": {
"type": "validation_error",
"message": "Insufficient balance for refund",
"requestId": "req_abc123"
}
}
Create Refund
Creates a refund for a completed checkout session.Refunds can only be created for sessions with status
completed. Each
session can only be refunded once.Request
Bearer token with your API key
The ID of the completed checkout session to refund
Reason for the refund (for internal tracking)
Response
Whether the request was successful
Show properties
Show properties
curl -X POST https://api.swiftpay.cx/api/refunds \
-H "Authorization: Bearer mp_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"checkoutSessionId": "sess_abc123",
"reason": "Customer requested refund"
}'
const response = await fetch("https://api.swiftpay.cx/api/refunds", {
method: "POST",
headers: {
Authorization: "Bearer mp_live_your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
checkoutSessionId: "sess_abc123",
reason: "Customer requested refund",
}),
});
const refund = await response.json();
console.log(
`Refund ${refund.data.id} created with status: ${refund.data.status}`
);
import requests
response = requests.post(
'https://api.swiftpay.cx/api/refunds',
headers={
'Authorization': 'Bearer mp_live_your_api_key',
'Content-Type': 'application/json'
},
json={
'checkoutSessionId': 'sess_abc123',
'reason': 'Customer requested refund'
}
)
refund = response.json()
print(f"Refund {refund['data']['id']} created")
{
"success": true,
"data": {
"id": "ref_xyz789",
"checkoutSessionId": "sess_abc123",
"amountInCents": 2999,
"reason": "Customer requested refund",
"status": "pending",
"createdAt": "2024-01-15T10:30:00Z"
}
}
{
"success": false,
"error": {
"type": "validation_error",
"message": "Can only refund completed sessions",
"requestId": "req_abc123"
}
}
{
"success": false,
"error": {
"type": "validation_error",
"message": "Insufficient balance for refund",
"requestId": "req_abc123"
}
}
How Refunds Work
- Check Balance: We verify sufficient funds (available balance + reserves)
- Deduct Funds:
- First from available balance
- Then from oldest active reserves if needed
- Process Refund: Funds returned to customer’s payment method
- Webhook Notification:
refund.completedorrefund.failedevent sent
Refund processing typically takes 5-10 business days to appear on the
customer’s statement.
⌘I