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

How to Add a Custom Tab to the Customer Order Detail Page in Magento 2

Spread the love Adding a custom tab to the Order Detail

Exception Handling in Java

Spread the love Introduction – Exception:An unwanted

How to add custom less file in Magento2

Spread the love Source files *.css included into layout

Spring Boot Microservices

Spread the love Microservices architecture has become

Implementation of WireMock for better testing

Spread the love WireMock is a flexible and powerful tool

Magento 2: How to selected default option in configurable options?

Spread the love Configurable products in Magento 2 allow

How To Implement Simple JWT Authentication in Django Rest Framework

Spread the love We’ll learn how to use simple JWT

Optimizing Search: Integrating Elasticsearch in Django Applications

Spread the love What is Elasticsearch? Elasticsearch is a

How to create Customer Segments

Spread the love In Magento 2, “customer

Proxy Design Pattern and Requisition List in Magento 2

Spread the love Requisition List in Magento 2 Requisition

bluethinkinc Blogs