Klarna Docs - 2.2: Get authorization

2.2: Get authorization

Now that your customer selected Klarna to pay, let's get the purchase authorized.

When your customer selects Klarna to pay, you need to use our JavaScript SDK to get authorization for the purchase.

In this step, you send all the necessary customer details for Klarna to assess and decide whether or not to accept this purchase. When the authorization is successful, you receive an authorization token as a response, useful for Step 3: Create an order.

The authorization is possible through the authorize() call happening on the client side.

The following information is useful for both scenarios, one-time and recurring payments.

Get authorization for the purchase by using the authorize() call. We recommend sending the following parameters in the data object of the authorize call:

  • billing_address, containing the customer's biling address.
  • shipping_address, containing the customer's shipping address. If you don't provide a shipping address, we copy the billing address and use it as the shipping address.

If no billing or shipping address is provided, new Klarna customers have to manually enter their full billing address on the Klarna payment page. Providing the billing address in the authorize() call enables Klarna to prefill the signup form for new customers.

    billing_address: {
      given_name: "Alice",
      family_name: "Test",
      email: "customer@email.se",
      street_address: "Södra Blasieholmshamnen 2",
      postal_code: "11 148",
      city: "Stockholm",

A sample authorize() call.

In some cases, Klarna requires additional information about the customer and purchase. We recommend you send it in the authorize() call. For more information, see the Extra merchant data section.

For GDPR (General Data Protection Regulation) reasons, you shouldn't send customer data before the authorize() call.

Klarna uses all this information to make the risk assessment. To see what data you need per market and how to format it, check the customer data requirements.

During the authorize() call and until you receive the callback, Klarna runs a purchase flow that includes a risk assessment. You need to visually indicate to your customer that an ongoing process is happening. For a better user experience, we suggest:

  • Avoiding another authorize() call (for example, disable the buy button)
  • Showing your customer that the order is in progress (for example, show a loading spinner)
  • Preventing your customer from changing the order or billing details (for example, lock the input fields on your page).

There are three potential cases that you need to handle based on the response:

  • Success response: The purchase is approved.
  • Fixable error response: The customer needs to adjust and try again.
  • Error response: The purchase is not approved and you can't display Klarna as a payment option.

If the response is approved: true, Klarna has approved the authorization for this purchase and as a response you will received the response including:

  • approved, containing the authorization result. It's a boolean value that indicates approved or denied.
  • show_form, showing the availability of Klarna as a payment option. It's a boolean value that indicates displayed or hidden.
  • authorization_token, containing the token that allows you to place the order. This is only returned if it's an approved authorization.
  • error, contanining details of potential error messages.

authorization_token allows you to create an order for both scenarios, recurring and one-time payments. The token is valid for 60 minutes.

  "show_form": true,
  "approved": true,
  "finalize_required": false,
  "authorization_token": "0eb73d2c-d55a-5358-9080-ddc3903e3941"

A sample finalize() response from Klarna.

Authorization callback

By using the server-side authorization callback, you will be able to obtain the corresponding authorization_token and session_id in the back-end still in the case of any client-side communication issues, which will allow you to create an order and improve the consumer experience in the case of front-end incident.

  "authorization_token": "0eb73d2c-d55a-5358-9080-ddc3903e3941",
  "session_id": "e4b81ca2-0aae-4c16-bcb2-29a0a088a35b"

A sample server-side callback request from Klarna.

For more details, see the authorization callbacks documentation.

Fixable error response

If the response of the authorize is not successful with show_form: true and an error object containing invalid_fields, something fixable is wrong and the customer needs to take action. An error message is displayed asking the customer to make corrections before you re-authorize the purchase. The error message points out which fields are incorrect.

It's also possible that the response is approved: false and show_form: true, but the callback doesn't include error. This means the customer has terminated a required interaction in the widget, such as authentication or sign-up flows. In this case, you should keep Klarna visible so that the customer can make another purchase attempt.

approved: false,
show_form: true,
error: {
  invalid_fields: [

A sample fixable error response.

We suggest you use the error message in the authorize() response to highlight a specific input field on your page.

Error response

If the response is show_form: false, your store is not able to offer Klarna as a payment option. You should disable Klarna from your checkout, and your customer might select another payment method.

This negative response results from the pre-assessment that Klarna executes for the purchase.

approved: false,
show_form: false

A sample error response.