简体   繁体   English

如何在opencart中传递给paypal之前将INR转换为USD

[英]How to convert INR to USD before passing to paypal in opencart

I have tried this below code in catalog/controller/payment/pp_standard.php . 我已经在catalog/controller/payment/pp_standard.php尝试了以下代码。 it works fine. 它工作正常。 For example, My product rate is 2450 INR. 例如,我的产品费率为2450 INR。 When I choose paypal option it would convert the INR rate into USD rate and then it would redirect to paypal.com successfully. 当我选择Paypal选项时,它将INR汇率转换为USD汇率,然后成功重定向到paypal.com。

But, I have enabled paypal express checkout also. 但是,我也启用了贝宝快速结帐。 So, When I choose paypal express checkout option it doesn't redirect to paypal.com. 因此,当我选择Paypal Express Checkout选项时,它不会重定向到paypal.com。 because of currency problem (I get currency is not supporrted error). 由于货币问题(我收到货币不支持的错误)。 How do I convert the INR currency to USD currency before passing to paypal in opencart? 在opencart中传递给Paypal之前,如何将INR货币转换为USD货币?

Note : I need a solution for Paypal Express Checkout catalog/controller/payment/pp_express.php & catalog/model/payment/pp_express.php 注意 :我需要一个针对Paypal Express Checkout catalog/controller/payment/pp_express.phpcatalog/model/payment/pp_express.php

$currencies = array(
                'AUD',
                'CAD',
                'EUR',
                'GBP',
                'JPY',
                'USD',
                'NZD',
                'CHF',
                'HKD',
                'SGD',
                'SEK',
                'DKK',
                'PLN',
                'NOK',
                'HUF',
                'CZK',
                'ILS',
                'MXN',
                'MYR',
                'BRL',
                'PHP',
                'TWD',
                'THB',
                'TRY'
             );

             if (!in_array(strtoupper($this->currency->getCode()), $currencies))
             {
                $order_info['currency_code'] = 'USD';
             }

Applying the same code after: 在以下位置应用相同的代码:

$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);

and adding one extra line, 并增加一行

$order_info['total'] = $this->currency->format($order_info['total'], $order_info['currency_code'], false, false);

should work just fine. 应该工作正常。

PS. PS。 I have not tested it, but you should be fine :D 我没有测试过,但是你应该没问题:D

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM