Step 8. Prepare for checkout

Order processing with Inventory Management

Now that all the items have been added to the cart, we can prepare the quote for checkout. This process includes the following steps:

  • Estimate shipping costs
  • Set shipping and billing information

Estimate shipping costs

Magento calculates shipping costs for each shipping method that can be applied to the order. In this tutorial, the flatrate ($5 per item) shipping method is active.

Endpoint:

POST <host>/rest/us/V1/carts/mine/estimate-shipping-methods

Scope:

us store view

Headers:

Content-Type: application/json

Authorization: Bearer <customer token>

Payload:

The payload contains the shipping address.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{  "address": {
      "region": "New York",
      "region_id": 43,
      "region_code": "NY",
      "country_id": "US",
      "street": [
        "123 Oak Ave"
        ],
      "postcode": "10577",
      "city": "Purchase",
      "firstname": "Jane",
      "lastname": "Doe",
      "customer_id": 5,
      "email": "jdoe@example.com",
      "telephone": "(512) 555-1111",
      "same_as_billing": 1
  }
}

Response:

The cost for the flatrate shipping method is $350 (70 items x $5 each). The downloadable item does not have a shipping charge because it is not a physical product.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[
    {
        "carrier_code": "flatrate",
        "method_code": "flatrate",
        "carrier_title": "Flat Rate",
        "method_title": "Fixed",
        "amount": 350,
        "base_amount": 350,
        "available": true,
        "error_message": "",
        "price_excl_tax": 350,
        "price_incl_tax": 350
    }
]

Set shipping and billing information

In this call, you specify the shipping and billing addresses, as well as the selected carrier_code and method_code. The customer has selected the Flat Rate shipping method.

Magento returns a list of payment options and calculates the order totals.

Endpoint:

POST <host>/rest/us/V1/carts/mine/shipping-information

Scope:

us store view

Headers:

Content-Type: application/json

Authorization: Bearer <customer token>

Payload:

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
{
"addressInformation": {
    "shipping_address": {
        "region": "New York",
        "region_id": 43,
        "region_code": "NY",
        "country_id": "US",
        "street": [
            "123 Oak Ave"
        ],
        "postcode": "10577",
        "city": "Purchase",
        "firstname": "Jane",
        "lastname": "Doe",
        "email": "jdoe@example.com",
        "telephone": "512-555-1111"
    },
    "billing_address": {
        "region": "New York",
        "region_id": 43,
        "region_code": "NY",
        "country_id": "US",
        "street": [
            "123 Oak Ave"
        ],
        "postcode": "10577",
        "city": "Purchase",
        "firstname": "Jane",
        "lastname": "Doe",
        "email": "jdoe@example.com",
        "telephone": "512-555-1111"
    },
    "shipping_carrier_code": "flatrate",
    "shipping_method_code": "flatrate"
    }
}

Response:

The subtotal of the order is $2462, and shipping charges are $350. The grand total is $2812.

The available payment methods are banktransfer and checkmo. The customer will specify a payment method in the next step.

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
{
    "payment_methods": [
        {
            "code": "banktransfer",
            "title": "Bank Transfer Payment"
        },
        {
            "code": "checkmo",
            "title": "Check / Money order"
        }
    ],
    "totals": {
        "grand_total": 2812,
        "base_grand_total": 2812,
        "subtotal": 2462,
        "base_subtotal": 2462,
        "discount_amount": 0,
        "base_discount_amount": 0,
        "subtotal_with_discount": 2462,
        "base_subtotal_with_discount": 2462,
        "shipping_amount": 350,
        "base_shipping_amount": 350,
        "shipping_discount_amount": 0,
        "base_shipping_discount_amount": 0,
        "tax_amount": 0,
        "base_tax_amount": 0,
        "weee_tax_applied_amount": null,
        "shipping_tax_amount": 0,
        "base_shipping_tax_amount": 0,
        "subtotal_incl_tax": 2462,
        "shipping_incl_tax": 350,
        "base_shipping_incl_tax": 350,
        "base_currency_code": "USD",
        "quote_currency_code": "USD",
        "items_qty": 71,
        "items": [
            {
                "item_id": 5,
                "price": 32,
                "base_price": 32,
                "qty": 20,
                "row_total": 640,
                "base_row_total": 640,
                "row_total_with_discount": 0,
                "tax_amount": 0,
                "base_tax_amount": 0,
                "tax_percent": 0,
                "discount_amount": 0,
                "base_discount_amount": 0,
                "discount_percent": 0,
                "price_incl_tax": 32,
                "base_price_incl_tax": 32,
                "row_total_incl_tax": 640,
                "base_row_total_incl_tax": 640,
                "options": "[]",
                "weee_tax_applied_amount": null,
                "weee_tax_applied": null,
                "name": "Voyage Yoga Bag"
            },
            {
                "item_id": 6,
                "price": 36,
                "base_price": 36,
                "qty": 50,
                "row_total": 1800,
                "base_row_total": 1800,
                "row_total_with_discount": 0,
                "tax_amount": 0,
                "base_tax_amount": 0,
                "tax_percent": 0,
                "discount_amount": 0,
                "base_discount_amount": 0,
                "discount_percent": 0,
                "price_incl_tax": 36,
                "base_price_incl_tax": 36,
                "row_total_incl_tax": 1800,
                "base_row_total_incl_tax": 1800,
                "options": "[]",
                "weee_tax_applied_amount": null,
                "weee_tax_applied": null,
                "name": "Driven Backpack"
            },
            {
                "item_id": 7,
                "price": 22,
                "base_price": 22,
                "qty": 1,
                "row_total": 22,
                "base_row_total": 22,
                "row_total_with_discount": 0,
                "tax_amount": 0,
                "base_tax_amount": 0,
                "tax_percent": 0,
                "discount_amount": 0,
                "base_discount_amount": 0,
                "discount_percent": 0,
                "price_incl_tax": 22,
                "base_price_incl_tax": 22,
                "row_total_incl_tax": 22,
                "base_row_total_incl_tax": 22,
                "options": "[{\"value\":\"Yoga Adventure\",\"label\":\"Downloads\"}]",
                "weee_tax_applied_amount": null,
                "weee_tax_applied": null,
                "name": "Yoga Adventure"
            }
        ],
        "total_segments": [
            {
                "code": "subtotal",
                "title": "Subtotal",
                "value": 2462
            },
            {
                "code": "giftwrapping",
                "title": "Gift Wrapping",
                "value": null,
                "extension_attributes": {
                    "gw_item_ids": [],
                    "gw_price": "0.0000",
                    "gw_base_price": "0.0000",
                    "gw_items_price": "0.0000",
                    "gw_items_base_price": "0.0000",
                    "gw_card_price": "0.0000",
                    "gw_card_base_price": "0.0000"
                }
            },
            {
                "code": "shipping",
                "title": "Shipping & Handling (Flat Rate - Fixed)",
                "value": 350
            },
            {
                "code": "tax",
                "title": "Tax",
                "value": 0,
                "extension_attributes": {
                    "tax_grandtotal_details": []
                }
            },
            {
                "code": "grand_total",
                "title": "Grand Total",
                "value": 2812,
                "area": "footer"
            },
            {
                "code": "customerbalance",
                "title": "Store Credit",
                "value": 0
            },
            {
                "code": "reward",
                "title": "0 Reward points",
                "value": 0
            }
        ],
        "extension_attributes": {
            "reward_points_balance": 0,
            "reward_currency_amount": 0,
            "base_reward_currency_amount": 0
        }
    }
}

Verify this step

Sign in to the US store (http://<host>/us) as the customer and go to the checkout page.

The payment method is Bank Transfer, the billing and shipping addresses are displayed, and the shipping charges and shipping charges calculate and display.