Jump to content

Transaction logged twice in Payment Gateway


Recommended Posts

Hi everyone,

I am developping a plugin with the aim to interface my Cubecart-powered website to a French PSP called Systempay. All works good, and I am about to publish. However, for a reason which I ignore, after payment, transactions are systematically logged twice. The problem is specific to my plugin Systempay (as you can see from the transaction logs enclosed, Paypal Commerce and Print Order Form work all right).

I believe the problem is somewhere around line 163 of my call function:

        $order->logTransaction($transData);


But what really puzzles me is that, whenever I comment this line, no transaction is logged. If I uncomment it, two transactions are logged. Needless to say, orders are processed only once, and so are payments, so I suspect it's really only a transaction logging issue.

The payment gateway is functional overall, but I'm more concerned from a reporting persepctive. Enclosed is the whole soft of the gateway.

Regards,

Guillaume

Transaction Logged Twice.png

Systempay 06 04 2021.zip

Link to post
Share on other sites

Because I can't understand the problem's root cause, I'm trying to make a patch by checking if the existing logs for that order are empty, and only log the transaction if so is the case. But I'm guessing I'm totally wrong in my syntax:

image.thumb.png.ae2a886e6dee2fffce6e68fa34d11221.png

I've similarly tried if !empty(...) and a few similar methods, without luck. What I'm struggling to understand is the nature of the object $order->logTransaction($transData)

I have also tried capturing the $order->logTransaction($transData) into a variable first, as below, but without luck:

image.png.794cce92ef05ba72208f7a1e52ae2c49.png

Similarly, I have also tried if (empty(...))

Link to post
Share on other sites

Order->logTransaction() returns only true or false as a response to whether or not the log action could have been performed.

A true response if all data required was present, a false if any of the data required was missing.

This function does not return anything based on already logged data.

To get an indication of whether this order was logged, use the $GLOBALS['db']->select() with the needed parameters.

 

 

Link to post
Share on other sites

Thanks a million. After several tries, I managed! I am pasting the code which works, for everyone's records:

 

        $transaction_records = $GLOBALS['db']->select('CubeCart_transactions', array('id'), array('order_id' => $cart_order_id), false, false, false, false);
        if (!$transaction_records) $order_log = $order->logTransaction($transData);

Link to post
Share on other sites

I think this is a work-around for their SystemPay module -- and perhaps some kind of issue with the payment processor calling CubeCart more than once.

This has not yet been proven to be a systemic problem with CubeCart code. So, I vote no.

 

Link to post
Share on other sites

It's indeed specific to my plugin. I don't think the problem comes from the payment processor, I don't master the Cubecart framework, so it's probably a bug in my code, which this work-around solves.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...