Getting Order/Invoice currency to Paypal payment

Hi team

i have the multicurrency module. Chilean peso as default for local customers and US dollar for international customer and suppliers.

When I issue a dollar order to a client, The PayPal link does not work because the currency passes as Chilean peso.

if I look at the order table, the currency established for this order is dollar:

But payment link does not receive the currency of the order but the default currency:

Captura_LINK.png

Of course, Paypal does not support the Chilean peso as payment currency :whistle:

Is there any way to establish that the payment link to PayPal get the currency of the order or invoice instead of the default currency?

I found a solution for my requirement.
I am interested in payment orders and invoices by PayPal only. I explain below in case it is helpful for others in the future:

1- Open htdocs/public/payment/newpayment.php

2- For ORDERS … go to line 809:

	
if ($action != 'dopayment') // Do not change amount if we just click on first dopayment
	{
		$amount=$order->total_ttc;
		if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
		$amount=price2num($amount);
	}

3- Select line 811:

		$amount=$order->total_ttc;

4- Replace by:

		if (!empty($conf->multicurrency->enabled) && ($order->multicurrency_code != $conf->currency))
		{
			// Multicurrency Amount TTC
			$amount=$order->multicurrency_total_ttc;
			$currency=$order->multicurrency_code;
		} else {
				$amount=$order->total_ttc;
		}

5- For INVOICES … go to line 948

	if ($action != 'dopayment') // Do not change amount if we just click on first dopayment
	{
		$amount=price2num($invoice->total_ttc - $invoice->getSommePaiement());
		if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
		$amount=price2num($amount);
	}

6- Select line 950:

		$amount=price2num($invoice->total_ttc - $invoice->getSommePaiement());

7- Replace by:

		if (!empty($conf->multicurrency->enabled) && ($order->multicurrency_code != $conf->currency))
		{
			// Multicurrency Amount TTC
			$amount=$invoice->multicurrency_total_ttc;
			$currency=$invoice->multicurrency_code;
		} else {
				$amount=$invoice->total_ttc;
		}

Result is:

The default currency of the company is Chilean peso but when issuing orders or invoices to clients whose currency is dollar, the payment form takes the currency of the document and not the currency of the company:

Captura_ok.png

NOTE: I still need to include the necessary code in paymentok.php and paymentko.php but I will update the post as soon as I finish it

Regards :wink:

1 Like

Hi Richard,

Greetings. Could you change on paymentok.php …

Kindly post whether you could achieve the goal in its totality.

thanks
yesbee

@ksar @eldy

Hi Ksar / eldy,

This seem to be very important feature since paypal doesnot allow currency of same country as a policy.

I have checked even in V15.0.0, and found it still takes up the total_ttc and not multicurrency_total_ttc.

Can you kindly guide how to get multi currency implemented for paypal…?

thanks
yesbee

Hi Rise,

I made the necessary changes to paymentok.php but forgot to update this post. Sorry about that.

Many of the modifications I have are backed up because I have never shared them to git and every update overwrites them. I don’t really use it but I will do it as soon as possible.

Regards

Hi Richard,

Thank you for the message. Can you kindly share the paymentok.php and paymentko.php if they are modified please.

thanks and regards,
yesbee