Let's look at the interactions between your site and Klarna when using Klarna Checkout.
- Render the checkout page. You will start the order session by calling Klarna's server with your customer's cart details, locale, your merchant ID and a few more details. You will get an HTML snippet back. If the request is successful, Klarna will return an HTML snippet which you will need to embed into your checkout page.
- Render the confirmation page. After the customer has completed the purchase in the checkout snippet, you will call Klarna to get a confirmation page HTML snippet. If the request is successful, Klarna will return an HTML snippet with order confirmation details which you will need to embed into your confirmation page.
You will need to have the following on your site
- A Checkout and a Confirmation page, each containing a div that will be populated with the HTML snippets you will receive from Klarna.
- A Push URL, where Klarna informs you of the order status. In the push URL you will need to have a placeholder, which Klarna will then replace with the
order_idwhen we send the push request.
- Terms and Conditions URL, where you host your terms and conditions. Klarna will provide the customer with a link to your terms and conditions in certain phases of the order, so you need to create a terms and conditions URL, to which Klarna Checkout will link.
- Review the security of your site. A great place to start is our Security Recommendations.
When using Klarna's APIs you need to authenticate using a merchant id and a shared secret. Visit the test credentials page to get authentication credentials for testing.
Let's get into the code. You will start by embedding the checkout snippet.