0

I have integrated PayPal to my website and PayPal does not support Base currency INR and support if Base Currency US Dollar.

Partial Working Method:

app\code\core\Mage\Paypal\Model\Express\Checkout.php

$this->_api->setAmount($this->_quote->getBaseGrandTotal())
            ->setCurrencyCode($this->_quote->getBaseCurrencyCode())
            ->setInvNum($this->_quote->getReservedOrderId())
            ->setReturnUrl($returnUrl)
            ->setCancelUrl($cancelUrl)
            ->setSolutionType($solutionType)
            ->setPaymentAction($this->_config->paymentAction);

Just replace the below code:

$this->_api->setAmount($this->_quote->getBaseGrandTotal())
            ->setCurrencyCode('USD')
            ->setInvNum($this->_quote->getReservedOrderId())
            ->setReturnUrl($returnUrl)
            ->setCancelUrl($cancelUrl)
            ->setSolutionType($solutionType)
            ->setPaymentAction($this->_config->paymentAction);

this one is working but the price Rs.70 displayed like $70 at my PayPal payment page. How to solve this issue?

How to convert the price from Base Currency to USD at PayPal payment?

  • Do you have usd currency in your store – Athul Vijayan Jul 26 '17 at 8:16
  • No, my store running in INR, paypal not support if base currency INR, if i change US Dollar paypal working, and above error also occurred. – user51361 Jul 26 '17 at 10:25
  • You need to do currency conversion to archive this. – zus Mar 31 '18 at 9:37
0

Magento has a lot of functionality to convert currency. It is designed as a multi-lingual and multi-currency application.

The easiest way to convert from the base currency into the current selected store currency is with the following code:

$amount = Mage::app()->getStore()->convertPrice($baseAmount, false, false);

You can also use the directory helper:

/* @var $helper Mage_Directory_Helper_Data */
$helper = Mage::helper('directory');

// second param = 'from', third param = 'to'
$amount = $helper->currencyConvert($amount, 'USD', 'EUR');

To make sure your currency exchange rates are up to date, you need to enable cron for the magento website and make sure that the schedule imports are enabled:

Magento Admin > System Config > Currency Setup > Scheduled Import Settings

To answer the specific question about Paypal, look at this link.

-1

if you are not using the USD as a currency in your store you can use this code for conversion.

    $from_Currency='INR';
    $to_Currency='USD';
    $amount = urlencode('100');
    $from_Currency = urlencode($from_Currency);
    $to_Currency = urlencode($to_Currency);
    $url = "http://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency";

    $ch = curl_init();
    $timeout = 0;
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $rawdata = curl_exec($ch);
    curl_close($ch);
    $data = explode('bld>', $rawdata);
    if(count($data) < 2){
        $data[1] = '';
    }
    $data = explode($to_Currency, $data[1]);

If you are using the USD as a currency in your store then you can use.

Mage::app()->getLocale()->currency('USD')->toCurrency($price);
  • where i can i apply this code – user51361 Jul 26 '17 at 10:23
  • Before this $this->_api->setAmount($this->_quote->getBaseGrandTotal()). and on my code $amount = urlencode($this->_quote->getBaseGrandTotal()); and change $this->_api->setAmount($this->_quote->getBaseGrandTotal()) to $this->_api->setAmount($data) – Athul Vijayan Jul 26 '17 at 11:02
  • May i know what is the error is this. – user51361 Jul 26 '17 at 11:21
  • this is the error : stackoverflow.com/a/28105993/5906850 – user51361 Jul 26 '17 at 11:44
  • -1 because you should be using default Magento functionality for currency conversion instead of a Google API. – Phil M Nov 27 '17 at 17:45
-1

As you need the complete solution goes here,

$from_Currency='INR';
$to_Currency='USD';
$amount = urlencode($this->_quote->getBaseGrandTotal());
$from_Currency = urlencode($from_Currency);
$to_Currency = urlencode($to_Currency);
$url = "http://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency";

$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$rawdata = curl_exec($ch);
curl_close($ch);
$data = explode('bld>', $rawdata);
if(count($data) < 2){
    $data[1] = '';
}
$priceinusd = explode($to_Currency, $data[1]);
$this->_api->setAmount($priceinusd)
        ->setCurrencyCode('USD')
        ->setInvNum($this->_quote->getReservedOrderId())
        ->setReturnUrl($returnUrl)
        ->setCancelUrl($cancelUrl)
        ->setSolutionType($solutionType)
        ->setPaymentAction($this->_config->paymentAction);

Try this

  • i get error like : PayPal gateway has rejected request. The totals of the cart item amounts do not match order amounts (#10413: Transaction refused because of an invalid argument. See additional error messages for details). – user51361 Jul 26 '17 at 11:14
  • They are saying that your order total not matching with the amount you are passing here. So you have to modify the code in the request of paypal for the payment. – Athul Vijayan Jul 26 '17 at 12:38
  • could you pls help me for that – user51361 Jul 26 '17 at 13:21
  • now everything okay, currency conversion is the only problem. – user51361 Jul 26 '17 at 13:33
  • You can use my code for conversion – Athul Vijayan Jul 27 '17 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy