5

When using Amazon Pay during the checkout process, seemingly any module that uses Javascript mixins to capture additional fields from the checkout page and pass them to the POST request for processing get skipped, resulting in the data never being sent to the server for processing.

For example, we're in the process of installing the GDPR module from Plumrocket and testing it on our development site. We've added a Consent Checkbox for the Privacy Policy to the checkout process. This adds a little checkbox just bellow the payment method to accept the Privacy Policy. If it's not checked, it won't let you click the checkout button. But when you check it and hit submit there's a server side check for the box, and that is throwing an error because the checkbox is never sent through the payment[extension_attributes][consent_ids] key during the POST.

So I opened up the console and started throwing some breakpoints in the javascript. And from what I can tell, none of Plumrocket GDPR's mixins get ran after hitting the submit button. In contrast, they work just fine when using PayPal, Auth.net/Credit Card, or Gift Card payment methods.

Now, I know what you might be thinking, that "It's probably just an issue with GDPR.", but we have another website where we are setting up Amazon Pay and it's causing issues with another module that tries to capture additional fields in the payment[extension_attributes] key.

This module adds a text box to capture a Delta SkyMiles account number and was built mostly following this stack answer. It's a pretty straight forward little module that does what it needs to do and like the GDPR, works on every payment method except Amazon Pay. And just like the GDPR, none of the mixins run, and the field ultimately is not added to the payment[extension_attributes] key during the POST.

So, my hope here is that someone has some insight as to what might be happening here. Because I'm at a loss at this point. This does not seem like the behavior I would expect from a proper payment method.

Edit 9/25

I've learned after some testing that this only happens to JS mixins applied to the payment_methods section of the checkout and are acting on Magento_Checkout/js/action/place-order. We recently added a checkbox to the shipping_methods section of checkout that acts on Magento_Checkout/js/action/set-shipping-information and that one works fine when using Amazon Pay and the checkbox is properly captured for the order.

4

I can't believe I didn't catch this sooner. I'm going to blame my newness to Magento, but for everyone else who might be struggling with this issue and since I couldn't find it anywhere else on the greater internet...

The Amazon Payment module that comes included with Magento 2.2.x, overrides the javascript used in the place-order action. So adding your mixin to the standard Magento_Checkout/js/action/place-order will not work with Amazon Pay. You must also include you mixin with Amazon Pay's version of place-order like so:

/**
 * app/code/[vendor]/[module]/view/frontend/web/requirejs-config.js
 */

var config = {
    config: {
        mixins: {
            'Magento_Checkout/js/action/place-order': {
                'Vendor_Module/js/order/place-order-mixin': true
            },
            'Amazon_Payment/js/action/place-order': {
                'Vendor_Module/js/order/place-order-mixin': true
            }
        }
    }
};

That's it. It's that easy to get everything working again. I hope this helps someone else, because boy do I sure wish this was mentioned somewhere.

  • 1
    If it makes you feel better half of my questions I answer myself and go "I can't believe I didn't ______ ..." – jamil Sep 26 '18 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.