diff --git a/src/Handler/Method/PayconiqPayment.php b/src/Handler/Method/PayconiqPayment.php new file mode 100644 index 000000000..50faba554 --- /dev/null +++ b/src/Handler/Method/PayconiqPayment.php @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index b6b71c8db..44196cf4c 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; @@ -448,6 +449,7 @@ public function getPaymentHandlers(): array MyBankPayment::class, AlmaPayment::class, TrustlyPayment::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 69262419f..a209adfeb 100644 --- a/tests/Cypress/cypress/e2e/storefront/checkout/checkout-success.cy.js +++ b/tests/Cypress/cypress/e2e/storefront/checkout/checkout-success.cy.js @@ -59,6 +59,7 @@ const payments = [ {caseId: 'C4121', key: 'giftcard', name: 'Gift cards', sanity: false}, {caseId: 'C4143', key: 'voucher', name: 'Voucher', sanity: false}, {caseId: 'C3362894', key: 'trustly', name: 'Trustly', 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 0d50277a4..b932b682e 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; @@ -138,6 +139,7 @@ public function testSupportedMethods(): void MyBankPayment::class, AlmaPayment::class, TrustlyPayment::class, + PayconiqPayment::class, ]; $handlers = $this->paymentMethodService->getPaymentHandlers();