This page will take you through the Hosted Payment Page API and explain how to interact with it and its concepts. Please make sure to understand why you should use the Hosted Payment Page and the Overview of the system before reading this documentation. The Hosted Payment Page works with a Payment Provider from the Klarna ecosystem, and you will need to create a KP Session or KCO Order before being able to create an HPP Session. A different integration guide is available for both platforms.
In this document, the term Payment Provider refers to either Klarna Payments or Klarna Checkout and Payment Session refers to the corresponding KP Session on Klarna Payments or KCO Order on Klarna Checkout.
Klarna’s Hosted Payment Page (HPP) requires that you integrate different server-side REST APIs from the Klarna environment and thus requires no client-side integration. The different APIs correspond to different Klarna products and have some defined objects that interact with each other.
The Hosted Payment Page supports both Klarna Checkout and Klarna Payments, which will be referred to in this documentation as the Payment Provider. You can integrate with both if you have contracted for both products, and the integration with HPP is quite similar, but an HPP Session will work only with one of the two Payment Providers at the same time. Choosing from one of the two Payment Provider will mainly depend on your use case and constrains.
a. Klarna Payments REST API: create Payment Session, place Order
b. Klarna Checkout REST API: create Checkout Order
Both KP Session and KCO Order will be referred to as Payment Session in the documentation.
The Hosted Payment Page REST API can be used to let Klarna host the client-side integration of Klarna Payments or Klarna Checkout for you. You will have to create a Session and then distribute it.
a. HPP Session: a session on HPP that is linked to a Payment Session. When a Payment Session is being completed, canceled or expires, it is also the case for the HPP Session. An HPP Session has an unique URL where the Consumer can be redirected to and can be distributed via different distribution methods.
a. OM Order: a due payment from the Consumer for defined goods. It is created using a KP Authorization Token with the KP Session or automatically by Klarna Checkout when a KCO Order is completed. The OM Order will allow you to capture the payment when goods or service have been delivered, and manage the post purchase experience of the Consumer.
In the Klarna Payments integration case, when placing the order with the KP Authorization Token, you can configure it to automatically capture the payment. In that case you won’t have to integrate the Order Management API outside of refunds. This should be limited to digital goods or when you limit it to some payment meth
KP Session, KCO Order and HPP Session both have an expiration time, but the expiration is driven by the Payment Session which usually expires 48 hours after its creation. A Consumer will be able to pay on HPP until 1 hour before the Payment Session expiration.
Klarna uses HTTP’s Basic auth to authenticate requests from Merchants. Use your API Credentials to add the corresponding HTTP headers to your requests, the credentials consist of two elements:
Use your credentials to generate the token: Base64(username:password)
Username | DemoMerchant |
---|---|
Password | DemoPassword |
Calculated basic auth | RGVtb01lcmNoYW50OkRlbW9QYXNzd29yZA== |
Example of request | curl -X GET https://api.klarna.com/payments/v1/sessions/<session_id> --header "Authorization: Basic RGVtb01lcmNoYW50OkRlbW9QYXNzd29yZA==" --header "Content-Type: application/json" |
Klarna offers a test environment named Playground and a Production environment. The different APIs are available on each environment. URL structures are the same for both environment, targeted environment will be defined by the domain you are using. To be able to test your integration, you will need a Test Account.
You can find more in our environments and testing guidelines.
The HPP API follows the same rules as other Klarna public APIs, we try to update our APIs regularly in a non breaking way, ensuring backward compatibility. You can find more in our API updates guidelines and see how we define backward compatibility and non-breaking changes.