From 4d09e494e93d29f842e2824a64c493d4ef26fa7e Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Tue, 2 Jul 2024 10:28:01 +0200 Subject: [PATCH 1/4] NTR: added payconiq payment --- src/Handler/Method/PayconiqPayment.php | 16 +++++ .../mollie-external-link.scss | 2 +- src/Resources/config/services/handlers.xml | 7 ++ src/Service/PaymentMethodService.php | 2 + .../checkout/checkout-success.cy.js | 1 + .../storefront/payment-methods/payconiq.cy.js | 43 ++++++++++++ .../Payments/PayconiqOrderBuilderTest.php | 67 +++++++++++++++++++ .../Service/PaymentMethodServiceTest.php | 2 + 8 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 src/Handler/Method/PayconiqPayment.php create mode 100644 tests/Cypress/cypress/e2e/storefront/payment-methods/payconiq.cy.js create mode 100644 tests/PHPUnit/Service/MollieApi/Builder/Payments/PayconiqOrderBuilderTest.php diff --git a/src/Handler/Method/PayconiqPayment.php b/src/Handler/Method/PayconiqPayment.php new file mode 100644 index 000000000..9346b4768 --- /dev/null +++ b/src/Handler/Method/PayconiqPayment.php @@ -0,0 +1,16 @@ + + + + + + + + diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index ddd40e95b..a0b9a75af 100644 --- a/src/Service/PaymentMethodService.php +++ b/src/Service/PaymentMethodService.php @@ -24,6 +24,7 @@ use Kiener\MolliePayments\Handler\Method\KlarnaPayNowPayment; use Kiener\MolliePayments\Handler\Method\KlarnaSliceItPayment; use Kiener\MolliePayments\Handler\Method\MyBankPayment; +use Kiener\MolliePayments\Handler\Method\PayconiqPayment; use Kiener\MolliePayments\Handler\Method\PayPalPayment; use Kiener\MolliePayments\Handler\Method\PaySafeCardPayment; use Kiener\MolliePayments\Handler\Method\PosPayment; @@ -446,6 +447,7 @@ public function getPaymentHandlers(): array BancomatPayment::class, MyBankPayment::class, AlmaPayment::class, + PayconiqPayment::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 9281088e7..fb9c58510 100644 --- a/tests/Cypress/cypress/e2e/storefront/checkout/checkout-success.cy.js +++ b/tests/Cypress/cypress/e2e/storefront/checkout/checkout-success.cy.js @@ -58,6 +58,7 @@ const payments = [ {caseId: 'C4127', key: 'belfius', name: 'Belfius', sanity: false}, {caseId: 'C4121', key: 'giftcard', name: 'Gift cards', sanity: false}, {caseId: 'C4143', key: 'voucher', name: 'Voucher', sanity: false}, + {caseId: 'C3362897', key: 'payconiq', name: 'Payconiq', 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/payconiq.cy.js b/tests/Cypress/cypress/e2e/storefront/payment-methods/payconiq.cy.js new file mode 100644 index 000000000..9c249316a --- /dev/null +++ b/tests/Cypress/cypress/e2e/storefront/payment-methods/payconiq.cy.js @@ -0,0 +1,43 @@ +import Devices from "Services/utils/Devices"; +import Session from "Services/utils/Session" +// ------------------------------------------------------ +import PaymentAction from "Actions/storefront/checkout/PaymentAction"; +import DummyBasketScenario from "Scenarios/DummyBasketScenario"; +// ------------------------------------------------------ + + +const devices = new Devices(); +const session = new Session(); + +const paymentAction = new PaymentAction(); +const scenarioDummyBasket = new DummyBasketScenario(1); + +const device = devices.getFirstDevice(); + + +describe('Payconiq', () => { + + context(devices.getDescription(device), () => { + + before(function () { + devices.setDevice(device); + }) + + beforeEach(() => { + session.resetBrowserSession(); + devices.setDevice(device); + }); + + it('C3362896: Payconiq is existing in checkout', () => { + + scenarioDummyBasket.execute(); + + paymentAction.switchPaymentMethod('Payconiq'); + + // payment would only work using currency CHF which cannot be done at the moment + }) + + }) + +}) + diff --git a/tests/PHPUnit/Service/MollieApi/Builder/Payments/PayconiqOrderBuilderTest.php b/tests/PHPUnit/Service/MollieApi/Builder/Payments/PayconiqOrderBuilderTest.php new file mode 100644 index 000000000..ff36602da --- /dev/null +++ b/tests/PHPUnit/Service/MollieApi/Builder/Payments/PayconiqOrderBuilderTest.php @@ -0,0 +1,67 @@ +router->method('generate')->willReturn($redirectWebhookUrl); + + $this->paymentHandler = new PayconiqPayment( + $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 9fd939294..4a37df781 100644 --- a/tests/PHPUnit/Service/PaymentMethodServiceTest.php +++ b/tests/PHPUnit/Service/PaymentMethodServiceTest.php @@ -22,6 +22,7 @@ use Kiener\MolliePayments\Handler\Method\KlarnaPayNowPayment; use Kiener\MolliePayments\Handler\Method\KlarnaSliceItPayment; use Kiener\MolliePayments\Handler\Method\MyBankPayment; +use Kiener\MolliePayments\Handler\Method\PayconiqPayment; use Kiener\MolliePayments\Handler\Method\PayPalPayment; use Kiener\MolliePayments\Handler\Method\PaySafeCardPayment; use Kiener\MolliePayments\Handler\Method\PosPayment; @@ -136,6 +137,7 @@ public function testSupportedMethods(): void BancomatPayment::class, MyBankPayment::class, AlmaPayment::class, + PayconiqPayment::class, ]; $handlers = $this->paymentMethodService->getPaymentHandlers(); From 7592ce7cd8d5a75e67d76a86d4ecfd8278c0950a Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Tue, 2 Jul 2024 10:49:21 +0200 Subject: [PATCH 2/4] NTR: csfix --- src/Handler/Method/PayconiqPayment.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Handler/Method/PayconiqPayment.php b/src/Handler/Method/PayconiqPayment.php index 9346b4768..50faba554 100644 --- a/src/Handler/Method/PayconiqPayment.php +++ b/src/Handler/Method/PayconiqPayment.php @@ -12,5 +12,4 @@ class PayconiqPayment extends PaymentHandler /** @var string */ protected $paymentMethod = self::PAYMENT_METHOD_NAME; - -} \ No newline at end of file +} From 8b523cba7083aa7eac8d4bb08bee02152db123f6 Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Tue, 2 Jul 2024 10:52:47 +0200 Subject: [PATCH 3/4] NTR: fix stylelint --- .../components/mollie-external-link/mollie-external-link.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Resources/app/administration/src/module/mollie-payments/components/mollie-external-link/mollie-external-link.scss b/src/Resources/app/administration/src/module/mollie-payments/components/mollie-external-link/mollie-external-link.scss index f19c256ae..758443346 100644 --- a/src/Resources/app/administration/src/module/mollie-payments/components/mollie-external-link/mollie-external-link.scss +++ b/src/Resources/app/administration/src/module/mollie-payments/components/mollie-external-link/mollie-external-link.scss @@ -6,6 +6,7 @@ text-decoration: underline; cursor: pointer; text-align: right; + &:hover, &:focus { color: $color-shopware-brand-600; From d023d2e5dd16fa1a8b4fe7cdb31417e641edbcd7 Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Tue, 2 Jul 2024 10:58:30 +0200 Subject: [PATCH 4/4] NTR: stylelint fix --- .../components/mollie-external-link/mollie-external-link.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/app/administration/src/module/mollie-payments/components/mollie-external-link/mollie-external-link.scss b/src/Resources/app/administration/src/module/mollie-payments/components/mollie-external-link/mollie-external-link.scss index 758443346..2f91d62bb 100644 --- a/src/Resources/app/administration/src/module/mollie-payments/components/mollie-external-link/mollie-external-link.scss +++ b/src/Resources/app/administration/src/module/mollie-payments/components/mollie-external-link/mollie-external-link.scss @@ -6,7 +6,7 @@ text-decoration: underline; cursor: pointer; text-align: right; - + &:hover, &:focus { color: $color-shopware-brand-600;