Post by Mister G » Tue Dec 12, 2017 9:30 pm

How to include INR currency in "PayPal Express Checkout" for Opencart V3 ?

- Gomzie >:D


.
Last edited by Mister G on Wed Dec 13, 2017 2:50 pm, edited 2 times in total.

Newbie

Posts

Joined
Mon Dec 11, 2017 7:35 pm

Post by straightlight » Tue Dec 12, 2017 9:47 pm

Which PayPal ... ?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Mister G » Wed Dec 13, 2017 2:49 pm

PayPal Express Checkout

- Gomzie >:D

Newbie

Posts

Joined
Mon Dec 11, 2017 7:35 pm

Post by straightlight » Wed Dec 13, 2017 10:20 pm

What must it do if the INR currency is selected from checkout? More information is needed.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Mister G » Sun Dec 17, 2017 1:07 pm

It must accept the amount in INR and convert to USD for the user to view and proceed to pay

Newbie

Posts

Joined
Mon Dec 11, 2017 7:35 pm

Post by straightlight » Sun Dec 17, 2017 11:17 pm

The only problem by doing that is that the converted product prices may also appear on the PayPal invoice compared to the prices that were previously showed on your store before buying the goods. However, if you want to give this a try with your sandbox account, in your catalog/controller/extension/payment/pp_express.php file (untested),

find:

Code: Select all

protected function validateCoupon() {
add above:

Code: Select all

protected function convertCurrencies($currency) {
	$list = array('INR',
			  );
			  
	if ($this->currency->has($currency) && in_array($currency, $list)) {
		return true;
	}
}
find:

Code: Select all

$price = $this->currency->format($unit_price, $this->session->data['currency']);
				$total = $this->currency->format($unit_price * $product['quantity'], $this->session->data['currency']);
replace with:

Code: Select all

$price = ($this->convertCurrencies($this->session->data['currency']) ? $this->currency->format($this->currency->convert($unit_price, $this->session->data['currency'], 'USD'), $this->session->data['currency']) : $this->currency->format($unit_price, $this->session->data['currency']));
				$total = ($this->convertCurrencies($this->session->data['currency']) ? $this->currency->format($this->currency->convert($unit_price, $this->session->data['currency'], 'USD') * $product['quantity'], $this->session->data['currency']) : $this->currency->format($unit_price * $product['quantity'], $this->session->data['currency']));
Then, find:

Code: Select all

$recurring_price = $this->currency->format($this->tax->calculate($product['recurring']['trial_price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
replace with:

Code: Select all

$recurring_price = ($this->convertCurrencies($this->session->data['currency']) ? $this->currency->format($this->tax->calculate($this->currency->convert($product['recurring']['trial_price'], $this->session->data['currency'], 'USD') * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']) : $this->currency->format($this->tax->calculate($product['recurring']['trial_price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']));
Then, find:

Code: Select all

$recurring_price = $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
replace with:

Code: Select all

$recurring_price = ($this->convertCurrencies($this->session->data['currency']) ? $this->currency->format($this->tax->calculate($this->currency->convert($product['recurring']['price'], $this->session->data['currency'], 'USD') * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']) : $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']));
Then, find:

Code: Select all

'text'  => $this->currency->format($total['value'], $this->session->data['currency']),
replace with:

Code: Select all

'text'  => ($this->convertCurrencies($this->session->data['currency']) ? $this->currency->format($this->currency->convert($total['value'], $this->session->data['currency'], 'USD'), $this->session->data['currency']) : $this->currency->format($total['value'], $this->session->data['currency'])),
Then, find:

Code: Select all

'price'      => $product['price'],
					'total'      => $product['total'],
					'tax'        => $this->tax->getTax($product['price'], $product['tax_class_id']),
replace with:

Code: Select all

'price'      => ($this->convertCurrencies($this->session->data['currency']) ? $this->currency->convert($product['price'], $this->session->data['currency'], 'USD'): $product['price']),
'total'      => ($this->convertCurrencies($this->session->data['currency']) ? $this->currency->convert($product['total'], $this->session->data['currency'], 'USD'): $product['total']),
'tax'        => ($this->convertCurrencies($this->session->data['currency']) ? $this->tax->getTax($this->currency->convert($product['price'], $this->session->data['currency'], 'USD'), $product['tax_class_id']) : $this->tax->getTax($product['price'], $product['tax_class_id'])),

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Mister G » Tue Dec 26, 2017 9:01 pm

Changed the file exactly as recommended in above codes for replacements and additions.

It still gives a validation / error as shown below :
Currency is not supported.

Even if a solution converts INR to USD and paypal payment is processed in USD its fine.
Kindly suggest

Newbie

Posts

Joined
Mon Dec 11, 2017 7:35 pm

Post by straightlight » Tue Dec 26, 2017 9:14 pm

Currency is not supported.
This message is provided by PayPal's response, not by OC.

Followed are a list of allowed currency codes: https://developer.paypal.com/docs/class ... ncy_codes/ . Followed is also alternative used with Shopify: https://ecommerce.shopify.com/c/ecommer ... age-484398 . You might want to try the same with Opencart noticing if it does solve the issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Mister G » Wed Dec 27, 2017 3:09 am

Thanks for the reply

If my display currency on website is INR, can u help that in someway while I proceed to checkout it displays the corresponding USD.
Since as we see here INR is not supported by PayPal.

Newbie

Posts

Joined
Mon Dec 11, 2017 7:35 pm

Post by straightlight » Wed Dec 27, 2017 4:29 am

If my display currency on website is INR, can u help that in someway while I proceed to checkout it displays the corresponding USD.
By doing that, the outputted amount would be differed from the customer's currency preferences on your store as a converted amount would be shown rather than the demonstrated amount before the converted amount has been made on the invoice.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Wed Dec 27, 2017 4:45 am

Additional information about this statement:
PayPal doesn't support Indian currency so far. My best guess would be to be use 'USD' as the currency. PayPal will itself convert it to 'INR' and send it to your bank account.

You cannot maintain an INR balance on PayPal account due to some local regulations, instead your balance is automatically swept to your local bank account.

Your customers will pay in USD, you'll receive USD, PayPal will convert USD to INR and send to your bank account.
Source: https://build.ooo/code/34178751/paypal- ... y-checkout

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 422 guests