Express Checkout (Klarna)
Complete Klarna Order
Finalizes the order using the Klarna authorization token
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>"
}
}
'import requests
url = "https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/complete-order"
payload = { "attributes": { "authorization_token": "<string>" } }
headers = {
"x-firmly-authorization": "<x-firmly-authorization>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-firmly-authorization': '<x-firmly-authorization>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({attributes: {authorization_token: '<string>'}})
};
fetch('https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/complete-order', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/complete-order",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'attributes' => [
'authorization_token' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-firmly-authorization: <x-firmly-authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/complete-order"
payload := strings.NewReader("{\n \"attributes\": {\n \"authorization_token\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-firmly-authorization", "<x-firmly-authorization>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/complete-order")
.header("x-firmly-authorization", "<x-firmly-authorization>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attributes\": {\n \"authorization_token\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/complete-order")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-firmly-authorization"] = '<x-firmly-authorization>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"attributes\": {\n \"authorization_token\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"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": {}
}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
string
required
Device authentication token from Browser Session
Path Parameters
string
required
The merchant domain (e.g., “merchant.example.com”)
Request Body
object
required
Klarna payment attributes
Show Attributes
Show Attributes
string
required
The Klarna authorization token. Can be provided here or retrieved from the session if the authorize endpoint was already called.
Response
Returns the order confirmation object.string
Unique identifier for the cart
string
The order number from the merchant platform
string
Status of the cart (e.g., “submitted”)
string
ISO timestamp when the order was submitted
string
Merchant’s display name
string
E-commerce platform identifier (e.g., “magento”, “shopify”)
string
Merchant domain
array
object
Delivery address details
object
Billing address details
object
Selected shipping method with pricing
object
object
Grand total including all costs
object
Subtotal before shipping and tax
object
Shipping cost
object
Tax amount
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;
}
import requests
response = requests.post(
'https://cc.firmly.work/api/v1/domains/merchant.example.com/express/klarna/complete-order',
headers={
'x-firmly-authorization': auth_token,
'Content-Type': 'application/json'
},
json={
'attributes': {
'authorization_token': 'klarna_auth_token_from_widget'
}
}
)
order = response.json()
print(f"Order placed: {order['platform_order_number']}")
print(f"Thank you page: {order['urls']['thank_you_page']}")
curl -X POST https://cc.firmly.work/api/v1/domains/merchant.example.com/express/klarna/complete-order \
-H "x-firmly-authorization: YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"attributes": {"authorization_token": "klarna_auth_token_from_widget"}}'
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
| Code | Description |
|---|---|
ErrorCartNotFound | No active cart for this domain |
ErrorBadRequest | Missing authorization_token |
ErrorGatewayNotFound | Klarna is not enabled for this merchant |
ErrorPaymentDeclined | Klarna declined the payment |
ErrorCheckout | Checkout failed at the merchant |
ErrorMissingShippingMethod | No shipping method selected |
ErrorMissingTaxSync | Tax has not been calculated |
ErrorStoreUnavailable | Merchant temporarily unavailable |
Related Endpoints
- Start Klarna Checkout - Create Klarna session
- Authorize Klarna Checkout - Confirm authorization
- Complete Order (Credit Card) - Alternative credit card flow
⌘I
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>"
}
}
'import requests
url = "https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/complete-order"
payload = { "attributes": { "authorization_token": "<string>" } }
headers = {
"x-firmly-authorization": "<x-firmly-authorization>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-firmly-authorization': '<x-firmly-authorization>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({attributes: {authorization_token: '<string>'}})
};
fetch('https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/complete-order', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/complete-order",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'attributes' => [
'authorization_token' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-firmly-authorization: <x-firmly-authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/complete-order"
payload := strings.NewReader("{\n \"attributes\": {\n \"authorization_token\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-firmly-authorization", "<x-firmly-authorization>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/complete-order")
.header("x-firmly-authorization", "<x-firmly-authorization>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attributes\": {\n \"authorization_token\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/complete-order")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-firmly-authorization"] = '<x-firmly-authorization>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"attributes\": {\n \"authorization_token\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"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": {}
}