Are you looking for test card numbers?

Would you like to contact support?

Payment-method icon

Klarna Component

Add Klarna to an existing Components integration.

On this page, you can find additional configuration for adding Klarna to your Components integration.

Before you begin

This page assumes you've already:

API reference

Select which endpoint you're integrating:

This is the default with Components v5.0.0 or later.
Parameter name Required Description
lineItems -white_check_mark- Price and product information about the purchased items.
Klarna will only approve the payment if the total amount specified in lineItems matches the amount.value.
You can optionally specify productUrl and imageUrl to include a link to and a picture of the purchased items in the invoice.  
shopperEmail -white_check_mark- The shopper's email address. This is where Klarna will send the payment instructions.
shopperReference -white_check_mark- A unique reference to identify the shopper (minimum length three characters).
shopperName The shopper's full name.
Recommended to increase conversion rates. If you don't include it, Klarna will ask the shopper to provide this in the checkout page.
billingAddress The postal address of the shopper.
Recommended to increase conversion rates. If you don't include it, Klarna will ask the shopper to provide this in the checkout page.
deliveryAddress The postal address where the purchased goods should be delivered. If not provided, this is the same as the billing address.
shopperLocale A combination of language code and country code to define the language of the Klarna checkout page. By default, the checkout page is rendered is English.

This has to match the countryCode and currency used in the request. For more information, see Klarna's documentation.
countryCode The shopper's country.

This has to match the country of the billingAddress.
telephoneNumber The shopper's telephone number, if provided.
additionalData.
openinvoicedata.merchantData
 
For some products or business models, Klarna might require additional information. If you need to send in this information, specify here the Base64 encoded JSON of the attachment.body value described in Klarna's documentation.
curl https://checkout-test.adyen.com/v68/sessions \
-H "x-API-key: YOUR_X-API-KEY" \
-H "content-type: application/json" \
-d '{
  "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
  "reference": "YOUR_ORDER_REFERENCE",
  "amount": {
    "currency": "SEK",
    "value": 1000
  },
  "shopperLocale": "en_US",
  "countryCode": "SE",
  "telephoneNumber": "+46 840 839 298",
  "shopperEmail": "youremail@email.com",
  "shopperName": {
    "firstName": "Testperson-se",
    "gender": "UNKNOWN",
    "lastName": "Approved"
  },
  "shopperReference": "YOUR_UNIQUE_SHOPPER_ID",
  "billingAddress": {
    "city": "Ankeborg",
    "country": "SE",
    "houseNumberOrName": "1",
    "postalCode": "12345",
    "street": "Stargatan"
  },
  "deliveryAddress": {
    "city": "Ankeborg",
    "country": "SE",
    "houseNumberOrName": "1",
    "postalCode": "12345",
    "street": "Stargatan"
  },
  "dateOfBirth": "1996-09-04",
  "socialSecurityNumber": "0108",
  "returnUrl": "https://your-company.com/checkout?shopperOrder=12xy..",
  "lineItems": [
    {
      "quantity": "1",
      "amountExcludingTax": "331",
      "taxPercentage": "2100",
      "description": "Shoes",
      "id": "Item #1",
      "taxAmount": "69",
      "amountIncludingTax": "400",
      "productUrl": "URL_TO_PURCHASED_ITEM",
      "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM"
    },
    {
      "quantity": "2",
      "amountExcludingTax": "248",
      "taxPercentage": "2100",
      "description": "Socks",
      "id": "Item #2",
      "taxAmount": "52",
      "amountIncludingTax": "300",
      "productUrl": "URL_TO_PURCHASED_ITEM",
      "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM"
    }
  ],
  "additionalData" : {
    "openinvoicedata.merchantData" : "eyJjdXN0b21lcl9hY ... "
  }
}'
Client client = new Client("Your X-API-KEY", Environment.TEST);
Checkout checkout = new Checkout(client);

CreateCheckoutSessionRequest sessionRequest = new CreateCheckoutSessionRequest();
sessionRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
sessionRequest.setReference("YOUR_ORDER_REFERENCE");

Amount amount = new Amount();
amount.setCurrency("SEK");
amount.setValue(1000L);
sessionRequest.setAmount(amount);

sessionRequest.setShopperLocale("en_US");
sessionRequest.setCountryCode("SE");
sessionRequest.setTelephoneNumber("+46 840 839 298");
sessionRequest.setShopperEmail("youremail@email.com");

Name shopperName = new Name();
shopperName.setFirstName("Testperson-se");
shopperName.setGender(Name.GenderEnum.UNKNOWN);
shopperName.setLastName("Approved");
sessionRequest.setShopperName(shopperName);

sessionRequest.setShopperReference("YOUR_UNIQUE_SHOPPER_ID");

Address billingAddress = new Address();
billingAddress.setCity("Ankeborg");
billingAddress.setCountry("SE");
billingAddress.setHouseNumberOrName("1");
billingAddress.setPostalCode("12345");
billingAddress.setStreet("Stargatan");
sessionRequest.setBillingAddress(billingAddress);

Address deliveryAddress = new Address();
deliveryAddress.setCity("Ankeborg");
deliveryAddress.setCountry("SE");
deliveryAddress.setHouseNumberOrName("1");
deliveryAddress.setPostalCode("12345");
deliveryAddress.setStreet("Stargatan");
sessionRequest.setDeliveryAddress(deliveryAddress);

sessionRequest.setDateOfBirth("1996-09-04");
sessionRequest.setSocialSecurityNumber("0108");
sessionRequest.returnUrl("https://your-company.com/checkout?shopperOrder=12xy..");

LineItem lineItem1 = new LineItem();
lineItem1.setQuantity(1L);
lineItem1.setAmountExcludingTax(331L);
lineItem1.setTaxPercentage(2100L);
lineItem1.setDescription("Shoes");
lineItem1.setId("Item #1");
lineItem1.setTaxAmount(69L);
lineItem1.setAmountIncludingTax(400L);
lineItem1.setProductUrl("URL_TO_PURCHASED_ITEM");
lineItem1.setImageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM");

LineItem lineItem2 = new LineItem();
lineItem2.setQuantity(2L);
lineItem2.setAmountExcludingTax(248L);
lineItem2.setTaxPercentage(2100L);
lineItem2.setDescription("Socks");
lineItem2.setId("Item #2");
lineItem2.setTaxAmount(52L);
lineItem2.setAmountIncludingTax(300L);
lineItem2.setProductUrl("URL_TO_PURCHASED_ITEM");
lineItem2.setImageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM");

List<LineItem> lineItems = new ArrayList<LineItem>();
lineItems.add(lineItem1);
lineItems.add(lineItem2);
sessionRequest.setLineItems(lineItems);

Map<String, String> additionalData = new HashMap<>();
additionalData.put("openinvoicedata.merchantData", "eyJjdXN0b21lcl9hY ... ");
sessionRequest.setAdditionalData(additionalData);

CreateCheckoutSessionResponse sessionResponse = checkout.sessions(sessionRequest);
var checkoutSessionRequest = new CreateCheckoutSessionRequest
{
    MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
    Reference = "YOUR_ORDER_REFERENCE",
    Amount = {
    Currency = "SEK",
    Value = 1000
    },
    ShopperLocale = "en_US",
    CountryCode = "SEK",
    TelephoneNumber = "+46 840 839 298",
    ShopperEmail = "youremail@email.com",
    ShopperName = {
    FirstName = "Testperson-se",
    Gender = Name.GenderEnum.UNKNOWN,
    LastName = "Approved"
    },
    ShopperReference = "YOUR_UNIQUE_SHOPPER_ID",
    BillingAddress = {
    City = "Ankeborg",
    Country = "SE",
    HouseNumberOrName = "1",
    PostalCode = "12345",
    Street = "Stargatan"
    },
    DeliveryAddress = {
    City = "Ankeborg",
    Country = "SE",
    HouseNumberOrName = "1",
    PostalCode = "12345",
    Street = "Stargatan"
    },
    DateOfBirth = new DateTime(1996, 09, 04),
    SocialSecurityNumber = "0108",
    ReturnUrl = "https://your-company.com/checkout?shopperOrder=12xy..",
    LineItems = new System.Collections.Generic.List<LineItem> {
    new LineItem {
      Quantity = 1,
        AmountExcludingTax = 331,
        TaxPercentage = 2100,
        Description = "Shoes",
        Id = "Item #1",
        TaxAmount = 69,
        AmountIncludingTax = 400,
        ProductUrl = "URL_TO_PURCHASED_ITEM",
        ImageUrl = "URL_TO_PICTURE_OF_PURCHASED_ITEM"
    },
    new LineItem {
      Quantity = 2,
        AmountExcludingTax = 248,
        TaxPercentage = 2100,
        Description = "Socks",
        Id = "Item #2",
        TaxAmount = 52,
        AmountIncludingTax = 300,
        ProductUrl = "URL_TO_PURCHASED_ITEM",
        ImageUrl = "URL_TO_PICTURE_OF_PURCHASED_ITEM"
    }
  },
    AdditionalData = new System.Collections.Generic.Dictionary<string, string> {
    {
      "openinvoicedata.merchantData",
      "eyJjdXN0b21lcl9hY ... "
    }
  }
};
var client = new Client("YOUR_X-API-KEY", Model.Enum.Environment.Test);
var checkout = new Checkout(client);
var createCheckoutSessionResponse = checkout.Sessions(checkoutSessionRequest);
If you implemented an advanced use case, or integrated Components before v5.0.0.
Parameter name Required Description
lineItems -white_check_mark- Price and product information about the purchased items.
Klarna will only approve the payment if the total amount specified in lineItems matches the amount.value.
You can optionally specify productUrl and imageUrl to include a link to and a picture of the purchased items in the invoice.  
shopperEmail -white_check_mark- The shopper's email address. This is where Klarna will send the payment instructions.
shopperReference -white_check_mark- A unique reference to identify the shopper (minimum length three characters).
shopperName The shopper's full name.
Recommended to increase conversion rates. If you don't include it, Klarna will ask the shopper to provide this in the checkout page.
billingAddress The postal address of the shopper.
Recommended to increase conversion rates. If you don't include it, Klarna will ask the shopper to provide this in the checkout page.
deliveryAddress The postal address where the purchased goods should be delivered. If not provided, this is the same as the billing address.
shopperLocale A combination of language code and country code to define the language of the Klarna checkout page. By default, the checkout page is rendered is English.

This has to match the countryCode and currency used in the request. For more information, see Klarna's documentation.
countryCode The shopper's country.

This has to match the country of the billingAddress.
telephoneNumber The shopper's telephone number, if provided.
additionalData.
openinvoicedata.merchantData
 
For some products or business models, Klarna might require additional information. If you need to send in this information, specify here the Base64 encoded JSON of the attachment.body value described in Klarna's documentation.
curl https://checkout-test.adyen.com/v67/payments \
-H "x-API-key: YOUR_X-API-KEY" \
-H "content-type: application/json" \
-d '{
   "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
   "reference":"YOUR_ORDER_REFERENCE",
   "paymentMethod":{
      "type":"klarna"
   },
   "amount":{
      "currency":"SEK",
      "value": 1000
   },
   "shopperLocale":"en_US",
   "countryCode":"SE",
   "telephoneNumber": "+46 840 839 298",
   "shopperEmail":"youremail@email.com",
   "shopperName":{
      "firstName":"Testperson-se",
      "gender":"UNKNOWN",
      "lastName":"Approved"
   },
   "shopperReference":"YOUR_UNIQUE_SHOPPER_ID",
   "billingAddress":{
      "city":"Ankeborg",
      "country":"SE",
      "houseNumberOrName":"1",
      "postalCode":"12345",
      "street":"Stargatan"
   },
   "deliveryAddress":{
      "city":"Ankeborg",
      "country":"SE",
      "houseNumberOrName":"1",
      "postalCode":"12345",
      "street":"Stargatan"
   },
   "returnUrl":"",
   "lineItems":[
      {
         "quantity":"1",
         "amountExcludingTax":"331",
         "taxPercentage":"2100",
         "description":"Shoes",
         "id":"Item #1",
         "taxAmount":"69",
         "amountIncludingTax":"400",
         "productUrl": "URL_TO_PURCHASED_ITEM",
         "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM"
      },
      {
         "quantity":"2",
         "amountExcludingTax":"248",
         "taxPercentage":"2100",
         "description":"Socks",
         "id":"Item #2",
         "taxAmount":"52",
         "amountIncludingTax":"300",
         "productUrl": "URL_TO_PURCHASED_ITEM",
         "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM"
      }
   ],
   "additionalData" : {
     "openinvoicedata.merchantData" : "eyJjdXN0b21lcl9hY ... "
   }
}'
# Set your X-API-KEY with the API key from the Customer Area.
adyen = Adyen::Client.new
adyen.env = :test
adyen.api_key = "YOUR_X-API-KEY"

response = adyen.checkout.payments({
  :merchantAccount => "YOUR_MERCHANT_ACCOUNT",
  :reference => "YOUR_ORDER_NUMBER",
  :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"
  },
  :telephoneNumber => "+46 840 839 298",
  :shopperReference => "YOUR_UNIQUE_SHOPPER_ID",
  :billingAddress => {
    :city => "Ankeborg",
    :country => "SE",
    :houseNumberOrName => "1",
    :postalCode => "12345",
    :street => "Stargatan"
  },
  :deliveryAddress => {
    :city => "Ankeborg",
    :country => "SE",
    :houseNumberOrName => "1",
    :postalCode => "12345",
    :street => "Stargatan"
  },
  :returnUrl => "",
  :lineItems => [
    {
      :quantity => "1",
      :amountExcludingTax => "331",
      :taxPercentage => "2100",
      :description => "Shoes",
      :id => "Item #1",
      :taxAmount => "69",
      :amountIncludingTax => "400",
      :productUrl => "URL_TO_PURCHASED_ITEM",
      :imageUrl => "URL_TO_PICTURE_OF_PURCHASED_ITEM"
    },
    {
      :quantity => "2",
      :amountExcludingTax => "248",
      :taxPercentage => "2100",
      :description => "Socks",
      :id => "Item #2",
      :taxAmount => "52",
      :amountIncludingTax => "300",
      :productUrl => "URL_TO_PURCHASED_ITEM",
      :imageUrl => "URL_TO_PICTURE_OF_PURCHASED_ITEM"
    }
  ],
  :additionalData => {
    :openinvoicedata.merchantData => "eyJjdXN0b21lcl9hY ... "
  }
})
// Create a Client to establish a connection to our services with your API Key from the Customer Area.
Client client = new Client("YOUR_API_KEY", Environment.TEST);

Checkout checkout = new Checkout(client);

PaymentsRequest paymentsRequest = new PaymentsRequest();

paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT");
paymentsRequest.setReference("YOUR_ORDER_REFERENCE");

PaymentMethodDetails paymentMethodDetails = new DefaultPaymentMethodDetails();
paymentMethodDetails.setType("klarna");

paymentsRequest.setPaymentMethod(paymentMethodDetails);

Amount amount = new Amount();
amount.setCurrency("SEK");
amount.setValue(1000L);

paymentsRequest.setAmount(amount);
paymentsRequest.setShopperLocale("en_US");
paymentsRequest.setCountryCode("SE");
paymentsRequest.setTelephoneNumber("+46 840 839 298");
paymentsRequest.setShopperEmail("youremail@email.com");

Name shopperDetails = new Name();
shopperDetails.setFirstName("TestPerson-Se");
shopperDetails.setGender(Name.GenderEnum.UNKNOWN);
shopperDetails.setLastName("Approved");

paymentsRequest.setShopperName(shopperDetails);
paymentsRequest.setShopperReference("YOUR_UNIQUE_SHOPPER_ID");

Address billingAddress = new Address();
billingAddress.setCity("Ankeborg");
billingAddress.setCountry("SE");
billingAddress.setHouseNumberOrName("1");
billingAddress.setPostalCode("12345");
billingAddress.setStreet("Stargatan");

paymentsRequest.setBillingAddress(billingAddress);

Address deliveryAddress = new Address();
deliveryAddress.setCity("Ankeborg");
deliveryAddress.setCountry("SE");
deliveryAddress.setHouseNumberOrName("1");
deliveryAddress.setPostalCode("12345");
deliveryAddress.setStreet("Stargatan");

paymentsRequest.setdeliveryAddress(deliveryAddress);
paymentsRequest.setReturnUrl("");

List<LineItem> lineItems = new ArrayList<>();
lineItems.add(
        new LineItem()
                .quantity(1L)
                .amountExcludingTax(331L)
                .taxPercentage(2100L)
                .description("Shoes")
                .id("Item #1")
                .taxAmount(69L)
                .amountIncludingTax(400L)
                .productUrl("URL_TO_PURCHASED_ITEM")
                .imageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM")
);
lineItems.add(
        new LineItem()
                .quantity(2L)
                .amountExcludingTax(248L)
                .taxPercentage(2100L)
                .description("Socks")
                .id("Item #2")
                .taxAmount(52L)
                .amountIncludingTax(300L)
                .productUrl("URL_TO_PURCHASED_ITEM")
                .imageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM")
);

paymentsRequest.setLineItems(lineItems);

Map<String, String> additionalData = new HashMap<>();
additionalData.put("openinvoicedata.merchantData", "eyJjdXN0b21lcl9hY ...");

paymentsRequest.setAdditionalData(additionalData);

PaymentsResponse paymentsResponse = checkout.payments(paymentsRequest);
// Set your X-API-KEY with the API key from the Customer Area.
$client = new \Adyen\Client();
$client->setXApiKey("YOUR_X-API-KEY");
$service = new \Adyen\Service\Checkout($client);

$params = [
  "merchantAccount" => "YOUR_MERCHANT_ACCOUNT",
  "reference" => "YOUR_ORDER_REFERENCE",
  "paymentMethod" => [
     "type" => "klarna"
  ],
  "amount" => [
     "currency" => "SEK",
     "value" => "1000"
  ],
  "shopperLocale" => "en_US",
  "countryCode" => "SE",
  "telephoneNumber" => "+46 840 839 298",
  "shopperEmail" => "youremail@email.com",
  "shopperName" => [
     "firstName" => "Testperson-se",
     "gender" => "UNKNOWN",
     "lastName" => "Approved"
  ],
  "shopperReference" => "YOUR_UNIQUE_SHOPPER_ID",
  "billingAddress" => [
     "city" => "Ankeborg",
     "country" => "SE",
     "houseNumberOrName" => "1",
     "postalCode" => "12345",
     "street" => "Stargatan"
  ],
  "deliveryAddress" => [
     "city" => "Ankeborg",
     "country" => "SE",
     "houseNumberOrName" => "1",
     "postalCode" => "12345",
     "street" => "Stargatan"
  ],
  "returnUrl" => "",
  "lineItems" => [
     [
        "quantity" => "1",
        "amountExcludingTax" => "331",
        "taxPercentage" => "2100",
        "description" => "Shoes",
        "id" => "Item #1",
        "taxAmount" => "69",
        "amountIncludingTax" => "400",
        "productUrl" => "URL_TO_PURCHASED_ITEM",
        "imageUrl" => "URL_TO_PICTURE_OF_PURCHASED_ITEM"
     ],
     [
        "quantity" => "2",
        "amountExcludingTax" => "248",
        "taxPercentage" => "2100",
        "description" => "Socks",
        "id" => "Item #2",
        "taxAmount" => "52",
        "amountIncludingTax" => "300",
        "productUrl" => "URL_TO_PURCHASED_ITEM",
        "imageUrl" => "URL_TO_PICTURE_OF_PURCHASED_ITEM"
     ]
  ],
  "additionalData" => [
    "openinvoicedata.merchantData" => "eyJjdXN0b21lcl9hY ... "
  ]
];

$result = $service->payments($params);

// Check if further action is needed
if (array_key_exists("action", $result)){
   // Pass the action object to your frontend.
   // $result["action"]
}
else {
   // No further action needed, pass the resultCode to your front end
   // $result['resultCode']
}
# Set your X-API-KEY with the API key from the Customer Area.
adyen = Adyen.Adyen()
adyen.client.xapikey = 'YOUR_X-API-KEY'

result = adyen.checkout.payments({
  "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
  "reference": "YOUR_ORDER_REFERENCE",
  "paymentMethod": {
    "type": "klarna"
  },
  "amount": {
    "currency": "SEK",
    "value": 1000
  },
  "shopperLocale": "en_US",
  "countryCode": "SE",
  "telephoneNumber": "+46 840 839 298",
  "shopperEmail": "youremail@email.com",
  "shopperName": {
    "firstName": "Testperson-se",
    "gender": "UNKNOWN",
    "lastName": "Approved"
  },
  "shopperReference": "YOUR_UNIQUE_SHOPPER_ID",
  "billingAddress": {
    "city": "Ankeborg",
    "country": "SE",
    "houseNumberOrName": "1",
    "postalCode": "12345",
    "street": "Stargatan"
  },
  "deliveryAddress": {
    "city": "Ankeborg",
    "country": "SE",
    "houseNumberOrName": "1",
    "postalCode": "12345",
    "street": "Stargatan"
  },
  "returnUrl": "",
  "lineItems": [
    {
      "quantity": "1",
      "amountExcludingTax": "331",
      "taxPercentage": "2100",
      "description": "Shoes",
      "id": "Item #1",
      "taxAmount": "69",
      "amountIncludingTax": "400",
      "productUrl": "URL_TO_PURCHASED_ITEM",
      "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM"
    },
    {
      "quantity": "2",
      "amountExcludingTax": "248",
      "taxPercentage": "2100",
      "description": "Socks",
      "id": "Item #2",
      "taxAmount": "52",
      "amountIncludingTax": "300",
      "productUrl": "URL_TO_PURCHASED_ITEM",
      "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM"
    }
  ],
  "additionalData": {
    "openinvoicedata.merchantData": "eyJjdXN0b21lcl9hY ... "
  }
})
// Set your X-API-KEY with the API key from the Customer Area.
var client = new Client ("YOUR_X-API-KEY", Environment.Test);
var checkout = new Checkout(client);

var paymentRequest = new Adyen.Model.Checkout.PaymentRequest
{
   MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
   Reference = "YOUR_ORDER_REFERENCE",
   PaymentMethod = new DefaultPaymentMethodDetails { Type = "klarna" },
   Amount = new Model.Checkout.Amount(Currency: "SEK", Value: 1000),
   ShopperLocale = "en_US",
   CountryCode = "SE",
   TelephoneNumber = "+46 840 839 298",
   ShopperEmail = "youremail@email.com",
   ShopperName = new Model.Checkout.Name
   {
       FirstName = "Testperson-se",
       Gender = Model.Checkout.Name.GenderEnum.UNKNOWN,
       LastName = "Approved"
   },
   ShopperReference = "YOUR_UNIQUE_SHOPPER_ID",
   BillingAddress = new Model.Checkout.Address
   {
       City = "Ankeborg",
       Country = "SE",
       HouseNumberOrName = "1",
       PostalCode = "12345",
       Street = "Stargatan"
   },
   DeliveryAddress = new Model.Checkout.Address
   {
       City = "Ankeborg",
       Country = "SE",
       HouseNumberOrName = "1",
       PostalCode = "12345",
       Street = "Stargatan"
   },
   ReturnUrl = "",
   LineItems = new List<LineItem>
{
   new LineItem(Quantity:1, AmountExcludingTax:331, TaxPercentage:2100,
   Description:"Shoes", Id:"Item #1", TaxAmount:69, AmountIncludingTax:400, ProductUrl:"URL_TO_PURCHASED_ITEM", ImageUrl:"URL_TO_PICTURE_OF_PURCHASED_ITEM"),
   new LineItem(Quantity:2, AmountExcludingTax:248, TaxPercentage:2100,
   Description:"Socks", Id:"Item #2", TaxAmount:52, AmountIncludingTax:300, ProductUrl:"URL_TO_PURCHASED_ITEM", ImageUrl:"URL_TO_PICTURE_OF_PURCHASED_ITEM"),
},
   AdditionalData = new Dictionary<string, string> { { "openinvoicedata.merchantData", "eyJjdXN0b21lcl9hY ... " } }
};
return paymentRequest;
}
// Set your X-API-KEY with the API key from the Customer Area.
const {Client, Config, CheckoutAPI} = require('@adyen/api-library');
const config = new Config();
// Set your X-API-KEY with the API key from the Customer Area.
config.apiKey = '[API_KEY]';
config.merchantAccount = '[MERCHANT_ACCOUNT]';
const client = new Client({ config });
client.setEnvironment("TEST");
const checkout = new CheckoutAPI(client);
checkout.payments({
  merchantAccount: "YOUR_MERCHANT_ACCOUNT",
  reference: "YOUR_ORDER_REFERENCE",
  paymentMethod: {
     type: "klarna"
  },
  amount: {
     currency: "SEK",
     value: "1000"
  },
  shopperLocale: "en_US",
  countryCode: "SE",
  telephoneNumber: "+46 840 839 298",
  shopperEmail: "youremail@email.com",
  shopperName: {
     firstName: "Testperson-se",
     gender: "UNKNOWN",
     lastName: "Approved"
  },
  shopperReference: "YOUR_UNIQUE_SHOPPER_ID",
  billingAddress: {
     city: "Ankeborg",
     country: "SE",
     houseNumberOrName: "1",
     postalCode: "12345",
     street: "Stargatan"
  },
  deliveryAddress: {
     city: "Ankeborg",
     country: "SE",
     houseNumberOrName: "1",
     postalCode: "12345",
     street: "Stargatan"
  },
  returnUrl: "",
  lineItems: [
     {
        quantity: "1",
        amountExcludingTax: "331",
        taxPercentage: "2100",
        description: "Shoes",
        id: "Item 1",
        taxAmount: "69",
        amountIncludingTax: "400",
        productUrl: "URL_TO_PURCHASED_ITEM",
        imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM"
     },
     {
        quantity: "2",
        amountExcludingTax: "248",
        taxPercentage: "2100",
        description: "Socks",
        id: "Item 2",
        taxAmount: "52",
        amountIncludingTax: "300",
        productUrl: "URL_TO_PURCHASED_ITEM",
        imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM"
     }
  ],
  additionalData: {
    "openinvoicedata.merchantData": "eyJjdXN0b21lcl9hY ... "
  }
}).then(res => res);

Component configuration

When creating an instance of the Klarna Component, specify which Klarna payment method type you want to use. To see in which countries the different payment method types are available, refer to Supported countries.

  • klarna_paynow for Klarna — Pay Now.
  • klarna for Klarna — Pay later.
  • klarna_account for Klarna — Pay over time.

Step 1: Create a DOM element

Create a DOM element on your checkout page, placing it where you want the payment method form to be rendered:

 <div id="klarna_paynow-container"></div>

Step 2: Create an instance of the Component

Use the create method of your AdyenCheckout instance, in this case checkout, to create the Component:

const klarnaPayNowComponent = checkout.create('klarna_paynow').mount('#klarna_paynow-container');

Capture the payment

All Klarna payments have to be manually captured within 90 days after authorisation, even if you have enabled automatic capture on your merchant account.

If you can guarantee that the goods are shipped within 24 hours of capturing the payment, our Support Team can also set up automatic capture for Klarna payments.

Manual captures

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

  • merchantAccount: The name of your merchant account that is used to process the payment.
  • modificationAmount: The amount that the shopper should pay. This must be the same as the authorised amount.
  • originalReference: The original pspReference of the payment that you want to capture. This reference is returned in the response to your payment request, and in the AUTHORISATION notification.
  • additionalData.openinvoicedata: Information to include on the invoice:

    Price and product information

    Although some of the field names are different, the information in additionalData.openinvoicedata is the same as what you provided in lineItems when making a /payments request. The following table shows how the fields correspond.
    openinvoicedata Corresponds with Description Required
    itemAmount lineItems.amountExcludingTax The price for one item, without the tax, in minor units. -white_check_mark-
    itemVatPercentage lineItems.taxPercentage The tax percentage, in minor units. -white_check_mark-
    itemVatAmount lineItems.taxAmount The tax amount for one item, in minor units.

    Shipping and tracking information (optional)

    You can optionally use additionalData.openinvoicedata to include shipping and tracking information. This adds information about how the products are shipped to the deliveryAddress that you specified in the /payments request. The shipping and tracking information maps to Klarna's shipping info object. If you have the shipping and tracking information at the time of the capture, we recommend that you send it as it will improve the overall shopper experience. Klarna includes this information in their app, where the info is updated based on the tracking details.
    • If all items are shipped with the same provider, specify the shipping and tracking information once, as shown in the capture example below.
    • If one or more items in the order are shipped with different a different provider or tracking details, specify the shipping and tracking information as an array.
    • You cannot specify different delivery addresses for a single order with multiple items.
    openinvoicedata Corresponds with Klarna's shipping_info object Description
    shippingCompany shipping_company The name of the shipping company, as specific as possible. Maximum 100 characters. If there are multiple shipping companies, specify an array. For example: DHL SE or [DHL SE, PostNord]
    shippingMethod shipping_method Shipping method. Possible values:
    • PickUpStore
    • Home
    • BoxReg
    • BoxUnreg
    • PickUpPoint
    • Own
    • Postal
    • DHLPackstation
    • Digital
    • Undefined
    trackingNumber tracking_number Tracking number for the shipment. Maximum 100 characters. If there are multiple tracking numbers, specify an array. For example: 050823 or [050823, 050824]
    trackingUri tracking_uri URI where the customer can track their shipment. Maximum 1024 characters.
    returnShippingCompany return_shipping_company The name of the shipping company for the return shipment, as specific as possible. Maximum 100 characters. For example: DHL SE
    returnTrackingNumber return_tracking_number Tracking number for the return shipment. Maximum 100 characters.
    returnTrackingUri return_tracking_uri URI where the customer can track their return shipment. Maximum 1024 characters.

/capture request
{
   "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
   "modificationAmount":{
      "currency":"SEK",
      "value":"1000"
   },
   "originalReference":"COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
   "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.productUrl":"URL_TO_PURCHASED_ITEM",
      "openinvoicedata.line1.imageUrl":"URL_TO_PICTURE_OF_PURCHASED_ITEM",
      "openinvoicedata.line1.shippingCompany": "DHL SE",
      "openinvoicedata.line1.shippingMethod": "Home",
      "openinvoicedata.line1.trackingNumber": "TRACKING_NUMBER",
      "openinvoicedata.line1.trackingUri": "TRACKING_URI",
      "openinvoicedata.line1.returnShippingCompany": "DHL SE",
      "openinvoicedata.line1.returnTrackingNumber": "RETURN_TRACKING_NUMBER",
      "openinvoicedata.line1.returnTrackingUri": "RETURN_TRACKING_URI",
      "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.productUrl":"URL_TO_PURCHASED_ITEM",
      "openinvoicedata.line2.imageUrl":"URL_TO_PICTURE_OF_PURCHASED_ITEM"
   },
   "reference":"YOUR_CAPTURE_REFERENCE"
}

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 Capture.

Partial captures

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

  • modificationAmount: The amount that the shopper should pay. This should be less than the authorised amount.
  • additionalData.openinvoicedata: Price, product and optionally shipping and tracking 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. You can use the same fields as listed in the manual captures section.

For more information and an example, refer to Invoice lines.

Pending and refused payments

When a payment is refused by Klarna, the shopper sees the following message:


If processing in the United States, you can receive a status of Pending or Received. This means that Klarna has not confirmed the final status of the payment yet, for example because of suspected fraud. If the payment is not authorised within 24 hours, it is automatically cancelled. In this case, you receive a notification with:

  • eventCode: AUTHORISATION
  • success: false

Recurring payments

To make recurring Klarna payments you need to:

  1. Create a shopper token.
  2. Use the token to make future payments for the shopper.
Not all Klarna payment methods or countries support recurring payments. For information about the availability of recurring payments, refer to Klarna documentation.

Create a token

To create a token, include in your /payments request:

  • storePaymentMethod: true
  • shopperReference: Your unique identifier for the shopper.

When the payment has been settled, you receive a notification webhook containing:

  • eventCode: RECURRING_CONTRACT
  • originalReference: The pspReference of the initial payment.
  • pspReference: This is the token that you need to make recurring payments for this shopper.
Make sure that your server is able to receive RECURRING_CONTRACT as part of your standard notifications. If you have not requested this additional configuration yet, contact our Support Team.

RECURRING_CONTRACT notification
  {
     "live":"false",
     "notificationItems":[
        {
           "NotificationRequestItem":{
              "additionalData":{
                 "shopperEmail":"youremail@email.com",
                 "shopperReference":"YOUR_UNIQUE_SHOPPER_ID"
              },
              "amount":{
                 "currency":"SEK",
                 "value":1000
              },
              "eventCode":"RECURRING_CONTRACT",
              "eventDate":"2019-11-27T16:41:42+01:00",
              "merchantAccountCode":"YOUR_MERCHANT_ACCOUNT",
              "merchantReference":"TestRef",
              "originalReference":"8515748691833061",
              "paymentMethod":"klarna_paynow",
              "{hint:The token for making recurring payments}pspReference{/hint}":"8315748692943051",
              "reason":"",
              "success":"true"
           }
        }
     ]
  }

Make a payment with a token

To make a payment with the token, include in your /payments request:

  • shopperReference: The unique shopper identifier that you specified when creating the token.
  • paymentMethod.storedPaymentMethodId: The pspReference from the RECURRING_CONTRACT notification. You can also get this value by using the /listRecurringDetails endpoint.
  • shopperInteractionContAuth.
  • recurringProcessingModel: The type of recurring payment that you want to make. Possible values:
recurringProcessingModel Description
CardOnFile Online purchase where shopper is actively making a purchase using their previously stored payment details.
Subscription A series of transactions with fixed or variable amounts, following a fixed time interval. This is the default value for payment requests where shopperInteractionContAuth.
UnscheduledCardOnFile Contracts that occur on a non-fixed schedule using stored payment details. For example, automatic top-ups when cardholder's balance drops below certain amount.
When making a recurring payment, you also need to provide all the parameters required for a Klarna payment request.

A sample request for Klarna — Pay now, when the shopper is actively making a purchase using previously stored payment details:

/payments request
  {
    "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
    "reference":"YOUR_ORDER_REFERENCE",
    "paymentMethod":{
       "type":"klarna_paynow",
       "{hint:The pspReference from the RECURRING_CONTRACT notification}storedPaymentMethodId{/hint}":"8315748692943051"
    },
    "{hint:The shopperReference that you specified when creating the token}shopperReference{/hint}":"YOUR_UNIQUE_SHOPPER_ID",
    "amount":{
       "currency":"SEK",
       "value":"1000"
    },
    "shopperInteraction":"ContAuth",
    "recurringProcessingModel": "CardOnFile",
    "shopperLocale":"en_US",
    "countryCode":"SE",
    "telephoneNumber": "+46 840 839 298",
    "shopperEmail":"youremail@email.com",
    "shopperName":{
       "firstName":"Testperson-se",
       "gender":"UNKNOWN",
       "lastName":"Approved"
    },
    "billingAddress":{
       "city":"Ankeborg",
       "country":"SE",
       "houseNumberOrName":"1",
       "postalCode":"12345",
       "street":"Stargatan"
    },
    "deliveryAddress":{
      "city":"Ankeborg",
      "country":"SE",
      "houseNumberOrName":"1",
      "postalCode":"12345",
      "street":"Stargatan"
    },
    "returnUrl":"https://your-company.com/checkout?shopperOrder=12xy..",
    "lineItems":[
       {
          "quantity":"1",
          "amountExcludingTax":"331",
          "taxPercentage":"2100",
          "description":"Shoes",
          "id":"Item #1",
          "taxAmount":"69",
          "amountIncludingTax":"400",
          "productUrl": "URL_TO_PURCHASED_ITEM",
          "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM"
       },
       {
          "quantity":"2",
          "amountExcludingTax":"248",
          "taxPercentage":"2100",
          "description":"Socks",
          "id":"Item #2",
          "taxAmount":"52",
          "amountIncludingTax":"300",
          "productUrl": "URL_TO_PURCHASED_ITEM",
          "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM"
       }
    ]
  }

Test and go live

Before accepting live payments, test your integration using the test environment and sample data provided by Klarna.
You can then check the status of Klarna test payments in your Customer Area > Transactions > Payments.

Before you go live

Make sure that:

  • You have considered Klarna's legal and privacy information.
  • You follow the Klarna guidelines on how to display Klarna in your checkout.
  • The invoice lines and VAT are displayed correctly on Klarna's pages.
  • If a shopper gets rejected by Klarna, you offer them another payment method.
  • You pass the shopper's name and address in your payment request. While optional, providing these parameters improves the shopper experience and increases conversion rates.

Testing in live environment

If you are going to test Klarna payments once you are in the live environment, make sure that you:

  • Provide real shopper data. For example, your real name, personal email, personal mobile, and home and billing address. Don't provide a company address as billing address.
  • Choose an item with a reasonable amount that meets Klarna's minimum requirements. For example, for Pay over time, Klarna requires a minimum amount of 35 GBP. Klarna can reject a request if the product is too expensive and they do not have enough transaction history for the shopper.
  • Don't perform multiple tests in a short span of time from the same device or IP address. This will trigger velocity rule checks, which will lead to the transaction being rejected.

If the conditions above are not met, you might receive a resultCode of Refused . The shopper sees a page with an "Option Not Available" message instead of the Klarna Payments widget. Note that these checks are bypassed in test and are only applied in the live environment.

See also