Author Topic: [PAYMENT METHOD] PAYPAL - Currency Converter by Deneb  (Read 75461 times)

deneb

  • Moderator
  • Full Member
  • *
  • Posts: 654
[PAYMENT METHOD] PAYPAL - Currency Converter by Deneb
« on: May 03, 2006, 05:18:33 am »
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

  • Beginner
  • *
  • Posts: 6
Re: [PAYMENT METHOD] PAYPAL - Currency Converter by Deneb
« Reply #1 on: May 17, 2006, 18:38:21 pm »
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

  • Beginner
  • *
  • Posts: 6
Re: [PAYMENT METHOD] PAYPAL - Currency Converter by Deneb
« Reply #2 on: May 17, 2006, 19:31:49 pm »
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

  • Moderator
  • Full Member
  • *
  • Posts: 654
Re: [PAYMENT METHOD] PAYPAL - Currency Converter b
« Reply #3 on: May 17, 2006, 22:01:09 pm »
Quote
Fatal 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:
Code: [Select]
global $mosConfig_cachepath, $mosConfig_live_site, $mosConfig_absolute_path;
to:
Code: [Select]
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

  • Beginner
  • *
  • Posts: 6
Re: [PAYMENT METHOD] PAYPAL - Currency Converter by Deneb
« Reply #4 on: May 18, 2006, 17:46:05 pm »
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

  • Jr. Member
  • **
  • Posts: 58
    • Nye hjemmesider?
Re: [PAYMENT METHOD] PAYPAL - Currency Converter by Deneb
« Reply #5 on: June 09, 2006, 14:29:33 pm »
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

  • Beginner
  • *
  • Posts: 2
Re: [PAYMENT METHOD] PAYPAL - Currency Converter by Deneb
« Reply #6 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.


RaXa

  • Beginner
  • *
  • Posts: 5
Re: [PAYMENT METHOD] PAYPAL - Currency Converter b
« Reply #7 on: October 25, 2006, 05:09:56 am »
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

deneb

  • Moderator
  • Full Member
  • *
  • Posts: 654
Re: [PAYMENT METHOD] PAYPAL - Currency Converter by Deneb
« Reply #8 on: October 25, 2006, 08:11:57 am »
Turn on VirtueMart DEBUG and you will see why the currency convert failed.

most likely your daily.xml file is corrupt or missing (file with exchange rates)

see above reply #3 for additional tips

RaXa

  • Beginner
  • *
  • Posts: 5
Re: [PAYMENT METHOD] PAYPAL - Currency Converter b
« Reply #9 on: October 25, 2006, 08:16:18 am »
Turn on VirtueMart DEBUG and you will see why the currency convert failed.

most likely your daily.xml file is corrupt or missing (file with exchange rates)

see above reply #3 for additional tips
Ok, but how i make the daily.xml or where i can get it, Thanl you

RaXa

  • Beginner
  • *
  • Posts: 5
Re: [PAYMENT METHOD] PAYPAL - Currency Converter by Deneb
« Reply #10 on: November 14, 2006, 05:56:15 am »
Ok the link to download the list doesn´t work, the currency list don´t have mexican pesos, so I dont know how to make this to work, my head is about to explode.

shurka

  • Beginner
  • *
  • Posts: 2
Re: [PAYMENT METHOD] PAYPAL - Currency Converter by Deneb
« Reply #11 on: November 17, 2006, 18:55:16 pm »
Hi deneb, nice converter, I just noticed that conversion failing when you switching to Checkout Process 4, what is the issue? I turned on debug but cant find error log, where should it be?

shurka

  • Beginner
  • *
  • Posts: 2
Re: [PAYMENT METHOD] PAYPAL - Currency Converter by Deneb
« Reply #12 on: November 17, 2006, 21:17:38 pm »
One more, the error accures when I set option with zero cost on delivering (such a downloadable goods), so it might be issue of operation with "0". So, try invistigate the formula.

Esteban

  • Beginner
  • *
  • Posts: 4
Re: [PAYMENT METHOD] PAYPAL - Currency Converter b
« Reply #13 on: January 25, 2007, 22:08:18 pm »
this still apply for VirtueMart 1.0.9?

sungoddess

  • Beginner
  • *
  • Posts: 5
  • Big Mami
    • the goddess room
Re: [PAYMENT METHOD] PAYPAL - Currency Converter b
« Reply #14 on: August 17, 2007, 20:53:01 pm »
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!