File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717 <language >en_US</language >
1818 <language >fr_FR</language >
1919 </languages >
20- <version >2.0.8 </version >
20+ <version >2.1.0 </version >
2121 <authors >
2222 <author >
2323 <name >Vincent Lopes-Vicente</name >
Original file line number Diff line number Diff line change @@ -577,7 +577,7 @@ class PayPlugPaymentEvent extends ActionEvent
577577 */
578578 protected $ notificationUrl ;
579579
580- public function buildFromOrder (Order $ order )
580+ public function buildFromOrder (Order $ order, ? float $ customTotalAmount = null )
581581 {
582582 $ this ->order = $ order ;
583583
@@ -591,7 +591,7 @@ public function buildFromOrder(Order $order)
591591
592592 if (null !== $ order ) {
593593 // Avoid php bad int cast https://www.php.net/manual/fr/function.intval.php#60793
594- $ orderAmount = round ($ order ->getTotalAmount (),2 ) * 100 ;
594+ $ orderAmount = round ($ customTotalAmount ?? $ order ->getTotalAmount (),2 ) * 100 ;
595595 $ this ->setAmount (intval ("$ orderAmount " ))
596596 ->setCurrency ($ order ->getCurrency ()->getCode ());
597597
Original file line number Diff line number Diff line change @@ -89,8 +89,9 @@ public function pay(Order $order)
8989 $ slice = 1 ;
9090
9191 $ isMultiPayment = $ this ->getRequest ()->getSession ()->get (OrderFormListener::PAY_PLUG_MULTI_PAYMENT_FIELD_NAME , 0 );
92+ $ orderTotalAmount = $ this ->getOrderPayTotalAmount ($ order );
93+
9294 if ($ isMultiPayment ) {
93- $ orderTotalAmount = $ order ->getTotalAmount ();
9495 $ minAmount = PayPlugModule::getConfigValue (PayPlugConfigValue::MULTI_PAYMENT_MINIMUM );
9596 $ maxAmount = PayPlugModule::getConfigValue (PayPlugConfigValue::MULTI_PAYMENT_MAXIMUM );
9697
@@ -103,7 +104,8 @@ public function pay(Order $order)
103104 $ order ,
104105 PayPlugModule::getConfigValue (PayPlugConfigValue::DIFFERED_PAYMENT_ENABLED , false ),
105106 PayPlugModule::getConfigValue (PayPlugConfigValue::ONE_CLICK_PAYMENT_ENABLED , false ),
106- $ slice
107+ $ slice ,
108+ $ orderTotalAmount
107109 );
108110
109111 $ forceRedirect = false ;
@@ -125,7 +127,7 @@ public function pay(Order $order)
125127 return new JsonResponse (['error ' => $ exception ->getMessage ()], 400 );
126128 }
127129 Tlog::getInstance ()->addError (
128- 'Error PayPlugModule::pay() : ' . $ exception ->getMessage ()
130+ 'Error PayPlugModule::pay() : ' . $ exception ->getMessage ()
129131 );
130132 return new RedirectResponse (URL ::getInstance ()->absoluteUrl ('error ' ));
131133 }
Original file line number Diff line number Diff line change @@ -44,10 +44,11 @@ public function sendOrderPayment(
4444 Order $ order ,
4545 bool $ capture = false ,
4646 bool $ allowSaveCard = false ,
47- int $ paymentSlice = 1
47+ int $ paymentSlice = 1 ,
48+ float $ totalOrder
4849 ) {
4950 $ paymentEvent = (new PayPlugPaymentEvent ())
50- ->buildFromOrder ($ order )
51+ ->buildFromOrder ($ order, $ totalOrder )
5152 ->setCapture ($ capture )
5253 ->setAllowSaveCard ($ allowSaveCard );
5354
You can’t perform that action at this time.
0 commit comments