1

I want to create a order in Magento 2 using REST api url i.e. http://localhost/taleb_check/rest/default/V1/carts/mine/payment-information. When we click place order button then this url get calls using ajax in normal magento flow.

So I have created one custom page which consist one button on click of which I want same functionality i.e. order placement.

Note : I have already all the required data which needs to place order in session.

Can any one please guide me.

So far I have created one js code which gets call using ajax request.

$('#place_order_button').click(function(){
        var param = 'ajax=1';
        var orderData = {
                            "billingAddress": {
                                "city": "Pune",
                                "countryId": "AU",
                                "customerAddressId": "1",
                                "customerId": "6",
                                "firstname": "user",
                                "lastname": "name",
                                "postcode": "1234",
                                "region": "New",
                                "regionCode": "NSW",
                                "regionId": "513",
                                "saveInAddressBook": null,
                                "street": {
                                    "0": "Pune",
                                    "telephone": "9876543210"
                                }
                            },
                            "cartId": "81",
                            "paymentMethod": {
                                "additional_data": null,
                                "method": "casho",
                                "po_number": null
                            }
                        }; 
        $.ajax({
            showLoader: true,
            url: "http://localhost/taleb_check/rest/default/V1/carts/mine/payment-information",
            data: orderData,
            type: "POST",
            dataType: 'json'
        }).done(function (data) {
            console.log(data);
        });
    });

But its not working can any one please point where I am making mistake.

Your Answer

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

Browse other questions tagged or ask your own question.