diff --git a/vendor/payuindia/payu/Helper/Payu.php b/vendor/payuindia/payu/Helper/Payu.php
index 1a3dcd3..91db738 100644
--- a/vendor/payuindia/payu/Helper/Payu.php
+++ b/vendor/payuindia/payu/Helper/Payu.php
@@ -1,5 +1,22 @@
 <?php
-
+/**
+ * PayUIndia
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the https://payu.in/ license that is
+ * available through the world-wide-web at this URL:
+ * https://payu.in/
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
+ * version in the future.
+ *
+ * @category    PayUIndia
+ * @package     PayUIndia_Payu
+ * @copyright   Copyright (c) PayUIndia (https://payu.in/)
+ */
 namespace PayUIndia\Payu\Helper;
 
 use Magento\Framework\App\Helper\Context;
@@ -10,6 +27,13 @@ use Magento\Framework\Exception\LocalizedException;
 
 class Payu extends AbstractHelper
 {
+
+    const PRODUCT_TYPE_BUNDLE = 'bundle';
+    const PRODUCT_TYPE_SOFT = 'soft';
+    /**
+     * @var $excludedProductType - List of product types to be excluded for discount distribution
+     */
+    private $excludedProductType = [self::PRODUCT_TYPE_BUNDLE,self::PRODUCT_TYPE_SOFT];
     private $session;
     private $customerSession;
     private $quote;
@@ -231,49 +255,53 @@ class Payu extends AbstractHelper
 
     }
 
-    public function setDiscount($order,$customDiscount,$discountDescription)
-    {
-        $total=$order->getBaseSubtotal();
-        $order->setDiscountAmount($customDiscount);
-        $order->setBaseDiscountAmount($customDiscount);
-        $order->setBaseGrandTotal($order->getBaseGrandTotal()-$customDiscount);
-        $order->setGrandTotal($order->getGrandTotal()-$customDiscount);
-        $order->setDiscountDescription($discountDescription);
-        $shippingAddress = $order->getShippingAddress();
-        if ($shippingAddress) {
-            $shippingAddress->setDiscountAmount($customDiscount);
-            $shippingAddress->setDiscountDescription($discountDescription);
-            $shippingAddress->setBaseDiscountAmount($customDiscount);
-        }
-        $orderBillingAddress = $order->getBillingAddress();
-        $orderBillingAddress->setDiscountAmount($customDiscount);
-        $orderBillingAddress->setDiscountDescription($discountDescription);
-        $orderBillingAddress->setBaseDiscountAmount($customDiscount);
-
-        $order->setSubtotal((float) $order->getSubTotal());
-        $order->setBaseSubtotal((float) $order->getBaseSubtotal());
-        $order->setGrandTotal((float)  $order->getGrandTotal());
-        $order->setBaseGrandTotal((float) $order->getBaseGrandTotal());
-        $order ->save();
-      
+    /**
+    * Settle discount value in order and payments.Distribute the discount for all eligible order items.
+    * @param \Magento\Sales\Api\Data\OrderInterface $order
+    * @param double $customDiscount
+    * @param string $discountDescription
+    */
 
+    public function setDiscount($order, $customDiscount, $discountDescription)
+    {
+        //used to store discount values in addStatusHistoryComment
+        $existingDiscount = $order->getDiscountAmount();
+        $newDiscount = $existingDiscount - $customDiscount; // Adding the custom discount
+        $order->setDiscountAmount($newDiscount);
+        $order->setBaseDiscountAmount($newDiscount);
+        $order->setGrandTotal($order->getGrandTotal() - $customDiscount);
+        $order->setBaseGrandTotal($order->getBaseGrandTotal() - $customDiscount);
+        $order->setDiscountDescription($order->getDiscountDescription() . '|||payu :-' . $discountDescription);
+        $order->addStatusHistoryComment('discount-' . $existingDiscount . 'payu discount-' . $customDiscount);
         $order->setBaseTotalInvoiced($order->getGrandTotal());
         $order->setTotalInvoiced($order->getGrandTotal());
-        $payment=$order->getpayment();
+        $payment=$order->getPayment();
         $payment->setBaseAmountPaid($order->getGrandTotal());
         $payment->setAmountPaid($order->getGrandTotal());
         $payment->setBaseAmountOrdered($order->getGrandTotal());
         $payment->setAmountOrdered($order->getGrandTotal());
+        //save order payment
         $payment->save();
-        foreach($order->getAllItems() as $item){
-            $rat=$item->getPriceInclTax()/$total;
-            $ratdisc=abs($customDiscount)*$rat;
-            $discountAmt=($item->getDiscountAmount()+$ratdisc) * $item->getQtyOrdered();
-            $base=($item->getBaseDiscountAmount()+$ratdisc) * $item->getQtyOrdered();
-            $item->setBaseDiscountAmount($base);
-            $item->setDiscountAmount($discountAmt);
-            $item->save();
+        $totalNew = 0;
+        foreach ($order->getAllItems() as $item) {
+            if(!in_array($item->getProductType(), $this->excludedProductType)) {
+                $totalNew = $totalNew + ($item->getPriceInclTax() * $item->getQtyOrdered()) - $item->getDiscountAmount();
+            }
+        }
+        if($totalNew > 0) {
+            // Distribute the discount proportionally among each order item
+            foreach ($order->getAllItems() as $item) {
+                if(!in_array($item->getProductType(), $this->excludedProductType)) {
+                    $itemPriceInclTax = ($item->getPriceInclTax() * $item->getQtyOrdered()) - $item->getDiscountAmount();
+                    $itemDiscountAmount = ($itemPriceInclTax / $totalNew) * abs($customDiscount);
+                    $item->setBaseDiscountAmount($item->getBaseDiscountAmount() + $itemDiscountAmount);
+                    $item->setDiscountAmount($item->getDiscountAmount() + $itemDiscountAmount);
+                    //save order item after adding discount portion
+                    $item->save();
+                }
+            }
         }
+        //save order data
         $order->save();
     }
 
