VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Payment VM 1.1 => PayPal / PayPal Pro VM 1.1 => Topic started by: fafiou on January 06, 2009, 02:02:50 AM

Title: Multi-currency store : wrong currency on paypal interface
Post by: fafiou on January 06, 2009, 02:02:50 AM
Hi folks,

Joomla! 1.5.8
VM 1.1.2
Currencies accepted: CHF, EUR and USD
Default currency in the store: CHF


My problem is seen a lot of times into the forum and solved sometimes, but the solutions that I've seen don't work in my case.


Description of the bug:
If I confirm order after the checkout without changing currency, emails display prices into CHF currency (ex: 40 CHF) but Paypal displays the same amount in USD (40 USD).

If I use the currency converter before to confirm order, the PayPal currency is ok (CHF in my example).

I've changed the code into Extra file info of the Paypal payment method as mentionned into several topics.

"currency_code" => $_SESSION['vendor_currency'],
remplaced by
"currency_code" => $_SESSION['product_currency'],

But the problem is not solved.
And I'm not alone in this case as I've seen in a lot of topics.


It's a very serious bug and I need some help.
I can't believe that a such bug is not already fixed by a VM genius.


Then If you have some advices, I don't say no ;)

Thank you.
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: weeonesbyjajoc on January 07, 2009, 19:01:56 PM
I too am having this same issue, but from CAD to USD.

Anyone?  Some how I think there is just something quick and easy I'm missing but can't seem to find it anywhere.

HELP!


I have fixed this problem simply by changing the php code for the paypal module as per the previous posters mention of changing the currency from

"currency_code" => $_SESSION['vendor_currency']

to

"currency_code" => $_SESSION['product_currency']

This seems to be working fine now.
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: weeonesbyjajoc on January 09, 2009, 17:10:11 PM
Now the problem seems to be reversed.  A US Customer checks out in CAD and the paypal payment gets sent to me in USD.  Clearly the above didn't fix the problem only switched the problem.  Why isn't the currency being set by what the customer chooses?  Anyone?
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: ufo_hk on January 21, 2009, 22:48:50 PM
Joomla! 1.5.8 (and 1.5.9) on three sites all configured similarly.
VM 1.1.2
Currencies accepted: NZ, EUR, USD and AUD
Default currency in the store: NZ

Paypal script code also changed:
"currency_code" => $_SESSION['vendor_currency']
to
"currency_code" => $_SESSION['product_currency']

Order is always placed with paypal as USD until currency change is confirmed. Once currency has been changed all further orders from that browser session are correct in terms of currency submitted to paypal.

As per original post it would seem that this is a confirmed "bug", although looking through the bug tracker list I don't see anything listed associated with this issue.

It would be great to know if the issue is being dealt with and there is a fix other that making site default currency US. Is it a fix in 1.1.3 expected soon?

Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: scotsit on January 27, 2009, 15:21:42 PM
I am having the same problem on a Euro default site where customers can choose GBP or USD. Whatever happens, if customers try to pay in anything other than the default currency, paypal always gets an incorrect value regardless of how well it looks in VirtueMart.

This item and similarly titled ones are scattered across the forum. Any chance a Moderator can get this into a single topic and promote this issue for a fix?
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: CB11 on January 30, 2009, 01:32:16 AM
I am having similar problems.

The default currency on my website is AUD and we offer the Virtuemart currency selector.

If a customer changes the currency e.g. from AUD to USD, it looks to be OK in the purchase order email but in PayPal it will display in AUD but the USD amount so we are charging our customers less.

The error message we get from PayPal is:
During a paypal transaction on your site the received amount didn't match the order total.
                   Order ID: 51.
                   Order Number: 9_8c1f9448edb8f706bfd7b2ec6cef56.
                   The amount received was: 101.47 AUD.
                   It should be: 101.47 USD.

Can anyone advise whether this is a PayPal setting issue or a virtuemart issue?

Thankyou
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: cynvill on February 22, 2009, 02:20:21 AM
hi,

I'm having the same problem here. Did anyone figure out a solution?

Thanks,

Cynthia
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Icewraithuk on February 25, 2009, 23:02:54 PM
Same problem here - any news on a fix or getting this escalated?
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Glenis on February 28, 2009, 02:58:28 AM
I found the method above by weeonesbyjajoc works (on my test runs) . Thanks weeonesbyjajoc !

"currency_code" => $_SESSION['product_currency']

In Paypal I have listed all of the currencies I use ie USD,GBP, AUD, NZD - maybe that's everyone's problem?
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Webdongle on February 28, 2009, 03:38:14 AM
mmmmmmmmmm  perhaps there is a reason for this.

Banks take commission on exchange rates.  Therefore, when a customer orders while seeing their price but your currency/price goes to the gateway then the first commission is payed by the customer.  And the gateway then pays you your price less their charge for the sevice.

But if the recieve the request in your customers currency then they convert it to yours.  Because banks have two exchange rates (one for buying and one for selling) you will get your price minus commission and minus the charge for the service.

?????????  just a thought ?????????
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Glenis on February 28, 2009, 04:46:08 AM
There is only one Paypal fee.
Well it did work but now I have a problem with the Shipping and Handling.  S & H works fine in the default currency but when using the conversion it is correct when you get to the final confirmation page but when you click the confirmation link and go to Paypal it changes the amount, and depending on the currency it can be more or less than the final confirmation page. 
The client confirmation email is in the new amount as well.  Seems to be doing a double conversion somewhere.  Converts once at the checkout stage and again at the confirmation stage.

Any ideas? Solutions?
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Webdongle on February 28, 2009, 12:16:15 PM
Quote from: Glenis on February 28, 2009, 04:46:08 AM
....... Converts once at the checkout stage and again at the confirmation stage.

Any ideas? Solutions?

Paypal is a bank and banks work on two exchange rates buy and sell

"About the Full Universal Currency Converter
The Full version of Universal Currency Converter, the world's most popular currency tool, lets you to perform currency and foreign exchange rate calculations using live, up-to-the-minute mid-market currency rates. (http://www.xe.com/faq.php#midmarket)"
http://www.xe.com/ucc/full/ (http://www.xe.com/ucc/full/)
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Icewraithuk on March 03, 2009, 15:05:50 PM
Hi,

A bit more detail on the problem...
My site is based in the UK and all my prices are in GBP, I offer a currency convertor to allow customers to see the prices in USD or EUR.

with "currency_code" => $_SESSION['vendor_currency'],
If a customer chooses to see prices in USD or EUR and then goes through checkout, PayPal will pay me the amount they had in their curreny (say $23.35) in GBP (I get £23.35) - this is obviously not great for my customers!

If I make this change:
"currency_code" => $_SESSION['vendor_currency'],
replaced by
"currency_code" => $_SESSION['product_currency'],

it all looks good, but now it seems that when a customer tries to checkout in GBP, everything looks right, except I receive the GBP amount in USD (So if it was £16.35 I get $16.35) - this is obviously very bad for me :)

For the moment, I am going to remove the facility to allow multiple currencies, but would really like a solution to this?
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Webdongle on March 04, 2009, 02:11:38 AM
Quote from: Icewraithuk on March 03, 2009, 15:05:50 PM
Hi,

A bit more detail on the problem...
My site is based in the UK and all my prices are in GBP, I offer a currency convertor to allow customers to see the prices in USD or EUR.

with "currency_code" => $_SESSION['vendor_currency'],
If a customer chooses to see prices in USD or EUR and then goes through checkout, PayPal will pay me the amount they had in their curreny (say $23.35) in GBP (I get £23.35) - this is obviously not great for my customers!

If I make this change:
"currency_code" => $_SESSION['vendor_currency'],
replaced by
"currency_code" => $_SESSION['product_currency'],

it all looks good, but now it seems that when a customer tries to checkout in GBP, everything looks right, except I receive the GBP amount in USD (So if it was £16.35 I get $16.35) - this is obviously very bad for me :)

For the moment, I am going to remove the facility to allow multiple currencies, but would really like a solution to this?

They buy at one rate and sell at another so make commission on both transactions.  The currency converter uses a rate inbetween the two for comparison purposes.

Therefore when the customer is looking at the converted price they are not seeing the buying price of the bank.  The price that the currency converter is for comparision purposes only.

Paypal will only allow calculation of their exchange rate for people buying through their Paypal account.  They will not disclose their exchange rate for people who pay using credit/debit cards.
https://www.paypal.com/helpcenter/main.jsp;jsessionid=JtSDGR1Vxf43rMRkmPnnrQTF5hLvqmNGN8vRnvpFyCHrJ92GMgQD!-503516583?locale=en_GB&_dyncharset=UTF-8&countrycode=US&cmd=_help-ext&serverInstance=9005&t=solutionTab&ft=&ps=solutionPanels&solutionId=17628 (https://www.paypal.com/helpcenter/main.jsp;jsessionid=JtSDGR1Vxf43rMRkmPnnrQTF5hLvqmNGN8vRnvpFyCHrJ92GMgQD!-503516583?locale=en_GB&_dyncharset=UTF-8&countrycode=US&cmd=_help-ext&serverInstance=9005&t=solutionTab&ft=&ps=solutionPanels&solutionId=17628)

When i get my site up and running i will stick to £.  There will be a page on the site explaining about exchange rates with links pointing to a site that displays exchange rates.  There will also be a disclaimer that the exact rate will be calculated at the time of the transaction.
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Icewraithuk on March 04, 2009, 10:31:04 AM
Sorry, I think you may have missed the point about my post - it's not about currency conversion, per se...

The point is, in the first example, the amount gets passed to PayPal as <currency type><amount in GBP> and in the second example it gets passed to PayPal as <USD><amount in whatever currency they have selected>

PayPal never gets a chance to do the conversion - it just either processes the transaction in whatever currency has been passed with the wrong amount (option 1) or in USD with the wrong amount. It's only when it lands in my account that it does any kind of conversion - this is about what happens before that.

I would be quite happy to accept, if my site did the conversion and came up with $23.50 and PayPal converted that back to a slightly lower amount in GBP when it landed in my account, but that's not what's going on here.

Let me try and make a better example...

Option 1:
3 items in the basket, values = 16GBP, 16.35EUR, 18.50USD
I will get paid 16GBP if customer had GBP selected, 16.35GBP if the customer had EUR selected or 18.50GBP if the customer had USD selected - nothing to do with PayPal conversion, it's Virtuemart passing the details badly

Option 2:
Same items/prices
I will get paid 16USD if the customer had GBP selected, 16.35USD if EUR or 18.50USD if they had USD selected - again, Virtuemart passing the wrong currency type to PayPal.

Hope that's a bit clearer?
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: JonathanNZ on March 05, 2009, 22:23:42 PM
Is there anyone on the development team looking into this issue?
It seems like a MAJOR issue in my opinion.
I am also facing this issue.
I am very surprised there is no mention of a solution.
What's up with that? I see so many posts in the forums with questions that go completely unanswered. That has also surprised me... I am used to open source projects having great user-to-user and even developer-to-user support. Seems lacking here... especially when an issue as significant as this has gone unresolved for nearly two months (not including all the earlier posts from other people facing the same issue)

A solution to this BUG would be greatly appreciated.

With thanks,

Jonathan
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Webdongle on March 06, 2009, 00:18:52 AM
I altered one of the test items to be £ then viewed the item with USD selected.  Then ordered.  All was ok, the cart passed the price with the USD amount that was showing on the creen when ordered.  That is correct because the customer is paying in USD and does not want to pay differently than they see on the screen.  The fact that Paypal charges @ a adifferent rate and then adds charges for cross border currencies is irrelevant to the way VM works.

I did the same test with £ showing and all was well.  The cart passed the correct £ amount to the cart.  In that instance Paypal would deduct the USD equivilant(based on their own exchange rate) from the customers card.  The amount of USD that would be deducted would not be the same as the amount that shows in VM when conversion is on.

The only time that there is a problem is when i have the site set to show £ but the product has an amount in a different currency.

If the Site is set to ones own currency and the item is given a value in the same currency then VM works correctly as it is installed.

The confusion arises because people do not understand that banks use their own exchange rates.  And do not change the currency of the test products.
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Icewraithuk on March 06, 2009, 10:25:35 AM
Hi,

I'll state this again, because clearly I've not been clear enough THIS IS NOTHING TO DO WITH PAYPAL DOING A CURRENCY EXCHANGE!!!!

Set your item price to £, change your site currency to USD, check out - everything looks fine at PayPal, but when you ACTUALLY PAY, it screws up and sends the amount in the other currency.

Seriously, I'm not a retard, I know when it's a currency conversion issue (the difference will be a very small amount) and when it's a programmatic error (which this is)

A currency exchange rate difference would not result in a USD23.35 order being paid as GBP23.35 - it would result in me getting something like £12.53 instead of £12.99 - this is NOT what is happening...

I re-iterate, it all looks absolutely correct until you actually finish the checkout with PayPal - to the customer, it all looks correct, the PayPal site says GBP/EUR/USD all the way through, it's just what you get in the end.

I'm guessing it's more of a PayPal issue than a VirtueMart one, but the easiest way to fix it would be to get VirtueMart to show whatever currency the user wants, but only ever send the amount in the store currency to PayPal - that way I'll always get my £12.99 and the customer takes the hit on the PayPal conversion...

Which I guess would be something like "currency_code" => $_SESSION['product_currency'], but always send GBP rather than USD?

Anyway, I've just turned it off for now - anyone know if there's a way to just get the store to display all prices in USD/EUR/GBP as the kind of "guide price" on every item and in the cart? That would be a lot more elegant
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Webdongle on March 06, 2009, 13:40:29 PM
Sorry did not mean to imply that you are a retard.  I now see your problem, you need to set prefferences in paypal.  Personaly i would just leave all as £ on VM and have a page linking to an example exchange rate and have a disclaimer saying the rate varies.



[attachment cleanup by admin]
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: yorkweb on April 10, 2009, 13:25:49 PM
Having had this exact issue I found this thread whilst trying to find a fix.

In my experience although the idea of forcing one currency and giving a currency comparison "page" for people to look at is a valid solution, it is also extremely off putting for a customer wishing to pay in their own currency - not only that but its also forcing them to quite visually bare the currency conversion cost (as others have suggested could be the root problem with this).

The solution I have come up with seems to deal with the problem reasonably well - I'm no php expert so if anyone can up with something better then lets do it, but it's working on my sites and stopping me losing money.

I have simply created a variable to use in the paypal array combined with some if statements to check which product_currency should be passed. I've found that by passing the actual currency code instead of the product_currency stored in $_SESSION it seems to do the trick:

$mycash = "";
if ($_SESSION['product_currency'] == "GBP" )
      {
      $mycash = "GBP";
      }
elseif ($_SESSION['product_currency'] == "USD" )
      {
      $mycash = "USD";
      }
else
{$mycash = "EUR";}


$url = "https://www.paypal.com/cgi-bin/webscr";
$tax_total = $db->f("order_tax") + $db->f("order_shipping_tax");
$discount_total = $db->f("coupon_discount") + $db->f("order_discount");
$post_variables = Array(
"cmd" => "_ext-enter",
"redirect_cmd" => "_xclick",
"upload" => "1",
"business" => PAYPAL_EMAIL,
"receiver_email" => PAYPAL_EMAIL,
"item_name" => $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER').": ". $db->f("order_id"),
"order_id" => $db->f("order_id"),
"invoice" => $db->f("order_number"),
"amount" => round( $db->f("order_subtotal")+$tax_total-$discount_total, 2),
"shipping" => sprintf("%.2f", $db->f("order_shipping")),
"currency_code" => $mycash,
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: craiggunn on April 16, 2009, 11:45:49 AM
tried the above, and it seems to work, thanks yorkweb, this was becoming a major issue for me!
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: chac416 on May 04, 2009, 18:44:08 PM
which file did you edit, and which lines?

Quote from: yorkweb on April 10, 2009, 13:25:49 PM
Having had this exact issue I found this thread whilst trying to find a fix.

In my experience although the idea of forcing one currency and giving a currency comparison "page" for people to look at is a valid solution, it is also extremely off putting for a customer wishing to pay in their own currency - not only that but its also forcing them to quite visually bare the currency conversion cost (as others have suggested could be the root problem with this).

The solution I have come up with seems to deal with the problem reasonably well - I'm no php expert so if anyone can up with something better then lets do it, but it's working on my sites and stopping me losing money.

I have simply created a variable to use in the paypal array combined with some if statements to check which product_currency should be passed. I've found that by passing the actual currency code instead of the product_currency stored in $_SESSION it seems to do the trick:

$mycash = "";
if ($_SESSION['product_currency'] == "GBP" )
      {
      $mycash = "GBP";
      }
elseif ($_SESSION['product_currency'] == "USD" )
      {
      $mycash = "USD";
      }
else
{$mycash = "EUR";}


$url = "https://www.paypal.com/cgi-bin/webscr";
$tax_total = $db->f("order_tax") + $db->f("order_shipping_tax");
$discount_total = $db->f("coupon_discount") + $db->f("order_discount");
$post_variables = Array(
"cmd" => "_ext-enter",
"redirect_cmd" => "_xclick",
"upload" => "1",
"business" => PAYPAL_EMAIL,
"receiver_email" => PAYPAL_EMAIL,
"item_name" => $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER').": ". $db->f("order_id"),
"order_id" => $db->f("order_id"),
"invoice" => $db->f("order_number"),
"amount" => round( $db->f("order_subtotal")+$tax_total-$discount_total, 2),
"shipping" => sprintf("%.2f", $db->f("order_shipping")),
"currency_code" => $mycash,
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: ufo_hk on June 08, 2009, 02:35:26 AM
Ok I need to ask again as this is a major issue, currently using VM 1.1.2 and decided to test with Beta VM 1.1.4 but see the same results.

Where a site is using the multi-currency module on the site, when accepting paypal payments, on the first order the currency sent to paypal is USD not the currency selected/displayed on the site.

Note: i also applied the change:
"currency_code" => $_SESSION['vendor_currency']
to
"currency_code" => $_SESSION['product_currency']

Does anyone have a successful solution to this issue, which seems to have been around for a while. Surely someone has the multi-currency module working correctly with paypal.

Thanks
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: creagenzia on July 02, 2009, 20:08:20 PM
having the same issue - running VM 1.1.3 on Joomla 1.5.10

Problem: selected currency is showed correctly in cart and on order confirmation, but booked as store currency in PayPal.

Standard Shipping Module seems to convert into selected currency, then use new value as store currency and convert once more. this amount is finally also booked in store currency.(...great I get more on shipping!!!)

this behavious renders currency conversion useless and puts off customers.

Looks like a very old issue with quite a number of VM users and that still has not experienced any fixing???? Simply incomprehensible how such a grave bug can be ignored so consistently by the devteam...

thought I write my experience here just to state that there is another currency victim out there :-(

haven't tried yorkwebs fix and go with chac416 wanting to know as WHERE to apply this fix - this info would maybe help to alleviate the pain a bit...

Thanks
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Nded on July 27, 2009, 21:53:35 PM
I just applied this $mycash fix to my VM 1.3 Joomla 1.5 store and it seems to be perfect.  I blended it with the improved PayPal screen generator at http://www.gjcwebdesign.com/configuration-paypal-payment-module-virtuemart.html to get a very good finished product.
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Nded on July 27, 2009, 22:02:56 PM
Here is my PayPal "Payment Extra Info" field with the improved PayPal output and the Multi-Currency patch $mycash applied:

Quote<?php

$mycash = "";
if ($_SESSION['product_currency'] == "GBP" )
      {
      $mycash = "GBP";
      }
elseif ($_SESSION['product_currency'] == "AUD" )
      {
      $mycash = "AUD";
      }
elseif ($_SESSION['product_currency'] == "CAD" )
      {
      $mycash = "CAD";
      }
elseif ($_SESSION['product_currency'] == "EUR" )
      {
      $mycash = "EUR";
      }
else
{$mycash = "USD";}

$url = "https://www.paypal.com/cgi-bin/webscr";
$order_id = $db->f("order_id");
$tax_total = $db->f("order_tax") + $db->f("order_shipping_tax");
$discount_total = $db->f("coupon_discount") + $db->f("order_discount"); 

// Query for Order Items
$dboi = new ps_DB;
$q_oi = "SELECT * FROM #__vm_order_item ";
$q_oi .= "WHERE #__vm_order_item.order_id='$order_id'";
$dboi->query($q_oi);

$row_num = $dboi->num_rows();

//Getting Cart Items
$auth = $_SESSION['auth'];
$cart = $_SESSION['cart'];
$t_quantity = 0;
$disc_perItem = 0;
$i=1;

// Query to get User Info
$dbb = new ps_DB;
$q = "SELECT * FROM #__vm_user_info ";
$q .= "WHERE user_id ='".$my->id."' ";
$dbb->setQuery($q);
$dbb->query();

//logic for applying discounts to multiple items
$discount_totalCP = $db->f("coupon_discount") + $db->f("order_discount");

while($dboi->next_record()) {
  $t_quantity = $t_quantity + intval($dboi->f("product_quantity"));
}

$dboi = null;
$dboi = new ps_DB;
$dboi->query($q_oi);

if($t_quantity > 0)
{
  if($discount_totalCP > 0) {
    $disc_perItem = round($discount_totalCP / $t_quantity, 2);
  }
  else {
    $disc_perItem = 0;
  }
}
else {
  $disc_perItem = 0;
}
//query to optain product attributes
while($dboi->next_record()) {

  $prod_attrib = $dboi->f("product_attribute");
  $supp_var['item_name_' . $i] = strip_tags("Order #". $db->f("order_id").": ". $dboi->f

("order_item_name"));

  if($prod_attrib > ''){
    $attributes_array = explode('<br/>',$prod_attrib);
    $v = 0;
    $z = 1;
    foreach ( $attributes_array as $attributes_value){
      $attrib_name = trim(substr($attributes_value, 0, strpos($attributes_value, ':')), " ");
      $supp_var['on' . $z . '_' . $i] = $attrib_name;
      $attrib_sel = trim(substr_replace(substr_replace($attributes_value, "", 0, strrpos

($attributes_value, ':')), "", 0, 2));
      $supp_var['os' . $z . '_' . $i] = $attrib_sel;
      $v++;
      $z++;
      unset($attributes_value);
    }
  }

  $supp_var['item_number_' . $i] = $dboi->f("order_item_sku");
  $supp_var['quantity_' . $i] = $dboi->f("product_quantity");
  $supp_var['amount_' . $i] = round(($dboi->f("product_item_price") - $disc_perItem),2);
  $i++;
}


//Query used to find whether to use Bill Address or Ship to address
$dboui = new ps_DB;
$q_oui = "SELECT * FROM #__vm_order_user_info ";
$q_oui .= "WHERE #__vm_order_user_info.order_id='$order_id' ORDER BY

#__vm_order_user_info.order_info_id DESC";
$dboui->query($q_oui);

$oui_id = $dboui->f("order_info_id");

if($oui_id == $order_id){
  $first_name = $dbb->f("first_name");
  $last_name = $dbb->f("last_name");
  $address1 = $dbb->f("address_1");
  $address2 = $dbb->f("address_2");
  $city = $dbb->f("city");
  $state = $dbb->f("state");
  $address_country = $dbbt->f("country");
  $zip = $dbb->f("zip");
  $H_PhoneNumber = $dbb->f("phone_1");
}
else {
  $first_name = $dboui->f("first_name");
  $last_name = $dboui->f("last_name");
  $address1 = $dboui->f("address_1");
  $address2 = $dboui->f("address_2");
  $city = $dboui->f("city");
  $state = $dboui->f("state");
  $address_country = $dboui->f("country");
  $zip = $dboui->f("zip");
  $H_PhoneNumber = $dboui->f("phone_1");
}

// Builds array for the form
$post_variables = Array(
"cmd" => "_cart",
"upload" => "1",
"page_style" => "paypal",
"business" => PAYPAL_EMAIL,
"currency_code" => $mycash,
"amount" => round( $db->f("order_subtotal")+$tax_total-$discount_total, 2),
"handling_cart" => sprintf("%.2f", $db->f("order_shipping")),
"tax" => $tax_total,
"tax_cart" => $tax_total,
"invoice" => $db->f("order_number"),
"image_url" => $vendor_image_url,
"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),
"notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",
"cancel_return" => SECUREURL ."index.php",
"no_shipping" => "1",
"no_note" => "1",
"email" => $dbb->f("user_email"),
"address_override" => "1",//change this to 0 if you have - Paypal does not allow your country of residence to ship to the country you wish to - errors
"first_name" => $first_name,
"last_name" => $last_name,
"address1" => $address1,
"address2" => $address2,
"city" => $city,
"state" => $state,
"address_country" => $address_country,
"zip" => $zip,
"night_phone_b" => $H_PhoneNumber
);
//add and send the new variables
if( $page == "checkout.thankyou" ) {
  $query_string = "?";

  foreach( $post_variables as $name => $value ) {
    $query_string .= $name. "=" . urlencode($value) ."&";
  }

  if(is_array($supp_var) && count($supp_var)) {
    foreach($supp_var as $name => $value) {
      $query_string .= $name. "=" . urlencode($value) ."&";
    }
  }

  vmRedirect( $url . $query_string );
}
else {
  echo '<form action="'.$url.'" method="post" target="_blank">';

  foreach( $post_variables as $name => $value ) {
    echo '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
  }

  if(is_array($supp_var) && count($supp_var)) {
    foreach($supp_var as $name => $value) {
      echo '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
    }
  }
  echo '<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-

but6.gif" border="0" alt="Make payments with PayPal, it is fast, free, and secure!">';
//Change the above image url for different languages and countries
  echo '</form>';
}
?>

It really is amazing that the Virtuemart development team is overlooking this major bug.
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: atrus on July 31, 2009, 15:33:52 PM
Good job with Multi-Currency patch $mycash! It certainly works better. However i'm facing problems with the shipping & handling fees.

More specifically:

Store Default Currency: Euro

Shipping Fees (Standard Module) are input in Euro.

Now,whenever pressing confirm to go to Paypal, everything is passed properly, including the currency, however the shipping and handling fees in Paypal are wrong (even though Virtuemart has calculated them correctly in the checkout page). Pls note that this happens with all other currencies except for the default one!

After a small investigation i found out that the shipping & handling fees are re-multiplied by the exchange rate of the default store's currency and the one the customer is using immediately after pressing the confirm button to go to paypal. The problem is actually with the order_shipping variable passed to Paypal; seems like a Virtuemart's bug.

Anybody found a workaround to the problem?

Working with Joomla 1.5.8 and Virtuemart 1.1.2
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: Nded on July 31, 2009, 18:40:43 PM
Quote from: atrus on July 31, 2009, 15:33:52 PM
Good job with Multi-Currency patch $mycash! It certainly works better. However i'm facing problems with the shipping & handling fees.

More specifically:

Store Default Currency: Euro

Shipping Fees (Standard Module) are input in Euro.

Now,whenever pressing confirm to go to Paypal, everything is passed properly, including the currency, however the shipping and handling fees in Paypal are wrong (even though Virtuemart has calculated them correctly in the checkout page). Pls note that this happens with all other currencies except for the default one!

After a small investigation i found out that the shipping & handling fees are re-multiplied by the exchange rate of the default store's currency and the one the customer is using immediately after pressing the confirm button to go to paypal. The problem is actually with the order_shipping variable passed to Paypal; seems like a Virtuemart's bug.

Anybody found a workaround to the problem?

Working with Joomla 1.5.8 and Virtuemart 1.1.2

I started a new thread recently about this "other" currency problem - http://forum.virtuemart.net/index.php?topic=58532.msg191822#msg191822
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: atrus on August 02, 2009, 20:35:50 PM
Nded, for your info, i solved my problem as follows:

Replace line 1599 in file ps_checkout.php (\administrator\components\com_virtuemart\classes) as follows:

//$d['shipping_total'] = $GLOBALS['CURRENCY']->convert( $d['shipping_total'] );

This line seems to be doing the unessecary 2nd conversion which messes everything up. That's why i removed it. Now everything works like a charm.

I hope this will be rectified in the next VM release.
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: cybersalt on August 03, 2009, 19:21:53 PM
Just in case anyone is confused - as initially was - this was line 1596 for me.

Basically you need to find the line below without the "//" and add "//" to the beginning. ::)




Quote from: atrus on August 02, 2009, 20:35:50 PM
Nded, for your info, i solved my problem as follows:

Replace line 1599 in file ps_checkout.php (\administrator\components\com_virtuemart\classes) as follows:

//$d['shipping_total'] = $GLOBALS['CURRENCY']->convert( $d['shipping_total'] );

This line seems to be doing the unessecary 2nd conversion which messes everything up. That's why i removed it. Now everything works like a charm.

I hope this will be rectified in the next VM release.
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: ufo_hk on August 20, 2009, 02:21:45 AM
Came back to post that I managed to get the issue fixed and see Nded had beat me to it.

Do as Nded says visit:
http://www.gjcwebdesign.com/configuration-paypal-payment-module-virtuemart.html

and not only do you get better info on the paypal but multicurrancy issue can be fixed. Note John @ gjcwebdesign did a great job of customising this for us.

Thanks - finally happy we have a suitable fix for this.
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: volksman3 on September 28, 2009, 16:09:04 PM
The fix at http://www.gjcwebdesign.com/configuration-paypal-payment-module-virtuemart.html works fine for sorting out the various currency issues and a disclaimer place on the store site explaining the slight difference between the paypal total and the virtuemart total due to the different exchange rates used between ECB and Paypal allows it to be used. The problem i have is if you checkout using the primary store currency using the above paypal script i get the following error from paypal:

The amount received was: 40.19 GBP.
It should be: 40.2 GBP.

If i revert back to the original paypal code this is not the case so somewhere in the new paypal script their is a rounding error but i cannot find it - It only seams to do this when the primary currency - in my case £ is used when checking out as the other orders in Euros work fine with no error.

Has anyone else had this problem and if so is there a fix for it?

ps here is my code:

<?php

$mycash = "";
if ($_SESSION['product_currency'] == "USD" )
      {
      $mycash = "USD";
      }
elseif ($_SESSION['product_currency'] == "AUD" )
      {
      $mycash = "AUD";
      }
elseif ($_SESSION['product_currency'] == "CAD" )
      {
      $mycash = "CAD";
      }
elseif ($_SESSION['product_currency'] == "EUR" )
      {
      $mycash = "EUR";
      }
else
{$mycash = "GBP";}

$url = "https://www.paypal.com/cgi-bin/webscr";
$order_id = $db->f("order_id");
$tax_total = $db->f("order_tax") + $db->f("order_shipping_tax");
$discount_total = $db->f("coupon_discount") + $db->f("order_discount");

// Query for Order Items
$dboi = new ps_DB;
$q_oi = "SELECT * FROM #__vm_order_item ";
$q_oi .= "WHERE #__vm_order_item.order_id='$order_id'";
$dboi->query($q_oi);

$row_num = $dboi->num_rows();

//Getting Cart Items
$auth = $_SESSION['auth'];
$cart = $_SESSION['cart'];
$t_quantity = 0;
$disc_perItem = 0;
$i=1;

// Query to get User Info
$dbb = new ps_DB;
$q = "SELECT * FROM #__vm_user_info ";
$q .= "WHERE user_id ='".$my->id."' ";
$dbb->setQuery($q);
$dbb->query();

//logic for applying discounts to multiple items
$discount_totalCP = $db->f("coupon_discount") + $db->f("order_discount");

while($dboi->next_record()) {
  $t_quantity = $t_quantity + intval($dboi->f("product_quantity"));
}

$dboi = null;
$dboi = new ps_DB;
$dboi->query($q_oi);

if($t_quantity > 0)
{
  if($discount_totalCP > 0) {
    $disc_perItem = round($discount_totalCP / $t_quantity, 2);
  }
  else {
    $disc_perItem = 0;
  }
}
else {
  $disc_perItem = 0;
}
//query to optain product attributes
while($dboi->next_record()) {

  $prod_attrib = $dboi->f("product_attribute");
  $supp_var['item_name_' . $i] = strip_tags("Order #". $db->f("order_id").": ". $dboi->f

("order_item_name"));

  if($prod_attrib > ''){
    $attributes_array = explode('<br/>',$prod_attrib);
    $v = 0;
    $z = 1;
    foreach ( $attributes_array as $attributes_value){
      $attrib_name = trim(substr($attributes_value, 0, strpos($attributes_value, ':')), " ");
      $supp_var['on' . $z . '_' . $i] = $attrib_name;
      $attrib_sel = trim(substr_replace(substr_replace($attributes_value, "", 0, strrpos

($attributes_value, ':')), "", 0, 2));
      $supp_var['os' . $z . '_' . $i] = $attrib_sel;
      $v++;
      $z++;
      unset($attributes_value);
    }
  }

  $supp_var['item_number_' . $i] = $dboi->f("order_item_sku");
  $supp_var['quantity_' . $i] = $dboi->f("product_quantity");
  $supp_var['amount_' . $i] = round(($dboi->f("product_item_price") - $disc_perItem),2);
  $i++;
}


//Query used to find whether to use Bill Address or Ship to address
$dboui = new ps_DB;
$q_oui = "SELECT * FROM #__vm_order_user_info ";
$q_oui .= "WHERE #__vm_order_user_info.order_id='$order_id' ORDER BY

#__vm_order_user_info.order_info_id DESC";
$dboui->query($q_oui);

$oui_id = $dboui->f("order_info_id");

if($oui_id == $order_id){
  $first_name = $dbb->f("first_name");
  $last_name = $dbb->f("last_name");
  $address1 = $dbb->f("address_1");
  $address2 = $dbb->f("address_2");
  $city = $dbb->f("city");
  $state = $dbb->f("state");
  $address_country = $dbbt->f("country");
  $zip = $dbb->f("zip");
  $H_PhoneNumber = $dbb->f("phone_1");
}
else {
  $first_name = $dboui->f("first_name");
  $last_name = $dboui->f("last_name");
  $address1 = $dboui->f("address_1");
  $address2 = $dboui->f("address_2");
  $city = $dboui->f("city");
  $state = $dboui->f("state");
  $address_country = $dboui->f("country");
  $zip = $dboui->f("zip");
  $H_PhoneNumber = $dboui->f("phone_1");
}

// Builds array for the form
$post_variables = Array(
"cmd" => "_cart",
"upload" => "1",
"page_style" => "paypal",
"business" => PAYPAL_EMAIL,
"currency_code" => $mycash,
"amount" => round( $db->f("order_subtotal")+$tax_total-$discount_total, 2),
"handling_cart" => sprintf("%.2f", $db->f("order_shipping")),
"tax" => $tax_total,
"tax_cart" => $tax_total,
"invoice" => $db->f("order_number"),
"image_url" => $vendor_image_url,
"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),
"notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",
"cancel_return" => SECUREURL ."index.php",
"no_shipping" => "1",
"no_note" => "1",
"email" => $dbb->f("user_email"),
"address_override" => "1",//change this to 0 if you have - Paypal does not allow your country of residence to ship to the country you wish to - errors
"first_name" => $first_name,
"last_name" => $last_name,
"address1" => $address1,
"address2" => $address2,
"city" => $city,
"state" => $state,
"address_country" => $address_country,
"zip" => $zip,
"night_phone_b" => $H_PhoneNumber
);
//add and send the new variables
if( $page == "checkout.thankyou" ) {
  $query_string = "?";

  foreach( $post_variables as $name => $value ) {
    $query_string .= $name. "=" . urlencode($value) ."&";
  }

  if(is_array($supp_var) && count($supp_var)) {
    foreach($supp_var as $name => $value) {
      $query_string .= $name. "=" . urlencode($value) ."&";
    }
  }

  vmRedirect( $url . $query_string );
}
else {
  echo '<form action="'.$url.'" method="post" target="_blank">';

  foreach( $post_variables as $name => $value ) {
    echo '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
  }

  if(is_array($supp_var) && count($supp_var)) {
    foreach($supp_var as $name => $value) {
      echo '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
    }
  }
  echo '<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-

but6.gif" border="0" alt="Make payments with PayPal, it is fast, free, and secure!">';
//Change the above image url for different languages and countries
  echo '</form>';
}
?>
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: riefvan on November 17, 2009, 06:08:13 AM
To fix this issue, i use this trick

change the line in the paypal configuration (payment method form)
"currency_code" => $db->f("vendor_currency"),
with
"currency_code" => $db->f("order_currency"),

Also apply fix by atrus
Quote from: atrus on August 02, 2009, 20:35:50 PM
Nded, for your info, i solved my problem as follows:

Replace line 1599 in file ps_checkout.php (\administrator\components\com_virtuemart\classes) as follows:

//$d['shipping_total'] = $GLOBALS['CURRENCY']->convert( $d['shipping_total'] );

This line seems to be doing the unessecary 2nd conversion which messes everything up. That's why i removed it. Now everything works like a charm.

I hope this will be rectified in the next VM release.

Just don't place your change currency module anywhere in virtuemart pages because it well mess shipping&handling fee in the cart if a buyer has passed filling out shipping informations step. Put the module inside a specific menu item. Virtuemart doesn't convert the shipping&handling fee on the fly. So that buyers have to start all over the checkout process if they want to change currency in checkout process after shipping information step done.

Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: spottedsparrow on March 03, 2010, 12:24:37 PM
I've finally gotten the currencies to display correctly in PayPal thanks to the many tips and hacks on these forums.  Unfortunately, PayPal is still not displaying the correct shipping charge.  A customer orders a product and the shipping charge of $1.22 is correctly displayed on my site.  When finishing the order and going to PayPal, the shipping charge is suddenly changed to $5.22.  Where did the extra $4 come from?

Here is my PayPal configuration using the $mycash and http://www.gjcwebdesign.com/configuration-paypal-payment-module-virtuemart.html (http://"http://www.gjcwebdesign.com/configuration-paypal-payment-module-virtuemart.html") fixes :
<?php

$mycash 
"";
if (
$_SESSION['product_currency'] == "EUR" )
      {
      
$mycash "EUR";
      }
elseif (
$_SESSION['product_currency'] == "AUD" )
      {
      
$mycash "AUD";
      }
elseif (
$_SESSION['product_currency'] == "CAD" )
      {
      
$mycash "CAD";
      }
elseif (
$_SESSION['product_currency'] == "GBP" )
      {
      
$mycash "GBP";
      }
else
{
$mycash "USD";}

$url "https://www.paypal.com/cgi-bin/webscr";
$order_id $db->f("order_id");
$tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
$discount_total $db->f("coupon_discount") + $db->f("order_discount");  
 
// Query for Order Items
$dboi = new ps_DB;
$q_oi "SELECT * FROM #__vm_order_item ";
$q_oi .= "WHERE #__vm_order_item.order_id='$order_id'";
$dboi->query($q_oi);
 
$row_num $dboi->num_rows();
 
//Getting Cart Items
$auth $_SESSION['auth'];
$cart $_SESSION['cart'];
$t_quantity 0;
$disc_perItem 0;
$i=1;
 
// Query to get User Info
$dbb = new ps_DB;
$q "SELECT * FROM #__vm_user_info ";
$q .= "WHERE user_id ='".$my->id."' ";
$dbb->setQuery($q);
$dbb->query();
 
//logic for applying discounts to multiple items
$discount_totalCP $db->f("coupon_discount") + $db->f("order_discount");
 
while(
$dboi->next_record()) {
  
$t_quantity $t_quantity intval($dboi->f("product_quantity"));
}
 
$dboi null;
$dboi = new ps_DB;
$dboi->query($q_oi);
 
if(
$t_quantity 0)
{
  if(
$discount_totalCP 0) {
    
$disc_perItem round($discount_totalCP $t_quantity2);
  }
  else {
    
$disc_perItem 0;
  }
}
else {
  
$disc_perItem 0;
}
//query to optain product attributes
while($dboi->next_record()) {
 
  
$prod_attrib $dboi->f("product_attribute");
  
$supp_var['item_name_' $i] = strip_tags("Order #"$db->f("order_id").": "$dboi->f("order_item_name"));
 
  if(
$prod_attrib ''){
    
$attributes_array explode('<br/>',$prod_attrib);
    
$v 0;
    
$z 1;
    foreach ( 
$attributes_array as $attributes_value){
      
$attrib_name trim(substr($attributes_value0strpos($attributes_value':')), " ");
      
$supp_var['on' $z '_' $i] = $attrib_name;
      
$attrib_sel trim(substr_replace(substr_replace($attributes_value""0strrpos($attributes_value':')), ""02));
      
$supp_var['os' $z '_' $i] = $attrib_sel;
      
$v++;
      
$z++;
      unset(
$attributes_value);
    }
  }
 
  
$supp_var['item_number_' $i] = $dboi->f("order_item_sku");
  
$supp_var['quantity_' $i] = $dboi->f("product_quantity");
  
$supp_var['amount_' $i] = round(($dboi->f("product_item_price") - $disc_perItem),2);
  
$i++;
}
 
 
//Query used to find whether to use Bill Address or Ship to address
$dboui = new ps_DB;
$q_oui "SELECT * FROM #__vm_order_user_info ";
$q_oui .= "WHERE #__vm_order_user_info.order_id='$order_id' ORDER BY #__vm_order_user_info.order_info_id DESC";
$dboui->query($q_oui);
 
/*$oui_id = $dboui->f("order_info_id");
 
if($oui_id == $order_id){
  $first_name = $dbb->f("first_name");
  $last_name = $dbb->f("last_name");
  $address1 = $dbb->f("address_1");
  $address2 = $dbb->f("address_2");
  $city = $dbb->f("city");
  $state = $dbb->f("state");
  $address_country = $dbbt->f("country");
  $zip = $dbb->f("zip");
  $H_PhoneNumber = $dbb->f("phone_1");
}
else {*/
  
$first_name $dboui->f("first_name");
  
$last_name $dboui->f("last_name");
  
$address1 $dboui->f("address_1");
  
$address2 $dboui->f("address_2");
  
$city $dboui->f("city");
  
$state $dboui->f("state");
  
$address_country $dboui->f("country");
  
$zip $dboui->f("zip");
  
$H_PhoneNumber $dboui->f("phone_1");
//}
 
// Builds array for the form
$post_variables = Array(
"cmd" => "_cart",
"upload" => "1",
"page_style" => "paypal",
"business" => PAYPAL_EMAIL,
"currency_code" => $_SESSION['product_currency'],
"amount" => round$db->f("order_subtotal")+$tax_total-$discount_total2),
"handling_cart" => sprintf("%.2f"$db->f("order_shipping")),
"tax" => $tax_total,
"tax_cart" => $tax_total,
"invoice" => $db->f("order_number"),
"image_url" => $vendor_image_url,
"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),
"notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",
"cancel_return" => SECUREURL ."index.php",
"no_shipping" => "1",
"no_note" => "1",
"email" => $dbb->f("user_email"),
"address_override" => "1",//change this to 0 if you have - Paypal does not allow your country of residence to ship to the country you wish to - errors
"first_name" => $first_name,
"last_name" => $last_name,
"address1" => $address1,
"address2" => $address2,
"city" => $city,
"state" => $state,
"country" => $address_country,
"zip" => $zip,
//"night_phone_b" => $H_PhoneNumber
);
//add and send the new variables
if( $page == "checkout.thankyou" ) {
  
$query_string "?";
 
  foreach( 
$post_variables as $name => $value ) {
    
$query_string .= $name"=" urlencode($value) ."&";
  }
 
  if(
is_array($supp_var) && count($supp_var)) {
    foreach(
$supp_var as $name => $value) {
      
$query_string .= $name"=" urlencode($value) ."&";
    }
  }
 
  
vmRedirect$url $query_string );

else {
  echo 
'<form action="'.$url.'" method="post" target="_blank">';
 
  foreach( 
$post_variables as $name => $value ) {
    echo 
'<input type="hidden" name="'.$name.'" value="'.$value.'" />';
  }
 
  if(
is_array($supp_var) && count($supp_var)) {
    foreach(
$supp_var as $name => $value) {
      echo 
'<input type="hidden" name="'.$name.'" value="'.$value.'" />';
    }
  }
  echo 
'<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0" alt="Make payments with PayPal, it is fast, free, and secure!">';
//Change the above image url for different languages and countries
  
echo '</form>';
}
?>


I've also checked my PayPal account settings for Shipping Calculations and Payment Receiving Preferences, and both seem to set up as they should be (screenshots attached).

Can anyone help?  This is really doing my head in!  With half of my customers in the US, I am desperate to have this fixed.  I thought this would have been fixed with the lastest VM update, but no such luck.

VM 1.1.4 and Joomla 1.5.15


[attachment cleanup by admin]
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: spottedsparrow on March 03, 2010, 12:30:53 PM
Don't you hate when you've spent hours, if not days, on something and it turns out to be the simplest thing?  I just solved my own problem.

When I looked at my post, I realized that I probably have to select each currency under PayPal Shipping Calculations.  Duh!  Everything is now working, including the shipping rates!  So, for anyone having similar shipping issues, be sure to change the shipping calculations for each currency you are accepting in your shop.

Thanks again to everyone for the other hacks in this thread.  It has been a lifesaver!
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: dkscompany on July 19, 2010, 23:43:32 PM
Hi, we have find the solution and using this and working properly.

Please try this, please replace with below script with paypal configuration textarea script:

<?php
$db1 = new ps_DB();
$q = "SELECT country_2_code FROM #__vm_country WHERE country_3_code='".$user->country."' ORDER BY country_2_code ASC";
$db1->query($q);


if(isset($_SESSION['product_currency']) && $_SESSION['product_currency']!=''){
$currency = $_SESSION['product_currency'];
}else{
$currency = $_SESSION['vendor_currency'];
}
if($currency=="USD"){
$shipping_temp = sprintf("%.2f", $db->f("order_shipping"));
$shipping =sprintf("%.2f", $GLOBALS['CURRENCY']->convert( $shipping_temp,$currency,'SGD'));
}else{
$shipping =sprintf("%.2f", $db->f("order_shipping"));
}

$url = "https://www.paypal.com/cgi-bin/webscr";
$tax_total = $db->f("order_tax") + $db->f("order_shipping_tax");
$discount_total = $db->f("coupon_discount") + $db->f("order_discount");
$post_variables = Array(
"cmd" => "_ext-enter",
"redirect_cmd" => "_xclick",
"upload" => "1",
"business" => PAYPAL_EMAIL,
"receiver_email" => PAYPAL_EMAIL,
"item_name" => $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER').": ". $db->f("order_id"),
"order_id" => $db->f("order_id"),
"invoice" => $db->f("order_number"),
"amount" => round( $db->f("order_subtotal")+$tax_total-$discount_total, 2),
"shipping" => $shipping,
"currency_code" => $currency ,

"address_override" => "1",
"first_name" => $dbbt->f('first_name'),
"last_name" => $dbbt->f('last_name'),
"address1" => $dbbt->f('address_1'),
"address2" => $dbbt->f('address_2'),
"zip" => $dbbt->f('zip'),
"city" => $dbbt->f('city'),
"state" => $dbbt->f('state'),
"country" => $db1->f('country_2_code'),
"email" => $dbbt->f('user_email'),
"night_phone_b" => $dbbt->f('phone_1'),
"cpp_header_image" => $vendor_image_url,

"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),
"notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",
"cancel_return" => SECUREURL ."index.php",
"undefined_quantity" => "0",

"test_ipn" => PAYPAL_DEBUG,
"pal" => "NRUBJXESJTY24",
"no_shipping" => "1",
"no_note" => "1"
);

if( $page == "checkout.thankyou" ) {
$query_string = "?";
foreach( $post_variables as $name => $value ) {
$query_string .= $name. "=" . urlencode($value) ."&";
}
vmRedirect( $url . $query_string );
} else {
echo '<form action="'.$url.'" method="post" target="_blank">';
echo '<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" alt="Click to pay with PayPal - it is fast, free and secure!" />';

foreach( $post_variables as $name => $value ) {
echo '<input type="hidden" name="'.$name.'" value="'.htmlspecialchars($value).'" />';
}
echo '</form>';

}
?>


In this script you change the currency where you get the error, like we using default currency SGD and error in USD, then put the condition for USD
if($currency=="USD"){
$shipping_temp = sprintf("%.2f", $db->f("order_shipping"));
$shipping =sprintf("%.2f", $GLOBALS['CURRENCY']->convert( $shipping_temp,$currency,'SGD'));
}else{
$shipping =sprintf("%.2f", $db->f("order_shipping"));
}
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: mailon on September 24, 2010, 21:31:25 PM
The $my_cash worked fine for me
the http://www.gjcwebdesign.com/configuration-paypal-payment-module-virtuemart.html did not work, don't really know why

Anyway, I was trying to add Russian Rubles to the payment and just realised that Paypal does not accept these payments!!! Still, can't I checkout in Russian Rubles and at payment this amount to be converted into US$ or Euros that paypal accepts?
cause my major market is in Russia and it would be really great if I could do that...
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: webgobe on September 29, 2010, 17:32:01 PM
After I tried to apply all the above recipes to fix the problem, I put together a new code, which works for me, and which has nothing hard-coded, as some of the above solutions. It's basically the tip by "dkscompany" a bit improved.
Just replace the code in the Payment Extra Info box with the one below:
<?php
$db1 
= new ps_DB();
$q "SELECT country_2_code FROM #__vm_country WHERE country_3_code='".$user->country."' ORDER BY country_2_code ASC";
$db1->query($q);

if(isset(
$_SESSION['product_currency']) && $_SESSION['product_currency']!=''){
$currency $_SESSION['product_currency'];
}else{
$currency $_SESSION['vendor_currency'];
}
$vendor_currency $_SESSION['vendor_currency'];
if(
$currency!=$vendor_currency){
        
$shipping_temp sprintf("%.2f"$db->f("order_shipping"));
        
$shipping =sprintf("%.2f"$GLOBALS['CURRENCY']->convert$shipping_temp,$currency,$vendor_currency));
}else{
        
$shipping =sprintf("%.2f"$db->f("order_shipping"));
}

$url "https://www.paypal.com/cgi-bin/webscr";
$tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
$discount_total $db->f("coupon_discount") + $db->f("order_discount");
$post_variables = Array(
"cmd" => "_ext-enter",
"redirect_cmd" => "_xclick",
"upload" => "1",
"business" => PAYPAL_EMAIL,
"receiver_email" => PAYPAL_EMAIL,
"item_name" => $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER').": "$db->f("order_id"),
"order_id" => $db->f("order_id"),
"invoice" => $db->f("order_number"),
"amount" => round$db->f("order_subtotal")+$tax_total-$discount_total2),
"shipping" => $shipping,
"currency_code" => $currency ,

"address_override" => "1",
"first_name" => $dbbt->f('first_name'),
"last_name" => $dbbt->f('last_name'),
"address1" => $dbbt->f('address_1'),
"address2" => $dbbt->f('address_2'),
"zip" => $dbbt->f('zip'),
"city" => $dbbt->f('city'),
"state" => $dbbt->f('state'),
"country" => $db1->f('country_2_code'),
"email" => $dbbt->f('user_email'),
"night_phone_b" => $dbbt->f('phone_1'),
"cpp_header_image" => $vendor_image_url,

"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),
"notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",
"cancel_return" => SECUREURL ."index.php",
"undefined_quantity" => "0",

"test_ipn" => PAYPAL_DEBUG,
"pal" => "NRUBJXESJTY24",
"no_shipping" => "1",
"no_note" => "1"
);

if( 
$page == "checkout.thankyou" ) {
$query_string "?";
foreach( 
$post_variables as $name => $value ) {
$query_string .= $name"=" urlencode($value) ."&";
}
vmRedirect$url $query_string );
} else {
echo 
'<form action="'.$url.'" method="post" target="_blank">';
echo 
'<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" alt="Click to pay with PayPal - it is fast, free and secure!" />';

foreach( 
$post_variables as $name => $value ) {
echo 
'<input type="hidden" name="'.$name.'" value="'.htmlspecialchars($value).'" />';
}
echo 
'</form>';

}
?>

Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: muffin on June 01, 2011, 16:31:29 PM
Hi there,

I've recently encountered this problem on a site I'm working on. Can someone please tell me if the above fix posted by webgobe works, and where I am supposed to put it? What is the file that needs to be edited ?

Thanks
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: webgobe on June 01, 2011, 17:21:27 PM
VirtueMart PAyment methods>PayPal>second tab with Virtue Mart Payment extra info box. CopyPaste the above code to replace what you have there.
Title: Re: Multi-currency store : wrong currency on paypal interface
Post by: jameel on June 09, 2011, 05:40:15 AM
Solution to your problem is here please check Paypal Payment module (multicurrency), get your copy

http://www.itechshop.org/index.php?option=com_virtuemart&page=shop.product_details&flypage=flypage.tpl&product_id=11


check the feedback by users
http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-payment-systems/16586