4. Place Order

You finalize the order in this step via a server side call. Before you place the order, you must have received an authorization_token from the previous step. For a recurring order, the customer token created in the previous step can be used.

4.1. The Merchant places a single order

When you have received the authorization_token you can place the order. Among the other order details in this request, you include a URL to the confirmation page for the customer.

If place order is called more than 60 minutes after the authorization or if different order details are provided the order may be rejected.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
POST /payments/v1/authorizations/<authorization_token>/order
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json
{
    "purchase_country": "GB",
    "purchase_currency": "GBP",
    "billing_address": {
        "given_name": "John",
        "family_name": "Doe",
        "email": "john@doe.com",
        "title": "Mr",
        "street_address": "13 New Burlington St",
        "street_address2": "Apt 214",
        "postal_code": "W13 3BG",
        "city": "London",
        "region": "",
        "phone": "01895808221",
        "country": "GB"
    },
    "shipping_address": {
        "given_name": "John",
        "family_name": "Doe",
        "email": "john@doe.com",
        "title": "Mr",
        "street_address": "13 New Burlington St",
        "street_address2": "Apt 214",
        "postal_code": "W13 3BG",
        "city": "London",
        "region": "",
        "phone": "01895808221",
        "country": "GB"
    },
    "order_amount": 10,
    "order_tax_amount": 0, // optional
    "order_lines": [
        {
            "type": "physical", // optional
            "reference": "19-402", // optional
            "name": "Battery Power Pack",
            "quantity": 1,
            "unit_price": 10,
            "tax_rate": 0, // optional
            "total_amount": 10,
            "total_discount_amount": 0, // optional
            "total_tax_amount": 0, // optional
            "product_url": "https://www.estore.com/products/f2a8d7e34", // optional
            "image_url": "https://www.exampleobjects.com/logo.png" // optional
        }
    ],
    "merchant_urls": {
        "confirmation": "https://example.com/confirmation",
        "notification": "https://example.com/pending" // optional
    },
    "merchant_reference1": "45aa52f387871e3a210645d4", // optional
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
POST /payments/v1/authorizations/<authorization_token>/order
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json
{
    "purchase_country": "DE",
    "purchase_currency": "EUR",
    "billing_address": {
        "given_name": "Omer",
        "family_name": "Heberstreit",
        "email": "omer@Heberstreit.com",
        "title": "Herr",
        "street_address": "Im Friedenstal 38",
        "postal_code": "55006",
        "city": "WestSchon Matishagenfeld",
        "region": "",
        "phone": "+491522113356",
        "country": "DE"
    },
    "shipping_address": {
        "given_name": "Omer",
        "family_name": "Heberstreit",
        "email": "omer@Heberstreit.com",
        "title": "Herr",
        "street_address": "Im Friedenstal 38",
        "postal_code": "55006",
        "city": "WestSchon Matishagenfeld",
        "region": "",
        "phone": "+491522113356",
        "country": "DE"
    },
    "order_amount": 10,
    "order_tax_amount": 0, // optional
    "order_lines": [
        {
            "type": "physical", // optional
            "reference": "19-402", // optional
            "name": "Battery Power Pack",
            "quantity": 1,
            "unit_price": 10,
            "tax_rate": 0, // optional
            "total_amount": 10,
            "total_discount_amount": 0, // optional
            "total_tax_amount": 0, // optional
            "product_url": "https://www.estore.com/products/f2a8d7e34", // optional
            "image_url": "https://www.exampleobjects.com/logo.png" // optional
        }
    ],
    "merchant_urls": {
        "confirmation": "https://example.com/confirmation",
        "notification": "https://example.com/pending" // optional
    },
    "merchant_reference1": "45aa52f387871e3a210645d4", // optional
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
POST /payments/v1/authorizations/<authorization_token>/order
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json
{
    "purchase_country": "AT",
    "purchase_currency": "EUR",
    "billing_address": {
        "given_name": "Edwin",
        "family_name": "Blochwitz",
        "email": "edwin@blochwitz.com",
        "title": "Herr",
        "street_address": "Paul Peters-Gasse 60b",
        "postal_code": "1733",
        "city": "WestZerlachmouth",
        "region": "OO",
        "phone": "+43 676 2600000",
        "country": "AT"
    },
    "shipping_address": {
        "given_name": "Edwin",
        "family_name": "Blochwitz",
        "email": "edwin@blochwitz.com",
        "title": "Herr",
        "street_address": "Paul Peters-Gasse 60b",
        "postal_code": "1733",
        "city": "WestZerlachmouth",
        "region": "OO",
        "phone": "+43 676 2600000",
        "country": "AT"
    },
    "order_amount": 10,
    "order_tax_amount": 0, // optional
    "order_lines": [
        {
            "type": "physical", // optional
            "reference": "19-402", // optional
            "name": "Battery Power Pack",
            "quantity": 1,
            "unit_price": 10,
            "tax_rate": 0, // optional
            "total_amount": 10,
            "total_discount_amount": 0, // optional
            "total_tax_amount": 0, // optional
            "product_url": "https://www.estore.com/products/f2a8d7e34", // optional
            "image_url": "https://www.exampleobjects.com/logo.png" // optional
        }
    ],
    "merchant_urls": {
        "confirmation": "https://example.com/confirmation",
        "notification": "https://example.com/pending" // optional
    },
    "merchant_reference1": "45aa52f387871e3a210645d4", // optional
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
POST /payments/v1/authorizations/<authorization_token>/order
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json
{
    "purchase_country": "NL",
    "purchase_currency": "EUR",
    "billing_address": {
        "given_name": "Sander",
        "family_name": "Dekker",
        "email": "sander@dekker.com",
        "title": "Dhr.",
        "street_address": "Boerpark 742 II",
        "postal_code": "7551 JI",
        "city": "Enschede",
        "phone": "06-14341727",
        "country": "NL"
    },
    "shipping_address": {
        "given_name": "Sander",
        "family_name": "Dekker",
        "email": "sander@dekker.com",
        "title": "Dhr.",
        "street_address": "Boerpark 742 II",
        "postal_code": "7551 JI",
        "city": "Enschede",
        "phone": "06-14341727",
        "country": "NL"
    },
    "order_amount": 10,
    "order_tax_amount": 0, // optional
    "order_lines": [
        {
            "type": "physical", // optional
            "reference": "19-402", // optional
            "name": "Battery Power Pack",
            "quantity": 1,
            "unit_price": 10,
            "tax_rate": 0, // optional
            "total_amount": 10,
            "total_discount_amount": 0, // optional
            "total_tax_amount": 0, // optional
            "product_url": "https://www.estore.com/products/f2a8d7e34", // optional
            "image_url": "https://www.exampleobjects.com/logo.png" // optional
        }
    ],
    "merchant_urls": {
        "confirmation": "https://example.com/confirmation",
        "notification": "https://example.com/pending" // optional
    },
    "merchant_reference1": "45aa52f387871e3a210645d4", // optional
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
POST /payments/v1/authorizations/<authorization_token>/order
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json
{
    "purchase_country": "DK",
    "purchase_currency": "DKK",
    "billing_address": {
        "given_name": "Michael",
        "family_name": "Sorensen",
        "email": "michael@sorensen.com",
        "street_address": "Nygyde 8",
        "postal_code": "2042",
        "city": "København",
        "phone": "29911076",
        "country": "DK"
    },
    "shipping_address": {
        "given_name": "Michael",
        "family_name": "Sorensen",
        "email": "michael@sorensen.com",
        "street_address": "Nygyde 8",
        "postal_code": "2042",
        "city": "København",
        "phone": "29911076",
        "country": "DK"
    },
    "order_amount": 10,
    "order_tax_amount": 0, // optional
    "order_lines": [
        {
            "type": "physical", // optional
            "reference": "19-402", // optional
            "name": "Battery Power Pack",
            "quantity": 1,
            "unit_price": 10,
            "tax_rate": 0, // optional
            "total_amount": 10,
            "total_discount_amount": 0, // optional
            "total_tax_amount": 0, // optional
            "product_url": "https://www.estore.com/products/f2a8d7e34", // optional
            "image_url": "https://www.exampleobjects.com/logo.png" // optional
        }
    ],
    "merchant_urls": {
        "confirmation": "https://example.com/confirmation",
        "notification": "https://example.com/pending" // optional
    },
    "merchant_reference1": "45aa52f387871e3a210645d4", // optional
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
POST /payments/v1/authorizations/<authorization_token>/order
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json
{
    "purchase_country": "NO",
    "purchase_currency": "NOK",
    "billing_address": {
        "given_name": "Marius",
        "family_name": "Huseby",
        "email": "marius@huseby.com",
        "street_address": "Hagens Gate 53",
        "postal_code": "2151",
        "city": "Oslo",
        "phone": "+45 40 123 456",
        "country": "NO"
    },
    "shipping_address": {
        "given_name": "Marius",
        "family_name": "Huseby",
        "email": "marius@huseby.com",
        "street_address": "Hagens Gate 53",
        "postal_code": "2151",
        "city": "Oslo",
        "phone": "+45 40 123 456",
        "country": "NO"
    },
    "order_amount": 10,
    "order_tax_amount": 0, // optional
    "order_lines": [
        {
            "type": "physical", // optional
            "reference": "19-402", // optional
            "name": "Battery Power Pack",
            "quantity": 1,
            "unit_price": 10,
            "tax_rate": 0, // optional
            "total_amount": 10,
            "total_discount_amount": 0, // optional
            "total_tax_amount": 0, // optional
            "product_url": "https://www.estore.com/products/f2a8d7e34", // optional
            "image_url": "https://www.exampleobjects.com/logo.png" // optional
        }
    ],
    "merchant_urls": {
        "confirmation": "https://example.com/confirmation",
        "notification": "https://example.com/pending" // optional
    },
    "merchant_reference1": "45aa52f387871e3a210645d4", // optional
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
POST /payments/v1/authorizations/<authorization_token>/order
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json
{
    "purchase_country": "FI",
    "purchase_currency": "EUR",
    "billing_address": {
        "given_name": "Saimi",
        "family_name": "Pennanen",
        "email": "saimi@pennanen.com",
        "street_address": "Meriluotokatu 447",
        "postal_code": "78164",
        "city": "Helsinki",
        "phone": "+358 401234567",
        "country": "FI"
    },
    "shipping_address": {
        "given_name": "Saimi",
        "family_name": "Pennanen",
        "email": "saimi@pennanen.com",
        "street_address": "Meriluotokatu 447",
        "postal_code": "78164",
        "city": "Helsinki",
        "phone": "+358 401234567",
        "country": "FI"
    },
    "order_amount": 10,
    "order_tax_amount": 0, // optional
    "order_lines": [
        {
            "type": "physical", // optional
            "reference": "19-402", // optional
            "name": "Battery Power Pack",
            "quantity": 1,
            "unit_price": 10,
            "tax_rate": 0, // optional
            "total_amount": 10,
            "total_discount_amount": 0, // optional
            "total_tax_amount": 0, // optional
            "product_url": "https://www.estore.com/products/f2a8d7e34", // optional
            "image_url": "https://www.exampleobjects.com/logo.png" // optional
        }
    ],
    "merchant_urls": {
        "confirmation": "https://example.com/confirmation",
        "notification": "https://example.com/pending" // optional
    },
    "merchant_reference1": "45aa52f387871e3a210645d4", // optional
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
POST /payments/v1/authorizations/<authorization_token>/order
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json
{
    "purchase_country": "SE",
    "purchase_currency": "SEK",
    "billing_address": {
        "given_name": "Håkan",
        "family_name": "Larsson",
        "email": "hakan.larsson.test@klarna.com",
        "street_address": "Lars Väg 399",
        "postal_code": "11354",
        "city": "Stockholm",
        "phone": "0765260000",
        "country": "SE"
    },
    "shipping_address": {
        "given_name": "Håkan",
        "family_name": "Larsson",
        "email": "hakan@larsson.com",
        "street_address": "Lars Väg 399",
        "postal_code": "11354",
        "city": "Stockholm",
        "phone": "0765260000",
        "country": "SE"
    },
    "order_amount": 10,
    "order_tax_amount": 0, // optional
    "order_lines": [
        {
            "type": "physical", // optional
            "reference": "19-402", // optional
            "name": "Battery Power Pack",
            "quantity": 1,
            "unit_price": 10,
            "tax_rate": 0, // optional
            "total_amount": 10,
            "total_discount_amount": 0, // optional
            "total_tax_amount": 0, // optional
            "product_url": "https://www.estore.com/products/f2a8d7e34", // optional
            "image_url": "https://www.exampleobjects.com/logo.png" // optional
        }
    ],
    "merchant_urls": {
        "confirmation": "https://example.com/confirmation",
        "notification": "https://example.com/pending" // optional
    },
    "merchant_reference1": "45aa52f387871e3a210645d4", // optional
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
POST /payments/v1/authorizations/<authorization_token>/order
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json
{
    "purchase_country": "US",
    "purchase_currency": "USD",
    "billing_address": {
        "given_name": "John",
        "family_name": "Doe",
        "email": "john@doe.com",
        "title": "Mr",
        "street_address": "Lombard St 10",
        "street_address2": "Apt 214",
        "postal_code": "90210",
        "city": "Beverly Hills",
        "region": "CA",
        "phone": "333444555",
        "country": "US"
    },
    "shipping_address": {
        "given_name": "John",
        "family_name": "Doe",
        "email": "john@doe.com",
        "title": "Mr",
        "street_address": "Lombard St 10",
        "street_address2": "Apt 214",
        "postal_code": "90210",
        "city": "Beverly Hills",
        "region": "CA",
        "phone": "333444555",
        "country": "US"
    },
    "order_amount": 10,
    "order_tax_amount": 0, // optional
    "order_lines": [
        {
            "type": "physical", // optional
            "reference": "19-402-USA", // optional
            "name": "Battery Power Pack",
            "quantity": 1,
            "unit_price": 10,
            "tax_rate": 0, // optional
            "total_amount": 10,
            "total_discount_amount": 0, // optional
            "total_tax_amount": 0, // optional
            "product_url": "https://www.estore.com/products/f2a8d7e34", // optional
            "image_url": "https://www.exampleobjects.com/logo.png" // optional
        }
    ],
    "merchant_urls": {
        "confirmation": "https://example.com/confirmation",
        "notification": "https://example.com/pending" // optional
    },
    "merchant_reference1": "45aa52f387871e3a210645d4", // optional
}

4.2 Handle the response

You can either get a successful response, or an error.

The response contains the following information

  • order_id - used for order management interactions, such as capturing or refunding the order
  • redirect_url - a URL which you immediately redirect the consumer to
  • fraud_status - may indicate that this is a suspected fraudulent order

Successful response: the order is confirmed

You receive an order_id, a redirect_url and fraud_status ACCEPTED.

1
2
3
4
5
{
"order_id": "3eaeb557-5e30-47f8-b840-b8d987f5945d",
"redirect_url": "https://payments.klarna.com/redirect/...",
"fraud_status": "ACCEPTED"
}

Store the order_id for future reference during order fulfillment or service center management.

In order for Klarna to securely handle the data and optimize the purchase flow they need to interact with the customer’s browser as first party (not in an iframe or similar). This is achieved by ‘bouncing’ the browser on a klarna.com page before presenting the merchant confirmation page. To do this the merchant provides the url of their confirmation page together with the rest of the order details, and Klarna will respond with a redirect url that will take the customer to the confirmation page. The merchant should send the customer browser to the redirect_url provided in the response.

Pending order

Instead of immediately accepting the order, it may happen that Klarna flags this transaction for additional review. This is indicated if the fraud_status is PENDING. Read more about what to next in our section about pending orders.

Error response

If an error is returned, see here for details.

There are two reasons we would reject

  1. The order was placed within the required time window. However, the data was not matching the data provided during the authorization call.
  2. The order was placed outside the authorization window, and Klarna could not re-authorize it successfully.

If you want to give the consumer the option to complete the order at this point, then update the session and proceed with loading the Widget again.

4.3 Place recurring order (tokenization)

The customer token created previously can be used to charge the customer at any time. The customer is charged by creating an order using the customer token. This is done by calling the customer token API with the customer token ID and data of order to be created.

The order can be automatically captured at time of creation by setting the auto_capture flag to true (default is false)

See following example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
POST /customer-token/v1/tokens/{customerToken}/order
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json

{
    "merchant_reference1": "45aa52f387871e3a210645d4",
    "merchant_data": "optional string",
    "locale": "sv-SE",
    "auto_capture": true,
    "purchase_currency": "SEK",
    "order_amount": 9900,
    "order_tax_amount": 0,
    "order_lines": [{
        "type": "digital",
        "reference": "ABC123",
        "name": "Premium package",
        "quantity": 1,
        "unit_price": 9900,
        "tax_rate": 0,
        "total_amount": 9900,
        "total_discount_amount": 0,
        "total_tax_amount": 0
    }]
}

1
2
3
4
5
6
// Success response format
{
    "order_id": "a89ec121-1276-419d-882a-c343d58fd1bc",
    "fraud_status": "ACCEPTED"
}

1
2
3
4
5
6
// Error response format
{
    "error_code" : "ERROR_CODE",
    "error_messages" : ["Array of error messages"],
    "correlation_id" : "Unique id for this request used for troubleshooting."
}
ERROR_CODEHTTP status CodeDescription
ERROR_CODE
 
HTTP status Code
200
Description
Order successfully created. Order ID returned.
ERROR_CODE
TOKEN_NOT_FOUND
HTTP status Code
404
Description
Customer token not found
ERROR_CODE
TOKEN_SUSPENDED
HTTP status Code
403
Description
Customer token has been suspended
ERROR_CODE
TOKEN_CANCELLED
HTTP status Code
403
Description
Customer token has been cancelled
ERROR_CODE
TOKEN_FORBIDDEN
HTTP status Code
403
Description
Customer token usage forbidden
ERROR_CODE
BAD_REQUEST
HTTP status Code
400
Description
Bad request. Error message includes more details.
ERROR_CODE
UNAVAILABLE_PAYMENT_METHOD
HTTP status Code
403
Description
Payment method type is not available.
ERROR_CODE
PAYMENT_METHOD_CURRENCY_MISMATCH
HTTP status Code
403
Description
Payment method not available for given currency
ERROR_CODE
PAYMENT_METHOD_FAILED
HTTP status Code
403
Description
Purchase for payment method failed. You can try again for PAYMENT_METHOD_FAILED errors.
ERROR_CODE
INTERNAL_SERVER_ERROR
HTTP status Code
500
Description
Internal server error.
ERROR_CODE
SERVICE_UNAVAILABLE
HTTP status Code
503
Description
Purchase failed because of a temporary internal Klarna error. You can try again for a 503.

Summary so far: “A Job Well Done”

Congratulations, you’ve just placed an order at Klarna! The widget is up and running the way it should.

What’s next?

Just a few more steps before start taking orders live. Go through our go live check list!