4

I use Payments Standard as a payment Method in Magento.

I checkout page I have add a custom discount to my cart and it will work perfectly at cart page. see the below Image.

enter image description here

When you move to the checkout page then I also got the discount.

enter image description here

When I place order and It will redirect to the paypal then I did not get Discount. please see the below Image.

enter image description here

Please Help me to solve out this issue.

If any body got same issue then help me.

Thanks in advance

4

You need to tell PayPal about the discount order total. You can do this by modifying the PayPal cart object that is passed.

Observe the event paypal_prepare_line_items (Mage_Paypal_Model_Cart line 318)

In your observer, you load the paypal cart as such:

$payPalCart = $observer->getPaypalCart();

Get your discount amount from the order

$order = $payPalCart->getSalesEntity();
$discountAmount = $order->getDiscountAmount();

You can then set the discount amount by calling updateTotal()

$payPalCart->updateTotal(Mage_Paypal_Model_Cart::TOTAL_DISCOUNT, $discountAmount);

And that is it, PayPal will now know about your discount. This should work for standard, advanced, and pro I believe - both express checkout and direct payments.

  • Yes @ben It's Working. – Keyul Shah Dec 24 '13 at 2:48
3

For me, the following function in my custom module's observer worked:

class YourNamespace_YourModule_Model_Observer
{
    public function updatePaypalTotal(Varien_Event_Observer $observer)
    {        
        $label = SOME_LABEL;
        $qty = SOME_QTY;
        $feeAmount = SOME_FEE_AMOUNT;
        $itemNumber = SOME_IDENTIFIER_OR_SKU;

        /* @var $cart Mage_Paypal_Model_Cart */
        $cart = $observer->getEvent()->getPaypalCart();

        $cart->addItem($label, $qty, $feeAmount, $itemNumber);

        return $this;
    }
}

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.