BayarGO

Cancel Payment

Cancel a payment transaction that is still pending.

View as Markdown
POST/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 statusResult
pendingcancelled
refund_processingpaid, the refund process is cancelled.
created, paid, expired, failed, cancelled, settled, refund_failed, refundedCannot be cancelled.

Path Params

ParamTypeRequiredDescription
idstringYesTransaction UUID or reference_id.

Request Example

cURL
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

HTTPCodeDescription
400payment_cancel_failedTransaction cannot be cancelled from its current status, or the provider did not confirm the cancellation.
401invalid_api_keySecret key is invalid.
403merchant_not_approvedMerchant is not active yet.
403api_key_ip_not_allowedRequest IP is not in the API key allowlist.
404not_foundTransaction was not found.

On this page