Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Japanese Yen Problem with PayPal IPN .96


ZeroAquaduct

Recommended Posts

I have USD as my default currency and JPY (Japanese Yen) as one of my other accepted currencies. This works perfectly if I select money order as my payment method, but it'll fail if I select PayPal (PayPal will return an error message). I know what the problem is -- the shopping cart is sending an amount with 2 decimals places to PayPal, although I have 0 decimal places configured under "currencies" in my admin. For example, it says ¥800 in my checkout, but when the checkout sends info to PayPal, it'll send ¥800.99, or whatever the cents turn out to be. This will not work with PayPal because JPY doesn't have cents.

 

I have the Nov. 20 snapshot installed along with the PayPal IPN .96 contribution.

 

Is there anyway I could keep USD as my default currency, but have the checkout send a 0 decimal place JPY amount to PayPal? I don't want to have my default currency in JPY, although this will solve the problem. TIA.

Link to comment
Share on other sites

For example, it says ¥800 in my checkout, but when the checkout sends info to PayPal, it'll send ¥800.99, or whatever the cents turn out to be.  This will not work with PayPal because JPY doesn't have cents.

 

Sorry, the Yen sign didn't show up. It should say:

 

For example, it says Y800 in my checkout, but when the checkout sends info to PayPal, it'll send Y800.99, or whatever the cents turn out to be. This will not work with PayPal because JPY doesn't have cents.

Link to comment
Share on other sites

I also send yen with 2 decimal places and have not noticed any problems. It could be because the payment always has .00 as decimals as the default currency is yen. However, if I send GBP or USD with 0 decimal places, PayPal just rounds it up so you would think it could manage this simple problem.

 

Anyway, if you have the post-nov version, you should be able to use this function to sort out the problem:

 

tep_draw_hidden_field('amount', number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency))) .

 

I am not using this as I have pre-nov but it looks like it should work. If it doesnt, it could be that you have not set the decimals for your currency correctly.

Ian-san

Flawlessnet

Link to comment
Share on other sites

Thanks for the reply Ian. I'm using the PayPay IPN contribution, so I don't use the stock PayPal payment module that came with osCommerce.

 

However, I used your code as a reference and looked at checkout_paypalipn.php; I realize that it has "2" in the code that processes the payment info (meaning "2 decimal places"). If I changed this to "0," the JPY will work, but now every currency will have 0 decimal places.

 

I added your "$currencies->get_decimal_places($my_currency)" code, but it returns an error, saying that the "get_decimal_places()" function is undefined. How can I add this definition into my file? The checkout_paypalipn.php is similar to checkout_process.php under the "// load the before_process function from the payment modules" area. TIA.

Link to comment
Share on other sites

It is part of the currencies.php class module in the new checkout. I dont know if it will work in older snapshots but you can try to add it in with the other functions shown at the end of this class module:

 

function get_value($code) {

return $this->currencies[$code]['value'];

}

 

function get_decimal_places($code) {

return $this->currencies[$code]['decimal_places'];

}

 

function display_price($products_price, $products_tax, $quantity = 1) {

return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);

}

}

?>

Ian-san

Flawlessnet

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...