diff --git a/Config/module.xml b/Config/module.xml index f5df809..53b24b8 100755 --- a/Config/module.xml +++ b/Config/module.xml @@ -17,7 +17,7 @@ en_US fr_FR - 2.0.8 + 2.1.0 Vincent Lopes-Vicente diff --git a/Event/PayPlugPaymentEvent.php b/Event/PayPlugPaymentEvent.php index 318fc76..e217bd7 100755 --- a/Event/PayPlugPaymentEvent.php +++ b/Event/PayPlugPaymentEvent.php @@ -577,7 +577,7 @@ class PayPlugPaymentEvent extends ActionEvent */ protected $notificationUrl; - public function buildFromOrder(Order $order) + public function buildFromOrder(Order $order, ?float $customTotalAmount = null) { $this->order = $order; @@ -591,7 +591,7 @@ public function buildFromOrder(Order $order) if (null !== $order) { // Avoid php bad int cast https://www.php.net/manual/fr/function.intval.php#60793 - $orderAmount = round($order->getTotalAmount(),2) * 100; + $orderAmount = round($customTotalAmount??$order->getTotalAmount(),2) * 100; $this->setAmount(intval("$orderAmount")) ->setCurrency($order->getCurrency()->getCode()); diff --git a/PayPlugModule.php b/PayPlugModule.php index 6aa2b18..b440ba6 100755 --- a/PayPlugModule.php +++ b/PayPlugModule.php @@ -89,8 +89,9 @@ public function pay(Order $order) $slice = 1; $isMultiPayment = $this->getRequest()->getSession()->get(OrderFormListener::PAY_PLUG_MULTI_PAYMENT_FIELD_NAME, 0); + $orderTotalAmount = $this->getOrderPayTotalAmount($order); + if ($isMultiPayment) { - $orderTotalAmount = $order->getTotalAmount(); $minAmount = PayPlugModule::getConfigValue(PayPlugConfigValue::MULTI_PAYMENT_MINIMUM); $maxAmount = PayPlugModule::getConfigValue(PayPlugConfigValue::MULTI_PAYMENT_MAXIMUM); @@ -103,7 +104,8 @@ public function pay(Order $order) $order, PayPlugModule::getConfigValue(PayPlugConfigValue::DIFFERED_PAYMENT_ENABLED, false), PayPlugModule::getConfigValue(PayPlugConfigValue::ONE_CLICK_PAYMENT_ENABLED, false), - $slice + $slice, + $orderTotalAmount ); $forceRedirect = false; @@ -125,7 +127,7 @@ public function pay(Order $order) return new JsonResponse(['error' => $exception->getMessage()], 400); } Tlog::getInstance()->addError( - 'Error PayPlugModule::pay() : ' . $exception->getMessage() + 'Error PayPlugModule::pay() : ' . $exception->getMessage() ); return new RedirectResponse(URL::getInstance()->absoluteUrl('error')); } diff --git a/Service/PaymentService.php b/Service/PaymentService.php index c81052f..4b7f7e5 100755 --- a/Service/PaymentService.php +++ b/Service/PaymentService.php @@ -44,10 +44,11 @@ public function sendOrderPayment( Order $order, bool $capture = false, bool $allowSaveCard = false, - int $paymentSlice = 1 + int $paymentSlice = 1, + float $totalOrder ) { $paymentEvent = (new PayPlugPaymentEvent()) - ->buildFromOrder($order) + ->buildFromOrder($order,$totalOrder) ->setCapture($capture) ->setAllowSaveCard($allowSaveCard);