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

PODMAN

Spread the love 1.Introduction Podman: The Modern Container

Running Your Java Program (JAR) 24/7 on AWS EC2 Automatically

Spread the love Introduction Running a Java application

Building a REST API with Spring Boot

Spread the love Introduction REST (Representational State

Custom API to Fetch Customer Data by Customer ID in Spryker

Spread the love Introduction In this blog post, we will

Creating a Custom Module for a Custom Frontend Page in Spryker

Spread the love To create a custom module for a custom

How to create custom module api get category list without access token in Spryker

Spread the love To create a custom API for fetching a

Creating a Custom Glue API in Spryker

Spread the love Spryker’s Glue API is a powerful tool

Get AI Generated 360-Degree View of Account Summary in Dynamics 365 Sales

Spread the love Navigating the demanding landscape of sales

Enhancing Productivity with Dynamics 365: The Power of Session Restore

Spread the love Enhancing Productivity with Dynamics 365:

Salesforce Admin

Spread the love In our last blog, we discussed common

bluethinkinc Blogs