Cancel a Payment
Cancel a payment that is still eligible for cancellation. For a completed payment, use a refund flow instead. See Payment Lifecycle for the eligible states.
Cancellation is a server-side Payments API operation. It can stop an eligible payment created through the widget or directly through the Payments API.
Before you startβ
- Have the
paymentIdand a merchant-scoped access token. Check the current status with Get Payment. - Confirm that the status is eligible: the Payment Lifecycle lists
PENDING,AUTHORIZED, andACCEPTEDcases. ACOMPLETEDpayment requires a refund instead. - Choose a
paymentCancellationReason:DUPLICATE,FRAUDULENT,REQUESTED_BY_CUSTOMER, orABANDONED.
Cancel the paymentβ
1. Send the cancellation requestβ
Call PATCH /v2/payments/{paymentId}/cancel from your backend. The JSON body requires paymentCancellationReason; paymentCancellationMessage is optional.
Cancellation request
PATCH /v2/payments/{paymentId}/cancel
Authorization: Bearer <merchant-token>
X-Merchant-Id: <merchant-id>
X-Upstream-Env: <environment>
Content-Type: application/json
{
"paymentCancellationReason": "REQUESTED_BY_CUSTOMER",
"paymentCancellationMessage": "Customer requested cancellation"
}
For the complete header and body contract, see the Cancel Payment API reference.
2. Check the final statusβ
The API returns 202 Accepted while cancellation is being processed. Track the payment through Get Payment or payment webhooks. CANCEL_INITIALIZED is in progress; verify the final CANCELED or FAILED status before treating the cancellation as finished.
If the request is rejected, check the response against the Cancel Payment API reference and Payment Error Codes. Recheck the payment status before deciding whether to retry or use a refund.
Related documentationβ
- Capture a Payment β complete an authorized payment instead
- Payment Lifecycle β cancellation eligibility and status
- Payments Overview β API flow and operation list