From 65f3e9264441673ed218dce0de06d7ffe9cacda1 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Tue, 30 May 2023 11:07:53 +0200 Subject: [PATCH 1/7] Bugfix: Only show the Second Chance BCC field when applicable --- etc/adminhtml/system.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index c23e7cdc7fe..f5f086bd0a4 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -359,7 +359,7 @@ Optional Comma separated list of emailaddresses. Leave empty to disable.]]> validate-emails - 1 + 1 From 6cf4404eed58c261e5925f6aff3299b472aa024b Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Tue, 30 May 2023 11:09:47 +0200 Subject: [PATCH 2/7] Bugfix: Always set the customer group id to prevent validation errors --- Service/Order/Reorder.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Service/Order/Reorder.php b/Service/Order/Reorder.php index d892333e0ff..fc02bc067cb 100644 --- a/Service/Order/Reorder.php +++ b/Service/Order/Reorder.php @@ -159,9 +159,8 @@ private function recreate( $this->orderCreate->setData('account', ['email' => $originalOrder->getCustomerEmail()]); $this->orderCreate->initFromOrder($originalOrder); - if ($originalOrder->getCustomerGroupId() === null) { - $this->orderCreate->getQuote()->getCustomer()->setGroupId(0); - } + $customerGroupId = $originalOrder->getCustomerGroupId() ?? 0; + $this->orderCreate->getQuote()->getCustomer()->setGroupId($customerGroupId); $order = $this->orderCreate->createOrder(); From 9365a5c404d59780cd062b3ccd218217703558ef Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Tue, 30 May 2023 14:29:42 +0200 Subject: [PATCH 3/7] Bugfix: Take shipping discount when creating order totals #643 --- .../Lines/Generator/ShippingDiscount.php | 44 +++++++++++++++++++ etc/di.xml | 1 + 2 files changed, 45 insertions(+) create mode 100644 Service/Order/Lines/Generator/ShippingDiscount.php diff --git a/Service/Order/Lines/Generator/ShippingDiscount.php b/Service/Order/Lines/Generator/ShippingDiscount.php new file mode 100644 index 00000000000..03171803f67 --- /dev/null +++ b/Service/Order/Lines/Generator/ShippingDiscount.php @@ -0,0 +1,44 @@ +mollieHelper = $mollieHelper; + } + + public function process(OrderInterface $order, array $orderLines): array + { + if (!$order->getShippingDiscountAmount()) { + return $orderLines; + } + + $forceBaseCurrency = (bool)$this->mollieHelper->useBaseCurrency($order->getStoreId()); + $currency = $forceBaseCurrency ? $order->getBaseCurrencyCode() : $order->getOrderCurrencyCode(); + $amount = abs($order->getData(($forceBaseCurrency ? 'base_' : '') . 'shipping_discount_amount')); + + $orderLines[] = [ + 'type' => OrderLineType::TYPE_DISCOUNT, + 'name' => __('Magento Discount'), + 'quantity' => 1, + 'unitPrice' => $this->mollieHelper->getAmountArray($currency, -$amount), + 'totalAmount' => $this->mollieHelper->getAmountArray($currency, -$amount), + 'vatRate' => '0.00', + 'vatAmount' => $this->mollieHelper->getAmountArray($currency, '0.00'), + ]; + + return $orderLines; + } +} diff --git a/etc/di.xml b/etc/di.xml index 3fa66fcb8d5..573987a7e20 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -148,6 +148,7 @@ Mollie\Payment\Service\Order\Lines\Generator\MagentoGiftCard Mollie\Payment\Service\Order\Lines\Generator\MagentoGiftWrapping Mollie\Payment\Service\Order\Lines\Generator\GeisswebEuvat + Mollie\Payment\Service\Order\Lines\Generator\ShippingDiscount From 7d89c3868d708e4b61c9405932cde95523fa8fca Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Thu, 8 Jun 2023 12:27:51 +0200 Subject: [PATCH 4/7] Feature: Differentiate between webhook and subscription --- Model/Client/Payments.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Model/Client/Payments.php b/Model/Client/Payments.php index 598a57c9714..f01b5362a5f 100644 --- a/Model/Client/Payments.php +++ b/Model/Client/Payments.php @@ -40,8 +40,9 @@ */ class Payments extends AbstractModel { - const CHECKOUT_TYPE = 'payment'; + const TRANSACTION_TYPE_WEBHOOK = 'webhook'; + const TRANSACTION_TYPE_SUBSCRIPTION = 'subscription'; /** * @var MollieHelper @@ -253,7 +254,7 @@ public function startTransaction(Order $order, $mollieApi) // Order is paid immediately (eg. Credit Card with Components, Apple Pay), process transaction if ($payment->isPaid()) { - $this->processTransaction->execute($order, 'webhook'); + $this->processTransaction->execute($order, static::TRANSACTION_TYPE_WEBHOOK); } return $payment->getCheckoutUrl(); @@ -331,7 +332,9 @@ public function processTransaction(Order $order, $mollieApi, $type = 'webhook', $status = $paymentData->status; $payment = $order->getPayment(); - if ($type == 'webhook' && $payment->getAdditionalInformation('payment_status') != $status) { + if (in_array($type, [static::TRANSACTION_TYPE_WEBHOOK, static::TRANSACTION_TYPE_SUBSCRIPTION]) && + $payment->getAdditionalInformation('payment_status') != $status + ) { $payment->setAdditionalInformation('payment_status', $status); $this->orderRepository->save($order); } @@ -351,12 +354,16 @@ public function processTransaction(Order $order, $mollieApi, $type = 'webhook', $this->saveAdditionalInformationDetails->execute($payment, $paymentData->details); } - if (!$payment->getIsTransactionClosed() && $type == 'webhook') { + if (!$payment->getIsTransactionClosed() && + in_array($type, [static::TRANSACTION_TYPE_WEBHOOK, static::TRANSACTION_TYPE_SUBSCRIPTION]) + ) { if ($order->isCanceled()) { $order = $this->mollieHelper->uncancelOrder($order); } - if (abs($amount - $orderAmount['value']) < 0.01) { + if (abs($amount - $orderAmount['value']) < 0.01 || + $type == static::TRANSACTION_TYPE_SUBSCRIPTION + ) { $payment->setTransactionId($transactionId); $payment->setCurrencyCode($order->getBaseCurrencyCode()); $payment->setIsTransactionClosed(true); @@ -440,7 +447,7 @@ public function processTransaction(Order $order, $mollieApi, $type = 'webhook', } } if ($status == 'canceled' || $status == 'failed' || $status == 'expired') { - if ($type == 'webhook') { + if (in_array($type, [static::TRANSACTION_TYPE_WEBHOOK, static::TRANSACTION_TYPE_SUBSCRIPTION])) { $this->cancelOrder->execute($order, $status); $this->transactionProcessor->process($order, null, $paymentData); } @@ -482,9 +489,10 @@ public function orderHasUpdate(OrderInterface $order, MollieApiClient $mollieApi */ public function checkCheckoutSession(Order $order, $paymentToken, $paymentData, $type) { - if ($type == 'webhook') { + if (in_array($type, [static::TRANSACTION_TYPE_WEBHOOK, static::TRANSACTION_TYPE_SUBSCRIPTION])) { return; } + if ($this->checkoutSession->getLastOrderId() != $order->getId()) { if ($paymentToken && isset($paymentData->metadata->payment_token)) { if ($paymentToken == $paymentData->metadata->payment_token) { From b47f50a58923e2cb6e464da5f66907de58abe37e Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 12 Jun 2023 14:47:38 +0200 Subject: [PATCH 5/7] Improvement: Better error logging for creating shipments --- Model/Client/Orders.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Model/Client/Orders.php b/Model/Client/Orders.php index 441db272864..c97677ffce0 100644 --- a/Model/Client/Orders.php +++ b/Model/Client/Orders.php @@ -565,9 +565,15 @@ public function createShipment(Order\Shipment $shipment, OrderInterface $order) } } } catch (\Exception $e) { - $this->mollieHelper->addTolog('error', $e->getMessage()); + $message = __( + 'Unable to ship order "%1" due to error: %2', + $order->getIncrementId(), + $e->getMessage() + ); + + $this->mollieHelper->addTolog('error', $message); throw new LocalizedException( - __('Mollie API: %1', $e->getMessage()) + $message ); } From d7eb2d34dcbd522200f913ceef58ac04f2894c62 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 12 Jun 2023 15:39:09 +0200 Subject: [PATCH 6/7] Bugfix: Make sure the payment link gets in the email --- .../StartTransactionForPaymentLinkOrders.php | 2 +- .../StartTransactionForPaymentLinkOrdersTest.php | 2 +- etc/events.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename Observer/{CheckoutSubmitAllAfter => SalesModelServiceQuoteSubmitSuccess}/StartTransactionForPaymentLinkOrders.php (92%) diff --git a/Observer/CheckoutSubmitAllAfter/StartTransactionForPaymentLinkOrders.php b/Observer/SalesModelServiceQuoteSubmitSuccess/StartTransactionForPaymentLinkOrders.php similarity index 92% rename from Observer/CheckoutSubmitAllAfter/StartTransactionForPaymentLinkOrders.php rename to Observer/SalesModelServiceQuoteSubmitSuccess/StartTransactionForPaymentLinkOrders.php index fc237c8b173..bdcdc1678ff 100644 --- a/Observer/CheckoutSubmitAllAfter/StartTransactionForPaymentLinkOrders.php +++ b/Observer/SalesModelServiceQuoteSubmitSuccess/StartTransactionForPaymentLinkOrders.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Mollie\Payment\Observer\CheckoutSubmitAllAfter; +namespace Mollie\Payment\Observer\SalesModelServiceQuoteSubmitSuccess; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; diff --git a/Test/Integration/Observer/CheckoutSubmitAllAfter/StartTransactionForPaymentLinkOrdersTest.php b/Test/Integration/Observer/CheckoutSubmitAllAfter/StartTransactionForPaymentLinkOrdersTest.php index 2fe5ce97a72..78fff6a7045 100644 --- a/Test/Integration/Observer/CheckoutSubmitAllAfter/StartTransactionForPaymentLinkOrdersTest.php +++ b/Test/Integration/Observer/CheckoutSubmitAllAfter/StartTransactionForPaymentLinkOrdersTest.php @@ -8,7 +8,7 @@ use Magento\Framework\Event\Observer; use Mollie\Payment\Model\Mollie; -use Mollie\Payment\Observer\CheckoutSubmitAllAfter\StartTransactionForPaymentLinkOrders; +use Mollie\Payment\Observer\SalesModelServiceQuoteSubmitSuccess\StartTransactionForPaymentLinkOrders; use Mollie\Payment\Test\Integration\IntegrationTestCase; class StartTransactionForPaymentLinkOrdersTest extends IntegrationTestCase diff --git a/etc/events.xml b/etc/events.xml index 3fb21fd1eb7..8d0cdb035cf 100644 --- a/etc/events.xml +++ b/etc/events.xml @@ -28,6 +28,7 @@ + @@ -46,7 +47,6 @@ - From ce136df78193733967c5ad41b47f23be6cc30785 Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Mon, 12 Jun 2023 19:59:24 +0200 Subject: [PATCH 7/7] Version bump --- composer.json | 2 +- etc/config.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 17c6370ae76..888279918bc 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "mollie/magento2", "description": "Mollie Payment Module for Magento 2", - "version": "2.26.0", + "version": "2.27.0", "keywords": [ "mollie", "payment", diff --git a/etc/config.xml b/etc/config.xml index 403b26c8d23..39c93749202 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -3,7 +3,7 @@ - v2.26.0 + v2.27.0 0 0 test