Authorize the payment

This guide walks you through integrating Klarna's Payment Authorization process using Klarna's SDK and API. It outlines required actions across the frontend and backend, with input/output parameters, example requests, and expected responses.

Integration overview

Once the customer has selected Klarna and decided to proceed to the payment with Klarna, Acquiring Partners are expected to authorize the payment with Klarna and allow the customer to go through Klarna's Purchase Journey.

The following sequence applies:

  1. Customer clicks on the Klarna Payment button
  2. The javascript function attached to the button click handler initiate is triggered
  3. Acquiring Partner’s backend call Klarna’s Payment Authorize API
  4. Klarna returns one of the following responses:
    1. APPROVED – transaction is completed.
    2. STEP_UP_REQUIRED – customer needs to go through Klarna's Purchase Journey
    3. DECLINED – payment was denied.
  5. The javascript function attached to the initiate button click handler returns a promise resolving to the authorization result

Integration details

Step 1: Handle Payment button click

As described in the previous section, once the customer has selected the Klarna payment option in the payment selector, the Acquiring Partner will need to render the Klarna Payment Button.

The Acquiring Partner will need to configure paymentButton component from the paymentPresentation instance with the following attributes:

  • initiate button click handler: attach a function which triggers your backend to call Klarna’s Payment Authorize APIKlarna Icon and return a promise resolving to the authorization result.
  • initiationMode: This parameter controls how the Klarna Purchase Journey is launched (redirect / pop up window) on different devices (mobile/desktop/native)

Sample code

JAVASCRIPT
async function initiateKlarnaPayment(klarnaNetworkSesionToken, paymentOptionId) {
  try {
    // 1) Ask your backend to authorize the payment
    const response = await fetch('/api/authorize-payment', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ klarnaNetworkSesionToken, paymentOptionId })
    });

    if (!response.ok) throw new Error('Network or server error');
    
    // 2) Handle backend response

The Acquiring Partner can also create a custom button to launch the Klarna Purchase Journey. This is detailed in the Launch the Klarna Purchase Journey with a custom button section.

Step 2: Call the Payment Authorization API

The initiate button click handler attribute from the SDK requires the Acquiring Partner to call Klarna's Payment Authorize API and return the results as a promise to the client-side.

  • When Partners optimize their integration with Klarna, they are likely to have Klarna Network data points to share with the Acquiring Partner.
  • The Acquiring Partner’s Checkout session API should accept klarna_network_session_token and klarna_network_data  parameters and if provided they must be forwarded when calling Klarna's Payment Authorize API.

The Payment Authorize APIKlarna Icon is used to start the payment process on Klarna Network whether they are with or without customer presence.<br />

A one-time payment represents the most common scenario, where the customer completes a single purchase with Klarna. The call may return an immediate authorization (APPROVED) or require additional customer interaction (STEP_UP_REQUIRED).

In the request to the Payment Authorize APIKlarna Icon, specify the following parameters:<br />

Payment AuthorizeKlarna Icon
POST:/v2/accounts/{partner_account_id}/payment/authorize
Show recommended
ParameterRequiredDescription
partner_account_id
Yes

Unique account identifier assigned by Klarna to the onboarded merchant

Here you can find all required parameters for this operation authorizePaymentKlarna Icon
SHELL
curl https://api-global.test.klarna.com/v2/accounts/{partner_account_id}/payment/authorize \
  -H 'Authorization: Basic <API key>' \
  -H 'Content-Type: application/json' \
  -H 'Klarna-Network-Session-Token: eyJhbGciOiJIU...' \
  -d '{
        "currency": "USD",
        "supplementary_purchase_data": { .. },
        "klarna_network_data": "<serialized-json>",
        "request_payment_transaction": {
          "amount": 11800,
          "payment_option_id": "***",
          "payment_transaction_reference": "acquiring-partner-transaction-reference-1234"

Step 3: Handle the Payment Authorization result

When performing customer-present authorization through the Payment Authorize APIKlarna Icon, Klarna returns a response that reflects the result of the authorization. Since this flow includes a request_payment_transaction in the request, the response will always contain a corresponding payment_transaction_response object. The result field inside this object indicates the outcome of the authorization and determines the next step to perform.

The result has the following possible values:

ResultWhat it indicatesRequired next step

APPROVED

The authorization succeeded and a payment_transaction was created.Payment is authorized and ready for post-purchase operations.

DECLINED

The authorization failed (for example, due to fraud, credit, or risk policy) and no transaction was created.`Authorization ends with a failure.

STEP_UP_REQUIRED

This result is returned only if step_up_config was provided in the request and additional customer interaction is needed to complete authorization. A payment_request is created, representing the step-up process.Customer completes Klarna Purchase Journey before authorization can continue.-

Here's the high level diagram of the payment authorization results and resources it produces:

Payment authorization results

The response schema is as follows:

Result: STEP_UP_REQUIRED

Handle this result when Klarna requires additional customer interaction to complete authorization.

  • Read payment_request_id and payment_request_url from the response.
  • Return the payment_request_url to the Partner without modification.
  • The customer (who must be present) completes the Klarna Purchase Journey.
  • Wait for step-up completion before finalizing authorization.

Sample payload

JSON
{
  "payment_transaction_response": {
    "result": "STEP_UP_REQUIRED"
  },
  "payment_request": {
    "payment_request_id": "krn:payment:eu1:request:552603c0-fe8b-4ab1-aacb-41d55fafbdb4",
    "payment_request_reference": "acquiring-partner-request-reference-1234",
    "amount": 11800,
    "currency": "USD",
    "state": "SUBMITTED",
    "expires_at": "2025-01-02T13:00:00Z",
    "created_at": "2025-01-01T12:00:00Z",

Result: APPROVED

Handle this result when Klarna authorizes the payment without requiring customer interaction.

  • Read the payment_transaction from the response.
  • Store the payment_transaction_id.
  • Return a success response to the Partner.
  • Continue with post-purchase operations (for example, capture or refund) using the

Payment Transactions API.

Sample payload

JSON
{
  "payment_transaction_response": {
    "result": "APPROVED",
    "payment_transaction": {
      "payment_transaction_id": "krn:payment:eu1:transaction:6debe89e-98c0-[...]",
      "payment_transaction_reference": "transaction-reference-1234",
      "amount": 11800,
      "currency": "USD",
      "payment_funding": {
        "type": "INVOICE",
        "details": { }
      },

Result: DECLINED

Handle this result when Klarna rejects the authorization.

  • Do not retry the authorization unless explicitly instructed by Klarna.
  • Return a failure response to the Partner.
  • End the payment flow.

Sample payload

JSON
{
  "payment_transaction_response": {
    "result": "DECLINED",
    "result_reason": "PAYMENT_DECLINED"
  }
}

Step 4: Handle the Payment Authorization response (frontend)

Extract and forward the Payment Authorize API response parameters to your frontend:

  • result: the result of the payment authorization attempt
  • payment_request_id: The unique Klarna identifier for the payment request

Update the implementation of the initiate callback to support different results:

JS
async function initiateKlarnaPayment(klarnaNetworkSesionToken, paymentOptionId) {
  try {
    // 1) Ask your backend to authorize the payment
    const response = await fetch('/api/authorize-payment', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ klarnaNetworkSesionToken, paymentOptionId })
    });

    if (!response.ok) throw new Error('Network or server error');

    // 3) Handle backend response