Why does the «carts/mine/payment-information» request return 404?

Hi guys,

why I get a 404 error when the checkout process call the URI carts/mine/payment-information

/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
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,
                paymentData = quote.paymentMethod();

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

                payload = {
                    cartId: quote.getQuoteId(),
                    method: paymentData,
                    billingAddress: quote.billingAddress()
                };
            }

            return storage.put(
                serviceUrl, JSON.stringify(payload)

            ).done(
                function () {
                   $.mage.redirect(window.checkoutConfig.payment.mymodule.redirectUrl);
                }
            ).fail(
                function (response) {
                    errorProcessor.process(response, messageContainer);
                    fullScreenLoader.stopLoader();
                }
            );
        };
    }
);

It is because storage.put is incorrect HTTP method for the /carts/mine/payment-information request.
You should use storage.get or storage.post depends on your task.

Examples

storage.get

storage.post

set-payment-information.js

place-order.js

1 Like