diff --git a/.github/actions/build-plugin/action.yml b/.github/actions/build-plugin/action.yml index b1d7dbd3b..ba537ad44 100644 --- a/.github/actions/build-plugin/action.yml +++ b/.github/actions/build-plugin/action.yml @@ -51,7 +51,7 @@ runs: unzip ~/.build/MolliePayments.zip -d ~/.build/MolliePayments - name: Store ZIP file in Github - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: MolliePayments-Shopware retention-days: 4 diff --git a/.github/actions/run-e2e/action.yml b/.github/actions/run-e2e/action.yml index ebae032f8..2d33ab682 100644 --- a/.github/actions/run-e2e/action.yml +++ b/.github/actions/run-e2e/action.yml @@ -184,7 +184,7 @@ runs: - name: Store Cypress Results if: ${{ inputs.RUN_CYPRESS == 'true' && always() }} - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: cypress_results_v${{ inputs.SHOPWARE }}${{ inputs.CYPRESS_RESULTS_SUFFIX }} retention-days: 1 diff --git a/src/Components/ApplePayDirect/ApplePayDirect.php b/src/Components/ApplePayDirect/ApplePayDirect.php index 320c97e51..764639abc 100644 --- a/src/Components/ApplePayDirect/ApplePayDirect.php +++ b/src/Components/ApplePayDirect/ApplePayDirect.php @@ -348,7 +348,7 @@ public function restoreCart(SalesChannelContext $context): void * @throws \Exception * @return SalesChannelContext */ - public function prepareCustomer(string $firstname, string $lastname, string $email, string $street, string $zipcode, string $city, string $countryCode, string $phone, string $paymentToken, SalesChannelContext $context): SalesChannelContext + public function prepareCustomer(string $firstname, string $lastname, string $email, string $street, string $zipcode, string $city, string $countryCode, string $phone, string $paymentToken, int $acceptedDataProtection, SalesChannelContext $context): SalesChannelContext { if (empty($paymentToken)) { throw new \Exception('PaymentToken not found!'); @@ -369,6 +369,7 @@ public function prepareCustomer(string $firstname, string $lastname, string $ema $zipcode, $city, $countryCode, + $acceptedDataProtection, $context ); diff --git a/src/Controller/StoreApi/ApplePayDirect/ApplePayDirectControllerBase.php b/src/Controller/StoreApi/ApplePayDirect/ApplePayDirectControllerBase.php index 5ffb41850..96ed191af 100644 --- a/src/Controller/StoreApi/ApplePayDirect/ApplePayDirectControllerBase.php +++ b/src/Controller/StoreApi/ApplePayDirect/ApplePayDirectControllerBase.php @@ -195,6 +195,8 @@ public function pay(RequestDataBag $data, SalesChannelContext $context): StoreAp $countryCode = (string)$data->get('countryCode', ''); $phone = (string)$data->get('phone', ''); + $acceptedDataProtection = (int)$data->get('acceptedDataProtection', '0'); + $paymentToken = (string)$data->get('paymentToken', ''); $finishUrl = (string)$data->get('finishUrl', ''); $errorUrl = (string)$data->get('errorUrl', ''); @@ -217,6 +219,7 @@ public function pay(RequestDataBag $data, SalesChannelContext $context): StoreAp $countryCode, $phone, $paymentToken, + $acceptedDataProtection, $context ); diff --git a/src/Controller/Storefront/ApplePayDirect/ApplePayDirectControllerBase.php b/src/Controller/Storefront/ApplePayDirect/ApplePayDirectControllerBase.php index 23a730737..de8dc7eaf 100644 --- a/src/Controller/Storefront/ApplePayDirect/ApplePayDirectControllerBase.php +++ b/src/Controller/Storefront/ApplePayDirect/ApplePayDirectControllerBase.php @@ -324,6 +324,7 @@ public function startPayment(SalesChannelContext $context, Request $request): Re $city = (string)$request->get('city', ''); $countryCode = (string)$request->get('countryCode', ''); $phone = (string)$request->get('phone', ''); + $acceptedDataProtection = (int)$request->get('acceptedDataProtection', '0'); $paymentToken = (string)$request->get('paymentToken', ''); @@ -342,6 +343,7 @@ public function startPayment(SalesChannelContext $context, Request $request): Re $countryCode, $phone, $paymentToken, + $acceptedDataProtection, $context ); diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-direct.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-direct.plugin.js index 3921d29e1..53f974b58 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-direct.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-direct.plugin.js @@ -30,10 +30,9 @@ export default class MollieApplePayDirect extends Plugin { } - const submitForm = document.querySelector('#productDetailPageBuyProductForm'); - if(submitForm !== null){ + if (submitForm !== null) { this.checkSubmitButton(submitForm); submitForm.addEventListener('change', (event) => { this.checkSubmitButton(event.target.closest('form#productDetailPageBuyProductForm')); @@ -86,7 +85,6 @@ export default class MollieApplePayDirect extends Plugin { const shopUrl = me.getShopUrl(applePayButtons[0]); - // verify if apple pay is even allowed // in our current sales channel me.client.get( @@ -102,7 +100,7 @@ export default class MollieApplePayDirect extends Plugin { applePayButtons.forEach(function (button) { - if(button.hasAttribute('disabled')){ + if (button.hasAttribute('disabled')) { button.classList.add('d-none'); button.removeEventListener('click', me.onButtonClick); return; @@ -118,24 +116,24 @@ export default class MollieApplePayDirect extends Plugin { ); } - checkSubmitButton(form){ + checkSubmitButton(form) { const buyButton = form.querySelector('.btn-buy'); - if(buyButton === null){ + if (buyButton === null) { return; } const applePayButton = form.querySelector('.js-apple-pay'); - if(applePayButton === null){ + if (applePayButton === null) { return; } - if(applePayButton.hasAttribute('disabled')){ + if (applePayButton.hasAttribute('disabled')) { applePayButton.removeAttribute('disabled'); } - if(buyButton.hasAttribute('disabled')){ - applePayButton.setAttribute('disabled','disabled'); + if (buyButton.hasAttribute('disabled')) { + applePayButton.setAttribute('disabled', 'disabled'); } } @@ -164,7 +162,20 @@ export default class MollieApplePayDirect extends Plugin { const currency = form.querySelector('input[name="currency"]').value; const mode = form.querySelector('input[name="mode"]').value; const withPhone = parseInt(form.querySelector('input[name="withPhone"]').value); + const dataProtection = form.querySelector('input[name="acceptedDataProtection"]'); + + form.classList.remove('was-validated'); + if (dataProtection !== null) { + const dataProtectionValue = dataProtection.checked ? 1: 0; + form.classList.add('was-validated'); + + dataProtection.classList.remove('is-invalid'); + if (dataProtectionValue === 0) { + dataProtection.classList.add('is-invalid'); + return; + } + } // this helps us to figure out if we are in // "product" mode to purchase a single product, or in "cart" mode @@ -192,7 +203,7 @@ export default class MollieApplePayDirect extends Plugin { } const applePaySessionFactory = new ApplePaySessionFactory(); - const session = applePaySessionFactory.create(isProductMode,countryCode,currency,withPhone,shopSlug); + const session = applePaySessionFactory.create(isProductMode, countryCode, currency, withPhone, shopSlug, dataProtection); session.begin(); } diff --git a/src/Resources/app/storefront/src/mollie-payments/services/ApplePaySessionFactory.js b/src/Resources/app/storefront/src/mollie-payments/services/ApplePaySessionFactory.js index e228db462..54974e0c3 100644 --- a/src/Resources/app/storefront/src/mollie-payments/services/ApplePaySessionFactory.js +++ b/src/Resources/app/storefront/src/mollie-payments/services/ApplePaySessionFactory.js @@ -18,9 +18,10 @@ export default class ApplePaySessionFactory { * @param currency * @param shopSlug * @param withPhone + * @param dataProtection * @returns {ApplePaySession} */ - create(isProductMode, country, currency, withPhone, shopSlug) { + create(isProductMode, country, currency, withPhone, shopSlug, dataProtection) { const me = this; var shippingFields = [ @@ -32,6 +33,10 @@ export default class ApplePaySessionFactory { if (withPhone === 1) { shippingFields.push('phone'); } + let dataProtectionValue = false; + if(dataProtection !== null){ + dataProtectionValue = dataProtection.value; + } var request = { countryCode: country, @@ -160,7 +165,7 @@ export default class ApplePaySessionFactory { // now finish our payment by filling a form // and submitting it along with our payment token - me.finishPayment(shopSlug + '/mollie/apple-pay/start-payment', paymentToken, event.payment); + me.finishPayment(shopSlug + '/mollie/apple-pay/start-payment', paymentToken, event.payment,dataProtectionValue); }; session.oncancel = function () { @@ -181,7 +186,7 @@ export default class ApplePaySessionFactory { * @param paymentToken * @param payment */ - finishPayment(checkoutURL, paymentToken, payment) { + finishPayment(checkoutURL, paymentToken, payment,dataProtectionValue) { const createInput = function (name, val) { const input = document.createElement('input'); input.type = 'hidden'; @@ -208,6 +213,7 @@ export default class ApplePaySessionFactory { form.insertAdjacentElement('beforeend', createInput('street', street)); form.insertAdjacentElement('beforeend', createInput('postalCode', payment.shippingContact.postalCode)); form.insertAdjacentElement('beforeend', createInput('city', payment.shippingContact.locality)); + form.insertAdjacentElement('beforeend', createInput('acceptedDataProtection', dataProtectionValue)); if (payment.shippingContact.phoneNumber !== undefined && payment.shippingContact.phoneNumber.length > 0) { form.insertAdjacentElement('beforeend', createInput('phone', payment.shippingContact.phoneNumber)); diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 26f23c6d3..6c27fb0e3 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -128,7 +128,7 @@ - + diff --git a/src/Resources/views/mollie/component/apple-pay-direct-button.twig b/src/Resources/views/mollie/component/apple-pay-direct-button.twig index c0c12a876..8b54cdaa7 100644 --- a/src/Resources/views/mollie/component/apple-pay-direct-button.twig +++ b/src/Resources/views/mollie/component/apple-pay-direct-button.twig @@ -1,4 +1,5 @@ {% block mollie_apple_pay_direct %} +
{% if page.product %} {# this is for older shopware versions #} @@ -32,6 +33,11 @@ {% block mollie_apple_pay_direct_button %} + + {% if mollie_express_required_data_protection %} + {% sw_include '@Storefront/storefront/component/privacy-notice.html.twig' %} + {% endif %} +