Zen Cart Logo
Forums / Currencies & Sales Taxes, VAT, GST, etc. / Currency Help with Paypal IPN

Currency Help with Paypal IPN

Locked

Views: 3,410

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
20 Jun 2007, 4:51 PM
#1
eizual avatar

eizual

New Zenner

Join Date:
May 2007
Posts:
33
Plugin Contributions:
0

Currency Help with Paypal IPN

Hi, I'm having some difficulties kinda like the person with the Canadian dollars just a couple threads down.

But basically my problem is this, in my shopping cart my currencies are displayed in Swedish Krona, currency code is SEK I believe. So once someone has say 129 kr worth of items, they check out, and for some reason when they enter their credit card information, they are charged 138.9 kr instead.

So what happens is that for some reason my customers are paying different amount from what my shopping cart told them that they would pay. In my paypal account I would just receive them in USD. I'm guessing my website is sending shopping cart info in USD with the conversion rate I pre-set? To further describe my problem, here is the detailed description of error.

Customer sees 129 kr. In my currency settings, 1 kr = 0.15 USD. So cart displays 129 kr, zen cart recognizes as 129 * 0.15 = $19.35 USD. It seems like $19.35 is the data being transmitted to paypal, which THEY convert back into SEK using a current exchange rate such as 1 USD = 7.175 SEK so it comes out to be $19.35 x 7.175 = 138.8 SEK (And this is how much the customer ends up paying)

I called paypal and they gave me something about how I need to edit certain line in the html code to set "buttons" or change some currency code, I've read the integration guide and to be honest I'm clueless.

So what I really want to do is just have zencart ask paypal "hey 129 kr is what we charge, and whatever the exchange rate let the seller bear the cost"

How would I approach this? Help please! My customers are over paying!

20 Jun 2007, 4:58 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: Currency Help with Paypal IPN

In your Zen Cart paypal settings, choose "Selected Currency" instead of "Only ZZZ" (where ZZZ is any currency)

20 Jun 2007, 5:49 PM
#3
eizual avatar

eizual

New Zenner

Join Date:
May 2007
Posts:
33
Plugin Contributions:
0

Re: Currency Help with Paypal IPN

Thanks for the fast reply. It was already under selected currencies. Yet for some reason it didn't work. I double checked my currencies too, Swedish Krona is set as default and the currency code is SEK, which I check is also correct. But for some reason it still charges people in USD. But here is a bit of update:

I screwed around with the paypal.php file in the modules/payment folder. And I was looking at this:
if (!in_array(strtolower($_SESSION['languages_code']), array('en', 'us', 'it', 'fr', 'es', 'de'))) {
$lang_code = 'us';
}
if (MODULE_PAYMENT_PAYPAL_CURRENCY == 'Selected Currency') {
$my_currency = $_SESSION['currency'];
} else {
$my_currency = substr(MODULE_PAYMENT_PAYPAL_CURRENCY, 5);
}
if (!in_array($my_currency, array('CAD', 'EUR', 'GBP', 'JPY', 'USD', 'AUD'))) {
$my_currency = 'USD';

I took the liberty and changed it to this:

if (!in_array(strtolower($_SESSION['languages_code']), array('en', 'us', 'it', 'fr', 'es', 'de'))) {
$lang_code = 'us';
}
if (MODULE_PAYMENT_PAYPAL_CURRENCY == 'Selected Currency') {
$my_currency = $_SESSION['currency'];
} else {
$my_currency = substr(MODULE_PAYMENT_PAYPAL_CURRENCY, 5);
}
if (!in_array($my_currency, array('CAD', 'EUR', 'GBP', 'JPY', 'USD', 'AUD'))) {
$my_currency = 'SEK';

And now the payment works, they get charged the right amount cause I used a Swedish credit card to test it out, HOWEVER, I no longer get order confirmation email, and the admin panel does not even register the order and the product is not deducted...

So it's either, pay the wrong amount, but order gets registered, or pay the right amount, but inventory not deducted and order never came through.

I've already wasted $2 USD on paypal fees just testing this out... I'd rather donate money to the forums for helping me out than paying Paypal just so I can redo my futile attempts.

20 Jun 2007, 7:03 PM
#4
eizual avatar

eizual

New Zenner

Join Date:
May 2007
Posts:
33
Plugin Contributions:
0

Re: Currency Help with Paypal IPN

Ok another quick update with some information so maybe people can help me brainstorm together...

So I went into my currencies, deleted USD as a currency, and as I try checking out via Swedish Kronor, once it got to the paypal website, it now says $0.00 dollars (yay free items).

So for some reason I'm guessing the problem lies in the fact that my zen cart is stubborn and communicates only in USD with paypal. I triple checked the currency code and its SEK in my settings and SEK is the correct code. Paypal also do accept SEK as a currency, my experiment in my last post also proved that...

At this point I don't mind just accepting Swedish Kronor as my only currency if I can't get it to configure correctly in zen cart. I don't mind just hard coding it in the IPN module files (there are several) and make it just default Swedish kronor and yet keep my website functional with order confirmation e-mails and orders actually being registered.

Any help would be appreciated!

20 Jun 2007, 8:21 PM
#5
drbyte avatar

drbyte

Sensei

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

Re: Currency Help with Paypal IPN

You are using obsolete code.
Support for PayPal's 17 currencies, including SEK was added in v1.3.7.

20 Jun 2007, 9:20 PM
#6
eizual avatar

eizual

New Zenner

Join Date:
May 2007
Posts:
33
Plugin Contributions:
0

Re: Currency Help with Paypal IPN

I thought about that too, but checking my version info I found:
** Zen Cart 1.3.7**

 ** Database Patch Level:  1.3.7**

v1.3.7 [2007-05-17 23:20:59] (Fresh Installation)

So my zen cart is up to date, but maybe the module isn't?

This line just doesn't make any sense in the paypal.php
if (!in_array($my_currency, array('CAD', 'EUR', 'GBP', 'JPY', 'USD', 'AUD'))) {
$my_currency = 'USD';

it's saying if $my_currency = SEK, and if it's not in that array above and it defaults back to USD? I'm not much of a web programmer but that's what it looks like to me, I could be wrong?

But I've did that thing in my previous post, forcing it to become $my_currency = 'SEK';

I did a transaction in debug mode, and my order did not show up in admin panel and there was no confirmation e-mail. The debug mode got to step 13 which said:

IPN WARNING::Currency/Amount Mismatch. Details:
PayPal email address = [email protected]
| mc_currency = SEK
| submitted_currency = USD
| order_currency = SEK
| mc_gross = 88.00
| converted_amount = 13.20
| order_amount = 88

I think thats when the whole thing just stops hence I don't get any e-mail. So I went into paypal_functions.php to see where the code ended...

if (MODULE_PAYMENT_PAYPAL_CURRENCY == 'Selected Currency') {
  $my_currency = $_SESSION['currency'];
} else {
  $my_currency = substr(MODULE_PAYMENT_PAYPAL_CURRENCY, 5);
}
$ec_currencies = array('CAD', 'EUR', 'GBP', 'JPY', 'USD', 'AUD', 'CHF', 'CZK', 'DKK', 'HKD', 'HUF', 'NOK', 'NZD', 'PLN', 'SEK', 'SGD', 'THB');
$basic_currencies = array('CAD', 'EUR', 'GBP', 'JPY', 'USD', 'AUD');
$currency_list = ($_POST['txn_type'] == 'express-checkout') ? $ec_currencies : $basic_currencies;
if (!in_array($my_currency, $currency_list)) {
  $my_currency = 'USD';
}
$transaction_amount = number_format(($amount) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
if ( ($_POST['mc_currency'] != $my_currency) || ($_POST['mc_gross'] != $transaction_amount && $_POST['mc_gross'] != -0.01) && MODULE_PAYMENT_PAYPAL_TESTING != 'Test' ) {
  ipn_debug_email('IPN WARNING::Currency/Amount Mismatch.  Details: ' . "\n" . 'PayPal email address = ' . $_POST['business'] . "\n" . ' | mc_currency = ' . $_POST['mc_currency'] . "\n" . ' | submitted_currency = ' . $my_currency . "\n" . ' | order_currency = ' . $currency . "\n" . ' | mc_gross = ' . $_POST['mc_gross'] . "\n" . ' | converted_amount = ' . $transaction_amount . "\n" . ' | order_amount = ' . $amount );
  return false;
}
return true;

}

The part in blue is basically the error I'm getting from debug mode.

And I still think the culprit is in red

After all $my_currency = USD according to the debug e-mail. I think I can fix this problem some where in here.. but I don't know how, and I'm not sure why the correct configuration in admin panel doesn't work automatically to begin with...

20 Jun 2007, 10:30 PM
#7
eizual avatar

eizual

New Zenner

Join Date:
May 2007
Posts:
33
Plugin Contributions:
0

Re: Currency Help with Paypal IPN

Ok last update, I post in my own thread way too much =)

So I just made 1 line changes each in the paypal.php and paypal_function.php

I just made it so that If blah blah blah, then else $my_currency = "sek" as highlighted red in above.

It worked! I guess I forced it to use SEK as default, which it very well should be since that's what I set it as under admin panel! Thanks for all your help. I just hope this doesn't cripple the English side of my website.