![]() | ![]() | ![]() |
| Messaging on the homepage | Messaging on the product detail page | Messaging in the checkout |
https://js.klarna.com/web-sdk/v2/klarna.mjsclientId to initialize the SDK.<script type="module">
const { KlarnaSDK } = await import("https://js.klarna.com/web-sdk/v2/klarna.mjs")
const klarna = await KlarnaSDK({
clientId: "[client-id]",
products: ["MESSAGING"],
locale: "en-US", // optional
})
// Klarna SDK ready to be utilized| Parameter | Presence | Description |
|---|---|---|
clientId | required | A credential that identifies the Partner's Partner Account (obtained via the Klarna Partner Portal). |
products | optional | Array to specify which products to load for optimal performance. This reduces the amount of data needed to download. For example, only loading PAYMENT will exclude the CUSTOMER product. |
locale | required | Language and region code (for example, en-US). If omitted, Klarna may default based on the customer's browser settings. |
placement method that allows creation and mounting of the messaging placement programmatically.klarna.Messaging.placement({
key: 'credit-promotion-badge',
amount: 20000,
currency: "USD",
locale: 'en-US',
theme: 'light'
}).mount('#osm-placement');
| Parameter | Presence | Description |
|---|---|---|
key | required | Placement type key. List of available keys |
currency | required | Currency in ISO 4217 format. Supported currencies: AUD, EUR, CAD, CZK, DKK, HUF, MXN, NZD, NOK, PLN, RON, SEK, CHF, GBP, USD. |
amount | required | Amount in minor units (for example, $5.00 = 500). To populate amount:
|
locale | required | Locale for messaging ("en-AT", "de-AT", "nl-BE", "en-BE", "fr-BE", "en-CH", "de-CH", "it-CH", "fr-CH", "en-CZ", "cs-CZ", "de-DE", "en-DE", "da-DK", "en-DK", "es-ES", "en-ES", "fi-FI", "sv-FI", "en-FI", "fr-FR", "en-FR", "en-GB", "en-GR", "el-GR", "en-HU", "en-IE", "en-IT", "hu-HU", "it-IT", "nl-NL", "en-NL", "no-NO", "nb-NO", "en-NO", "en-PL", "pl-PL", "en-PT", "pt-PT", "en-RO", "ro-RO", "sv-SE", "en-SE", "sk-SK, "en-SK", en-CA", "fr-CA", "es-MX", "en-MX", "en-US", "es-US", "en-AU", "en-NZ") |
theme | optional | Defines what the theme of the placement would be, which are light or dark |
intent |
![]() | ![]() | ![]() |
| Interact with Product or Cart On-site Messaging placement | Go through Klarna Pre-qualification flow | Checkout page reflects prequalified status using Klarna Network Session Token. |
klarna_network_session_token to reflect the pre-qualification in the checkout.Network.Session package. The token is available either synchronously through klarna.Network.Session.token() or by subscribing to tokenupdate events with klarna.Network.Session.on('tokenupdate', callback) to react to token changes during the session.const klarnaNetworkSessionToken = klarna.Network.Session.token();
klarna.Network.Session.on('tokenupdate', (klarnaNetworkSessionToken) => {
// Forward the updated token to the Partner's backend
});Klarna-Network-Session-Token header to provide customer context and enable a personalized experience.curl https://api-global.test.klarna.com/v2/accounts/{partner_account_id}/payment/presentation \
-H 'Authorization: Basic <API key>' \
-H 'Content-Type: application/json' \
-H 'Klarna-Network-Session-Token: eyJhbGciOiJIU...' \
-d '{
"locale": "en-US",
"amount": 11836,
"currency": "USD",
"intent": "PAY"
}'