Cancel/Revert a Klarna Payment
Overview
If the merchant is not intending to complete the authorised Klarna payment and therefore no longer requires the amount to be held, the Klarna payment should be cancelled to free up the available purchase amount for this customer at Klarna. This is especially important if the customer has used a card in his purchase flow.
Klarna (Partial) Cancellation requests are only applicable for the following payment methods:
- Klarna Pay Now (370)
- Klarna Pay Later (371)
- Klarna Financing (372)
Two different use-cases are supported:
- Full cancellation
Applies if the Klarna Deposit has not yet been (partially) captured. The full authorisation amount will be cancelled with Klarna. - Release the remaining authorisation amount (partial cancellation)
Applies if at least one successful partial capture has been done already. The remaining authorised amount will be cancelled with Klarna. No further captures will be possible.
All captures need to be sent before remaining amount is released
No further partial capture request will be accepted for the original Klarna payment once a cancellation request to revert the remaining amount was sent.
How to cancel/revert or release the remaining amount for a Klarna Payment
A Klarna payment can be cancelled by using the executePaymentAction with actionID
= 1
(Cancel). Any amount sent in this request will be ignored and the remaining or full authorisation amount is reverted.
In the case of a cancellation of a Klarna payment, the original Klarna payment remain in state ExecutedByProvider (142).
Example executePaymentActionRequest
for a cancellation of a Klarna payment:
<?xml version="1.0" encoding="utf-8"?>
<executePaymentActionRequest xmlns="http://www.cqrpayments.com/PaymentProcessing"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<merchantID>KalixaAcceptDEMO</merchantID>
<shopID>KalixaAcceptDEMO</shopID>
<paymentID>684e2d61-b0aa-4e2f-bc21-afd8f9287f94</paymentID>
<actionID>1</actionID>
</executePaymentActionRequest>
A new payment which is linked to the original Klarna payment will be created with the following payment method:
ID | Payment Method Name | Successful State |
---|---|---|
381 | Klarna Cancellation | Cancelled (113) |
The response for the executePaymentAction request will contain all relevant data about the new cancellation payment which was created for the cancellation/reversal.
Example executePaymentActionResponse
for a full cancellation of a Klarna payment:
<executePaymentActionResponse xmlns="http://www.cqrpayments.com/PaymentProcessing" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<statusCode>0</statusCode>
<actionResults>
<result xsi:type="keyStringValuePair">
<key>lastStateDefinition</key>
<value>142</value>
</result>
<result xsi:type="keyStringValuePair">
<key>createdPayment.paymentID</key>
<value>43f91041-035e-4b50-86d6-2f5f4e5d486a</value>
</result>
<result xsi:type="keyStringValuePair">
<key>createdPayment.lastStateDefinition</key>
<value>113</value>
</result>
<result xsi:type="keyStringValuePair">
<key>createdPayment.paymentMethodID</key>
<value>381</value>
</result>
<result xsi:type="keyStringValuePair">
<key>ProviderTransactionID</key>
<value>D9FFE800-89DF-41D0-AFC3-58C47DAC3370</value>
</result>
</actionResults>
</executePaymentActionResponse>
Details for actionResults:
Field | Value | Description |
---|---|---|
lastStateDefinition | 142 (ExecutedByProvider) | The last state of the original Klarna payment for which the cancel request was sent. |
createdPayment.paymentID | some GUID | The ID of the new cancellation payment which was created. |
createdPayment.lastStateDefinition | 113 (Cancelled) This is the successful state. or 260 (CancelRefusedByProvider) or 349 (CancelCommunicationErrorOccurred) | The state of the new cancellation payment. |
createdPayment.paymentMethodID | 381 (Klarna Cancellation) | The payment method ID of the new cancellation payment. |
Example executePaymentActionResponse
for a cancellation request of a Klarna payment which was refused by the provider (Klarna):
<executePaymentActionResponse xmlns="http://www.cqrpayments.com/PaymentProcessing" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<statusCode>0</statusCode>
<actionResults>
<result xsi:type="keyStringValuePair">
<key>lastStateDefinition</key>
<value>142</value>
</result>
<result xsi:type="keyStringValuePair">
<key>createdPayment.paymentID</key>
<value>3132a0b3-c93f-4d55-a396-a63e01ef236d</value>
</result>
<result xsi:type="keyStringValuePair">
<key>createdPayment.lastStateDefinition</key>
<value>260</value>
</result>
<result xsi:type="keyStringValuePair">
<key>createdPayment.paymentMethodID</key>
<value>381</value>
</result>
<result xsi:type="keyStringValuePair">
<key>ProviderTransactionID</key>
<value>D9FFE800-89DF-41D0-AFC3-58C47DAC3370</value>
</result>
</actionResults>
</executePaymentActionResponse>
Payment Flow for Klarna Cancellation payments:
Errors
PXP Financial Payment Service will return a paymentServiceException message in case an unexpected error occurs when initiating a Klarna Deposit payment.
Generic Error Codes
Find here more information about Error Handling and generic error codes.
If the cancellation request was refused due to a validation error, the following error code is returned and the message will explain the problem:
Error Code | Error Message |
---|---|
100 | A general validation error occurred. For details see message field of the paymentServiceException |
Example paymentServiceException message for an invalid cancellation payment request for a Klarna payment:
<paymentServiceException xmlns="http://www.cqrpayments.com/PaymentProcessing" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id>c3962c91-43fe-4d25-b383-9f5c2da927cc</id>
<errorCode>100</errorCode>
<errorMessage>There is no authorized amount left to cancel.</errorMessage>
</paymentServiceException>
How to test Klarna Cancellation
- Test-Cases applicable for Klarna Cancellation: Klarna Cancellation Test Cases
- Information how to cancel a Klarna Deposit payment manually using the PXP Admin tool: Capture Testing FAQs
Updated about 4 years ago