Show purchase confirmation

This tutorial will cover how to retrieve a checkout order and render the confirmation HTML snippet on your confirmation page. Once the consumer has completed the purchase they will be redirected to the confirmation page as specified by the merchant_urls.confirmation property you used when you created the checkout order.

For instance with these merchant urls:

$merchantUrls = [
    'terms' => 'http://toc',
    'checkout' => 'http://checkout?klarna_order_id={}',
    'confirmation' => 'http://confirmation?klarna_order_id={}',
    'push' => 'http://push?klarna_order_id={}'
final MerchantUrls urls = new MerchantUrls()
MerchantUrls merchantUrls = new MerchantUrls
    Terms = new System.Uri(
    Checkout = new System.Uri(
    Confirmation = new System.Uri(
    Push = new System.Uri(

the users would be redirected to: http://confirmation?klarna_order_id=12345

1. Retrieve the checkout order

You should now use the checkout order URI found in the query parameter klarna_order_id to fetch the order from Klarna

$merchantId = 0;
$sharedSecret = 'sharedSecret';
$orderId = '12345';

$connector = \Klarna\Rest\Transport\Connector::create(

$checkout = new \Klarna\Rest\Checkout\Order($connector, $orderId);

Client client = DefaultClient.newInstance(

CheckoutOrder checkout = client.newCheckoutOrder("12345");
CheckoutOrderData orderData = checkout.fetch();
IConnector connector = ConnectorFactory.Create(

Client client = new Client(connector);

ICheckoutOrder checkout = client.NewCheckoutOrder("123456");
CheckoutOrderData orderData = checkout.Fetch();

2. Create an order in your system

You should now create the order in your system with the order data that you want to store. The full resource structure of an order can be found in the API Reference.

3. Render the confirmation snippet

The checkout order now contains an updated HTML snippet under the html_snippet property. You should extract the HTML snippet and display it on your confirmation page.

Note: You should remove any browser session references to the checkout order after you have rendered the confirmation snippet.

echo "<div>{$checkout['html_snippet']}</div>";
out.println(String.format("<div>%s</div>", orderData.getHtmlSnippet()));
Response.Write(string.Format("<div>{0}</div>", orderData.HtmlSnippet));

This is what it should look like:

Full code example

The complete code example used for rendering the confirmation snippet can be found in the example section of our client libraries.


What's next?

You have now integrated Klarna Checkout into your confirmation page. 

The next step is to learn how to confirm purchase.