2 deleted 26 characters in body
source | link

Solution by DKNZDESIGN

The problem is that Paypal takes the discount amount including tax and subtracts from the subtotal excluding tax. EG:
Magento
(Subtotal Incl Tax $28.80)
Orig Subtotal Excl Tax $27.30
Discount (10%) ($2.88) - MAGENTO TAKES DISCOUNT THEN APPLIES TAX AFTERWARD

(NEW SUBTOTAL INC TAX $25.92)
NEW SUBTOTAL EXCL TAX $24.57
Tax (5.5%) $1.35
Grand Total $25.92

Paypal
ORIG Subtotal Excl Tax $27.30
Discount ($2.88) -THIS AMOUNT CONTAINS TAX
Tax (5.5%) $1.35
Grand Total $25.77
(This amount to less than the expected grand total and triggers a fraud warning)


So The discount sent to Paypal includes tax, we have to calculate Discount without tax and send THAT amount in the request. This problem only occurs for the Hosted Paypal Solution
Sooooo... go to:
App/code/core/Mage/Paypal/Hostedpro?Request.php
Around Line 156
Find the function _getOrderData()

add these lines at the begining of the function

$origDiscount=$order->getBaseGiftCardsAmount()
                + abs($order->getBaseDiscountAmount())
                + $order->getBaseCustomerBalanceAmount();
$RealDiscount = $origDiscount ;
if($origDiscount>0){
                    $gt=$order->getGrandTotal();//grandtotal
                    $st=$order->getBaseSubtotal();//subwithouttax
                    $tx=$order->getBaseTaxAmount();//tax
                    $sp=$order->getBaseShippingAmount();//shipping
                    //Figure out Discount using Grand Total
                    $RealDiscount=$st+$tx+$sp-$gt;
                 }

Then in the $request array change these lines: (around Lines 166 to 169)

'discount'         => $this->_formatPrice(
                $order->getBaseGiftCardsAmount()
                + abs($order->getBaseDiscountAmount())
                + $order->getBaseCustomerBalanceAmount()

To This:

 'discount'         => $this->_formatPrice($RealDiscount)

OK remember you should not really alter core files so you can put that whole document in the local code pool, or a better way is to override the function with a module.

The real discount has been calculated in a fail safe way that uses the formula: Subtotal Excl Tax
+
Shipping Cost
+
Tax
-
(Discount)
=
Grandtotal

Solution by DKNZDESIGN

The problem is that Paypal takes the discount amount including tax and subtracts from the subtotal excluding tax. EG:
Magento
(Subtotal Incl Tax $28.80)
Orig Subtotal Excl Tax $27.30
Discount (10%) ($2.88) - MAGENTO TAKES DISCOUNT THEN APPLIES TAX AFTERWARD

(NEW SUBTOTAL INC TAX $25.92)
NEW SUBTOTAL EXCL TAX $24.57
Tax (5.5%) $1.35
Grand Total $25.92

Paypal
ORIG Subtotal Excl Tax $27.30
Discount ($2.88) -THIS AMOUNT CONTAINS TAX
Tax (5.5%) $1.35
Grand Total $25.77
(This amount to less than the expected grand total and triggers a fraud warning)


So The discount sent to Paypal includes tax, we have to calculate Discount without tax and send THAT amount in the request. This problem only occurs for the Hosted Paypal Solution
Sooooo... go to:
App/code/core/Mage/Paypal/Hostedpro?Request.php
Around Line 156
Find the function _getOrderData()

add these lines at the begining of the function

$origDiscount=$order->getBaseGiftCardsAmount()
                + abs($order->getBaseDiscountAmount())
                + $order->getBaseCustomerBalanceAmount();
$RealDiscount = $origDiscount ;
if($origDiscount>0){
                    $gt=$order->getGrandTotal();//grandtotal
                    $st=$order->getBaseSubtotal();//subwithouttax
                    $tx=$order->getBaseTaxAmount();//tax
                    $sp=$order->getBaseShippingAmount();//shipping
                    //Figure out Discount using Grand Total
                    $RealDiscount=$st+$tx+$sp-$gt;
                 }

Then in the $request array change these lines: (around Lines 166 to 169)

'discount'         => $this->_formatPrice(
                $order->getBaseGiftCardsAmount()
                + abs($order->getBaseDiscountAmount())
                + $order->getBaseCustomerBalanceAmount()

To This:

 'discount'         => $this->_formatPrice($RealDiscount)

OK remember you should not really alter core files so you can put that whole document in the local code pool, or a better way is to override the function with a module.

The real discount has been calculated in a fail safe way that uses the formula: Subtotal Excl Tax
+
Shipping Cost
+
Tax
-
(Discount)
=
Grandtotal

The problem is that Paypal takes the discount amount including tax and subtracts from the subtotal excluding tax. EG:
Magento
(Subtotal Incl Tax $28.80)
Orig Subtotal Excl Tax $27.30
Discount (10%) ($2.88) - MAGENTO TAKES DISCOUNT THEN APPLIES TAX AFTERWARD

(NEW SUBTOTAL INC TAX $25.92)
NEW SUBTOTAL EXCL TAX $24.57
Tax (5.5%) $1.35
Grand Total $25.92

Paypal
ORIG Subtotal Excl Tax $27.30
Discount ($2.88) -THIS AMOUNT CONTAINS TAX
Tax (5.5%) $1.35
Grand Total $25.77
(This amount to less than the expected grand total and triggers a fraud warning)


So The discount sent to Paypal includes tax, we have to calculate Discount without tax and send THAT amount in the request. This problem only occurs for the Hosted Paypal Solution
Sooooo... go to:
App/code/core/Mage/Paypal/Hostedpro?Request.php
Around Line 156
Find the function _getOrderData()

add these lines at the begining of the function

$origDiscount=$order->getBaseGiftCardsAmount()
                + abs($order->getBaseDiscountAmount())
                + $order->getBaseCustomerBalanceAmount();
$RealDiscount = $origDiscount ;
if($origDiscount>0){
                    $gt=$order->getGrandTotal();//grandtotal
                    $st=$order->getBaseSubtotal();//subwithouttax
                    $tx=$order->getBaseTaxAmount();//tax
                    $sp=$order->getBaseShippingAmount();//shipping
                    //Figure out Discount using Grand Total
                    $RealDiscount=$st+$tx+$sp-$gt;
                 }

Then in the $request array change these lines: (around Lines 166 to 169)

'discount'         => $this->_formatPrice(
                $order->getBaseGiftCardsAmount()
                + abs($order->getBaseDiscountAmount())
                + $order->getBaseCustomerBalanceAmount()

To This:

 'discount'         => $this->_formatPrice($RealDiscount)

OK remember you should not really alter core files so you can put that whole document in the local code pool, or a better way is to override the function with a module.

The real discount has been calculated in a fail safe way that uses the formula: Subtotal Excl Tax
+
Shipping Cost
+
Tax
-
(Discount)
=
Grandtotal

1
source | link

Solution by DKNZDESIGN

The problem is that Paypal takes the discount amount including tax and subtracts from the subtotal excluding tax. EG:
Magento
(Subtotal Incl Tax $28.80)
Orig Subtotal Excl Tax $27.30
Discount (10%) ($2.88) - MAGENTO TAKES DISCOUNT THEN APPLIES TAX AFTERWARD

(NEW SUBTOTAL INC TAX $25.92)
NEW SUBTOTAL EXCL TAX $24.57
Tax (5.5%) $1.35
Grand Total $25.92

Paypal
ORIG Subtotal Excl Tax $27.30
Discount ($2.88) -THIS AMOUNT CONTAINS TAX
Tax (5.5%) $1.35
Grand Total $25.77
(This amount to less than the expected grand total and triggers a fraud warning)


So The discount sent to Paypal includes tax, we have to calculate Discount without tax and send THAT amount in the request. This problem only occurs for the Hosted Paypal Solution
Sooooo... go to:
App/code/core/Mage/Paypal/Hostedpro?Request.php
Around Line 156
Find the function _getOrderData()

add these lines at the begining of the function

$origDiscount=$order->getBaseGiftCardsAmount()
                + abs($order->getBaseDiscountAmount())
                + $order->getBaseCustomerBalanceAmount();
$RealDiscount = $origDiscount ;
if($origDiscount>0){
                    $gt=$order->getGrandTotal();//grandtotal
                    $st=$order->getBaseSubtotal();//subwithouttax
                    $tx=$order->getBaseTaxAmount();//tax
                    $sp=$order->getBaseShippingAmount();//shipping
                    //Figure out Discount using Grand Total
                    $RealDiscount=$st+$tx+$sp-$gt;
                 }

Then in the $request array change these lines: (around Lines 166 to 169)

'discount'         => $this->_formatPrice(
                $order->getBaseGiftCardsAmount()
                + abs($order->getBaseDiscountAmount())
                + $order->getBaseCustomerBalanceAmount()

To This:

 'discount'         => $this->_formatPrice($RealDiscount)

OK remember you should not really alter core files so you can put that whole document in the local code pool, or a better way is to override the function with a module.

The real discount has been calculated in a fail safe way that uses the formula: Subtotal Excl Tax
+
Shipping Cost
+
Tax
-
(Discount)
=
Grandtotal