PayPal Advanced error when fees included in total
-
With an otherwise functioning PayPal advanced gateway i was receiving errors when I added fees to an order.
Fees were added via WC->cart->add_fee() and otherwise worked as expected. However, when a customer goes to pay PayPal Advanced throws this error:
Error: “Field format error: 10413-The totals of the cart item amounts do not match order amounts.”
Looking through the angelleye plugin code I found at line 494 in wc-gateway-paypal-advanced-angelleye.php a choice is made whether to send a list of items or a grand total. It appears if there are discounts or tax issues a total is sent. It did not look like the itemized list of items was being fee adjusted so did not match the total amount of the order.
By adding a test here for fees the plugin works again:
if (($is_prices_include_tax || $order->get_total_discount() > 0 || $length_error > 1) && $order->get_subtotal() > 0) {
becomes
if (($is_prices_include_tax || $order->get_total_discount() > 0 || $length_error > 1)|| count($order->get_fees()) && $order->get_subtotal() > 0) {
Notes:
- this is not fully tested
- i may not correctly understand the uses of fees
- The topic ‘PayPal Advanced error when fees included in total’ is closed to new replies.