v1

latestOpenAPI 3.0.02026-07-1462248.4 KB
orders

Generate a consumer token

Use this API call to create a Klarna Customer Token.<br/>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 consumer token.

post/payments/v1/authorizations/{authorizationToken}/customer-token

Path parameters

authorizationTokenstring required

Request body

descriptionstring required

Description of the purpose of the token.

intended_use'SUBSCRIPTION' required

Intended use for the token.

localestring required

RFC 1766 customer's locale.

purchase_countrystring required

ISO 3166 alpha-2 purchase country.

purchase_currencystring required

ISO 4217 purchase currency.

Example request

{
  "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."
  },
  "customer": {
    "date_of_birth": "1978-12-31",
    "gender": "male",
    "title": "Mr.",
    "type": "organization"
  },
  "locale": "en-GB",
  "purchase_country": "GB",
  "purchase_currency": "GBP"
}

Response

Token was successfully created.

payment_method_referencestring

Used to connect customers with payment method when it is present.

redirect_urlstring

URL to redirect the customer to after placing the order. This is a Klarna URL where Klarna 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.

token_idstring required

Generated customer token. This token will be used to create a new order for the subscription using the Create a New order using token API.

Example response

{
  "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."
  },
  "customer": {
    "date_of_birth": "1978-12-31",
    "gender": "male"
  },
  "payment_method_reference": "0b1d9815-165e-42e2-8867-35bc03789e00",
  "redirect_url": "https://credit.klarna.com/v1/sessions/0b1d9815-165e-42e2-8867-35bc03789e00/redirect",
  "token_id": "0b1d9815-165e-42e2-8867-35bc03789e00"
}