Build payment form with API

Integrate Payment Presentation API to display branded payment options when SDK use isn’t feasible, ensuring a consistent and compliant checkout experience.

If Acquiring Partners cannot use the Klarna SDK to retrieve the presentation instruction due to infrastructure constraints on their end, they must utilize Klarna Payment Presentation API to retrieve the assets and instructions necessary to build the payment selector.

The Klarna Payment Presentation APIAPI enables Acquiring Partners to retrieve Klarna-branded presentation assets (e.g. button text, icons, descriptors) tailored to a specific payment context. These assets help Partners render Klarna in compliance with Klarna’s brand and UX guidelines.

Before calling Klarna’s Payment Presentation API, ensure your backend accepts and forwards the Klarna specific parameters. These include the interoperability token which preserve session context as well as basic transaction parameters (amount, currency, locale) which will allow Klarna to deliver tailored assets to build the payment form.

Klarna Presentation API's require an interoperability token in order to provide personalized features when displaying Klarna in the payment form.

If an interoperability token was provided by the Partner requesting a checkout form, it must be forwarded to Klarna in headers.

In the request to the Payment Presentation APIAPI, the Acquiring Partner will specify the following parameters:

Path

ParameterDescription

partner_account_idAPI

The unique identifier of the Partner account. This is used to scope the request.

Header

ParameterDescription

AuthorizationAPI

Acquiring Partners use their Klarna API key to authenticate:
Basic <API key>

Klarna-Interoperability-TokenAPI

Must contain the interoperability token if provided by the Partner.

Body

ParameterDescription

localeAPI

The locale to use for localization of Klarna assets (IETF BCP 47 format e.g., en-US, fr-FR).

amountAPI

The total payment amount in minor units (e.g., 11836 = $118.36).

currencyAPI

ISO 4217 3-letter currency code (e.g., USD, EUR).

intentsAPI

List of requested intents. Currently, ["PAY"] is the supported value.

Sample request body

SHELL
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-Interoperability-Token: eyJhbGciOiJIU...' \
  -d '{
        "locale": "en-US",
        "amount": 11836,
        "currency": "USD",
        "intents": ["PAY"]
      }'

The response from Klarna will contain the following parameters:

FieldTypeDescription

instructionAPI

stringKlarna display instruction (e.g., SHOW_KLARNA, etc.).

payment_statusAPI

stringStatus of the payment process. (e.g., REQUIRES_CUSTOMER_ACTION, etc.).

payment_buttonAPI

objectContains the label to be used on the Klarna payment button.

descriptorAPI

objectContains all Klarna display assets for the payment selector, including:
  • header

    : Main title (e.g., "Pay with Klarna")
  • subheader.short

    : Short message (e.g., "Pay in 4.")
  • subheader.enriched

    : Detailed offer text with optional link
  • icon

    : Badge images (square, rectangle, alt text)

Sample response

JSON
{
  "instruction": "SHOW_KLARNA",
  "payment_status": "REQUIRES_CUSTOMER_ACTION",
  "payment_button": {
    "text": "Pay with Klarna"
  },
  "descriptor": {
    "header": {
      "text": "Pay with Klarna"
    },

The Acquiring Partner must used the assets returned by the presentation API (text, link, instruction) to display Klarna when loading the checkout form. In this step it is needed to present to the customer Klarna as an available payment method and initially only 3 elements should be presented to the customer:

  1. Icon
  2. Header
  3. Subheader

The Acquiring Partner must use the instruction attribute returned in the response to the Payment Presentation API to dynamically build the payment selector. The instruction attribute will contain one of the following values:

InstructionDescription

SHOW_KLARNA

This is the default value returned. When received, show Klarna alongside other payment methods.

PRESELECT_KLARNA

This is returned when the customer has logged in using the Sign in with Klarna feature. In this scenario the customer has used Klarna to login, however this does not indicate a clear intention to pay with Klarna. Therefore Klarna should be pre-selected but still alongside others.

SHOW_ONLY_KLARNA

This is returned when the customer has finished the first step of Klarna Express Checkout multistep. Since the customer has already shown intention to pay with Klarna, this should be the only payment method displayed.

HIDE_KLARNA

This value is returned when the Partner has been identified as fraudulent and subsequently terminated. As a result, the Partner is no longer able to use Klarna services—functionality is fully disabled, and Klarna should no longer be displayed in the checkout.

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 KlarnaPreselect KlarnaShow only KlarnaHide Klarna

The presentation instructions are derived from possible customer purchase journeys described in the following article.

The links present in the api response(enriched.link.href), must be opened only a new tab or new window. Please avoid using iframes.

Once the customer has decided to proceed to the Payment using Klarna, or if Klarna was pre-selected due to the presentation instruction seen above, Acquiring Partners have to refresh the layout, build and present the Klarna Enriched Subheader as well as payment button using the assets (text, link) provided by the Payment Presentation API.

  1. Icon
  2. Header
  3. Subheader
  4. Message
  5. Payment Button

To correctly render the Klarna Payment button, include Klarna’s CSS and configure the button with your preferred theme, shape, and copy.

Sample code

HTML
<link rel="stylesheet" href="https://js.klarna.com/web-sdk/buttons/payment-button.css" />
  <button
    style="width: 100%"
    class="klarna-sdk-button theme-outlined shape-rect"
    aria-label="Continue with Klarna"
  >
    <div class="klarna-sdk-button__outline" aria-hidden="true">

</div>

Payment button variants

You can adjust the button’s appearance and behavior by customizing the following:

Theme

Klarna provides multiple theme options to match your site’s design. Update the button class to switch between themes:

HTML
   class="klarna-sdk-button theme-outlined shape-rect"
theme-darktheme-lighttheme-outlined

Dark background

Don’t use dark theme on black or dark backgrounds. The button must be used on backgrounds that provide sufficient contrast.

Light background

​Don’t use light theme on white or light backgrounds. The button must be used on backgrounds that provide sufficient contrast.

Shape

The Klarna button supports multiple shapes. Update the class to choose the appropriate option:

HTML
    class="klarna-sdk-button theme-outlined shape-rect"
shape-defaultshape-pillshape-rect
Button copy

Use the payment_button.text value from the response to dynamically set the button label for each market. If this can't be retrieved from the response, Klarna provides approved translations per market that can be used as a fallback.

To update button text and accessibility labels:

  • Update the aria-label for accessibility.
  • Update the klarna-sdk-button-copy text for the visible button label.
HTML
<button aria-label="Continue with Klarna">
  <span class="klarna-sdk-button-copy">Continue with</span>
</button>
Button size

Width

Prominently display the Klarna button. Make the button the same width as other payment buttons in stacked button layouts.

Height

The default recommended height of the Klarna button is 48px and the min height allowed is 40px. Make sure the button is the same height of other payment buttons.