diff --git a/src/Controller/StoreApi/iDEAL/Response/IssuersResponse.php b/src/Controller/StoreApi/iDEAL/Response/IssuersResponse.php deleted file mode 100644 index 4c82faee0..000000000 --- a/src/Controller/StoreApi/iDEAL/Response/IssuersResponse.php +++ /dev/null @@ -1,30 +0,0 @@ - - */ - protected $object; - - - /** - * @param array $terminals - */ - public function __construct(array $terminals) - { - $this->object = new ArrayStruct( - [ - 'issuers' => $terminals, - ], - 'mollie_payments_ideal_issuers' - ); - - parent::__construct($this->object); - } -} diff --git a/src/Controller/StoreApi/iDEAL/Response/StoreIssuerResponse.php b/src/Controller/StoreApi/iDEAL/Response/StoreIssuerResponse.php deleted file mode 100644 index 8e840afc6..000000000 --- a/src/Controller/StoreApi/iDEAL/Response/StoreIssuerResponse.php +++ /dev/null @@ -1,29 +0,0 @@ - - */ - protected $object; - - /** - * @param bool $success - */ - public function __construct(bool $success) - { - $this->object = new ArrayStruct( - [ - 'success' => $success, - ], - 'mollie_payments_ideal_issuer_stored' - ); - - parent::__construct($this->object); - } -} diff --git a/src/Controller/StoreApi/iDEAL/iDealControllerBase.php b/src/Controller/StoreApi/iDEAL/iDealControllerBase.php deleted file mode 100644 index 07f45bf4b..000000000 --- a/src/Controller/StoreApi/iDEAL/iDealControllerBase.php +++ /dev/null @@ -1,98 +0,0 @@ -customerService = $customerService; - $this->mollieGateway = $mollieGateway; - } - - - /** - * - * @param SalesChannelContext $context - * @return StoreApiResponse - */ - public function getIssuers(SalesChannelContext $context): StoreApiResponse - { - $this->mollieGateway->switchClient($context->getSalesChannelId()); - - $issuers = $this->mollieGateway->getIDealIssuers(); - - $issuerArray = []; - - foreach ($issuers as $issuer) { - $issuerArray[] = [ - 'id' => $issuer->getId(), - 'name' => $issuer->getName(), - 'images' => [ - '1x' => $issuer->getImage1x(), - '2x' => $issuer->getImage2x(), - 'svg' => $issuer->getSvg(), - ], - ]; - } - - return new IssuersResponse($issuerArray); - } - - /** - * - * @param string $customerId - * @param string $issuerId - * @param SalesChannelContext $context - * @throws \Exception - * @return StoreApiResponse - */ - public function saveIssuer(string $customerId, string $issuerId, SalesChannelContext $context): StoreApiResponse - { - $customer = $this->customerService->getCustomer($customerId, $context->getContext()); - - if (!$customer instanceof CustomerEntity) { - throw new \Exception('Customer with ID ' . $customerId . ' not found in Shopware'); - } - - # if we have a "reset" value, then empty our stored issuer - if ($issuerId === iDealPayment::ISSUER_RESET_VALUE) { - $issuerId = ''; - } - - $result = $this->customerService->setIDealIssuer( - $customer, - $issuerId, - $context->getContext() - ); - - return new StoreIssuerResponse($result !== null); - } -} diff --git a/src/Controller/Storefront/iDEAL/iDealControllerBase.php b/src/Controller/Storefront/iDEAL/iDealControllerBase.php deleted file mode 100644 index 712b6da10..000000000 --- a/src/Controller/Storefront/iDEAL/iDealControllerBase.php +++ /dev/null @@ -1,63 +0,0 @@ -customerService = $customerService; - } - - /** - * - * @param SalesChannelContext $context - * @param string $customerId - * @param string $issuerId - * - * @return JsonResponse - */ - public function storeIssuer(SalesChannelContext $context, string $customerId, string $issuerId): JsonResponse - { - $result = null; - - # if we have a "reset" value, then empty our stored issuer - if ($issuerId === iDealPayment::ISSUER_RESET_VALUE) { - $issuerId = ''; - } - - $customer = $this->customerService->getCustomer($customerId, $context->getContext()); - - if ($customer instanceof CustomerEntity) { - $writtenEvent = $this->customerService->setIDealIssuer( - $customer, - $issuerId, - $context->getContext() - ); - - $result = $writtenEvent->getErrors(); - } - - return new JsonResponse([ - 'success' => (bool)$result, - 'customerId' => $customerId, - 'result' => $result, - ]); - } -} diff --git a/src/Gateway/Mollie/Model/Issuer.php b/src/Gateway/Mollie/Model/Issuer.php deleted file mode 100644 index a528f5c8a..000000000 --- a/src/Gateway/Mollie/Model/Issuer.php +++ /dev/null @@ -1,88 +0,0 @@ -id = $id; - $this->name = $name; - $this->image1x = $image1x; - $this->image2x = $image2x; - $this->svg = $svg; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return string - */ - public function getImage1x(): string - { - return $this->image1x; - } - - /** - * @return string - */ - public function getImage2x(): string - { - return $this->image2x; - } - - /** - * @return string - */ - public function getSvg(): string - { - return $this->svg; - } -} diff --git a/src/Gateway/Mollie/MollieGateway.php b/src/Gateway/Mollie/MollieGateway.php index 355032dc1..7de5e910d 100644 --- a/src/Gateway/Mollie/MollieGateway.php +++ b/src/Gateway/Mollie/MollieGateway.php @@ -3,16 +3,13 @@ namespace Kiener\MolliePayments\Gateway\Mollie; use Kiener\MolliePayments\Factory\MollieApiFactory; -use Kiener\MolliePayments\Gateway\Mollie\Model\Issuer; use Kiener\MolliePayments\Gateway\MollieGatewayInterface; use Mollie\Api\MollieApiClient; -use Mollie\Api\Resources\Method; use Mollie\Api\Resources\Order; use Mollie\Api\Resources\Payment; use Mollie\Api\Resources\Profile; use Mollie\Api\Resources\Subscription; use Mollie\Api\Resources\Terminal; -use Mollie\Api\Types\PaymentMethod; class MollieGateway implements MollieGatewayInterface { @@ -88,34 +85,7 @@ public function getOrganizationId(): string return (string)$orgId; } - /** - * @throws \Mollie\Api\Exceptions\ApiException - * @return Issuer[] - */ - public function getIDealIssuers(): array - { - $parameters = [ - 'include' => 'issuers', - ]; - - /** @var Method $iDeal */ - $iDeal = $this->apiClient->methods->get(PaymentMethod::IDEAL, $parameters); - - $issuers = []; - - /** @var \Mollie\Api\Resources\Issuer $issuer */ - foreach ($iDeal->issuers as $issuer) { - $issuers[] = new Issuer( - $issuer->id, - $issuer->name, - $issuer->image->size1x, - $issuer->image->size2x, - $issuer->image->svg - ); - } - return $issuers; - } /** * @throws \Mollie\Api\Exceptions\ApiException diff --git a/src/Gateway/MollieGatewayInterface.php b/src/Gateway/MollieGatewayInterface.php index 6d484b4e6..7170ab2e8 100644 --- a/src/Gateway/MollieGatewayInterface.php +++ b/src/Gateway/MollieGatewayInterface.php @@ -2,7 +2,6 @@ namespace Kiener\MolliePayments\Gateway; -use Kiener\MolliePayments\Gateway\Mollie\Model\Issuer; use Mollie\Api\Resources\Order; use Mollie\Api\Resources\Payment; use Mollie\Api\Resources\Subscription; @@ -25,10 +24,6 @@ public function getOrganizationId(): string; */ public function getProfileId(): string; - /** - * @return Issuer[] - */ - public function getIDealIssuers(): array; /** * @return Terminal[] diff --git a/src/Handler/Method/iDealPayment.php b/src/Handler/Method/iDealPayment.php index 972311422..f13e85855 100644 --- a/src/Handler/Method/iDealPayment.php +++ b/src/Handler/Method/iDealPayment.php @@ -12,12 +12,11 @@ class iDealPayment extends PaymentHandler { public const PAYMENT_METHOD_NAME = PaymentMethod::IDEAL; public const PAYMENT_METHOD_DESCRIPTION = 'iDEAL'; - protected const FIELD_IDEAL_ISSUER = 'issuer'; + /** @var string */ protected $paymentMethod = self::PAYMENT_METHOD_NAME; - public const ISSUER_RESET_VALUE = 'ideal_reset'; /** * @param array $orderData @@ -28,19 +27,6 @@ class iDealPayment extends PaymentHandler */ public function processPaymentMethodSpecificParameters(array $orderData, OrderEntity $orderEntity, SalesChannelContext $salesChannelContext, CustomerEntity $customer): array { - $customFields = $customer->getCustomFields() ?? []; - - $issuer = $customFields['mollie_payments']['preferred_ideal_issuer'] ?? ''; - $paymentIssuer = $orderData['payment']['issuer'] ?? ''; - - if (empty($issuer)) { - return $orderData; - } - - if (empty($paymentIssuer)) { - $orderData['payment']['issuer'] = $issuer; - } - return $orderData; } } diff --git a/src/Resources/app/administration/src/module/mollie-payments/extension/sw-customer/component/sw-customer-base-info/index.js b/src/Resources/app/administration/src/module/mollie-payments/extension/sw-customer/component/sw-customer-base-info/index.js deleted file mode 100644 index db0513d7b..000000000 --- a/src/Resources/app/administration/src/module/mollie-payments/extension/sw-customer/component/sw-customer-base-info/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import template from './sw-customer-base-info.html.twig'; - -// eslint-disable-next-line no-undef -const { Component } = Shopware; - -Component.override('sw-customer-base-info', { - template, - - computed: { - preferredIdealIssuer() { - if ( - !!this.customer - && !!this.customer.customFields - && !!this.customer.customFields.mollie_payments - && !!this.customer.customFields.mollie_payments.preferred_ideal_issuer - ) { - return this.customer.customFields.mollie_payments.preferred_ideal_issuer; - } - - return null; - }, - }, -}); \ No newline at end of file diff --git a/src/Resources/app/administration/src/module/mollie-payments/extension/sw-customer/component/sw-customer-base-info/sw-customer-base-info.html.twig b/src/Resources/app/administration/src/module/mollie-payments/extension/sw-customer/component/sw-customer-base-info/sw-customer-base-info.html.twig deleted file mode 100644 index 4074d9753..000000000 --- a/src/Resources/app/administration/src/module/mollie-payments/extension/sw-customer/component/sw-customer-base-info/sw-customer-base-info.html.twig +++ /dev/null @@ -1,9 +0,0 @@ -{% block sw_customer_base_metadata_default_payment %} - {% parent %} - -
{{ $tc('sw-customer.extendedInfo.labelPreferredIdealIssuer') }}
-
- {{ preferredIdealIssuer }} -
-
-{% endblock %} \ No newline at end of file diff --git a/src/Resources/app/administration/src/module/mollie-payments/extension/sw-customer/index.js b/src/Resources/app/administration/src/module/mollie-payments/extension/sw-customer/index.js deleted file mode 100644 index 8d3878b65..000000000 --- a/src/Resources/app/administration/src/module/mollie-payments/extension/sw-customer/index.js +++ /dev/null @@ -1 +0,0 @@ -import './component/sw-customer-base-info'; \ No newline at end of file diff --git a/src/Resources/app/administration/src/module/mollie-payments/index.js b/src/Resources/app/administration/src/module/mollie-payments/index.js index 300bfb80d..bccbf38a5 100644 --- a/src/Resources/app/administration/src/module/mollie-payments/index.js +++ b/src/Resources/app/administration/src/module/mollie-payments/index.js @@ -1,5 +1,4 @@ import './acl'; -import './extension/sw-customer'; import './extension/sw-order'; import './extension/sw-settings'; import './components/mollie-pluginconfig-element-orderstate-select'; diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js deleted file mode 100644 index fc4085199..000000000 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js +++ /dev/null @@ -1,225 +0,0 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; -import HttpClient from '../services/HttpClient' - - -export default class MollieIDealIssuer extends Plugin { - - _shopUrl = ''; - _customerId = ''; - - _isModalForm = false; - - _container = null; - _paymentForm = null; - _issuersDropdown = null; - _radioInputs = null; - _iDealRadioInput = null; - - - /** - * - */ - init() { - - this._container = document.querySelector('div.mollie-ideal-issuer'); - - if (this._container === undefined || this._container === null) { - return; - } - - - // load our controls - // and register the necessary events - this.initControls(); - - // now check if we even have a payment form - // if not, then we are not on the checkout page - // but maybe in the accounts page instead...we dont need components there - if (this._paymentForm === null) { - return; - } - - // if we dont have the issuers dropdown available, then we can't even do anything - if (this._issuersDropdown === null) { - return; - } - - this.registerEvents(); - - // update the visibility of our - // issuer dropdown list - this.updateIssuerVisibility(this._iDealRadioInput, this._container, this._issuersDropdown) - - // if we do not have the old modal form, but - // the new inline form, then automatically set the - // currently selected issuer as the selected on of the customer. - // this is for consistency. - if (!this._isModalForm) { - this.updateIssuer(this._shopUrl, this._customerId, this._iDealRadioInput, this._issuersDropdown, function () { - }); - } - } - - /** - * - */ - initControls() { - this._shopUrl = this._container.getAttribute('data-shop-url'); - - if (this._shopUrl.substr(-1) === '/') { - this._shopUrl = this._shopUrl.substr(0, this._shopUrl.length - 1); - } - - this._customerId = this._container.getAttribute('data-customer-id'); - this._issuersDropdown = document.querySelector('#iDealIssuer'); - - // Shopware < 6.4 - const oldPaymentForm = document.querySelector('#confirmPaymentForm'); - // Shopware >= 6.4 - const newPaymentForm = document.querySelector('#changePaymentForm'); - - if (newPaymentForm) { - this._paymentForm = newPaymentForm; - } else { - this._isModalForm = true; - this._paymentForm = oldPaymentForm; - } - - if (this._paymentForm === undefined || this._paymentForm === null) { - return; - } - - this._radioInputs = this._paymentForm.querySelectorAll('input[type="radio"]'); - this._iDealRadioInput = this._paymentForm.querySelector('input[type="radio"].ideal'); - } - - /** - * - */ - registerEvents() { - - if (this._paymentForm === null) { - return; - } - - // create locally scoped variables - // for async functions. this is required - const shopUrl = this._shopUrl; - const customerId = this._customerId; - const container = this._container; - const paymentForm = this._paymentForm; - const allRadioInputs = this._radioInputs; - const iDealRadioInput = this._iDealRadioInput; - const issuersDropdown = this._issuersDropdown; - - - // add event to toggle the dropdown visibility - // when switching payment methods - allRadioInputs.forEach((element) => { - element.addEventListener('change', () => { - this.updateIssuerVisibility(iDealRadioInput, container, issuersDropdown) - }); - }); - - - // if we have the old modal form, then we have a - // dedicated "submit" button that we use to trigger - // the change of our selected issuer for our user. - // if we have the new form directly on the confirm, then we do this immediately - // while the user switches the values in the dropdown - if (!this._isModalForm) { - - issuersDropdown.addEventListener('change', async () => { - this.updateIssuer(shopUrl, customerId, iDealRadioInput, issuersDropdown, function () { - }); - }); - - } else { - - const submitButton = paymentForm.querySelector('button[type="submit"]'); - - submitButton.addEventListener('click', async () => { - this.updateIssuer(shopUrl, customerId, iDealRadioInput, issuersDropdown, function () { - }); - }); - } - } - - /** - * - * @param iDealRadio - * @param container - * @param dropdown - */ - updateIssuerVisibility(iDealRadio, container, dropdown) { - - let issuerRequired = false; - - if (iDealRadio === undefined || iDealRadio.checked === false) { - container.classList.add('d-none'); - } else { - container.classList.remove('d-none'); - issuerRequired = true; - } - - if (dropdown !== undefined) { - dropdown.required = issuerRequired; - } - } - - /** - * - * @param shopUrl - * @param customerId - * @param iDealRadio - * @param issuersDropdown - * @param onCompleted - */ - updateIssuer(shopUrl, customerId, iDealRadio, issuersDropdown, onCompleted) { - - if (iDealRadio === undefined) { - onCompleted('iDEAL Radio Input not defined'); - return; - } - - if (iDealRadio === null) { - onCompleted('iDEAL Radio Input not found'); - return; - } - - if (iDealRadio.checked === false) { - onCompleted('iDEAL payment not active'); - return; - } - - if (issuersDropdown === undefined) { - onCompleted('iDEAL issuers not defined'); - return; - } - - if (issuersDropdown === null) { - onCompleted('iDEAL issuers not found'); - return; - } - - const client = new HttpClient(); - - var selectedIssuer = issuersDropdown.value; - - if (selectedIssuer === undefined || selectedIssuer === null || selectedIssuer === '') { - selectedIssuer = 'ideal_reset'; - } - - client.get( - shopUrl + '/mollie/ideal/store-issuer/' + customerId + '/' + selectedIssuer, - function () { - onCompleted('issuer updated successfully'); - }, - function () { - onCompleted('error when updating issuer'); - }, - 'application/json; charset=utf-8' - ); - } - -} \ No newline at end of file diff --git a/src/Resources/app/storefront/src/register.js b/src/Resources/app/storefront/src/register.js index 61abbca7f..bfd76dc6a 100644 --- a/src/Resources/app/storefront/src/register.js +++ b/src/Resources/app/storefront/src/register.js @@ -1,6 +1,5 @@ import MollieCreditCardComponents from './mollie-payments/plugins/creditcard-components.plugin'; import MollieCreditCardComponentsSw64 from './mollie-payments/plugins/creditcard-components-sw64.plugin'; -import MollieIDealIssuer from './mollie-payments/plugins/ideal-issuer.plugin'; import MollieApplePayDirect from './mollie-payments/plugins/apple-pay-direct.plugin'; import MollieApplePayPaymentMethod from './mollie-payments/plugins/apple-pay-payment-method.plugin'; import MollieCreditCardMandateManage from './mollie-payments/plugins/creditcard-mandate-manage.plugin'; @@ -21,8 +20,7 @@ export default class MolliRegistration { // ----------------------------------------------------------------------------- // hide apple pay direct buttons across the whole shop, if not available pluginManager.register('MollieApplePayDirect', MollieApplePayDirect); - // this is just the iDEAL dropdown..not quite sure why its not bound to the DOM -> TODO? - pluginManager.register('MollieIDealIssuer', MollieIDealIssuer); + // hiding the standard Apple Pay method in the checkout and account area // ----------------------------------------------------------------------------- diff --git a/src/Resources/config/routes/store-api/ideal.xml b/src/Resources/config/routes/store-api/ideal.xml deleted file mode 100644 index 1ea5165ad..000000000 --- a/src/Resources/config/routes/store-api/ideal.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - Kiener\MolliePayments\Controller\StoreApi\iDEAL\iDealControllerBase::getIssuers - store-api - - - - Kiener\MolliePayments\Controller\StoreApi\iDEAL\iDealControllerBase::saveIssuer - store-api - - - diff --git a/src/Resources/config/routes/storefront/ideal.xml b/src/Resources/config/routes/storefront/ideal.xml deleted file mode 100644 index 127eccde5..000000000 --- a/src/Resources/config/routes/storefront/ideal.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Kiener\MolliePayments\Controller\Storefront\iDEAL\iDealControllerBase::storeIssuer - storefront - - - - diff --git a/src/Resources/config/services/controller.xml b/src/Resources/config/services/controller.xml index 078c98d5d..dfc0f1168 100644 --- a/src/Resources/config/services/controller.xml +++ b/src/Resources/config/services/controller.xml @@ -153,13 +153,6 @@ - - - - - - - @@ -226,11 +219,6 @@ - - - - - diff --git a/src/Resources/views/storefront/component/payment/component/ideal-fields.html.twig b/src/Resources/views/storefront/component/payment/component/ideal-fields.html.twig deleted file mode 100644 index dc138e5b7..000000000 --- a/src/Resources/views/storefront/component/payment/component/ideal-fields.html.twig +++ /dev/null @@ -1,13 +0,0 @@ -
- - {% if page.ideal_issuers %} - - {% endif %} -
diff --git a/src/Resources/views/storefront/component/payment/payment-fields.html.twig b/src/Resources/views/storefront/component/payment/payment-fields.html.twig index 48cd7d061..66532a14b 100644 --- a/src/Resources/views/storefront/component/payment/payment-fields.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-fields.html.twig @@ -31,8 +31,6 @@ {% sw_include '@MolliePayments/storefront/component/payment/component/cc-fields.html.twig' with { showIfActive: false } %} - {% elseif payment.translated.customFields.mollie_payment_method_name == 'ideal' %} - {% sw_include '@MolliePayments/storefront/component/payment/component/ideal-fields.html.twig' %} {% elseif payment.translated.customFields.mollie_payment_method_name == 'pointofsale' %} {% sw_include '@MolliePayments/storefront/component/payment/component/pos-fields.html.twig' %} {% elseif payment.translated.customFields.mollie_payment_method_name == 'bancomatpay' %} diff --git a/src/Resources/views/storefront/component/payment/payment-method.html.twig b/src/Resources/views/storefront/component/payment/payment-method.html.twig index 4ea8b365b..318c7912d 100644 --- a/src/Resources/views/storefront/component/payment/payment-method.html.twig +++ b/src/Resources/views/storefront/component/payment/payment-method.html.twig @@ -37,8 +37,6 @@ showIfActive: (payment.id is same as(selectedPaymentMethodId)), sw64: true } %} - {% elseif payment.translated.customFields.mollie_payment_method_name == 'ideal' %} - {% sw_include '@MolliePayments/storefront/component/payment/component/ideal-fields.html.twig' %} {% elseif payment.translated.customFields.mollie_payment_method_name == 'pointofsale' %} {% sw_include '@MolliePayments/storefront/component/payment/component/pos-fields.html.twig' %} {% elseif payment.translated.customFields.mollie_payment_method_name == 'bancomatpay' %} diff --git a/src/Service/CustomerService.php b/src/Service/CustomerService.php index 81b450b4a..ad403cef8 100644 --- a/src/Service/CustomerService.php +++ b/src/Service/CustomerService.php @@ -276,34 +276,7 @@ public function saveCustomerCustomFields(string $customerID, array $customFields ]], $context); } - /** - * Stores the ideal issuer in the custom fields of the customer. - * - * @param CustomerEntity $customer - * @param string $issuerId - * @param Context $context - * - * @return EntityWrittenContainerEvent - */ - public function setIDealIssuer(CustomerEntity $customer, string $issuerId, Context $context): EntityWrittenContainerEvent - { - // Get existing custom fields - $customFields = $customer->getCustomFields(); - // If custom fields are empty, create a new array - if (!is_array($customFields)) { - $customFields = []; - } - - // Store the card token in the custom fields - $customFields[CustomFieldService::CUSTOM_FIELDS_KEY_MOLLIE_PAYMENTS][self::CUSTOM_FIELDS_KEY_PREFERRED_IDEAL_ISSUER] = $issuerId; - - // Store the custom fields on the customer - return $this->customerRepository->update([[ - 'id' => $customer->getId(), - 'customFields' => $customFields - ]], $context); - } /** * @param CustomerEntity $customer diff --git a/src/Service/CustomerServiceInterface.php b/src/Service/CustomerServiceInterface.php index 2be4f80ef..4aa8e96e8 100644 --- a/src/Service/CustomerServiceInterface.php +++ b/src/Service/CustomerServiceInterface.php @@ -26,7 +26,6 @@ public function setMandateId(CustomerEntity $customer, string $cardToken, Contex * @return EntityWrittenContainerEvent */ public function saveCustomerCustomFields(string $customerID, array $customFields, Context $context): EntityWrittenContainerEvent; - public function setIDealIssuer(CustomerEntity $customer, string $issuerId, Context $context): EntityWrittenContainerEvent; public function getMollieCustomerId(string $customerId, string $salesChannelId, Context $context): string; public function setMollieCustomerId(string $customerId, string $mollieCustomerId, string $profileId, bool $testMode, Context $context): void; public function getCustomer(string $customerId, Context $context): ?CustomerEntity; diff --git a/src/Struct/CustomerStruct.php b/src/Struct/CustomerStruct.php index 58a5bd941..5837b918c 100644 --- a/src/Struct/CustomerStruct.php +++ b/src/Struct/CustomerStruct.php @@ -20,11 +20,6 @@ class CustomerStruct extends Struct */ private $customerIds = []; - /** - * @var ?string - */ - private $preferredIdealIssuer; - /** * @var string */ @@ -98,21 +93,6 @@ public function setCustomerIds(array $customerIds): void $this->customerIds = $customerIds; } - /** - * @return null|string - */ - public function getPreferredIdealIssuer(): ?string - { - return $this->preferredIdealIssuer; - } - - /** - * @param null|string $preferredIdealIssuer - */ - public function setPreferredIdealIssuer(?string $preferredIdealIssuer): void - { - $this->preferredIdealIssuer = $preferredIdealIssuer; - } /** * @param null|string $creditCardToken @@ -152,9 +132,6 @@ public function toCustomFieldsArray(): array } } - if (!empty((string)$this->preferredIdealIssuer)) { - $mollieData['preferred_ideal_issuer'] = (string)$this->preferredIdealIssuer; - } if (!empty((string)$this->creditCardToken)) { $mollieData['credit_card_token'] = (string)$this->creditCardToken; diff --git a/src/Subscriber/CheckoutConfirmPageSubscriber.php b/src/Subscriber/CheckoutConfirmPageSubscriber.php index e3f5187c6..52f5673bf 100644 --- a/src/Subscriber/CheckoutConfirmPageSubscriber.php +++ b/src/Subscriber/CheckoutConfirmPageSubscriber.php @@ -124,7 +124,6 @@ public function addDataToPage($args): void $this->addMollieProfileIdVariableToPage($args); $this->addMollieTestModeVariableToPage($args); $this->addMollieComponentsVariableToPage($args); - $this->addMollieIdealIssuersVariableToPage($args, $mollieAttributes); $this->addMollieSingleClickPaymentDataToPage($args, $mollieAttributes); $this->addMolliePosTerminalsVariableToPage($args, $mollieAttributes); } @@ -212,62 +211,6 @@ private function addMollieComponentsVariableToPage($args): void ]); } - /** - * Adds ideal issuers variable to the storefront. - * - * @param AccountEditOrderPageLoadedEvent|CheckoutConfirmPageLoadedEvent $args - * @param PaymentMethodAttributes $selectedPayment - */ - private function addMollieIdealIssuersVariableToPage($args, $selectedPayment): void - { - // do not load ideal issuers if not required - if ($selectedPayment->getMollieIdentifier() !== PaymentMethod::IDEAL) { - return; - } - $customFields = []; - $ideal = null; - $preferredIssuer = ''; - - $mollieProfileId = $this->loadMollieProfileId(); - - // Get custom fields from the customer in the sales channel context - if ($args->getSalesChannelContext()->getCustomer() !== null) { - $customFields = $args->getSalesChannelContext()->getCustomer()->getCustomFields(); - } - - // Get the preferred issuer from the custom fields - if ( - is_array($customFields) - && isset($customFields[CustomFieldService::CUSTOM_FIELDS_KEY_MOLLIE_PAYMENTS][CustomerService::CUSTOM_FIELDS_KEY_PREFERRED_IDEAL_ISSUER]) - && (string)$customFields[CustomFieldService::CUSTOM_FIELDS_KEY_MOLLIE_PAYMENTS][CustomerService::CUSTOM_FIELDS_KEY_PREFERRED_IDEAL_ISSUER] !== '' - ) { - $preferredIssuer = $customFields[CustomFieldService::CUSTOM_FIELDS_KEY_MOLLIE_PAYMENTS][CustomerService::CUSTOM_FIELDS_KEY_PREFERRED_IDEAL_ISSUER]; - } - - - $parameters = [ - 'include' => 'issuers', - ]; - - if ($this->apiClient->usesOAuth()) { - $parameters['profileId'] = $mollieProfileId; - } - - // Get issuers from the API - try { - $ideal = $this->apiClient->methods->get(PaymentMethod::IDEAL, $parameters); - } catch (Exception $e) { - // - } - - // Assign issuers to storefront - if ($ideal instanceof Method) { - $args->getPage()->assign([ - 'ideal_issuers' => $ideal->issuers, - 'preferred_issuer' => $preferredIssuer, - ]); - } - } /** * Adds ideal issuers variable to the storefront. diff --git a/tests/Cypress/cypress/e2e/store-api/ideal.cy.js b/tests/Cypress/cypress/e2e/store-api/ideal.cy.js deleted file mode 100644 index e0d80a11b..000000000 --- a/tests/Cypress/cypress/e2e/store-api/ideal.cy.js +++ /dev/null @@ -1,47 +0,0 @@ -import StoreAPIClient from "Services/shopware/StoreAPIClient"; -import Shopware from "Services/shopware/Shopware" - - -const shopware = new Shopware(); - - -const client = new StoreAPIClient(shopware.getStoreApiToken()); - -const storeApiPrefix = '/store-api'; - - -context(storeApiPrefix +"/mollie/ideal/issuers", () => { - - it('C266683: iDEAL fetch issuers (Store API)', () => { - - const request = new Promise((resolve) => { - client.get('/mollie/ideal/issuers').then(response => { - resolve({'data': response.data}); - }); - }) - - cy.wrap(request).its('data').then(response => { - cy.wrap(response).its('apiAlias').should('eq', 'mollie_payments_ideal_issuers') - cy.wrap(response).its('issuers').its('length').should('be.gte', 1) - }); - }) - -}) - -context(storeApiPrefix +"/mollie/ideal/store-issuer", () => { - - it('C266684: iDEAL store issuer with invalid customer id (Store API) @core', () => { - - const request = new Promise((resolve) => { - client.post('/mollie/ideal/store-issuer/cust-123/ideal_ABNANL2A').then(response => { - resolve({'data': response.data}); - }); - }) - - cy.wrap(request).its('data').then(response => { - cy.wrap(response).its('status').should('eq', 500) - expect(response.data.errors[0].detail).to.contain('Customer with ID cust-123 not found in Shopware'); - }); - }) - -}) diff --git a/tests/Cypress/cypress/e2e/storefront/payment-methods/ideal.cy.js b/tests/Cypress/cypress/e2e/storefront/payment-methods/ideal.cy.js index 726556eea..770b22727 100644 --- a/tests/Cypress/cypress/e2e/storefront/payment-methods/ideal.cy.js +++ b/tests/Cypress/cypress/e2e/storefront/payment-methods/ideal.cy.js @@ -44,7 +44,6 @@ describe('iDEAL Issuers', () => { } paymentAction.selectPaymentMethod('iDEAL'); - paymentAction.selectIDealIssuer('bunq'); }) }) }) diff --git a/tests/Cypress/cypress/support/actions/storefront/checkout/PaymentAction.js b/tests/Cypress/cypress/support/actions/storefront/checkout/PaymentAction.js index 6738ac710..1df7353b7 100644 --- a/tests/Cypress/cypress/support/actions/storefront/checkout/PaymentAction.js +++ b/tests/Cypress/cypress/support/actions/storefront/checkout/PaymentAction.js @@ -134,13 +134,7 @@ export default class PaymentAction { cy.wait(1000); } - /** - * - * @param issuer - */ - selectIDealIssuer(issuer) { - cy.get('#iDealIssuer').select(issuer); - } + /** * diff --git a/tests/PHPUnit/Fakes/FakeMollieGateway.php b/tests/PHPUnit/Fakes/FakeMollieGateway.php index 6fe87bf4a..5c68b28a4 100644 --- a/tests/PHPUnit/Fakes/FakeMollieGateway.php +++ b/tests/PHPUnit/Fakes/FakeMollieGateway.php @@ -2,7 +2,6 @@ namespace MolliePayments\Tests\Fakes; -use Kiener\MolliePayments\Gateway\Mollie\Model\Issuer; use Kiener\MolliePayments\Gateway\MollieGatewayInterface; use Mollie\Api\Resources\Order; use Mollie\Api\Resources\Payment; @@ -59,9 +58,4 @@ public function updateSubscription(string $subscriptionId, string $customerId, s { // TODO: Implement updateSubscription() method. } - - public function getIDealIssuers(): array - { - return []; - } } diff --git a/tests/PHPUnit/Service/MollieApi/Builder/Payments/IDealOrderBuilderTest.php b/tests/PHPUnit/Service/MollieApi/Builder/Payments/IDealOrderBuilderTest.php index 2edebad0a..43526624f 100644 --- a/tests/PHPUnit/Service/MollieApi/Builder/Payments/IDealOrderBuilderTest.php +++ b/tests/PHPUnit/Service/MollieApi/Builder/Payments/IDealOrderBuilderTest.php @@ -27,10 +27,6 @@ public function testOrderBuild(): void new FakeContainer() ); - $preferredIdealIssuer = 'preferredIssuer'; - $this->customer->setCustomFields([ - 'mollie_payments' => ['preferred_ideal_issuer' => $preferredIdealIssuer] - ]); $transactionId = Uuid::randomHex(); $amountTotal = 27.0; @@ -58,8 +54,7 @@ public function testOrderBuild(): void 'method' => $paymentMethod, 'orderNumber' => $orderNumber, 'payment' => [ - 'webhookUrl' => $redirectWebhookUrl, - 'issuer' => $preferredIdealIssuer + 'webhookUrl' => $redirectWebhookUrl ], 'redirectUrl' => $redirectWebhookUrl, 'webhookUrl' => $redirectWebhookUrl, diff --git a/tests/PHPUnit/Struct/CustomerStructTest.php b/tests/PHPUnit/Struct/CustomerStructTest.php index 04d87d760..edb7bba49 100644 --- a/tests/PHPUnit/Struct/CustomerStructTest.php +++ b/tests/PHPUnit/Struct/CustomerStructTest.php @@ -15,11 +15,9 @@ public function testSnakeToCamelKeyMagicSet() $struct = new CustomerStruct(); $struct->assign([ - 'preferred_ideal_issuer' => 'foo', 'customer_ids' => ['bar'], ]); - $this->assertSame('foo', $struct->getPreferredIdealIssuer()); $this->assertSame(['bar'], $struct->getCustomerIds()); } @@ -131,7 +129,7 @@ public function testCustomFieldsArray() $struct->setCustomerId('cst_3test', 'pfl_3', true); $struct->setCreditCardToken('cc_123'); - $struct->setPreferredIdealIssuer('ideal_bunq'); + $customFields = $struct->toCustomFieldsArray(); @@ -151,7 +149,6 @@ public function testCustomFieldsArray() 'test' => 'cst_3test' ], ], - 'preferred_ideal_issuer' => 'ideal_bunq', 'credit_card_token' => 'cc_123', ] ];