News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

cancel url calling from wrong plugin

Started by rejoan, October 06, 2020, 19:06:15 PM

Previous topic - Next topic

rejoan

Hi,
I am developing a payment plugin for virtumart. It is working fine but one issue raised. I have created a new method called plgVmOnUserPaymentCancel in my "amarpay.php" (amarpay plugin). But this method not calling on user cancel. plgVmOnUserPaymentCancel is being called from "tco(2checkout)" plugin. My new plugin same name method not calling.
When I remove/uninstall 2chekout plugin then start working new plugin plgVmOnUserPaymentCancel method

How to resolve this issue? please help.  have seen there are many same name method/event available across the payment plugin & calling/triggering corresponding right method but mine is not working

Jörgen

#1
Your plugin is badly written...
It is your responsibility to make sure that the call is for your plugin. Look att the existing plugins...

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

rejoan

I have copied the standard plugin and modified as required.

Jörgen

Then You have not understood the code in the beginning of each trigger function...
Without any real code example, this is what I think.

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Jörgen

Maybe to old VM version, who knows ?

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

rejoan

#5
My Joomla version is 3.9.21 & my virtumart version is 3.8. I have called cancel url in my plgVmConfirmedOrder like this

$cancelUrl = JURI::root() . 'index.php/shop/pluginresponse/pluginUserPaymentCancel?on=' . $order['details']['BT']->order_number . ',' . $order['details']['BT']->virtuemart_paymentmethod_id;
$post_data['cancel_url'] = $cancelUrl;
$response = $this->_sendRequest($method, $post_data);


and at com_virtumart/controllers/vmplg.php the pluginUserPaymentCancel method I do not touch anything

Finally my plugin construct method like this

if (!class_exists('vmPSPlugin')) {
    require(VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php');
}

class plgVmPaymentAmarpay extends vmPSPlugin {

    function __construct(& $subject, $config) {

        parent::__construct($subject, $config);
        $this->_loggable = TRUE;
        $this->tableFields = array_keys($this->getTableSQLFields());
        $this->_tablepkey = 'id';
        $this->_tableId = 'id';
        $varsToPush = $this->getVarsToPush();
        $this->addVarsToPushCore($varsToPush, 1);
        $this->setConfigParameterable($this->_configTableFieldName, $varsToPush);
    }

function plgVmOnUserPaymentCancel() {
        $reqData = vRequest::getString('on', '');
        $reqDataArr = explode(',', $reqData);
        $order_number = trim($reqDataArr[0]);

        $virtuemart_paymentmethod_id = trim($reqDataArr[1]);
...





Jörgen

You have to look for this kind of construct !


if (!($this->_currentMethod = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
return NULL; // Another method was selected, do nothing


Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

rejoan

After providing unique order number for each payment method when payment method created. It is working

AH

That means your code for your new plugin is wrong - each payment method does not require a unique order_id
Payment plugins should test to see if the order being "updated" by the plugin was actually created by that plugin
Regards
A

Joomla 4.4.5
php 8.1