Order processing tutorial

Step 8. Create an invoice

You create an invoice after you receive payment for an order. In this example, the order was paid offline via a bank transfer. Therefore, you must tell Magento that payment for the order has been captured.

Capture payment

This example creates a full invoice. You can create a partial invoice by adding to the payload an array of items to be invoiced.

Endpoint:

POST <host>/rest/<store_code>/V1/order/3/invoice

where 3 is the orderid

Headers:

Content-Type application/json

Authorization Bearer <administrator token>

Payload:

1
2
3
4
{
  "capture": true,
  "notify": true
}

Response:

An invoice id, such as 3.

View the invoice

An invoice is structurally similar to an order, but an order contains more details.

Endpoint:

GET <host>/rest/<store_code>/V1/invoices/3

Headers:

Content-Type application/json

Authorization Bearer <administrator token>

Payload:

Not applicable

Response:

You will use the order_item_id values to create a shipment in the next step.

Show code sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
{
    "base_currency_code": "USD",
    "base_discount_amount": 0,
    "base_grand_total": 165,
    "base_discount_tax_compensation_amount": 0,
    "base_shipping_amount": 5,
    "base_shipping_incl_tax": 5,
    "base_shipping_tax_amount": 0,
    "base_subtotal": 160,
    "base_subtotal_incl_tax": 160,
    "base_tax_amount": 0,
    "base_to_global_rate": 1,
    "base_to_order_rate": 1,
    "billing_address_id": 6,
    "can_void_flag": 0,
    "created_at": "2017-08-21 22:36:02",
    "discount_amount": 0,
    "email_sent": 1,
    "entity_id": 3,
    "global_currency_code": "USD",
    "grand_total": 165,
    "discount_tax_compensation_amount": 0,
    "increment_id": "000000003",
    "order_currency_code": "USD",
    "order_id": 3,
    "shipping_address_id": 5,
    "shipping_amount": 5,
    "shipping_discount_tax_compensation_amount": 0,
    "shipping_incl_tax": 5,
    "shipping_tax_amount": 0,
    "state": 2,
    "store_currency_code": "USD",
    "store_id": 1,
    "store_to_base_rate": 0,
    "store_to_order_rate": 0,
    "subtotal": 160,
    "subtotal_incl_tax": 160,
    "tax_amount": 0,
    "total_qty": 9,
    "updated_at": "2017-08-21 22:36:03",
    "items": [
        {
            "base_discount_tax_compensation_amount": 0,
            "base_price": 22,
            "base_price_incl_tax": 22,
            "base_row_total": 22,
            "base_row_total_incl_tax": 22,
            "base_tax_amount": 0,
            "entity_id": 3,
            "discount_tax_compensation_amount": 0,
            "name": "Radiant Tee-M-Orange",
            "parent_id": 3,
            "price": 22,
            "price_incl_tax": 22,
            "product_id": 1553,
            "row_total": 22,
            "row_total_incl_tax": 22,
            "sku": "WS12-M-Orange",
            "tax_amount": 0,
            "order_item_id": 3,
            "qty": 1
        },
        {
            "base_discount_tax_compensation_amount": 0,
            "base_price": 18,
            "base_price_incl_tax": 18,
            "base_row_total": 18,
            "base_row_total_incl_tax": 18,
            "base_tax_amount": 0,
            "entity_id": 4,
            "discount_tax_compensation_amount": 0,
            "name": "Advanced Pilates & Yoga (Strength)",
            "parent_id": 3,
            "price": 18,
            "price_incl_tax": 18,
            "product_id": 49,
            "row_total": 18,
            "row_total_incl_tax": 18,
            "sku": "240-LV08",
            "tax_amount": 0,
            "order_item_id": 4,
            "qty": 1
        },
        {
            "base_price": 68,
            "base_price_incl_tax": 68,
            "entity_id": 5,
            "name": "Sprite Yoga Companion Kit",
            "parent_id": 3,
            "price": 68,
            "price_incl_tax": 68,
            "product_id": 51,
            "sku": "24-WG080-24-WG084-24-WG088-24-WG082-blue-24-WG086",
            "order_item_id": 5,
            "qty": 1
        },
        {
            "base_discount_tax_compensation_amount": 0,
            "base_price": 27,
            "base_price_incl_tax": 27,
            "base_row_total": 27,
            "base_row_total_incl_tax": 27,
            "base_tax_amount": 0,
            "entity_id": 6,
            "discount_tax_compensation_amount": 0,
            "name": "Sprite Stasis Ball 65 cm",
            "parent_id": 3,
            "price": 27,
            "price_incl_tax": 27,
            "product_id": 29,
            "row_total": 27,
            "row_total_incl_tax": 27,
            "sku": "24-WG082-blue",
            "tax_amount": 0,
            "order_item_id": 6,
            "qty": 1
        },
        {
            "base_discount_tax_compensation_amount": 0,
            "base_price": 5,
            "base_price_incl_tax": 5,
            "base_row_total": 5,
            "base_row_total_incl_tax": 5,
            "base_tax_amount": 0,
            "entity_id": 7,
            "discount_tax_compensation_amount": 0,
            "name": "Sprite Foam Yoga Brick",
            "parent_id": 3,
            "price": 5,
            "price_incl_tax": 5,
            "product_id": 21,
            "row_total": 5,
            "row_total_incl_tax": 5,
            "sku": "24-WG084",
            "tax_amount": 0,
            "order_item_id": 7,
            "qty": 1
        },
        {
            "base_discount_tax_compensation_amount": 0,
            "base_price": 17,
            "base_price_incl_tax": 17,
            "base_row_total": 17,
            "base_row_total_incl_tax": 17,
            "base_tax_amount": 0,
            "entity_id": 8,
            "discount_tax_compensation_amount": 0,
            "name": "Sprite Yoga Strap 8 foot",
            "parent_id": 3,
            "price": 17,
            "price_incl_tax": 17,
            "product_id": 34,
            "row_total": 17,
            "row_total_incl_tax": 17,
            "sku": "24-WG086",
            "tax_amount": 0,
            "order_item_id": 8,
            "qty": 1
        },
        {
            "base_discount_tax_compensation_amount": 0,
            "base_price": 19,
            "base_price_incl_tax": 19,
            "base_row_total": 19,
            "base_row_total_incl_tax": 19,
            "base_tax_amount": 0,
            "entity_id": 9,
            "discount_tax_compensation_amount": 0,
            "name": "Sprite Foam Roller",
            "parent_id": 3,
            "price": 19,
            "price_incl_tax": 19,
            "product_id": 22,
            "row_total": 19,
            "row_total_incl_tax": 19,
            "sku": "24-WG088",
            "tax_amount": 0,
            "order_item_id": 9,
            "qty": 1
        },
        {
            "base_discount_tax_compensation_amount": 0,
            "base_price": 52,
            "base_price_incl_tax": 52,
            "base_row_total": 52,
            "base_row_total_incl_tax": 52,
            "base_tax_amount": 0,
            "entity_id": 10,
            "discount_tax_compensation_amount": 0,
            "name": "Chaz Kangeroo Hoodie",
            "parent_id": 3,
            "price": 52,
            "price_incl_tax": 52,
            "product_id": 67,
            "row_total": 52,
            "row_total_incl_tax": 52,
            "sku": "MH01-S-Gray",
            "tax_amount": 0,
            "order_item_id": 10,
            "qty": 1
        },
        {
            "base_price": 0,
            "entity_id": 11,
            "name": "Chaz Kangeroo Hoodie-S-Gray",
            "parent_id": 3,
            "price": 0,
            "product_id": 56,
            "sku": "MH01-S-Gray",
            "order_item_id": 11,
            "qty": 1
        }
    ],
    "comments": []
}

Verify this step

Log in to Admin. Click Sales > Invoices. The invoice is displayed in the grid. The status is Paid. Then click Sales > Orders. The status is Processing.