Learn to track Klarna HPP session updates via status callbacks. Activate by adding a URL to merchant_urls. Callbacks include an event_id and session status in JSON, secured by HTTPS and one-time tokens.
It is possible when integrating HPP to received status changes callbacks to a certain URL. This address that is unique to every session will be called by our systems whenever the status of the session is updated. This is really handy to create interaction whenever something happens and avoid to have a costly polling mechanism.
sequenceDiagram
autonumber
participant A as Consumer
participant B as Browser
participant C as HPP
participant D as Merchant Backend
C -->> A: A link to the HPP is provided to the consumer by e-mail, SMS, QR code or<br/> simply browser redirection
B ->> C: Request url
note over A,D: The consumer arrives to the HPP and the distribution of the link was successful,<br/> the Merchant backend is notified to be able to act on it.<br/> On integration with multiple actors, it may allow to tell the other actor (a clerk) that the consumer is filling the application.
C -->>D: Notification IN_PROGRESS
alt Successful authorization
A ->>C: Presses pay button
note over A,D: The consumer has a successful authorization from Klarna and the payment can be satisfied. The HPP session is considered as COMPLETED<br/> but it is needed from the Merchant to place the order.
C -->>D: Notification COMPLETED
note over A,D: Depending on how the HPP session was created, the consumer will receive as a result a hosted confirmation page<br/> or a redirection to your website using merchant_urls.
C ->>B: Result
else Declined authorization
A ->>C: Presses pay button
note over A,D: Although the consumer wants to pay with Klarna, its application may be declined, which is known as a Failure.<br/> The HPP session is considered as FAILED, but the consumer can still try again until they cancel the HPP session<br/> or the merchant integration does it.
C -->>D: Notification FAILED
note over A,D: Depending on how the HPP session was created, the consumer will receive as a result a hosted confirmation page<br/> or a redirection to your website using merchant_urls.
C ->>B: Result
else Bank and error cases
note over A,D: The consumer chooses to cancel the order or to go back to the checkout progress.<br/> All cases can be interpreted the same way as there is just a notification that will send the new status of the HPP session.<br/> Depending if it is a back button or cancellation request,<br/> the consumer may or may not come back to the same HPP session.
A ->>C: Presses back button or cancellation button
C -->>D: Notification BACK or CANCELLED
note over A,D: Depending on how the HPP session was created, the consumer will receive as a result a hosted confirmation page<br/> or a redirection to your website using merchant_urls.
C -->>B: Result
else Timeout of the HPP session
note over A,D: The consumer may not use the back button or cancel button and just leave the page, or choose another payment method using the previous<br/> page feature of their browser. In these cases, the HPP system loses track of the consumer.<br/> A timer is set for every HPP session and will turn the status to TIMEOUT. This timer will depend on how the HPP session was created.
C -->>D: Notification TIMEOUT
end
When creating the HPP SessionHPP Session, you need to pass an URL in the status_update field of the merchant_urls. This URL will be called by HPP each time the status of the HPP Session is updated on Consumers actions, it contains the new status of the HPP Session the same way it would be gotten by reading the HPP Session from the read session endpoint of the API.
The calls made to the status_update URL will be made by HPP without waiting for any response from your server. It is expected from the the URL to send back a 2xx status code response.
In case no response is gotten in less than 3 seconds, there will be a retry after a few seconds. This mechanism will happen up to three times, with 4 calls being made for the same events. If of these calls are unanswered, the callback mechanism will end.
The URL provided as status_update must be over HTTPS, but to be able to authenticate that the callback comes from Klarna, it is advised to generate a one time token that you will only use for this specific HPP Session.
This lets you validate that the call made to you on an update of status is only made by us.