News:

Looking for documentation? Take a look on our wiki

Main Menu

2 Payment plugins problem

Started by restodo, January 01, 2018, 22:50:08 PM

Previous topic - Next topic

restodo

Hello!
I have Joomla 3.8.2 and Virtuemart 3.2.12 and I'm trying to use 2 payments plugins of companies in Argentina (Mercadopago and Todo Pago).

If I install only Mercadopago plugin works good. If I install only Todo Pago plugin works good. Then both plugins works well.
If I install and enable both plugins and only create the payment entry in VM for Todo Pago, when I make a payment and back to Virtuemart an error appears.

I want to know If someone knows which function could be missing in both plugins to make that problem? It seems when going back from Todo Pago payment form to Virtuemart for some reason come in action some of Mercadopago plugin.


Thanks in advance.

Alemantico

what version of vm/joomla are you using? what is the error message? what other payments you are using? localhost/life server? please provide more information!

restodo

Quote from: Alemantico on January 02, 2018, 09:55:29 AM
what version of vm/joomla are you using? what is the error message? what other payments you are using? localhost/life server? please provide more information!

Thanks for your answer.

1) Joomla 3.8.2 and Virtuemart 3.2.12
2) When Virtuemart must show Thank You message, shows Error 400 Invalid Credentials. I assume this error happens because the other payment method (Mercadopago) came in action I don't know why because selected was Todo Pago
3) File Server

Studio 42

I think that the plugin are bugged.
All plugin return to same address, so if the plugin dont check if another plugin is called and not itself(using plugin id for eg.), you have such error.
Error 400 Invalid Credentials is certainly because plugin mean you call it but you call another one. Only the plugin developer can solve this bug.

restodo

Quote from: Studio 42 on January 02, 2018, 15:54:59 PM
I think that the plugin are bugged.
All plugin return to same address, so if the plugin dont check if another plugin is called and not itself(using plugin id for eg.), you have such error.
Error 400 Invalid Credentials is certainly because plugin mean you call it but you call another one. Only the plugin developer can solve this bug.

Thanks for the answer Studio 42! I think the same as you.

The Todo Pago plugin returns to the following address when shows Error 400 Invalid Credentials
https://test.restodo.com.ar/index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=201800175&pm=13&Answer=6ed9d18d-f8a8-69d4-44af-8c8faaa2b4e5

I see pm=13 that is the id for Todo Pago plugin, then I think maybe the problem is with Mercadopago plugin. What do you think?

If you don't mind, could you tell me in what function of the plugin must check " if another plugin is called " ?

Studio 42

This is the triggered  function and standard way to verify in your JOOMLAROOT\plugins\vmpayment\MYPAYMENT\MYPAYMENT.php
function plgVmOnPaymentResponseReceived(&$html) {
if (!class_exists('VirtueMartCart')) {
require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
}
if (!class_exists('shopFunctionsF')) {
require(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php');
}
if (!class_exists('VirtueMartModelOrders')) {
require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php' );
}
VmConfig::loadJLang('com_virtuemart_orders', TRUE);

// the payment itself should send the parameter needed.
$virtuemart_paymentmethod_id = vRequest::getInt('pm', 0);
if (!($method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
return NULL; // Another method was selected, do nothing
}
if (!$this->selectedThisElement($method->payment_element)) {
return NULL;
}
$order_number = vRequest::getString('on', 0);
if (!$virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number)) {
return NULL;
}
if (!$payments = $this->getDatasByOrderNumber($order_number)) {
return '';
}
// render response
$html = $this->renderByLayout( 'response',
array("success" => $success,
"payment_name" => $method->payer_method,
"order" => $order)
);
$cart = VirtueMartCart::getCart();
$cart->emptyCart();
return TRUE;
}


The minimum code to prevent your bug is :
// the payment itself should send the parameter needed.
$virtuemart_paymentmethod_id = vRequest::getInt('pm', 0);
if (!($method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
return NULL; // Another method was selected, do nothing
}

restodo

Quote from: Studio 42 on January 02, 2018, 18:14:18 PM
This is the triggered  function and standard way to verify in your JOOMLAROOT\plugins\vmpayment\MYPAYMENT\MYPAYMENT.php
function plgVmOnPaymentResponseReceived(&$html) {
if (!class_exists('VirtueMartCart')) {
require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
}
if (!class_exists('shopFunctionsF')) {
require(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php');
}
if (!class_exists('VirtueMartModelOrders')) {
require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php' );
}
VmConfig::loadJLang('com_virtuemart_orders', TRUE);

// the payment itself should send the parameter needed.
$virtuemart_paymentmethod_id = vRequest::getInt('pm', 0);
if (!($method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
return NULL; // Another method was selected, do nothing
}
if (!$this->selectedThisElement($method->payment_element)) {
return NULL;
}
$order_number = vRequest::getString('on', 0);
if (!$virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number)) {
return NULL;
}
if (!$payments = $this->getDatasByOrderNumber($order_number)) {
return '';
}
// render response
$html = $this->renderByLayout( 'response',
array("success" => $success,
"payment_name" => $method->payer_method,
"order" => $order)
);
$cart = VirtueMartCart::getCart();
$cart->emptyCart();
return TRUE;
}


The minimum code to prevent your bug is :
// the payment itself should send the parameter needed.
$virtuemart_paymentmethod_id = vRequest::getInt('pm', 0);
if (!($method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
return NULL; // Another method was selected, do nothing
}


Thanks!! I've added the code given by you and the problem was solved!!