From e9c3f406e200059d996607063b7fbc7ec7568ff4 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 6 Jun 2022 10:54:43 +0200 Subject: [PATCH 1/4] Feature: Implemented in3 --- Helper/General.php | 1 + Model/Methods/In3.php | 24 ++++ Model/Mollie.php | 2 +- Model/MollieConfigProvider.php | 19 +-- Service/Mollie/PaymentMethods.php | 1 + Service/Order/PartialInvoice.php | 1 + .../Etc/Config/MethodsConfigurationTest.php | 1 + Test/Integration/Helper/GeneralTest.php | 1 + Test/Integration/Model/Methods/In3Test.php | 16 +++ .../Model/MollieConfigProviderTest.php | 1 + .../Service/Config/PaymentFeeTest.php | 19 +-- etc/adminhtml/methods.xml | 1 + etc/adminhtml/methods/applepay.xml | 2 +- etc/adminhtml/methods/in3.xml | 130 ++++++++++++++++++ etc/config.xml | 18 +++ etc/di.xml | 45 ++++++ etc/graphql/di.xml | 1 + etc/payment.xml | 3 + .../templates/form/mollie_paymentlink.phtml | 1 + view/adminhtml/web/images/in3.svg | 14 ++ view/frontend/layout/checkout_index_index.xml | 32 ++--- view/frontend/web/images/methods/in3.svg | 14 ++ .../web/js/view/payment/method-renderer.js | 15 +- 23 files changed, 319 insertions(+), 43 deletions(-) create mode 100644 Model/Methods/In3.php create mode 100644 Test/Integration/Model/Methods/In3Test.php create mode 100644 etc/adminhtml/methods/in3.xml create mode 100644 view/adminhtml/web/images/in3.svg create mode 100644 view/frontend/web/images/methods/in3.svg diff --git a/Helper/General.php b/Helper/General.php index 9703cffbbf5..f7830db08ad 100755 --- a/Helper/General.php +++ b/Helper/General.php @@ -693,6 +693,7 @@ public function getAllActiveMethods($storeId) 'mollie_methods_giftcard', 'mollie_methods_giropay', 'mollie_methods_ideal', + 'mollie_methods_in3', 'mollie_methods_kbc', 'mollie_methods_klarnapaylater', 'mollie_methods_klarnapaynow', diff --git a/Model/Methods/In3.php b/Model/Methods/In3.php new file mode 100644 index 00000000000..501e126e9f6 --- /dev/null +++ b/Model/Methods/In3.php @@ -0,0 +1,24 @@ +mollieHelper->getMethodCode($order); - if (in_array($methodCode, ['klarnapaylater', 'klarnapaynow', 'klarnasliceit', 'voucher'])) { + if (in_array($methodCode, ['klarnapaylater', 'klarnapaynow', 'klarnasliceit', 'voucher', 'in3'])) { throw new LocalizedException(__($exception->getMessage())); } diff --git a/Model/MollieConfigProvider.php b/Model/MollieConfigProvider.php index b19e0c1fa7c..fc3bff6793e 100644 --- a/Model/MollieConfigProvider.php +++ b/Model/MollieConfigProvider.php @@ -33,26 +33,27 @@ class MollieConfigProvider implements ConfigProviderInterface * @var array */ private $methodCodes = [ + 'mollie_methods_applepay', 'mollie_methods_bancontact', 'mollie_methods_banktransfer', 'mollie_methods_belfius', 'mollie_methods_creditcard', 'mollie_methods_directdebit', + 'mollie_methods_eps', + 'mollie_methods_giftcard', + 'mollie_methods_giropay', 'mollie_methods_ideal', + 'mollie_methods_in3', 'mollie_methods_kbc', - 'mollie_methods_voucher', - 'mollie_methods_paypal', - 'mollie_methods_paysafecard', - 'mollie_methods_sofort', - 'mollie_methods_giropay', - 'mollie_methods_eps', 'mollie_methods_klarnapaylater', 'mollie_methods_klarnapaynow', 'mollie_methods_klarnasliceit', - 'mollie_methods_giftcard', - 'mollie_methods_przelewy24', - 'mollie_methods_applepay', 'mollie_methods_mybank', + 'mollie_methods_paypal', + 'mollie_methods_paysafecard', + 'mollie_methods_przelewy24', + 'mollie_methods_sofort', + 'mollie_methods_voucher', ]; /** * @var array diff --git a/Service/Mollie/PaymentMethods.php b/Service/Mollie/PaymentMethods.php index 83cfa1fd4ab..17648f89842 100644 --- a/Service/Mollie/PaymentMethods.php +++ b/Service/Mollie/PaymentMethods.php @@ -33,6 +33,7 @@ public function __construct( 'mollie_methods_directdebit', 'mollie_methods_eps', 'mollie_methods_ideal', + 'mollie_methods_in3', 'mollie_methods_giropay', 'mollie_methods_giftcard', 'mollie_methods_kbc', diff --git a/Service/Order/PartialInvoice.php b/Service/Order/PartialInvoice.php index dd67a5875ef..a3a91955704 100644 --- a/Service/Order/PartialInvoice.php +++ b/Service/Order/PartialInvoice.php @@ -50,6 +50,7 @@ public function createFromShipment(ShipmentInterface $shipment) 'mollie_methods_klarnapaylater', 'mollie_methods_klarnapaynow', 'mollie_methods_klarnasliceit', + 'mollie_methods_in3', ] ) || $this->mollieHelper->getInvoiceMoment($order->getStoreId()) != InvoiceMoment::ON_SHIPMENT diff --git a/Test/Integration/Etc/Config/MethodsConfigurationTest.php b/Test/Integration/Etc/Config/MethodsConfigurationTest.php index ce9d9d6b3b6..acd721234a2 100644 --- a/Test/Integration/Etc/Config/MethodsConfigurationTest.php +++ b/Test/Integration/Etc/Config/MethodsConfigurationTest.php @@ -24,6 +24,7 @@ public function methods() ['mollie_methods_giftcard'], ['mollie_methods_giropay'], ['mollie_methods_ideal'], + ['mollie_methods_in3'], ['mollie_methods_kbc'], ['mollie_methods_klarnapaylater'], ['mollie_methods_klarnapaynow'], diff --git a/Test/Integration/Helper/GeneralTest.php b/Test/Integration/Helper/GeneralTest.php index ba1735152ce..8420b52c8e1 100644 --- a/Test/Integration/Helper/GeneralTest.php +++ b/Test/Integration/Helper/GeneralTest.php @@ -147,6 +147,7 @@ public function getMethodCodeDataProvider() 'giftcard' => ['mollie_methods_giftcard', 'giftcard'], 'giropay' => ['mollie_methods_giropay', 'giropay'], 'ideal' => ['mollie_methods_ideal', 'ideal'], + 'in3' => ['mollie_methods_in3', 'in3'], 'kbc' => ['mollie_methods_kbc', 'kbc'], 'klarnapaylater' => ['mollie_methods_klarnapaylater', 'klarnapaylater'], 'klarnapaynow' => ['mollie_methods_klarnapaynow', 'klarnapaynow'], diff --git a/Test/Integration/Model/Methods/In3Test.php b/Test/Integration/Model/Methods/In3Test.php new file mode 100644 index 00000000000..13417d18096 --- /dev/null +++ b/Test/Integration/Model/Methods/In3Test.php @@ -0,0 +1,16 @@ +assertArrayHasKey('mollie_methods_giftcard', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_giropay', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_ideal', $result['payment']['image']); + $this->assertArrayHasKey('mollie_methods_in3', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_kbc', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_klarnapaylater', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_klarnapaynow', $result['payment']['image']); diff --git a/Test/Integration/Service/Config/PaymentFeeTest.php b/Test/Integration/Service/Config/PaymentFeeTest.php index a9d3a60cee7..dc738a45443 100644 --- a/Test/Integration/Service/Config/PaymentFeeTest.php +++ b/Test/Integration/Service/Config/PaymentFeeTest.php @@ -23,26 +23,27 @@ class PaymentFeeTest extends IntegrationTestCase public function isAvailableForMethodProvider() { return [ + ['mollie_methods_applepay', true], ['mollie_methods_bancontact', true], ['mollie_methods_banktransfer', true], ['mollie_methods_belfius', true], ['mollie_methods_creditcard', true], ['mollie_methods_directdebit', true], + ['mollie_methods_eps', true], ['mollie_methods_ideal', true], - ['mollie_methods_kbc', true], - ['mollie_methods_voucher', true], - ['mollie_methods_paypal', true], - ['mollie_methods_paysafecard', true], - ['mollie_methods_sofort', true], + ['mollie_methods_in3', true], + ['mollie_methods_giftcard', true], ['mollie_methods_giropay', true], - ['mollie_methods_eps', true], + ['mollie_methods_kbc', true], ['mollie_methods_klarnapaylater', true], ['mollie_methods_klarnapaynow', true], ['mollie_methods_klarnasliceit', true], - ['mollie_methods_giftcard', true], - ['mollie_methods_przelewy24', true], - ['mollie_methods_applepay', true], ['mollie_methods_mybank', true], + ['mollie_methods_paypal', true], + ['mollie_methods_paysafecard', true], + ['mollie_methods_przelewy24', true], + ['mollie_methods_sofort', true], + ['mollie_methods_voucher', true], ['not_relevant_payment_method', false], ]; } diff --git a/etc/adminhtml/methods.xml b/etc/adminhtml/methods.xml index bcb3f41d423..041fc572f4f 100644 --- a/etc/adminhtml/methods.xml +++ b/etc/adminhtml/methods.xml @@ -16,6 +16,7 @@ + diff --git a/etc/adminhtml/methods/applepay.xml b/etc/adminhtml/methods/applepay.xml index 0f7f56f92a2..bd1fcd36ad9 100644 --- a/etc/adminhtml/methods/applepay.xml +++ b/etc/adminhtml/methods/applepay.xml @@ -48,7 +48,7 @@ payment/mollie_methods_applepay/integration_type
External: The user is redirected to a Mollie page. No extra configuration required.
- Direct: The user can use Apple Pay in your checkout. You need to upload a certificate to your server for this to work. View instructions. + Direct: The user can use Apple Pay in your checkout. You need to upload a certificate to your server for this to work. View instructions. ]]>
Mollie\Payment\Model\Adminhtml\Source\AppleyPayIntegrationType diff --git a/etc/adminhtml/methods/in3.xml b/etc/adminhtml/methods/in3.xml new file mode 100644 index 00000000000..e59a2c574eb --- /dev/null +++ b/etc/adminhtml/methods/in3.xml @@ -0,0 +1,130 @@ + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/mollie_methods_in3/active + + + + payment/mollie_methods_in3/title + + 1 + + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/mollie_methods_in3/allowspecific + + 1 + + + + + Magento\Directory\Model\Config\Source\Country + 1 + payment/mollie_methods_in3/specificcountry + + 1 + + + + + payment/mollie_methods_in3/min_order_total + + 1 + + + + + payment/mollie_methods_in3/max_order_total + + 1 + + + + + payment/mollie_methods_in3/payment_surcharge_type + Mollie\Payment\Model\Adminhtml\Source\PaymentFeeType + + 1 + + + + + payment/mollie_methods_in3/payment_surcharge_fixed_amount + Mollie\Payment\Model\Adminhtml\Backend\VerifiyPaymentFee + validate-not-negative-number + + 1 + fixed_fee,fixed_fee_and_percentage + + + + + payment/mollie_methods_in3/payment_surcharge_percentage + Mollie\Payment\Model\Adminhtml\Backend\VerifiyPaymentFee + validate-number-range number-range-0-10 + + 1 + percentage,fixed_fee_and_percentage + + + + + payment/mollie_methods_in3/payment_surcharge_limit + + Mollie\Payment\Model\Adminhtml\Backend\VerifiyPaymentFee + validate-not-negative-number + + 1 + percentage,fixed_fee_and_percentage + + + + + payment/mollie_methods_in3/payment_surcharge_tax_class + \Magento\Tax\Model\TaxClass\Source\Product + + 1 + fixed_fee,percentage,fixed_fee_and_percentage + + + + + validate-number + payment/mollie_methods_in3/sort_order + + 1 + + + + + validate-digits-range digits-range-1-365 + payment/mollie_methods_in3/days_before_expire + + 1 + order + + How many days before orders for this method becomes expired? Leave empty to use default expiration (28 days) + + + diff --git a/etc/config.xml b/etc/config.xml index 18ef790427c..b2f83e5ee70 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -235,6 +235,24 @@ 0 0 + + 1 + Mollie\Payment\Model\Methods\In3 + in3 + {ordernumber} + order + order + 0 + + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 Mollie\Payment\Model\Methods\Kbc diff --git a/etc/di.xml b/etc/di.xml index 0e594d35ef3..cc14670376e 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -799,6 +799,51 @@ + + + + Magento\Payment\Block\Form + Mollie\Payment\Block\Info\Base + MollieIn3ValueHandlerPool + MollieCommandPool + MollieIn3ValidatorPool + + + + + + + MollieIn3ConfigValueHandler + + + + + + + MollieIn3Config + + + + + + Mollie\Payment\Model\Methods\In3::CODE + + + + + + + MollieIn3CountryValidator + + + + + + + MollieIn3Config + + + diff --git a/etc/graphql/di.xml b/etc/graphql/di.xml index 115c79b8aba..5a9c0c857eb 100644 --- a/etc/graphql/di.xml +++ b/etc/graphql/di.xml @@ -13,6 +13,7 @@ Mollie\Payment\GraphQL\DataProvider Mollie\Payment\GraphQL\DataProvider Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider Mollie\Payment\GraphQL\DataProvider Mollie\Payment\GraphQL\DataProvider Mollie\Payment\GraphQL\DataProvider diff --git a/etc/payment.xml b/etc/payment.xml index 68898c8f108..2962f2118b7 100644 --- a/etc/payment.xml +++ b/etc/payment.xml @@ -31,6 +31,9 @@ 0 + + 0 + 0 diff --git a/view/adminhtml/templates/form/mollie_paymentlink.phtml b/view/adminhtml/templates/form/mollie_paymentlink.phtml index 1bf01d6c425..a8415be7614 100644 --- a/view/adminhtml/templates/form/mollie_paymentlink.phtml +++ b/view/adminhtml/templates/form/mollie_paymentlink.phtml @@ -26,6 +26,7 @@ $code; ?>" style="display:none"> + diff --git a/view/adminhtml/web/images/in3.svg b/view/adminhtml/web/images/in3.svg new file mode 100644 index 00000000000..418f0e64ec2 --- /dev/null +++ b/view/adminhtml/web/images/in3.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 0e6de240abf..f1cdba0029b 100644 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -22,6 +22,9 @@ Mollie_Payment/js/view/payment/method-renderer + + true + true @@ -37,31 +40,25 @@ true - - true - - - true - - + true - + true - + true - + true - + true - + true - + true @@ -73,16 +70,19 @@ true - + + true + + true true - + true - + true diff --git a/view/frontend/web/images/methods/in3.svg b/view/frontend/web/images/methods/in3.svg new file mode 100644 index 00000000000..418f0e64ec2 --- /dev/null +++ b/view/frontend/web/images/methods/in3.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/view/frontend/web/js/view/payment/method-renderer.js b/view/frontend/web/js/view/payment/method-renderer.js index b8a037bba0e..486d4e1f108 100644 --- a/view/frontend/web/js/view/payment/method-renderer.js +++ b/view/frontend/web/js/view/payment/method-renderer.js @@ -27,19 +27,20 @@ define( {type: 'mollie_methods_belfius', component: defaultComponent}, {type: 'mollie_methods_creditcard', component: creditcardComponent}, {type: 'mollie_methods_directdebit', component: defaultComponent}, + {type: 'mollie_methods_eps', component: defaultComponent}, + {type: 'mollie_methods_giftcard', component: giftcardComponent}, {type: 'mollie_methods_ideal', component: idealComponent}, - {type: 'mollie_methods_kbc', component: kbcComponent}, - {type: 'mollie_methods_paypal', component: defaultComponent}, - {type: 'mollie_methods_paysafecard', component: defaultComponent}, - {type: 'mollie_methods_sofort', component: defaultComponent}, + {type: 'mollie_methods_in3', component: defaultComponent}, {type: 'mollie_methods_giropay', component: defaultComponent}, - {type: 'mollie_methods_eps', component: defaultComponent}, + {type: 'mollie_methods_kbc', component: kbcComponent}, {type: 'mollie_methods_klarnapaylater', component: defaultComponent}, {type: 'mollie_methods_klarnapaynow', component: defaultComponent}, {type: 'mollie_methods_klarnasliceit', component: defaultComponent}, - {type: 'mollie_methods_giftcard', component: giftcardComponent}, - {type: 'mollie_methods_przelewy24', component: defaultComponent}, {type: 'mollie_methods_mybank', component: defaultComponent}, + {type: 'mollie_methods_paypal', component: defaultComponent}, + {type: 'mollie_methods_paysafecard', component: defaultComponent}, + {type: 'mollie_methods_przelewy24', component: defaultComponent}, + {type: 'mollie_methods_sofort', component: defaultComponent}, {type: 'mollie_methods_voucher', component: defaultComponent} ]; From f18162355acd19b90f2cff55ed4e41f88997cf53 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Tue, 7 Jun 2022 10:02:02 +0200 Subject: [PATCH 2/4] Feature: Add integration tests for Magento 2.4.4 --- .github/workflows/integration-test.yml | 8 +++++--- Service/Mollie/DashboardUrl.php | 6 +++--- Service/Order/Lines/Order.php | 6 +++--- Test/Integration/Model/Client/OrdersTest.php | 2 ++ Test/Integration/Model/Client/PaymentsTest.php | 1 + Test/Integration/Model/Client/ProcessTransactionTest.php | 1 + .../Service/Mollie/MethodParameterPartTest.php | 2 +- 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 6d21e855fa6..7678347cb52 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -16,12 +16,14 @@ jobs: MAGENTO_VERSION: 2.4.2 - PHP_VERSION: php74-fpm MAGENTO_VERSION: 2.4.3-with-replacements + - PHP_VERSION: php81-fpm + MAGENTO_VERSION: 2.4.4 runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Start Docker - run: PHP_VERSION=${{ matrix.PHP_VERSION }} MAGENTO_VERSION=magento${{ matrix.MAGENTO_VERSION }} docker-compose -f .github/workflows/templates/docker-compose.yml up -d + run: docker run --detach --name magento-project-community-edition michielgerritsen/magento-project-community-edition:${{ matrix.PHP_VERSION }}-magento${{ matrix.MAGENTO_VERSION }} - name: Create branch for Composer and remove version from composer.json run: git checkout -b continuous-integration-test-branch && sed -i '/version/d' ./composer.json @@ -29,8 +31,8 @@ jobs: - name: Upload the code into the docker container run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition composer require mollie/magento2:dev-continuous-integration-test-branch - - name: Enable developer mode - run: docker exec magento-project-community-edition php bin/magento deploy:mode:set developer + - name: Activate the extension + run: docker exec magento-project-community-edition bash -c "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade" - name: Run tests run: docker exec magento-project-community-edition bash -c "cd /data/dev/tests/integration/ && /data/vendor/bin/phpunit -c /data/dev/tests/integration/phpunit.xml" diff --git a/Service/Mollie/DashboardUrl.php b/Service/Mollie/DashboardUrl.php index 14f1825f442..dbb6a50f504 100644 --- a/Service/Mollie/DashboardUrl.php +++ b/Service/Mollie/DashboardUrl.php @@ -21,7 +21,7 @@ public function __construct( $this->config = $config; } - public function forOrdersApi($storeId, $id) + public function forOrdersApi($storeId, string $id): string { return str_replace( '{id}', @@ -30,7 +30,7 @@ public function forOrdersApi($storeId, $id) ); } - public function forPaymentsApi($storeId, $id) + public function forPaymentsApi($storeId, string $id): string { return str_replace( '{id}', @@ -38,4 +38,4 @@ public function forPaymentsApi($storeId, $id) $this->config->getDashboardUrlForPaymentsApi($storeId) ); } -} \ No newline at end of file +} diff --git a/Service/Order/Lines/Order.php b/Service/Order/Lines/Order.php index 523dff759da..a23e5456b4d 100644 --- a/Service/Order/Lines/Order.php +++ b/Service/Order/Lines/Order.php @@ -174,13 +174,13 @@ private function getOrderLine(OrderItemInterface $item, $zeroPriceLine = false) $orderLine = [ 'item_id' => $item->getId(), 'type' => $item->getProductType() != 'downloadable' ? 'physical' : 'digital', - 'name' => preg_replace("/[^A-Za-z0-9 -]/", "", $item->getName()), + 'name' => preg_replace('/[^A-Za-z0-9 -]/', '', $item->getName() ?? ''), 'quantity' => round($item->getQtyOrdered()), 'unitPrice' => $this->mollieHelper->getAmountArray($this->currency, $unitPrice), 'totalAmount' => $this->mollieHelper->getAmountArray($this->currency, $totalAmount), 'vatRate' => sprintf("%.2f", $item->getTaxPercent()), 'vatAmount' => $this->mollieHelper->getAmountArray($this->currency, $vatAmount), - 'sku' => substr($item->getSku(), 0, 64), + 'sku' => substr($item->getSku() ?? '', 0, 64), 'productUrl' => $this->getProductUrl($item), ]; @@ -212,7 +212,7 @@ protected function getShippingOrderLine(OrderInterface $order) */ $vatAmount = round($totalAmount * ($vatRate / (100 + $vatRate)), 2); - $name = preg_replace("/[^A-Za-z0-9 -]/", "", $order->getShippingDescription()); + $name = preg_replace('/[^A-Za-z0-9 -]/', '', $order->getShippingDescription() ?? ''); if (!$name) { $name = $order->getShippingMethod(); } diff --git a/Test/Integration/Model/Client/OrdersTest.php b/Test/Integration/Model/Client/OrdersTest.php index 84043e6564b..4cb514eff79 100644 --- a/Test/Integration/Model/Client/OrdersTest.php +++ b/Test/Integration/Model/Client/OrdersTest.php @@ -58,6 +58,7 @@ public function testRemovesEmptySpaceFromThePrefix() $address = $this->objectManager->get(OrderAddressInterface::class); $address->setPrefix(' '); + $address->setStreet(''); $result = $instance->getAddressLine($address); @@ -75,6 +76,7 @@ public function testProcessTransactionHandlesAStackOfPaymentsCorrectly() $this->loadFakeEncryptor()->addReturnValue('', 'test_dummyapikeythatisvalidandislongenough'); $mollieOrderMock = $this->mollieOrderMock('N/A', 'EUR'); + $mollieOrderMock->id = 'trx_test_123'; $mollieOrderMock->lines = []; $mollieOrderMock->status = OrderStatus::STATUS_PAID; $mollieOrderMock->_embedded->payments = []; diff --git a/Test/Integration/Model/Client/PaymentsTest.php b/Test/Integration/Model/Client/PaymentsTest.php index d58ea075086..0e00f7f7df1 100644 --- a/Test/Integration/Model/Client/PaymentsTest.php +++ b/Test/Integration/Model/Client/PaymentsTest.php @@ -104,6 +104,7 @@ public function testProcessTransaction($currency, $mollieOrderStatus, $orderComm protected function getMolliePayment($status, $currency) { $payment = new \Mollie\Api\Resources\Payment($this->createMock(MollieApiClient::class)); + $payment->id = 'tr_test_transaction'; $payment->status = $status; $payment->settlementAmount = new \stdClass; $payment->settlementAmount->value = 50; diff --git a/Test/Integration/Model/Client/ProcessTransactionTest.php b/Test/Integration/Model/Client/ProcessTransactionTest.php index a588bb9c925..7eea0aec4c1 100644 --- a/Test/Integration/Model/Client/ProcessTransactionTest.php +++ b/Test/Integration/Model/Client/ProcessTransactionTest.php @@ -179,6 +179,7 @@ public function testCallsTheCorrectProcessor(string $state, string $event) protected function mollieClientMock(string $status, string $currency): MockObject { $mollieOrder = new \Mollie\Api\Resources\Order($this->createMock(MollieApiClient::class)); + $mollieOrder->id = 'tr_test_transaction'; $mollieOrder->lines = []; $mollieOrder->status = $status; $mollieOrder->amountCaptured = new \stdClass(); diff --git a/Test/Integration/Service/Mollie/MethodParameterPartTest.php b/Test/Integration/Service/Mollie/MethodParameterPartTest.php index c454d149530..c52aac808a7 100644 --- a/Test/Integration/Service/Mollie/MethodParameterPartTest.php +++ b/Test/Integration/Service/Mollie/MethodParameterPartTest.php @@ -10,7 +10,7 @@ use Mollie\Payment\Service\Mollie\Parameters\ParameterPartInterface; use Mollie\Payment\Test\Integration\IntegrationTestCase; -class MethodParametersTest extends IntegrationTestCase +class MethodParameterPartTest extends IntegrationTestCase { const DEFAULT_INPUT = [ 'amount[value]' => 10, From 8be337a505ccd16c83ed3397f28406cbf21628c1 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Tue, 7 Jun 2022 11:32:42 +0200 Subject: [PATCH 3/4] Feature: Add PHPStan support for Magento 2.4.4 --- .github/workflows/phpstan.yml | 26 ++++++++++++------- .github/workflows/unit-test.yml | 9 +++++-- Block/Loading.php | 2 +- Helper/Tests.php | 4 +-- Model/Client/Orders/OrderProcessors.php | 1 - Model/Client/Payments/PaymentProcessors.php | 1 - Model/Mollie.php | 9 ++----- .../PaymentFee/Order/Pdf/Total/PaymentFee.php | 4 +++ phpstan.neon | 3 +-- .../system/config/button/debug.phtml | 2 +- 10 files changed, 34 insertions(+), 27 deletions(-) diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 5352c3c1c0a..f66e25a9424 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -4,14 +4,17 @@ on: [push, pull_request] jobs: build: strategy: - matrix: - include: - - PHP_VERSION: php72-fpm - MAGENTO_VERSION: 2.3.3 - - PHP_VERSION: php73-fpm - MAGENTO_VERSION: 2.3.6-p1 - - PHP_VERSION: php74-fpm - MAGENTO_VERSION: 2.4.2 + matrix: + include: + - PHP_VERSION: php72-fpm + MAGENTO_VERSION: 2.3.4 + - PHP_VERSION: php73-fpm + MAGENTO_VERSION: 2.3.7 + - PHP_VERSION: php74-fpm + MAGENTO_VERSION: 2.4.0 + - PHP_VERSION: php81-fpm + MAGENTO_VERSION: 2.4.4 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 @@ -26,7 +29,10 @@ jobs: run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ - name: Install the extensions in Magento - run: docker exec magento-project-community-edition composer require mollie/magento2:dev-continuous-integration-test-branch fooman/phpstan-magento2-magic-methods:^0.7 phpstan/phpstan:0.* + run: docker exec magento-project-community-edition composer require mollie/magento2:dev-continuous-integration-test-branch + + - name: Activate the extension + run: docker exec magento-project-community-edition bash -c "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade && php bin/magento setup:di:compile" - name: Run PHPStan - run: docker exec magento-project-community-edition /bin/bash -c "./vendor/bin/phpstan analyse -c /data/extensions/*/phpstan.neon /data/extensions" + run: docker exec magento-project-community-edition /bin/bash -c "./vendor/bin/phpstan analyse --no-progress -c /data/extensions/*/phpstan.neon /data/extensions" diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index d862eb00c1c..af7519e72e2 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -9,11 +9,13 @@ jobs: - PHP_VERSION: php71-fpm MAGENTO_VERSION: 2.3.3 - PHP_VERSION: php73-fpm - MAGENTO_VERSION: 2.3.6-p1 + MAGENTO_VERSION: 2.3.7 - PHP_VERSION: php74-fpm - MAGENTO_VERSION: 2.4.2 + MAGENTO_VERSION: 2.4.0 - PHP_VERSION: php74-fpm MAGENTO_VERSION: 2.4.3-with-replacements + - PHP_VERSION: php81-fpm + MAGENTO_VERSION: 2.4.4 runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 @@ -27,5 +29,8 @@ jobs: - name: Upload the code into the docker container run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition composer require mollie/magento2:dev-continuous-integration-test-branch + - name: Activate the extension + run: docker exec magento-project-community-edition bash -c "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade && php bin/magento setup:di:compile" + - name: Run tests run: docker exec magento-project-community-edition bash -c "vendor/bin/phpunit extensions/*/Test/Unit" diff --git a/Block/Loading.php b/Block/Loading.php index b4babca38f7..b34624f23ba 100644 --- a/Block/Loading.php +++ b/Block/Loading.php @@ -15,10 +15,10 @@ * Class Loading * * @package Mollie\Payment\Block + * @method string getMollieRedirect() */ class Loading extends Template { - /** * @var Session */ diff --git a/Helper/Tests.php b/Helper/Tests.php index 4a05e533663..d8a95aa514c 100644 --- a/Helper/Tests.php +++ b/Helper/Tests.php @@ -56,8 +56,8 @@ public function __construct( } /** - * @param null $testKey - * @param null $liveKey + * @param string|null $testKey + * @param string|null $liveKey * * @return array */ diff --git a/Model/Client/Orders/OrderProcessors.php b/Model/Client/Orders/OrderProcessors.php index 155fb834c81..86af991af28 100644 --- a/Model/Client/Orders/OrderProcessors.php +++ b/Model/Client/Orders/OrderProcessors.php @@ -49,7 +49,6 @@ public function process( ProcessTransactionResponse $response ): ?ProcessTransactionResponse { if (!isset($this->processors[$event])) { - $response = $response ?? $this->returnResponse($mollieOrder, $magentoOrder, $type); $this->config->addToLog('success', $response->toArray()); return $response; } diff --git a/Model/Client/Payments/PaymentProcessors.php b/Model/Client/Payments/PaymentProcessors.php index aa652fb2992..640c14f050b 100644 --- a/Model/Client/Payments/PaymentProcessors.php +++ b/Model/Client/Payments/PaymentProcessors.php @@ -49,7 +49,6 @@ public function process( ProcessTransactionResponse $response ): ?ProcessTransactionResponse { if (!isset($this->processors[$event])) { - $response = $response ?? $this->returnResponse($molliePayment, $magentoOrder, $type); $this->config->addToLog('success', $response->toArray()); return $response; } diff --git a/Model/Mollie.php b/Model/Mollie.php index 23dd6edb682..f68692577f6 100644 --- a/Model/Mollie.php +++ b/Model/Mollie.php @@ -308,11 +308,6 @@ public function processTransaction($orderId, $type = 'webhook', $paymentToken = /** @var \Magento\Sales\Model\Order $order */ $order = $this->orderRepository->get($orderId); $this->eventManager->dispatch('mollie_process_transaction_start', ['order' => $order]); - if (empty($order)) { - $msg = ['error' => true, 'msg' => __('Order not found')]; - $this->mollieHelper->addTolog('error', $msg); - return $msg; - } $transactionId = $order->getMollieTransactionId(); if (empty($transactionId)) { @@ -556,13 +551,13 @@ public function getOrderIdsByTransactionId(string $transactionId): array /** * Get list of Issuers from API * - * @param MollieApiClient $mollieApi + * @param MollieApiClient|null $mollieApi * @param $method * @param $issuerListType * * @return array|null */ - public function getIssuers($mollieApi, $method, $issuerListType): ?array + public function getIssuers(MollieApiClient $mollieApi = null, $method, $issuerListType): ?array { $issuers = []; if (empty($mollieApi) || $issuerListType == 'none') { diff --git a/Model/PaymentFee/Order/Pdf/Total/PaymentFee.php b/Model/PaymentFee/Order/Pdf/Total/PaymentFee.php index 988f3c98a4e..f2d0f2c1e61 100644 --- a/Model/PaymentFee/Order/Pdf/Total/PaymentFee.php +++ b/Model/PaymentFee/Order/Pdf/Total/PaymentFee.php @@ -12,6 +12,10 @@ use Magento\Tax\Model\Calculation; use Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory; +/** + * @method getSource(); + * @method int|null getFontSize(); + */ class PaymentFee extends DefaultTotal { /** diff --git a/phpstan.neon b/phpstan.neon index 6988b37326a..006a53ff804 100755 --- a/phpstan.neon +++ b/phpstan.neon @@ -12,8 +12,7 @@ parameters: fileExtensions: - php - phtml - excludes_analyse: + excludePaths: - Test/* # These fail on Magento 2.2 and that's expected, these are only applicable on Magento 2.3 and higher. - - Plugin/Framework/App/Request/CsrfValidatorSkip.php - Service/Order/Uncancel/OrderReservation.php diff --git a/view/adminhtml/templates/system/config/button/debug.phtml b/view/adminhtml/templates/system/config/button/debug.phtml index 585c720e3e3..9aee698ba30 100755 --- a/view/adminhtml/templates/system/config/button/debug.phtml +++ b/view/adminhtml/templates/system/config/button/debug.phtml @@ -16,5 +16,5 @@ use Mollie\Payment\Block\Adminhtml\System\Config\Button\DebugCheck;
-getButtonHtml() ?> +getButtonHtml(); From 8643c13258a0fbb62e057a48e87381d8b7a4176c Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Tue, 7 Jun 2022 13:40:31 +0200 Subject: [PATCH 4/4] 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 a25e37f7a82..cd6302aea22 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "mollie/magento2", "description": "Mollie Payment Module for Magento 2", - "version": "2.11.0", + "version": "2.12.0", "keywords": [ "mollie", "payment", diff --git a/etc/config.xml b/etc/config.xml index 9556cecfaac..1bde992980d 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -3,7 +3,7 @@ - v2.11.0 + v2.12.0 0 0 test