From 11accbcbd09455f2b2a9df244a11d19ddb6e5390 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 19 Aug 2024 13:54:23 +0200 Subject: [PATCH 01/11] Feature: Add Payconiq --- .../templates/magento/configure-mollie.sh | 1 + Model/Methods/Payconiq.php | 18 ++ README.md | 1 + Service/Mollie/PaymentMethods.php | 1 + .../e2e/magento/methods/payconiq.cy.js | 60 +++++++ .../fixtures/belgian-shipping-address.json | 15 ++ .../VisitCheckoutPaymentCompositeAction.js | 11 +- .../pages/frontend/CheckoutShippingPage.js | 6 + .../Etc/Config/MethodsConfigurationTest.php | 1 + Test/Integration/Helper/GeneralTest.php | 1 + .../Model/Methods/PayconiqTest.php | 16 ++ .../Model/MollieConfigProviderTest.php | 1 + .../Service/Config/PaymentFeeTest.php | 1 + etc/adminhtml/methods.xml | 1 + etc/adminhtml/methods/payconiq.xml | 156 ++++++++++++++++++ etc/adminhtml/methods/paymentlink.xml | 7 +- etc/adminhtml/methods/paypal.xml | 7 +- etc/adminhtml/methods/paysafecard.xml | 7 +- etc/adminhtml/methods/pointofsale.xml | 7 +- etc/adminhtml/methods/przelewy24.xml | 7 +- etc/adminhtml/methods/riverty.xml | 2 +- etc/adminhtml/methods/sofort.xml | 2 +- etc/adminhtml/methods/trustly.xml | 2 +- etc/adminhtml/methods/twint.xml | 2 +- etc/adminhtml/methods/voucher.xml | 2 +- etc/config.xml | 19 +++ etc/di.xml | 45 +++++ etc/graphql/di.xml | 1 + etc/payment.xml | 3 + i18n/de_DE.csv | 1 + i18n/en_US.csv | 1 + i18n/es_ES.csv | 1 + i18n/fr_FR.csv | 1 + i18n/nl_NL.csv | 1 + view/adminhtml/web/images/payconiq.svg | 1 + view/frontend/layout/checkout_index_index.xml | 3 + view/frontend/web/images/methods/payconiq.svg | 1 + .../web/js/view/payment/method-renderer.js | 1 + 38 files changed, 401 insertions(+), 13 deletions(-) create mode 100644 Model/Methods/Payconiq.php create mode 100644 Test/End-2-end/cypress/e2e/magento/methods/payconiq.cy.js create mode 100644 Test/End-2-end/cypress/fixtures/belgian-shipping-address.json create mode 100644 Test/Integration/Model/Methods/PayconiqTest.php create mode 100644 etc/adminhtml/methods/payconiq.xml create mode 100644 view/adminhtml/web/images/payconiq.svg create mode 100644 view/frontend/web/images/methods/payconiq.svg diff --git a/.github/workflows/templates/magento/configure-mollie.sh b/.github/workflows/templates/magento/configure-mollie.sh index 9650bcae224..8439e9e00e3 100644 --- a/.github/workflows/templates/magento/configure-mollie.sh +++ b/.github/workflows/templates/magento/configure-mollie.sh @@ -26,6 +26,7 @@ bin/magento config:set payment/mollie_methods_kbc/active 1 & bin/magento config:set payment/mollie_methods_klarnasliceit/active 1 & bin/magento config:set payment/mollie_methods_paypal/active 1 & bin/magento config:set payment/mollie_methods_przelewy24/active 1 & +bin/magento config:set payment/mollie_methods_payconiq/active 1 & bin/magento config:set payment/mollie_methods_alma/active 1 & bin/magento config:set payment/mollie_methods_bancontact/active 1 & bin/magento config:set payment/mollie_methods_bancomatpay/active 1 & diff --git a/Model/Methods/Payconiq.php b/Model/Methods/Payconiq.php new file mode 100644 index 00000000000..567f5dcdd4d --- /dev/null +++ b/Model/Methods/Payconiq.php @@ -0,0 +1,18 @@ + { + [ + {status: 'paid', orderStatus: 'Processing', title: 'C3706886: Validate the submission of an order with Payconiq as payment method and payment mark as "Paid" '}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3706887: Validate the submission of an order with Payconiq as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3706888: Validate the submission of an order with Payconiq as payment method and payment mark as "Expired" '}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3706889: Validate the submission of an order with Payconiq as payment method and payment mark as "Canceled" '}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit('BE'); + + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + + checkoutPaymentPage.selectPaymentMethod('Payconiq'); + checkoutPaymentPage.placeOrder(); + + mollieHostedPaymentPage.selectStatus(testCase.status); + + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } + + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } + + cy.backendLogin(); + + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); + + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } + + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); + }); + }) +} diff --git a/Test/End-2-end/cypress/fixtures/belgian-shipping-address.json b/Test/End-2-end/cypress/fixtures/belgian-shipping-address.json new file mode 100644 index 00000000000..e0b48229859 --- /dev/null +++ b/Test/End-2-end/cypress/fixtures/belgian-shipping-address.json @@ -0,0 +1,15 @@ +{ + "type": { + "username": "annaschmidt@mollie.com", + "firstname": "Anna", + "company": "Acme Firma BVBA", + "lastname": "Schmidt", + "street[0]": "Voorbeeldstraat 1", + "city": "Brussel", + "postcode": "1000", + "telephone": "+32 2 XXXXXXX" + }, + "select": { + "country_id": "BE" + } +} diff --git a/Test/End-2-end/cypress/support/actions/composite/VisitCheckoutPaymentCompositeAction.js b/Test/End-2-end/cypress/support/actions/composite/VisitCheckoutPaymentCompositeAction.js index 2394fc60ef2..c8ed6d5395d 100644 --- a/Test/End-2-end/cypress/support/actions/composite/VisitCheckoutPaymentCompositeAction.js +++ b/Test/End-2-end/cypress/support/actions/composite/VisitCheckoutPaymentCompositeAction.js @@ -39,9 +39,14 @@ export default class VisitCheckoutPaymentCompositeAction { } fillAddress(fixture, asCustomer = false) { - if (asCustomer) { - checkoutShippingPage.skipUsername(); - } + if (asCustomer) { + checkoutShippingPage.skipUsername(); + } + + if (fixture === 'BE') { + checkoutShippingPage.fillBelgianShippingAddress(); + return; + } if (fixture === 'DE') { checkoutShippingPage.fillGermanShippingAddress(); diff --git a/Test/End-2-end/cypress/support/pages/frontend/CheckoutShippingPage.js b/Test/End-2-end/cypress/support/pages/frontend/CheckoutShippingPage.js index 8ddb743f2c3..905724e04fd 100644 --- a/Test/End-2-end/cypress/support/pages/frontend/CheckoutShippingPage.js +++ b/Test/End-2-end/cypress/support/pages/frontend/CheckoutShippingPage.js @@ -16,6 +16,12 @@ export default class CheckoutShippingPage { }); } + fillBelgianShippingAddress() { + cy.fixture('belgian-shipping-address').then((address) => { + this.fillShippingAddress(address); + }); + } + fillGermanShippingAddress() { cy.fixture('german-shipping-address').then((address) => { this.fillShippingAddress(address); diff --git a/Test/Integration/Etc/Config/MethodsConfigurationTest.php b/Test/Integration/Etc/Config/MethodsConfigurationTest.php index e3845068414..809202a02e4 100644 --- a/Test/Integration/Etc/Config/MethodsConfigurationTest.php +++ b/Test/Integration/Etc/Config/MethodsConfigurationTest.php @@ -38,6 +38,7 @@ public function methods(): array ['mollie_methods_paypal'], ['mollie_methods_paysafecard'], ['mollie_methods_pointofsale'], + ['mollie_methods_payconiq'], ['mollie_methods_przelewy24'], ['mollie_methods_riverty'], ['mollie_methods_sofort'], diff --git a/Test/Integration/Helper/GeneralTest.php b/Test/Integration/Helper/GeneralTest.php index b3a711ee34d..58a316bf346 100644 --- a/Test/Integration/Helper/GeneralTest.php +++ b/Test/Integration/Helper/GeneralTest.php @@ -165,6 +165,7 @@ public function getMethodCodeDataProvider() 'paypal' => ['mollie_methods_paypal', 'paypal'], 'paysafecard' => ['mollie_methods_paysafecard', 'paysafecard'], 'pointofsale' => ['mollie_methods_pointofsale', 'pointofsale'], + 'payconiq' => ['mollie_methods_payconiq', 'payconiq'], 'przelewy24' => ['mollie_methods_przelewy24', 'przelewy24'], 'riverty' => ['mollie_methods_riverty', 'riverty'], 'sofort' => ['mollie_methods_sofort', 'sofort'], diff --git a/Test/Integration/Model/Methods/PayconiqTest.php b/Test/Integration/Model/Methods/PayconiqTest.php new file mode 100644 index 00000000000..47c05927cc0 --- /dev/null +++ b/Test/Integration/Model/Methods/PayconiqTest.php @@ -0,0 +1,16 @@ +assertArrayHasKey('mollie_methods_paypal', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_paysafecard', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_pointofsale', $result['payment']['image']); + $this->assertArrayHasKey('mollie_methods_payconiq', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_przelewy24', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_riverty', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_sofort', $result['payment']['image']); diff --git a/Test/Integration/Service/Config/PaymentFeeTest.php b/Test/Integration/Service/Config/PaymentFeeTest.php index 1c5cfaff059..e7e70808710 100644 --- a/Test/Integration/Service/Config/PaymentFeeTest.php +++ b/Test/Integration/Service/Config/PaymentFeeTest.php @@ -46,6 +46,7 @@ public function isAvailableForMethodProvider() ['mollie_methods_paypal', true], ['mollie_methods_paysafecard', true], ['mollie_methods_pointofsale', true], + ['mollie_methods_payconiq', true], ['mollie_methods_przelewy24', true], ['mollie_methods_riverty', true], ['mollie_methods_sofort', true], diff --git a/etc/adminhtml/methods.xml b/etc/adminhtml/methods.xml index d8bc8482603..7417f0b9103 100644 --- a/etc/adminhtml/methods.xml +++ b/etc/adminhtml/methods.xml @@ -28,6 +28,7 @@ + diff --git a/etc/adminhtml/methods/payconiq.xml b/etc/adminhtml/methods/payconiq.xml new file mode 100644 index 00000000000..a6973f0d434 --- /dev/null +++ b/etc/adminhtml/methods/payconiq.xml @@ -0,0 +1,156 @@ + + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/mollie_methods_payconiq/active + + + + payment/mollie_methods_payconiq/title + + 1 + + + + + Mollie\Payment\Model\Adminhtml\Source\Method + payment/mollie_methods_payconiq/method + + 1 + + here + to read more about the differences between the Payment and Orders API.]]> + + + + payment/mollie_methods_payconiq/payment_description + + + payment + 1 + + + + + validate-digits-range digits-range-1-365 + payment/mollie_methods_payconiq/days_before_expire + + 1 + order + + How many days before orders for this method becomes expired? Leave empty to use default expiration (28 days) + + + + Magento\Payment\Model\Config\Source\Allspecificcountries + payment/mollie_methods_payconiq/allowspecific + + 1 + + + + + Magento\Directory\Model\Config\Source\Country + 1 + payment/mollie_methods_payconiq/specificcountry + + 1 + + + + + payment/mollie_methods_payconiq/min_order_total + + 1 + + + + + payment/mollie_methods_payconiq/max_order_total + + 1 + + + + + payment/mollie_methods_payconiq/payment_surcharge_type + Mollie\Payment\Model\Adminhtml\Source\PaymentFeeType + + 1 + + + + + payment/mollie_methods_payconiq/payment_surcharge_fixed_amount + Mollie\Payment\Model\Adminhtml\Backend\VerifiyPaymentFee + validate-not-negative-number + + 1 + fixed_fee,fixed_fee_and_percentage + + + + + payment/mollie_methods_payconiq/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_payconiq/payment_surcharge_limit + + Mollie\Payment\Model\Adminhtml\Backend\VerifiyPaymentFee + validate-not-negative-number + + 1 + percentage,fixed_fee_and_percentage + + + + + payment/mollie_methods_payconiq/payment_surcharge_tax_class + \Magento\Tax\Model\TaxClass\Source\Product + + 1 + fixed_fee,percentage,fixed_fee_and_percentage + + + + + validate-number + payment/mollie_methods_payconiq/sort_order + + 1 + + + + diff --git a/etc/adminhtml/methods/paymentlink.xml b/etc/adminhtml/methods/paymentlink.xml index eda0276c5c6..faa57c77a9b 100644 --- a/etc/adminhtml/methods/paymentlink.xml +++ b/etc/adminhtml/methods/paymentlink.xml @@ -1,7 +1,12 @@ + + - + + - + + - + + - + + - - - - - - 0 1 + + 1 + Mollie\Payment\Model\Methods\Payconiq + Payconiq + {ordernumber} + payment + order + 0 + + 1 + 1 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 1 Mollie\Payment\Model\Methods\Przelewy24 diff --git a/etc/di.xml b/etc/di.xml index 08b039519d8..2bfdac32221 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1597,6 +1597,51 @@ + + + + Magento\Payment\Block\Form + Mollie\Payment\Block\Info\Base + MolliePayconiqValueHandlerPool + MollieCommandPool + MolliePayconiqValidatorPool + + + + + + + MolliePayconiqConfigValueHandler + + + + + + + MolliePayconiqConfig + + + + + + Mollie\Payment\Model\Methods\Payconiq::CODE + + + + + + + MolliePayconiqCountryValidator + + + + + + + MolliePayconiqConfig + + + diff --git a/etc/graphql/di.xml b/etc/graphql/di.xml index cd45735746e..984530c1bb3 100644 --- a/etc/graphql/di.xml +++ b/etc/graphql/di.xml @@ -32,6 +32,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 15938bd2f81..390c0c4b327 100644 --- a/etc/payment.xml +++ b/etc/payment.xml @@ -78,6 +78,9 @@ 0 + + 0 + 0 diff --git a/i18n/de_DE.csv b/i18n/de_DE.csv index a0dc16054c9..4d74018075c 100644 --- a/i18n/de_DE.csv +++ b/i18n/de_DE.csv @@ -221,6 +221,7 @@ "Paypal","PayPal" "Paysafecard","Paysafecard" "Point Of Sale (POS)","Point Of Sale (POS)" +"Payconiq","Payconiq" "Przelewy24","Przelewy24" "Sofort","Sofort" "Trustly","Trustly" diff --git a/i18n/en_US.csv b/i18n/en_US.csv index 9ad7cf38b69..dddb3f72c2b 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -221,6 +221,7 @@ "Paypal","Paypal" "Paysafecard","Paysafecard" "Point Of Sale (POS)","Point Of Sale (POS)" +"Payconiq","Payconiq" "Przelewy24","Przelewy24" "Sofort","Sofort" "Trustly","Trustly" diff --git a/i18n/es_ES.csv b/i18n/es_ES.csv index 97ea9ba9482..b123e880cbd 100644 --- a/i18n/es_ES.csv +++ b/i18n/es_ES.csv @@ -221,6 +221,7 @@ "Paypal","Paypal" "Paysafecard","Paysafecard" "Point Of Sale (POS)","Point Of Sale (POS)" +"Payconiq","Payconiq" "Przelewy24","Przelewy24" "Sofort","Sofort" "Trustly","Trustly" diff --git a/i18n/fr_FR.csv b/i18n/fr_FR.csv index e074c0d5e8a..d6da30e74ea 100644 --- a/i18n/fr_FR.csv +++ b/i18n/fr_FR.csv @@ -221,6 +221,7 @@ "Paypal","PayPal" "Paysafecard","Paysafecard" "Point Of Sale (POS)","Point Of Sale (POS)" +"Payconiq","Payconiq" "Przelewy24","Przelewy24" "Sofort","Sofort" "Trustly","Trustly" diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv index c6ba9e346ae..6755231acee 100644 --- a/i18n/nl_NL.csv +++ b/i18n/nl_NL.csv @@ -221,6 +221,7 @@ "Paypal","PayPal" "Paysafecard","Paysafecard" "Point Of Sale (POS)","Point Of Sale (POS)" +"Payconiq","Payconiq" "Przelewy24","Przelewy24" "Sofort","Sofort" "Trustly","Trustly" diff --git a/view/adminhtml/web/images/payconiq.svg b/view/adminhtml/web/images/payconiq.svg new file mode 100644 index 00000000000..fd3dbfb937e --- /dev/null +++ b/view/adminhtml/web/images/payconiq.svg @@ -0,0 +1 @@ + diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 7c120a849ce..fcfcbaf60f6 100644 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -96,6 +96,9 @@ true + + true + true diff --git a/view/frontend/web/images/methods/payconiq.svg b/view/frontend/web/images/methods/payconiq.svg new file mode 100644 index 00000000000..fd3dbfb937e --- /dev/null +++ b/view/frontend/web/images/methods/payconiq.svg @@ -0,0 +1 @@ + diff --git a/view/frontend/web/js/view/payment/method-renderer.js b/view/frontend/web/js/view/payment/method-renderer.js index 817d373586b..bb93036566e 100644 --- a/view/frontend/web/js/view/payment/method-renderer.js +++ b/view/frontend/web/js/view/payment/method-renderer.js @@ -50,6 +50,7 @@ define( {type: 'mollie_methods_paypal', component: defaultComponent}, {type: 'mollie_methods_paysafecard', component: defaultComponent}, {type: 'mollie_methods_pointofsale', component: pointofsaleComponent}, + {type: 'mollie_methods_payconiq', component: defaultComponent}, {type: 'mollie_methods_przelewy24', component: defaultComponent}, {type: 'mollie_methods_riverty', component: defaultComponent}, {type: 'mollie_methods_sofort', component: defaultComponent}, From 4be7012c8f2724b8aed1ff047a3ca6badb04e6fc Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 19 Aug 2024 13:56:49 +0200 Subject: [PATCH 02/11] Improvement: New documentation link --- .../templates/system/config/button/documentation.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/adminhtml/templates/system/config/button/documentation.phtml b/view/adminhtml/templates/system/config/button/documentation.phtml index e7f1dbf7a90..98960b85fad 100644 --- a/view/adminhtml/templates/system/config/button/documentation.phtml +++ b/view/adminhtml/templates/system/config/button/documentation.phtml @@ -1,6 +1,6 @@ Open Documentation From b6847976737e118728047014c370a05507736978 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 19 Aug 2024 15:00:29 +0200 Subject: [PATCH 03/11] Bugfix: Prevent multiple customer addresses #800 --- view/frontend/web/js/view/checkout/save-payment-method.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/view/frontend/web/js/view/checkout/save-payment-method.js b/view/frontend/web/js/view/checkout/save-payment-method.js index 63562310f97..5bd1bc0208f 100644 --- a/view/frontend/web/js/view/checkout/save-payment-method.js +++ b/view/frontend/web/js/view/checkout/save-payment-method.js @@ -1,3 +1,8 @@ +/* + * Copyright Magmodules.eu. All rights reserved. + * See COPYING.txt for license details. + */ + define([ 'ko', 'uiComponent', @@ -64,7 +69,8 @@ define([ extension_attributes: {} }; - payload.billingAddress = quote.billingAddress(); + // Do not send the billing address, this is saved by Magento itself + // payload.billingAddress = quote.billingAddress(); /** * Problem: We need to set the payment method, therefor we created this function. The api call requires From 8d07b4c2e5c7c77d6a50a955faa5616f31d9261c Mon Sep 17 00:00:00 2001 From: Kiel Date: Tue, 20 Aug 2024 03:56:29 -0700 Subject: [PATCH 04/11] Open Mollie Dashboard in New Tab --- 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 8f813096ac3..ba2631b1070 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -50,7 +50,7 @@ showInWebsite="1" showInStore="1"> Mollie\Payment\Block\Adminhtml\Render\Heading - Mollie Profile.
]]> + Mollie Profile.
]]>
From 8b3c7019cf87449e2db710fe72b06bc016c40645 Mon Sep 17 00:00:00 2001 From: Julian Date: Tue, 27 Aug 2024 09:38:29 +0200 Subject: [PATCH 05/11] Added RestAPI compatibility with methods such as Apple Pay --- Webapi/StartTransaction.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Webapi/StartTransaction.php b/Webapi/StartTransaction.php index 7ac877d5392..2db1392b98a 100644 --- a/Webapi/StartTransaction.php +++ b/Webapi/StartTransaction.php @@ -10,6 +10,7 @@ use Magento\Sales\Api\OrderRepositoryInterface; use Mollie\Payment\Api\PaymentTokenRepositoryInterface; use Mollie\Payment\Api\Webapi\StartTransactionRequestInterface; +use Mollie\Payment\Service\Order\Transaction; class StartTransaction implements StartTransactionRequestInterface { @@ -23,12 +24,19 @@ class StartTransaction implements StartTransactionRequestInterface */ private $paymentTokenRepository; + /** + * @var Transaction + */ + private $transaction; + public function __construct( OrderRepositoryInterface $orderRepository, - PaymentTokenRepositoryInterface $paymentTokenRepository + PaymentTokenRepositoryInterface $paymentTokenRepository, + Transaction $transaction ) { $this->orderRepository = $orderRepository; $this->paymentTokenRepository = $paymentTokenRepository; + $this->transaction = $transaction; } /** @@ -45,6 +53,16 @@ public function execute(string $token) /** @var \Mollie\Payment\Model\Mollie $instance */ $instance = $order->getPayment()->getMethodInstance(); - return $instance->startTransaction($order); + $checkoutUrl = $instance->startTransaction($order); + if ($checkoutUrl !== null) { + return $checkoutUrl; + } + + // If the order is paid with a payment method without hosted payment page, + // we need to redirect to the success page. As the order is instantly paid. + return $this->transaction->getRedirectUrl( + $order, + $token + ); } } From 55610c7fd01e819a851f0e7879d55a516660295b Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 2 Sep 2024 10:02:32 +0200 Subject: [PATCH 06/11] Improvement: Implement a retry for point of sale orders #799 --- Api/Webapi/ResetCartInterface.php | 16 +++++ Controller/Checkout/Pointofsale.php | 70 ++++++++++++++++++- Webapi/ResetCart.php | 64 +++++++++++++++++ etc/di.xml | 1 + etc/webapi.xml | 15 ++-- .../templates/checkout/pointofsale/wait.phtml | 32 +++++++-- 6 files changed, 185 insertions(+), 13 deletions(-) create mode 100644 Api/Webapi/ResetCartInterface.php create mode 100644 Webapi/ResetCart.php diff --git a/Api/Webapi/ResetCartInterface.php b/Api/Webapi/ResetCartInterface.php new file mode 100644 index 00000000000..e730849bc43 --- /dev/null +++ b/Api/Webapi/ResetCartInterface.php @@ -0,0 +1,16 @@ +resultPageFactory = $resultPageFactory; $this->request = $request; $this->storeManager = $storeManager; + $this->url = $url; + $this->orderRepository = $orderRepository; + $this->encryptor = $encryptor; + $this->paymentTokenRepository = $paymentTokenRepository; + $this->generatePaymentToken = $generatePaymentToken; } public function execute() @@ -42,12 +83,35 @@ public function execute() throw new AuthorizationException(__('Invalid token')); } + $id = $this->encryptor->decrypt(base64_decode($token)); + $order = $this->orderRepository->get($id); + $resultPage = $this->resultPageFactory->create(); $resultPage->getConfig()->getTitle()->set(__('Please finish the payment on the terminal.')); $block = $resultPage->getLayout()->getBlock('mollie.pointofsale.wait'); - $block->setData('token', $token); - $block->setData('storeCode', $this->storeManager->getStore()->getCode()); + $block->setData( + 'status_url', + '/rest/' . $this->storeManager->getStore()->getCode() . '/V1/mollie/get-order/' . $token + ); + $block->setData( + 'reset_url', + '/rest/' . $this->storeManager->getStore()->getCode() . '/V1/mollie/reset-cart/' . $token + ); + $block->setData( + 'retry_url', + $this->url->getUrl('mollie/checkout/redirect', ['paymentToken' => $this->getToken($order)]) + ); return $resultPage; } + + private function getToken(OrderInterface $order): string + { + $token = $this->paymentTokenRepository->getByOrder($order); + if ($token) { + return $token->getToken(); + } + + return $this->generatePaymentToken->forOrder($order)->getToken(); + } } diff --git a/Webapi/ResetCart.php b/Webapi/ResetCart.php new file mode 100644 index 00000000000..d56fc7e25d1 --- /dev/null +++ b/Webapi/ResetCart.php @@ -0,0 +1,64 @@ +encryptor = $encryptor; + $this->orderRepository = $orderRepository; + $this->checkoutSession = $checkoutSession; + } + + public function byHash(string $hash): void + { + $decodedHash = base64_decode($hash); + $orderId = $this->encryptor->decrypt($decodedHash); + + $this->checkIfLastRealOrder((int)$orderId); + $this->checkoutSession->restoreQuote(); + } + + private function checkIfLastRealOrder(int $orderId) + { + if ($this->checkoutSession->getLastRealOrder()->getId()) { + return; + } + + try { + $order = $this->orderRepository->get($orderId); + $this->checkoutSession->setLastRealOrderId($order->getIncrementId()); + } catch (NoSuchEntityException $exception) { + // + } + } +} diff --git a/etc/di.xml b/etc/di.xml index 08b039519d8..1ae21046092 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -9,6 +9,7 @@ + diff --git a/etc/webapi.xml b/etc/webapi.xml index 7461462ccac..5c56d22ecb4 100644 --- a/etc/webapi.xml +++ b/etc/webapi.xml @@ -1,10 +1,8 @@ + ~ Copyright Magmodules.eu. All rights reserved. + ~ See COPYING.txt for license details. + --> @@ -51,6 +49,13 @@ + + + + + + + diff --git a/view/frontend/templates/checkout/pointofsale/wait.phtml b/view/frontend/templates/checkout/pointofsale/wait.phtml index 7d827205bf6..72132ab7cde 100644 --- a/view/frontend/templates/checkout/pointofsale/wait.phtml +++ b/view/frontend/templates/checkout/pointofsale/wait.phtml @@ -1,4 +1,8 @@ -
"}}'>
+
+ + From 7a2e18fa9a004bf09e0eea15d2b358117b6c4af6 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Thu, 5 Sep 2024 11:03:39 +0200 Subject: [PATCH 07/11] Improvement: Store Mollie payment method for better redirects --- Model/Client/Orders/Processors/AddAdditionalInformation.php | 1 + Model/Client/Payments.php | 1 + Model/Client/Payments/Processors/AddAdditionalInformation.php | 1 + Service/Mollie/ProcessTransaction.php | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Model/Client/Orders/Processors/AddAdditionalInformation.php b/Model/Client/Orders/Processors/AddAdditionalInformation.php index 25c54143864..adc24c1fd07 100644 --- a/Model/Client/Orders/Processors/AddAdditionalInformation.php +++ b/Model/Client/Orders/Processors/AddAdditionalInformation.php @@ -49,6 +49,7 @@ public function process(OrderInterface $magentoOrder, Order $mollieOrder, string $dashboardUrl = $this->dashboardUrl->forOrdersApi($magentoOrder->getStoreId(), $mollieOrder->id); $magentoOrder->getPayment()->setAdditionalInformation('mollie_id', $mollieOrder->id); $magentoOrder->getPayment()->setAdditionalInformation('dashboard_url', $dashboardUrl); + $magentoOrder->getPayment()->setAdditionalInformation('method', $mollieOrder->method); $status = $mollieOrder->status; $payment = $magentoOrder->getPayment(); diff --git a/Model/Client/Payments.php b/Model/Client/Payments.php index e3dade8f7c4..7b736eda987 100644 --- a/Model/Client/Payments.php +++ b/Model/Client/Payments.php @@ -341,6 +341,7 @@ public function processTransaction(Order $order, $mollieApi, $type = 'webhook', $dashboardUrl = $this->dashboardUrl->forPaymentsApi($order->getStoreId(), $paymentData->id); $order->getPayment()->setAdditionalInformation('dashboard_url', $dashboardUrl); $order->getPayment()->setAdditionalInformation('mollie_id', $paymentData->id); + $order->getPayment()->setAdditionalInformation('method', $paymentData->method); $status = $paymentData->status; $payment = $order->getPayment(); diff --git a/Model/Client/Payments/Processors/AddAdditionalInformation.php b/Model/Client/Payments/Processors/AddAdditionalInformation.php index 10987a4b48f..af5c3d3051c 100644 --- a/Model/Client/Payments/Processors/AddAdditionalInformation.php +++ b/Model/Client/Payments/Processors/AddAdditionalInformation.php @@ -43,6 +43,7 @@ public function process( $dashboardUrl = $this->dashboardUrl->forPaymentsApi($order->getStoreId(), $molliePayment->id); $magentoPayment->setAdditionalInformation('dashboard_url', $dashboardUrl); $magentoPayment->setAdditionalInformation('mollie_id', $molliePayment->id); + $magentoPayment->setAdditionalInformation('method', $molliePayment->method); $status = $molliePayment->status; if ($type == 'webhook' && $magentoPayment->getAdditionalInformation('payment_status') != $status) { diff --git a/Service/Mollie/ProcessTransaction.php b/Service/Mollie/ProcessTransaction.php index af33f5aefd6..cac73e2c204 100644 --- a/Service/Mollie/ProcessTransaction.php +++ b/Service/Mollie/ProcessTransaction.php @@ -78,7 +78,7 @@ public function execute(int $orderId, string $transactionId, string $type = 'web return $this->getMollieStatusResultFactory->create([ 'status' => $result['status'], - 'method' => $order->getPayment()->getMethod(), + 'method' => $order->getPayment()->getAdditionalInformation('method'), ]); } From 214bec35564c28566a7402daafa6e08e52326abe Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 2 Sep 2024 11:59:41 +0200 Subject: [PATCH 08/11] Improvement: Set checkout_url for payment link orders #806 --- .../SetCheckoutUrlForPaymentLink.php | 55 +++++++++++++++++++ Service/Mollie/GetMollieStatusResult.php | 4 +- etc/events.xml | 6 ++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 Observer/SalesModelServiceQuoteSubmitSuccess/SetCheckoutUrlForPaymentLink.php diff --git a/Observer/SalesModelServiceQuoteSubmitSuccess/SetCheckoutUrlForPaymentLink.php b/Observer/SalesModelServiceQuoteSubmitSuccess/SetCheckoutUrlForPaymentLink.php new file mode 100644 index 00000000000..0af342d3447 --- /dev/null +++ b/Observer/SalesModelServiceQuoteSubmitSuccess/SetCheckoutUrlForPaymentLink.php @@ -0,0 +1,55 @@ +paymentLinkUrl = $paymentLinkUrl; + $this->orderPaymentRepository = $orderPaymentRepository; + } + + public function execute(Observer $observer) + { + /** @var OrderInterface $order */ + $order = $observer->getEvent()->getData('order'); + + $payment = $order->getPayment(); + if ($payment->getMethod() != Paymentlink::CODE) { + return; + } + + $payment->setAdditionalInformation( + 'checkout_url', + $this->paymentLinkUrl->execute((int)$order->getEntityId()) + ); + + $this->orderPaymentRepository->save($payment); + } +} diff --git a/Service/Mollie/GetMollieStatusResult.php b/Service/Mollie/GetMollieStatusResult.php index cd421db4c62..d3697f9eb4f 100644 --- a/Service/Mollie/GetMollieStatusResult.php +++ b/Service/Mollie/GetMollieStatusResult.php @@ -23,7 +23,9 @@ public function __construct( string $status, string $method = null ) { - $method = str_replace('mollie_methods_', '', $method); + if ($method !== null) { + $method = str_replace('mollie_methods_', '', $method); + } $this->status = $status; $this->method = $method; diff --git a/etc/events.xml b/etc/events.xml index 6c9df6b8668..de771b9207c 100644 --- a/etc/events.xml +++ b/etc/events.xml @@ -1,4 +1,9 @@ + + @@ -29,6 +34,7 @@ + From d577537768455b0f8c516d706f9495af249dbd08 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 9 Sep 2024 09:14:07 +0200 Subject: [PATCH 09/11] Add fallback --- Service/Mollie/ProcessTransaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Service/Mollie/ProcessTransaction.php b/Service/Mollie/ProcessTransaction.php index cac73e2c204..5f9a270063b 100644 --- a/Service/Mollie/ProcessTransaction.php +++ b/Service/Mollie/ProcessTransaction.php @@ -78,7 +78,7 @@ public function execute(int $orderId, string $transactionId, string $type = 'web return $this->getMollieStatusResultFactory->create([ 'status' => $result['status'], - 'method' => $order->getPayment()->getAdditionalInformation('method'), + 'method' => $order->getPayment()->getAdditionalInformation('method') ?? $order->getPayment()->getMethod(), ]); } From 3773913d656636cca577b88f172a4d818f3a3471 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 9 Sep 2024 10:20:44 +0200 Subject: [PATCH 10/11] Add rel to the link --- 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 ba2631b1070..0fed8b0b094 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -50,7 +50,7 @@ showInWebsite="1" showInStore="1"> Mollie\Payment\Block\Adminhtml\Render\Heading - Mollie Profile.
]]>
+ Mollie Profile.
]]>
From 98b325fdc94c55b2f977cd9db572b7e06731197f Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Mon, 9 Sep 2024 19:55:40 +0200 Subject: [PATCH 11/11] 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 15a186b6f26..b2c65383da1 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "mollie/magento2", "description": "Mollie Payment Module for Magento 2", - "version": "2.40.1", + "version": "2.41.0", "keywords": [ "mollie", "payment", diff --git a/etc/config.xml b/etc/config.xml index 50c1976039b..6ef01a71507 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -8,7 +8,7 @@ - v2.40.1 + v2.41.0 0 0 test