Express Checkout (Klarna)
Authorize Klarna Checkout
Confirms the Klarna authorization token after customer approval in the Klarna widget
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>"
}
}
'import requests
url = "https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/authorize"
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/authorize', 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/authorize",
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/authorize"
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/authorize")
.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/authorize")
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>",
"line_items": [
{}
],
"payment_method": {
"payment_type": "<string>",
"attributes": {
"session_id": "<string>",
"authorization_token": "<string>"
}
},
"shipping_info": {},
"total": {},
"sub_total": {},
"tax": {}
}Overview
After the customer authorizes payment in the Klarna widget (client-side), this endpoint confirms the authorization with Firmly. It stores theauthorization_token in the session and returns the cart with the confirmed Klarna payment method.
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 authorization details
Show Attributes
Show Attributes
string
required
The authorization token received from the Klarna Payments SDK after the customer approves payment. Obtained from the
Klarna.Payments.authorize() callback.Response
Returns the cart with the confirmed Klarna payment method.string
Unique identifier for the cart
array
Array of items in the cart
object
object
Delivery address details
object
Grand total including all costs
object
Subtotal before shipping and 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
import requests
response = requests.post(
'https://cc.firmly.work/api/v1/domains/merchant.example.com/express/klarna/authorize',
headers={
'x-firmly-authorization': auth_token,
'Content-Type': 'application/json'
},
json={
'attributes': {
'authorization_token': 'klarna_auth_token_from_widget'
}
}
)
cart = response.json()
curl -X POST https://cc.firmly.work/api/v1/domains/merchant.example.com/express/klarna/authorize \
-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",
"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
| Code | Description |
|---|---|
ErrorCartNotFound | No active cart for this domain |
ErrorBadRequest | Missing authorization_token in request body |
ErrorGatewayNotFound | Klarna is not enabled for this merchant |
ErrorPrecondition | Precondition failed (e.g., cart state invalid) |
ErrorSubmitExpressCheckout | Authorization failed at the merchant |
Related Endpoints
- Start Klarna Checkout - Create Klarna session first
- Complete Klarna Order - Finalize the order
⌘I
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>"
}
}
'import requests
url = "https://cc.firmly.work/api/v1/domains/{domain}/express/klarna/authorize"
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/authorize', 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/authorize",
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/authorize"
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/authorize")
.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/authorize")
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>",
"line_items": [
{}
],
"payment_method": {
"payment_type": "<string>",
"attributes": {
"session_id": "<string>",
"authorization_token": "<string>"
}
},
"shipping_info": {},
"total": {},
"sub_total": {},
"tax": {}
}