Klarna Payments API V1 (1.0.0)

Download OpenAPI specification:Download

The payments API is used to create a session to offer Klarna's payment methods as part of your checkout. As soon as the purchase is completed the order should be read and handled using the Order Management API.

Note: Examples provided in this section includes full payloads, including all supported fields , required and optionals. In order to implement a best in class request we recommend you don't include customer details when initiating a payment session. Refer to Initiate a payment section for further details.

Read more on Klarna payments.

Create a session

Use this API call to create a Klarna Payments session.
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.

Request
Request Body schema: application/json
required

session_request

acquiring_channel
string

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

Enum: "ECOMMERCE" "IN_STORE" "TELESALES"
object (attachment)
object (address)
custom_payment_method_ids
Array of strings

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.

object (customer)
design
string

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.

locale
string^[A-Za-z]{2,2}(?:-[A-Za-z]{2,2})*$

Used to define the language and region of the customer. The locale follows the format of RFC 1766, meaning its value consists of language-country. Default value is "en-US". Read more on Supported Locals and Currencies.

merchant_data
string [ 0 .. 6000 ] characters

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_reference1
string [ 0 .. 255 ] characters

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

merchant_reference2
string [ 0 .. 255 ] characters

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

object (merchant_urls)
object (options)
order_amount
required
integer <int64> >= 0

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.

required
Array of objects (order_line) [ 1 .. 1000 ] items

The array containing list of line items that are part of this order. Maximum of 1000 line items could be processed in a single order.

order_tax_amount
integer <int64> >= 0

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

purchase_country
required
string^[A-Za-z]{2,2}$

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_currency
required
string^[A-Za-z]{3,3}$

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

object (address)
intent
string

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

Enum: "buy" "tokenize" "buy_and_tokenize"
Responses
200

successful operation

400

We were unable to create a session with the provided data. Some field constraint was violated.

403

You were not authorized to execute this operation.

post/payments/v1/sessions
Request samples
application/json
{
  • "acquiring_channel": "ECOMMERCE",
  • "attachment": {
    },
  • "billing_address": {
    },
  • "custom_payment_method_ids": [
    ],
  • "customer": {
    },
  • "design": "string",
  • "locale": "en-US",
  • "merchant_data": "{\"order_specific\":[{\"substore\":\"Women's Fashion\",\"product_name\":\"Women Sweatshirt\"}]}",
  • "merchant_reference1": "ON4711",
  • "merchant_reference2": "hdt53h-zdgg6-hdaff2",
  • "options": {
    },
  • "order_amount": 2000,
  • "order_lines": [
    ],
  • "order_tax_amount": 333,
  • "purchase_country": "GB",
  • "purchase_currency": "GBP",
  • "shipping_address": {
    },
  • "intent": "buy"
}
Response samples
application/json
{}

Update a session

Use this API call to update a Klarna Payments session with new details, in case something in the order has changed and the checkout has been reloaded. Including if the consumer adds a new item to the cart or if consumer details are updated. Read more on Update an existing payment session.

Request
path Parameters
session_id
required
string

session_id

Request Body schema: application/json
required

session_request

acquiring_channel
string

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

Enum: "ECOMMERCE" "IN_STORE" "TELESALES"
object (attachment)
object (address)
custom_payment_method_ids
Array of strings

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.

object (customer)
design
string

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.

locale
string^[A-Za-z]{2,2}(?:-[A-Za-z]{2,2})*$

Used to define the language and region of the customer. The locale follows the format of RFC 1766, meaning its value consists of language-country. Read more on Supported Locals and Currencies.

merchant_data
string [ 0 .. 6000 ] characters

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_reference1
string [ 0 .. 255 ] characters

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

merchant_reference2
string [ 0 .. 255 ] characters

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

object (merchant_urls)
object (options)
order_amount
integer <int64> >= 0

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.

Array of objects (order_line) [ 1 .. 1000 ] items

The array containing list of line items that are part of this order. Maximum of 1000 line items could be processed in a single order.

order_tax_amount
integer <int64> >= 0

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

purchase_country
string^[A-Za-z]{2,2}$

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_currency
string^[A-Za-z]{3,3}$

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

object (address)
intent
string

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

Enum: "buy" "tokenize" "buy_and_tokenize"
Responses
204

The session was updated successfully.

400

We were unable to update the session with the provided data. Some field constraint was violated.

403

You were not authorized to execute this operation.

404

The session does not exist.

post/payments/v1/sessions/{session_id}
Request samples
application/json
{
  • "acquiring_channel": "ECOMMERCE",
  • "attachment": {
    },
  • "billing_address": {
    },
  • "custom_payment_method_ids": [
    ],
  • "customer": {
    },
  • "design": "string",
  • "locale": "en-GB",
  • "merchant_data": "{\"order_specific\":[{\"substore\":\"Women's Fashion\",\"product_name\":\"Women Sweatshirt\"}]}",
  • "merchant_reference1": "ON4711",
  • "merchant_reference2": "hdt53h-zdgg6-hdaff2",
  • "options": {
    },
  • "order_amount": 2000,
  • "order_lines": [
    ],
  • "order_tax_amount": 333,
  • "purchase_country": "GB",
  • "purchase_currency": "GBP",
  • "shipping_address": {
    },
  • "intent": "buy"
}

Get details about a session

Use this API call to get a Klarna Payments session. You can read the Klarna Payments session at any time after it has been created, to get information about it. This will return all data that has been collected during the session. Read more on Read an existing payment session.

Request
path Parameters
session_id
required
string

session_id

Responses
200

successful operation

403

You were not authorized to execute this operation.

404

The session does not exist.

get/payments/v1/sessions/{session_id}
Request samples
Response samples
application/json
{
  • "acquiring_channel": "ECOMMERCE",
  • "attachment": {
    },
  • "authorization_token": "string",
  • "billing_address": {
    },
  • "client_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJzZXNzaW9uX2lkIiA6ICIw",
  • "custom_payment_method_ids": [
    ],
  • "customer": {
    },
  • "design": "string",
  • "expires_at": "2038-01-19T03:14:07.000Z",
  • "locale": "en-GB",
  • "merchant_data": "{\"order_specific\":[{\"substore\":\"Women's Fashion\",\"product_name\":\"Women Sweatshirt\"}]}",
  • "merchant_reference1": "ON4711",
  • "merchant_reference2": "hdt53h-zdgg6-hdaff2",
  • "options": {
    },
  • "order_amount": 2000,
  • "order_lines": [
    ],
  • "order_tax_amount": 333,
  • "payment_method_categories": [],
  • "purchase_country": "GB",
  • "purchase_currency": "GBP",
  • "shipping_address": {
    },
  • "status": "complete",
  • "intent": "buy"
}

Cancel an authorization

Use this API call to cancel/release an authorization. If the authorization_token received during a Klarna Payments won’t be used to place an order immediately you could release the authorization. Read more on Cancel an existing authorization.

Request
path Parameters
authorizationToken
required
string
Responses
204

The authorization was cancelled successfully.

403

You were not authorized to execute this operation.

404

The authorization does not exist.

delete/payments/v1/authorizations/{authorizationToken}
Request samples

Create an order

Use this API call to create a new order. Placing an order towards Klarna means that the Klarna Payments session will be closed and that an order will be created in Klarna's system.
When you have received the authorization_token for a successful authorization you can place the order. Among the other order details in this request, you include a URL to the confirmation page for the customer.
When the Order has been successfully placed at Klarna, you need to handle it either through the Merchant Portal or using Klarna’s Order Management API. Read more on Create a new order.

Request
path Parameters
authorizationToken
required
string
Request Body schema: application/json
auto_capture
boolean
Default: false

Allow merchant to trigger auto capturing.

object (address)
custom_payment_method_ids
Array of strings

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.

object (customer)
locale
string^[A-Za-z]{2,2}(?:-[A-Za-z]{2,2})*$

Used to define the language and region of the customer. The locale follows the format of RFC 1766, meaning its value consists of language-country. Read more on Supported Locals and Currencies.

merchant_data
string [ 0 .. 6000 ] characters

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_reference1
string [ 0 .. 255 ] characters

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

merchant_reference2
string [ 0 .. 255 ] characters

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

object (merchant_urls)
order_amount
required
integer <int64> >= 0

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.

required
Array of objects (order_line) [ 1 .. 1000 ] items

The array containing list of line items that are part of this order. Maximum of 1000 line items could be processed in a single order.

order_tax_amount
integer <int64> >= 0

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

purchase_country
required
string^[A-Za-z]{2,2}$

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_currency
required
string^[A-Za-z]{3,3}$

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

object (address)
Responses
200

Order was successfully created.

400

We were unable to create an order with the provided data. Some field constraint was violated.

403

You were not authorized to execute this operation.

404

The authorization does not exist.

409

The data in the request does not match the session for the authorization.

post/payments/v1/authorizations/{authorizationToken}/order
Request samples
application/json
{
  • "auto_capture": false,
  • "billing_address": {
    },
  • "custom_payment_method_ids": [
    ],
  • "customer": {
    },
  • "locale": "en-GB",
  • "merchant_data": "{\"order_specific\":[{\"substore\":\"Women's Fashion\",\"product_name\":\"Women Sweatshirt\"}]}",
  • "merchant_reference1": "ON4711",
  • "merchant_reference2": "hdt53h-zdgg6-hdaff2",
  • "order_amount": 2000,
  • "order_lines": [
    ],
  • "order_tax_amount": 333,
  • "purchase_country": "GB",
  • "purchase_currency": "GBP",
  • "shipping_address": {
    }
}
Response samples
application/json
{}

Generate a customer token

Use this API call to create a Klarna Customer Token.
After having obtained an authorization_token for a successful authorization, this can be used to create a purchase token instead of placing the order. Creating a Klarna Customer Token results in Klarna storing customer and payment method details. Read more on Generate a costumer token.

Request
path Parameters
authorizationToken
required
string
Request Body schema: application/json
object (address)
object (customer)
description
required
string [ 1 .. 255 ] characters

Description of the purpose of the token.

intended_use
required
string

Intended use for the token.

Value: "SUBSCRIPTION"
locale
required
string^[A-Za-z]{2,2}(?:-[A-Za-z]{2,2})*$

RFC 1766 customer's locale.

purchase_country
required
string^[A-Za-z]{2,2}$

ISO 3166 alpha-2 purchase country.

purchase_currency
required
string^[A-Za-z]{3,3}$

ISO 4217 purchase currency.

Responses
200

Token was successfully created.

400

We were unable to create a customer token with the provided data. Some field constraint was violated.

403

You were not authorized to execute this operation.

404

The authorization does not exist.

409

The data in the request does not match the session for the authorization.

post/payments/v1/authorizations/{authorizationToken}/customer-token
Request samples
application/json
{
  • "billing_address": {
    },
  • "customer": {
    },
  • "description": "string",
  • "intended_use": "SUBSCRIPTION",
  • "locale": "en-GB",
  • "purchase_country": "GB",
  • "purchase_currency": "GBP"
}
Response samples
application/json
{
  • "billing_address": {
    },
  • "customer": {
    },
  • "payment_method_reference": "0b1d9815-165e-42e2-8867-35bc03789e00",
  • "token_id": "0b1d9815-165e-42e2-8867-35bc03789e00"
}