From 218c71a3826e4bf74838c937e56187365412f40a Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Fri, 28 Jul 2023 12:33:26 +0200 Subject: [PATCH 1/2] Bugfix: Handle the new transaction ID for orders --- .github/workflows/end-2-end-test.yml | 3 ++- Model/Client/Payments.php | 2 +- Model/Mollie.php | 4 ++-- .../SalesOrderShipmentSaveBefore/CreateMollieShipment.php | 2 +- Service/Mollie/Order/CreateInvoiceOnShipment.php | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/end-2-end-test.yml b/.github/workflows/end-2-end-test.yml index 43455ac0f36..5c044a2aac2 100644 --- a/.github/workflows/end-2-end-test.yml +++ b/.github/workflows/end-2-end-test.yml @@ -19,7 +19,8 @@ jobs: env: MOLLIE_API_KEY_TEST: ${{ secrets.MOLLIE_API_KEY_TEST }} if: "${{ env.MOLLIE_API_KEY_TEST != '' }}" - run: echo "is_mollie_api_key_test_set=true" >> $GITHUB_OUTPUT + # Disabled for now. Change to =true to re-enable. + run: echo "is_mollie_api_key_test_set=false" >> $GITHUB_OUTPUT # Remove flag used to trigger the e2e tests remove_flag: diff --git a/Model/Client/Payments.php b/Model/Client/Payments.php index 4251d29243a..2aaea5977f7 100644 --- a/Model/Client/Payments.php +++ b/Model/Client/Payments.php @@ -221,7 +221,7 @@ public function startTransaction(Order $order, $mollieApi) $orderId = $order->getEntityId(); $transactionId = $order->getMollieTransactionId(); - if (!empty($transactionId) && !preg_match('/^ord_\w+$/', $transactionId)) { + if (!empty($transactionId) && substr($transactionId, 0, 4) != 'ord_') { $payment = $mollieApi->payments->get($transactionId); return $payment->getCheckoutUrl(); } diff --git a/Model/Mollie.php b/Model/Mollie.php index ca3b82cd089..c440756eb38 100644 --- a/Model/Mollie.php +++ b/Model/Mollie.php @@ -360,7 +360,7 @@ public function processTransactionForOrder(OrderInterface $order, $type = 'webho $type, $paymentToken ) { - if (preg_match('/^ord_\w+$/', $transactionId)) { + if (substr($transactionId, 0, 4) == 'ord_') { $result = $this->ordersProcessTraction->execute($order, $type)->toArray(); } else { $mollieApi = $this->mollieApiClient->loadByStore($order->getStoreId()); @@ -398,7 +398,7 @@ public function orderHasUpdate($orderId) $mollieApi = $this->mollieApiClient->loadByStore($order->getStoreId()); - if (preg_match('/^ord_\w+$/', $transactionId)) { + if (substr($transactionId, 0, 4) == 'ord_') { return $this->ordersApi->orderHasUpdate($order, $mollieApi); } else { return $this->paymentsApi->orderHasUpdate($order, $mollieApi); diff --git a/Observer/SalesOrderShipmentSaveBefore/CreateMollieShipment.php b/Observer/SalesOrderShipmentSaveBefore/CreateMollieShipment.php index fb0e405d802..5e7ce3dc2f9 100644 --- a/Observer/SalesOrderShipmentSaveBefore/CreateMollieShipment.php +++ b/Observer/SalesOrderShipmentSaveBefore/CreateMollieShipment.php @@ -55,7 +55,7 @@ public function execute(Observer $observer) $order = $shipment->getOrder(); $transactionId = $order->getMollieTransactionId() ?? ''; - $useOrdersApi = preg_match('/^ord_\w+$/', $transactionId); + $useOrdersApi = substr($transactionId, 0, 4) == 'ord_'; if ($useOrdersApi) { $this->ordersApi->createShipment($shipment, $order); } diff --git a/Service/Mollie/Order/CreateInvoiceOnShipment.php b/Service/Mollie/Order/CreateInvoiceOnShipment.php index d8911a6711d..e624ab6b9fb 100644 --- a/Service/Mollie/Order/CreateInvoiceOnShipment.php +++ b/Service/Mollie/Order/CreateInvoiceOnShipment.php @@ -33,7 +33,7 @@ public function execute(OrderInterface $order): bool } $transactionId = $order->getMollieTransactionId() ?? ''; - $api = preg_match('/^ord_\w+$/', $transactionId) ? 'orders' : 'payments'; + $api = substr($transactionId, 0, 4) == 'ord_' ? 'orders' : 'payments'; if ($methodCode == 'mollie_methods_creditcard' && $this->config->useManualCapture($order->getStoreId()) && $api == 'payments' From 186203fd7553d0b422f7fc197a2c8fc0f005fd07 Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Fri, 28 Jul 2023 12:59:09 +0200 Subject: [PATCH 2/2] 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 3bb1fbdeda9..c340b3893d2 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "mollie/magento2", "description": "Mollie Payment Module for Magento 2", - "version": "2.29.0", + "version": "2.29.1", "keywords": [ "mollie", "payment", diff --git a/etc/config.xml b/etc/config.xml index 66ea98da219..230eff7f040 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -3,7 +3,7 @@ - v2.29.0 + v2.29.1 0 0 test