1

I have magento2 with base currency NPR I want to use Paypal as another payment option. where as papal doesn't support NPR i want to pay it in droller.

for that I have added "NPR" in $_supportedCurrencyCodes variable in vendor/magento/module-paypal/Model/Config.php

add logic for sending currency code "USD" instead of "NPR" and change amount to USD in vendor/magento/module-paypal/Model/Express/Checkout.php in "start" function while checkout it give me error for Paypal doesn't support for shipping to Nepal. Is their any way to resolve this?

3

Here is the example of use AED currency in PayPal. You can use same for other currencies.

Follow this step to support other currencies in paypal:

1) Override Config.php and Nvp.php

app/code/{Vendor}/{Module}/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Paypal\Model\Config" type="{Vendor}\{Module}\Model\Magento\Paypal\Config" />
    <preference for="Magento\Paypal\Model\Api\Nvp" type="{Vendor}\{Module}\Model\Magento\Paypal\Api\Nvp" />
</config>

2) Add your currency in $_supportedCurrencyCodes

app/code/{Vendor}/{Module}/Model/Magento/Paypal/Config

protected $_supportedCurrencyCodes = [
    'AUD',
    'CAD',
    'CZK',
    'DKK',
    'EUR',
    'HKD',
    'HUF',
    'ILS',
    'JPY',
    'MXN',
    'NOK',
    'NZD',
    'PLN',
    'GBP',
    'RUB',
    'SGD',
    'SEK',
    'CHF',
    'TWD',
    'THB',
    'USD',
    'AED', // Add currency
];

3) Now convert currency amount to USD amount in API request

app/code/{Vendor}/{Module}/Model/Magento/Paypal/Api/Nvp.php

Inject \Magento\Directory\Helper\Data class for convert currency rate

Approx after line: 1175

//print_r($request);

if ($request["METHOD"] == "SetExpressCheckout" || $request["METHOD"] == "DoExpressCheckoutPayment")
{
    if($request['CURRENCYCODE'] == "AED") {

        $payAmt = $request['AMT'];
        $payShippingAmt = $request['SHIPPINGAMT'];
        $payItemAmt = $request['ITEMAMT'];
        $payTaxAmt = $request['TAXAMT'];
        $conAmt = round($this->_currencyHelper->currencyConvert($payAmt, "AED", "USD"), 2);
        $conShippingAmt = round($this->_currencyHelper->currencyConvert($payShippingAmt, "AED", "USD"), 2);
        $conItemAmt = round($this->_currencyHelper->currencyConvert($payItemAmt, "AED", "USD"), 2);
        $conTaxAmt = round($this->_currencyHelper->currencyConvert($payTaxAmt, "AED", "USD"), 2);

        //set converted USD amount to request api

        $request['CURRENCYCODE'] = "USD";
        $request['AMT'] = $conAmt;
        $request['SHIPPINGAMT'] = $conShippingAmt;
        $request['ITEMAMT'] = $conItemAmt;
        $request['TAXAMT'] = $conTaxAmt;
    }
}

Note: set Transfer Cart Line Items to No From

Store->Configuration->Sales->PaymentMethod->Paypal->Configure->Advanced Settings

To pass only order, shipping and tax amount

If you set yes from this config setting. Magento passes all cart item amount to PayPal request and you have to change the logic of converting price.

  • In Magento2.2.4 EE I have edited above files and configured as defined by you. Now on checkout page at order placing time I am getting that message "PayPal gateway has rejected request. Receiving country does not support the transaction currency (#10605: Transaction refused because of an invalid argument. See additional error messages for details)." Please help me what can I do to resolve it. Merchant country = UAE and default currency = AED. – Banvari Lal May 27 at 5:23
1

I've created a simple M2 module to handle this. You can use it https://github.com/zamoroka/Magento-2-Paypal-All-Currencies-extension

0

My base currency is INR and PayPal currency set to USD. On purchasing INR as the base it's working but on switching the currency to USD from frontend currency switcher. Paypal rejects with an error message.Do you have any idea to solve this. My requirement is if the current active currency is USD no need to convert.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.