Cancel Payments
There may be scenarios in which you need to cancel a payment, such as a customer placing a payment by mistake or an authorized payment that needs to be voided before settlement.
Both Payment Intents and the direct Payments API support cancellation. A succeeded payment cannot be canceled — use the refund flow instead.
Getting Started
To get started, you will need a Credova Account.
Get your Secret Key
Next you will need your Secret Key. Go to your Developers section and click Reveal for your Secret Key and copy the value.
Payment Intents
A Payment Intent can be canceled from any non-terminal status: requires_payment_method, requires_confirmation, or requires_capture. It cannot be canceled once it has succeeded.
Cancel the Payment Intent
Call the Cancel Payment Intent endpoint with the intent ID:
curl 'https://api.publicsquare.com/payment_intents/pmt_int_2xNjK7abcdefghij/cancel' \
-X 'POST' \
-H 'X-API-KEY: <SECRET_API_KEY>' \
-H 'Content-Type: application/json'
You should see a response with status: canceled:
{
"id": "pmt_int_2xNjK7abcdefghij",
"account_id": "acc_B518niGwGYKzig6vtrRVZGGGV",
"environment": "test",
"status": "canceled",
"amount": 1000,
"currency": "USD",
"cancellation_reason": "requested",
"canceled_date": "2026-04-15T15:10:00Z",
"payment_id": null,
"created_date": "2026-04-15T14:22:10Z",
"modified_date": "2026-04-15T15:10:00Z"
}
Handling Cancellation Errors
If you attempt to cancel an intent that is already canceled, you will receive a 409 Conflict:
{
"error": {
"code": "payment_intent_already_canceled",
"message": "This PaymentIntent has already been canceled."
}
}
If a confirm is currently in progress, cancellation will be rejected until the confirm completes. Retry the cancel once the intent transitions out of processing:
{
"error": {
"code": "payment_intent_confirm_in_progress",
"message": "A confirm is currently in progress. Please try again shortly."
}
}
succeeded, cancel is not available. Follow the Issue a Refund guide instead.Legacy
The direct Payments API offers the ability to cancel a payment before it is settled or captured.
In order to cancel a payment, we will need the ID of an authorized or recently captured payment. Assuming you have a payment similar to:
{
"id": "pmt_2YKewBonG4tgk12MheY3PiHDy",
"account_id": "acc_B518niGwGYKzig6vtrRVZGGGV",
"environment": "test",
"status": "requires_capture",
...
}
We need to make a call to Cancel Payment endpoint:
curl 'https://api.publicsquare.com/payments/cancel' \
-X 'POST' \
-H 'X-API-KEY: <SECRET_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"payment_id": "pmt_2YKewBonG4tgk12MheY3PiHDy"
}'
Payment Response
Given the above example, you should see a cancelled payment result similar to:
{
"id": "pmt_2YKewBonG4tgk12MheY3PiHDy",
"account_id": "acc_B518niGwGYKzig6vtrRVZGGGV",
"environment": "test",
"status": "cancelled",
"transaction_id": "trx_95rvMJvAVeG68W4NtLdfkN3LG",
"amount": 1000,
"amount_capturable": 0,
"amount_charged": 1000,
"amount_refunded": 0,
"refunded": false,
...
"transaction": {
"id": "trx_95rvMJvAVeG68W4NtLdfkN3LG",
"account_id": "acc_B518niGwGYKzig6vtrRVZGGGV",
"environment": "test",
"status": "cancelled",
"amount": 1000,
"fee_amount": 0,
"net_amount": 1000,
...
},
...
}
Handling Cancellation Failures
If a payment cannot be cancelled because the payment has already been settled, an error response will be returned:
{
"title": "Error",
"status": 400,
"detail": "payment cancellation failed."
}
If payment cancellation fails, you can follow the refund payment guide.
Conclusion
This guide showed you how to cancel a payment. You can also follow our refund payment guide which will attempt to cancel the payment and fallback to issuing a refund.
Follow these guides to learn more: