PayPal Standard BROKEN when rounding amounts
-
Hello,
First thank you for such a great add on to WP.
I am using WP 3.8.1 and WC 2.1.1
I am using Standard Tax Rates and PayPal Standard in sandbox. My tax rate is 8.3500 % and is applied to shipping.
When the shopping cart calculates the tax it displays this ROUNDED UP to two decimal places. For instance:
Cart Subtotal = $1
S&H = $14.42
MO Tax = $1.20
ORDER TOTAL = $16.71The actual internal amount is $16.7076 and can be seen if you enable four decimal places in the WooCommerce -> Settings -> General Tab.
When you click on the “Place Order” button you are redirected to the PayPal Website to complete your order. Unfortunately, the system is giving PayPal the full four decimal place amount. More unfortunately PayPal DOES NOT ROUND UP and processes the payment for $16.70. This is because PayPal TRUNCATES the extra decimal places.
This of course fails and you receive a: “Payment error: Amounts do not match (gross 16.70)” error.
A little creative code work in class-wc-gateway-paypal.php verifies this. By changing
$this->log->add( 'paypal', 'Payment error: Amounts do not match (gross ' . $posted['mc_gross'] . ')' );
to
$this->log->add( 'paypal', 'Payment error: Amounts do not match (requested '. $order->get_total() . ' and received ' . $posted['mc_gross'] . ')' );
I am now able to see the following error in the log file:
Payment error: Amounts do not match (requested 16.71 and received 16.70)
So I thought I would just set the system to four decimal places under the general tab. But then the tax amount is dropped in PayPal because PayPal does not recognize a tax amount with four decimal places.
Any help on this would be greatly appreciated!
Brett
- The topic ‘PayPal Standard BROKEN when rounding amounts’ is closed to new replies.