Troubleshooting WooCommerce Subscriptions and KP

  1. Home
  2. /
  3. Klarna Payments for WooCommerce
  4. /
  5. Troubleshooting
  6. /
  7. Troubleshooting WooCommerce Subscriptions and KP

Troubleshooting WooCommerce Subscriptions and KP

The Checkout flow in Klarna Payments is constructed in a way that a WooCommerce order will be created first (in Pending status), then the Klarna order is placed, and finally the WooCommerce order is updated to Processing status. This flow is more compatible with other WooCommerce plugins.

This 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 Payments payment gateway.


I see pending orders in WooCommerce, is something wrong?


As mentioned above – you can have pending orders in WooCommerce with Klarna Payments 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.

Klarna Developer logs


The Klarna Developer logs allows you to inspect the technical communication (API calls) between your back office and Klarna.

Read more in the Klarna Developer logs section.


Manage Subscription


When handling the subscription order via My account as a customer or via backend as an administrator, for example Suspend, Cancel, Reactivate or Change address on the subscription, nothing will be logged.


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. Create session (POST)

"type":"POST","title":"Create session"

When customers visit the checkout page, a new checkout session is initiated. This session includes data about which Klarna payment methods to display to the customer, and a session ID for identifying, and referring to this session.

This event should happen once.

2. Update session (POST)

"type":"POST","title":"Update session"

If a change happens on the checkout page that Klarna needs to know about (e.g., the selected shipping option is changed, the customer’s address is changed, or the cart items has been modified), we need to let Klarna know about this. This is referred to as a “session change”. To let Klarna know which session needs to be updated, we use the session ID that was created in step 1.

This event can happen multiple times.

3. Successfully placed order

"Frontend JS : Successfully placed order. Starting authorization with Klarna"

When the customer clicks on the “Place order” button, we issue a request to Woo to validate the checkout data. If something is wrong, we’ll display a generic “Internal Server Error” message to the customer, and log the actual reason. For security reasons, we don’t display the actual reason to the customer.

If the validation is successful, a pending payment order will be created by Woo, and we inform Klarna to proceed with authorizing the purchase. When this happens, you’ll see the above message in the log, and Klarna will display a modal on the checkout page to the customer. Since this modal is managed by Klarna, the Woo store (including our plugin) has no access to what it contains, and what will appear.

This event usually happens once.

4. Create customer token (POST)

"type":"POST","title":"Create customer token"

Creates a customer token that is required for subscriptions.

This event should happen once.

5. Place order (POST)

"type":"POST","title":"Place order"

When the customer has been authorized by Klarna, and the purchase is considered complete (as indicated by the modal disappearing), the Woo store will be informed so that it can take action. At this point, we’ll send the merchant reference number to Klarna and the URL to redirect the customer to (i.e., the confirmation URL), and save any metadata related to the Woo order. When this has happened, you’ll see the above message in the Woo logs.

This event should happen once, but if the “Place order” fails, the process may be repeated.


Process Renewal order log flow


When processing a renewal order on an already existing subscription a new order should be created in WooCommerce that is connected to this Subscription and this will be added to the log:

Create recurring order (POST)

"type":"POST","title":"Create recurring order"

When processing a renewal order this will be logged and a recurring token will be created. 

This event should happen once.


Change payment via the My Account page


When a customer change payment via the Change payment-button on the Subscription via the My Account page, this will be logged:

1. Cancel recurring order (PATCH)

"type":"PATCH","title":"Cancel recurring order","arguments":{"country":"SE","recurring_token":"your-recurring-token"}

When the customer changes payment method, we have to cancel the existing token, if any, that is associated with the existing subscription.

This event should happen once.

2. Create session (POST)

"type":"POST","title":"Create session","arguments":{"country":"SE","order_id":your-order-id

When customers visit the checkout page, a new checkout session is initiated. This session includes data about which Klarna payment methods to display to the customer, and a session ID for identifying, and referring to this session.

This event should happen once.

3. Create HPP (POST)

"type":"POST","title":"Create HPP","arguments":{"country":"SE","session_id":"your-session-id","order_id":your-order-id

Requests Klarna to create a hosted payment page, associated with the existing session, that we can redirect the customer to.

This event should happen once.

4. Create customer token (POST)

"type":"POST","title":"Create customer token","arguments":{"country":"SE","auth_token":"your-auth-token","order_id":"your-order-id"

The customer was redirected back to the Woo store (the subscription view) successfully, and we can proceed with creating a customer token for the subscription.

This event should happen once.


Errors that might happen


Failed to create recurring token

'Failed to create recurring token. Reason: %s', 'klarna-payments-for-woocommerce'

The customer was redirected back to the Woo store (the subscription view) successfully, and we can proceed with creating a customer token for the subscription. However, for some unknown reason, the request failed.