VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: smusselm on September 19, 2019, 14:49:52 PM

Title: Trigger for Stopping Order Submission
Post by: smusselm on September 19, 2019, 14:49:52 PM
I am customizing the off-line credit card processing plugin to work with a client's proprietary accounting system. They require that I write the information to an encrypted file (done). Then I do a curl to have that line processed (authorized) by the credit card processor (done). It needs to be done this way, so that when the order is processed internally they can charge the card with their existing processes.

All is working except, I need to be able to stop the order process if the authorization response does not come back successful. They should be able to enter new credit card information at that point.

I was testing the following code in different places in file, but I can't seem to find the right trigger(s):

$auth_result = '0';
if ($auth_result != 100) {
            return false;
         }

(Will build out the code, once I find the right trigger.)

Can you point me in the right direction? Thanks!
Title: Re: Trigger for Stopping Order Submission
Post by: GJC Web Design on September 19, 2019, 17:10:46 PM
In payment plugins normally you are calling  plgVmOnPaymentResponseReceived (&$html) and if invalid return null

if valid return  true and set the $html that is rendered by the orderdone.php

in that function update the order : e.g. $modelOrder->updateStatusForOneOrder ($virtuemart_order_id, $order, TRUE);

Title: Re: Trigger for Stopping Order Submission
Post by: smusselm on September 19, 2019, 19:43:11 PM
Thanks!

Still can't get it to stop the order completion. There must be something (probably a lot) I'm missing.  What is the code that OKs the order completion?

I moved the update order status from plgVMConfirmedOrder to plgVmOnPaymentResponseReceived and it's still going through.

    function plgVmOnPaymentResponseReceived(&$html) {

if (!class_exists('VirtueMartCart')) {
require(VMPATH_SITE . DS . 'helpers' . DS . 'cart.php');
}
if (!class_exists('shopFunctionsF')) {
require(VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php');
}
if (!class_exists('VirtueMartModelOrders')) {
require(VMPATH_ADMIN . DS . 'models' . DS . 'orders.php');
}

vmLanguage::loadJLang('com_virtuemart_orders', TRUE);

        $auth_result=0;

        if($auth_result != 100) {
            return NULL;
        }

        else {
            return true;
            $html = "yes!";

$modelOrder = VmModel::getModel('orders');
$order['order_status'] = $method->order_status_confirmed;
$order['customer_notified'] = 1;
$order['comments'] = "";
$modelOrder->updateStatusForOneOrder($order['details']['BT']->virtuemart_order_id, $order, TRUE);

        }

       }


PS. Exposing my complete ignorance here. I'm a complete newbie, but I have to get this done. :/
Title: Re: Trigger for Stopping Order Submission
Post by: Jörgen on September 20, 2019, 07:05:45 AM
Afaik the order will still go through, but you can choose to set order status to pending and not empty the cart.
Jörgen @ Kreativ Fotografi