Currency convertion on payment plugin
10 years 5 months ago - 10 years 5 months ago #237424
by ghiamar
Currency convertion on payment plugin was created by ghiamar
-- HikaShop version -- : 2.6.0
-- Joomla version -- : 3.4.8
-- PHP version -- : 5.6.20
-- Browser(s) name and version -- : firefox 45
-- Error-message(debug-mod must be tuned on) -- : none
Hi, I have developed a payment plugin for south american MercadoPago gateway, and I wonder if I can convert the currency of the whole cart to the currency expected by the gateway, that differs from the cart currency.
IE: I have a product valued u$s10 but if I choose MercadoPago payment I expect that value to be converted to BRL for example, which is $35 BRL. Is that possible using the built in currency converter?
Thanks in advise
-- Joomla version -- : 3.4.8
-- PHP version -- : 5.6.20
-- Browser(s) name and version -- : firefox 45
-- Error-message(debug-mod must be tuned on) -- : none
Hi, I have developed a payment plugin for south american MercadoPago gateway, and I wonder if I can convert the currency of the whole cart to the currency expected by the gateway, that differs from the cart currency.
IE: I have a product valued u$s10 but if I choose MercadoPago payment I expect that value to be converted to BRL for example, which is $35 BRL. Is that possible using the built in currency converter?
Thanks in advise
Last edit: 10 years 5 months ago by ghiamar.
Please Log in or Create an account to join the conversation.
10 years 5 months ago #237430
by nicolas
Replied by nicolas on topic Currency convertion on payment plugin
Hi,
Yes. Usually what you do is that you disable the USD currency but keep it displayed and configure BRL as the main currency. That way, when the customer browse the website with the USD currency and then arrives on the checkout, the system automatically converts the prices to BRL.
If you want to convert a price in your code using the currency converter system in place, you can do like that:
Yes. Usually what you do is that you disable the USD currency but keep it displayed and configure BRL as the main currency. That way, when the customer browse the website with the USD currency and then arrives on the checkout, the system automatically converts the prices to BRL.
If you want to convert a price in your code using the currency converter system in place, you can do like that:
Code:
$class = hikashop_get('class.currency');
$srcCurrency = $class->get('USD');
$dstCurrency = $class->get('BRL');
$convertedPrice = $class->convertUniquePrice($price, $srcCurrency->currency_id, $dstCurrency->currency_id);
The following user(s) said Thank You: ghiamar
Please Log in or Create an account to join the conversation.
10 years 5 months ago #237699
by ghiamar
Replied by ghiamar on topic Currency convertion on payment plugin
Thanks! it turns out that I already applyed that code before, but for some reason it doesn't convert the ammount, just let me double check my setup and will ask if I found something.
Thanks again!
Thanks again!
Please Log in or Create an account to join the conversation.
10 years 5 months ago #237732
by ghiamar
Thanks a lot!
Replied by ghiamar on topic Currency convertion on payment plugin
I confirm this snippet does the trick, I already had in my payment plugin, but I have set a product with several currencyes and that was causing the issue.nicolas wrote: Hi,
Code:$class = hikashop_get('class.currency'); $srcCurrency = $class->get('USD'); $dstCurrency = $class->get('BRL'); $convertedPrice = $class->convertUniquePrice($price, $srcCurrency->currency_id, $dstCurrency->currency_id);
Thanks a lot!
Please Log in or Create an account to join the conversation.
Time to create page: 0.190 seconds