diff --git a/CHANGELOG.md b/CHANGELOG.md index bc893f445..87bd29d28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Returns for Shopware Commercial plugins are now transferred to Mollie when the return status is set to "Done" and can be canceled with the "Cancelled" status. Please note that refunds cannot be canceled after two hours. +- MB Way payment method is now available for Mollie Payments. ### Changed diff --git a/src/Handler/Method/MbWayPayment.php b/src/Handler/Method/MbWayPayment.php new file mode 100644 index 000000000..5530ce8ab --- /dev/null +++ b/src/Handler/Method/MbWayPayment.php @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index 879c71195..f8db477b8 100644 --- a/src/Service/PaymentMethodService.php +++ b/src/Service/PaymentMethodService.php @@ -22,6 +22,7 @@ use Kiener\MolliePayments\Handler\Method\KlarnaPayLaterPayment; use Kiener\MolliePayments\Handler\Method\KlarnaPayNowPayment; use Kiener\MolliePayments\Handler\Method\KlarnaSliceItPayment; +use Kiener\MolliePayments\Handler\Method\MbWayPayment; use Kiener\MolliePayments\Handler\Method\MyBankPayment; use Kiener\MolliePayments\Handler\Method\PayByBankPayment; use Kiener\MolliePayments\Handler\Method\PayconiqPayment; @@ -461,6 +462,7 @@ public function getPaymentHandlers(): array RivertyPayment::class, SatispayPayment::class, PayByBankPayment::class, + MbWayPayment::class // IngHomePayPayment::class, // not allowed anymore // DirectDebitPayment::class, // only allowed when updating subsriptions, aka => not allowed anymore ]; diff --git a/tests/Cypress/cypress/e2e/storefront/checkout/checkout-success.cy.js b/tests/Cypress/cypress/e2e/storefront/checkout/checkout-success.cy.js index 2ad7f4c0d..2eda44c89 100644 --- a/tests/Cypress/cypress/e2e/storefront/checkout/checkout-success.cy.js +++ b/tests/Cypress/cypress/e2e/storefront/checkout/checkout-success.cy.js @@ -60,6 +60,7 @@ const payments = [ {caseId: 'C3713510', key: 'riverty', name: 'Riverty', sanity: false}, {caseId: 'C3713512', key: 'satispay', name: 'Satispay', sanity: false}, {caseId: 'C4212005', key: 'paybybank', name: 'Pay by Bank', sanity: false}, + {caseId: '', key: 'mbway', name: 'MB Way', sanity: false}, // unfortunately address and product prices need to match, so we cannot do in3 automatically for now // {caseId: '', key: 'in3', name: 'in3'}, ]; diff --git a/tests/Cypress/cypress/e2e/storefront/payment-methods/mbway.cy.js b/tests/Cypress/cypress/e2e/storefront/payment-methods/mbway.cy.js new file mode 100644 index 000000000..4878c2e0e --- /dev/null +++ b/tests/Cypress/cypress/e2e/storefront/payment-methods/mbway.cy.js @@ -0,0 +1,44 @@ +import Devices from "Services/utils/Devices"; +import Session from "Services/utils/Session" +// ------------------------------------------------------ +import PaymentAction from "Actions/storefront/checkout/PaymentAction"; +import DummyBasketScenario from "Scenarios/DummyBasketScenario"; +import CheckoutAction from "Actions/storefront/checkout/CheckoutAction"; +// ------------------------------------------------------ + + +const devices = new Devices(); +const session = new Session(); + +const paymentAction = new PaymentAction(); +const scenarioDummyBasket = new DummyBasketScenario(1); +const checkout = new CheckoutAction(); +const device = devices.getFirstDevice(); + + +describe('MW Way', () => { + + context(devices.getDescription(device), () => { + + before(function () { + devices.setDevice(device); + }) + + beforeEach(() => { + session.resetBrowserSession(); + devices.setDevice(device); + }); + + it('MB Way is existing in checkout', () => { + + scenarioDummyBasket.execute(); + checkout.changeBillingCountry('Portugal'); + paymentAction.switchPaymentMethod('mbway'); + + // payment would only work using currency CHF which cannot be done at the moment + }) + + }) + +}) + diff --git a/tests/PHPUnit/Service/MollieApi/Builder/Payments/MbWayOrderBuilderTest.php b/tests/PHPUnit/Service/MollieApi/Builder/Payments/MbWayOrderBuilderTest.php new file mode 100644 index 000000000..c26e0cc67 --- /dev/null +++ b/tests/PHPUnit/Service/MollieApi/Builder/Payments/MbWayOrderBuilderTest.php @@ -0,0 +1,63 @@ +router->method('generate')->willReturn($redirectWebhookUrl); + + $this->paymentHandler = new MbWayPayment( + $this->loggerService, + new FakeContainer() + ); + + $transactionId = Uuid::randomHex(); + $amountTotal = 27.0; + $taxStatus = CartPrice::TAX_STATE_GROSS; + $currencyISO = 'EUR'; + + $currency = new CurrencyEntity(); + $currency->setId(Uuid::randomHex()); + $currency->setIsoCode($currencyISO); + + $orderNumber = 'foo number'; + $lineItems = $this->getDummyLineItems(); + + $order = $this->getOrderEntity($amountTotal, $taxStatus, $currencyISO, $lineItems, $orderNumber); + + $actual = $this->builder->buildOrderPayload($order, $transactionId, $this->paymentHandler::PAYMENT_METHOD_NAME, $this->salesChannelContext, $this->paymentHandler, []); + + $expectedOrderLifeTime = (new DateTime())->setTimezone(new DateTimeZone('UTC')) + ->modify(sprintf('+%d day', $this->expiresAt)) + ->format('Y-m-d'); + + $expected = [ + 'amount' => (new MollieOrderPriceBuilder())->build($amountTotal, $currencyISO), + 'locale' => $this->localeCode, + 'method' => $this->paymentHandler::PAYMENT_METHOD_NAME, + 'orderNumber' => $orderNumber, + 'payment' => ['webhookUrl' => $redirectWebhookUrl], + 'redirectUrl' => $redirectWebhookUrl, + 'webhookUrl' => $redirectWebhookUrl, + 'lines' => $this->getExpectedLineItems($taxStatus, $lineItems, $currency), + 'billingAddress' => $this->getExpectedTestAddress($this->address, $this->email), + 'shippingAddress' => $this->getExpectedTestAddress($this->address, $this->email), + 'expiresAt' => $expectedOrderLifeTime + ]; + + self::assertSame($expected, $actual); + } +} diff --git a/tests/PHPUnit/Service/PaymentMethodServiceTest.php b/tests/PHPUnit/Service/PaymentMethodServiceTest.php index 142a21ac1..74b442d74 100644 --- a/tests/PHPUnit/Service/PaymentMethodServiceTest.php +++ b/tests/PHPUnit/Service/PaymentMethodServiceTest.php @@ -20,6 +20,7 @@ use Kiener\MolliePayments\Handler\Method\KlarnaPayLaterPayment; use Kiener\MolliePayments\Handler\Method\KlarnaPayNowPayment; use Kiener\MolliePayments\Handler\Method\KlarnaSliceItPayment; +use Kiener\MolliePayments\Handler\Method\MbWayPayment; use Kiener\MolliePayments\Handler\Method\MyBankPayment; use Kiener\MolliePayments\Handler\Method\PayByBankPayment; use Kiener\MolliePayments\Handler\Method\PayconiqPayment; @@ -147,6 +148,7 @@ public function testSupportedMethods(): void RivertyPayment::class, SatispayPayment::class, PayByBankPayment::class, + MbWayPayment::class, PayPalExpressPayment::class, ];