Magento 2.1.9 Throwing 501 When User is Logged in And Calling /rest/default/V1/carts/mine/selected-payment-method

magento.stackexchange https://magento.stackexchange.com/questions/221599

質問

I'm having an issue with my 2.1.9 Magento site where a guest user can checkout with PayPal without any issue but when a logged in user attempts to they're unable to.

During the checkout process there is a call to /rest/default/V1/carts/mine/selected-payment-method after you select PayPal as the payment method you wish to use.

The data sent to the server in this call is:

{"cartId":"10","method":{"method":"paypal_express","po_number":null,"additional_data":null}}

The response is:

{"method":null}

The call also returns a 501 which leads to an exception being thrown in the JS.

The JS that powers this is:

define(
    [
        'jquery',
        'Magento_Checkout/js/model/quote',
        'Magento_Checkout/js/model/url-builder',
        'mage/storage',
        'Magento_Checkout/js/model/error-processor',
        'Magento_Customer/js/model/customer',
        'Magento_Checkout/js/model/full-screen-loader'
    ],
    function ($, quote, urlBuilder, storage, errorProcessor, customer, fullScreenLoader) {
        'use strict';

        return function (messageContainer) {
            var serviceUrl,
                payload,
                method = 'put',
                paymentData = quote.paymentMethod();

            /**
             * Checkout for guest and registered customer.
             */
            if (!customer.isLoggedIn()) {
                serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/set-payment-information', {
                    cartId: quote.getQuoteId()
                });
                payload = {
                    cartId: quote.getQuoteId(),
                    email: quote.guestEmail,
                    paymentMethod: paymentData
                };
                method = 'post';
            } else {
                serviceUrl = urlBuilder.createUrl('/carts/mine/selected-payment-method', {});
                payload = {
                    cartId: quote.getQuoteId(),
                    method: paymentData
                };
            }
            fullScreenLoader.startLoader();

            return storage[method](
                serviceUrl, JSON.stringify(payload)
            ).fail(
                function (response) {
                    errorProcessor.process(response, messageContainer);
                    fullScreenLoader.stopLoader();
                }
            );
        };
    }
);

Console showing issue

役に立ちましたか?

解決

Found the issue, Magento had nothing to do with it.

The problem was caused by an Apache config issue.

For reference please see this post.

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top