Jump to content

Update of order status


Guillaume

Recommended Posts

Hello,

I am developping a new payment gateway, aiming to interface with Systempay payment system. However, even though the payment is accepted, I don't manage to set to the correct status neither the order (which would be ORDER_PROCESS or ORDER_COMPLETE) nor the payment (PAYMENT_SUCCESS). The orcder status stays in ORDER_PENDING

I have a piece of software in gateway.class.php (lines 166 and 167), inside an if loop (lines 162 to 167) which I know we get into. Indeed, the httpredir command on line 163 is executed.

Am I gettng the below totally wrong?

        if($_REQUEST['vads_trans_status'] == "AUTHORISED"){
            httpredir($GLOBALS['storeURL'].'/index.php?_a=complete', '', true, 200, true); //empties the cart?
            $transData['status']     = "Success";
            $transData['notes']     = "Payment was successful.";
            $order->orderStatus(Order::ORDER_COMPLETE, $cart_order_id);
            $order->paymentStatus(Order::PAYMENT_SUCCESS, $cart_order_id);

    }

Thanks in advance for any help you may bring. Here enclosed is the full software.

 

Systempay 02 04 2021.zip

Link to comment
Share on other sites

The function httpredir() is one of the several exit points for CubeCart. No relevant work is performed once entering here.

Put it at the end of your call() method.

Also, do change the order to Order::ORDER_PROCESS, or Order::ORDER_PENDING with PAYMENT_PENDING, depending on the outcome. (A Complete status is after it gets shipped, or, if digital, is automatic via CubeCart decision-making.)

Link to comment
Share on other sites

Hi,

Really appreciate your help! However, I have tried the following (the full soft is enclosed to this message), and the order and payment statuses still seem to be ignored. I fully agree with your remark on the order status (complete means it has been shipped), but for now I simply wanted to test using a status which is different enough from pending, so that I can clearly identify if my instruction is applied or not (and unfortunately it is not):

 

        $redirection = $GLOBALS['storeURL'].'/index.php';
        
        if($_REQUEST['vads_trans_status'] == "AUTHORISED"){
            $redirection = $redirection . '?_a=complete'; //empties the cart?
            $transData['status']     = "Success";
            $transData['notes']     = "Payment was successful.";
            $order->orderStatus(Order::ORDER_COMPLETE, $cart_order_id);
            $order->paymentStatus(Order::PAYMENT_SUCCESS, $cart_order_id);
        } else if ($_REQUEST['vads_trans_status'] == "REFUSED"){
            $redirection = $redirection . '?_a=gateway'; //keeps the cart alive?
            $transData['status']     = "Failed";
            $transData['notes']     = "Payment was refused.";
        } else if ($_REQUEST['vads_trans_status'] == "ABANDONED"){
            $redirection = $redirection . '?_a=confirm'; //keeps the cart alive?
            $transData['status']     = "Failed";
            $transData['notes']     = "Payment was abandonned.";
        }
                        
        $order->logTransaction($transData);
        unset($GLOBALS['seo']);
        httpredir($redirection, '', true, 200, true);

 

Appreciate if you have any thoughts! Cheers,Systempay 02 04 2021 - updated.zip

Guillaume

Link to comment
Share on other sites

Are there any new log entries in the admin's Transaction Logs?

If not, then the call() method isn't getting executed. If so, click the link that is the Order Number to see more details about the response.

Have you determined if the call() method is being executed?

Link to comment
Share on other sites

Hi,

Thanks a lot for your support. I am absolutely sure the call() method is executed and we get into the if loop checking the payment is authorized. I tested this by changing the URL we redirect to (see the last version of my file, where in the if loop I define the URL to redirect to, while as you suggested earlier, the httpredir command is only executed at the very end).

Enclosed are the logs (Cubecart debug mode) appearing below the page, after payment. Was it these logs you were about? The order ID in this occurence is 210403-223854-8239. I did not find anyting meaningful with regards to the status though, but I have to admit I am unfamiliar reading such logs.

On a separate note, and unlike the above it's nothing blocking me, but I wonder what the instruction unset($GLOBALS['seo']) (line 180) actually does)?

Thanks a lot in advance for your kind support. Best regards,

Guillaume

Logs order pending after payment successful.txt

Link to comment
Share on other sites

Sorry, no, not the debug logs. In admin, in the left pane navigation, in the Customers section, click the link "Transaction Logs".

There are numerous occasions where a web address link is created (documents, login, etc, etc). This link construction will always pass through SEO in an attempt to create a "custom friendly URL" as opposed to the standard URL.

For this case, that is not what is wanting to happen. (Why not, exactly, I have no ready answer.)

Link to comment
Share on other sites

Hi,

My admin page unfortunately is in French, but I believe the below is what you are about. I have several payment gateways (Print Order Form, Paypal Commerce, Systempay) offered on the website, and transactions (and orders) made with Systempay are indeed never reported here... Which I believe is an interesting finding.

image.png.4c059748d9681a86e16b3a23849a91e1.png

Looking again at the soft, I am under the impression that the instruction on line 179 $order->logTransaction($transData); is therefore probably not executed?

However, I checked again changing the redirection address, and am 100% sure that the call() function is called, and within the call() function, the if statement checking upon the fact that the payment is authorized. Strange isn't it?

Guillaume

Link to comment
Share on other sites

I would like for you to check this statement:

Near line 156:

$transData['trans_id'] = $_REQUEST['transId'];

Should it be?

$transData['order_id'] = $_REQUEST['transId'];

The transaction logger will not log if there is a missing 'order_id' or a missing 'gateway' in the data to be logged.

Link to comment
Share on other sites

Hi,

Thanks for the heads-up above, that's good to know. I tried the above and it didn't work, unfortunately. As I was afraid it may be because $_REQUEST['transId'] is empty, I identified seven characteristics of transData present in the "Print Order Form" gateway (which correctly logs transactions made on the website I am developping) and tried hard-coding them. It gives a code like the below:

            $transData['customer_id']    = "Guillaume";
            $transData['gateway']         = "Systempay";
            $transData['order_id']         = "1234";
            $transData['trans_id']         = "123456";
            $transData['amount']         = "10";
            $transData['status']     = "Success";
            $transData['notes']     = "Payment was successful.";
            $order->logTransaction($transData);

But here again, no transaction is logged... Anything I am missing again?

More generally, regarding your remark on transData's required attributed (gateway and order_id as you mentioned), does Cubecart document this somewhere?

Best regards,

Guillaume

Link to comment
Share on other sites

Maybe try using a legitimate 'order_id', say "210404-120000-1234". Even though this order does not exist, it should not matter. (Neither should "1234", either.)

There is no organized resource for learning how the code works.

 

Link to comment
Share on other sites

Thanks for your heads-up. I have tried a few things which did not work, only to later find out that, in my soft the order ID is used as a key for nearly everything (see picture enclosed). The problem is, in that call() function I get the order ID back from the payment gateway message, and hence it must be defined with its own syntax. In the very case of Systempay that means:

$cart_order_id = sanitizeVar($_REQUEST['vads_order_id']);

And that's what I got wrong all the way. Now everything works, not only I have the transaction in the logs, but the order status is updated, and everything is fine! Thanks again for your continuous support!

Cart Order Id - myMistake.png

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...