Yet another bug with this module.
Now that it seems to be working, I made a test payment and at step 4 from the cart checkout, when select Paypal as method then proceed with the payment, the button takes me to /module/paypal/ecInit?credit_card=0 and then goes back to the checkout page.
With some debug output I saw that the module was passing NULL as currency to Paypal API which does not like it.
The reason for that NULL value is modules/paypal/classes/MethodEC.php in the init() method, near the top:
$currency = $module->getCurrency($context->cart->id_currency);
Which is then used lower:
$items[] = array(
'quantity' => 1,
'name' => $paypal->l('Discount : ').$discount['name'],
'price' => $price_discount,
'currency' => $currency->iso_code,
'description' => strip_tags($discount['description']),
'tax' => $tax_discount,
);
The problem is getCurrency() is coming from /classes/PaymentModule.php
And that method is returning an array of more than one currency (at least in my case because my shop uses two currencies).
However, the code above is expecting a single currency and thus $currency->iso_code returns null.
The name of the function is getCurrency, so one expects this to return a single currency not multiple...
Because I don't know the impact of changing that, I made a fix in MethodEC.php instead.
So I just replaced:
$currency = $module->getCurrency($context->cart->id_currency);
With this:
$currencies = $module->getCurrency($context->cart->id_currency);
foreach ($currencies as $availableCurrency) {
if ((int)$context->cart->id_currency === (int) $availableCurrency['id_currency']) {
$availableCurrency['id'] = $availableCurrency['id_currency'];
$currency = (object) $availableCurrency;
break;
}
}
Then do the same in the validation() method, replace:
$currencies = $paypal->getCurrency($context->currency->id);
with this:
$currencies = $paypal->getCurrency($context->currency->id);
foreach ($currencies as $availableCurrency) {
if ((int)$context->cart->id_currency === (int) $availableCurrency['id_currency']) {
$availableCurrency['id'] = $availableCurrency['id_currency'];
$currency = (object) $availableCurrency;
break;
}
}