The Klarna Web SDK follows JavaScript module approach
and you should include it where you need a reference to the SDK, such as when
rendering components or initiating a payment flow. Always load the script directly
from https://js.klarna.com/web-sdk/v2/klarna.mjs, rather
than included in a bundle or hosted yourself.
Initiating the SDK with credentials
Klarna Web SDK can be imported directly as JS module. The products array should
be updated according to your needs, ensuring that only the utilized products are
specified for the best performance:
// Klarna SDK ready to be used // Klarna.Payment.button().mount('#payment_container') </script>
For Acquiring Partners or integrators with complex account setups
For Acquiring Partners or integrators with complex account setups, two fields
tell Klarna which account the SDK acts for:
partnerAccountId refers to a specific Klarna Partner Account.
acquiringConfig refers to one Payment Account within that Partner Account.
Set it when the Partner Account has more than one Payment Account, with either
paymentAccountId, or paymentAcquiringAccountId and paymentAccountReference.
// Klarna SDK ready to be used // Klarna.Payment.button().mount('#payment_container') </script>
To change the Payment Account after initialization, use
Klarna.Config.setAcquiringConfig.
Loading SDK with bundlers
Since the SDK is offered as JS a module, you can import the module directly in any
JavaScript file. However, module bundlers such as webpack / rollup will try to load
the library while compiling which is not possible since its loaded from a CDN and
not as npm module. To avoid any errors, please use appropriate ignore mechanism for
respective bundlers. For webpack, the syntax will be following:
Including Klarna Web SDK
The Klarna Web SDK follows JavaScript module approach and you should include it where you need a reference to the SDK, such as when rendering components or initiating a payment flow. Always load the script directly from https://js.klarna.com/web-sdk/v2/klarna.mjs, rather than included in a bundle or hosted yourself.
Initiating the SDK with credentials
Klarna Web SDK can be imported directly as JS module. The
productsarray should be updated according to your needs, ensuring that only the utilized products are specified for the best performance:For Acquiring Partners or integrators with complex account setups
For Acquiring Partners or integrators with complex account setups, two fields tell Klarna which account the SDK acts for:
partnerAccountIdrefers to a specific Klarna Partner Account.acquiringConfigrefers to one Payment Account within that Partner Account. Set it when the Partner Account has more than one Payment Account, with eitherpaymentAccountId, orpaymentAcquiringAccountIdandpaymentAccountReference.To change the Payment Account after initialization, use
Klarna.Config.setAcquiringConfig.Loading SDK with bundlers
Since the SDK is offered as JS a module, you can import the module directly in any JavaScript file. However, module bundlers such as webpack / rollup will try to load the library while compiling which is not possible since its loaded from a CDN and not as npm module. To avoid any errors, please use appropriate ignore mechanism for respective bundlers. For webpack, the syntax will be following:
Supported browsers:
Klarna Web SDK supports the following set of browsers:
You can see the full supported list here. Ensure that your usage of the SDK aligns with these browsers to guarantee full functionality.