Search docs

Are you looking for test card numbers?

Would you like to contact support?

Start searching Adyen's documentation...

  Documentation

Klarna

Learn how to accept Klarna payments.

Klarna payments are popular in Sweden, and are also available in Denmark, Finland, Norway, Germany, Austria, Switzerland, the Netherlands, the United Kingdom, and the United States.

Klarna Pay now

With Klarna's Pay now, formerly known as Sofort, shoppers can pay the whole amount instantly. For more information, refer to our Sofort integration guide.

With Klarna, the shopper can choose to: 

  • Pay later: Pay by invoice, after the goods have been delivered.
  • Slice it: Pay in installments over time. 

Before approving the payment, Klarna performs risk checks on the shopper. If successful, Klarna takes on the full fraud risk for the payment, and pays you up front.

When making a Klarna payment, you need to provide price and product information about the purchased goods. This will be included on the invoice. When you ship the goods, you also need to capture the payment. This is what triggers the invoice to be sent to the shopper. 

If you have a business model without physical goods, Klarna payments might not be suitable for you, or require additional configuration. For more information, contact our Support Team.

Payment Type Payment flow Recurring Refunds Partial Refunds Captures Partial Captures Chargebacks
Open invoice Redirect No Yes Yes Yes* Yes No**

* All Klarna payments need to be captured manually, even if you have enabled automatic capture for other payment methods.
** There are no chargebacks as long as you stick to the Klarna scheme rules. For more information about the Klarna scheme rules, contact our Support Team.

You can accept Klarna payments with: 

When using our classic Hosted Payment Pages integration, refer to our old Klarna documentation instead.

Integrate with Checkout SDKs

Before you begin this section, make sure you read and understand our SDK Integration guides.

Our Checkout SDKs support Klarna payments without any additional configuration, however you need to provide some additional parameters in your call to the /paymentSession endpoint:

  • lineItems: Price and product information about the purchased items. This is included on the invoice that Klarna sends to the shopper.

    Klarna will only approve the payment if the amounts stated in lineItems are correct. For more information, refer to Invoice lines.

  • shopperEmail: The shopper's email address. This is where Klarna will send the invoice.
  • shopperName(optional): The shopper's full name and gender (if specified). 
  • billingAddress (optional): The postal address to be included on the invoice. 

Klarna uses the shopperName and billingAddress to perform risk checks on the shopper. If not specified, the shopper has to enter this information when completing the payment on the Klarna page. 

curl -H "Content-Type: application/json" -H "X-API-Key: YourAPIkey" -X POST -d '{
       "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
       "channel":"Web",
       "amount":{
          "currency":"SEK",
          "value":"1000"
       },
       "reference":"YOUR_ORDER_REFERENCE",
       "countryCode":"SE",
       "returnUrl":"https://www.yourshop.com/checkout/result",
       "shopperLocale":"en_US",
       "shopperEmail":"youremail@email.com",
       "shopperName":{
          "firstName":"Testperson-se",
          "gender":"UNKNOWN",
          "lastName":"Approved"
       },
       "shopperReference":"klarna_SE",
       "billingAddress":{
          "city":"Ankeborg",
          "country":"SE",
          "houseNumberOrName":"1",
          "postalCode":"12345",
          "street":"Stargatan"
       },
       "lineItems":[
          {
             "quantity":"1",
             "amountExcludingTax":"331",
             "taxPercentage":"2100",
             "description":"Shoes",
             "id":"Item #1",
             "taxAmount":"69",
             "amountIncludingTax":"400",
             "taxCategory":"High"
          },
          {
             "quantity":"2",
             "amountExcludingTax":"248",
             "taxPercentage":"2100",
             "description":"Socks",
             "id":"Item #2",
             "taxAmount":"52",
             "amountIncludingTax":"300",
             "taxCategory":"High"
          }
       ]
}' https://checkout-test.adyen.com/v41/paymentSession

The response will contain a paymentSession. Use this to initialize the SDK. The SDK will send the shopper to Klarna to verify the payment, and back to your website or app using the returnUrl.

To complete the Klarna payment, you also need to capture it after the goods have been sent.

Integrate with API

Before you begin this section, make sure you read and understand our API Integration guide.

With our API integration, you can accept Klarna payments using either: 

  • Redirect to Klarna : The shopper is redirected to Klarna to complete the payment.
  • The Klarna widget:  The shopper completes the payment in your checkout. For more information about the Klarna widget, refer to Klarna documentation. If you want to use the Klarna widget contact our Support Team, as this requires some additional configuration on our end.

Step 1: Collect required shopper details

Use your payment form to collect the shopper's email address.

We also recommend collecting the shopper's name and billing address. These are used by Klarna to perform risk checks on the shopper. If not specified, the shopper has to enter this information when completing the payment on the Klarna page. 

Step 2: Make a payment

Make a /payments API call, providing:

  • paymentMethod.type: The type of Klarna payment the shopper wants to use.  Possible values: 

    • klarna: Klarna - Pay later.
    • klarna_account: Klarna - Slice it. 
  • shopperLocale: A combination of a language code and a country code to specify the language used in your checkout. 
  • countryCode: The shopper's country. 
  • shopperEmail: The shopper's email address. This is where Klarna will send the invoice.
  • shopperName: The shopper's full name and gender (if specified).
  • shopperReference: A unique reference to identify the shopper. 
  • returnUrl:  Only required if you are using a redirect to Klarna. The URL that the shopper is redirected to after they complete the payment. 
  • lineItems: Price and product information about the purchased items. This is included on the invoice that Klarna sends to the shopper. 

    Klarna will only approve the payment if the amounts stated in lineItems are correct. For more information, refer to Invoice lines.

  • shopperName (optional): The shopper's full name and gender (if specified).
  • billingAddress (optional):  The postal address to be included on the invoice. 
{
   "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
   "reference":"YOUR_ORDER_REFERENCE",
   "paymentMethod":{
      "type":"klarna"
   },
   "amount":{
      "currency":"SEK",
      "value":"1000"
   },
   "shopperLocale":"en_US",
   "countryCode":"SE",
   "shopperEmail":"youremail@email.com",
   "shopperName":{
      "firstName":"Testperson-se",
      "gender":"UNKNOWN",
      "lastName":"Approved"
   },
   "shopperReference":"klarna_SE",
   "billingAddress":{
      "city":"Ankeborg",
      "country":"SE",
      "houseNumberOrName":"1",
      "postalCode":"12345",
      "street":"Stargatan"
   },
   "returnUrl":"https://www.yourshop.com/checkout/result",
   "lineItems":[
      {
         "quantity":"1",
         "amountExcludingTax":"331",
         "taxPercentage":"2100",
         "description":"Shoes",
         "id":"Item #1",
         "taxAmount":"69",
         "amountIncludingTax":"400",
         "taxCategory":"High"
      },
      {
         "quantity":"2",
         "amountExcludingTax":"248",
         "taxPercentage":"2100",
         "description":"Socks",
         "id":"Item #2",
         "taxAmount":"52",
         "amountIncludingTax":"300",
         "taxCategory":"High"
      }
   ]
}

The response to your /payments call depends on whether you are using a redirect to Klarna, or the Klarna widget.

Step 3: Complete the payment

The steps for completing the Klarna payment depend on whether you are using:

Redirect to Klarna

The response to your  /payments call contains: 

  • resultCodeRedirectShopper

  • paymentData: Value that you need to submit to the /payments/details endpoint later. 

  • redirect: Object containing a url.

    {
       "resultCode":"RedirectShopper",
       "details":[
          {
             "key":"redirectResult",
             "type":"text"
          }
       ],
       "paymentData":"abcxyz...",
       "redirect":{
          "method":"GET",
          "url":"https://test.adyen.com/hpp/skipDetails.shtml?billingAddress. ..."
       }
    }
  1. Redirect the shopper to the URL specified at  redirect.url

    The shopper is redirected to Klarna. After approving the payment, they are redirected back to your website or app using the returnUrl that you specified in the /payments call . This is appended with a redirectResult:

    https://your-company.com/done?redirectResult=xyzabc...
  2. Verify the result of the payment by making a /payments/details call, providing: 

    • redirectResult: You received this in the previous step.   

    • paymentData:  The value from the response to your /payments call. 
    {
       "paymentData":"abcxyz...",
       "details":{
          "redirectResult" : "xyzabc..."
       }
    }

    The response contains a pspReference, which is our unique identifier for this payment, and a resultCode

  3. Use the resultCode to present the payment result to your shopper via your website or app. For more information on how to handle the resultCode, refer to Result codes.

  4. After the goods have been sent, you also need to capture the payment.

The Klarna widget

The response to your  /payments call contains: 

  • resultCodePending

  • paymentData: A value that you need to submit to the /payments/details endpoint later. 

  • redirect: An object containing a client token.
{
   "resultCode":"Pending",
   "details":[
      {
         "key":"token",
         "type":"text"
      }
   ],
   "paymentData":"abcxyz...",
   "redirect":{
      "data":{
         "klarna.client_token":"eyJhbGciOiJu ..."
      }
   }
}
  1. Use the client token to populate the Klarna widget. 
    This opens an iframe where the shopper has to enter their details. 
  2. After the shopper has submitted the details, you will receive an authorization_token. For more information about the authorization_token, refer to Klarna documentation.
  3. Verify the result of the payment by making a /payments/details call, providing: 

    • authorization_token: You received this in the previous step.     

    • paymentData: The value from the response to your /payments call. 
    {
       "paymentData":"abcxyz...",
       "details":{
          "token":"eba4d492-ddd4-6dd3-ad31-5ba2ad6a86d0"
       }
    }

    The response contains a pspReference, which is our unique identifier for this payment, and a resultCode

  4. Use the resultCode to present the payment result to your shopper via your website or app. For more information on how to handle the resultCode, refer to Result codes.

  5. After the goods have been sent, you also need to capture the payment.

Capture the Klarna payment

Unlike most other payments, all Klarna payments have to be captured. This is what triggers the invoice to be sent to the shopper. 

By default, Klarna payments need to be captured manually. If you can guarantee compliance with the Klarna scheme rules, our Support Team can also set up automatic capture for Klarna payments.

Partial captures

To partially capture a Klarna payment, specify in your call to the /capture  endpoint:

  • modificationAmount: The amount that the shopper should pay. 
  • additionalData.openinvoicedata: Price and product information for the items that the shopper should pay for, to be included on the invoice. For the partial capture to be successful, the amounts stated in openinvoicedata need to be correct. For more information, refer to Invoice lines.

If you need to use multiple partial captures, contact our Support Team, who can set this up. Multiple partial captures will create a new invoice for each capture. 

{
   "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
   "modificationAmount":{
      "currency":"SEK",
      "value":"400"
   },
   "originalReference":"8825408195409505",
   "additionalData":{
      "openinvoicedata.numberOfLines":"1",
      "openinvoicedata.line1.currencyCode":"SEK",
      "openinvoicedata.line1.description":"Shoes",
      "openinvoicedata.line1.itemAmount":"331",
      "openinvoicedata.line1.itemVatAmount":"69",
      "openinvoicedata.line1.itemVatPercentage":"2100",
      "openinvoicedata.line1.numberOfItems":"1",
      "openinvoicedata.line1.vatCategory":"High"
   }
}

You will receive a /capture response containing a pspReference associated with this request. Once we have processed your request, you will also receive a CAPTURE notification. For more information, refer to our Capture.

Refunds and cancellations

If a Klarna payment has not yet been captured, you can cancel it. If the Klarna payment has already been captured and you want to return the funds to the shopper, you need to refund it.

Partial refunds

To partially refund a Klarna payment, specify in your call to the /refund endpoint:

  • modificationAmount: The amount to be refunded to the shopper.
  • additionalData.openinvoicedata: Price and product information about the returned items. For the partial refund request to be successful, the amounts stated in openinvoicedata need to be correct. For more information, refer to Invoice lines.
{
   "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
   "modificationAmount":{
      "currency":"SEK",
      "value":"400"
   },
   "originalReference":"8825408195409505",
   "additionalData":{
      "openinvoicedata.numberOfLines":"1",
      "openinvoicedata.line1.currencyCode":"SEK",
      "openinvoicedata.line1.description":"Shoes",
      "openinvoicedata.line1.itemAmount":"331",
      "openinvoicedata.line1.itemVatAmount":"69",
      "openinvoicedata.line1.itemVatPercentage":"2100",
      "openinvoicedata.line1.numberOfItems":"1",
      "openinvoicedata.line1.vatCategory":"High"
   }
} 

You will receive a /refund response containing a pspReference associated with this request. Once we have processed your request, you will also receive a REFUND notification. For more information, refer to Refund.

Invoice lines

When you make a Klarna payment, or request a partial capture or a partial refund, you need to provide price and product information to be included on the invoice.

For a payment request, include this information in lineItems. For more information about the required fields, refer to our API Explorer.

{
   "amount":{
      "currency":"SEK",
      "value":"1000"
   },
   "lineItems":[
      {
         "quantity":"1",
         "amountExcludingTax":"331",
         "taxPercentage":"2100",
         "description":"Shoes",
         "id":"Item #1",
         "taxAmount":"69",
         "amountIncludingTax":"400",
         "taxCategory":"High"
      },
      {
         "quantity":"2",
         "amountExcludingTax":"248",
         "taxPercentage":"2100",
         "description":"Socks",
         "id":"Item #2",
         "taxAmount":"52",
         "amountIncludingTax":"300",
         "taxCategory":"High"
      }
   ]
...
}

For a partial capture or a partial refund request, include this information in the openinvoicedata fields of additionalData. For more information about the required fields, refer to our API Reference.

{
   "modificationAmount":{
      "currency":"SEK",
      "value":"1000"
   },
   "additionalData":{
      "openinvoicedata.numberOfLines":"2",
      "openinvoicedata.line1.currencyCode":"SEK",
      "openinvoicedata.line1.description":"Shoes",
      "openinvoicedata.line1.itemAmount":"331",
      "openinvoicedata.line1.itemVatAmount":"69",
      "openinvoicedata.line1.itemVatPercentage":"2100",
      "openinvoicedata.line1.numberOfItems":"1",
      "openinvoicedata.line1.vatCategory":"High"
      "openinvoicedata.line2.currencyCode":"SEK",
      "openinvoicedata.line2.description":"Socks",
      "openinvoicedata.line2.itemAmount":"248",
      "openinvoicedata.line2.itemVatAmount":"52",
      "openinvoicedata.line2.itemVatPercentage":"2100",
      "openinvoicedata.line2.numberOfItems":"2",
      "openinvoicedata.line2.vatCategory":"High"
   }
...
}

For Klarna to approve the payment, the amounts stated in the invoice lines need to be correct: 

  1. For each line item, the tax amount has to match the tax percentage, given the amount excluding tax. When using lineItems

    taxAmount = (amountExcludingTax * taxPercentage)

    When using openinvoicedata:

    itemVatAmount = (itemAmount * itemVatPercentage)

    In the example above, 69 = (331 * 0,21), and 52 = (248 * 0,21).

  2. The value specified in the amount (or modificationAmount) has to match the total amount of the invoice lines. To calculate the total amount of the invoice lines, refer to the following pseudo-code: 

    total = 0;
    
    for each (invoiceLine in lineItems) {
      total += (amountExcludingTax + taxAmount) * quantity;
    }
    
    totalValue = total;

    In the example above: (331 + 69) * 1 = 400, and (248 + 52) * 2 = 600, so totalValue = 400 + 600 = 1000.

Testing your integration

Before accepting live Klarna payments, test your integration using the test details provided in the Klarna documentation

See also