Cancel Payment
POST
/api/payment-cancelCancels a pending checkout session by invoice_id. Once cancelled the checkout URL stops accepting new payments and any subsequent payment attempts are rejected with a friendly message. Use this when your application knows the order is no longer valid — for example, the customer removed all items from their cart, the product went out of stock, or your fraud check failed. You cannot cancel an invoice that has already been paid; use the Refund endpoint for that.
Request headers
| Field | Type | Required | Description |
|---|---|---|---|
| Authorization | string | required | Your test or live API key. Example: pg_live_xxx |
| Content-Type | string | required | Must be application/json. Example: application/json |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
| invoice_id | string | required | The invoice_id of the pending checkout to cancel. Example: inv_01HZX5JM3W7QZK8YF7N9P0RTS2 |
Response
200 OK
1{2 "invoice_id": "inv_01HZX5JM3W7QZK8YF7N9P0RTS2",3 "status": "cancelled",4 "cancelled_at": "2026-05-30T14:20:00Z"5}TipCancellation triggers a webhook
Cancelling an invoice fires the
payment.cancelled webhook event so any downstream system (inventory hold, CRM record) can react automatically.Error codes
| Field | Type | Required | Description |
|---|---|---|---|
| 400 | already_paid | optional | The invoice is already completed. Issue a refund instead. |
| 400 | already_cancelled | optional | The invoice is already cancelled. |
| 401 | unauthorized | optional | API key is missing or invalid. |
| 404 | not_found | optional | No invoice exists for the given id. |
WarningCancellation is final
A cancelled invoice cannot be reopened. If the customer changes their mind, create a fresh checkout.