Cancel Payment
Cancel a payment transaction that is still pending.
POST
cURL
/payments/:id/cancel
Cancel a transaction that is still pending.
The ShopeePay Partner SDK does not support cancellation.
For GoPay transactions, BayarGO first requests cancellation from GoPay. The local transaction changes to cancelled and emits payment.cancelled only after the provider confirms the cancellation. If the provider request fails, the transaction remains pending.
The POST /transactions/:id/cancel alias is available with the same behavior.
Status Rules
| Initial status | Result |
|---|---|
pending | cancelled |
refund_processing | paid, the refund process is cancelled. |
created, paid, expired, failed, cancelled, settled, refund_failed, refunded | Cannot be cancelled. |
Path Params
| Param | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Transaction UUID or reference_id. |
Request Example
curl -X POST "https://api.bayargo.id/payments/f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001/cancel" \ -H "Authorization: Bearer sk_xxx"Response
{
"payment": {
"id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
"reference_id": "PAY-LXAMPLE",
"merchant_reference_id": "ORDER-1024",
"payment_method_code": "qris",
"currency": "IDR",
"amount": 150000,
"fee_amount": 1050,
"net_amount": 150000,
"total_amount": 151050,
"status": "cancelled",
"cancelled_at": "2026-05-19T10:05:00Z"
}
}HTTP Error Codes
| HTTP | Code | Description |
|---|---|---|
400 | payment_cancel_failed | Transaction cannot be cancelled from its current status, or the provider did not confirm the cancellation. |
401 | invalid_api_key | Secret key is invalid. |
403 | merchant_not_approved | Merchant is not active yet. |
403 | api_key_ip_not_allowed | Request IP is not in the API key allowlist. |
404 | not_found | Transaction was not found. |