Klarna Checkout API V3 (1.0.0)

Download OpenAPI specification:Download

Klarna provides a number of different callbacks during the customer's checkout session. The callbacks can be used to update the order when the customer changes their address as well as to do a final check to validate the order before it is submitted. The callbacks are sent as POST requests to the endpoint you specify when creating the order. Your response is interpreted using the response code and body.\n\nRead more on Klarna checkout.

Address update

Will be called whenever the consumer changes billing or shipping address. The order will be updated according to the response received by Checkout.

Request
Request Body schema: application/json
order_amount
required
integer <int64> >= 0

Non-negative, minor units. Total total amount of the order, including tax and any discounts.

order_tax_amount
required
integer <int64> >= 0

Non-negative, minor units. The total tax amount of the order.

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

The applicable order lines (max 1000)

object (AddressV1)
object (AddressV1)
object (shipping_option)
purchase_currency
required
string^[A-Za-z]{3,3}$

ISO 4217 purchase currency.

object (customer)
tags
Array of strings

The product's extra features, example ["dangerous_goods", "bulky"]

Responses
200

Address looks good. The order will be updated according to response data.

301

Bad Address. Checkout will redirect the consumer to the page in Location header value.

302

Bad Address. Checkout will redirect the consumer to the page in Location header value.

303

Bad Address. Checkout will redirect the consumer to the page in Location header value.

307

Bad Address. Checkout will redirect the consumer to the page in Location header value.

400

Bad address. This type of response can be used to show an error text message to the consumer. The response body should include one of the following values in the error_type field: 'address_error', 'unsupported_shipping_address' or 'approval_failed'. An 'error_text' field can also be included in the response (mandatory if error_type is 'address_error' or 'approval_failed'). The error message will be shown to the consumer and he or she will be kept in the Checkout page.

post/merchant_urls.address_update
Request samples
application/json
{
  • "order_amount": 0,
  • "order_tax_amount": 0,
  • "order_lines": [
    ],
  • "billing_address": {
    },
  • "shipping_address": {
    },
  • "selected_shipping_option": {
    },
  • "purchase_currency": "USD",
  • "customer": {
    },
  • "tags": [
    ]
}
Response samples
application/json
{
  • "order_amount": 0,
  • "order_tax_amount": 0,
  • "merchant_data": "{\"marketplace_seller_info\":[{\"product_category\":\"Women's Fashion\",\"product_name\":\"Women Sweatshirt\"}]}",
  • "order_lines": [
    ],
  • "shipping_options": [
    ],
  • "attachment": {
    },
  • "purchase_currency": "USD",
  • "locale": "en-US",
  • "external_payment_methods": [],
  • "tags": [
    ]
}

Country change

Will be called whenever the consumer changes billing address country. The order will be updated according to the response received by Checkout.

Request
Request Body schema: application/json
order_amount
required
integer <int64> >= 0

Non-negative, minor units. Total total amount of the order, including tax and any discounts.

order_tax_amount
required
integer <int64> >= 0

Non-negative, minor units. The total tax amount of the order.

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

The applicable order lines (max 1000)

object (AddressV1)
object (AddressV1)
object (shipping_option)
purchase_currency
required
string^[A-Za-z]{3,3}$

ISO 4217 purchase currency.

object (customer)
tags
Array of strings

The product's extra features, example ["dangerous_goods", "bulky"]

Responses
200

New country is accepted. The order will be updated according to response data.

301

New country is not accepted. Checkout will redirect the consumer to the page in Location header value.

302

New country is not accepted. Checkout will redirect the consumer to the page in Location header value.

303

New country is not accepted. Checkout will redirect the consumer to the page in Location header value.

307

New country is not accepted. Checkout will redirect the consumer to the page in Location header value.

400

Bad address. This type of response can be used to show an error text message to the consumer. The response body should include one of the following values in the error_type field: 'address_error', 'unsupported_shipping_address' or 'approval_failed'. An 'error_text' field can also be included in the response (mandatory if error_type is 'address_error' or 'approval_failed'). The error message will be shown to the consumer and he or she will be kept in the Checkout page.

post/merchant_urls.country_change
Request samples
application/json
{
  • "order_amount": 0,
  • "order_tax_amount": 0,
  • "order_lines": [
    ],
  • "billing_address": {
    },
  • "shipping_address": {
    },
  • "selected_shipping_option": {
    },
  • "purchase_currency": "USD",
  • "customer": {
    },
  • "tags": [
    ]
}
Response samples
application/json
{
  • "order_amount": 0,
  • "order_tax_amount": 0,
  • "merchant_data": "{\"marketplace_seller_info\":[{\"product_category\":\"Women's Fashion\",\"product_name\":\"Women Sweatshirt\"}]}",
  • "order_lines": [
    ],
  • "shipping_options": [
    ],
  • "attachment": {
    },
  • "purchase_currency": "USD",
  • "locale": "en-US",
  • "external_payment_methods": [],
  • "tags": [
    ]
}

Shipping option update

Will be called whenever the consumer selects a shipping option. The order will be updated according to the response received by Checkout.

Request
Request Body schema: application/json
order_amount
required
integer <int64> >= 0

Non-negative, minor units. Total total amount of the order, including tax and any discounts.

order_tax_amount
required
integer <int64> >= 0

Non-negative, minor units. The total tax amount of the order.

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

The applicable order lines (max 1000)

object (AddressV1)
object (AddressV1)
object (shipping_option)
purchase_currency
required
string^[A-Za-z]{3,3}$

ISO 4217 purchase currency.

object (customer)
tags
Array of strings

The product's extra features, example ["dangerous_goods", "bulky"]

Responses
200

Shipping option looks good. The order will be updated according to response data.

301

Bad shipping option. Checkout will redirect the consumer to the page in Location header value.

302

Bad shipping option. Checkout will redirect the consumer to the page in Location header value.

303

Bad shipping option. Checkout will redirect the consumer to the page in Location header value.

307

Bad shipping option. Checkout will redirect the consumer to the page in Location header value.

400

Bad address. This type of response can be used to show an error text message to the consumer. The response body should include one of the following values in the error_type field: 'address_error', 'unsupported_shipping_address' or 'approval_failed'. An 'error_text' field can also be included in the response (mandatory if error_type is 'address_error' or 'approval_failed'). The error message will be shown to the consumer and he or she will be kept in the Checkout page.

post/merchant_urls.shipping_option_update
Request samples
application/json
{
  • "order_amount": 0,
  • "order_tax_amount": 0,
  • "order_lines": [
    ],
  • "billing_address": {
    },
  • "shipping_address": {
    },
  • "selected_shipping_option": {
    },
  • "purchase_currency": "USD",
  • "customer": {
    },
  • "tags": [
    ]
}
Response samples
application/json
{
  • "order_amount": 0,
  • "order_tax_amount": 0,
  • "merchant_data": "{\"marketplace_seller_info\":[{\"product_category\":\"Women's Fashion\",\"product_name\":\"Women Sweatshirt\"}]}",
  • "order_lines": [
    ],
  • "shipping_options": [
    ],
  • "attachment": {
    },
  • "purchase_currency": "USD",
  • "locale": "en-US",
  • "external_payment_methods": [],
  • "tags": [
    ]
}

Order validation

Will be called before completing the purchase to validate the information provided by the consumer in Klarna's Checkout iframe.

Request
Request Body schema: application/json
purchase_country
required
string^[A-Za-z]{2,2}$

The purchase country of the merchant's store. The format to be used is ISO 3166 alpha-2. Eg: GB, SE, DE, US, etc.

Note: purchase country and currency need to match the defined merchant configuration. For global configuration read this https://docs.klarna.com/klarna-checkout/popular-use-cases/selling-to-multiple-countries/

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

The purchase currency of the merchant's store. The format to be used is ISO 4217. Eg: USD, EUR, SEK, GBP, etc.

Note: purchase country and currency need to match the defined merchant configuration. For global configuration read this https://docs.klarna.com/klarna-checkout/popular-use-cases/selling-to-multiple-countries/

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

Used to define the language and region of the customer. RFC 1766 customer's locale.

status
string

The current status of the order. The status will be ‘incomplete’ until the customer has been successfully authorized.

object (address)
object (address)
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.

Example: 25 Euros should be 2500.

order_tax_amount
required
integer <int64> >= 0

Total tax amount of the order. The value should be in non-negative minor units.

Example: 25 Euros should be 2500.

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

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

object (customer)
object (merchant_urls)
merchant_reference1
string [ 0 .. 255 ] characters

Used for storing merchant's internal order number or other reference. If set, will be shown on the confirmation page as "order number" . The value is also available in the settlement files. (max 255 characters). Example: "45aa52f387871e3a210645d4"

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). Example: "45aa52f387871e3a210645d4"

object (options)
object (attachment)
Array of objects (payment_provider)

List of external payment methods that will be displayed as part of payment methods in the checkout.

Array of objects (payment_provider)

List of external checkouts that will be displayed as part of payment methods in the checkout. The image_url is required, and the image size has to be 276x48px

shipping_countries
Array of strings

List of allowed shipping countries for this order in ISO-3166 alpha-2 format.

If specified, the customer will be able to change the shipping country in the checkout and you will be notified through ‘address_update’ callback or the ‘shipping_address_change’ javascript event.

If not specified then the default value will be the purchase country.

Example: look at billing_countries example.

Array of objects (shipping_option)

A list of shipping options available for this order.

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

object (gui)
object (merchant_requested)
object (shipping_option)
recurring
boolean

Indicates whether this purchase will create a token that can be used by the merchant to create recurring purchases. This must be enabled for the merchant to use. Default: false

Depending on specified country, recurring could be used for the following payment methods: Pay Later, Direct Debit, Card.

billing_countries
Array of strings

List of allowed billing countries for this order. If specified, the customer will be able to change the billing country in the checkout and you will be notified through ‘country_change’ callback or the ‘billing_address_change’ javascript event. If not specified but shipping_countries is specified, will use same values as shipping_countries. If not specified and shipping_countries is not specified, then the default value will be the purchase country.

Example: ["AD", "AE", "AG", "AI", "AL", "AM", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BW", "BY", "BZ", "CA", "CF", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GR", "GS", "GT", "GU", "GY", "HK", "HN", "HR", "HU", "ID", "IE", "IL", "IM", "IN", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KI", "KM", "KN", "KR", "KW", "KY", "KZ", "LA", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SR", "ST", "SV", "SX", "SZ", "TC", "TF", "TG", "TH", "TJ", "TK", "TL", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VG", "VI", "VN", "VU", "WF", "WS", "XK", "YT", "ZA", "ZM", "ZW"]"

tags
Array of strings

Extra information added to the order.

Example: ["dangerous_goods", "bulky"]

Array of objects (discount_line)

List of discounts applied to this order via the KCO discount-service

Responses
200

Purchase approved. The consumer will then be redirected as usual to the checkout confirmation page.

301

Purchase denied. Checkout will redirect the consumer to the page in Location header value.

302

Purchase denied. Checkout will redirect the consumer to the page in Location header value.

303

Purchase denied. Checkout will redirect the consumer to the page in Location header value.

307

Purchase denied. Checkout will redirect the consumer to the page in Location header value.

400

This type of response can be used to show an error text message to the consumer. The response body should include one of the following values in the error_type field: 'address_error', 'unsupported_shipping_address' or 'approval_failed'. An 'error_text' field can also be included in the response (mandatory if error_type is 'address_error' or 'approval_failed'). The error message will be shown to the consumer and he or she will be kept in the Checkout page.

post/merchant_urls.validation
Request samples
application/json
{
  • "purchase_country": "US",
  • "purchase_currency": "USD",
  • "locale": "en-US",
  • "status": "CHECKOUT_INCOMPLETE",
  • "billing_address": {
    },
  • "shipping_address": {
    },
  • "order_amount": 50000,
  • "order_tax_amount": 4545,
  • "order_lines": [
    ],
  • "customer": {
    },
  • "merchant_reference1": "45aa52f387871e3a210645d4",
  • "merchant_reference2": "45aa52f387871e3a210645d4",
  • "options": {
    },
  • "attachment": {
    },
  • "external_payment_methods": [],
  • "external_checkouts": [],
  • "shipping_countries": [
    ],
  • "shipping_options": [
    ],
  • "merchant_data": "{\"marketplace_seller_info\":[{\"product_category\":\"Women's Fashion\",\"product_name\":\"Women Sweatshirt\"}]}",
  • "gui": {
    },
  • "merchant_requested": { },
  • "selected_shipping_option": {
    },
  • "recurring": true,
  • "billing_countries": [
    ],
  • "tags": [
    ],
  • "discount_lines": [
    ]
}