Klarna Checkout Adapter
Overview Document: Payment Adapters Overview
Klarna is transitioning from Klarna Checkout (KCO) to Kustom Checkout. See how to migrate to Kustom Checkout for configuration guidance.
Overview and Unique Capabilities
The Klarna Checkout Adapter integrates Klarna Checkout with Norce Checkout. This page focuses on the unique technical details and configuration for Klarna.
Supported payment methods and other features: Features Overview
Configuration in Norce Admin
The adapter is configured using the following unique details obtained from Klarna:
API Settings (required)
| Field | Description | Example Value |
|---|---|---|
apiSettings.apiUrl | Klarna Checkout API URL (test or production). | https://api.klarna.com |
apiSettings.username | Your Klarna API username. | PK12345_abcdef |
apiSettings.password | Your Klarna API password. | xyz123abc |
Redirect URLs (required)
| Field | Description | Example Value |
|---|---|---|
redirectUrls.termsUrl | URL to your terms and conditions page. | https://your-store.com/terms |
redirectUrls.checkoutUrl | URL to your checkout page (for back navigation). | https://your-store.com/checkout |
redirectUrls.confirmationUrl | URL to redirect after successful payment. Supports {orderId} and {channel} placeholders. | https://your-store.com/confirmation/{orderId} |
redirectUrls.validationErrorUrl | URL to redirect when validation fails. | https://your-store.com/checkout/error |
Shipping Countries (required)
| Field | Description | Example Value |
|---|---|---|
shippingCountries | List of countries where shipping is available (ISO 3166 alpha-2). | ["SE", "NO", "FI", "DK"] |
Optional Configuration
| Field | Description | Default |
|---|---|---|
options.useRecurringPayment | Enable recurring payment token generation for subscriptions. | false |
providesShipping | Enable Klarna-provided shipping options within the iframe. | false |
options.allowSeparateShippingAddress | Allow different billing and shipping addresses. | false (except DE: true) |
options.allowedCustomerTypes | Array of allowed customer types: ["person"], ["organization"], or ["person", "organization"] for B2B support. | — |
options.dateOfBirthMandatory | Require date of birth from customer. | false |
options.phoneMandatory | Require phone number from customer (DACH countries only). | false |
options.titleMandatory | Require title from customer (GB only). | false |
options.nationalIdentificationNumberMandatory | Require national ID in SE, NO, FI, DK. Contact Klarna to read this value in validation callback. | false |
options.verifyNationalIdentificationNumber | Enable verification of national ID (SE, FI, NO only). Also makes national ID mandatory. | false |
options.showVatRegistrationNumberField | Show optional VAT registration number field (B2B orders only). | false |
options.vatRemoved | Hide VAT in Checkout's Order Summary page. | false |
options.showSubtotalDetail | Expand Order Detail subtotals view when iframe loads. | false |
options.acquiringChannel | Acquiring channel for the order. Values: ECOMMERCE, MOTO, IN_STORE, TELESALES. | ECOMMERCE |
options.shippingDetails | Message displayed on confirmation page under "Delivery" headline. | — |
options.additionalMerchantTerms | Extra terms and conditions to show in checkout. | — |
options.merchantReferenceSource | Controls how merchant references are mapped. Values: OrderId, OrderCartReference, OrderReference. | OrderId |
The merchantReferenceSource option determines how Klarna's merchant_reference1 and merchant_reference2 fields are populated:
OrderId:merchant_reference1= Order.Id,merchant_reference2= Order.Cart.ReferenceOrderCartReference:merchant_reference1= Order.Cart.Reference,merchant_reference2= Order.IdOrderReference:merchant_reference1= Order.Reference,merchant_reference2= Order.Id
Checkout UI Customization
| Field | Description |
|---|---|
options.colorButton | Button background color (CSS hex value, e.g., #FF0000). |
options.colorButtonText | Button text color (CSS hex value). |
options.colorCheckbox | Checkbox color (CSS hex value). |
options.colorCheckboxCheckMark | Checkbox checkmark color (CSS hex value). |
options.colorHeader | Header color (CSS hex value). |
options.colorLink | Hyperlink color (CSS hex value). |
options.radiusBorder | Border radius for UI elements (e.g., 5px). |
External Payment Methods
External payment methods allow you to offer additional payment options within the Klarna Checkout iframe that redirect customers to external payment providers. Configure these in the externalPaymentMethods array:
| Field | Description | Required |
|---|---|---|
name | Display name of the payment provider. | Yes |
redirectUrl | URL to redirect to when selected. Supports placeholders: {orderId}, {order.id}, {order.merchant}, {order.channel}. | Yes |
imageUrl | URL to an image/logo for the payment method. | No |
fee | Additional fee in minor units (includes tax). | No |
description | Short description displayed below the payment method. | No |
countries | Limit availability to specific countries (ISO alpha-2 codes). | No |
Example configuration:
{
"externalPaymentMethods": [
{
"name": "Swish",
"redirectUrl": "https://your-store.com/checkout/swish?orderId={orderId}",
"imageUrl": "https://your-cdn.com/swish-logo.png",
"description": "Pay instantly with Swish",
"countries": ["SE"]
}
]
}Shipping Options (Klarna-Provided Shipping)
When providesShipping is enabled, you can configure static shipping options that appear within the Klarna Checkout iframe. Configure these in the shippingOptions array:
| Field | Description | Required |
|---|---|---|
id | Unique identifier for the shipping option. | Yes |
name | Display name of the shipping option. | Yes |
price | Price in minor units including tax (e.g., 4900 = 49.00 SEK). | Yes |
taxAmount | Tax amount in minor units. | Yes |
taxRate | Tax rate with two implicit decimals (e.g., 2500 = 25%). | Yes |
description | Optional description text. | No |
preselected | Set to true to preselect this option. | No |
shippingMethod | Shipping method type. Values: PickUpStore, Home, BoxReg, BoxUnreg, PickUpPoint, Own, Postal, DHLPackstation, Digital. | No |
Example configuration:
{
"shippingOptions": [
{
"id": "home-delivery",
"name": "Home Delivery",
"description": "Delivered to your door within 2-3 business days",
"price": 4900,
"taxAmount": 980,
"taxRate": 2500,
"preselected": true,
"shippingMethod": "Home"
},
{
"id": "pickup-point",
"name": "Pickup Point",
"price": 0,
"taxAmount": 0,
"taxRate": 2500,
"shippingMethod": "PickUpPoint"
}
]
}When shippingMethod is set to DHLPackstation, Klarna displays the appropriate form for customers to enter their Packstation details.
Klarna API Environments
In addition to the generic Norce Adapter URLs (see Payment Adapters Overview), Klarna uses the following external API environments:
| Environment | Klarna API Base URL |
|---|---|
| Production | https://api.klarna.com |
| Playground | https://api.playground.klarna.com |
Creating a Payment
To create a Klarna Checkout order and receive the HTML snippet for embedding:
POST /api/checkout/v1/orders/{order_id}/payments
Host: {slug}.api-se.stage.norce.tech
x-merchant: {merchant}
x-channel: {channel}
Authorization: Bearer {token}The response includes the Klarna Checkout HTML snippet:
{
"id": "p_KBiXuYjvYxsezKCQAMuuSKGDaT",
"status": "CHECKOUT_INCOMPLETE",
"htmlSnippet": "<div id='klarna-checkout-container'><script>...</script></div>"
}Embed the htmlSnippet in your checkout page to display the Klarna Checkout iframe.
Creating a Recurring Payment
To create an order using a previously stored recurring token:
POST /api/checkout/v1/orders/{order_id}/payments/recurring
Host: {slug}.api-se.stage.norce.tech
x-merchant: {merchant}
x-channel: {channel}
Authorization: Bearer {token}
Content-Type: application/json
{
"token": "dc50da60-3bf4-4a70-9290-a89629cae418",
"autoCapture": false
}The autoCapture parameter determines whether the payment should be captured immediately:
true: Payment is captured immediately (useful for digital goods)false: Payment is only authorized, requiring a separate capture request
If the token is valid and fraud_status is ACCEPTED, the order is completed immediately. If fraud status is not accepted, the order is marked as "Accepted" with a pending payment status.
When recurring payments are enabled and a customer completes a purchase, the payment object includes a recurring.token field. Store this token securely to create future orders without customer interaction.
Updating a Klarna Checkout Order
When the cart changes during checkout, update the Klarna order to reflect the new totals. First suspend the Klarna Checkout UI with JavaScript, then call the update endpoint:
PUT /api/checkout/v1/orders/{order_id}/payments/{payment_id}
Host: {slug}.api-se.stage.norce.tech
x-merchant: {merchant}
x-channel: {channel}
Authorization: Bearer {token}After the update completes, resume the Klarna Checkout UI to display the new totals. See Klarna Checkout documentation for details on suspending and resuming the checkout.
Validation Callback
When the customer clicks "Place order" in the Klarna Checkout UI, a validation request is sent to the adapter. At this stage, the adapter updates the payment address so you can identify the customer. You can configure Norce Checkout to validate that all products are still available in stock and that all discounts are valid.
If validation succeeds, the adapter returns HTTP 200 and Klarna continues with confirming the payment. The Norce order transitions to the processing state and is locked from further changes except status updates.
If validation fails, the adapter returns HTTP 400 with a localized error message that Klarna displays to the customer in a popup. The customer is then redirected to the validationErrorUrl.
Confirmation Page
After payment is confirmed, Klarna redirects the customer to the confirmation callback endpoint, which then redirects to your configured confirmationUrl. On your confirmation page, retrieve the Klarna Checkout order to display the confirmation snippet:
GET /api/checkout/v1/orders/{order_id}/payments/{payment_id}
Host: {slug}.api-se.stage.norce.tech
x-merchant: {merchant}
x-channel: {channel}
Authorization: Bearer {token}The response includes the confirmation snippet:
{
"id": "p_KBiXuYjvYxsezKCQAMuuSKGDaT",
"status": "CHECKOUT_COMPLETE",
"htmlSnippet": "<div id='klarna-checkout-container'><script>...</script></div>"
}If the confirmation callback fails due to communication issues, Klarna sends a push notification approximately 2 minutes after payment confirmation. This ensures the order is completed in Norce Checkout even if the customer's browser fails to reach the confirmation endpoint.
Troubleshooting (Klarna Specific)
In addition to the generic troubleshooting steps:
- Review the order status directly in Klarna's Merchant Portal.
- If Capture fails, verify the Norce order is in the reserved state and that the Klarna order status is AUTHORIZED.
- For validation failures, check that all products are still available and discounts are valid.
- Use the Klarna-specific refresh call to update available payment actions:
POST /api/order/v1/orders/{order_id}/payments/{payment_id}/refresh-kco
Host: {slug}.api-se.stage.norce.tech
x-merchant: {merchant}
x-channel: {channel}
Authorization: Bearer {token}