How to place an order using the Magento2 API?

I am looking for a complete "happy journey" to place an order using the Magento2 REST API. So far, I have followed all these steps. What else am I missing?

  • Create a user: [POST] /rest/V1/customers

  • Login (token creation): [POST] /rest/V1/integration/customer/token

  • Get product categories for navigation: [GET] /rest/V1/categories

  • Get Products:

    4.1 Get products in categories: [GET] /rest/V1/categories/{category_id}/products

    4.2 Or find a product: [GET] /rest/V1/products

  • Create Cart: [POST] /rest/V1/carts/mine

  • Add items to cart: [POST] /rest/V1/carts/mine/items

  • Get information about payment cards [GET] /rest/V1/carts/mine/payment-information

  • ...

What else do I need to do to place an order?

+7
rest api magento2
source share
2 answers
  • create an empty cart url: http://www.xxxxxx.com/rest/V1/carts/mine call: post answer: cartID for example: 4290

  • Add product to cart url: http://www.xxxxxx.com/rest/V1/carts/mine/items body:

     {"cartItem":{ "sku":"JFCO00017","qty":1,"name":"Devil May Cry III 3 Dante Cosplay Costume","price":81.55,"product_type":"simple","quote_id":"4290","product_option":{"extension_attributes":{"custom_options":[{"option_id":"thumbnail","option_value":"\/d\/e\/devilmaycryiii3dantecosplay_1_.jpg"},{"option_id":"color_2","option_value":"Red"},{"option_id":"google_size","option_value":"xxs"}]}}} } 
  • Add url billing information: http://www.xxxxxx.com/rest/V1/carts/mine/billing-address body:

     { "address": { "city": "noida", "company": "iprag", "countryId": "IN", "email": " manish+2@gmail.com ", "firstname": "Manish", "lastname": "Kumar", "postcode": "201301", "region": "UP", "saveInAddressBook": 1, "street": ["D-84"], "telephone": "8802xxxx90" }, "useForShipping": true } 
  • Get url shipping methods: http://www.xxxxxx.com/rest/V1/carts/mine/shipping-methods

     { "carrier_code": "flatrate", "method_code": "flatrate", "carrier_title": "Flat Rate", "method_title": "Fixed", "amount": 10, "base_amount": 10, "available": true, "error_message": "", "price_excl_tax": 10, "price_incl_tax": 10 

    }

  • add shipping information url: http://www.xxxxxx.com/rest/V1/carts/mine/shipping-information Body:

     { "addressInformation": { "billingAddress": { "city": "noida", "company": "iprag", "email": " nkn@gmail.com ", "firstname": "Manish", "lastname": "Kumar", "postcode": "335001", "region": "UP", "street": ["D-84"], "telephone": "9413433217" }, "shippingAddress": { "city": "noida", "company": "iprag", "email": " nkn@gmail.com ", "firstname": "Manish", "lastname": "Kumar", "postcode": "335001", "region": "UP", "street": ["D-84"], "telephone": "9413433217" }, "shippingCarrierCode": "flatrate", "shippingMethodCode": "flatrate" } } 

Answer: payment method and basket details

  1. Place reservation URL: http://www.xxxxxx.com/rest/V1/carts/mine/order body:

     { "paymentMethod":{"method":"checkmo"}, "shippingMethod": { "method_code":"flatrate", "carrier_code":"flatrate", "additionalProperties":{} } } 

response: orderid

+4
source share

Ok, I finally get it.

  1. Save the payment information and create the order [POST] /rest/V1/carts/mine/payment-information
+2
source share

All Articles