Skip to content

Commit 8104168

Browse files
authored
Merge pull request #13 from mdevaud/fix/payplug-product
fix: do not add order product as payplug product when his price is 0
2 parents feacae0 + 6dd6a25 commit 8104168

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

Config/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<language>en_US</language>
1818
<language>fr_FR</language>
1919
</languages>
20-
<version>2.0.4</version>
20+
<version>2.0.5</version>
2121
<authors>
2222
<author>
2323
<name>Vincent Lopes-Vicente</name>

Event/PayPlugPaymentEvent.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,9 @@ public function buildFromOrder(Order $order)
612612
->findOne();
613613

614614
foreach ($order->getOrderProducts() as $orderProduct) {
615-
$this->addProduct((new PayPlugProduct())->buildFromOrderProduct($orderProduct, $payPlugDeliveryType));
615+
if($orderProduct->getPrice() > 0 ){
616+
$this->addProduct((new PayPlugProduct())->buildFromOrderProduct($orderProduct, $payPlugDeliveryType));
617+
}
616618
}
617619
}
618620

PayPlugModule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function isValidPayment()
8282
public function pay(Order $order)
8383
{
8484
try {
85+
8586
/** @var PaymentService $paymentService */
8687
$paymentService = $this->container->get('payplugmodule_payment_service');
8788

@@ -90,7 +91,6 @@ public function pay(Order $order)
9091
$isMultiPayment = $this->getRequest()->getSession()->get(OrderFormListener::PAY_PLUG_MULTI_PAYMENT_FIELD_NAME, 0);
9192
if ($isMultiPayment) {
9293
$orderTotalAmount = $order->getTotalAmount();
93-
9494
$minAmount = PayPlugModule::getConfigValue(PayPlugConfigValue::MULTI_PAYMENT_MINIMUM);
9595
$maxAmount = PayPlugModule::getConfigValue(PayPlugConfigValue::MULTI_PAYMENT_MAXIMUM);
9696

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

0 commit comments

Comments
 (0)