diff --git a/.github/workflows/templates/magento/configure-mollie.sh b/.github/workflows/templates/magento/configure-mollie.sh index 3cab4876433..bb108fb6b65 100644 --- a/.github/workflows/templates/magento/configure-mollie.sh +++ b/.github/workflows/templates/magento/configure-mollie.sh @@ -1,3 +1,8 @@ +# +# Copyright Magmodules.eu. All rights reserved. +# See COPYING.txt for license details. +# + if [ -z "$MOLLIE_API_KEY_TEST" ]; then echo "Variable \$MOLLIE_API_KEY_TEST is not set" exit 1 @@ -23,6 +28,7 @@ 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_alma/active 1 & bin/magento config:set payment/mollie_methods_bancontact/active 1 & +bin/magento config:set payment/mollie_methods_bancomatpay/active 1 & bin/magento config:set payment/mollie_methods_belfius/active 1 & bin/magento config:set payment/mollie_methods_eps/active 1 & bin/magento config:set payment/mollie_methods_giropay/active 1 & diff --git a/Config.php b/Config.php index 6613d427cfe..b6eb4552763 100644 --- a/Config.php +++ b/Config.php @@ -1,5 +1,5 @@ isSetFlag(static::GENERAL_ENCRYPT_PAYMENT_DETAILS, $storeId); } + public function getApiMethod(string $method, int $storeId = null): string + { + return (string)$this->getPath( + $this->addMethodToPath(static::PAYMENT_METHOD_API_METHOD, $method), + $storeId + ); + } + /** * @param string $method * @param null|int|string $storeId diff --git a/Controller/ApplePay/PlaceOrder.php b/Controller/ApplePay/PlaceOrder.php index 0216edb7e50..6fa59109534 100644 --- a/Controller/ApplePay/PlaceOrder.php +++ b/Controller/ApplePay/PlaceOrder.php @@ -86,7 +86,13 @@ public function execute() $cart->setCustomerEmail($this->getRequest()->getParam('shippingAddress')['emailAddress']); - $shippingAddress->setShippingMethod($this->getRequest()->getParam('shippingMethod')['identifier']); + $shippingAddress->setShippingMethod( + str_replace( + '__SPLIT__', + '_', + $this->getRequest()->getParam('shippingMethod')['identifier'] + ) + ); $cart->setPaymentMethod('mollie_methods_applepay'); $cart->setCustomerIsGuest(true); diff --git a/Controller/ApplePay/ShippingMethods.php b/Controller/ApplePay/ShippingMethods.php index 6f04908b837..9912219f742 100644 --- a/Controller/ApplePay/ShippingMethods.php +++ b/Controller/ApplePay/ShippingMethods.php @@ -87,7 +87,9 @@ public function execute() return $response->setData([ 'shipping_methods' => array_map(function ($method) { return [ - 'identifier' => $method->getCarrierCode() . '_' . $method->getMethodCode(), + // Magento uses an _ (underscore) to separate the carrier and method, but those can have an + // underscore as well. So separate by a different divider to prevent errors. + 'identifier' => $method->getCarrierCode() . '__SPLIT__' . $method->getMethodCode(), 'label' => $method->getMethodTitle() . ' - ' . $method->getCarrierTitle(), 'amount' => number_format($method->getPriceInclTax() ?: 0.0, 2, '.', ''), 'detail' => '', diff --git a/Helper/General.php b/Helper/General.php index 242f055885d..12de810bf54 100755 --- a/Helper/General.php +++ b/Helper/General.php @@ -381,7 +381,7 @@ public function getMethodCode($order): string */ public function getApiMethod(OrderInterface $order) { - $method = $order->getPayment()->getMethodInstance()->getCode(); + $method = $order->getPayment()->getMethod(); $method = str_replace('_vault', '', $method); $methodXpath = str_replace('%method%', $method, self::XML_PATH_API_METHOD); return $this->getStoreConfig($methodXpath, $order->getStoreId()); @@ -621,6 +621,7 @@ public function getAllActiveMethods($storeId) $methodCodes = [ 'mollie_methods_applepay', 'mollie_methods_alma', + 'mollie_methods_bancomatpay', 'mollie_methods_bancontact', 'mollie_methods_banktransfer', 'mollie_methods_belfius', diff --git a/Model/Client/Orders.php b/Model/Client/Orders.php index f22353a9ac2..9f5f721cd9b 100644 --- a/Model/Client/Orders.php +++ b/Model/Client/Orders.php @@ -1,6 +1,6 @@ orderLines = $orderLines; + $this->orderOrderLines = $orderOrderLines; $this->invoiceSender = $invoiceSender; $this->orderRepository = $orderRepository; $this->checkoutSession = $checkoutSession; @@ -224,8 +231,10 @@ public function startTransaction(OrderInterface $order, $mollieApi) $additionalData = $order->getPayment()->getAdditionalInformation(); $transactionId = $order->getMollieTransactionId(); - if (!empty($transactionId)) { - return $this->getCheckoutUrl($mollieApi, $order); + if (!empty($transactionId) && + $checkoutUrl = $this->getCheckoutUrl($mollieApi, $order) + ) { + return $checkoutUrl; } $paymentToken = $this->paymentTokenForOrder->execute($order); @@ -236,7 +245,7 @@ public function startTransaction(OrderInterface $order, $mollieApi) 'orderNumber' => $order->getIncrementId(), 'billingAddress' => $this->getAddressLine($order->getBillingAddress()), 'consumerDateOfBirth' => null, - 'lines' => $this->orderLines->getOrderLines($order), + 'lines' => $this->orderOrderLines->get($order), 'redirectUrl' => $this->transaction->getRedirectUrl($order, $paymentToken), 'webhookUrl' => $this->transaction->getWebhookUrl([$order]), 'locale' => $this->mollieHelper->getLocaleCode($storeId, self::CHECKOUT_TYPE), @@ -308,7 +317,7 @@ public function getAddressLine($address) * * @throws LocalizedException */ - public function processResponse(Order $order, $mollieOrder) + public function processResponse(OrderInterface $order, MollieOrder $mollieOrder): void { $eventData = [ 'order' => $order, diff --git a/Model/Client/Payments.php b/Model/Client/Payments.php index f490100d980..e14f815d48b 100644 --- a/Model/Client/Payments.php +++ b/Model/Client/Payments.php @@ -1,6 +1,6 @@ getEntityId(); $transactionId = $order->getMollieTransactionId(); - if (!empty($transactionId) && substr($transactionId, 0, 4) != 'ord_') { - $payment = $mollieApi->payments->get($transactionId); - return $payment->getCheckoutUrl(); + if (!empty($transactionId) && + substr($transactionId, 0, 4) != 'ord_' && + $checkoutUrl = $this->getCheckoutUrl($mollieApi, $transactionId) + ) { + return $checkoutUrl; } $paymentToken = $this->paymentTokenForOrder->execute($order); @@ -537,4 +539,16 @@ public function checkCheckoutSession(Order $order, $paymentToken, $paymentData, } } } + + /** + * @param MollieApiClient $mollieApi + * @param $transactionId + * @return string|null + * @throws \Mollie\Api\Exceptions\ApiException + */ + public function getCheckoutUrl(MollieApiClient $mollieApi, $transactionId): ?string + { + $payment = $mollieApi->payments->get($transactionId); + return $payment->getCheckoutUrl(); + } } diff --git a/Model/Methods/Bancomatpay.php b/Model/Methods/Bancomatpay.php new file mode 100644 index 00000000000..282a9a027e4 --- /dev/null +++ b/Model/Methods/Bancomatpay.php @@ -0,0 +1,24 @@ +getOrder(); $order->setCanSendNewEmailFlag(false); + $stateObject->setState(Order::STATE_PENDING_PAYMENT); + if ($status = $this->config->statusNewPaymentLink($order->getStoreId())) { $stateObject->setStatus($status); } diff --git a/Model/Methods/Reorder.php b/Model/Methods/Reorder.php index 15de29109a7..400f05ab15f 100644 --- a/Model/Methods/Reorder.php +++ b/Model/Methods/Reorder.php @@ -1,6 +1,6 @@ orderLockService = $orderLockService; $this->mollieApiClient = $mollieApiClient; $this->transactionToOrderRepository = $transactionToOrderRepository; + $this->getApiMethod = $getApiMethod; } public function getCode() @@ -258,7 +265,7 @@ public function startTransaction(Order $order) return $this->orderLockService->execute($order, function (OrderInterface $order) use ($apiKey) { $mollieApi = $this->loadMollieApi($apiKey); - $method = $this->mollieHelper->getApiMethod($order); + $method = $this->getApiMethod->execute($order); // When clicking the back button from the hosted payment we need a way to verify if the order was paid or not. // If this is not the case, we restore the quote. This flag is used to determine if it was paid or not. diff --git a/Model/MollieConfigProvider.php b/Model/MollieConfigProvider.php index f381b36d0eb..bdd439fa22f 100644 --- a/Model/MollieConfigProvider.php +++ b/Model/MollieConfigProvider.php @@ -35,6 +35,7 @@ class MollieConfigProvider implements ConfigProviderInterface private $methodCodes = [ 'mollie_methods_applepay', 'mollie_methods_alma', + 'mollie_methods_bancomatpay', 'mollie_methods_bancontact', 'mollie_methods_banktransfer', 'mollie_methods_belfius', diff --git a/Model/OrderLines.php b/Model/OrderLines.php index f1eaf9ef20d..5375d64899d 100644 --- a/Model/OrderLines.php +++ b/Model/OrderLines.php @@ -280,7 +280,7 @@ public function getCreditmemoOrderLines(CreditmemoInterface $creditmemo, bool $a foreach ($creditmemo->getAllItems() as $item) { $orderItemId = $item->getOrderItemId(); $lineId = $this->getOrderLineByItemId($orderItemId)->getLineId(); - if (!$lineId || $item->getOrderItem()->getProductType() == 'bundle') { + if (!$lineId || $this->shouldSkipCreditmemoForBundleProduct($item)) { continue; } @@ -425,6 +425,19 @@ public function _construct() $this->_init('Mollie\Payment\Model\ResourceModel\OrderLines'); } + private function shouldSkipCreditmemoForBundleProduct(CreditmemoItemInterface $item): bool + { + if ($item->getOrderItem()->getProductType() != 'bundle') { + return false; + } + + if ($item->getOrderItem()->getProductOptionByCode('product_calculations') == 1) { + return false; + } + + return true; + } + /** * @param OrderInterface $order * @param int $forceBaseCurrency diff --git a/README.md b/README.md index 2d5732cbabe..4d13d788f85 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Mollie requires no minimum costs, no fixed contracts, no hidden costs. At Mollie - Apple Pay (direct) - Alma - Bancontact +- Bancomat Pay - Bank transfer - Belfius Pay Button - Billie diff --git a/Service/Magento/ApplePayDomainAssociationRouter.php b/Service/Magento/ApplePayDomainAssociationRouter.php index ed59fa7d1e0..a7ef4474610 100644 --- a/Service/Magento/ApplePayDomainAssociationRouter.php +++ b/Service/Magento/ApplePayDomainAssociationRouter.php @@ -53,7 +53,6 @@ public function match(RequestInterface $request) } $actionClassName = $this->actionList->get($modules[0], null, 'ApplePay', 'AppleDeveloperMerchantidDomainAssociation'); - $actionInstance = $this->actionFactory->create($actionClassName); - return $actionInstance; + return $this->actionFactory->create($actionClassName); } } diff --git a/Service/Magento/ChangeShippingMethodForQuote.php b/Service/Magento/ChangeShippingMethodForQuote.php index 1403b0e42e3..572bd2b1add 100644 --- a/Service/Magento/ChangeShippingMethodForQuote.php +++ b/Service/Magento/ChangeShippingMethodForQuote.php @@ -37,7 +37,7 @@ public function execute(AddressInterface $address, string $identifier): void $address->setCollectShippingRates(true); $address->setShippingMethod($identifier); - [$carrierCode, $methodCode] = explode('_', $identifier); + [$carrierCode, $methodCode] = explode('__SPLIT__', $identifier); $shippingInformation = $this->shippingInformationFactory->create([ 'data' => [ ShippingInformationInterface::SHIPPING_ADDRESS => $address, diff --git a/Service/Mollie/GetApiMethod.php b/Service/Mollie/GetApiMethod.php new file mode 100644 index 00000000000..dc0e2642acc --- /dev/null +++ b/Service/Mollie/GetApiMethod.php @@ -0,0 +1,44 @@ +methodCode = $methodCode; + $this->config = $config; + } + + /** + * @param OrderInterface $order + * @return string 'order' or 'payment' + */ + public function execute(OrderInterface $order): string + { + $method = $this->methodCode->execute($order); + $storeId = $order->getStoreId() == null ? null : (int)$order->getStoreId(); + return $this->config->getApiMethod($method, $storeId); + } +} diff --git a/Service/Mollie/PaymentMethods.php b/Service/Mollie/PaymentMethods.php index 5cd713637e3..e1a9927843c 100644 --- a/Service/Mollie/PaymentMethods.php +++ b/Service/Mollie/PaymentMethods.php @@ -27,6 +27,7 @@ public function __construct( private $methods = [ 'mollie_methods_applepay', 'mollie_methods_alma', + 'mollie_methods_bancomatpay', 'mollie_methods_bancontact', 'mollie_methods_banktransfer', 'mollie_methods_belfius', diff --git a/Service/Order/Lines/Order.php b/Service/Order/Lines/Order.php index ec28e4646be..d45c231cd75 100644 --- a/Service/Order/Lines/Order.php +++ b/Service/Order/Lines/Order.php @@ -13,6 +13,7 @@ use Mollie\Payment\Helper\General as MollieHelper; use Mollie\Payment\Model\OrderLines; use Mollie\Payment\Model\OrderLinesFactory; +use Mollie\Payment\Model\ResourceModel\OrderLines\CollectionFactory; class Order { @@ -51,6 +52,11 @@ class Order */ private $order; + /** + * @var CollectionFactory + */ + private $orderLinesCollectionFactory; + /** * @var OrderLinesProcessor */ @@ -60,7 +66,6 @@ class Order * @var OrderLinesGenerator */ private $orderLinesGenerator; - /** * @var StoreManagerInterface */ @@ -70,6 +75,7 @@ public function __construct( MollieHelper $mollieHelper, StoreCredit $storeCredit, PaymentFee $paymentFee, + CollectionFactory $orderLinesCollection, OrderLinesFactory $orderLinesFactory, OrderLinesProcessor $orderLinesProcessor, OrderLinesGenerator $orderLinesGenerator, @@ -78,6 +84,7 @@ public function __construct( $this->mollieHelper = $mollieHelper; $this->storeCredit = $storeCredit; $this->paymentFee = $paymentFee; + $this->orderLinesCollectionFactory = $orderLinesCollection; $this->orderLinesFactory = $orderLinesFactory; $this->orderLinesProcessor = $orderLinesProcessor; $this->orderLinesGenerator = $orderLinesGenerator; @@ -313,6 +320,14 @@ public function getShippingVatRate(OrderInterface $order) */ public function saveOrderLines($orderLines, OrderInterface $order) { + $existingItems = $this->orderLinesCollectionFactory->create() + ->addFieldToFilter('order_id', ['eq' => $order->getEntityId()]); + + // When the orderLines already exists, do not create again. + if ($existingItems->getSize() == count($orderLines)) { + return; + } + foreach ($orderLines as $line) { /** @var OrderLines $orderLine */ $orderLine = $this->orderLinesFactory->create(); diff --git a/Test/End-2-end/cypress/e2e/magento/applepay.cy.js b/Test/End-2-end/cypress/e2e/magento/applepay.cy.js index 926601a5016..a2b57db38c8 100644 --- a/Test/End-2-end/cypress/e2e/magento/applepay.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/applepay.cy.js @@ -8,7 +8,7 @@ describe('Apple Pay', () => { cy.request('/.well-known/apple-developer-merchantid-domain-association') .then((response) => { expect(response.body).to.satisfy(body => body.startsWith('7B2270737')); - expect(response.body.trim()).to.satisfy(body => body.endsWith('837303533303738636562626638326462306561376633303030303030303030303030227D')); + expect(response.body.trim()).to.satisfy(body => body.endsWith('265373839353336646432646335323937366561613237663939333566386330353164393963303030303030303030303030227D')); }); }); }); diff --git a/Test/End-2-end/cypress/e2e/magento/checkout.cy.js b/Test/End-2-end/cypress/e2e/magento/checkout.cy.js index e6627a4d027..dfe1fe600c6 100644 --- a/Test/End-2-end/cypress/e2e/magento/checkout.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/checkout.cy.js @@ -29,6 +29,7 @@ describe('Checkout usage', () => { const availableMethods = Cypress.env('mollie_available_methods'); [ 'alma', + 'bancomatpay', 'bancontact', 'banktransfer', 'belfius', diff --git a/Test/End-2-end/cypress/e2e/magento/methods/bancomatpay.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/bancomatpay.cy.js new file mode 100644 index 00000000000..03544549aee --- /dev/null +++ b/Test/End-2-end/cypress/e2e/magento/methods/bancomatpay.cy.js @@ -0,0 +1,60 @@ +/* + * Copyright Magmodules.eu. All rights reserved. + * See COPYING.txt for license details. + */ + +import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage"; +import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction"; +import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage"; +import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage"; +import OrdersPage from "Pages/backend/OrdersPage"; +import CartPage from "Pages/frontend/CartPage"; + +const checkoutPaymentPage = new CheckoutPaymentPage(); +const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); +const mollieHostedPaymentPage = new MollieHostedPaymentPage(); +const checkoutSuccessPage = new CheckoutSuccessPage(); +const ordersPage = new OrdersPage(); +const cartPage = new CartPage(); + +if (Cypress.env('mollie_available_methods').includes('bancomatpay')) { + describe('Check that bancomatpay behaves as expected', () => { + [ + {status: 'paid', orderStatus: 'Processing', title: 'C3190598: Validate the submission of an order with Bancomat Pay as payment method and payment mark as "Paid"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3190599: Validate the submission of an order with Bancomat Pay as payment method and payment mark as "Failed" '}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3190600: Validate the submission of an order with Bancomat Pay as payment method and payment mark as "Expired" '}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3190601: Validate the submission of an order with Bancomat Pay as payment method and payment mark as "Cancelled" '}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); + + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + + checkoutPaymentPage.selectPaymentMethod('Bancomat Pay'); + 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/Integration/Etc/Config/MethodsConfigurationTest.php b/Test/Integration/Etc/Config/MethodsConfigurationTest.php index b5dd4a45797..a4ee19885f8 100644 --- a/Test/Integration/Etc/Config/MethodsConfigurationTest.php +++ b/Test/Integration/Etc/Config/MethodsConfigurationTest.php @@ -16,6 +16,7 @@ public function methods(): array return [ ['mollie_methods_applepay'], ['mollie_methods_alma'], + ['mollie_methods_bancomatpay'], ['mollie_methods_bancontact'], ['mollie_methods_banktransfer'], ['mollie_methods_belfius'], diff --git a/Test/Integration/Helper/GeneralTest.php b/Test/Integration/Helper/GeneralTest.php index 2361be46d23..1dd7fb46fab 100644 --- a/Test/Integration/Helper/GeneralTest.php +++ b/Test/Integration/Helper/GeneralTest.php @@ -143,6 +143,7 @@ public function getMethodCodeDataProvider() 'applepay' => ['mollie_methods_applepay', 'applepay'], 'alma' => ['mollie_methods_alma', 'alma'], + 'bancomatpay' => ['mollie_methods_bancomatpay', 'bancomatpay'], 'bancontact' => ['mollie_methods_bancontact', 'bancontact'], 'banktransfer' => ['mollie_methods_banktransfer', 'banktransfer'], 'belfius' => ['mollie_methods_belfius', 'belfius'], diff --git a/Test/Integration/Model/Methods/BancomatpayTest.php b/Test/Integration/Model/Methods/BancomatpayTest.php new file mode 100644 index 00000000000..f50575aeeb5 --- /dev/null +++ b/Test/Integration/Model/Methods/BancomatpayTest.php @@ -0,0 +1,16 @@ +assertArrayHasKey('mollie_methods_applepay', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_alma', $result['payment']['image']); + $this->assertArrayHasKey('mollie_methods_bancomatpay', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_bancontact', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_banktransfer', $result['payment']['image']); $this->assertArrayHasKey('mollie_methods_belfius', $result['payment']['image']); diff --git a/Test/Integration/Model/MollieTest.php b/Test/Integration/Model/MollieTest.php index 1e325fa163b..4ea3f34ba8d 100644 --- a/Test/Integration/Model/MollieTest.php +++ b/Test/Integration/Model/MollieTest.php @@ -1,4 +1,8 @@ objectManager->create(OrderInterface::class); $order->setEntityId(1); - $order->setPayment($this->objectManager->create(OrderPaymentInterface::class)); - - $helperMock = $this->createMock(\Mollie\Payment\Helper\General::class); - $helperMock->method('getApiKey')->willReturn('test_dummyapikeywhichmustbe30characterslong'); - $helperMock->method('getApiMethod')->willReturn('order'); + $payment = $this->objectManager->create(OrderPaymentInterface::class); + $payment->setMethod('mollie_methods_ideal'); + $order->setPayment($payment); $ordersApiMock = $this->createMock(Orders::class); $ordersApiMock->method('startTransaction')->willReturn('order'); @@ -104,7 +111,6 @@ public function testStartTransactionWithMethodOrder() $instance = $this->objectManager->create(Mollie::class, [ 'ordersApi' => $ordersApiMock, 'paymentsApi' => $paymentsApiMock, - 'mollieHelper' => $helperMock, ]); $result = $instance->startTransaction($order); @@ -112,16 +118,19 @@ public function testStartTransactionWithMethodOrder() $this->assertEquals('order', $result); } + /** + * @magentoConfigFixture default_store payment/mollie_methods_ideal/method payment + * @magentoConfigFixture default_store payment/mollie_general/mode test + * @magentoConfigFixture default_store payment/mollie_general/apikey_test test_dummyapikeywhichmustbe30characterslong + */ public function testStartTransactionWithMethodPayment() { /** @var OrderInterface $order */ $order = $this->objectManager->create(OrderInterface::class); $order->setEntityId(1); - $order->setPayment($this->objectManager->create(OrderPaymentInterface::class)); - - $helperMock = $this->createMock(\Mollie\Payment\Helper\General::class); - $helperMock->method('getApiKey')->willReturn('test_dummyapikeywhichmustbe30characterslong'); - $helperMock->method('getApiMethod')->willReturn('payment'); + $payment = $this->objectManager->create(OrderPaymentInterface::class); + $payment->setMethod('mollie_methods_ideal'); + $order->setPayment($payment); $ordersApiMock = $this->createMock(Orders::class); $ordersApiMock->expects($this->never())->method('startTransaction'); @@ -133,7 +142,6 @@ public function testStartTransactionWithMethodPayment() $instance = $this->objectManager->create(Mollie::class, [ 'ordersApi' => $ordersApiMock, 'paymentsApi' => $paymentsApiMock, - 'mollieHelper' => $helperMock, ]); $result = $instance->startTransaction($order); @@ -142,20 +150,18 @@ public function testStartTransactionWithMethodPayment() } /** - * @throws \Magento\Framework\Exception\LocalizedException - * @throws \Mollie\Api\Exceptions\ApiException - * @throws \ReflectionException + * @magentoConfigFixture default_store payment/mollie_methods_ideal/method order + * @magentoConfigFixture default_store payment/mollie_general/mode test + * @magentoConfigFixture default_store payment/mollie_general/apikey_test test_dummyapikeywhichmustbe30characterslong */ public function testRetriesOnACurlTimeout() { /** @var OrderInterface $order */ $order = $this->objectManager->create(OrderInterface::class); $order->setEntityId(1); - $order->setPayment($this->objectManager->create(OrderPaymentInterface::class)); - - $helperMock = $this->createMock(\Mollie\Payment\Helper\General::class); - $helperMock->method('getApiKey')->willReturn('test_dummyapikeywhichmustbe30characterslong'); - $helperMock->method('getApiMethod')->willReturn('order'); + $payment = $this->objectManager->create(OrderPaymentInterface::class); + $payment->setMethod('mollie_methods_ideal'); + $order->setPayment($payment); $ordersApiMock = $this->createMock(Orders::class); $ordersApiMock->expects($this->exactly(3))->method('startTransaction')->willThrowException( @@ -172,7 +178,6 @@ public function testRetriesOnACurlTimeout() $instance = $this->objectManager->create(Mollie::class, [ 'ordersApi' => $ordersApiMock, 'paymentsApi' => $paymentsApiMock, - 'mollieHelper' => $helperMock, ]); $result = $instance->startTransaction($order); diff --git a/Test/Integration/Service/Config/PaymentFeeTest.php b/Test/Integration/Service/Config/PaymentFeeTest.php index 13388b2c0e3..dc680f8e83a 100644 --- a/Test/Integration/Service/Config/PaymentFeeTest.php +++ b/Test/Integration/Service/Config/PaymentFeeTest.php @@ -25,6 +25,7 @@ public function isAvailableForMethodProvider() return [ ['mollie_methods_applepay', true], ['mollie_methods_alma', true], + ['mollie_methods_bancomatpay', true], ['mollie_methods_bancontact', true], ['mollie_methods_banktransfer', true], ['mollie_methods_belfius', true], diff --git a/Test/Integration/Service/Mollie/Order/CreateInvoiceOnShipmentTest.php b/Test/Integration/Service/Mollie/Order/CreateInvoiceOnShipmentTest.php index fa68bb60df7..53e3c288c86 100644 --- a/Test/Integration/Service/Mollie/Order/CreateInvoiceOnShipmentTest.php +++ b/Test/Integration/Service/Mollie/Order/CreateInvoiceOnShipmentTest.php @@ -2,7 +2,6 @@ namespace Mollie\Payment\Test\Integration\Service\Mollie\Order; -use Mollie\Payment\Model\Adminhtml\Source\InvoiceMoment; use Mollie\Payment\Model\Methods\Bancontact; use Mollie\Payment\Model\Methods\Banktransfer; use Mollie\Payment\Model\Methods\Billie; diff --git a/composer.json b/composer.json index e10f2156b2c..5cdc7716238 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "mollie/magento2", "description": "Mollie Payment Module for Magento 2", - "version": "2.37.0", + "version": "2.38.0", "keywords": [ "mollie", "payment", @@ -9,6 +9,8 @@ "apple pay", "alma", "bancontact", + "bancomat", + "bancomat pay", "banktransfer", "belfius", "belfius direct net", diff --git a/etc/adminhtml/methods.xml b/etc/adminhtml/methods.xml index d3402c05eb3..7a31d6028ce 100644 --- a/etc/adminhtml/methods.xml +++ b/etc/adminhtml/methods.xml @@ -7,6 +7,7 @@ + diff --git a/etc/adminhtml/methods/applepay.xml b/etc/adminhtml/methods/applepay.xml index 0fefe3579f8..0fedcfc76ed 100644 --- a/etc/adminhtml/methods/applepay.xml +++ b/etc/adminhtml/methods/applepay.xml @@ -85,6 +85,7 @@ Mollie\Payment\Model\Adminhtml\Source\ApplePayButtonColor 1 + direct 1 @@ -98,6 +99,7 @@ Mollie\Payment\Model\Adminhtml\Source\ApplePayButtonText 1 + direct 1 @@ -124,6 +126,7 @@ Mollie\Payment\Model\Adminhtml\Source\ApplePayButtonColor 1 + direct 1 @@ -137,6 +140,7 @@ Mollie\Payment\Model\Adminhtml\Source\ApplePayButtonText 1 + direct 1 diff --git a/etc/adminhtml/methods/bancomatpay.xml b/etc/adminhtml/methods/bancomatpay.xml new file mode 100644 index 00000000000..98a7ad21326 --- /dev/null +++ b/etc/adminhtml/methods/bancomatpay.xml @@ -0,0 +1,156 @@ + + + + + + + + + Magento\Config\Model\Config\Source\Yesno + payment/mollie_methods_bancomatpay/active + + + + payment/mollie_methods_bancomatpay/title + + 1 + + + + + Mollie\Payment\Model\Adminhtml\Source\Method + payment/mollie_methods_bancomatpay/method + + 1 + + here + to read more about the differences between the Payment and Orders API.]]> + + + + payment/mollie_methods_bancomatpay/payment_description + + + payment + 1 + + + + + validate-digits-range digits-range-1-365 + payment/mollie_methods_bancomatpay/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_bancomatpay/allowspecific + + 1 + + + + + Magento\Directory\Model\Config\Source\Country + 1 + payment/mollie_methods_bancomatpay/specificcountry + + 1 + + + + + payment/mollie_methods_bancomatpay/min_order_total + + 1 + + + + + payment/mollie_methods_bancomatpay/max_order_total + + 1 + + + + + payment/mollie_methods_bancomatpay/payment_surcharge_type + Mollie\Payment\Model\Adminhtml\Source\PaymentFeeType + + 1 + + + + + payment/mollie_methods_bancomatpay/payment_surcharge_fixed_amount + Mollie\Payment\Model\Adminhtml\Backend\VerifiyPaymentFee + validate-not-negative-number + + 1 + fixed_fee,fixed_fee_and_percentage + + + + + payment/mollie_methods_bancomatpay/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_bancomatpay/payment_surcharge_limit + + Mollie\Payment\Model\Adminhtml\Backend\VerifiyPaymentFee + validate-not-negative-number + + 1 + percentage,fixed_fee_and_percentage + + + + + payment/mollie_methods_bancomatpay/payment_surcharge_tax_class + \Magento\Tax\Model\TaxClass\Source\Product + + 1 + fixed_fee,percentage,fixed_fee_and_percentage + + + + + validate-number + payment/mollie_methods_bancomatpay/sort_order + + 1 + + + + diff --git a/etc/adminhtml/methods/bancontact.xml b/etc/adminhtml/methods/bancontact.xml index 74a44308b04..28fbf32e411 100644 --- a/etc/adminhtml/methods/bancontact.xml +++ b/etc/adminhtml/methods/bancontact.xml @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + - v2.37.0 + v2.38.0 0 0 test @@ -109,6 +114,25 @@ 0 1 + + 1 + Mollie\Payment\Model\Methods\Bancomatpay + Bancomat Pay + {ordernumber} + payment + order + 0 + + 1 + 1 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 1 Mollie\Payment\Model\Methods\Banktransfer diff --git a/etc/di.xml b/etc/di.xml index 9fb71038043..7eb6a9fdbe6 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1,4 +1,9 @@ + + @@ -507,6 +512,51 @@ + + + + Magento\Payment\Block\Form + Mollie\Payment\Block\Info\Base + MollieBancomatpayValueHandlerPool + MollieCommandPool + MollieBancomatpayValidatorPool + + + + + + + MollieBancomatpayConfigValueHandler + + + + + + + MollieBancomatpayConfig + + + + + + Mollie\Payment\Model\Methods\Bancomatpay::CODE + + + + + + + MollieBancomatpayCountryValidator + + + + + + + MollieBancomatpayConfig + + + diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index c9b92ccfd7a..c18133a0f75 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -5,7 +5,7 @@ Mollie\Payment\Service\Magento\ApplePayDomainAssociationRouter - 10 + 9 diff --git a/etc/graphql/di.xml b/etc/graphql/di.xml index 5017366df3e..bffa9f50add 100644 --- a/etc/graphql/di.xml +++ b/etc/graphql/di.xml @@ -10,6 +10,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 diff --git a/etc/payment.xml b/etc/payment.xml index 16c2a8ede56..774d1d7a692 100644 --- a/etc/payment.xml +++ b/etc/payment.xml @@ -15,6 +15,9 @@ 0 + + 0 + 0 diff --git a/i18n/de_DE.csv b/i18n/de_DE.csv index 55074350eb4..5f5c7067919 100644 --- a/i18n/de_DE.csv +++ b/i18n/de_DE.csv @@ -194,6 +194,7 @@ "Sorting Order","Sortierreihenfolge" "Alma","Alma" "Bancontact","Bancontact" +"Bancomat Pay","Bancomat Pay" "Banktransfer","Banküberweisung" "Status Pending","Status ausstehend" "We recommend using another 'pending' status as the default Magento pending status can automatically cancel the order before the payment expiry time is reached.
By default the status ""Pending Payment"" is not visible for customers, therefore we advise you to create a new status for this, which should also be visible to the customer, informing them they still have to complete their payment.","Wir empfehlen, einen anderen als den standardmäßigen ausstehenden Status von Magento zu verwenden, da die Zahlung bei diesem vor Ablauf der Zahlungsfrist automatisch storniert werden kann.
Standardmäßig ist der Status „Ausstehende Zahlung“ für den Kunden nicht sichtbar. Wir empfehlen Ihnen daher, einen neuen Status zu erstellen, der auch für den Kunden sichtbar ist und ihm mitteilt, dass er die Zahlung noch vervollständigen muss." diff --git a/i18n/en_US.csv b/i18n/en_US.csv index b09a1b55a5c..47dd21fa85c 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -194,6 +194,7 @@ "Sorting Order","Sorting Order" "Alma","Alma" "Bancontact","Bancontact" +"Bancomat Pay","Bancomat Pay" "Banktransfer","Banktransfer" "Status Pending","Status Pending" "We recommend using another 'pending' status as the default Magento pending status can automatically cancel the order before the payment expiry time is reached.
By default the status ""Pending Payment"" is not visible for customers, therefore we advise you to create a new status for this, which should also be visible to the customer, informing them they still have to complete their payment.","We recommend using another 'pending' status as the default Magento pending status can automatically cancel the order before the payment expiry time is reached.
By default the status ""Pending Payment"" is not visible for customers, therefore we advise you to create a new status for this, which should also be visible to the customer, informing them they still have to complete their payment." diff --git a/i18n/es_ES.csv b/i18n/es_ES.csv index b8a8db57c49..c15a6c313dc 100644 --- a/i18n/es_ES.csv +++ b/i18n/es_ES.csv @@ -194,6 +194,7 @@ "Sorting Order","Orden de clasificación" "Alma","Alma" "Bancontact","Contacto bancario" +"Bancomat Pay","Bancomat Pay" "Banktransfer","Transferencia bancaria" "Status Pending","Estado pendiente" "We recommend using another 'pending' status as the default Magento pending status can automatically cancel the order before the payment expiry time is reached.
By default the status ""Pending Payment"" is not visible for customers, therefore we advise you to create a new status for this, which should also be visible to the customer, informing them they still have to complete their payment.","Recomendamos utilizar otro estado 'pendiente', ya que el estado pendiente por defecto de Magento puede cancelar automáticamente el pedido antes de que se llegue a la fecha de vencimiento del pago.
Por defecto, el estado «Pago pendiente» no es visible para los clientes, por lo que le aconsejamos que cree un nuevo estado para esto, que también debería ser visible para el cliente, que le informe de que todavía tiene que completar su pago." diff --git a/i18n/fr_FR.csv b/i18n/fr_FR.csv index 4128f6df607..364504e61d7 100644 --- a/i18n/fr_FR.csv +++ b/i18n/fr_FR.csv @@ -194,6 +194,7 @@ "Sorting Order","Tri des commandes" "Alma","Alma" "Bancontact","Bancontact" +"Bancomat Pay","Bancomat Pay" "Banktransfer","Virement bancaire" "Status Pending","Statut en attente" "We recommend using another 'pending' status as the default Magento pending status can automatically cancel the order before the payment expiry time is reached.
By default the status ""Pending Payment"" is not visible for customers, therefore we advise you to create a new status for this, which should also be visible to the customer, informing them they still have to complete their payment.","Nous vous recommandons d'utiliser un autre statut «en attente», car le statut en attente Magento par défaut peut annuler automatiquement la commande avant même l'expiration du délai de paiement.
Comme le statut «Paiement en attente» n'est pas visible par défaut par les clients, nous vous recommandons de créer un nouveau statut qui sera visible par la clientèle et l'informera qu'elle doit finaliser son paiement." diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv index ce54e3eba97..159fb1dd14a 100644 --- a/i18n/nl_NL.csv +++ b/i18n/nl_NL.csv @@ -194,6 +194,7 @@ "Sorting Order","Sorteervolgorde" "Alma","Alma" "Bancontact","Bancontact" +"Bancomat Pay","Bancomat Pay" "Banktransfer","Bankoverschrijving" "Status Pending","Status openstaand" "We recommend using another 'pending' status as the default Magento pending status can automatically cancel the order before the payment expiry time is reached.
By default the status ""Pending Payment"" is not visible for customers, therefore we advise you to create a new status for this, which should also be visible to the customer, informing them they still have to complete their payment.","Wij raden u aan om een andere status voor 'openstaand' te gebruiken, omdat de standaard Magento-status 'openstaand' de bestelling automatisch kan annuleren, voordat de vervaltermijn is afgelopen.
Standaard is de status 'openstaande betaling' niet zichtbaar voor klanten, daarom adviseren wij u om hiervoor een nieuwe status aan te maken, die ook zichtbaar is voor de klant, om hem te laten weten dat hij zijn betaling nog dient te voltooien." diff --git a/view/adminhtml/templates/form/mollie_paymentlink.phtml b/view/adminhtml/templates/form/mollie_paymentlink.phtml index ba4307efcd2..d080dff317c 100644 --- a/view/adminhtml/templates/form/mollie_paymentlink.phtml +++ b/view/adminhtml/templates/form/mollie_paymentlink.phtml @@ -18,6 +18,7 @@ $code; ?>" style="display:none">