Cancel a Payment Request

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.

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.

Klarna recommends proactively canceling Payment Requests that have not resulted in successful transactions, especially if your Payment Request timeout is less than 3 hours. A Payment Request remains open for 3 hours and will automatically expire if not completed or explicitly canceled.

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

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 cancelPaymentRequestAPI with the payment_request_id to cancel the Payment Request. This is a DELETE operation with no request body.

Sample request

SHELL
curl -X DELETE https://api-global.test.klarna.com/v2/accounts/{partner_account_id}/payment/requests/{payment_request_id} \
  -H 'Authorization: Basic <API key>'

Response

The API returns the canceled Payment Request with state CANCELED.

Sample response

JSON
{
  "payment_request_id": "krn:payment:eu1:request:10be1d49-7beb-6b24-b9dd-8c14d0528503",
  "state": "CANCELED",
  "expires_at": "2025-02-26T17:25:34.534721775Z",
  "created_at": "2025-02-24T17:25:34.534721775Z",
  "updated_at": "2025-02-24T17:35:00.123456789Z",
  "canceled_at": "2025-02-24T17:35:00.123456789Z",
  "payment_request_reference": "acquiring-partner-request-reference-1234",
  "amount": 11836,
  "currency": "EUR",
  "supplementary_purchase_data": {...},
  "customer_interaction_config": {

Webhook

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.

Sample payload

JSON
{
  "metadata": {
    "event_type": "payment.request.state-change.canceled",
    "event_id": "b2c3d4e5-f6g7-8901-bcde-fg2345678901",
    "event_version": "v2",
    "occurred_at": "2025-02-24T17:35:00Z",
    "correlation_id": "4f3779ga-39e5-688e-b46e-d1c5g03e4c24",
    "subject_account_id": "krn:partner:global:account:live:HGBY07TR",
    "recipient_account_id": "krn:partner:global:account:live:LWT2XJSE",
    "product_instance_id": "krn:partner:product:payment:ad71bc48-8a07-4919-[...]",
    "webhook_id": "krn:partner:global:notification:webhook:120e5b7e-abcd-4def-[...]",
    "live": false

Use cases

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.

SHELL
curl -X DELETE https://api-global.test.klarna.com/v2/accounts/{partner_account_id}/payment/requests/krn:payment:eu1:request:abc123 \
  -H 'Authorization: Basic <API key>'

Session timeout

Proactively cancel Payment Requests when your session expires to avoid unnecessary open requests.

Consider using the custom Payment Request expiration feature in authorizePaymentAPI (step_up_config.payment_request_expires_at) to align Payment Request expiration times with your session timeout. This reduces the need for manual cancellation when the session expires.

SHELL
# Cancel payment request after 30-minute session timeout
curl -X DELETE https://api-global.test.klarna.com/v2/accounts/{partner_account_id}/payment/requests/{payment_request_id} \
  -H 'Authorization: Basic <API key>'

Best practices

Proactive cancellation

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

Related articles

Setup your webhooks