Learn how to cancel an existing payment request to prevent further processing. This operation transitions the payment request to the CANCELED state, which is a final state from which no further actions can be taken.
74 min read
Introduction
Cancel an existing Payment Request to prevent further processing. This operation transitions the Payment Request to the CANCELED state, which is a final state from which no further actions can be taken.
Proactive cancellation recommended
Klarna recommends proactively canceling Payment Requests that have not resulted in successful transactions, especially if the Partner's checkout session timeout is shorter than the Payment Request lifetime. By default, a Payment Request remains open for 3 hours and will automatically expire if not completed or explicitly canceled. You can override this default with the custom Payment Request expiry feature.
Prerequisites
Before canceling a Payment Request, ensure the following:
A valid Partner Account with API credentials
Backend capability to receive and process Klarna webhooks
An existing Payment Request that can be canceled
The payment_request_id of the Payment Request to cancel
Cancellable states only
Payment Requests can only be canceled while in SUBMITTED or IN_PROGRESS states. Once a Payment Request reaches a final state (COMPLETED, EXPIRED, CANCELED, or DECLINED), it cannot be canceled.
Request
Call cancelPaymentRequest with the payment_request_id to cancel the Payment Request. This is a DELETE operation with no request body.
Subscribe to the payment.request.state-change.canceled webhook event using the guidelines provided here. Klarna sends this event when a Payment Request is successfully canceled.
Cancel Payment Requests in various scenarios to maintain accurate payment tracking and free up resources. Common scenarios include abandoned checkouts, session timeouts, and error recovery.
Abandoned checkout
Cancel the Payment Request when the customer abandons the checkout flow.
Proactively cancel Payment Requests when the Partner's checkout session expires to avoid unnecessary open requests.
Align expiry with session timeout
Consider using the custom Payment Request expiry feature in authorizePayment (step_up_config.customer_interaction_config.interaction_expiry) to align Payment Request expiration times with the Partner's checkout session timeout. This reduces the need for manual cancellation when the session expires.
Implement automatic cancellation for Payment Requests that haven't completed within your expected timeframe. This helps:
Reduce unnecessary open Payment Requests
Improve Payment Request tracking and reporting
Free up system resources
Maintain clean Payment Request state
Webhook integration
Subscribe to the payment.request.state-change.canceled webhook to be notified when Payment Requests are canceled, whether by your system or by Klarna (due to expiration or other reasons).
Error handling
Implement proper error handling for cancellation failures:
Handle 409 Conflict errors for requests already in final states
Retry with exponential backoff for temporary failures
Log cancellation attempts for debugging and auditing