PayPal 5.3.2 Invalid request - see details



  • I am not able to let Paypal module work. I get the following error:

    Currency amount must be non-negative number, may optionally contain exactly 2 decimal places separated by ‘.’, optional thousands separator ‘,’, limited to 7 digits before the decimal point and currency which is a valid ISO Currency Code

    The call is:

    stdClass Object
    (
        [transactions] => Array
            (
                [0] => stdClass Object
                    (
                        [amount] => stdClass Object
                            (
                                [total] => 174.79
                                [currency] => EUR
                                [details] => Array
                                    (
                                        [shipping] => 7.00
                                        [tax] => 29.98
                                        [subtotal] => 136.27
                                        [handling_fee] => 1.54
                                    )
    
                            )
    
                        [description] => Payment description
                        [item_list] => Array
                            (
                                [items] => Array
                                    (
                                        [0] => stdClass Object
                                            (
                                                [name] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                                                [currency] => EUR
                                                [quantity] => 1
                                                [price] => 136.27
                                                [tax] => 29.98
                                            )
    
                                    )
    
                                [shipping_address] => Array
                                    (
                                        [recipient_name] => xxxxxx xxxxxx
                                        [line1] => xxxxxxxxxx
                                        [line2] => xxxxxxxxxx
                                        [city] => xxxxxxxxxx
                                        [country_code] => IT
                                        [postal_code] => XXXXX
                                        [state] => XX
                                    )
    
                            )
    
                    )
    
            )
    
        [payer] => stdClass Object
            (
                [payment_method] => paypal
            )
    
        [intent] => sale
        [experience_profile_id] => XP-XSTK-xxxx-7UX3-xxxx
        [redirect_urls] => stdClass Object
            (
                [cancel_url] => https://xxx.xxx.com/it/module/paypal/expresscheckoutcancel?id_cart=34
                [return_url] => https://xxx.xxx.com/it/module/paypal/expresscheckout?id_cart=34
            )
    
    )
    

    Can someone help me on fix it? Thansk, Daniele



  • Do you have the original request as well?



  • I just fixed it: on function createPaymentObject I replaced round() with number_format() and it solved the problem.



  • To fix the same problem is needed also the following fix: on modules/paypal/classes/PayPalRestApi.php

    $details[‘shipping_discount’] = abs(round($remaining - $giftWithoutTax, 2));

    need to be changed as follow:

    $details[‘shipping_discount’] = number_format(abs($remaining - $giftWithoutTax), 2);



  • Even though this is for 6.0.0: https://github.com/thirtybees/paypal/commit/daf8c771b1bca118ae2c41b205a897fc80c57754
    it contains all the spots where I had to replace it.


 

Looks like your connection to thirty bees forum was lost, please wait while we try to reconnect.