Post by freedomizer » Tue Jul 29, 2008 5:50 pm

I just installed OpenCart and paypal module. paying in Euro is ok, however I set another currency as well (local and defauly) which is RON. When I try to buy something in RON, paypal gets it as EURO.

For ex:
1 sugarcandy = 10 Euros
1 sugarcandy = 38 Ron (Romanian Lei)
.

If I buy 1 sugarcandy in Euro I pay 10 euros --ok
If I buy 1 sugarcandy in Ron I pay 38 euros --ok. Paypal gets the amount correctly but thinks it is in Euro. It would be ok to process it in Euros, but with the correct amount.

any suggestions?

p.s. RON is the valid currency ID.

Newbie

Posts

Joined
Tue Jul 29, 2008 5:47 pm

Post by bruce » Tue Jul 29, 2008 6:06 pm

All transactions are made in the store currency which is set in you store settings in admin. The prices you enter for products and options are expected to be the value in the store currency.

The currency selector on the catalog is a converter and only provides an indication of how much an item may cost in another currency. It is only an indication because the conversions are maintained in admin as well, are probably wrong and are not updated in real time.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by freedomizer » Tue Jul 29, 2008 6:42 pm

bruce wrote: All transactions are made in the store currency which is set in you store settings in admin. The prices you enter for products and options are expected to be the value in the store currency.

The currency selector on the catalog is a converter and only provides an indication of how much an item may cost in another currency. It is only an indication because the conversions are maintained in admin as well, are probably wrong and are not updated in real time.
OK. the prices displayed are all correct. If I look at an item in Euro it shows 10 Euro and if I look at it in RON shows 38 RON correctly. THe problem is during checkout. If I buy it in RON, on the paypal payments page appears 38 EURO not 38 RON. If it would say 10 Euro it would be OK.

Newbie

Posts

Joined
Tue Jul 29, 2008 5:47 pm

Post by bruce » Tue Jul 29, 2008 6:55 pm

You need to modify admin\controller\payment_paypal.php to add another currency to the list at around line 115

Code: Select all

		$currency_data[] = array(
			'text'     => $language->get('text_ron'),
			'value'    => 'RON',
			'selected' => in_array('RON', $payment_info)
		);

you also need to add an entry in the language file admin\controller\payment_paypal.php for text_ron similar to say text_eur

after that, you can select RON in the list of currencies displayed in your paypal admin and all should be well

cheers

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by freedomizer » Fri Aug 01, 2008 4:37 am

I did the suggested modifications.

I tried testing with a live paypal account, which is set to accept payments in any denomination. However paypal does not accept RON directly, it does not appear on any of Paypal's lists of accepted currencies.

After doing the modifications, indeed the new RON appears, and I selected both RON & Euro + clicked save in paypal control panel.

I tried to check out with paypal payment and now it gives this message:
This recipient does not accept payments denominated in USD. Please contact the seller and ask him to update his payment receiving preferences to accept this currency.
The fact that now paypal gives a different message indicates that indeed there is a change in the currency type the script sends to paypal. However I think the problem is that paypal doesn't recognize the currency (RON) and so it gives this message that USD is not accepted.

I think it is better to just convert the amounts to EURO when sending the checkout to paypal to process.

I found a function fields() in paypal.php which seems to fill out the fields transmitted to paypal.

For my purpose I could modify the script to just convert the amount to EUro and submit euro as currency type, but I would like to use the rate that is defined in the admin panel. I only have 2 currencies. How could I access the currency exchange rate most easily?
bruce wrote: You need to modify admin\controller\payment_paypal.php to add another currency to the list at around line 115

Code: Select all

		$currency_data[] = array(
			'text'     => $language->get('text_ron'),
			'value'    => 'RON',
			'selected' => in_array('RON', $payment_info)
		);

you also need to add an entry in the language file admin\controller\payment_paypal.php for text_ron similar to say text_eur

after that, you can select RON in the list of currencies displayed in your paypal admin and all should be well

cheers

Newbie

Posts

Joined
Tue Jul 29, 2008 5:47 pm

Post by bruce » Fri Aug 01, 2008 8:32 am

Provided that the currency code that you want to use is defined in your admin list of currencies, you can call the following function in library\cart\currency.php.

Code: Select all

  	function getValue($currency) {
    	return (isset($this->currencies[$currency]) ? $this->currencies[$currency]['value'] : NULL);
  	}
where the parameter $currency is actually the currency code.

You might also like to install david's currency converter. It needs to be run from cron every once in a while to keep your currency conversions up to date. Otherwise, you will have to do it manually.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by freedomizer » Mon Aug 11, 2008 9:06 pm

I resolved the issue with a brute method. If someone has the same problem can use this, just replace RON with your unaccepted currency, and the code will convert your total from RON to EUR and transmit to paypal the amount in EURO. This supposes that your default store currency is EURO with a currency rate of 1.0. If your store default currency is Pounds, then you need to replace "EUR" to "GBP".

I replaced the following code in paypal.php:
ORIGINAL CODE:

Code: Select all

		$ouput .= '<input type="hidden" name="currency_code" value="' . $currency . '" />' . "\n";
		$ouput .= '<input type="hidden" name="amount" value="' . $this->currency->format($this->order->get('total'), $currency, FALSE, FALSE) . '" />' . "\n";
NEW CODE:

Code: Select all

if ($currency == "RON") {
		$ouput .= '<input type="hidden" name="currency_code" value="' . "EUR" . '" />' . "\n";
		$ouput .= '<input type="hidden" name="amount" value="' . $this->currency->format($this->order->get('total'), $currency, FALSE, FALSE)/$this->currency->getValue("RON") . '" />' . "\n";
		}
		else
		{
		$ouput .= '<input type="hidden" name="currency_code" value="' . $currency . '" />' . "\n";
		$ouput .= '<input type="hidden" name="amount" value="' . $this->currency->format($this->order->get('total'), $currency, FALSE, FALSE) . '" />' . "\n";
		};

Newbie

Posts

Joined
Tue Jul 29, 2008 5:47 pm

Post by jitender » Sun Oct 19, 2008 4:03 am

im unable to configure can u please help me step by step and im from INDIA

I have custom currency INR indian rupee rs. symobol with value 48 i created a custom one with code INR

now when i checkout with paypal for Rs.480 its taking 480$ instead of 10$
please help me step by step with location of files

Newbie

Posts

Joined
Sun Oct 19, 2008 2:50 am

Post by bruce » Sun Oct 19, 2008 6:55 am

Please post a screen shot of your currency definition in admin showing all the fields that you entered data for.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by jitender » Sun Oct 19, 2008 7:00 am

there are settign i put for currency INR i need

Attachments

???
aa.jpg

Newbie

Posts

Joined
Sun Oct 19, 2008 2:50 am

Post by fido-x » Sun Oct 19, 2008 9:58 am

Hi jitender,

You should set the value of your own currency to 1 then set the value of the USD to 48, this is assuming that the 1USD is worth 48INR.

Regards, Fido-X.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by jitender » Sun Oct 19, 2008 12:51 pm

no dude

1 USD = Rs.48

i have problem with this even

when at final checkout i face a problem of currency  not converted to USD in paypal and instead if bill is 100rs in paypal it shows 100$ instead of billing 100/48$ (remember 1 USD = Rs.48)

Newbie

Posts

Joined
Sun Oct 19, 2008 2:50 am

Post by fido-x » Sun Oct 19, 2008 5:05 pm

Sorry, my mistake. What I mean is set the value of your currency to 1 and set the value of any other currency to the conversion factor, ie. whatever your currency is worth against the other. So if USD 1 = Rs 0.48 then Rs 1 = USD 0.48.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by bruce » Sun Oct 19, 2008 8:30 pm

What have you set as the "default" currency?

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by jitender » Sun Oct 19, 2008 11:49 pm

USD is default

Newbie

Posts

Joined
Sun Oct 19, 2008 2:50 am

Post by bruce » Mon Oct 20, 2008 9:02 am

So the prices you enter for product cost and shipping fees etc must be in USD.

I have managed to reproduce this problem even in version 0.7.7 so I think you have found a rather nasty bug.

I will investigate further and let you know.

Cheers

Bruce

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by jitender » Tue Oct 21, 2008 1:37 am

no u didnot get it

like i have 2 Payments accepted INR and USD

USd is working fine with paypal

but when it comes to INR,
for billing Rs.480 INR =  10$ in paypal its billing for 480$

so i want a convertion thing at paypal step where INR will be directly converted to USD in paypal step

Newbie

Posts

Joined
Sun Oct 19, 2008 2:50 am

Post by Qphoria » Tue Oct 21, 2008 1:51 am

What price do you see on the checkout confirmation screen, before you goto paypal? That should be the price that gets sent to paypal.

If your store default is USD and the currency conversion rate is 1.00000
And I buy a $100.00 product
and I choose INR with a conversion rate of .48

The total I should see at checkout would be: Rs.48

Do you see that on the checkout page? And then when you goto Paypal it converts to $480?
Do you have your new currency selected in the "currency" list when you modify the paypal configuration?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Tue Oct 21, 2008 11:43 am

Ok I see now. It is Rs. at the checkout page but then paypal drops the value and replaces it with USD.

At first, I thought the problem was the fallback code in the extension/payment/paypal.php file:

Code: Select all

if (in_array($this->currency->getCode(), $currency_data)) {
    $currency = $this->currency->getCode();
} else {
    $currency = $this->config->get('config_currency');
}
If the currency code is not in the list of available currencies, it defaults to the store's default currency.

I wasn't sure where the list of selectable currencies comes from when configuring payment modules? I would have thought it should match the available currencies you offer in your store. So when you add a new currency, it populates in that list.

But then I realized that maybe that list is of the only currency that Paypal does support.

So I researched it and found:
https://www.paypal.com/us/cgi-bin/websc ... wa-outside

And sure enough, INR is not supported. And lo and behold, at the bottom of that currency table on the paypal site, the words:
If the currency_code is omitted, the default currency will be U.S. Dollars.
So even if OpenCart didn't default to USD, paypal still would.

In the end, you need to use a different currency that Paypal supports.
Last edited by Qphoria on Tue Oct 21, 2008 11:47 am, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by bruce » Tue Oct 21, 2008 11:53 am

The currency list presented by the payment extension admin represents all of the currencies in which the provider (paypal in this case) will accept a payment. The user can select one or more from that list for use by their store.

Personally, I think the lookup/fallback in paypal.php is back to front. The payments should always be in the store currency unless the store currency is not supported by the payment gateway. Only then should the system resort to converting the currency amounts. I say this because the conversion is done using internal static data from the currency table which may be out of date and inaccurate. This then leads to need for the currency converter contribution and regular updating via that mechanism.

cheers

Bruce

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm
Who is online

Users browsing this forum: No registered users and 5 guests