How to Create a Order using Rest Api in Magento2

Blog
Spread the love

When a product is added to the customer’s shopping cart, Magento produces a quote and the quote will be used to perform the following tasks:

Step1 – Create quoteId

Step2 – Create cartItems

Step3 – Create shipping information & billing information

Step4 – Create payment methods

But before create a quoteId we need to create a customer Authorization Token for loggedin user for this we need to do the following –

The customer’s authorization token must be contained in the authorization header to create a cart.

I will use Postman to interact with Magento 2 API and create a quote. First you have to generate a customer access token with this endpoint.

Request Type : POST

like this – http://local.magento.com/rest/V1/integration/customer/token

product-api

customer token is – ugihamdexb2jwazgwebn8svne4340c22

Step1 – Create quoteId

Request Type – POST

like as : http://local.magento.com/rest/default/V1/carts/mine

Payload – None

product-api

Response – 12

Step2 – Create cartItems

Request Type – POST

EndPoinst –

like this – (http://local.magento.com/rest/default/V1/carts/mine/items)

Customer_token – ugihamdexb2jwazgwebn8svne4340c22

Headers:

Content-Type application/json

product-api

Step3 – Create shipping information & billing information

Request Type –POST

EndPoinsts –

(http://local.magento.com/rest/default/V1/carts/mine/shipping-information)

Authorization: Bearer token – customer token

Header –

Content-Type application/json

product-api

Step4 – Create payment methods

Endpoinsts –

(http://local.magento.com/rest/default/V1/carts/mine/payment-information)

Request-Type – POST

Authorization: Bearer token – customer token

product-api

Response: “6”

Order Created Successfully.

bluethinkinc_blog

bluethinkinc_blog

2023-02-08

0

Leave a Reply

Your email address will not be published. Required fields are marked *

Find More Blogs

Salesforce Admin

Spread the love In our last blog, we discussed common

Unlocking AI with Spring Boot: Real-World Use Cases and Solutions

Spread the love Artificial Intelligence (AI) has moved from

Enhancing Performance with Reactive Java: A Beginner-Friendly Guide

Spread the love In today’s fast-paced software

Integrating Azure Function with Dynamics 365

Spread the love Signup on azure portal and make sure to

How to Create a Power Apps Component Framework (PCF) with React

Spread the love If youʼve been looking to supercharge your

Customize lead qualification for a seamless experience

Spread the love When the 2024 Release Wave 2 was launched,

Create a Custom Console Command in Spryker

Spread the love In Spryker, developers can create custom

SALESFORCE

Spread the love Salesforce is a cloud-based software

CRUD Operation in Spryker Backoffice with a Custom Module

Spread the love Spryker is a highly flexible and modular

How to create custom module on Spryker for Backoffice?

Spread the love Creating a custom module in Spryker

bluethinkinc Blogs