Payments
API ReferencePaymentsCancel
Cancel Payment
Cancels a payment that has not been fully captured yet. Releases any authorized funds back to the customer's payment method. Once cancelled, the payment cannot be captured.
POST /payments/:payment_id/cancel
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
payment_id | string | Yes | The ID of the payment to cancel. |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cancellation_reason | string | No | Free-text reason for the cancellation, useful for your own audit trail and customer support. |
Request Example
curl -X POST 'https://api.v2.paychtec.com/payments/pay_1234567890abcdef/cancel' \ -H "Content-Type: application/json" \ -H "api-key: snd_YOUR_API_KEY" \ -d '{ "cancellation_reason": "Customer requested cancellation"}'Response
{
"payment_id": "pay_1234567890abcdef",
"status": "cancelled",
"amount": 6540,
"currency": "USD",
"cancellation_reason": "Customer requested cancellation",
"cancelled_at": "2024-01-22T14:30:00Z"
}Errors
| Status | When |
|---|---|
400 | Payment is in a state that cannot be cancelled (e.g. already fully captured or already cancelled). |
404 | Payment id does not exist. |