How to create Invoice using Rest API Magento 2?

Magento 2 is robust,scalable and multi feature enable eCommerce platform. You can create Invoice of an Order Using an third party platform to Magento 2 by API request.

For Create order, Create order using Rest API Magento 2

For Create Shipment Using API, Create Shipment using Rest API Magento 2
Using below payload you can create Shipment of an order using any third party platform to Magento 2. you Just need to pass below payload in your request with POST data.

Request:
{YOUR_URL}/rest/V1/order/{order_id}/invoice

Type: POST

Body:

{
  "capture": true,
  "items": [
    {
      "extension_attributes": {},
      "order_item_id": 82,
      "qty": 1
    }
  ],
  "notify": true,
  "appendComment": true,
  "comment": {
    "extension_attributes": {},
    "comment": "Order Invoice generate",
    "is_visible_on_front": 0
  },
  "arguments": {
    "extension_attributes": {}
  }
}

Pass order_item_id is your order item’s id don’t pass order id in order_item_id field. Pass order_id in reqeuest Url. You can create multiple request using pass multi array in items array.

Response:
10 (new Invoice id)

How to create shipment using Rest API Magento 2?

Magento 2 is robust, scalable and multi-feature enable eCommerce platform. You can create Shipment of an Order Using a third party platform to Magento 2 backend by API request.
Using below payload you can create Shipment of an order using any third party platform to Magento 2. you Just need to pass below payload in your request with POST data. Check for creating an order using API,  Create order using rest api in Magento 2

Request:
{YOUR_URL}/rest/V1/order/{order_id}/ship

Type:
POST

Body:

{
    "items": [
      {
        "order_item_id": 10,
        "qty": 1
      }
    ],
    "notify": true,
  	"appendComment": true,
    "comment": {
	    "extension_attributes": {},
	    "comment": "comment on shipment",
	    "is_visible_on_front": 1
	   },
    "tracks": [
      {
        "track_number": "123456",
        "title": "fedex Shipment",
        "carrier_code": "fedex"
      }
    ]    
}

Pass order item id is your order item’s id dont pass order id. Pass order_id in request Url. You can create multiple request using pass multi-array in the items array.

Response:
10 (new shipment id)

 

How to create order using /V1/orders/create Rest API Magento 2?

Create Sales Order by REST API Magento 2 is useful to generate dynamic orders from the third-party platform in Magento System.

You can create an order using the required value from the given Payload. Send Payload in your request with PUT action.

For the Demonstrate purpose pass data like Shipping method, Flatrate shipping, Added Custom discount Shopping cart Rule, and COD as a payment method in payload request. Continue reading “How to create order using /V1/orders/create Rest API Magento 2?”