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

Looking for info about Payment plugins: function plgVmOnSelectCheckPayment + ...

Started by rvbgnu, August 27, 2015, 19:06:55 PM

Previous topic - Next topic

rvbgnu

Hi,

I am looking further into existing payment plugins, and found an inconsistency, or I did not understand the different contexts (I am not familiar with EVERY payment system).

On both functions plgVmOnSelectCheckPayment() and plgVmOnCheckoutCheckDataPayment(), we can find the test
if (!($this->_currentMethod = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) {

But depending on which payment plugin it is, we have either
if (!($this->_currentMethod = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) {
return NULL; // Another method was selected, do nothing
}


OR

if (!($this->_currentMethod = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) {
return FALSE;
}


My understanding is that this statement should respond null if the event triggered (like "OnSelectCheckPayment") must return null if another payment method is selected.

Here are some links to current plugins versions to see what I mean:
Amazon "always" returns null
http://dev.virtuemart.net/projects/virtuemart/repository/annotate/trunk/virtuemart/plugins/vmpayment/amazon/amazon.php#L846
http://dev.virtuemart.net/projects/virtuemart/repository/annotate/trunk/virtuemart/plugins/vmpayment/amazon/amazon.php#L2505
http://dev.virtuemart.net/projects/virtuemart/repository/annotate/trunk/virtuemart/plugins/vmpayment/amazon/amazon.php#L2679

Authorize.net returns false in plgVmOnCheckoutCheckDataPayment() and in plgVmOnSelectCheckPayment()
http://dev.virtuemart.net/projects/virtuemart/repository/annotate/trunk/virtuemart/plugins/vmpayment/authorizenet/authorizenet.php#L350
but null in plgVmOnSelectedCalculatePricePayment()
http://dev.virtuemart.net/projects/virtuemart/repository/annotate/trunk/virtuemart/plugins/vmpayment/authorizenet/authorizenet.php#L404


So if someone can put a light on it, I will really appreciate it. And also I will be more than happy to provide a patch and to help finding and digging further this inconsistency, if it is a confirmed one.

Kind regards,
Hervé
Best Regards, Hervé Boinnard - Irish Time (GMT)
Joomla! multilingual website and online business made easy - https://www.puma-it.ie

3D Secure v1 (3DS1) & Strong Customer Authentication (SCA)! Stripe.com payment plugin for VirtueMart 3: https://www.puma-it.ie/en/joomla-and-virtuemart-extensions/stripe-for-virtuemart
Authipay (AIB Merchant Services) for VirtueMart 2 & 3: https://www.puma-it.ie/en/joomla-and-virtuemart-extensions/authipay-aib-merchant-services-for-virtuemart

alatak

Hello Hervé

Amazon is not the correct payment you should look at .It is not a "classic payment"
And i should remove the plgVmOnSelectCheckPayment trigger since it is not used.

The best is that you get inspiration from Authorize.net payment plugin.
Or from this one administrator/components/com_virtuemart/plugins/vmpsplugin.php which is the class

Those are the 2 lines which are correct:
if (!($this->_currentMethod = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) {
                        return NULL;
                }
if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
                        return FALSE;
                }


Those triggers should return:
NULL: if it is another method selected
FALSE if the method was selected but the data is not valid
TRUE  if the method was selected but the data is valid