PHP Warning: A non-numeric value encountered in creditcard.php

Started by EsSa55, September 18, 2019, 10:17:24 AM

Previous topic - Next topic

EsSa55

TIA


PHP 7.2.22
JM   3.9.11
VM  3.6.1.10144


PHP Warning:  A non-numeric value encountered in /public_html/administrator/components/com_virtuemart/helpers/creditcard.php on line 133


96   static function mod10($card_number) {      
97         
98      $digit_array = array();   
99      $cnt = 0;   
100         
101      //Reverse the card number   
102      $card_temp = strrev($card_number);   
103         
104      //Multiple every other number by 2 then ( even placement )   
105      //Add the digits and place in an array   
106      for ($i = 1; $i <= strlen($card_temp) - 1; $i = $i + 2) {   
107         //multiply every other digit by 2
108         $t = substr($card_temp, $i, 1);
109         $t = $t * 2;
110         //if there are more than one digit in the
111         //result of multipling by two ex: 7 * 2 = 14
112         //then add the two digits together ex: 1 + 4 = 5
113         if (strlen($t) > 1) {
114         
115         
116         
117         
118         
119         
120         
121         
122         } else { // result of (* 2) is only one digit long
123         
124         }
125         //place the result in an array for later
126         //adding to the odd digits in the credit card number
127         $digit_array [$cnt++] = $tmp;
128      }   
129      $tmp = 0;   
130         
131      //Add the numbers not doubled earlier ( odd placement )   
132      for ($i = 0; $i <= strlen($card_temp); $i = $i + 2) {   
133         $tmp = substr($card_temp, $i, 1) + $tmp;
134      }   
135         
136      //Add the earlier doubled and digit-added numbers to the result   
137      $result = $tmp + array_sum($digit_array);   
138         
139      //Check to make sure that the remainder   
140      //of dividing by 10 is 0 by using the modulas   
141      //operator   
142      return ($result % 10 == 0);   
143   }      

stemithy

Exact same issue and versions here.  For me it results in the user being stuck in a loop between the cart checkout screen and the enter credit card screen.  It shows that it retained the payment information but won't complete the transaction.

Thanks,

GJC Web Design

try to debug what is parsed there

e.g. add after line 132

print 'Debug Line '.__LINE__.' substr($card_temp, $i, 1) <pre>'; print_r (substr($card_temp, $i, 1)); print "</pre><br />\n";

then die(); after line 134

all numeric? no blanks? etc
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

ssc3

For users of the PayPal Pro plugin from Virtuemart Extensions there was an update released last week to address this issue.

PHP 7.2 seems to be giving out a warning message ignored by earlier versions.

However in this case the warning message had no effect on the processing of the order.

If using our plugin use the update link at the top of the page in the PayPal Pro plugin setup.

The latest version is also working correctly in VM 3.6.x
Virtuemart Payment Plugins
https://plugins.online-store.co.uk


ssc3

Quote from: stemithy on October 01, 2019, 15:41:34 PM
I'm having the issue using the Authorize.net plugin.

The native Authorize.Net plugin is currently broke in 3.6.1 and 3.6.2 and orders can not be processed.

The Authorize.Net Accept plugin from Virtuemart Extensions is still working in 3.6.1 and 3.6.2
Virtuemart Payment Plugins
https://plugins.online-store.co.uk

Milbo

Quote from: ssc3 on October 01, 2019, 21:00:33 PM
The native Authorize.Net plugin is currently broke in 3.6.1 and 3.6.2 and orders can not be processed.

What is broken? Should work.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

Quote from: ssc3 on September 30, 2019, 23:44:19 PM
PHP 7.2 seems to be giving out a warning message ignored by earlier versions.

However in this case the warning message had no effect on the processing of the order.

What should be changed? So that the file is working "clean" again.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

ssc3

Quote from: Milbo on October 02, 2019, 08:57:21 AM
Quote from: ssc3 on October 01, 2019, 21:00:33 PM
The native Authorize.Net plugin is currently broke in 3.6.1 and 3.6.2 and orders can not be processed.

What is broken? Should work.

http://forum.virtuemart.net/index.php?topic=143438.0

Still using old code.
Virtuemart Payment Plugins
https://plugins.online-store.co.uk

ssc3

Quote from: Milbo on October 02, 2019, 08:58:00 AM
What should be changed? So that the file is working "clean" again.


131      //Add the numbers not doubled earlier ( odd placement )   
132      for ($i = 0; $i <= strlen($card_temp); $i = $i + 2) {   
133         $tmp = substr($card_temp, $i, 1) + $tmp;
134      } 


as far as i can tell this is making one loop too many.

but a none too subtle fix.


//Add the numbers not doubled earlier ( odd placement )
for ($i = 0; $i <= strlen($card_temp); $i = $i + 2) {

$sub = substr($card_temp, $i, 1);

//echo "*$sub#";
//echo is_numeric($sub);

if(is_numeric($sub))
{
$tmp = $sub + $tmp;
}
}

Virtuemart Payment Plugins
https://plugins.online-store.co.uk

Milbo

or maybe

for ($i = 0; $i < (strlen($card_temp)); $i = $i + 2) {


Of course it runs to far, because we have $i+2, or? So either length -1 or lets remove the =
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

I will replace it by


//Add the numbers not doubled earlier ( odd placement )
$l = strlen($card_temp);
for ($i = 0; $i < $l; $i = $i + 2) {
$tmp = substr($card_temp, $i, 1) + $tmp;
}
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

ssc3

I was thinking about trying

for ($i = 0; $i < strlen($card_temp); $i = $i + 2)

but the original code on which this based was first written in 2002, according to the copyright. I was a little reluctant to change something that had been "working" since then.

The code I used for debugging which filtered the non numberic values also worked, so I just left that in place.
Virtuemart Payment Plugins
https://plugins.online-store.co.uk

ssc3

Quote from: Milbo on October 02, 2019, 12:29:54 PM

//Add the numbers not doubled earlier ( odd placement )
$l = strlen($card_temp);
for ($i = 0; $i < $l; $i = $i + 2) {
$tmp = substr($card_temp, $i, 1) + $tmp;
}


Works as far as I can tell.

Both odd and even digit credit card numbers. Amex and Visa tested
Virtuemart Payment Plugins
https://plugins.online-store.co.uk

Milbo

yeh I tested it in my "play" view, which is just there to test snippets. I tested it with 12345678 and 123..89
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/