2

I previously used magento website payments pro but to become more PCI compliant switching to Paypal Hosted Solution.

I get a difference between what magento says should be paid and what paypal captures when a discount is applied to a customer account.

For exampled if customer orders £243.74 worth of products with one of the products costing £7.99 with a discount £7.99 so it is free the total should be £235.75 as stated in magento. When the customer pays by card using the paypal hosted service it captures £234.42. The difference in the prices is £1.33 from what they have paid and should pay. This works out at being the amount of TAX that would be applicable to the discount.

This occurs with other orders too.

Prices when entered into the system include TAX and apply customer tax set to after discount apply discount on prices set to including tax

This does not happen when customer pays by express checkout.

Not sure how to resolve this issue, any help wold be great.

Henry

2

This is simply a matter of misconfiguration or incorrectly interpreted configuration by Magento... Depending on your point of view.

To fix the suspected fraud issue and have the correct amount debited from the customers card when using Paypal Hosted Payment Pages and a discount code is applied, simply set:-

SYSTEM -> CONFIGURATION -> SALES -> TAX -> Shopping Cart Display Settings

Include Tax In Grand Total: Yes

As you are seeing this issue you most likely have this option set to No.

This does result in more detailed tax info on your checkout page as well as fixing the issue. If the more detailed tax breakdown is an issue edit this in your cart template - far more preferable than overriding Magento' core paypal code.

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.