Jump to content

Transaction logged twice in Payment Gateway


Guillaume

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 comment
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 comment
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 comment
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 comment
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 comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...