Zen Cart Logo
Forums / Bug Reports / [Done 1.5.0] Hungarian Forint... not working

[Done 1.5.0] Hungarian Forint... not working

Locked

Views: 3,426

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
10 Mar 2011, 7:54 PM
#1
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

[Done 1.5.0] Hungarian Forint... not working

Every once in a while, I get 1, or 2 or 10 emails in a row (from my zencart shopping cart) saying the following:

ALERT: PayPal Express Checkout Error (10401)
10401 Transaction refused because of an invalid argument. See additional
error messages for details. - Order total is invalid.

It only happens when a customer chooses the Hungarian Forint as their currency and then uses the PayPal express checkout.

I phoned PayPal and they confirmed its all good on their end (id. I have the HUF currency activated), and for whatever reason, my shopping cart software is passing an invalid format.

At first I thought it was a simple matter that the HUF uses no decimal - it is an integer format currency. But then the Yen (JPY) shouldn't work either, and it works just fine. The only difference I could see between the JPY and the HUF is the thousands seperator (HUF uses . and JPY uses ,) but I tried changing that to "," or none and it didn't help.

Any thoughts?

10 Mar 2011, 7:57 PM
#2
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: [Done 1.5.0] Hungarian Forint... not working

I did notice another difference between HUF and JPY... HUF uses a right hand symbol, which I have as " Ft". OK, so that's it, right Wrong. The Czech Koruna (CZK) uses the same thing (" Kc") and it works fine.

15 Mar 2011, 6:08 AM
#3
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: [Done 1.5.0] Hungarian Forint... not working

Nothing at all? Fine... I'll move it to bugs.

15 Mar 2011, 6:09 AM
#4
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: [Done 1.5.0] Hungarian Forint... not working

I posted it elsewhere last week but it got no attention. I think its a bug. I've looked at it as much as I can and I see no rhyme nor reason why the Hungarian currency isn't working with PayPal but all other currencies are. PayPal insists its not on their end.

Any ideas? Original post: http://www.zen-cart.com/forum/showthread.php?t=176219

15 Mar 2011, 3:36 PM
#5
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,607
Plugin Contributions:
0

Re: [Done 1.5.0] Hungarian Forint... not working

Moderator's note - both threads merged here.

10 Apr 2011, 4:35 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done 1.5.0] Hungarian Forint... not working

It would help to see the PayPal debug logs recorded by your server for that transaction, assuming they're enabled. Namely the PayPal_CURL_xxxx.log files.

10 Apr 2011, 5:42 AM
#7
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: [Done 1.5.0] Hungarian Forint... not working

Thanks... I didn't know what logs to look at. A month later, I don't want to dig through logs to find it, so I did a test transaction now and here is the result:

2011-04-10 06:34:48
-------------------
(live transaction) --> https://api-3t.paypal.com/nvp
Request Headers: 
Array
(
    [0] => Content-Type: text/namevalue
    [1] => X-VPS-Timeout: 45
    [2] => X-VPS-VIT-Client-Type: PHP/cURL
    [3] => X-VPS-VIT-Integration-Product: PHP::Zen Cart(tm) - PayPal/NVP
    [4] => X-VPS-VIT-Integration-Version: 1.3.9f
)


Request Parameters: {SetExpressCheckout} 
Array
(
    [LOCALECODE] => CA
    [PAYMENTACTION] => Sale
    [ALLOWNOTE] => 1
    [LANDINGPAGE] => Billing
    [AMT] => 7,453.80
    [RETURNURL] => https://www.FAKEDOMAIN.com/shop/ipn_main_handler.php?type=ec
    [CANCELURL] => https://www.FAKEDOMAIN.com/shop/index.php?main_page=login&ec_cancel=1
    [PAGESTYLE] => Primary
    [METHOD] => SetExpressCheckout
    [CURRENCYCODE] => HUF
    [USER] => steven_api1.FAKEDOMAIN.com
    [PWD] => ****************
    [VERSION] => 60.0
    [SIGNATURE] => ****************************************************guWU
)


Response: 
Array
(
    [TIMESTAMP] => 2011-04-10T05:34:49Z
    [CORRELATIONID] => a11defd326e99
    [ACK] => Failure
    [VERSION] => 60.0
    [BUILD] => 1824201
    [L_ERRORCODE0] => 10401
    [L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details.
    [L_LONGMESSAGE0] => Order total is invalid.
    [L_SEVERITYCODE0] => Error
    [CURL_ERRORS] => 
)


SetExpressCheckout, Elapsed: 964ms -- Failure

And right away I think I see the problem. The amount is shown as having a decimal value, when that is not possible for this currency. However, the JPY does it correctly, as you can see with this test:

2011-04-10 06:39:33
-------------------
(live transaction) --> https://api-3t.paypal.com/nvp
Request Headers: 
Array
(
    [0] => Content-Type: text/namevalue
    [1] => X-VPS-Timeout: 45
    [2] => X-VPS-VIT-Client-Type: PHP/cURL
    [3] => X-VPS-VIT-Integration-Product: PHP::Zen Cart(tm) - PayPal/NVP
    [4] => X-VPS-VIT-Integration-Version: 1.3.9f
)


Request Parameters: {SetExpressCheckout} 
Array
(
    [LOCALECODE] => CA
    [PAYMENTACTION] => Sale
    [ALLOWNOTE] => 1
    [LANDINGPAGE] => Billing
    [AMT] => 3,474.00
    [RETURNURL] => https://www.FAKEDOMAIN.com/shop/ipn_main_handler.php?type=ec
    [CANCELURL] => https://www.FAKEDOMAIN.com/shop/index.php?main_page=login&ec_cancel=1
    [PAGESTYLE] => Primary
    [METHOD] => SetExpressCheckout
    [CURRENCYCODE] => JPY
    [USER] => steven_api1.FAKEDOMAIN.com
    [PWD] => ****************
    [VERSION] => 60.0
    [SIGNATURE] => ****************************************************guWU
)


Response: 
Array
(
    [TOKEN] => EC-3J265139L9568884C
    [TIMESTAMP] => 2011-04-10T05:39:34Z
    [CORRELATIONID] => e3dee601dec49
    [ACK] => Success
    [VERSION] => 60.0
    [BUILD] => 1824201
    [CURL_ERRORS] => 
)


SetExpressCheckout, Elapsed: 891ms -- Success

So is it just a minor bug in the system where JPY was correctly set to eliminate any non-zero decimal value and HUF wasn't?

  • Steven
10 Apr 2011, 5:51 AM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done 1.5.0] Hungarian Forint... not working

s_mack:

So is it just a minor bug in the system where JPY was correctly set to eliminate any non-zero decimal value and HUF wasn't?
Quite possibly. It's proven difficult to find a definitive list of non-zero-decimal currencies.
Indeed in v1.3.9h (I note yours is 1.3.9f) we added support to protect against problematic currency updates when "0 decimals" were listed, as well as specify JPY handling because we knew about the JPY issues.
You could apply similar logic in your PayPal module for HUF if you like.
We'll probably drop the currency-specific handling in 1.5.0 in favor of checking whether "0 decimals" has been specified instead.

10 Apr 2011, 1:57 PM
#9
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: [Done 1.5.0] Hungarian Forint... not working

DrByte:

You could apply similar logic in your PayPal module for HUF if you like.

Thank you, and any hints on where to look would be appreciated.

10 Apr 2011, 2:17 PM
#10
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: [Done 1.5.0] Hungarian Forint... not working

I am curious why a specified 0-decimal currency was ever sent to PayPal as a 2-decimal? Even the JPY, according to the logs anyway, is sent with two zeros appended. Shouldn't it simply be sent as an integer?

Anyway, here is one list of ISO 4217 that specifies all currencies and their formats. The trick with it is that some currencies have multiple formats with no hint as to which is the "proper" or "most current" (however you want to view it) format and some have mistakes. For example, the Mozambique Metical has a 2-decimal version and an integer version, both with the same name and both recognized under ISO 4217 (one as the MZM and one as the MZN). In this particular case, a secondary search turns up the specifics: Due to hyper-inflation, the MZM was replaced by the MZN at a rate of 1000:1 in 2006 and it is in a transitional period where both are valid until 2012. The mistake, in this case, is that it shows MZN as being a zero-decimal format, which is not true. MZN does have centavo coins, as shown in Wikipedia and confirmed on the Bank of Mozambique's website (I was curious)... so you're right, that it is difficult to find a truly definitive listing.... but then again, how many of us accept the Mozambique Metical?

Lol.. how many of us accept the HUF? I would say many times more... simply because it is a valid PayPal currency.

  • Steven
20 Apr 2011, 3:18 AM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done 1.5.0] Hungarian Forint... not working

s_mack:

Thank you, and any hints on where to look would be appreciated.
Probably like this ...

  /**
   * Calculate the amount based on acceptable currencies
   */
  function calc_order_amount($amount, $paypalCurrency, $applyFormatting = false) {
    global $currencies;
    $amount = ($amount * $currencies->get_value($paypalCurrency));
    if ($paypalCurrency == 'JPY' || (int)$currencies->get_decimal_places($paypalCurrency) == 0) {
      $amount = (int)$amount;
      $applyFormatting = FALSE;
    }
    return ($applyFormatting ? number_format($amount, $currencies->get_decimal_places($paypalCurrency)) : $amount);
  }
```and```
    // tidy up all values so that they comply with proper format (number_format(xxxx,2) for PayPal US use )
    if (!defined('PAYPALWPP_SKIP_LINE_ITEM_DETAIL_FORMATTING') || PAYPALWPP_SKIP_LINE_ITEM_DETAIL_FORMATTING != 'true' || in_array($order->info['currency'], array('JPY', 'NOK', 'HUF'))) {
      if (is_array($optionsST)) foreach ($optionsST as $key=>$value) {
        $optionsST[$key] = number_format($value, ((int)$currencies->get_decimal_places($paypalCurrency) == 0 ? 0 : 2));
      }
      if (is_array($optionsLI)) foreach ($optionsLI as $key=>$value) {
        if (substr($key, 0, 8) == 'L_TAXAMT' && ($optionsLI[$key] == '' || $optionsLI[$key] == 0)) {
          unset($optionsLI[$key]);
        } else {
          if (strstr($key, 'AMT')) $optionsLI[$key] = number_format($value, ((int)$currencies->get_decimal_places($paypalCurrency) == 0 ? 0 : 2));
        }
      }
    }