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

Proxy Design Pattern and Requisition List in Magento 2

Spread the love Requisition List in Magento 2 Requisition

Google Ads Conversion Tracking Through Magento Platform:

Spread the love Google Ads Conversion Tracking Through

Object Pool Pattern in Magento2

Spread the love What is Object Pool Pattern in Magento 2 An

JENKINS

Spread the love JENKINS Introduction and Installation

Virtual Type and Type

Spread the love Virtual type is one of the most common

Customize the length of Input field

Spread the love Sometimes we need to change the limit the

How to Add Custom Tab on Admin Dashboard and Count Website Total Visitor in Magento 2?

Spread the love In this blog we’ll see How to Add Custom

How to Add Sign Out Tab in Customer Account in Magento 2?

Spread the love In this blog we’ll see How to Add

How to create custom tab in product detail page in magento 2?

Spread the love In this blog we’ll see how to add

Understanding and Implementing CORS & CSRF

Spread the love What is security? The world has become more

bluethinkinc Blogs