Klarna Payments API
The Payments API from Klarna — 5 operation(s) for payments.
The Payments API from Klarna — 5 operation(s) for payments.
openapi: 3.0.0
info:
description: Hosted Payment Page (HPP) API is a service that lets you integrate Klarna Payments without the need of hosting the web page that manages the client side of Klarna Payments.
version: '1.1'
title: Klarna HPP Captures Payments API
license:
name: Klarna Bank AB
servers:
- url: https://api.klarna.com
tags:
- name: Payments
paths:
/payments/v1/sessions:
post:
summary: Create a session
description: 'Use this API call to create a Klarna Payments session.<br/>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](https://docs.klarna.com/klarna-payments/integrate-with-klarna-payments/step-1-initiate-a-payment/)**.'
operationId: createCreditSession
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/session_create'
description: session_request
required: true
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/merchant_session'
'400':
description: We were unable to create a session with the provided data. Some field constraint was violated.
'403':
description: You were not authorized to execute this operation.
tags:
- Payments
/payments/v1/sessions/{session_id}:
post:
summary: Update a session
description: '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](https://docs.klarna.com/klarna-payments/other-actions/update-the-cart/)**.'
operationId: updateCreditSession
parameters:
- name: session_id
in: path
description: session_id
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/session'
description: session_request
required: true
responses:
'204':
description: The session was updated successfully.
'400':
description: We were unable to update the session with the provided data. Some field constraint was violated.
'403':
description: You were not authorized to execute this operation.
'404':
description: The session does not exist.
tags:
- Payments
get:
summary: Get details about a session
description: '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](https://docs.klarna.com/klarna-payments/other-actions/check-the-details-of-a-payment-session/)**.'
operationId: readCreditSession
parameters:
- name: session_id
in: path
description: session_id
required: true
schema:
type: string
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/session_read'
'403':
description: You were not authorized to execute this operation.
'404':
description: The session does not exist.
tags:
- Payments
/payments/v1/authorizations/{authorizationToken}:
delete:
summary: Cancel an authorization
description: 'Use this API call to cancel/release an authorization. If the `authorization_token` received during a Klarna Payments wont be used to place an order immediately you could release the authorization.
Read more on **[Cancel an existing authorization](https://docs.klarna.com/klarna-payments/other-actions/cancel-an-authorization/)**.'
operationId: cancelAuthorization
parameters:
- name: authorizationToken
in: path
required: true
schema:
type: string
responses:
'204':
description: The authorization was cancelled successfully.
'403':
description: You were not authorized to execute this operation.
'404':
description: The authorization does not exist.
tags:
- Payments
/payments/v1/authorizations/{authorizationToken}/order:
post:
summary: Create an order
description: '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.<br/>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.<br/>When the Order has been successfully placed at Klarna, you need to handle it either through the Merchant Portal or using [Klarnas Order Management API](#order-management-api).
Read more on **[Create a new order](https://docs.klarna.com/klarna-payments/integrate-with-klarna-payments/step-3-create-an-order/)**.'
operationId: createOrder
parameters:
- name: authorizationToken
in: path
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/create_order_request'
responses:
'200':
description: Order was successfully created.
content:
application/json:
schema:
$ref: '#/components/schemas/order'
'400':
description: We were unable to create an order with the provided data. Some field constraint was violated.
'403':
description: You were not authorized to execute this operation.
'404':
description: The authorization does not exist.
'409':
description: The data in the request does not match the session for the authorization.
tags:
- Payments
/payments/v1/authorizations/{authorizationToken}/customer-token:
post:
summary: Generate a customer token
description: '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 costumer token](https://docs.klarna.com/klarna-payments/in-depth-knowledge/customer-token/)**.'
operationId: purchaseToken
parameters:
- name: authorizationToken
in: path
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/customer_token_creation_request'
responses:
'200':
description: Token was successfully created.
content:
application/json:
schema:
$ref: '#/components/schemas/customer_token_creation_response'
'400':
description: We were unable to create a customer token with the provided data. Some field constraint was violated.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorV2'
'403':
description: You were not authorized to execute this operation.
'404':
description: The authorization does not exist.
'409':
description: The data in the request does not match the session for the authorization.
tags:
- Payments
components:
schemas:
customer:
type: object
properties:
date_of_birth:
type: string
example: '1978-12-31'
description: Customers date of birth. The format is yyyy-mm-dd
gender:
type: string
example: male
description: Customers gender - male or female
last_four_ssn:
type: string
description: Last four digits of the customer's social security number. This value is available for US customers.
pattern: ^([0-9]{4}|[0-9]{9})$
national_identification_number:
type: string
description: The customer's national identification number. This value is available for EU customers utilizing national identification numbers.
organization_entity_type:
type: string
description: Organization entity type. Only applicable for B2B customers.
enum:
- LIMITED_COMPANY
- PUBLIC_LIMITED_COMPANY
- ENTREPRENEURIAL_COMPANY
- LIMITED_PARTNERSHIP_LIMITED_COMPANY
- LIMITED_PARTNERSHIP
- GENERAL_PARTNERSHIP
- REGISTERED_SOLE_TRADER
- SOLE_TRADER
- CIVIL_LAW_PARTNERSHIP
- PUBLIC_INSTITUTION
- OTHER
organization_registration_id:
type: string
description: Organization registration id. Only applicable for B2B customers.
title:
type: string
example: Mr.
description: "Customers Title. Allowed values per country:\nUK - \"Mr\", \"Ms\"\nDE - \"Herr\", \"Frau\"\nAT: \"Herr, \"Frau\"\nCH: de-CH: \"Herr, \"Frau\" it-CH: \"Sig.\", \"Sig.ra\" fr-CH: \"M\", \"Mme\" \nBE: \"Dhr.\", \"Mevr.\"\nNL: \"Dhr.\", \"Mevr.\""
type:
type: string
example: organization
description: Type of customer in the session. If nothing is added, a B2C session will be the default. If it is a b2b-session, you should enter organization to trigger a B2B session.
pattern: ^(person|organization)$
vat_id:
type: string
description: VAT ID. Only applicable for B2B customers.
attachment:
type: object
required:
- body
- content_type
properties:
body:
type: string
example: '{"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"}]}'
description: The content of the extra merchant data should be presented as a string inside this property. The body should be an object containing any of the keys and sub-objects described below serialized to JSON. More information on that object can be found [here](https://docs.klarna.com/api/extra-merchant-data).
content_type:
type: string
example: application/vnd.klarna.internal.emd-v2+json
description: The content type of the body. It is usually represented as "application/vnd.klarna.internal.emd-v2+json"
customer_token_creation_response:
type: object
required:
- token_id
properties:
billing_address:
$ref: '#/components/schemas/address'
customer:
$ref: '#/components/schemas/customer_read_create_token'
payment_method_reference:
type: string
example: 0b1d9815-165e-42e2-8867-35bc03789e00
description: Used to connect customers with payment method when it is present.
redirect_url:
type: string
example: https://credit.klarna.com/v1/sessions/0b1d9815-165e-42e2-8867-35bc03789e00/redirect
description: URL to redirect the customer to after placing the order. This is a Klarna URL where Klarna will place a cookie in the customers 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 customers experience.
token_id:
type: string
example: 0b1d9815-165e-42e2-8867-35bc03789e00
description: 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.
ErrorV2:
type: object
properties:
correlation_id:
type: string
error_code:
type: string
error_messages:
type: array
items:
type: string
product_identifiers:
type: object
properties:
brand:
type: string
example: shoe-brand
description: The product's brand name as generally recognized by consumers. If no brand is available for a product, do not supply any value.
minLength: 0
maxLength: 70
category_path:
type: string
example: Shoes > Running
description: The product's category path as used in the merchant's webshop. Include the full and most detailed category and separate the segments with ' > '
minLength: 0
maxLength: 750
global_trade_item_number:
type: string
example: '4912345678904'
description: The product's Global Trade Item Number (GTIN). Common types of GTIN are EAN, ISBN or UPC. Exclude dashes and spaces, where possible
minLength: 0
maxLength: 50
manufacturer_part_number:
type: string
example: AD6654412-334.22
description: The product's Manufacturer Part Number (MPN), which - together with the brand - uniquely identifies a product. Only submit MPNs assigned by a manufacturer and use the most specific MPN possible
minLength: 0
maxLength: 70
color:
type: string
example: white
description: Color to be shown to the end customer (max 64 characters).
minLength: 0
maxLength: 64
size:
type: string
example: small
description: Size to be shown to the end customer (max 64 characters).
minLength: 0
maxLength: 64
create_order_request:
type: object
required:
- order_amount
- order_lines
- purchase_country
- purchase_currency
properties:
authorization_token:
type: string
description: Authorization token.
readOnly: true
auto_capture:
type: boolean
description: Allow merchant to trigger auto capturing.
default: false
billing_address:
$ref: '#/components/schemas/address'
custom_payment_method_ids:
type: array
description: '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. '
items:
type: string
customer:
$ref: '#/components/schemas/customer'
locale:
type: string
example: en-GB
description: 'Used to define the language and region of the customer. The locale follows the format of [RFC 1766](https://datatracker.ietf.org/doc/rfc1766/), meaning its value consists of language-country.
Read more on **[Supported Locals and Currencies](https://docs.klarna.com/klarna-payments/in-depth-knowledge/puchase-countries-currencies-locales/)**.'
pattern: ^[A-Za-z]{2,2}(?:-[A-Za-z]{2,2})*$
merchant_data:
type: string
example: '{"order_specific":[{"substore":"Women''s Fashion","product_name":"Women Sweatshirt"}]}'
description: Pass through field to send any information about the order to be used later for reference while retrieving the order details (max 6000 characters)
minLength: 0
maxLength: 6000
merchant_reference1:
type: string
example: ON4711
description: Used for storing merchant's internal order number or other reference.
minLength: 0
maxLength: 255
merchant_reference2:
type: string
example: hdt53h-zdgg6-hdaff2
description: Used for storing merchant's internal order number or other reference. The value is available in the settlement files. (max 255 characters).
minLength: 0
maxLength: 255
merchant_urls:
$ref: '#/components/schemas/merchant_urls'
order_amount:
type: integer
format: int64
example: 2000
description: '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.'
minimum: 0
order_lines:
type: array
description: 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.
items:
$ref: '#/components/schemas/order_line'
maxItems: 1000
minItems: 1
order_tax_amount:
type: integer
format: int64
example: 333
description: 'Total tax amount of the order. The value should be in non-negative minor units. Eg: 25 Euros should be 2500.'
minimum: 0
payment_method_categories:
type: array
description: Available payment method categories
readOnly: true
uniqueItems: true
items:
$ref: '#/components/schemas/payment_method_category'
purchase_country:
type: string
example: GB
description: 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.
pattern: ^[A-Za-z]{2,2}$
purchase_currency:
type: string
example: GBP
description: The purchase currency of the order. Formatted according to ISO 4217 standard, e.g. USD, EUR, SEK, GBP, etc.
pattern: ^[A-Za-z]{3,3}$
shipping_address:
$ref: '#/components/schemas/address'
status:
type: string
example: complete
description: 'The current status of the session. Possible values: ''complete'', ''incomplete'' where ''complete'' is set when the order has been placed.'
readOnly: true
enum:
- complete
- incomplete
merchant_urls:
type: object
properties:
confirmation:
type: string
example: https://www.example-url.com/confirmation
description: URL of the merchant confirmation page. The consumer will be redirected back to the confirmation page if the consumer is sent to the redirect URL after placing the order. Insert {session.id} and/or {order.id} as placeholder to connect either of those IDs to the URL(max 2000 characters).
minLength: 0
maxLength: 2000
notification:
type: string
example: https://www.example-url.com/notification
description: URL for notifications on pending orders. Insert {session.id} and/or {order.id} as placeholder to connect either of those IDs to the URL (max 2000 characters).
minLength: 0
maxLength: 2000
push:
type: string
example: https://www.example-url.com/push
description: URL that will be requested when an order is completed. Should be different than checkout and confirmation URLs. Insert {session.id} and/or {order.id} as placeholder to connect either of those IDs to the URL (max 2000 characters).
minLength: 0
maxLength: 2000
authorization:
description: URL for receiving the authorization token when payment is completed. Used for Authorization Callback.
example: https://www.example-url.com/authorization
maxLength: 2000
minLength: 0
type: string
subscription:
type: object
required:
- name
- interval
- interval_count
properties:
name:
description: The name of the subscription product
type: string
minLength: 1
maxLength: 255
interval:
description: The cadence unit for this.
type: string
enum:
- DAY
- WEEK
- MONTH
- YEAR
interval_count:
description: The number of intervals
type: integer
minimum: 1
customer_read:
type: object
properties:
date_of_birth:
type: string
example: '1978-12-31'
description: Customers date of birth. The format is yyyy-mm-dd
gender:
type: string
example: male
description: Customers gender - male or female
organization_entity_type:
type: string
description: Organization entity type. Only applicable for B2B customers.
enum:
- LIMITED_COMPANY
- PUBLIC_LIMITED_COMPANY
- ENTREPRENEURIAL_COMPANY
- LIMITED_PARTNERSHIP_LIMITED_COMPANY
- LIMITED_PARTNERSHIP
- GENERAL_PARTNERSHIP
- REGISTERED_SOLE_TRADER
- SOLE_TRADER
- CIVIL_LAW_PARTNERSHIP
- PUBLIC_INSTITUTION
- OTHER
organization_registration_id:
type: string
description: Organization registration id. Only applicable for B2B customers.
title:
type: string
example: Mr.
description: "Customers Title. Allowed values per country:\nUK - \"Mr\", \"Ms\"\nDE - \"Herr\", \"Frau\"\nAT: \"Herr, \"Frau\"\nCH: de-CH: \"Herr, \"Frau\" it-CH: \"Sig.\", \"Sig.ra\" fr-CH: \"M\", \"Mme\" \nBE: \"Dhr.\", \"Mevr.\"\nNL: \"Dhr.\", \"Mevr.\""
type:
type: string
example: organization
description: Type of customer in the session. If nothing is added, a B2C session will be the default. If it is a b2b-session, you should enter organization to trigger a B2B session.
vat_id:
type: string
description: VAT ID. Only applicable for B2B customers.
customer_token_creation_request:
type: object
required:
- description
- intended_use
- locale
- purchase_country
- purchase_currency
properties:
billing_address:
$ref: '#/components/schemas/address'
customer:
$ref: '#/components/schemas/customer'
description:
type: string
description: Description of the purpose of the token.
minLength: 1
maxLength: 255
intended_use:
type: string
description: Intended use for the token.
enum:
- SUBSCRIPTION
locale:
type: string
example: en-GB
description: RFC 1766 customer's locale.
pattern: ^[A-Za-z]{2,2}(?:-[A-Za-z]{2,2})*$
purchase_country:
type: string
example: GB
description: ISO 3166 alpha-2 purchase country.
pattern: ^[A-Za-z]{2,2}$
purchase_currency:
type: string
example: GBP
description: ISO 4217 purchase currency.
pattern: ^[A-Za-z]{3,3}$
options:
type: object
properties:
color_border:
type: string
example: '#FF9900'
description: Color for the border of elements within the iFrame. Value should be a CSS hex color, e.g. "#FF9900"
pattern: ^#[A-Fa-f0-9]{6}$
color_border_selected:
type: string
example: '#FF9900'
description: Color for the border of elements within the iFrame when selected by the customer. Value should be a CSS hex color, e.g. "#FF9900"
pattern: ^#[A-Fa-f0-9]{6}$
color_details:
type: string
example: '#FF9900'
description: Color for the bullet points within the iFrame. Value should be a CSS hex color, e.g. "#FF9900"
pattern: ^#[A-Fa-f0-9]{6}$
color_text:
type: string
example: '#FF9900'
description: Color for the texts within the iFrame. Value should be a CSS hex color, e.g. "#FF9900"
pattern: ^#[A-Fa-f0-9]{6}$
radius_border:
type: string
example: 5px
description: Radius for the border of elements within the iFrame.
payment_method_category:
type: object
properties:
asset_urls:
$ref: '#/components/schemas/asset_urls'
identifier:
type: string
example: klarna
description: 'ID of the payment method category to be used while loading the widget later.
The possible values are:<ul><li>klarna</li><li>pay_later</li><li>pay_now</li><li>pay_over_time</li><li>direct_bank_transfer</li><li>direct_debit</li></ul>'
name:
type: string
example: Pay with Klarna
description: Name of the payment method category. These names are dynamic depending on what payment method is in the category. Using this dynamic asset will make sure that any copy update of Klarna will automatically be propagated, or any updates of included payment methods by you.
order:
type: object
required:
- order_id
properties:
authorized_payment_method:
$ref: '#/components/schemas/authorized_payment_method'
fraud_status:
type: string
description: 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 Klarna in the notification URL that the order has been approved. You can find additional information here.
order_id:
type: string
description: Unique order ID of the transaction. This ID will be used for all order management processes.
redirect_url:
type: string
example: https://credit.klarna.com/v1/sessions/0b1d9815-165e-42e2-8867-35bc03789e00/redirect
description: URL to redirect the customer to after placing the order. This is a Klarna URL to which the merchant should redirect the customer to. Klarna will place a cookie in the customers 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 customers experience. It is a spontaneous step and does not harm the customers experience.
asset_urls:
type: object
properties:
descriptive:
type: string
example: https://x.klarnacdn.net/payment-method/assets/badges/generic/klarna.svg
description: URL of the descriptive asset. Using this dynamic asset will make sure that any copy update of Klarna will automatically be propagated.
standard:
type: string
example: https://x.klarnacdn.net/payment-method/assets/badges/generic/klarna.svg
description: URL of the standard asset. Using this dynamic asset will make sure that any copy update of Klarna will automatically be propagated.
merchant_session:
type: object
required:
- client_token
- session_id
properties:
client_token:
type: string
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJzZXNzaW9uX2lkIiA6ICIw
description: Client token to be passed to the JS client while initializing the JS SDK in the next step.
maxLength: 4096
minLength: 0
payment_method_categories:
type: array
description: Available payment method categories for this particular session
uniqueItems: true
items:
$ref: '#/components/schemas/payment_method_category'
session_id:
type: string
example: 0b1d9815-165e-42e2-8867-35bc03789e00
description: ID of the created session. Please use this ID to share with Klarna for identifying any issues during integration.
maxLength: 255
minLength: 0
order_line:
type: object
required:
- name
- quantity
- total_amount
- unit_price
properties:
image_url:
type: string
example: https://www.exampleobjects.com/logo.png
description: "URL to an image that can be later embedded in communications between Klarna and the customer. (max 1024 characters).\n A minimum of 250x250 px resolution is recommended for the image to look good in the Klarna app, and below 50x50 px won't even show. We recommend using a good sized image (650x650 px or more), however the file size must not exceed 12MB."
minLength: 0
maxLength: 1024
merchant_data:
type: string
example: '{"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"}]}'
description: Used for storing merchant's internal order number or other reference. Pass through field. (max 1024 characters)
minLength: 0
maxLength: 1024
name:
type: string
example: Running shoe
description: Descriptive name of the order line item.
minLength: 1
maxLength: 255
product_identifiers:
$ref: '#/components/schemas/product_identifiers'
product_url:
type: string
example: https://.../AD6654412.html
description: URL to the product in the merchants webshop that can be later used in communications between Klarna and the customer. (max 1024 characters)
minLength: 0
maxLength: 1024
quantity:
type: integer
format: int64
example: 1
description: Quantity of the order line item. Must be a non-negative number.
minimum: 0
quantity_unit:
type: string
example: pcs
description: Unit used to describe the quantity, e.g. kg, pcs, etc. If defined the value has to be 1-8 characters.
minLength: 1
maxLength: 8
reference:
type: string
example: AD6654412
description: Client facing article number, SKU or similar. Max length is 256 characters.
minLength: 0
maxLength: 255
tax_rate:
type: integer
format: int64
example: 2000
description: Tax rate of the order line. Non-negative value. The percentage value is represented with two implicit decimals. I.e 2000 = 20%.
minimum: 0
maximum: 10000
total_amount:
type: integer
format: int64
example: 2000
description: "Total amount of the order line. Must be defined as minor units. Includes tax and discount. Eg: 2000=20 euros\nValue = (quantity x unit_price) - total_discount_amount. \n(max value: 200000000)"
maximum: 200000000
total_discount_amount:
type: integer
format: int64
example: 500
description: 'Non-negative minor units. Includes tax. Eg: 500=5 euros'
minimum: 0
total_tax_amount:
type: integer
format: int64
example: 333
description: Total tax amount of the order line. Must be within �1 of total_amount - total_amount 10000 / (10000 + tax_rate). Negative when type is discount.
type:
type: string
example: physical
description: 'Type of the order line item. The possible values are:
physical
discount
shipping_fee
sales_tax
digital
gift_card
store_credit
surcharge'
unit
# --- truncated at 32 KB (54 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/klarna/refs/heads/main/openapi/klarna-payments-api-openapi.yml