The first step is to setup a Merchant ID and configure Klarna Payments with the suitable payment methods for the purpose of generating customer tokens. This configuration should be done for all the billing countries the merchant wants to use Instant Shopping for.
For the next steps you will need the Klarna API Credentials (you can generate new after logging in to the Merchant Portal)
You need to create a Button key which you can reuse for displaying Instant Shopping 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 Instant Shopping in multiple pages, it is advised that you generate it once and then store it somewhere within your system.
To create a key you can use the Instant Shopping Button Keys Service. An example of a request to this service is given below. Note that you need to use your API credentials to authenticate.
You complete this step from your client-side
After successfully completing this part you should see the Instant Shopping Button.
To do this add the following script tag as soon as possible in the page (e.g. <head>).
At this step you decide where you want to place the Instant Shopping button within the page by positioning the HTML container element.
You will now need to provide all the information necessary to support the purchase flow. This information refers to the product(s) being in the cart (together with possible discounts, etc.), relevant shipping options, locale, currency, etc.
Note that you will use the button key created from the previous step.
Below you see an example of the configuration options that are necessary for the consumer flow. Please note that the order_amount and order_tax_amount will be calculated by the service.
You should define this function before the script tag for fetching lib.js (see 3.a) and as early as possible in the page, e.g. head.
In the example below we consider that this Instant Shopping flow is selling subscriptions of variant durations.
Important: You need to provide a localized text describing the details of the subscription (cost, duration, start, end dates) by setting up the tokenization.description property.
When the consumer has chosen to finalize the flow, our server-side will ping you at the merchant_urls.create_customer_token endpoint, and prompt you to ask for the generation of a customer token. You do not need to act on this request, you can merely respond with HTTP 200 and proceed.
At this point we expect that you validate the request body and decide whether you will approve/decline.
The response to this request is not important, you can reply with HTTP 200.
To approve and receive a customer token you will need to perform a POST to Instant Shopping API, as shown in the example below. You will use the authorization_token from the ping request body above.
To place the order you will need to use the response above in KP for each recurring payment. For more information on the KP place order, you can visit Klarna Payments
To decline you will need to perform a DELETE to Instant Shopping API, as shown in the example below. You will use the authorization_token from the ping request body above.