Klarna for WooCommerce – Recurring payments

Introduction

The Klarna payment gateway for WooCommerce is compatible with the WooCommerce Subscriptions extension for handling of recurring payments.

Requirements

To get started with recurring payments via Klarna in your WooCommerce store, you will need the following:

  • An agreement with Klarna to handle recurring payments (via Klarna Checkout).
  • The extension WooCommerce Subscriptions installed and configured.

Get started with subscriptions

  1. Create a simple subscription product. Set it to a daily renewal so that we can test the renewal process as well.
  2. Make a test purchase (either with a real account or a test account).
  3. Make sure that:
    – The subscription order is created in both Klarna and WooCommerce.
    –  A Klarna reservation number is added to the order notes in WooCommerce.
    – The subscription status is set to Active in WooCommerce.
  4. Wait 24 hours and check that the renewal order is created and a new reservation number from Klarna is added to the order notes in the original order.

Don’t have the time to wait? – Manually trigger renewal orders

1. Switch to Debug mode

The first step to testing renewals is to switch your site into debug mode. To switch WordPress into debugging mode, add the following line of code to your site’s wp-config.php file:

define( 'WP_DEBUG', true );

To switch WooCommerce Subscriptions into debugging mode, add the following code to your site’s wp-config.php file:

if ( ! defined( 'WCS_DEBUG' ) ) {
define( 'WCS_DEBUG', true );
}

2. Triggering the Renewal

  • Visit your site’s administration dashboard.
  • Go to: Tools -> Scheduled Actions.
  • In the search box, enter {order_id}_ i.e. the ID of the order in which the subscription was purchased followed by an underscore. For example, for a subscription purchased in order 3125, the search string is 3125_.
  • Find the row with the hook scheduled_subscription_payment and the status pending.
  • Hover over the row and and click Run.

Check that the renewal order is created and a new reservation number from Klarna is added to the order notes in the original order.

3. Cleaning Up

Once you have triggered the renewal successfully, you will end up with two pending scheduled_subscription_payment actions – one on the original schedule and another on a new schedule based on the time of running the action (i.e. now).

You can find and trash either of these actions from the Scheduled Actions screen. Which scheduled action you choose to trash depends on which schedule you wish to keep.