Cancel checkout session before payment processing

Cancel a checkout session before payment processing starts or contract is created.

Common use cases:

  • Customer abandonment: Track when customers decide not to proceed with purchase
  • Duplicate removal: Cancel sessions when creating new ones with different terms
  • Expiration handling: Clean up sessions that have reached their expiry time
  • Fraud prevention: Cancel sessions flagged by risk management systems

Behavior & restrictions:

  • Only 'open' sessions can be cancelled
  • Sessions with payment_status 'pending' or 'paid' cannot be cancelled
  • Provide optional cancellation context using standardized reason types:
    • customer_requested: When customer explicitly cancels
    • payment_failed: When payment attempt unsuccessful
    • expired: When session reaches expiration time
    • duplicate: When another session supersedes this one
    • fraudulent: When fraud risk detected
    • other: For any other reason (requires explanation)

Related endpoints:

  • POST /checkout_session: Creates a session that may later be cancelled
  • GET /checkout_session/{id}: Check session status before cancelling
  • PUT /checkout_session/{id}: Alternative to cancellation when modifications needed

Errors include not-open sessions, disallowed payment status, and invalid status transitions.

Language
Credentials
Header
Click Try It! to start a request and see the response here!