Forums / Bug Reports / Japanese Yen and Paypal - JPY error 10401

Japanese Yen and Paypal - JPY error 10401

Locked

Views: 8,063

Results 1 to 15 of 15
This thread is locked. New replies are disabled.
2 Dec 2009, 4:52 PM
#1
crystalkoi avatar

crystalkoi

Zen Follower

Join Date:
Apr 2007
Posts:
181
Plugin Contributions:
0

Japanese Yen and Paypal - JPY error 10401

Hi,

In setting up Zen-cart to be able to handle payment from Japanese yen, which is a good option right now because the USD is so weak, I came up with an error.

I have not dug into this so deep yet, but Yen is being handled wrong.

For example, lets say that 1USD = 100 yen. This would be a perfect world, and everything would work right.

Yen does not use decimals, never, only in rates can you use a decimal for yen, and then it is taken to the nearest 1 yen. 1yen is not expressed as .01, it is 1. It never goes below 1. This is the problem

So now lets say the rate is 1usd = 85.4094093 yen Now we are going to have problems paying with paypal if you don't have Yen as your default currency. The reason being, yen is going to be passed to paypal like this: 2399.94 yen, Paypal sees this, and goes...wait, yen can't be .94 send error 10401.

Dr. Byte if you have a code update you would like to do, please advise or I will come up with one soon as I have a client waiting for this.

Regards,

Shaun

2 Dec 2009, 9:19 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: Japanese Yen and Paypal - JPY error 10401

What do you have for number of decimal places set for yen in your currency settings?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Dec 2009, 7:49 AM
#4
drbyte avatar

drbyte

Sensei

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

Re: Japanese Yen and Paypal - JPY error 10401

Which PayPal module(s) are you seeing this with?

Can you provide me with the PayPal_CURL_xxxxxxxx.log log files from some failing EC transactions?
ie: http://www.zen-cart.com/forum/showthread.php?t=61199
And also some details of the prices/totals in the cart for those same transactions ... and your JPY vs Default currency exchange rate at the time.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Dec 2009, 4:37 AM
#5
crystalkoi avatar

crystalkoi

Zen Follower

Join Date:
Apr 2007
Posts:
181
Plugin Contributions:
0

Re: Japanese Yen and Paypal - JPY error 10401

Hi,

PayPal Website Payments Pro and PayPal Express Checkout.

For the Default currency I have USD, Japanese yen I have set to this.

Title: Japanese Yen

Code: JPY

Symbol Left: ¥

Symbol Right: null

Decimal Point: null

Thousands Point: ,

Decimal Places: 0

Value: 91.00000000

If the value has anything set to say, 91.2000000, then its going to error.

I will pm you the log location.

Regards,

Shaun

4 Dec 2009, 4:38 AM
#6
drbyte avatar

drbyte

Sensei

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

Re: Japanese Yen and Paypal - JPY error 10401

CrystalKoi:

Decimal Places: 0

Value: 91.00000000

If the value has anything set to say, 91.2000000, then its going to error.
So ... is that the key?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Dec 2009, 4:43 AM
#7
crystalkoi avatar

crystalkoi

Zen Follower

Join Date:
Apr 2007
Posts:
181
Plugin Contributions:
0

Re: Japanese Yen and Paypal - JPY error 10401

Well, yes and no. I mean if people want to run a cron to keep their rates up to date, then it is going to error until they go in and fix it.

You see what I mean? The rate for Japanese yen for the order total needs to me above .00 , if that makes sense.

You still need that log?

4 Dec 2009, 5:25 AM
#8
drbyte avatar

drbyte

Sensei

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

Re: Japanese Yen and Paypal - JPY error 10401

I think I see what you mean.

More specifically, my question is: If one uses whole numbers (no decimals) for the JPY exchange rate, does that solve ALL these problems?
(Yes, I know the currency updater tool might change that, but that's a separate matter. If the decimals are removed again, is all okay again?)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Dec 2009, 7:15 AM
#10
crystalkoi avatar

crystalkoi

Zen Follower

Join Date:
Apr 2007
Posts:
181
Plugin Contributions:
0

Re: Japanese Yen and Paypal - JPY error 10401

Actually no, sorry, I should have played with my numbers first. If we set the dollar and the yen to a one to one ratio. 1$ = 100 yen, then this will work no problem.

But if I set the yen to a rate of $1 = 92 yen, and my product is $23.47, when converted to yen it will become 2,159.24 yen. Now here you can see that the .24 is going to make the error. What I would like to see is that the rate is rounded up or down, say if it is .49999 it will be rounded down and .500 and up will be rounded up to the nearest whole number.

4 Dec 2009, 7:31 AM
#11
drbyte avatar

drbyte

Sensei

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

Re: Japanese Yen and Paypal - JPY error 10401

And just to confirm ... you're only testing this with PayPal, right? Which modules?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Dec 2009, 7:35 AM
#12
crystalkoi avatar

crystalkoi

Zen Follower

Join Date:
Apr 2007
Posts:
181
Plugin Contributions:
0

Re: Japanese Yen and Paypal - JPY error 10401

Yes Just PayPal, express checkout and normal paypal checkout. Next I will go to websites payment pro. I am also sure this applies to any other currency that works like this.

-PayPal Website Payments Pro
-PayPal Express Checkout

11 Dec 2009, 4:21 AM
#13
crystalkoi avatar

crystalkoi

Zen Follower

Join Date:
Apr 2007
Posts:
181
Plugin Contributions:
0

Re: Japanese Yen and Paypal - JPY error 10401

Hi DrByte, (I always feel you should be an evil character in MegaMan or something with that name...:-) )

Know you are busy, but did you come up with any solution for this problem or should we just come up with a fix?

Let me know, no push on you, just thought your fix might be better than mine since you know ZC a bit better than me.

Thanks,
Shaun

11 Dec 2009, 4:28 AM
#14
drbyte avatar

drbyte

Sensei

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

Re: Japanese Yen and Paypal - JPY error 10401

To properly allow the PayPal module to handle JPY without submitting a decimal point and fractions, I recommend this replacement for the calc_order_amount() function in /includes/modules/payment/paypalwpp.php:```
/**

  • Calculate the amount based on acceptable currencies
    */
    function calc_order_amount($amount, $paypalCurrency, $applyFormatting = false) {
    global $currencies;
    $amount = ($amount) * $currencies->get_value($paypalCurrency);
    [B] if ($paypalCurrency == 'JPY') {
    $amount = (int)$amount;
    $applyFormatting = FALSE;
    }
    [/B] return ($applyFormatting ? number_format($amount, $currencies->get_decimal_places($paypalCurrency)) : $amount);
    }

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.