Klarna Checkout - checkout flow rewrite

From version 2.0.0 of the Klarna Checkout plugin, the checkout flow has changed. This means that the order of when the purchase in Klarna is finalized and when the order in WooCommerce is created, is now different than in older versions of the plugin.

Old checkout flow

Versions older than v2.0.0 had a flow like this:

  1. Customer navigates to the checkout page in WooCommerce. If Klarna Checkout is the selected (or only) payment method, a Klarna order id is created.
  2. When the customer clicks the Place order button in KCO, the payment is finalized in Klarnas system.
  3. Klarna redirects the customer to the confirmation URL (the checkout page with a couple of extra params in the URL).
  4. The standard WooCommerce checkout form is submitted and an order is created in WooCommerce.
  5. The customer is redirected to the order received page.

This setup has some weaknesses. If a technical issue happens between the payment is finalized in Klarnas system and the order is created in WooCommerce, we might end up in a situation where we miss some data. There is a fallback sequence where the order in WooCommerce can be created on a callback from Klarna. Therefore the order will not be missing in WooCommerce. But there might be data added to the cart session (by other plugins) that we aren't able to restore during the order creation in the fallback sequence.

New checkout flow

To solve this weakness we have been working together with Klarna and Klarna have done a couple of additions to their API's. The new flow is structured in the following way:

  1. Customer navigates to the checkout page in WooCommerce. If Klarna Checkout is the selected (or only) payment method, a Klarna order id is created.
  2. When the customer clicks the Place order button in KCO, a JavaScript event is triggered by Klarna.
  3. The standard WooCommerce checkout form is submitted by the Klarna Checkout plugin and a pending order is created in WooCommerce.
  4. If the order creation went well, the KCO plugin responds with a true message in the JavaScript event (if something went wrong during the order creation process the KCO plugin will respond with a false message in the JavaScript event and Klarna will not finalize the purchase. Instead an error notice will be displayed for the customer). 
  5. Provided that the KCO plugin respond with a true message, Klarna then finalizes the purchase in their system.
  6. Klarna redirects the customer to the confirmation URL.
  7. The KCO plugin redirects the customer to the order received page and updates the order status to Processing in WooCommerce.

The new checkout flow is more inline with the standard WooCommerce checkout flow. This way the KCO plugin will be more compatible with other WooCommerce extensions and the risk of lost data will decrease.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.