Confirm the purchase

In this tutorial you will learn how to confirm that you have received and created an order in your system. This confirmation is needed in response to a push notification from Klarna, indicating that the consumer has completed a purchase.

Use case

A consumer has completed the purchase and you want to create the order in your system.


  • A consumer has completed a purchase with Klarna Checkout.

1. Handle the POST request

Once a consumer has completed a purchase, Klarna will inform you via a POST request. The POST request will be made to the push notification URI you provided when you created the checkout order.

Note: There is a 2 minute delay before the order confirmation push to merchants is attempted.

So for instance with these configured 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(

You would receive a post request to the push url with the placeholder {} replaced with the correct order id with an empty body. 

For example: http://push?klarna_order_id=12345

2. Request the order from Klarna

In the POST request you received in point 1, you should now use the order id found in the query parameter klarna_order_id to fetch the order from the order management API.

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

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

$order = new \Klarna\Rest\OrderManagement\Order(

String merchantId = "0";
String sharedSecret = "sharedSecret";
URI baseUrl = Client.EU_TEST_BASE_URL;
String orderId = "12345";

Client client = DefaultClient.newInstance(

Order order = client.newOrder(orderId);

OrderData data = order.fetch();
const string MerchantId = "0";
const string SharedSecret = "sharedSecret";
string orderId = "12345";

IConnector connector = ConnectorFactory.Create(

Client client = new Client(connector);
IOrder order = client.NewOrder(orderId);

OrderData orderData = order.Fetch();

3. Backup order creation

The confirmation page might fail to load for a number of reasons, even though the purchase is confirmed by Klarna. When receiving the POST request  you can make sure that you have created the order and create if it doesn't exist. The full resource structure of an order can be found in the API Reference.

4. Acknowledge the order

You must now send a request to Klarna saying that you've acknowledged the order.

Note: Klarna will send the push notifications every two hours for a total of 48 hours or until you confirm that you have received the order.


Order creation and the order confirmation push

  1. There should be an attempt to commit the order on the confirmation page.
  2. The order confirmation push should be implemented as a backup.
    If the order doesn't exist when the push is received the order should be created. If there is no intention to ship the order it should be canceled.
  3. Every order should either be acknowledged or canceled. Orders which will not be shipped should be canceled immediately.

Ship, then capture the order to finalize the payment

You now have a confirmed authorization for this order. Once you have shipped the product, you need to capture the order in order to finalize the payment. The order can be found in Klarna's Merchant Portal or you can integrate our order management using the APIs provided.

What's next?

  • You now know how to create and read a checkout order. We encourage you to take a look at the next step in the tutorial where you will test your integration to make sure everything works as expected.
  • In order to finalize the payment, and initiate the payout to you, you need to capture the order after you have shipped it to the consumer. You can either use our APIs for managing orders, or you can perform this action manually each time in our Merchant Portal.
  • A very detailed guide explaining some "gotchas", in case you get stuck, can be found in the best practices guide.