From 5e6b7b1669694c00a53ee9e1a0fae8bb3e8f128c Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Wed, 27 Nov 2024 13:57:32 +0100 Subject: [PATCH 1/3] NTR: do not cancel orders, when a new payment method is not mollie (#898) Co-authored-by: Vitalij Mik --- src/Service/Order/OrderExpireService.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Service/Order/OrderExpireService.php b/src/Service/Order/OrderExpireService.php index 22a742872..b342ae4d2 100644 --- a/src/Service/Order/OrderExpireService.php +++ b/src/Service/Order/OrderExpireService.php @@ -77,12 +77,27 @@ public function cancelExpiredOrders(OrderCollection $orders, Context $context): } $transactions->sort(function (OrderTransactionEntity $a, OrderTransactionEntity $b) { - return $a->getCreatedAt() <=> $b->getCreatedAt(); + if ($a->getCreatedAt() === null || $b->getCreatedAt() === null) { + return -1; + } + return $a->getCreatedAt()->getTimestamp() <=> $b->getCreatedAt()->getTimestamp(); }); /** @var OrderTransactionEntity $lastTransaction */ $lastTransaction = $transactions->last(); + $paymentMethod = $lastTransaction->getPaymentMethod(); + if ($paymentMethod === null) { + $this->logger->warning('Transaction has no payment method', ['orderNumber'=>$order->getOrderNumber(),'transactionId'=>$lastTransaction->getId()]); + continue; + } + $paymentMethodIdentifier = $paymentMethod->getHandlerIdentifier(); + + if (strpos($paymentMethodIdentifier, 'Mollie') === false) { + $this->logger->debug('Payment method is not a mollie payment, dont touch it', ['identifier'=>$paymentMethodIdentifier]); + continue; + } + $stateMachineState = $lastTransaction->getStateMachineState(); if ($stateMachineState === null) { continue; From 6aa03a981ba3a1e264fdccbc498844178ba96223 Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Wed, 27 Nov 2024 14:16:53 +0100 Subject: [PATCH 2/3] NTR: PISHPS-379: enable trustly for subscriptions (#899) Co-authored-by: Vitalij Mik --- .../SubscriptionRemover.php | 29 +++++++++++++------ .../PaymentMethodRemoverTest.php | 1 + 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/Components/Subscription/Services/PaymentMethodRemover/SubscriptionRemover.php b/src/Components/Subscription/Services/PaymentMethodRemover/SubscriptionRemover.php index 09f452223..5dcec1750 100644 --- a/src/Components/Subscription/Services/PaymentMethodRemover/SubscriptionRemover.php +++ b/src/Components/Subscription/Services/PaymentMethodRemover/SubscriptionRemover.php @@ -2,6 +2,16 @@ namespace Kiener\MolliePayments\Components\Subscription\Services\PaymentMethodRemover; +use Kiener\MolliePayments\Handler\Method\BanContactPayment; +use Kiener\MolliePayments\Handler\Method\BelfiusPayment; +use Kiener\MolliePayments\Handler\Method\CreditCardPayment; +use Kiener\MolliePayments\Handler\Method\DirectDebitPayment; +use Kiener\MolliePayments\Handler\Method\EpsPayment; +use Kiener\MolliePayments\Handler\Method\GiroPayPayment; +use Kiener\MolliePayments\Handler\Method\iDealPayment; +use Kiener\MolliePayments\Handler\Method\PayPalPayment; +use Kiener\MolliePayments\Handler\Method\SofortPayment; +use Kiener\MolliePayments\Handler\Method\TrustlyPayment; use Kiener\MolliePayments\Service\MollieApi\OrderItemsExtractor; use Kiener\MolliePayments\Service\OrderService; use Kiener\MolliePayments\Service\Payment\Remover\PaymentMethodRemover; @@ -16,15 +26,16 @@ class SubscriptionRemover extends PaymentMethodRemover { public const ALLOWED_METHODS = [ - 'ideal', - 'bancontact', - 'sofort', - 'eps', - 'giropay', - 'belfius', - 'creditcard', - 'paypal', - 'directdebit', + iDealPayment::PAYMENT_METHOD_NAME, + BanContactPayment::PAYMENT_METHOD_NAME, + SofortPayment::PAYMENT_METHOD_NAME, + EpsPayment::PAYMENT_METHOD_NAME, + GiroPayPayment::PAYMENT_METHOD_NAME, + BelfiusPayment::PAYMENT_METHOD_NAME, + CreditCardPayment::PAYMENT_METHOD_NAME, + PaypalPayment::PAYMENT_METHOD_NAME, + DirectDebitPayment::PAYMENT_METHOD_NAME, + TrustlyPayment::PAYMENT_METHOD_NAME ]; /** diff --git a/tests/PHPUnit/Components/Subscription/Services/PaymentMethodRemover/PaymentMethodRemoverTest.php b/tests/PHPUnit/Components/Subscription/Services/PaymentMethodRemover/PaymentMethodRemoverTest.php index a336098cf..4612af285 100644 --- a/tests/PHPUnit/Components/Subscription/Services/PaymentMethodRemover/PaymentMethodRemoverTest.php +++ b/tests/PHPUnit/Components/Subscription/Services/PaymentMethodRemover/PaymentMethodRemoverTest.php @@ -27,6 +27,7 @@ public function testAllowedPaymentMethods() 'creditcard', 'paypal', 'directdebit', + 'trustly' ]; $this->assertEquals($expected, SubscriptionRemover::ALLOWED_METHODS); From 030266f2e23820d09fda157a005e14e97be7486a Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Fri, 29 Nov 2024 15:03:31 +0100 Subject: [PATCH 3/3] NTR: do not cancel orders (#901) Co-authored-by: Vitalij Mik --- src/Components/OrderExpiration/ExpireAction.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Components/OrderExpiration/ExpireAction.php b/src/Components/OrderExpiration/ExpireAction.php index edd47656d..654f444db 100644 --- a/src/Components/OrderExpiration/ExpireAction.php +++ b/src/Components/OrderExpiration/ExpireAction.php @@ -78,6 +78,7 @@ private function expireOrdersInSalesChannel(SalesChannelEntity $salesChannelEnti $criteria = new Criteria(); $criteria->addAssociation('transactions.stateMachineState'); + $criteria->addAssociation('transactions.paymentMethod'); $criteria->addFilter(new EqualsFilter('transactions.stateMachineState.technicalName', OrderTransactionStates::STATE_IN_PROGRESS)); $criteria->addFilter(new EqualsFilter('salesChannelId', $salesChannelEntity->getId())); $criteria->addFilter(new RangeFilter('orderDateTime', [RangeFilter::GTE => $date->format(Defaults::STORAGE_DATE_TIME_FORMAT)]));