Paypal support for INR

Opening for Office assistant cum Data Entry operator
February 5, 2016
web page designing
Getting 404 error after migrating wordpress websites in to new hosting
March 30, 2016
Opening for Office assistant cum Data Entry operator
February 5, 2016
web page designing
Getting 404 error after migrating wordpress websites in to new hosting
March 30, 2016
Show all

Paypal support for INR

paypal

Multi-currency and Paypal compatibility is the biggest problem we will face while developing Woocommerce store.

When we switching currency to INR paypal payment gateway will disabled automatically – because paypal doesn’t support Indian rupees.

paypal1

 

 

 

 

 

Solution –

Add custom php code in to function.php file of theme

Code –

/*————————————-*/

add_filter( ‘woocommerce_paypal_supported_currencies’, ‘add_paypal_valid_currency’ );

function add_paypal_valid_currency( $currencies ) {

array_push ( $currencies , ‘INR’ ); /* YOUR CURRENCY */

return $currencies;

}

/*————————————-*/

Now we added INR also to supported currency list of paypal. Next we need to convert value automatically when we moving to paypal page from INR to USD because INR not included in the paypal supported currency list.

/*————————————-*/

function woocommerce_paypal_args_for_inr($paypal_args){

if ( $paypal_args[‘currency_code’] == ‘INR’){

$convert_rate = getFromYahoo();

$count = 1;

while( isset($paypal_args[‘amount_’ . $count]) ){

$paypal_args[‘amount_’ . $count] = round( $paypal_args[‘amount_’ . $count] / $convert_rate, 2);

$count++;

}

$paypal_args[‘tax_cart’] = round( $paypal_args[‘tax_cart’] / $convert_rate, 2);

}

return $paypal_args;

}

add_filter(‘woocommerce_paypal_args’, ‘woocommerce_paypal_args_for_inr’);

function getFromYahoo()

{

$from   = ‘USD’; /*change it to your required currencies */

$to     = ‘INR’;

$url = ‘http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=’. $from . $to .’=X’;

$handle = @fopen($url, ‘r’);

 

if ($handle) {

$result = fgets($handle, 4096);

fclose($handle);

}

$allData = explode(‘,’,$result); /* Get all the contents to an array */

return $allData[1];

}

/*————————————-*/

Logic –

  • first we fetching all values in store
  • converting INR to USD based on yahoo finance
  • Modifying the paypal arguments according to USD

 

That’s it

Like this we can add any unsupported currencies to paypal.

For Customization help please contact us

 

1 Comment

  1. اغاني says:

    Hi there,I read your blog named “Paypal support for INR | Fajr Technologies” like every week.Your humoristic style is awesome, keep up the good work! And you can look our website about اغاني.

Leave a Reply

Your email address will not be published. Required fields are marked *