Payments API V1 (1.0.0)

The Customer Token API is used to charge customers with a tokenized 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.

Download OpenAPI description
Languages
Servers
https://api.klarna.com/

Get customer token

Request

Use this API request to retrieve the content of a Kustom 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.

Path
customerTokenstringrequired
curl -i -X GET \
  'https://api.klarna.com/customer-token/v1/tokens/{customerToken}'

Responses

Token was successfully read.

Bodyapplication/json
cardobject(card_information)
direct_debitobject(direct_debit_information)
payment_method_typestringrequired

Selected payment method

Example: "INVOICE"
statusstringrequired

Status of token, can be active, cancelled, suspended

Example: "ACTIVE"
Response
application/json
{ "card": { "brand": "VISA", "expiry_date": "12/2020", "masked_number": "************1234" }, "direct_debit": { "masked_number": "**********124" }, "payment_method_type": "INVOICE", "status": "ACTIVE" }

Create an order with a customer token

Request

Use this API call to create an order using a Kustom 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.

Path
customerTokenstringrequired
Headers
Klarna-Idempotency-Keystring
Bodyapplication/json
attachmentobject(attachment)
auto_captureboolean

Allow merchant to trigger auto capturing.

Default false
merchant_datastring[ 0 .. 6000 ] characters

Pass through field (max 6000 characters).

Example: "{\"order_specific\":[{\"substore\":\"Women's Fashion\",\"product_name\":\"Women Sweatshirt\"}]}"
merchant_reference1string[ 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).

Example: "ON4711"
merchant_reference2string[ 0 .. 255 ] characters

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

Example: "ON4711"
merchant_urlsobject(merchant_urls)
order_amountinteger(int64)>= 1required

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

order_linesArray of objects(order_line)[ 1 .. 1000 ] itemsrequired

The applicable order lines (max 1000)

order_tax_amountinteger(int64)>= 0

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

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

ISO 4217 purchase currency.

Example: "GBP"
shipping_addressobject(address)
curl -i -X POST \
  'https://api.klarna.com/customer-token/v1/tokens/{customerToken}/order' \
  -H 'Content-Type: application/json' \
  -H 'Klarna-Idempotency-Key: string' \
  -d '{
    "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"
    },
    "auto_capture": false,
    "merchant_data": "{\"order_specific\":[{\"substore\":\"Women'\''s Fashion\",\"product_name\":\"Women Sweatshirt\"}]}",
    "merchant_reference1": "ON4711",
    "merchant_reference2": "ON4711",
    "merchant_urls": {
      "confirmation": "string",
      "push": "string"
    },
    "order_amount": 1,
    "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",
          "global_trade_item_number": "4912345678904",
          "manufacturer_part_number": "AD6654412-334.22",
          "color": "white",
          "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,
        "subscription": {
          "name": "string",
          "interval": "DAY",
          "interval_count": 1
        }
      }
    ],
    "order_tax_amount": 0,
    "purchase_currency": "GBP",
    "shipping_address": {
      "attention": "Attn",
      "city": "London",
      "country": "GB",
      "email": "test.sam@test.com",
      "family_name": "Andersson",
      "given_name": "Adam",
      "organization_name": "string",
      "phone": "+44795465131",
      "postal_code": "W1G 0PW",
      "region": "OH",
      "street_address": "33 Cavendish Square",
      "street_address2": "Floor 22 / Flat 2",
      "title": "Mr."
    }
  }'

Responses

Order was successfully created.

Bodyapplication/json
authorized_payment_methodobject(authorized_payment_method)
fraud_statusstringrequired

Fraud status for the order. Either ACCEPTED or PENDING. If ACCEPTED, the order could be captured. If PENDING, please wait till you receive the notification from Kustom in the notification URL that the order has been approved. You can find additional information here.

order_idstringrequired

Unique order ID of the transaction. This ID will be used for all order management processes.

redirect_urlstringrequired

URL to redirect the customer to after placing the order. This is a Kustom URL to which the merchant should redirect the customer to. Kustom will place a cookie in the customer’s browser (if redirected) and redirect the customer back to the confirmation URL provided by the merchant. This is not a mandatory step but a recommended one to improve the returning customer’s experience. It is a spontaneous step and does not harm the customer’s experience.

Example: "https://credit.klarna.com/v1/sessions/0b1d9815-165e-42e2-8867-35bc03789e00/redirect"
Response
application/json
{ "authorized_payment_method": { "number_of_days": 0, "number_of_installments": 0, "type": "invoice" }, "fraud_status": "string", "order_id": "string", "redirect_url": "https://credit.klarna.com/v1/sessions/0b1d9815-165e-42e2-8867-35bc03789e00/redirect" }

Update customer token status

Request

Use this API call to update the status of a Kustom 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.

Path
customerTokenstringrequired
Bodyapplication/json
statusstringrequired

The token status to update to.

Value"CANCELLED"
Example: "CANCELLED"
curl -i -X PATCH \
  'https://api.klarna.com/customer-token/v1/tokens/{customerToken}/status' \
  -H 'Content-Type: application/json' \
  -d '{
    "status": "CANCELLED"
  }'

Responses

Token patch request has been accepted and is being processed.