1. Obtain a Instant Shopping Key (server-side)

You complete this step leveraging the Instant Shopping Button Keys REST API from your server-side

As a first step you need to obtain a Button key which you can reuse for displaying Instant Shopping buttons in multiple pages. This key is used to identify you as a merchant and also to link to some necessary configuration options.

Since this key can be reused for displaying buttons in multiple pages, it is advised that you generate it once and then store it somewhere within your system.

To obtain a key you can use the Instant Shopping Key Generation Service. An example of a request to this service is given below. Note that you need to use your API credentials to authenticate.

You can include more setup options here, e.g. options, merchant_data, merchant_reference, etc., as shown in the API documentation.

The minimum information needed to setyp a Key is the URL of an endpoint where the Instant Shopping Button’s server-side will ping you when an Order is authorized.

Note: Read about Klarna’s API URLs to know the base URL, and about Authentication to know how to authenticate when calling our REST API. More detailed documentation on the Instant Shopping orders API is available in the API documentation.

Request to generate a Button key

1
2
3
4
5
6
7
8
POST /instantshopping/v1/buttons
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json
{
  "merchant_urls": {
    "place_order": "< mandatory, URL of an endpoint at the merchant side, which will receive a ping to place an order. (must be https, max 2000 characters) >"
  }
}

Upon success the response of this service will provide you the next URL to fetch the key.

Response for created Button key

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
HTTP 201 Created
Content-Type: application/json
Location: /instantshopping/v1/buttons/123e4567-e89b-12d3-a456-426655440000
{
  "button_key": "123e4567-e89b-12d3-a456-426655440000",
  "merchant_urls": { /* ... */ },
  "purchase_country": "string",
  "purchase_currency": "string",
  "locale": "string",
  "merchant_reference1": "string",
  "merchant_reference2": "string",
  "merchant_data": "string",
  "options": { /*...*/ },
  "order_lines":  [ /*...*/ ],
  "shipping_options": [ /*...*/ ]
}

What’s next?

It’s time to use the button key you have just created in order to setup the page for the Instant Shopping Button.