v1

latestOpenAPI 3.0.02026-07-1462248.4 KB
sessions

Create a new payment session

Use this API call to create a Klarna Payments session.<br/>When a session is created you will receive the available payment_method_categories for the session, a session_id and a client_token. The session_id can be used to read or update the session using the REST API. The client_token should be passed to the browser. Read more on Create a new payment session.

post/payments/v1/sessions

Request body

acquiring_channel'ECOMMERCE' | 'IN_STORE' | 'TELESALES'

The acquiring channel in which the session takes place. Ecommerce is default unless specified. Any other values should be defined in the agreement.

authorization_tokenstring

Authorization token.

client_tokenstring

Token to be passed to the JS client

custom_payment_method_idsstring[]

Promo codes - The array could be used to define which of the configured payment options within a payment category (pay_later, pay_over_time, etc.) should be shown for this purchase. Discuss with the delivery manager to know about the promo codes that will be configured for your account. The feature could also be used to provide promotional offers to specific customers (eg: 0% financing). Please be informed that the usage of this feature can have commercial implications.

designstring

Design package to use in the session. This can only by used if a custom design has been implemented for Klarna Payments and agreed upon in the agreement. It might have a financial impact. Delivery manager will provide the value for the parameter.

expires_atstring date-time

Session expiration date

intent'buy' | 'tokenize' | 'buy_and_tokenize'

Intent for the session. The field is designed to let partners inform Klarna of the purpose of the customer’s session.

localestring

Used to define the language and region of the customer. The locale follows the format of (RFC 1766)[https://datatracker.ietf.org/doc/rfc1766/], meaning its value consists of language-country. The following values are applicable:

AT: "de-AT", "de-DE", "en-DE" BE: "be-BE", "nl-BE", "fr-BE", "en-BE" CH: "it-CH", "de-CH", "fr-CH", "en-CH" DE: "de-DE", "de-AT", "en-DE" DK: "da-DK", "en-DK" ES: "es-ES", "ca-ES", "en-ES" FI: "fi-FI", "sv-FI", "en-FI" GB: "en-GB" IT: "it-IT", "en-IT" NL: "nl-NL", "en-NL" NO: "nb-NO", "en-NO" PL: "pl-PL", "en-PL" SE: "sv-SE", "en-SE" US: "en-US". Default value is "en-US".

merchant_datastring

Pass through field to send any information about the order to be used later for reference while retrieving the order details (max 6000 characters)

merchant_reference1string

Used for storing merchant's internal order number or other reference.

merchant_reference2string

Used for storing merchant's internal order number or other reference. The value is available in the settlement files. (max 255 characters).

order_amountinteger required

Total amount of the order including tax and any available discounts. The value should be in non-negative minor units. Eg: 25 Euros should be 2500.

order_tax_amountinteger

Total tax amount of the order. The value should be in non-negative minor units. Eg: 25 Euros should be 2500.

purchase_countrystring required

The purchase country of the customer. The billing country always overrides purchase country if the values are different. Formatted according to ISO 3166 alpha-2 standard, e.g. GB, SE, DE, US, etc.

purchase_currencystring required

The purchase currency of the order. Formatted according to ISO 4217 standard, e.g. USD, EUR, SEK, GBP, etc.

status'complete' | 'incomplete'

The current status of the session. Possible values: 'complete', 'incomplete' where 'complete' is set when the order has been placed.

Example request

{
  "acquiring_channel": "ECOMMERCE",
  "attachment": {
    "body": "{\"customer_account_info\":[{\"unique_account_identifier\":\"test@gmail.com\",\"account_registration_date\":\"2017-02-13T10:49:20Z\",\"account_last_modified\":\"2019-03-13T11:45:27Z\"}]}",
    "content_type": "application/vnd.klarna.internal.emd-v2+json"
  },
  "billing_address": {
    "attention": "Attn",
    "city": "London",
    "country": "GB",
    "email": "test.sam@test.com",
    "family_name": "Andersson",
    "given_name": "Adam",
    "phone": "+44795465131",
    "postal_code": "W1G 0PW",
    "region": "OH",
    "street_address": "33 Cavendish Square",
    "street_address2": "Floor 22 / Flat 2",
    "title": "Mr."
  },
  "client_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJzZXNzaW9uX2lkIiA6ICIw",
  "customer": {
    "date_of_birth": "1978-12-31",
    "gender": "male",
    "title": "Mr.",
    "type": "organization"
  },
  "expires_at": "2038-01-19T03:14:07.000Z",
  "intent": "buy",
  "locale": "en-US",
  "merchant_data": "{\"order_specific\":[{\"substore\":\"Women's Fashion\",\"product_name\":\"Women Sweatshirt\"}]}",
  "merchant_reference1": "ON4711",
  "merchant_reference2": "hdt53h-zdgg6-hdaff2",
  "merchant_urls": {
    "authorization": "https://www.example-url.com/authorization",
    "confirmation": "https://www.example-url.com/confirmation",
    "notification": "https://www.example-url.com/notification",
    "push": "https://www.example-url.com/push"
  },
  "options": {
    "color_border": "#FF9900",
    "color_border_selected": "#FF9900",
    "color_details": "#FF9900",
    "color_text": "#FF9900",
    "radius_border": "5px"
  },
  "order_amount": 2500,
  "order_lines": [
    {
      "image_url": "https://www.exampleobjects.com/logo.png",
      "merchant_data": "{\"customer_account_info\":[{\"unique_account_identifier\":\"test@gmail.com\",\"account_registration_date\":\"2017-02-13T10:49:20Z\",\"account_last_modified\":\"2019-03-13T11:45:27Z\"}]}",
      "name": "Running shoe",
      "product_identifiers": {
        "brand": "shoe-brand",
        "category_path": "Shoes > Running",
        "color": "white",
        "global_trade_item_number": "4912345678904",
        "manufacturer_part_number": "AD6654412-334.22",
        "size": "small"
      },
      "product_url": "https://.../AD6654412.html",
      "quantity": 1,
      "quantity_unit": "pcs",
      "reference": "AD6654412",
      "tax_rate": 1900,
      "total_amount": 2500,
      "total_discount_amount": 500,
      "total_tax_amount": 475,
      "type": "physical",
      "unit_price": 2500
    }
  ],
  "order_tax_amount": 475,
  "payment_method_categories": [
    {
      "asset_urls": {
        "descriptive": "https://x.klarnacdn.net/payment-method/assets/badges/generic/klarna.svg",
        "standard": "https://x.klarnacdn.net/payment-method/assets/badges/generic/klarna.svg"
      },
      "identifier": "klarna",
      "name": "Pay with Klarna"
    }
  ],
  "purchase_country": "GB",
  "purchase_currency": "GBP",
  "shipping_address": {
    "attention": "Attn",
    "city": "London",
    "country": "GB",
    "email": "test.sam@test.com",
    "family_name": "Andersson",
    "given_name": "Adam",
    "phone": "+44795465131",
    "postal_code": "W1G 0PW",
    "region": "OH",
    "street_address": "33 Cavendish Square",
    "street_address2": "Floor 22 / Flat 2",
    "title": "Mr."
  },
  "status": "complete"
}

Response

successful operation

client_tokenstring required

Client token to be passed to the JS client while initializing the JS SDK in the next step.

session_idstring required

ID of the created session. Please use this ID to share with Klarna for identifying any issues during integration.

Example response

{
  "client_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJzZXNzaW9uX2lkIiA6ICIw",
  "payment_method_categories": [
    {
      "asset_urls": {
        "descriptive": "https://x.klarnacdn.net/payment-method/assets/badges/generic/klarna.svg",
        "standard": "https://x.klarnacdn.net/payment-method/assets/badges/generic/klarna.svg"
      },
      "identifier": "klarna",
      "name": "Pay with Klarna"
    }
  ],
  "session_id": "0b1d9815-165e-42e2-8867-35bc03789e00"
}