anth wrote
Having a few issues with PayPal module.
Doesn't always work for customers. No idea why but customers say it looks like it's gone through but our system shows the order but with no status. Here is error log.
ERROR - 2016-04-17 20:12:20 --> PayPalExpress::setExpressCheckout Error -->20194: 10401: Order total is invalid.
ERROR - 2016-04-17 20:12:35 --> PayPalExpress::setExpressCheckout Error -->20194: 10401: Order total is invalid.
ERROR - 2016-04-17 20:13:41 --> PayPalExpress::setExpressCheckout Error -->20194: 10401: Order total is invalid.
ERROR - 2016-04-17 20:13:42 --> PayPalExpress::setExpressCheckout Error -->20194: 10401: Order total is invalid
Hi,
I have this issue as well and debugging it a bit it seems like I found the culprit. If you have tax/vat set, then it seems that the total float number is sent using more than 2 decimal places sometimes which causes that error message.
I fixed it by rounding total to 2 decimal places:
//tastyigniter\extensions\paypal_express\models\Paypal_model.php
//Line 71
if ($this->cart->order_total() > 0) {
$nvp_data .= '&PAYMENTREQUEST_0_AMT='. urlencode(round($this->cart->order_total(), 2, PHP_ROUND_HALF_UP));
}
But then there's another error that appeared after that fix:
ERROR - 2017-04-23 21:56:13 --> PayPalExpress::setExpressCheckout Error -->20002: 10413: The totals of the cart item amounts do not match order amounts.
And to fix that I added this code right after the above line
if ($this->cart->tax_amount()) {
$nvp_data .= '&PAYMENTREQUEST_0_TAXAMT=' . urlencode(round($this->cart->tax_amount(), 2, PHP_ROUND_HALF_UP));
}
sampoyigi, how does one contribute code for this kind of stuff? I am a developer but never contributed code to a repository before.