Sending a Paypal-accepted currency amount in Bakery

Ruud

Quote from: hillschmidt on May 22, 2013, 10:40:07 AM
Just to give an idea what's possible!
It might be hard to find a public/free feed with the GTQ exchangerate.

Alternative (a bit dirty solution) you could place a small file (i.e. in the media folder) that holds the current rate.

Upload in your /media folder a file called "rate.txt" with the content 7.85 (so just the current rate, nothing else..)

Somewhere just before creating the array with data to send
Code (untested) Select
$rate = floatval(file_get_contents(WB_PATH.MEDIA_DIRECTORY'./rate.txt'));
and next calculate the rate like:
Code (untested) Select
'amount'        => round($_SESSION['bakery']['order_total'] / $rate , 2),

The tricky part is that there may never be any error in the "rate.txt" file, or the payment will crash or use a wrong amount.
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]


svsanchez

Yes! It worked perfectly! One last question, in this solution the exchange rate is written in the code, is there a way to call the exchange rate somehow so that the site administrator doesn't have to mess with the code?

Ruud

In the file /modules/bakery/payment_methods/paypal/processor.php you can find these two lines:
Code (original) Select

'currency_code' => $setting_shop_currency,
'amount'        => $_SESSION['bakery']['order_total'],


You can overrule the currency code to "USD" and fill the amount with a calculated USD price.
Something like:
Code (untested) Select

'currency_code' => 'USD',
'amount'        => round ($_SESSION['bakery']['order_total'] / 7.85 , 2),


This way it will never show USD in the website, only the transaction data sent to PayPal will be in USD
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

svsanchez

Hello community, I think this one could be a little hard:

I have a customer who is creating his Bakery shop and he uses the local currency (Guatemalan Quetzal). He will accept Paypal (which doesn't accept Quetzals) and also Advance Payment and Invoice Payment. He wants to show his prices in Guatemalan Quetzals by default, and ONLY use US Dollars if the user selects to pay by Paypal. Is it possible to convert the amount that Bakery will send to Paypal from the local currency to USD at the checkout?

I didn't tell him this wasn't possible as this little software always has something new to amaze me.