Troubleshooting the checkout flow

  1. Home
  2. /
  3. Klarna Checkout for WooCommerce
  4. /
  5. Troubleshooting
  6. /
  7. Troubleshooting the checkout flow

Troubleshooting the checkout flow

From version 2.0 of Klarna Checkout for WooCommerce the checkout flow has changed.

The WooCommerce order will now be created first (in Pending status), then the Klarna order is placed, and finally the WooCommerce order is updated to Processing status. This update is more compatible with other WooCommerce plugins.

The new checkout flow also means that Pending orders can be visible in WooCommerce, where the payment has not been finalized in Klarna (for example card payment where there was not enough funds on the card). This is part of the general WooCommerce checkout flow, and it does not implicate that something is wrong. It is just a new scenario for the Klarna Checkout payment gateway.

I see pending orders in WooCommerce, is something wrong?

As mentioned above – you can have pending orders in WooCommerce with Klarna Checkout as the payment method without any errors in your store. These might just be orders not finalized by the customer.

However, if you want to troubleshoot this a bit closer, here’s how you do it.

  • Make sure that you have turned on Logging in the plugin settings.
  • The logs can be found by navigating to WooCommerce > Status > Logs.

Order creation step by step

Order creation step by step and how to debug and follow it in the log

Some of these events happen one time in the order creation, while others can happen multiple times. We have added a note to each event on whether you should expect to find it in the log once or several times.

1. KCO create order (POST)

"id”:”your-klarna-order-id","type":"POST","title":"KCO create order"

When customers visit the checkout page, a new checkout session is initiated. This action generates a fresh Klarna order ID that will be linked to the ongoing session.

This event should happen once.

2. KCO get order (GET)

"id":"your-klarna-order-id","type":"GET","title":"KCO get order"

This request is made whenever Klarna notifies us about a change that occurred in the embedded payment form. We need to retrieve the updated form data from them in such cases. It’s important to note that this type of request can occur multiple times. 

For instance, when a customer enters the billing address in the embedded payment form and clicks on the “Continue” button can be a trigger for this event.

This event can happen more than once.

3. Set chosen shipping method

"Set chosen shipping method for your-klarna-order-id [\"flat_rate:1\”]”

This situation occurs when the shipping options are displayed within the embedded payment form (<iframe>). It is triggered when there is a change in the chosen shipping method within WooCommerce (WC). Typically, this change is initiated either by Klarna Shipping Assistant (KSA) defaulting to a standard WC shipping method or by a third-party plugin.

This event can happen more than once.

4. KCO update order (POST)

"id":"your-klarna-order-id","type":"POST","title":"KCO update order"

Whenever a change occurs in WC, we need to notify Klarna about it. We achieve this by issuing a POST request. It’s important to note that this type of request can occur multiple times, and the changes made may not always be immediately reflected in Klarna’s embedded payment form. 

For instance, if a new item is added to the cart or if the quantity of an item is modified, a POST request is sent to inform Klarna about these changes.

This event can happen more than once.

5. Validation_callback from Klarna triggered

"Frontend JS your-klarna-order-id: validation_callback from Klarna triggered"

When the customer clicks the Place order button in the Klarna iframe, the following log will be added to the log file.

This event usually happens once, but can happen more times if there are any changes to the order.

6. Extra shipping debug

"Extra shipping debug: {\"kco_order_id\":\"your-klarna-order-id\",\"wc_order_shipping\":\"Flat rate\”

This debug data allows us to check for any discrepancies between WC and Klarna. It helps us compare the selected shipping option in WC with the saved Klarna shipping option.

This event usually happens once, but can happen more times if there are any changes to the shipping method.

7. KCO update confirmation (POST)

{"id":"your-klarna-order-id","type":"POST","title":"KCO update confirmation"

In this sequence the Klarna Checkout (KCO) plugin populates the address fields in the regular WooCommerce checkout form and submits the form. If the WooCommerce validation is successful (e.g., no coupon errors, the products are in stock), a new pending order is created in WooCommerce.

This event usually happens once, but can happen more times if the WC cart hash has been changed. Then you will also see that another WC order is created. More common is that it updates the existing WC order.

8. Successfully placed order

"Frontend JS your-klarna-order-id: Successfully placed order. Sending \"should_proceed: true\" to Klarna"

If the order creation went well you should now see this in the logs and the plugin now hands over the checkout process to Klarna.

This event usually happens once, but can happen more times if the customer for example cancels the purchase through Klarna’s modal window, returns to the store to add another product and then proceeds to the checkout again.

9. Confirm the Klarna order from the confirmation page.

"your-klarna-order-id: Confirm the klarna order from the confirmation page."

This indicates that the purchase process was completed, and the customer was successfully redirected to the confirmation (thank you) page.

This event should happen once.

10. KCO get order management order (POST)

{"id":"your-klarna-order-id","type":"POST","title":"KCO get order management order"

This is where the plugin gets the order from Klarna’s order management API.

This event should happen once.

11. KCO acknowledge order (POST)

{"id":"your-klarna-order-id","type":"POST","title":"KCO acknowledge order”

Klarna requires that we acknowledge that the order was completed successfully. This confirms that the acknowledgment was issued to Klarna.

This event should happen once.

12. KCO set merchant reference (PATCH)

{"id":"your-klarna-order-id","type":"PATCH","title":"KCO set merchant reference"

Updates the Klarna order to include the WC order ID and WC order number.

This event should happen once.

13. Fraud status accepted

"your-klarna-order-id: Fraud status accepted for order KR-KCO-XXXX. payment_complete triggered."

If the payment went well, you should now see this in the log (where KR-KCO-XXXX is replaced by your WooCommerce order number)

This event only applies to some regions and should in that case happen once.

Errors that might happen

If the order creation didn’t go as expected you might see a Checkout error. This is caused by WooCommerce validation NOT being successful (e.g., coupon errors, subscription that require login, no stock). This should happen between step 7-8 in the order creation.

Possible scenarios with errors

  1. Your customer claims that nothing happens after they have signed with BankID, instead they get a white screen or they get redirected back to the cart.
    If your last log entry (with a specific klarna order id) is Frontend JS your-klarna-order-id: Successfully placed order. Sending \"should_proceed: true\" to Klarna. then there is most likely something wrong in Klarnas system (or in the communication between Klarna and BankID/3DSecure/the acquiring bank). For more information in these cases you need to contact your regions Klarna Merchant Support as the KCO plugin do not have access to the log data after this step. This happens between step 8-9.
  2. Something went wrong in the confirmation step
    If this happens we have a backup function (server-to-server call) running and then you will see a Confirm the klarna order from the thankyou page in the logs. This happens in step 9 in the order creation.