Passing Currency to Paypal via redirect plugin

deskelf 08 Feb, 2013
I tried finding a previous post to get the answer, but I was unsuccessful.

My form does a little bit of math and adds up amounts bases on the dropdowns people select. They have the option to get baskets of different prices, and the form calculates the total.

There is a dropdown that allows people to choose a currency, and the form recalculates the total, and gives the equivalent in the other currency.

Right now I can pass everything to paypal in USD, as that is what is in the settings. How do I add extra fields (or using any other method) to send the proper currency to paypal?

My form is currently located at http://www.kollelbaisdovid.com/mm

Thank you very much for your help!
GreyHead 08 Feb, 2013
Hi deskelf,

You don't say how you are linking to PayPal. If you are using the Redirect actions then you should e able to set the PayPal parmeters - I think they are amount and mc_currency

Bob
deskelf 08 Feb, 2013
Hey Bob,

Yes, I am using PayPal Redirect Full.

This is the HTML I am using for the dropdown:
<div class="ccms_form_element cfdiv_select" id="autoID-09ceb33c673b165ca8a1853170ada205_container_div" style=""><label>Desired Currency</label><select size="1" class="" title="" container_id="0" name="currency" onchange="CalculateTotal(this.form)">
<option value="1">Dollars</option>
<option value="2">Pounds</option>
</select>


I have values 1 and 2 so that I can make the math happen. I saw the mc_currency in the paypal docs. I do not know enough php to make it happen correctly, but I understand it in theory. If the value of currency is 2, set mc_currency = GBP, and then have it echo mc_currency.

Does that make sense? How would I code that? Sorry for being such a newbie.😟

Any help you can provide is super appreciated.
deskelf 08 Feb, 2013
In an attempt to not be a total moron newb, I did some research and came up with this:

<?php $currency =  $form->data['currency'] ;
     if ($currency === 2) {
         echo "mc_currency = 'GBP'";
     } else {
	     echo "mc_currency = 'USD'";
	 }
?>


It doesn't work, but let me know if I am on the right track here.
GreyHead 08 Feb, 2013
Hi deskelf,

I'd change the options to make the currency setting easier:
<div class="ccms_form_element cfdiv_select" id="autoID-09ceb33c673b165ca8a1853170ada205_container_div" style="">
  <label>Desired Currency</label>
  <select size="1" class="" title="" container_id="0" name="currency" onchange="CalculateTotal(this.form)">
    <option value="USD">Dollars</option>
    <option value="GBP">Pounds</option>
  </select>
. . .
Then you should be able to put mc_currency=currency in the Extra Options box of the PayPal Redirect action.

switch ( $form->data['currency'] ) {
case 2:
$form->data['mc_currency'] = 'GBP';
break;
case 1:
default:
$form->data['mc_currency'] = 'USD';
break;
}
?>[/code]Then you'd use mc_currency=mc_currency in the Extra Options box.

Bob
deskelf 08 Feb, 2013
Hi Bob,

I tried using
<option value="USD">Dollars</option> and <option value="GBP">Pounds</option> 
but I was not able to figure out how to make the javascript convert the order_total.

Tat is why I switched the values to
<option value="1">Dollars</option> and <option value="2">Pounds</option>


The javascript added up the order_total, and then I wrote this to convert it:
 switchToPounds = parseInt(frm.currency.value)
            if (switchToPounds >= 2) {
                order_total = order_total / 1.57
            }


How do I change this javascript to take into account the values being set to
<option value="USD">Dollars</option> and <option value="GBP">Pounds</option>
?
GreyHead 09 Feb, 2013
Hi deskelf,

The simplest answer is probably to replace this
switchToPounds = parseInt(frm.currency.value)
if (switchToPounds >= 2) {
  order_total = order_total / 1.57
}

with something like this:
if ( $('currency').value == 'GBP' ) {
  order_total = order_total / 1.57;
}

Bob
deskelf 09 Feb, 2013
Hi Bob,

Thanks for getting back to me. That helped me get that math working.

With this as my HTML:
<div class="ccms_form_element cfdiv_select" id="autoID-09ceb33c673b165ca8a1853170ada205_container_div" style=""><label>Desired Currency</label><select size="1" class="" title="" container_id="0" name="currency" onchange="CalculateTotal(this.form)">
<option value="USD">Dollars</option>
<option value="GBP">Pounds</option>
</select>



And with this as my Javascript:
 if ( frm.currency.value == 'GBP' ) {
           order_total = order_total / 1.57;
         }


I was able to get the math working properly. I tried to put mc_currency=currency in the Extra Fields Box. So although my math works fine, not matter what I do, when the browser redirects to PayPal, the amount is always in $. I tried a bunch of different combos, but could not get anything to work. I am stuck unless someone else has any ideas.

Please help!
GreyHead 09 Feb, 2013
Hi deskelf,

Check the PayPal docs to make sure that I have the correct variable names for the currency and amount. Do you have to enable anything in PayPal to let you work in multiple currencies?

I looked at the Plug-in code and I thought that any extra option settings would over-write values in the specific option boxes.

Bob
deskelf 09 Feb, 2013
For ipn I just had to follow the instructions you guys gave me. mc_currency is the proper variable name. I left the currency field blank in the settings. I tried adding currency and mc_currency in the redirect settings. If just said they weren't valid currencies.

Paypal says for the shopping cart you need to set up multiple currencies:
http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html#1070711
but not for the ipn.

From all of the research I have done, it seems like you could accept fund in any currency, whether it is connected to your account or not. If you have never told them you would like to receive funds in a given currency, they will ask you to accept it when it comes, and they hit you with conversion fees. This account in particular is already set to accept both USD and GBP, so it should definitely be able to accept both already.

I feel like this is a pretty important function for the extra field. If I have run into it, I am sure someone will want to do the same eventually. My form is not all that hard core. No matter what I do it goes through as USD, even though USD is not even in the currency field in the PayPal Redirect settings. I left the field blank, hoping to add it in the extra fields.

I am on the tail end of this project, please help me make this happen!
Max_admin 10 Feb, 2013
Hello,

You can enable the debugging mode in the Paypal plugin and check the query string used to go to PayPal, if you can alter this string to force PayPal to accept GBP then please let us know the changes and we can help, any extra parameters you add to that string can be simply added to the extra fields box, and they will be sent to PayPal.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
deskelf 10 Feb, 2013
Hi Max,

Thanks for getting back to me. I enabled debugging, and this is what I got:
https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=blfreilich%40gmail.com&no_shipping=1&no_note=1&return=http%3A%2F%2Fwww.pnineichein.com%2Fform%2Fthank-you¤cy_code=&item_name=Pninei+Chein+Mishloach+Manos&amount=3.18&first_name=&last_name=&address1=&address2=&city=&state=&zip=&country=&night_phone_a=&mc_currency=GBP&


It says GBP in the url, but when trying this without the debugging activated, paypal puts through the transaction in $. You can clearly see that in the image I have attached. It seems like it should be working, but its not. What should we do? I can give you access if you want. You can try it out for yourself: http://www.kollelbaisdovid.com/mm
GreyHead 10 Feb, 2013
Hi deskelf,

The currency code parameter needs to be currency_code, not mc_currency. That works OK
https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=blfreilich%40gmail.com&no_shipping=1&no_note=1&return=http%3A%2F%2Fwww.pnineichein.com%2Fform%2Fthank-you¤cy_code=&item_name=Pninei+Chein+Mishloach+Manos&amount=3.18&first_name=&last_name=&address1=&address2=&city=&state=&zip=&country=&night_phone_a=¤cy_code=GBP&


Bob
deskelf 11 Feb, 2013
Bob,

You totally did it! Thank you so much. I will be sending a couple of beers your way later on today.

DeskElf Team
This topic is locked and no more replies can be posted.