News:

Support the VirtueMart project and become a member

Main Menu

Trigger for Stopping Order Submission

Started by smusselm, September 19, 2019, 14:49:52 PM

Previous topic - Next topic

smusselm

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!

GJC Web Design

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);

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

smusselm

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. :/

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.