Zen cart 1.57d, php7.4
one-page checkout 2.4.5. Paypal express & paypal payment pro
We received intermittent duplicated orders when customer paid by credit card/paypal payment pro, like once per week. And it seems getting worse and worse. One pattern I noticed that, in the paypal log files of those duplicated orders, the INVNUM or order number are very close to each others (1s difference or so). PayPal has a function to auto-deny the transaction if both transactions have the same INVNUM numbers.
Here is the github link for paypalwpp.php I'm currently using:
https://github.com/zencart/zencart/b.../paypalwpp.php
I did some search and INVNUM is related to line 396 as the following:
$options['PAYMENTREQUEST_0_INVNUM'] = (int)$_SESSION['customer_id'] . '-' . time() . '-[' . substr(preg_replace('/[^a-zA-Z0-9_]/', '', STORE_NAME), 0, 30) . ']'; // (cannot send actual invoice number because it's not assigned until after payment is completed)
In the log file I received, INVNUM is like 1095xx-167700xxxx-[webstore] So the 10-digit middle section of the current INVNUM is generated via time().
I changed this line to the following code and I expected the new INVNUM format is like 1095xx-167700xx-[webstore]. So the middle section will be 8 digit only.
$options['PAYMENTREQUEST_0_INVNUM'] = (int)$_SESSION['customer_id'] . '-' . (floor(time()/60)) . '-[' . substr(preg_replace('/[^a-zA-Z0-9_]/', '', STORE_NAME), 0, 30) . ']'; // (cannot send actual invoice number because it's not assigned until after payment is completed)
However, it doesn't work. By my new test, INVNUM format is unchanged (verified in paypal side and the log files).
So what is the proper way to change the format of INVNUM value? Any suggestions are appreciated.
Bookmarks