Klarna Payments API V1 (1.0.0)

Download OpenAPI specification:Download

The Customer Token API is used to charge customers with a tokenized Klarna payment method and can be used for recurring purchases, subscriptions and for storing a customer's payment method. Tokens are created using the generate a customer token call in the payments API.

Read more on Klarna payments.

Get customer token

Use this API request to retrieve the content of a Klarna customer token. The request will return the status of the token as well as payment method details. To learn more, refer to the Read customer tokens details article.

Request
path Parameters
customerToken
required
string
Responses
200

Token was successfully read.

403

You were not authorized to execute this operation.

404

The token does not exist.

get/customer-token/v1/tokens/{customerToken}
Request samples
curl -i -X GET \
  'https://api.klarna.com/customer-token/v1/tokens/{customerToken}'
Response samples
application/json
{
  • "card": {
    },
  • "direct_debit": {
    },
  • "payment_method_type": "INVOICE",
  • "status": "ACTIVE"
}

Create an order with a customer token

Use this API call to create an order using a Klarna Customer Token. Make sure you use the correct token ID when placing an order, to ensure that the right consumer gets billed. Read more on Create a new order using the customer token.

Request
path Parameters
customerToken
required
string
header Parameters
Klarna-Idempotency-Key
string
Request Body schema: application/json
object (attachment)
auto_capture
boolean
Default: false

Allow merchant to trigger auto capturing.

merchant_data
string [ 0 .. 6000 ] characters

Pass through field (max 6000 characters).

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" (max 255 characters).

merchant_reference2
string [ 0 .. 255 ] characters

Used for storing merchant's internal order number or other reference (max 255 characters).

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

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

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

The applicable order lines (max 1000)

order_tax_amount
required
integer <int64> >= 0

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

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

ISO 4217 purchase currency.

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 token does not exist.

409

The data in the request does not match the session.

post/customer-token/v1/tokens/{customerToken}/order
Request samples
application/json
{
  • "attachment": {
    },
  • "auto_capture": false,
  • "merchant_data": "{\"order_specific\":[{\"substore\":\"Women's Fashion\",\"product_name\":\"Women Sweatshirt\"}]}",
  • "merchant_reference1": "ON4711",
  • "merchant_reference2": "ON4711",
  • "merchant_urls": {
    },
  • "order_amount": 1,
  • "order_lines": [
    ],
  • "order_tax_amount": 0,
  • "purchase_currency": "GBP",
  • "shipping_address": {
    }
}
Response samples
application/json
{}

Update customer token status

Use this API call to update the status of a Klarna Customer Token. This should be used if you want to cancel a specific customer token. Read more on Update the status of a customer token.

Request
path Parameters
customerToken
required
string
Request Body schema: application/json
status
required
string

The token status to update to.

Value: "CANCELLED"
Responses
202

Token patch request has been accepted and is being processed.

400

Unable to patch the token with the provided data. Some field constraint was violated.

403

You were not authorized to execute this operation.

404

The token does not exist.

patch/customer-token/v1/tokens/{customerToken}/status
Request samples
application/json
{
  • "status": "CANCELLED"
}