![]() | ![]() | ![]() |
| 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 you (the Partner), which is obtained via Klarna’s 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 MESSAGING will exclude the PAYMENT product. |
locale | optional | Language and region code (e.g., en-US). If omitted, Klarna may default based on the customer’s browser settings. |
products are properly specified while initializing for the best performance outcome, by providing only the products that will be used by your web application. For On-Site Messaging to function the MESSAGING product must be provided.placement method that allows to create and mount the messaging placement programmatically:klarna.Messaging.placement({
key: 'credit-promotion-badge',
amount: 20000,
locale: 'en-US',
theme: 'light'
}).mount('#osm-placement');
credit-promotion-badge placement, check the placements page for the full selection of placements.| Parameter | Presence | Description |
|---|---|---|
key | required | Placement type key. List of available keys |
amount | optional | Amount in minor units (e.g., $5.00 = 500), required for credit-promotion-* placements and optional for top-strip-promotion-*. 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 |
top-strip-promotion-* and credit-promotion-*.![]() | ![]() | ![]() |
| Interact with Product or Cart On-site Messaging placement | Go through Klarna Pre-qualification flow | Checkout page reflects prequalified status |
const klarnaNetworkSessionToken = klarna.Network.Session.token();klarna_network_session_token to when you initiate a payment, refer to Paytrail's integration checklist.