News:

Support the VirtueMart project and become a member

Main Menu

[PAYMENT METHOD] PAYPAL - Currency Converter by Deneb

Started by deneb, May 03, 2006, 05:18:33 AM

Previous topic - Next topic

deneb

a client needed a way to convert the currency of cart amounts, to those supported by PayPal.
This needed to occur prior to sending the customer over to PayPal to make the payment.

THIS IS AN ENHANCED VERSION OF THE STOCK CODE RELEASED IN VirtueMart 1.0.4

DO YOU NEED THIS?
--------------------------------
If you use a shop currency that is not one of these:
U.S. Dollar (USD)
Australian Dollar (AUD)
Canadian Dollar (CAD)
British Pounds Sterling (GBP)
Japanese Yen (JPY)
Euro (EUR)

...AND you wish to accept PayPal payments.
...BUT you can install this anyway and just disable it from the config.
...OR Dev Team can merge this into the next release.
--------------------------------

This payment Method:
->Converts the cart Total Amount and Shipping charges to one of the supported currencies that PayPal allows.
  TIP: The allowed currencies are viewable in your PayPal account, under 'Profile' > Financial Information - 'Currency Balances' links.
  TIP: For more payment receiving options related to currency, See 'Profile' > Selling Preferences - 'Payment Receiving Preferences' (make sure you are not blocking payments that you do not want blocked!)

->Shows a warning to the customer that the currency will be different in PayPal.(configurable!)

->Updates the payment variables sent to PayPal (Post Variables) with the new values. (Or in the case of customer viewing the order from 'Account Maintenance'...it formats the PayPal button correctly.

->Adds DEBUG output, which shows troubleshooting hints, conversion details, and PayPal post variables. (visible when VM DEBUG is turned on.)

->Adds PayPal config option to:
  => Enable/Disable the converter
  => Set the supported PayPal currencies
  => Select the PayPal currency to use.
  => Enable/Disable a currency convert warning on Order View
  => Set the Pre text on the warning (HTML OK)
  => Set the Post text on the warning (HTML OK)

One thing to think about...
The current functionality of VM allows customers to checkout with PayPal payment selected, and not immediately fulfill payment.
Also, the currency converter is pulled from daily exchage rates and converts using those rates on the fly.
...The PayPal button on the order.
...Exchange Rates change.
So, an order where the PayPal payment is still 'pending' (whether marked as such or not) could be converted later at a
substantially different rate than when purchsed. This may / may not be advantagous / disadvantagous to the vendor / customer.
--------------------------------

Install Steps:

1. First, back-up some files:
  a. PayPal class files
    ->folder: /administrator/components/com_virtuemart/classes/payment/
    ->file: ps_paypal.php
    ->file: ps_paypal.cfg.php
  b. Language file
    ->folder: /administrator/components/com_virtuemart/languages/
    ->file: english.php
2. Figure out if you have any hacks currently applied to your PayPal files.
   You may or may not need to merge them into the code supplied with this hack.
3. Back-up your PayPal - 'Payment Extra Info'
  ->Login to Joomla admin and go to the VirtueMart admin.
  ->Select 'Store' > 'List Payment Methods' menu item,
  ->Find PayPal method on the list and click it's name to Edit.
  ->Go to 'Configuration' tab
  ->Copy all text in the 'Payment Extra Info' textbox at the bottom.
  ->Paste it into a text editor and save it somewhere local.
4. Figure out if you have any hacks currently applied to your PayPal 'Payment Extra Info' code.
   You may or may not need to merge them into the code supplied with this hack.
5. Edit your Language file and add the language nuggets from the file supplied in this attached archive (english_paypal_currency.txt)
6. Upload the class files (ps_paypal.php, ps_paypal.cfg.php) to folder: /administrator/components/com_virtuemart/classes/payment/
7. Configure your new PayPal method, and 'Payment Extra Info'
  ->Login to Joomla admin and go to the VirtueMart admin.
  ->Select 'Store' > 'List Payment Methods' menu item.
  ->Find PayPal on the list and click name to Edit.
  ->Go to 'Configuration' tab.
  ->Re-enter your old settings (look in your backed-up config file), and Choose the new settings you want for currency converter section.
  ->Copy all text from the file supplied in this attached archive (paypal_PEI_currency.txt)
    and Paste it into the 'Payment Extra Info' textbox at the bottom.
  ->Click the SAVE button.
8. Test it.


[attachment cleanup by admin]

alexlancaster

Hey, just made the changes, however, I'm getting an error message:

Warning: fopen(.../administrator/components/com_virtuemart/classes/payment/ps_paypal.cfg.php): failed to open stream: Permission denied in .../administrator/components/com_virtuemart/classes/payment/ps_paypal.php on line 266

Any ideas???

alexlancaster

Ok, that was a CHMOD issue, got it solved. Now I seem to have a more serious problem, my customers are getting:

Fatal error: Call to a member function on a non-object in .../administrator/components/com_virtuemart/classes/currency_convert.php on line 59

When they try to complete and order.

Heeelp!

deneb

QuoteFatal error: Call to a member function on a non-object in .../administrator/components/com_virtuemart/classes/currency_convert.php on line 59

SOLUTION: You need to ensure that your Joomla/Mambo folder /media is writable. (Or, if using Joomla caching...make that cache folder writable, defined by $mosConfig_cachepath)

This error is displayed due to a minor flaw in the code in currency_convert.php...I think it is choking on the vmLogger function (used for displaying errors) so you don't get the real error.
BUT...the real problem you have is explained in above Solution.

To fix the minor flaw: (make $vmLogger global in the function: convertECB)
Backup this file:
/administrator/components/com_virtuemart/classes/currency_convert.php
Then, open that file for edit.

Change line 21 from:
global $mosConfig_cachepath, $mosConfig_live_site, $mosConfig_absolute_path;

to:
global $mosConfig_cachepath, $mosConfig_live_site, $mosConfig_absolute_path, $vmLogger;

Now you will see the reason for the currency conversion failure:
Go thru Checkout and select PayPal payment. You should see an error about how your folder is not writable, so it could not store the daily currency exchange rate file to your server folder mentioned above.

let us know... 8)

alexlancaster

Hi! Thanks for the quick response...

I made the changes you suggested and I stopped getting the error message. I checked the /media folder and found the daily.xml file.
At checkout, users are once again being sent to PayPal. However, the currency isn't getting converted. Needless to say that the curreny converter is enabled ;)
My store currency is MXP (Mexican Peso) and I want users to pay in USD. I tried changing my store currency to USD and PayPal to EUR, viceversa, and still didn't get conversion.

bilba

Thank you very much for this add-on.. I works like a charm!!
There are 10 types of people in the world, those who understands binary and those who don't! | Malmstein.No | New link exchange network - http://www.receivelinks.com/?a=21

Boet van Tonder

Everything works it goes to paypal but the currency conversion does not take place giving me the following error on Paypal site:

"This recipient does not accept payments denominated in ZAR. Please contact the seller and ask him to update his payment receiving preferences to accept this currency."

Everything looks right in the setup and Enable currensy converter is set to "Yes"

Please help This is just what I need.


RaXa

Quote from: Boet van Tonder on July 24, 2006, 23:05:19 PM
Everything works it goes to paypal but the currency conversion does not take place giving me the following error on Paypal site:

"This recipient does not accept payments denominated in ZAR. Please contact the seller and ask him to update his payment receiving preferences to accept this currency."

Everything looks right in the setup and Enable currensy converter is set to "Yes"

Please help This is just what I need.



I have the same problem, I use Mexican pesos, everything is configured right but when checkout is complete, no warning about the currency convert or in fact the currency convert is not working, anyone who can help me ? thanks a lot

Esteban


sungoddess

I have installed these files, and made the changes and I am STILL getting:

Return to Merchant

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.

-----

I am at my wits end!


Francis Yap

I need someone give me a hint how to do, please ...

MoonWizard

Hello everybody!

I am making a virtuemart shop for Mexico... obviously PayPal doesn't still accept Mexican Peso and it is supposed that with this solution the currency will be converted to USD, isn't it?

Is this solution compatible with the latest release 1.0.15?

Best regards!

gaswaru

Hi,
I'm totally new to this and drowning in this too...  :-[

I am developing the a site that use Malaysian Ringgit as default currency and need to be process in SGD in Paypal.

I have try using the package mention at the start of the thread but still no luck....

hope some one can help me... many many thanks!!

gaswaru

any help please please....

Quote from: gaswaru on April 07, 2008, 19:32:12 PM
Hi,
I'm totally new to this and drowning in this too...  :-[
I am developing the a site that use Malaysian Ringgit as default currency and need to be process in SGD in Paypal.
I have try using the package mention at the start of the thread but still no luck....
hope some one can help me... many many thanks!!