Enable Klarna in payment forms presented through hosted checkout pages or embedded elements using Klarna’s SDKs. This ensures a branded, compliant, and high-conversion checkout experience.
With this integration path, Partners are presenting a payment form generated by the Acquiring Partners:
The following diagram gives an overview of the customer journey and the Acquiring Partner workflow.
High level integration visualization of an Hosted Checkout experience from the Acquiring Partner
Before calling Klarna’s Payment Authorization API, the Acquiring Partner must ensure their backend accept and forward Klarna specific parameters. These include interoperability parameters that preserve session context as well as supplementary purchase data which improves Klarna’s ability to assess risk, optimize approval rates, and deliver a more personalized checkout experience.
When Partners optimize their integration with Klarna, they are likely to have interoperability parameters to share with the Acquiring Partner.
Parameter | Purpose |
---|---|
interoperability_token | Encodes Klarna-specific session context (e.g., preselected payment option, pre-qualification results). |
interoperability_data | Submit supplementary purchase data directly to Klarna |
These ensure consistent customer and transaction context throughout the payment flow and must be forwarded unaltered to Klarna.
interoperability_token
in client side javascript library.interoperability_data
should NOT be exposed client-side.Sample request
Below some examples of how Acquiring Partners can accept the interoperability parameters:
The Partner-facing field should be named either klarna_interoperability_token
/klarna_interoperability_data
or interoperability_token
/interoperability_data
in a Klarna-specific context, ensuring that it’s easy for any Partner to identify and use.
As those parameters can change over time and are versioned so that the third party integration continues to work, Acquiring Partners need to respect these guidelines if they wish to validate parameters:
Parameter | Type | Max length | <span>Validation</span> |
---|---|---|---|
interoperability_token | string (JWT) | 8192 chars | Optional: verify format only |
interoperability_data | string (stringified JSON object) | 10240 chars | Optional: check for valid JSON |
The Acquiring Partner can validate the input based on the provided guidelines but must not modify it. The input must always be forwarded as received, without any interference.
Supplementary purchase data improves Klarna’s ability to assess risk, optimize approval rates, and deliver a more personalized checkout experience. It includes structured information such as line items, L2/L3 data for Card Network optimization and other transaction context.
Acquiring Partners may receive this data from the Partner in two ways:
interoperability_data
supplementary_purchase_data
object format when calling the Klarna Payment Authorization API.Read more about Supplementary Purchase Data here.
Acquiring Partner must not add specific fields of the supplementary purchase data to their APIs for supporting Klarna, but rather make sure interoperability_data
and its requirements are properly implemented.
In both cases, the Acquiring Partner must ensure that data provided by the Partner is forwarded to Klarna. Do not require Partners to resubmit the same information through multiple mechanisms.
To integrate Klarna as a payment method into their payment form, the Acquiring Partner must initialize Klarna’s Web SDK using specific credentials and tokens.
If a Partner provides an interoperability_token
, the Acquiring Partner must exchange if for a short-lived sdk_token
using the Generate SDK Token API endpoint.
sdk_token
is a single-use, browser-bound credential.This step is only applicable if the Partner has shared an interoperability_token
.
Load Klarna’s Web SDK module directly from Klarna’s servers to always get the latest version:
const { KlarnaSDK } = await import("https://js.klarna.com/web-sdk/v2/klarna.mjs");
Do not bundle or self-host the SDK script, always load it dynamically from Klarna.
When using the Klarna Web SDK, you are responsible for informing your users about the tracking technologies it uses. Learn more about how to disclose this on your site.
To initialize the SDK, you must pass:
Parameter | Description |
---|---|
clientId | A credential that identifies the Acquiring Partner (obtained via Klarna’s Credentials API). It is shared across all integrated Partners. |
partnerAccountId | A unique identifier for the specific Partner onboarding under the Acquiring Partner. |
sdkToken | The short-lived token exchanged from the interoperability_token . Enables restoring the customer's session state securely on the client. |
locale | Optional, language and region code (e.g., en-US ). If omitted, Klarna may default based on the customer’s browser settings. |
SDK Initialization sample
const klarna = await KlarnaSDK({
clientId: "klarna_test_client_***",
partnerAccountId: "krn:partner:global:account:***",
sdkToken: "rxvqGi07j...", // retrieved from server
locale: "en-US" // optional but recommended
});
// sdkToken can also be set after SDK initiation
// Klarna.Config.setSdkToken("rxvqGi07j...")
After initialization, the Klarna SDK instance is ready to retrieve payment presentation data and manage the checkout flow.
Once the Klarna Web SDK is initialized, the next step is to retrieve Klarna’s Payment Presentation element.
This element provides all the visual assets, localized texts, and instructions needed to correctly display Klarna in your checkout form.
Use the initialized SDK instance to call the Klarna.Payment.presentation() method.
Basic checkout context parameters must be provided:
Parameter | Description |
---|---|
amount | The transaction amount in minor units (e.g., $118.00 = 11800 ). |
currency | Three-letter ISO 4217 currency code (e.g., USD , EUR ). |
locale | Locale code to localize texts and formats (e.g., en-US , de-DE ). |
intents | Optional. Specify the intent of the checkout flow: PAY , SUBSCRIBE , SIGNUP , SIGNIN , DONATE .Default value is PAY . |
Sample code
var paymentPresentation = await klarna.Payment.presentation({
amount: 11800,
currency: "USD",
locale: "en-US",
intents: ["PAY"], // optional, other values: "SUBSCRIBE" ||"SIGNUP" || "SIGNIN" || "DONATE"
});
Always use the correct locale and currency for the customer session to ensure Klarna assets and instructions are accurately localized.
The PaymentPresentation
interface provides the full Klarna branding package and instructions tailored to the customer's purchase:
Attribute | Purpose |
---|---|
header | The main descriptor to introduces Klarna in the payment form. The value will be dynamically adjusted based on the locale provided. |
subheader | The descriptor subheader which must be loaded inline below the main descriptor header. Short and enriched descriptive texts. Provides transparency on available options like installments, pay later, etc. |
icon | Klarna badge/logo suitable for checkout forms. |
instruction | Klarna’s directive on how to display Klarna (e.g., show, preselect, show-only, or hide). |
paymentButton | Klarna button component to trigger the Klarna authorization flow when the user proceeds. |
Once an instance of PaymentPresentation
is created, the Acquiring Partner must dynamically render Klarna payment option in the payment selector according to Klarna’s presentation guidelines.
The instruction
attribute from the PaymentPresentation
instance informs how Klarna should be displayed in the payment form:
Instruction | Description |
---|---|
SHOW_KLARNA | Show Klarna alongside other payment methods. |
PRESELECT_KLARNA | Show Klarna pre-selected but still alongside others. |
SHOW_ONLY_KLARNA | Display Klarna as the only payment method. |
HIDE_KLARNA | Do not show Klarna at all. |
The presentation instructions indicate Acquiring Partners how Klarna should be presented in the payment selector. Acquiring Partners are required to adhere to Klarna’s payment presentation instruction to achieve the best-in-class user experience.
![]() | ![]() | ![]() | ![]() |
Show Klarna | Preselect Klarna | Show only Klarna | Hide Klarna |
The presentation instructions are derived from possible customer purchase journeys described in the following article.
The following attributes from PaymentPresentation
instance will be used when loading the payment selector initially:
The sample function below shows how to add the Klarna option dynamically in the payment form.
function renderKlarnaOption(paymentPresentation) {
const klarnaContainer = document.getElementById("klarna-option");
if (!klarnaContainer) {
console.error("Klarna container missing.");
return;
}
// Clear the container first
klarnaContainer.innerHTML = `
The paymentPresentation.instruction
must be respected when presenting Klarna:
if (paymentPresentation) {
switch (paymentPresentation.instruction) {
case "SHOW_KLARNA":
console.log("Showing Klarna alongside other payment methods.");
renderKlarnaOption(paymentPresentation);
break;
case "PRESELECT_KLARNA":
console.log("Showing Klarna preselected alongside other payment methods.");
renderKlarnaOption(paymentPresentation);
break;
After the customer selects Klarna in the payment selector (or if Klarna was pre-selected according to presentation instructions), the next step is to show:
This step finalizes the presentation of Klarna's payment method before the customer proceeds to payment authorization.
The remaining attributes from PaymentPresentation
instance will be used when loading the payment selector:
Attribute | Purpose |
---|---|
subheader.enriched | Enriched tailored description with link |
paymentButton | Payment button for the customer to start the Klarna purchase Journey |
The payment presentation instance allows you to either mount the prebuilt button component or retrieve the button text asset. The Klarna Payment Button is context-aware and dynamically adapts to your configuration.
This guide will focus on the Klarna paymentButton component, to learn more about creating your own button. Visit this section.
The paymentButton.component()
can be configured with the following set of parameters:
Parameter | Description |
---|---|
shape | Defines the button’s shape. Possible values are:default , pill , rect |
theme | Sets the visual theme of the button. Possible values are: default , light , dark , outlined |
logoAlignment | Controls the alignment of Klarna’s logo inside the button. Possible values are default , left , center |
intents | Sets the purpose of the payment. Used to personalize the button and flow if not set when creating the PaymentPresentation instance |
id | Sets a custom DOM ID on the rendered button. Useful for testing or styling. |
locale | Sets the language and region (e.g., en-US ). Defaults to browser settings if omitted. |
disabled | Disables the button when set to true . Useful during form validation or async operations. |
hideOverlay | If true , disables Klarna’s default loading overlay. Use with care. |
loading | Forces the button into a loading state. Useful when awaiting async setup or validation. |
initiate | Function that returns a Promise resolving to either a PaymentRequestData , a paymentRequestId , or a returnUrl . This will be covered in details in the next section - Authorize the payment. |
initiationMode | Defines how Klarna launches the purchase journey. This will be covered in details in the next section - Authorize the payment. |
Sample code
const buttonConfig = {
shape: "pill", // Button shape ("pill", "rectangle", etc.)
theme: "dark", // Theme ("dark", "light", etc.)
initiate: () => {
// This function should trigger your backend to call Klarna’s POST /payment/authorize API
// and return a promise resolving to the authorization result
return fetch('/your-api/authorize-payment')
.then(response => response.json());
},
initiationMode: "DEVICE_BEST", // Device-optimized payment initiation
Finally, mount the button inside the appropriate container:
paymentPresentation.paymentButton.component(buttonConfig).mount("#klarna-button-container");
The button will automatically handle customer interaction and trigger the Klarna Purchase Journey via the initiate
function.
interoperability_token
in your checkout session API and JavaScript library.interoperability_data
in your checkout session API (server-side only).interoperability_token
is provided, exchange it server-side for an sdk_token
.clientId
, partnerAccountId
, sdkToken
, and locale
.Klarna.Payment.presentation()
SDK method to dynamically retrieve personalized assets to build the payment selectorinstruction
(e.g., show, hide, preselect Klarna).