Read order

Now you should complete the order in the rendered checkout on your webpage, use some fake data to complete the purchase. After completing the purchase you will be redirected to the url in the merchant_urls.confirmation provided in the create order request.

For instance with these merchant urls:

1
2
3
4
5
6
"merchant_urls": {
  "terms": "https://merchant.com/tac.php",
  "checkout": "https://merchant.com/checkout.php?sid={checkout.order.id}",
  "confirmation": "https://merchant.com/thankyou.php?sid={checkout.order.id}",
  "push": "https://merchant.com/kco/push.php?checkout_uri={checkout.order.id}"
}

the users would be redirected to: https://merchant.com/thankyou.php?sid=12345 where 12345 is the order_id.

In a live integration you should now use the checkout order id found in the query parameter sid from the merchant-confirmation url to fetch the order from Klarna. For this guide you need to keep track on the order_id from the create order response return values.

Read order request

To read the order you will use our REST API and make a HTTP GET request towards the endpoint /checkout/v3/orders/order_id where you replace order_id with the the order_id from the create order response. You need to send the header content-type: application/json and have an empty body.

Read order response

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
56
57
58
59
60
61
62
63
64
65
66
67
{
  "order_id": "8cf27b55-53e8-6aba-9fb4-7c692e56ddee",
  "status": "checkout_complete",
  "purchase_country": "gb",
  "purchase_currency": "GBP",
  "locale": "en-GB",
  "billing_address": {
    "given_name": "Testperson-se",
    "family_name": "Approved",
    "email": "Testperson-se@test.klarna.com",
    "title": "Mr",
    "street_address": "test House 57",
    "postal_code": "WC2N 5DU",
    "city": "London",
    "phone": "+46 76 526 00 00",
    "country": "gb"
  },
  "customer": {
    "date_of_birth": "1941-03-21",
    "gender": "male"
  },
  "shipping_address": {
    "given_name": "Testperson-se",
    "family_name": "Approved",
    "email": "Testperson-se@test.klarna.com",
    "title": "Mr",
    "street_address": "test House 57",
    "postal_code": "WC2N 5DU",
    "city": "London",
    "phone": "+46 76 526 00 00",
    "country": "gb"
  },
  "order_amount": 50000,
  "order_tax_amount": 4545,
  "order_lines": [
    {
      "type": "physical",
      "reference": "19-402-USA",
      "name": "Red T-Shirt",
      "quantity": 5,
      "quantity_unit": "pcs",
      "unit_price": 10000,
      "tax_rate": 1000,
      "total_amount": 50000,
      "total_discount_amount": 0,
      "total_tax_amount": 4545
    }
  ],
  "merchant_urls": {
    "terms": "https://www.example.com/terms.html",
    "checkout": "https://www.example.com/checkout.html?order_id={checkout.order.id}",
    "confirmation": "https://www.example.com/confirmation.html?order_id={checkout.order.id}",
    "push": "https://www.example.com/api/push?order_id={checkout.order.id}"
  },
  "html_snippet": "<div id=\"klarna-checkout-container\".................",
  "started_at": "2020-03-05T13:32:42Z",
  "completed_at": "2020-03-05T13:33:14Z",
  "last_modified_at": "2020-03-05T13:33:14Z",
  "options": {
    "allow_separate_shipping_address": false,
    "date_of_birth_mandatory": false,
    "require_validate_callback_success": false
  },
  "external_payment_methods": [],
  "external_checkouts": [],
  "payment_type_allows_increase": true
}

What’s next?

Render the confirmation snippet