From 4a2d5b83e08a54022e8c8ee40ee4d6e54efa12e8 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Sun, 22 Nov 2026 17:21:20 +0100 Subject: [PATCH 1/2] [TASK] Send order emails with the OrderMailSender in tests Since cart 12.4 sending the emails of an order with the MailHandler triggers a deprecation, which fails the functional tests. The tests enable the feature toggle cart.useNewOrderMailSender, so the emails are sent by the OrderMailSender. Co-Authored-By: Claude Opus 5.5 --- .../Controller/Order/AbstractPaymentControllerTestCase.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Tests/Functional/Controller/Order/AbstractPaymentControllerTestCase.php b/Tests/Functional/Controller/Order/AbstractPaymentControllerTestCase.php index ffaa220..425b5d0 100644 --- a/Tests/Functional/Controller/Order/AbstractPaymentControllerTestCase.php +++ b/Tests/Functional/Controller/Order/AbstractPaymentControllerTestCase.php @@ -53,6 +53,11 @@ abstract class AbstractPaymentControllerTestCase extends FunctionalTestCase 'enforceValidation' => false, ], ], + 'SYS' => [ + 'features' => [ + 'cart.useNewOrderMailSender' => true, + ], + ], 'MAIL' => [ 'transport' => 'null', ], From b94d4295a19de363b7eb6d6c3b3421a97083d26e Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Sun, 22 Nov 2026 17:03:42 +0100 Subject: [PATCH 2/2] [BUGFIX] Reject notifications for unknown transactions If no transaction of the payment matched the gcReference of the notification, the last transaction of the payment was updated and the payment was marked as paid or canceled anyway. The notification is now rejected like a notification for a payment without any transaction. Co-Authored-By: Claude Opus 5.5 --- .../Controller/Order/PaymentController.php | 8 +++++--- .../PaymentControllerNotifyActionTest.php | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Classes/Controller/Order/PaymentController.php b/Classes/Controller/Order/PaymentController.php index 70bc9fd..933fe67 100644 --- a/Classes/Controller/Order/PaymentController.php +++ b/Classes/Controller/Order/PaymentController.php @@ -154,12 +154,14 @@ private function updatePaymentAndTransaction($notify, Item $orderItem, string $s $payment = $orderItem->getPayment(); - foreach ($payment->getTransactions() as $transaction) { - if ($transaction->getTxnId() === ($notify->getResponseParam('gcReference'))) { + $transaction = null; + foreach ($payment->getTransactions() as $paymentTransaction) { + if ($paymentTransaction->getTxnId() === $notify->getResponseParam('gcReference')) { + $transaction = $paymentTransaction; break; } } - if (!isset($transaction)) { + if ($transaction === null) { throw new Exception('No transaction found!', 1731616906); } diff --git a/Tests/Functional/Controller/Order/PaymentControllerNotifyActionTest.php b/Tests/Functional/Controller/Order/PaymentControllerNotifyActionTest.php index fcc7ee9..895ffe0 100644 --- a/Tests/Functional/Controller/Order/PaymentControllerNotifyActionTest.php +++ b/Tests/Functional/Controller/Order/PaymentControllerNotifyActionTest.php @@ -191,6 +191,25 @@ public function notificationForPaymentWithoutTransactionIsRejected(): void self::assertSame([], EventRecorder::getEvents()); } + #[Test] + public function notificationForUnknownTransactionIsRejected(): void + { + $this->get(ConnectionPool::class) + ->getConnectionForTable('tx_cart_domain_model_order_transaction') + ->update('tx_cart_domain_model_order_transaction', ['txn_id' => 'gc-reference-0002'], ['uid' => 1]); + + try { + $this->sendNotification(self::RESULT_PAYMENT_SUCCESSFUL, self::TYPOSCRIPT_SECRET); + self::fail('The notification for an unknown transaction has been accepted.'); + } catch (\Exception $exception) { + self::assertSame(1731616906, $exception->getCode()); + } + + self::assertSame('open', $this->getPayment()['status']); + self::assertSame('created', $this->getTransaction()['status']); + self::assertSame([], EventRecorder::getEvents()); + } + #[Test] public function notifyActionRespondsWithEmptyBody(): void {