• We are having some problems with transactions that start out in Vipps (via the krokedil integration with Klarna) and then for some reason later on tries to finish the transaction with Klarna instead of Vipps.

    I have been trying to figure out a way to turn on a more verbose logging in the Vipps plugin but I have not found how to turn that on. Could you please let me know how to turn on better logging?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Iver Odin Kvello

    (@iverok)

    There is no verbose logging setting, but there are many hooks that can be augmented with a call to

    Vipps::instance()->log("...");

    We have gotten some reports of a similar situation before; but we have not been able to find the actual problem. In the given cases, the *payment method* has changed to Klarna at some point in the payment process, even though the order was completed with Vipps. Is this what you are experiencing as well?

    When logging this on other sites, we have focused on logging the payment method on different parts of the lifecycle of the order, in particular on the callback, in process_payment and so forth. However, on testing the orders had payment method “vipps” all the way through; but “kco” when the callback from Vipps arrived. This means that something in the Klarna logic sets the payment method in the interim.

    If you are seeing the same thing, you may try to log the payment method in process payment with

    add_action('woo_vipps_before_redirect_to_vipps', function($order_id) {
         $order = wc_get_order($orderid);
         if ($order) {
               Vipps::instance()->log("on redirect, $orderid har pm " . $order->get_payment_method());
          }
    }, 10, 1);

    And on the callback,

    add_action('woo_vipps_vipps_callback',  
        function ($result,$raw_post) { 
          $orderid = Vipps::instance()->getOrderIdByVippsOrderId($result['orderId']);
          $order = wc_get_order($orderid);
          if ($order) {
               Vipps::instance()->log("ved callback, $orderid har pm " . $order->get_payment_method());
          }
        }, 10, 2);

    If it is the same, you should see “vipps” and then “kco” when logging this.

    If something external – Klarna, or something else – resets the payment method, and you cannot find the reason for this, you may have to just set the payment method back to Vipps again. There are meta variables in the order that can be checked to see if this is appropriate.

    (As mentioned, we don’t know why this happens. It does not seem that KCO explicitly resets the payment method, but it could happen if for instance they have an $order object instantiated with the old payment method that gets saved after the new payment method is set, or something like that. If you are using a persistent object cache, that could be a part of it. If you find anything, please let us know.)

    Thread Starter jarledb

    (@jarledb)

    Yes, we are seeing the payment method has changed to Klarna at some point in the payment process, even though the order was completed with Vipps.

    Do you have any email address I can send some more details we are seeing in the order process that I don’t want to share on this forum?

    As to the logging: Can I just add the code you provided to functions.php?

    We had object caching turned on, but that has been turned off now. We do use Varnish and Breeze for caching though. I will test with removing the Breeze plugin – that has caused other issues on other sites in the past.

    Plugin Author Iver Odin Kvello

    (@iverok)

    You can contact us at [email protected].

    You should be able to add the logging to functions.php directly, yes. You may want to add it to a small plugin instead so it will be easy to turn off.

    It is very unlikely that page caching is the problem; in particular not Varnish since that respects all the no-cache headers all the woo pages in question output.

    The issue is most likely caused by some conflict with the KCO plugin. We of course do not set the payment method to anything not Vipps, but cursory inspection of the KCO plugin hasn’t uncovered any obvious point where that would do this either. The solution may be to just reset the payment method to Vipps again when we know this to be correct (for instance in the callback). If you contact us on the above address we may be able to assist in testing this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Logging for debugging?’ is closed to new replies.