Skip to content

Commit

Permalink
Merge pull request #13 from mdevaud/fix/payplug-product
Browse files Browse the repository at this point in the history
fix: do not add order product as payplug product when his price is 0
  • Loading branch information
zawaze authored Apr 8, 2024
2 parents feacae0 + 6dd6a25 commit 8104168
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>2.0.4</version>
<version>2.0.5</version>
<authors>
<author>
<name>Vincent Lopes-Vicente</name>
Expand Down
4 changes: 3 additions & 1 deletion Event/PayPlugPaymentEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,9 @@ public function buildFromOrder(Order $order)
->findOne();

foreach ($order->getOrderProducts() as $orderProduct) {
$this->addProduct((new PayPlugProduct())->buildFromOrderProduct($orderProduct, $payPlugDeliveryType));
if($orderProduct->getPrice() > 0 ){
$this->addProduct((new PayPlugProduct())->buildFromOrderProduct($orderProduct, $payPlugDeliveryType));
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion PayPlugModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function isValidPayment()
public function pay(Order $order)
{
try {

/** @var PaymentService $paymentService */
$paymentService = $this->container->get('payplugmodule_payment_service');

Expand All @@ -90,7 +91,6 @@ public function pay(Order $order)
$isMultiPayment = $this->getRequest()->getSession()->get(OrderFormListener::PAY_PLUG_MULTI_PAYMENT_FIELD_NAME, 0);
if ($isMultiPayment) {
$orderTotalAmount = $order->getTotalAmount();

$minAmount = PayPlugModule::getConfigValue(PayPlugConfigValue::MULTI_PAYMENT_MINIMUM);
$maxAmount = PayPlugModule::getConfigValue(PayPlugConfigValue::MULTI_PAYMENT_MAXIMUM);

Expand Down Expand Up @@ -124,6 +124,7 @@ public function pay(Order $order)
if ($this->getRequest()->isXmlHttpRequest()) {
return new JsonResponse(['error' => $exception->getMessage()], 400);
}
Tlog::getInstance()->addError('Error PayPlugModule::pay() : '. $exception->getMessage());
return new RedirectResponse(URL::getInstance()->absoluteUrl('error'));
}

Expand Down

0 comments on commit 8104168

Please sign in to comment.