Paypal express checkout -ordertotal invalid error

I use express check-in for a shopping cart site. My final amount is divided into a site admin fee and a seller fee based on the percentage of the site admin fee. In my expresscheckout.php file, if I select the percentage of the site administrator as 10, then 10% of the total is provided to the site administrator and remains the seller

$ siteowner_amount = (($ paymentAmount) * $ admin_percentage) / 100;

$ seller_amount = $ paymentAmount- $ siteowner_amount;

$ str = "& PAYMENTREQUEST_0_AMT =". $ seller_amount;

$ str = $ str. "& Amp; PAYMENTREQUEST_1_AMT =" $ siteowner_amount.

and also transfer the total amount to my paypalfunction.php file. I get the correct total amount in my paypalfunction.php (the amount of the site admin fee and the seller fee). and also succeed in paypal sandbox. But my problem is that when I ever use a site admin percentage of less than 10, and even if the total amount is correct, I get an error

"10401 order total inavlid The transaction was rejected due to an invalid argument. See the additional error messages for details."

But his work is great for admin% 10 and above. only release with less than 10. I checked the amount that I get in paypalfunction.php, this is correct.

Please, help. thank you in advance

+4
source share
1 answer

You do math with floating point money. This is a bad idea, because you are not allowed to send transactions with fractional cents at all. Beware of rounding that you do not control ...

To debug, take a look at $seller_amount and $siteowner_amount . You probably have a single decimal number that should be carefully rounded.

+4
source

All Articles