Skip to main content
POST
/
api
/
v1
/
domains
/
{domain}
/
express
/
klarna
/
authorize
Authorize Klarna Checkout
curl --request POST \
  --url https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/authorize \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'x-firmly-authorization: <x-firmly-authorization>' \
  --data '
{
  "attributes": {
    "authorization_token": "<string>"
  }
}
'
{
  "cart_id": "<string>",
  "line_items": [
    {}
  ],
  "payment_method": {
    "payment_type": "<string>",
    "attributes": {
      "session_id": "<string>",
      "authorization_token": "<string>"
    }
  },
  "shipping_info": {},
  "total": {},
  "sub_total": {},
  "tax": {}
}

Documentation Index

Fetch the complete documentation index at: https://developers.firmly.ai/llms.txt

Use this file to discover all available pages before exploring further.

Overview

After the customer authorizes payment in the Klarna widget (client-side), this endpoint confirms the authorization with Firmly. It stores the authorization_token in the session and returns the cart with the confirmed Klarna payment method.

Authentication

x-firmly-authorization
string
required
Device authentication token from Browser Session

Path Parameters

domain
string
required
The merchant domain (e.g., “merchant.example.com”)

Request Body

attributes
object
required
Klarna authorization details

Response

Returns the cart with the confirmed Klarna payment method.
cart_id
string
Unique identifier for the cart
line_items
array
Array of items in the cart
payment_method
object
Confirmed Klarna payment method
shipping_info
object
Delivery address details
total
object
Grand total including all costs
sub_total
object
Subtotal before shipping and tax
tax
object
Tax amount

Code Example

// After Klarna.Payments.authorize() callback returns authorization_token
const response = await fetch(
  'https://cc.firmly.work/api/v1/domains/merchant.example.com/express/klarna/authorize',
  {
    method: 'POST',
    headers: {
      'x-firmly-authorization': authToken,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      attributes: {
        authorization_token: 'klarna_auth_token_from_widget'
      }
    })
  }
);

const cart = await response.json();
// Payment is now authorized, proceed to complete order

Response Example

{
  "cart_id": "9cf76530-1344-420f-9ca6-c7a96fb6db45",
  "line_items": [
    {
      "line_item_id": "3e66bef5-43f5-4a80-8957-91c5c8233163",
      "sku": "MT12",
      "quantity": 1,
      "description": "Cassius Sparring Tank",
      "price": {
        "currency": "USD",
        "value": 18,
        "number": 1800,
        "symbol": "$"
      },
      "line_price": {
        "currency": "USD",
        "value": 18,
        "number": 1800,
        "symbol": "$"
      }
    }
  ],
  "payment_method": {
    "payment_type": "Klarna",
    "attributes": {
      "session_id": "kp_abc123def456",
      "authorization_token": "klarna_auth_token_from_widget"
    }
  },
  "shipping_info": {
    "first_name": "John",
    "last_name": "Smith",
    "email": "john@example.com",
    "phone": "2065551212",
    "address1": "123 Main St",
    "city": "Seattle",
    "state_or_province": "WA",
    "country": "US",
    "postal_code": "98101"
  },
  "total": {
    "currency": "USD",
    "value": 30,
    "number": 3000,
    "symbol": "$"
  },
  "sub_total": {
    "currency": "USD",
    "value": 18,
    "number": 1800,
    "symbol": "$"
  },
  "tax": {
    "currency": "USD",
    "value": 2,
    "number": 200,
    "symbol": "$"
  }
}

Error Responses

CodeDescription
ErrorCartNotFoundNo active cart for this domain
ErrorBadRequestMissing authorization_token in request body
ErrorGatewayNotFoundKlarna is not enabled for this merchant
ErrorPreconditionPrecondition failed (e.g., cart state invalid)
ErrorSubmitExpressCheckoutAuthorization failed at the merchant