Estimate Shipping Price
Get order information, validate it and return the list of shipping fee
Flow: When call the api, service call estimate api of delivery service and return response.
URL : /api/vendor/order/estimate
Method : POST
Content-Type : multipart/form-data
Validate Rule :
'customer' => ['required', 'array'],
'customer.name' => ['required', 'string', 'min:1', 'max:100'],
'customer.phone' => ['required', 'regex:/^[0-9]*$/', 'size:10'],
'storeCode' => ['nullable', 'string'],
'shippingAddress' => ['required', 'array'],
'shippingAddress.city' => ['required', 'string'],
'shippingAddress.district' => ['required', 'string'],
'shippingAddress.ward' => ['required', 'string'],
'shippingAddress.streetAddress' => ['required', 'string', 'min:1'],
'shippingAddress.name' => ['required', 'string', 'min:1', 'max:100'],
'shippingAddress.phone' => ['required', 'regex:/^[0-9]*$/', 'size:10'],
'shippingAddress.email' => ['nullable', 'email'],
'lines' => ['required', 'array'],
'lines.*.quantity' => ['required', 'integer', 'min:1'],
'lines.*.unit' => ['required', 'string'],
'lines.*.sku' => ['required', 'string'],
'lines.*.price' => ['required', 'numeric', 'min:0'],
'subtotalPrice' => ['required', 'numeric', 'min:0'],
'paymentId' => ['required', 'int'],
'billingAddress' => ['nullable', 'array'],
'billingAddress.phone' => ['required_with:billingAddress', 'regex:/^[0-9]*$/', 'size:10'],
'billingAddress.companyName' => ['required_with:billingAddress', 'string'],
'billingAddress.address' => ['required_with:billingAddress', 'string'],
'billingAddress.email' => ['required_with:billingAddress', 'email'],
'billingAddress.taxCode' => ['required_with:billingAddress', 'string'],
'prescriptionImage' => ['nullable', 'file', 'image'],
It is basically like validating to create new request order.
Input :
customer[name]:Tiến
customer[phone]:+84933565465
shippingAddress[city]:Thành phố Hồ Chí Minh
shippingAddress[district]:Quận Bình Thạnh
shippingAddress[ward]:Phường 12
shippingAddress[streetAddress]:274 Bùi Đình Tuý
shippingAddress[name]:Long
shippingAddress[phone]:0933565465
shippingAddress[email]:abc@gmail.com
lines[0][sku]:P00047
lines[0][unit]:Goi
lines[0][quantity]:2
lines[0][price]:2000
lines[1][sku]:P00050
lines[1][unit]:Goi
lines[1][quantity]:1
lines[1][price]:2800
subtotalPrice:6800
paymentId:1
prescriptionImage:binary data
Success Response
Code : 200 OK
Content example
{
"success": true,
"errors": null,
"errorCode": null,
"data": [
{
"name": "Ahamove",
"code": "ahamove",
"price": 16000,
"service_code": "SGN-EXPRESS"
},
{
"name": "Viettel Post",
"code": "viettelpost",
"price": 16500,
"service_code": "PHS"
}
]
}
Error Response
Code : 400 BAD REQUEST
Content :
{
"success": false,
"errors": {
"customer": [
"Trường customer không được bỏ trống."
],
"customer.name": [
"Trường tên khách hàng không được bỏ trống."
],
"customer.phone": [
"Trường số điện thoại khách hàng không được bỏ trống."
]
},
"errorCode": "INVALID_INPUT",
"data": null
}