Klarna Docs - Create order
Create order

The first step is to create an order using the create_order API call with the correct authentication and endpoint (URL), to which Klarna responds with an HTML snippet that allows the merchant to render the Checkout iframe.

This step should be done after the consumer selects their product(s) and proceeds to Checkout.

You probably have your test credentials already, otherwise, you can get them here.

Klarna uses HTTP Basic Auth for authentication (see general information here). Use the API credentials provided to you to authenticate with Klarna. The credentials consist of two elements:

  • Username: a username linked to your Merchant ID at Klarna
  • Password: a unique password that is associated with the username Authentication: Base64(username:password)

Never share your test or live credentials.

Klarna’s European and North American environments have different endpoints (URLs) for testing and for live purchases. All requests to Klarna go through HTTPS. Read more here

To create an order you will use our REST API and make a HTTP POST request towards the right test endpoint + /checkout/v3/orders with the header content-type: application/json.

JSON
{
  "purchase_country": "GB",
  "purchase_currency": "GBP",
  "locale": "en-GB",
  "order_amount": 50000,
  "order_tax_amount": 4545,
  "order_lines": [
      {
          "type": "physical",
          "reference": "19-402-USA",

The example above is configured for UK(GB) and contains the minimum amount of data that is needed to create an order with mock URLs. Please see popular use cases, in-depth knowledge, and our API reference for more details on how to configure an order for your specific needs.

To read about all of the data fields in the response see our API reference, for now, we will highlight:

  • order_id a unique ID generated by Klarna, which you need to keep track of since it is a reference to the order you created.
  • html_snippet a string that you need to include on your page to render the checkout. We will do that in the next step of this guide.
JSON
{
  "order_id": "8cf27b55-53e8-6aba-9fb4-7c692e56ddee",
  "status": "checkout_incomplete",
  "purchase_country": "gb",
  "purchase_currency": "GBP",
  "locale": "en-GB",
  "billing_address": {
    "country": "gb"
  },
  "customer": {},