VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: panjarek on May 08, 2019, 14:16:57 PM

Title: PayPal Standard wrong email currency
Post by: panjarek on May 08, 2019, 14:16:57 PM
Hello,

I use PayPal Standard in a multi currency store. I allowed users to pay in selected currency via currency module and I set email currency as "Payment currency" in PayPal payment method settings. The problem is with emails, users receive amounts in shop currency not in payment currency. In emails there is only information "Exchange rate and total in payment currency" with total amount in payment currency. Is this correct behavior? I would like to have all amount in payment currency not only total value. Does anyone have solution for it? I didn't find any solution in this forum.

VirtueMart 3.2.14 (I tested newer version and have the same results)
Joomla! 3.9.5   

Kind regards
Jarek
Title: Re: PayPal Standard wrong email currency
Post by: panjarek on May 15, 2019, 22:16:19 PM
I found that code from method getPaymentCurrency in class plgVmPaymentPaypal in paypal.php, returns wrong currency while sending notification to user. Has someone any suggestions how can I correct it?


$mainframe = JFactory::getApplication();
$selectedUserCurrency = $mainframe->getUserStateFromRequest( "virtuemart_currency_id", 'virtuemart_currency_id', vRequest::getInt( 'virtuemart_currency_id', $vendor_currencies['vendor_currency'] ) );
Title: Re: PayPal Standard wrong email currency
Post by: panjarek on May 17, 2019, 09:31:39 AM
I noriced that during notification sending, method plgVmgetEmailCurrency of class plgVmPaymentPaypal has on input correct email currency ( $emailCurrencyId parameter ) and change it to a wrong one by calling getEmailCurrency method. I changed plgVmgetEmailCurrency as below and it seems to solve the problem. Maybe someone knows the logic behind, why it works it that way?


function plgVmgetEmailCurrency($virtuemart_paymentmethod_id, $virtuemart_order_id, &$emailCurrencyId) {

if (!($method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
return NULL; // Another method was selected, do nothing
}
if (!$this->selectedThisElement($method->payment_element)) {
return FALSE;
}
/*if (!($payments = $this->_getPaypalInternalData($virtuemart_order_id))) {
// JError::raiseWarning(500, $db->getErrorMsg());
return '';
}*/

//added - begin
if ( empty($emailCurrencyId) ) {
$emailCurrencyId = $this -> getEmailCurrency($method);
}
//added - end

return $emailCurrencyId;
}