Adyen / adyen-magento2

Adyen Payment plugin for Magento2
MIT License
155 stars 211 forks source link

Non extable Magento_Checkout/js/action/set-shipping-information by mixins #1155

Closed LexKoomen closed 3 years ago

LexKoomen commented 3 years ago

Describe the bug Because of this commit: https://github.com/Adyen/adyen-magento2/commit/8176e579690629ae61766a76a03c96052b4d70ef#diff-305640b060cc6eabfd8947b348781a297906bda7f8ea7a33e375fa2a875680ec

The Magento_Checkout/js/action/set-shipping-information isn't extendable anymore. That is because in the mixin the result is not returned, so other mixins do not have a result.

To Reproduce Steps to reproduce the behavior:

  1. Create mixin on Magento_Checkout/js/action/set-shipping-information
  2. Try to extend the .done() function of the original request:
    return target().done(function (res) {
    console.log(res);
    }
  3. res is undefined
  4. Now add 'return result' in the original method of Adyen
  5. see that res is not undefined anymore

Expected behavior That the result is extendable for other modules aswell

Magento version [e.g. 2.3.7]

Plugin version [7.2.0]

Problem could be solved by adding return result in https://github.com/Adyen/adyen-magento2/blob/7.2.0/view/frontend/web/js/model/set-shipping-information-mixin.js before line 29.

return function (shippingInformationAction) {

        return wrapper.wrap(shippingInformationAction, function (originalAction) {
            return originalAction().then(function (result) {
                fullScreenLoader.startLoader();
                // Retrieve adyen payment methods
                adyenPaymentService.retrievePaymentMethods().done(function(paymentMethods) {
                    paymentMethods = JSON.parse(paymentMethods);
                    adyenPaymentService.setPaymentMethods(paymentMethods);
                    fullScreenLoader.stopLoader();
                }).fail(function() {
                    console.log('Fetching the payment methods failed!');
                })

                return result; <<<<<<<<<<--------------
            });
        });

    };
acampos1916 commented 3 years ago

Thanks for the heads up @LexKoomen, I've created a PR with the fix.