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
idstring RequiredThe payment's ID, such aspmt_QI02vLdJGd48hBbg.
Errors
- 404
not_foundNo payment with that ID belongs to your business. - 409
payment_not_cancelableFunds have arrived, or the payment came from a link. Archive the link instead. - 409
payment_in_flightA 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://api.402pay.co/api/v1/payments/pmt_cQL3ct8r16YeUw4l/cancel" \
-H "Authorization: Bearer $PAY402_SECRET_KEY"const response = await fetch("https://api.402pay.co/api/v1/payments/pmt_cQL3ct8r16YeUw4l/cancel", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PAY402_SECRET_KEY}`,
},
});
const { data } = await response.json();import os
import requests
response = requests.post(
"https://api.402pay.co/api/v1/payments/pmt_cQL3ct8r16YeUw4l/cancel",
headers={
"Authorization": f"Bearer {os.environ['PAY402_SECRET_KEY']}",
},
)
data = response.json()["data"]Response200 OK
{
"data": {
"id": "pmt_cQL3ct8r16YeUw4l",
"kind": "payment",
"status": "failed",
"amount": "49.00",
"currency": "USD",
"fee_payer": "business",
"customer_fee": "0.00",
"amount_received": "0.00",
"reporting": {
"currency": "USD",
"amount": "49.00",
"fee": "0.00",
"transaction_fee": "0.00",
"customer_fee": "0.00",
"net": "0.00"
},
"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": "ethereum",
"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"
}
}
]
}
}