Skip to main content
POST
/
api
/
v1
/
domains
/
{domain}
/
express
/
klarna
/
complete-order
Complete Klarna Order
curl --request POST \
  --url https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/complete-order \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'x-firmly-authorization: <x-firmly-authorization>' \
  --data '
{
  "attributes": {
    "authorization_token": "<string>"
  }
}
'
{
  "cart_id": "<string>",
  "platform_order_number": "<string>",
  "cart_status": "<string>",
  "submitted_at": "<string>",
  "display_name": "<string>",
  "platform_id": "<string>",
  "shop_id": "<string>",
  "urls": {
    "thank_you_page": "<string>"
  },
  "line_items": [
    {
      "line_item_id": "<string>",
      "sku": "<string>",
      "quantity": 123,
      "description": "<string>",
      "price": {},
      "line_price": {},
      "image": {}
    }
  ],
  "shipping_info": {},
  "billing_info": {},
  "shipping_method": {},
  "payment_summary": {
    "payment_type": "<string>",
    "attributes": {
      "session_id": "<string>",
      "authorization_token": "<string>"
    }
  },
  "total": {},
  "sub_total": {},
  "shipping_total": {},
  "tax": {},
  "cart_discount": {}
}

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

Completes the checkout process by placing an order with the merchant using the Klarna authorization. This is the final step in the Klarna checkout flow. The endpoint validates the authorization token, places the order, and returns the order confirmation with the merchant’s order number.
If the authorize step was skipped, this endpoint will automatically call authorize before completing the order, as long as the authorization_token is provided.

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 payment attributes

Response

Returns the order confirmation object.
cart_id
string
Unique identifier for the cart
platform_order_number
string
The order number from the merchant platform
cart_status
string
Status of the cart (e.g., “submitted”)
submitted_at
string
ISO timestamp when the order was submitted
display_name
string
Merchant’s display name
platform_id
string
E-commerce platform identifier (e.g., “magento”, “shopify”)
shop_id
string
Merchant domain
urls
object
Relevant URLs for the order
line_items
array
Array of items in the order
shipping_info
object
Delivery address details
billing_info
object
Billing address details
shipping_method
object
Selected shipping method with pricing
payment_summary
object
Summary of the Klarna payment
total
object
Grand total including all costs
sub_total
object
Subtotal before shipping and tax
shipping_total
object
Shipping cost
tax
object
Tax amount
cart_discount
object
Total discount applied

Code Example

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

const order = await response.json();
console.log('Order number:', order.platform_order_number);

// Redirect to thank you page
if (order.urls?.thank_you_page) {
  window.location.href = order.urls.thank_you_page;
}

Response Example

{
  "cart_id": "9cf76530-1344-420f-9ca6-c7a96fb6db45",
  "platform_order_number": "6800018416",
  "cart_status": "submitted",
  "submitted_at": "2024-07-22T18:58:25.000Z",
  "display_name": "Example Store",
  "platform_id": "magento",
  "shop_id": "merchant.example.com",
  "urls": {
    "thank_you_page": "https://merchant.example.com/checkout/onepage/success/"
  },
  "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": "$"
      },
      "image": {
        "url": "https://merchant.example.com/pub/media/catalog/product/mt12-blue_main.jpg"
      }
    }
  ],
  "shipping_info": {
    "first_name": "John",
    "last_name": "Smith",
    "email": "john@example.com",
    "phone": "(206) 555-1212",
    "address1": "123 Main St",
    "city": "Seattle",
    "state_or_province": "Washington",
    "country": "US",
    "postal_code": "98101"
  },
  "billing_info": {
    "first_name": "John",
    "last_name": "Smith",
    "email": "john@example.com",
    "phone": "(206) 555-1212",
    "address1": "123 Main St",
    "city": "Seattle",
    "state_or_province": "Washington",
    "country": "US",
    "postal_code": "98101"
  },
  "shipping_method": {
    "id": "s2_2_day",
    "description": "2-Day Shipping",
    "price": {
      "currency": "USD",
      "value": 12,
      "number": 1200,
      "symbol": "$"
    }
  },
  "payment_summary": {
    "payment_type": "Klarna",
    "attributes": {
      "session_id": "kp_abc123def456",
      "authorization_token": "klarna_auth_token_from_widget"
    }
  },
  "total": {
    "currency": "USD",
    "value": 32,
    "number": 3200,
    "symbol": "$"
  },
  "sub_total": {
    "currency": "USD",
    "value": 18,
    "number": 1800,
    "symbol": "$"
  },
  "shipping_total": {
    "currency": "USD",
    "value": 12,
    "number": 1200,
    "symbol": "$"
  },
  "tax": {
    "currency": "USD",
    "value": 2,
    "number": 200,
    "symbol": "$"
  },
  "cart_discount": {
    "currency": "USD",
    "value": 0,
    "number": 0,
    "symbol": "$"
  }
}

Error Responses

CodeDescription
ErrorCartNotFoundNo active cart for this domain
ErrorBadRequestMissing authorization_token
ErrorGatewayNotFoundKlarna is not enabled for this merchant
ErrorPaymentDeclinedKlarna declined the payment
ErrorCheckoutCheckout failed at the merchant
ErrorMissingShippingMethodNo shipping method selected
ErrorMissingTaxSyncTax has not been calculated
ErrorStoreUnavailableMerchant temporarily unavailable