Skip to content
Docs menu

Endpoints

Cancel a payment

Stop a payment created through the API before any funds arrive.

Works on a payment you created through the API that hasn't received funds. It becomes failed with canceled_at set, its timeline ends with a failed event whose reason is canceled, and any open checkout for it closes. You receive payment.failed.

Canceling twice returns the payment as it is, so a retry can't fail.

Path

  • id string Required
    The payment's ID, such as pmt_QI02vLdJGd48hBbg.

Errors

  • 404 not_found
    No payment with that ID belongs to your business.
  • 403 test_mode_unavailable
    A test key can't cancel a payment on a live business, so use a live key.
  • 409 payment_not_cancelable
    Funds have arrived, or the payment came from a link. Archive the link instead.
  • 409 payment_in_flight
    A transfer for the payment is on its way.

Any request can also fail on its key or its body. See errors.

Request
curl -X POST "https://dash.402pay.co/api/v1/payments/pmt_cQL3ct8r16YeUw4l/cancel" \  -H "Authorization: Bearer $PAY402_SECRET_KEY"
Response200 OK
{  "data": {    "id": "pmt_cQL3ct8r16YeUw4l",    "kind": "payment",    "status": "failed",    "amount": 4900,    "currency": "USD",    "fee_payer": "business",    "customer_fee": 0,    "amount_received": 0,    "reporting": {      "currency": "USD",      "amount": 4900,      "fee": 0,      "transaction_fee": 0,      "customer_fee": 0,      "net": 0    },    "fee_rate_bps": 0,    "method": {      "rail": "crypto",      "asset": null,      "network": null,      "amount": null,      "expected_amount": null,      "overpaid_amount": null,      "from_address": null,      "tx_hash": null,      "explorer_url": null    },    "settlement": {      "destination": "wallet",      "asset": "USDC",      "network": "polygon",      "amount": "0.00",      "wallet_id": null,      "address": null,      "tx_hash": null,      "explorer_url": null    },    "customer_id": null,    "link_id": null,    "url": "https://checkout.402pay.co/checkout/cd6dfqk65a",    "reference": "order_1043",    "metadata": {      "order_id": "1043"    },    "success_url": "https://example.com/thanks",    "cancel_url": "https://example.com/cart",    "expires_at": "2026-09-27T21:23:16.653Z",    "canceled_at": "2026-09-26T21:23:16.669Z",    "checkout_id": null,    "description": "Pro plan, monthly",    "country": "",    "failure_code": null,    "failure_message": "The business canceled the payment.",    "confirmed_at": null,    "created_at": "2026-09-26T21:23:16.653Z",    "updated_at": "2026-09-26T21:23:16.669Z",    "events": [      {        "type": "created",        "created_at": "2026-09-26T21:23:16.653Z",        "data": null      },      {        "type": "failed",        "created_at": "2026-09-26T21:23:16.669Z",        "data": {          "reason": "canceled"        }      }    ]  }}