Magento – Magento 1.9.1 Bug? Discount + Tax + Paypal Pro = incorrect total

discountmagento-1.9paypalpaypal-pro

I have a problem with a magento store 1.9.x

I configured tax for the products and i created a coupon code -30%.

When i proceed to Checkout with Paypal Pro, the imports for the products are incorrect.

Example:

Product: 100$ incl. tax
discount40 %: -30$
shipping: 5$
tax: 12.62$
TOTAL tax escl. 62,38
TOTAL: 75$

the Review in Paypal PRo:

Total item: 51,97$
TAX: 12,62$
Shipping: 5$
TOTAL: 69,59

The problem appears only when
– The tax is actived & configured
– Customer use a Coupon Code
– The payment method is PayPal Pro.

If the customer use a different payment method or don't use a coupon code the problem does not occur.

I tested the problem on a clean installations (1.9.0.1 and 1.9.1) and with the same configurations, the problem appears.

It's a reported bug? how do I fix?

Thanks

Best Answer

I think the problem is that discount is calculated AFTER taxation, when paypal tries to calculate it BEFORE. I solved extending the Mage_Paypal_Model_Hostedpro_Request class and adding the hidden tax amount to the tax, resulting in

protected function _getOrderData(Mage_Sales_Model_Order $order)
    {
        $request = array(
            'subtotal'      => $this->_formatPrice($order-getBaseSubtotal()),
            'tax'           => $this->_formatPrice($order->getBaseTaxAmount() + $order->getHiddenTaxAmount()),
            'shipping'      => $this->_formatPrice($order-getBaseShippingAmount()),
            'invoice'       => $order->getIncrementId(),
            'address_override' => 'true',
            'currency_code'    => $order->getBaseCurrencyCode(),
            'buyer_email'      => $order->getCustomerEmail(),
            'discount'         => $this->_formatPrice(
                $order->getBaseGiftCardsAmount()
                + abs($order->getBaseDiscountAmount())
                + $order->getBaseCustomerBalanceAmount()
            ),
        );
...

I'm planning to put everything in an extension if someone is not able to do it. Stay in touch because I could forget about it :D

EDIT Here it is!