Overview
The Cancel Payment Intent endpoint allows you to cancel a pending payment intent before the terminal processes the card payment or the intent expires. Once cancelled, the terminal will be notified and the payment request is withdrawn. Common use cases:- Customer decides not to pay at the terminal
- Order was entered with incorrect amount or details
- User navigates away from the payment screen in your application
- A new payment intent needs to replace an existing one
Cancelling only withdraws a request the terminal has not charged yet. Once the card was approved, the intent is
CONFIRMED and this endpoint answers 400 Payment intent already confirmed: give the money back with Refund a Payment Intent instead.Authentication
Send your API key in thex-api-key header, or, from an installed app (OAuth), its access token in Authorization: Bearer. An installed app needs the payments:write scope. See Why a request answers 401.
Cancellation Rules
You can only cancel a payment intent if all of these conditions are met:1
Status is PENDING
The payment intent must be in
PENDING status. You cannot cancel payment intents that are already CONFIRMED or CANCELLED.2
Payment intent belongs to your organization
You can only cancel payment intents created by your organization.
If a
terminalCode was provided when creating the payment intent, cancelling it also notifies the terminal that the payment request has been withdrawn.Request Format
POST /payment-intent/{id}/cancel
Response Format
The endpoint returns an empty JSON object on success:Examples
These examples call the production host. While you build, replace
https://api-harmony.compago.com with https://demo-api-harmony.compago.com and use a key from the Demo dashboard. See Environments.Cancel a payment intent
Cancel with error handling
Error Responses
Cannot cancel payment intent - The payment intent is not in
PENDING status.Common reasons:- Payment intent status is
CONFIRMED(already paid) - Payment intent status is
CANCELLED(already cancelled)
Payment intent not found - No payment intent with the specified ID exists in your organization.
Unauthorized - The credential was not accepted. See Why a request answers 401.
What Happens After Cancellation
After a payment intent is successfully cancelled:- Status Change: The status changes from
PENDINGtoCANCELLED - Terminal Notification: The associated terminal (if any) is notified
- Return to Your App: If the payment intent was created with a
redirectAppId, the terminal returns to that app after showing the cancellation screen - Irreversible: The cancellation cannot be undone
- New Intent Required: If payment is still needed, create a new payment intent
Next Steps
Create Payment Intent
Create a new payment intent to replace the cancelled one
API Reference
View the full API reference for the cancel endpoint