News:

Looking for documentation? Take a look on our wiki

Main Menu

Paypal probem due to incorrectly formatted item amount

Started by gajdoseni, January 30, 2014, 17:13:03 PM

Previous topic - Next topic

gajdoseni

Hello,
With VM 2.0.26d I have this error message after placing an order: "The link you have used to enter the PayPal system contains an incorrectly formatted item amount."
I guess it is becuse the payment amount is not rounded. If all the prices are round, it works. I would like the 3,4% PayPal fee get paid, and this causes a not round number, so I get the error message.
I have found on forums some solutios for this round number problem, for older versions, but I can not find those codes in papypal.php file what I should change.
Could someone help with this?

alatak

Hello
Can you please turn on the debug option in the paypal configuration and copy paste the message displayed before being redirected to Paypal.

gajdoseni

Thanks for our help!

Here is the text:

PayPal request::
Array
(
        [cmd]   ⇒   _ext-enter
        [redirect_cmd]   ⇒   _xclick
        [paymentaction]   ⇒   sale
        [upload]   ⇒   1
        [business]   ⇒   info@okoanyu.hu
        [receiver_email]   ⇒   info@okoanyu.hu
        [order_number]   ⇒   754e0102
        [invoice]   ⇒   754e0102
        [custom]   ⇒   ede2c9e3c937a5c5efdab9c142446cf5
        [currency_code]   ⇒   HUF
        [address_override]   ⇒   1
        [first_name]   ⇒   Gajdos   Enikő
        [last_name]   ⇒ 
        [address1]   ⇒   Zrínyi   u.   26.
        [address2]   ⇒ 
        [zip]   ⇒   7761
        [city]   ⇒   Kozármisleny
        [state]   ⇒ 
        [country]   ⇒   HU
        [email]   ⇒   eni.gajdos@gmail.com
        [night_phone_b]   ⇒ 
        [return]   ⇒   http://okoanyu.hu/index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=754e0102&pm=3&Itemid=163&lang=
        [notify_url]   ⇒   http://okoanyu.hu/index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component&lang=
        [cancel_return]   ⇒   http://okoanyu.hu/index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on=754e0102&pm=3&Itemid=163&lang=
        [rm]   ⇒   2
        [bn]   ⇒   VirtueMart_Cart_PPA
        [no_shipping]   ⇒   0
        [no_note]   ⇒   1
        [image_url]   ⇒   http://okoanyu.hu/images/stories/virtuemart/vendor/logo_okoanyu_uj200.png
        [item_name]   ⇒   Megrendelés   száma:   754e0102
        [amount]   ⇒   9296.07
)

sandomatyas

This is an old story, it is because you want to pay in HUF and the amount is 9296.07, but PayPal won't accept decimals with HUF.
The best way to solve this problem if the plugin would use the rounding settings of the component. Or just put a parameter to the paypal settings: round the amount Y/N
The fast and ugly way:
plugins/vmpayment/paypal/paypal/helpers/paypalstd.php
Around line 195 you can find this:

foreach ($post_variables as $name => $value) {
  $html .= '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value) . '" />';
}

change it to this one:

$post_variables['amount'] = round($post_variables['amount']);
foreach ($post_variables as $name => $value) {
  $html .= '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value) . '" />';
}

It will round your amout before the redirect to paypal.

alatak

Hello
May be the best is to change the currency
go to
yourwebsite.com/administrator/index.php?option=com_virtuemart&view=currency&task=edit&cid[]=64
and change the decimal parameter.

Is there decimal for Hungarian forint ? we can change the default values if it wrong.

gajdoseni

Hello,
I have the same problem with virtuemart 3. Do you have solution for this version also?
Can't find the same code in the new paypal.php file.
I have vm 3.0.9 installed.

thanks,
Eniko