A non well formed numeric value encountered in PayPal











up vote
0
down vote

favorite












Have an error in my PayPal module on my Prestashop site. It says



[30-Oct-2018 10:37:19 Australia/Sydney] PHP Notice: A non well formed numeric value encountered in /home/public_html/modules/npaypalpro/ajax.php on line 214



Line 214 is



$amountCheck += number_format($item['quantity'] * $item['price'], 2);


Any ideas what might be the cause?



PHP7.1 on the server



PayPal said




I quickly checked the transaction logs and found that there is mismatch in total amount and item amount.



For one of the order, total amount is AUD 2337.30 but the sum of item
details are AUD 2339.30



Item Details :



Hikvision 6 MB - 180.90 x 7(quantity) = 1266.30 AUD Hikvisiion 4
channel - 535.50 x 2(quantity) = 1071.00 AUD Shipping – 0 Voucher
Taxes – 2.00 AUD – Which is not added in the total amount.



Could you please ask the web developer to check how Voucher taxes are
getting added or to see why this is not passing in the API call?




Full function



function totalAmountCheck($amount, $items)
{
$amountCheck = $diff = 0;

foreach ($items as $item)
$amountCheck += number_format($item['quantity'] * $item['price'], 2);

if ($amountCheck != $amount)
$diff = number_format($amountCheck - $amount, 2);

return $diff;


}










share|improve this question
























  • Are you using a module to apply an additional fee?
    – idnovate
    Nov 12 at 7:41










  • @idnovate no the module links with PayPal via the API. There was a discount applied to a product with taxes included. We tried turning off taxes but it still didn't like it
    – Paul D
    Nov 12 at 9:21















up vote
0
down vote

favorite












Have an error in my PayPal module on my Prestashop site. It says



[30-Oct-2018 10:37:19 Australia/Sydney] PHP Notice: A non well formed numeric value encountered in /home/public_html/modules/npaypalpro/ajax.php on line 214



Line 214 is



$amountCheck += number_format($item['quantity'] * $item['price'], 2);


Any ideas what might be the cause?



PHP7.1 on the server



PayPal said




I quickly checked the transaction logs and found that there is mismatch in total amount and item amount.



For one of the order, total amount is AUD 2337.30 but the sum of item
details are AUD 2339.30



Item Details :



Hikvision 6 MB - 180.90 x 7(quantity) = 1266.30 AUD Hikvisiion 4
channel - 535.50 x 2(quantity) = 1071.00 AUD Shipping – 0 Voucher
Taxes – 2.00 AUD – Which is not added in the total amount.



Could you please ask the web developer to check how Voucher taxes are
getting added or to see why this is not passing in the API call?




Full function



function totalAmountCheck($amount, $items)
{
$amountCheck = $diff = 0;

foreach ($items as $item)
$amountCheck += number_format($item['quantity'] * $item['price'], 2);

if ($amountCheck != $amount)
$diff = number_format($amountCheck - $amount, 2);

return $diff;


}










share|improve this question
























  • Are you using a module to apply an additional fee?
    – idnovate
    Nov 12 at 7:41










  • @idnovate no the module links with PayPal via the API. There was a discount applied to a product with taxes included. We tried turning off taxes but it still didn't like it
    – Paul D
    Nov 12 at 9:21













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Have an error in my PayPal module on my Prestashop site. It says



[30-Oct-2018 10:37:19 Australia/Sydney] PHP Notice: A non well formed numeric value encountered in /home/public_html/modules/npaypalpro/ajax.php on line 214



Line 214 is



$amountCheck += number_format($item['quantity'] * $item['price'], 2);


Any ideas what might be the cause?



PHP7.1 on the server



PayPal said




I quickly checked the transaction logs and found that there is mismatch in total amount and item amount.



For one of the order, total amount is AUD 2337.30 but the sum of item
details are AUD 2339.30



Item Details :



Hikvision 6 MB - 180.90 x 7(quantity) = 1266.30 AUD Hikvisiion 4
channel - 535.50 x 2(quantity) = 1071.00 AUD Shipping – 0 Voucher
Taxes – 2.00 AUD – Which is not added in the total amount.



Could you please ask the web developer to check how Voucher taxes are
getting added or to see why this is not passing in the API call?




Full function



function totalAmountCheck($amount, $items)
{
$amountCheck = $diff = 0;

foreach ($items as $item)
$amountCheck += number_format($item['quantity'] * $item['price'], 2);

if ($amountCheck != $amount)
$diff = number_format($amountCheck - $amount, 2);

return $diff;


}










share|improve this question















Have an error in my PayPal module on my Prestashop site. It says



[30-Oct-2018 10:37:19 Australia/Sydney] PHP Notice: A non well formed numeric value encountered in /home/public_html/modules/npaypalpro/ajax.php on line 214



Line 214 is



$amountCheck += number_format($item['quantity'] * $item['price'], 2);


Any ideas what might be the cause?



PHP7.1 on the server



PayPal said




I quickly checked the transaction logs and found that there is mismatch in total amount and item amount.



For one of the order, total amount is AUD 2337.30 but the sum of item
details are AUD 2339.30



Item Details :



Hikvision 6 MB - 180.90 x 7(quantity) = 1266.30 AUD Hikvisiion 4
channel - 535.50 x 2(quantity) = 1071.00 AUD Shipping – 0 Voucher
Taxes – 2.00 AUD – Which is not added in the total amount.



Could you please ask the web developer to check how Voucher taxes are
getting added or to see why this is not passing in the API call?




Full function



function totalAmountCheck($amount, $items)
{
$amountCheck = $diff = 0;

foreach ($items as $item)
$amountCheck += number_format($item['quantity'] * $item['price'], 2);

if ($amountCheck != $amount)
$diff = number_format($amountCheck - $amount, 2);

return $diff;


}







php paypal prestashop






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 11:47

























asked Nov 11 at 11:24









Paul D

74




74












  • Are you using a module to apply an additional fee?
    – idnovate
    Nov 12 at 7:41










  • @idnovate no the module links with PayPal via the API. There was a discount applied to a product with taxes included. We tried turning off taxes but it still didn't like it
    – Paul D
    Nov 12 at 9:21


















  • Are you using a module to apply an additional fee?
    – idnovate
    Nov 12 at 7:41










  • @idnovate no the module links with PayPal via the API. There was a discount applied to a product with taxes included. We tried turning off taxes but it still didn't like it
    – Paul D
    Nov 12 at 9:21
















Are you using a module to apply an additional fee?
– idnovate
Nov 12 at 7:41




Are you using a module to apply an additional fee?
– idnovate
Nov 12 at 7:41












@idnovate no the module links with PayPal via the API. There was a discount applied to a product with taxes included. We tried turning off taxes but it still didn't like it
– Paul D
Nov 12 at 9:21




@idnovate no the module links with PayPal via the API. There was a discount applied to a product with taxes included. We tried turning off taxes but it still didn't like it
– Paul D
Nov 12 at 9:21












2 Answers
2






active

oldest

votes

















up vote
0
down vote













The problem is the format of the content in the variables, you can solve it by replacing it with this:
$amountCheck += number_format((int)$item['quantity'] * (float)$item['price'], 2);






share|improve this answer





















  • thank you I will give that a try and report results back
    – Paul D
    Nov 12 at 9:20










  • just attempted payment with changes and received the generic failed error.
    – Paul D
    Nov 13 at 8:38










  • Creating a .htaccess folder in the PayPal module worked for me This is what I used #In order to change the version to 5.5 - <FilesMatch ".(php4|php5|php7|php3|php2|php|phtml)$"> SetHandler application/x-lsphp55 </FilesMatch> Working now
    – Paul D
    Nov 13 at 12:02










  • @PaulD What kind of error exactly, the same error?, because your solution was change the php version, that's not a solution, php 7 is much better and optimized than php 5
    – Rolige
    Nov 13 at 14:24










  • Same error, but the developer said " I haven't this issue with other sites so server settings might have something to do with it (maybe different character encodings cause PayPal to be more strict?). Without looking at the site and debugging i wouldn't be able to tell you what's going on with the other modules :/. As for this one this seemed to do the trick." Problem $amount = $ps_amount; // float Resolution: $amount = (string) $ps_amount; // string // The payload is then turned into json by php and send by cURL With his fix there was still issues though
    – Paul D
    Nov 22 at 9:07




















up vote
0
down vote













Paypal wants the exact price.



For example:



If your cart is 25 euro for 2 products plus 5 euro of shipping, you must to passing the shipping too.



in this case you must to pass the Voucher Taxes.



Paypal say: you want 2339.30 AUD but your cart is 2 AUD less.






share|improve this answer





















  • Have tried buying another Paypal module but having issues with that one too. Might be PHP7.1 or could be something else. More likely PHP 7.1 as everything works fine in PHP5.6
    – Paul D
    Nov 18 at 22:15










  • It's just strange that PayPal would have a hissy fit on PHP7 but not PHP5.5
    – Paul D
    Nov 22 at 9:55











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248227%2fa-non-well-formed-numeric-value-encountered-in-paypal%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













The problem is the format of the content in the variables, you can solve it by replacing it with this:
$amountCheck += number_format((int)$item['quantity'] * (float)$item['price'], 2);






share|improve this answer





















  • thank you I will give that a try and report results back
    – Paul D
    Nov 12 at 9:20










  • just attempted payment with changes and received the generic failed error.
    – Paul D
    Nov 13 at 8:38










  • Creating a .htaccess folder in the PayPal module worked for me This is what I used #In order to change the version to 5.5 - <FilesMatch ".(php4|php5|php7|php3|php2|php|phtml)$"> SetHandler application/x-lsphp55 </FilesMatch> Working now
    – Paul D
    Nov 13 at 12:02










  • @PaulD What kind of error exactly, the same error?, because your solution was change the php version, that's not a solution, php 7 is much better and optimized than php 5
    – Rolige
    Nov 13 at 14:24










  • Same error, but the developer said " I haven't this issue with other sites so server settings might have something to do with it (maybe different character encodings cause PayPal to be more strict?). Without looking at the site and debugging i wouldn't be able to tell you what's going on with the other modules :/. As for this one this seemed to do the trick." Problem $amount = $ps_amount; // float Resolution: $amount = (string) $ps_amount; // string // The payload is then turned into json by php and send by cURL With his fix there was still issues though
    – Paul D
    Nov 22 at 9:07

















up vote
0
down vote













The problem is the format of the content in the variables, you can solve it by replacing it with this:
$amountCheck += number_format((int)$item['quantity'] * (float)$item['price'], 2);






share|improve this answer





















  • thank you I will give that a try and report results back
    – Paul D
    Nov 12 at 9:20










  • just attempted payment with changes and received the generic failed error.
    – Paul D
    Nov 13 at 8:38










  • Creating a .htaccess folder in the PayPal module worked for me This is what I used #In order to change the version to 5.5 - <FilesMatch ".(php4|php5|php7|php3|php2|php|phtml)$"> SetHandler application/x-lsphp55 </FilesMatch> Working now
    – Paul D
    Nov 13 at 12:02










  • @PaulD What kind of error exactly, the same error?, because your solution was change the php version, that's not a solution, php 7 is much better and optimized than php 5
    – Rolige
    Nov 13 at 14:24










  • Same error, but the developer said " I haven't this issue with other sites so server settings might have something to do with it (maybe different character encodings cause PayPal to be more strict?). Without looking at the site and debugging i wouldn't be able to tell you what's going on with the other modules :/. As for this one this seemed to do the trick." Problem $amount = $ps_amount; // float Resolution: $amount = (string) $ps_amount; // string // The payload is then turned into json by php and send by cURL With his fix there was still issues though
    – Paul D
    Nov 22 at 9:07















up vote
0
down vote










up vote
0
down vote









The problem is the format of the content in the variables, you can solve it by replacing it with this:
$amountCheck += number_format((int)$item['quantity'] * (float)$item['price'], 2);






share|improve this answer












The problem is the format of the content in the variables, you can solve it by replacing it with this:
$amountCheck += number_format((int)$item['quantity'] * (float)$item['price'], 2);







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 14:51









Rolige

54058




54058












  • thank you I will give that a try and report results back
    – Paul D
    Nov 12 at 9:20










  • just attempted payment with changes and received the generic failed error.
    – Paul D
    Nov 13 at 8:38










  • Creating a .htaccess folder in the PayPal module worked for me This is what I used #In order to change the version to 5.5 - <FilesMatch ".(php4|php5|php7|php3|php2|php|phtml)$"> SetHandler application/x-lsphp55 </FilesMatch> Working now
    – Paul D
    Nov 13 at 12:02










  • @PaulD What kind of error exactly, the same error?, because your solution was change the php version, that's not a solution, php 7 is much better and optimized than php 5
    – Rolige
    Nov 13 at 14:24










  • Same error, but the developer said " I haven't this issue with other sites so server settings might have something to do with it (maybe different character encodings cause PayPal to be more strict?). Without looking at the site and debugging i wouldn't be able to tell you what's going on with the other modules :/. As for this one this seemed to do the trick." Problem $amount = $ps_amount; // float Resolution: $amount = (string) $ps_amount; // string // The payload is then turned into json by php and send by cURL With his fix there was still issues though
    – Paul D
    Nov 22 at 9:07




















  • thank you I will give that a try and report results back
    – Paul D
    Nov 12 at 9:20










  • just attempted payment with changes and received the generic failed error.
    – Paul D
    Nov 13 at 8:38










  • Creating a .htaccess folder in the PayPal module worked for me This is what I used #In order to change the version to 5.5 - <FilesMatch ".(php4|php5|php7|php3|php2|php|phtml)$"> SetHandler application/x-lsphp55 </FilesMatch> Working now
    – Paul D
    Nov 13 at 12:02










  • @PaulD What kind of error exactly, the same error?, because your solution was change the php version, that's not a solution, php 7 is much better and optimized than php 5
    – Rolige
    Nov 13 at 14:24










  • Same error, but the developer said " I haven't this issue with other sites so server settings might have something to do with it (maybe different character encodings cause PayPal to be more strict?). Without looking at the site and debugging i wouldn't be able to tell you what's going on with the other modules :/. As for this one this seemed to do the trick." Problem $amount = $ps_amount; // float Resolution: $amount = (string) $ps_amount; // string // The payload is then turned into json by php and send by cURL With his fix there was still issues though
    – Paul D
    Nov 22 at 9:07


















thank you I will give that a try and report results back
– Paul D
Nov 12 at 9:20




thank you I will give that a try and report results back
– Paul D
Nov 12 at 9:20












just attempted payment with changes and received the generic failed error.
– Paul D
Nov 13 at 8:38




just attempted payment with changes and received the generic failed error.
– Paul D
Nov 13 at 8:38












Creating a .htaccess folder in the PayPal module worked for me This is what I used #In order to change the version to 5.5 - <FilesMatch ".(php4|php5|php7|php3|php2|php|phtml)$"> SetHandler application/x-lsphp55 </FilesMatch> Working now
– Paul D
Nov 13 at 12:02




Creating a .htaccess folder in the PayPal module worked for me This is what I used #In order to change the version to 5.5 - <FilesMatch ".(php4|php5|php7|php3|php2|php|phtml)$"> SetHandler application/x-lsphp55 </FilesMatch> Working now
– Paul D
Nov 13 at 12:02












@PaulD What kind of error exactly, the same error?, because your solution was change the php version, that's not a solution, php 7 is much better and optimized than php 5
– Rolige
Nov 13 at 14:24




@PaulD What kind of error exactly, the same error?, because your solution was change the php version, that's not a solution, php 7 is much better and optimized than php 5
– Rolige
Nov 13 at 14:24












Same error, but the developer said " I haven't this issue with other sites so server settings might have something to do with it (maybe different character encodings cause PayPal to be more strict?). Without looking at the site and debugging i wouldn't be able to tell you what's going on with the other modules :/. As for this one this seemed to do the trick." Problem $amount = $ps_amount; // float Resolution: $amount = (string) $ps_amount; // string // The payload is then turned into json by php and send by cURL With his fix there was still issues though
– Paul D
Nov 22 at 9:07






Same error, but the developer said " I haven't this issue with other sites so server settings might have something to do with it (maybe different character encodings cause PayPal to be more strict?). Without looking at the site and debugging i wouldn't be able to tell you what's going on with the other modules :/. As for this one this seemed to do the trick." Problem $amount = $ps_amount; // float Resolution: $amount = (string) $ps_amount; // string // The payload is then turned into json by php and send by cURL With his fix there was still issues though
– Paul D
Nov 22 at 9:07














up vote
0
down vote













Paypal wants the exact price.



For example:



If your cart is 25 euro for 2 products plus 5 euro of shipping, you must to passing the shipping too.



in this case you must to pass the Voucher Taxes.



Paypal say: you want 2339.30 AUD but your cart is 2 AUD less.






share|improve this answer





















  • Have tried buying another Paypal module but having issues with that one too. Might be PHP7.1 or could be something else. More likely PHP 7.1 as everything works fine in PHP5.6
    – Paul D
    Nov 18 at 22:15










  • It's just strange that PayPal would have a hissy fit on PHP7 but not PHP5.5
    – Paul D
    Nov 22 at 9:55















up vote
0
down vote













Paypal wants the exact price.



For example:



If your cart is 25 euro for 2 products plus 5 euro of shipping, you must to passing the shipping too.



in this case you must to pass the Voucher Taxes.



Paypal say: you want 2339.30 AUD but your cart is 2 AUD less.






share|improve this answer





















  • Have tried buying another Paypal module but having issues with that one too. Might be PHP7.1 or could be something else. More likely PHP 7.1 as everything works fine in PHP5.6
    – Paul D
    Nov 18 at 22:15










  • It's just strange that PayPal would have a hissy fit on PHP7 but not PHP5.5
    – Paul D
    Nov 22 at 9:55













up vote
0
down vote










up vote
0
down vote









Paypal wants the exact price.



For example:



If your cart is 25 euro for 2 products plus 5 euro of shipping, you must to passing the shipping too.



in this case you must to pass the Voucher Taxes.



Paypal say: you want 2339.30 AUD but your cart is 2 AUD less.






share|improve this answer












Paypal wants the exact price.



For example:



If your cart is 25 euro for 2 products plus 5 euro of shipping, you must to passing the shipping too.



in this case you must to pass the Voucher Taxes.



Paypal say: you want 2339.30 AUD but your cart is 2 AUD less.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 17 at 15:29









Gabriele Carbonai

187113




187113












  • Have tried buying another Paypal module but having issues with that one too. Might be PHP7.1 or could be something else. More likely PHP 7.1 as everything works fine in PHP5.6
    – Paul D
    Nov 18 at 22:15










  • It's just strange that PayPal would have a hissy fit on PHP7 but not PHP5.5
    – Paul D
    Nov 22 at 9:55


















  • Have tried buying another Paypal module but having issues with that one too. Might be PHP7.1 or could be something else. More likely PHP 7.1 as everything works fine in PHP5.6
    – Paul D
    Nov 18 at 22:15










  • It's just strange that PayPal would have a hissy fit on PHP7 but not PHP5.5
    – Paul D
    Nov 22 at 9:55
















Have tried buying another Paypal module but having issues with that one too. Might be PHP7.1 or could be something else. More likely PHP 7.1 as everything works fine in PHP5.6
– Paul D
Nov 18 at 22:15




Have tried buying another Paypal module but having issues with that one too. Might be PHP7.1 or could be something else. More likely PHP 7.1 as everything works fine in PHP5.6
– Paul D
Nov 18 at 22:15












It's just strange that PayPal would have a hissy fit on PHP7 but not PHP5.5
– Paul D
Nov 22 at 9:55




It's just strange that PayPal would have a hissy fit on PHP7 but not PHP5.5
– Paul D
Nov 22 at 9:55


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248227%2fa-non-well-formed-numeric-value-encountered-in-paypal%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values