Create Order
Create a new order by user (support both GET/POST method)
- cURL
- JavaScript
curl --request POST \
--url https://apistg.ahamove.com/v1/order/create \
--header 'Cache-Control: no-cache' \
--header 'accept: application/json' \
--header 'content-type: application/x-www-form-urlencoded' \
--data-urlencode 'service_id=SGN-BIKE' \
--data-urlencode 'payment_method=CASH' \
--data-urlencode 'promo_code=KHUYENMAI' \
--data-urlencode 'remarks=This is note for order' \
--data-urlencode 'order_time=0' \
--data-urlencode 'requests=[{"_id":"SGN-BIKE-TIP","num":2}]' \
--data-urlencode 'path=[{"lat":10.7692105,"lng":106.6637935,"address":"725 Hẻm số 7 Thành Thái, Phường 14, Quận 10, Hồ Chí Minh, Việt Nam","short_address":"Quận 10","name":"nmbmb","mobile":"84xxxxxxxxx"},{"lat":10.7828887,"lng":106.704898,"address":"Miss Ao Dai Building, 21 Nguyễn Trung Ngạn, Bến Nghé, Quận 1, Hồ Chí Minh, Vietnam","name":"Bao","mobile":"84xxxxxxxxx","remarks":"call me","cod":85000,"tracking_number":"1234"}]' \
--data-urlencode 'items=[{"_id": "TS","num": 2,"name": "Sua tuoi","price": 15000},{"_id": "ST","num": 2,"name": "Sinh to","price": 30000}]' \
--data-urlencode 'token=<TOKEN_STG>'
var myHeaders = new Headers();
myHeaders.append('accept', 'application/json');
myHeaders.append('content-type', 'application/x-www-form-urlencoded');
var urlencoded = new URLSearchParams();
urlencoded.append('service_id', 'SGN-BIKE');
urlencoded.append('payment_method', 'CASH');
urlencoded.append('promo_code', 'KHUYENMAI');
urlencoded.append('remarks', 'This is note for order');
urlencoded.append('order_time', '0');
urlencoded.append('requests', '[{"_id":"SGN-BIKE-TIP","num":2}]');
urlencoded.append(
'path',
'[{"lat":10.7692105,"lng":106.6637935,"address":"725 Hẻm số 7 Thành Thái, Phường 14, Quận 10, Hồ Chí Minh, Việt Nam","short_address":"Quận 10","name":"nmbmb","mobile":"84xxxxxxxxx"},{"lat":10.7828887,"lng":106.704898,"address":"Miss Ao Dai Building, 21 Nguyễn Trung Ngạn, Bến Nghé, Quận 1, Hồ Chí Minh, Vietnam","name":"Bao","mobile":"84xxxxxxxxx","remarks":"call me","cod":85000,"tracking_number":"1234"}]'
);
urlencoded.append("items", "[{"_id": "TS","num": 2,"name": "Sua tuoi","price": 15000},{"_id": "ST","num": 2,"name": "Sinh to","price": 30000}]");
urlencoded.append('token', '<TOKEN_STG>');
urlencoded.append('conversion_data', '');
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow',
};
fetch('https://apistg.ahamove.com/v1/order/create', requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log('error', error));
HTTP Request
POST https://apistg.ahamove.com/v1/order/create
(x-wwww-form-urlencoded)
or
GET https://apistg.ahamove.com/v1/order/create
Parameters
# Parameters
{
"order_time": 0,
"path": [
{
"lat": 10.7692105,
"lng": 106.6637935,
"address": "725 Hẻm số 7 Thành Thái, Phường 14, Quận 10, Hồ Chí Minh, Việt Nam",
"short_address": "Quận 10",
"name": "nmbmb",
"mobile":"84xxxxxxxxx"
},
{
"lat": 10.7828887,
"lng": 106.704898,
"address": "Miss Ao Dai Building, 21 Nguyễn Trung Ngạn, Bến Nghé, Quận 1, Hồ Chí Minh, Vietnam",
"name": "Bao",
"mobile":"84xxxxxxxxx",
"remarks": "call me",
"cod": 85000,
"tracking_number": "1234"
}
],
"service_id": "SGN-BIKE",
"requests": [
{
"_id": "SGN-BIKE-TIP",
"num": 2
}
],
"images": [],
"promo_code": "KHUYENMAI",
"remarks": "Call me when arrived",
"payment_method": "CASH",
"items": [
{
"_id": "TS",
"num": 2,
"name": "Sua tuoi",
"price": 15000
},
{
"_id": "ST",
"num": 2,
"name": "Sinh to lua mach",
"price": 30000
}
]
}
Path
Representing From path[0]
and multiple Tos path[x], x > 0
Parameter | Type | Required | Description |
---|---|---|---|
address | String | Yes | Address of the location. |
lat | Number | Yes | Latitude of the location (Optional but highly recommended). |
lng | Number | Yes | Longitude of the location (Optional but highly recommended). |
name | String | Yes | Recipient's name. Optional if is path[0] . |
mobile | String | Yes | Recipient's mobile number. Optional if is path[0] . |
tracking_number | String | No | Tracking number for the package (Partner's internal order id, not required but Ahamove highly recommended having this field in path[x] ). |
remarks | String | No | Note to supplier, for multiple delivery points. |
cod | Number | No | COD amount (Cash on delivery) |
require_pod | Boolean | No | If true, supplier will be required proof of delivery before complete the transaction |
building | String | No | Building name for delivery to door |
apt_number | String | No | Apartment, Suite or Floor number for delivery to door |
Note
lat
and lng
is not required but
address
field in parameters needs to have correct information as shown in the
format below
Ex: 117 Hùng Vương, Phường 4, Quận 5, Thành phố Hồ Chí Minh, Việt Nam
or 117 Hùng Vương, Phường 4, Quận 5, Hồ Chí Minh
Some types of Invalid Address :
- 658 võ văn kiệt p1 Quận 5 Hồ Chí Minh
- 58 Nghĩa Thục - Phường 5 - Quận 5 - Hồ Chí Minh - Việt Nam
- 22 Bùi Hữu Nghĩa
- 60/62 chiêu anh các
- 930 vo văn Kiệt p5q5
- Có ji e gởi đia chỉ 835/17c trần hung dao p1 q5 tphcm giúp c nha, Phường 01, Quận 5, Thành phố Hồ Chí Minh
- 54 Bạch Vân (Nhà màu xanh cuối hẻm, gọi số 0908999999), Phường 5, Quận 5, TP Hồ Chí Minh
- 189 Trần Tuấn Khải F.5 Q.5 Ngay ngã 3 Trần Hưng Đạo
- địa chỉ: 53 Huỳnh Mẫn Đạt phường 5 Quận 5 TP.HCM ĐT: 0912123456
- 14/20 .an binh p5q5
- 155 Trần Tuần Khải, p5, q5
- Số 1 bạch Vân phường 5 quận 5 TPHCM
- đc hẻm 93/107/16 đường bạch vân p5 q5
- 112 An Bình P5, Quận 5, HCM
- 1025, Phường 5, Quận 5
Response
JSON response example:
{
"order_id": "USAGND",
"status": "ASSIGNING",
"shared_link": "https://cloudstg.ahamove.com/share-order/USAGND/84909055578",
"order": {
"_id": "USAGND",
"currency": "VND",
"user_main_account": 0,
"user_bonus_account": 0,
"total_pay": 33000,
"distance": 1.02,
"duration": 268,
"distance_fee": 23000,
"request_fee": 10000,
"stop_fee": 0,
"vat_fee": 0,
"discount": 0,
"path": [
{
"address": "Nhà Thờ Đức Bà, Vietnam",
"lat": 10.7797855,
"lng": 106.6990189
},
{
"address": "Chợ Bến Thành, Vietnam",
"lat": 10.7725451,
"lng": 106.6980413
}
],
"from_location": {
"type": "Point",
"coordinates": [106.6990189, 10.7797855]
},
"requests": [
{
"_id": "SGN-BIKE-TIP",
"num": 2
}
],
"items": [],
"total_fee": 33000,
"remarks": "This is note for order",
"app": "Ahamove",
"service_id": "SGN-BIKE",
"city_id": "SGN",
"user_id": "84xxxxxxxxx",
"user_name": "TEST CREATE AN ORDER",
"user_imei": null,
"create_time": 1565577713.2757928,
"order_time": 1565577713.2757928,
"index": 12,
"status": "ASSIGNING",
"partner": "TESTPARTNER",
"polylines": "ukx`A}rfjS~CuDhHnGlBnA|DoEdFcB|BhBxBtDzBmA",
"online_pay": 0,
"notify_package_return": true,
"uniform_user_feedback": 2,
"pending_period": 100,
"stoppoint_price": 0,
"special_request_price": 10000,
"vat": 0,
"distance_price": 23000,
"voucher_discount": 0,
"subtotal_price": 33000,
"total_price": 33000
}
}
Status-Code: 200 OK
Errors
Code | Text | Description |
---|---|---|
400 | INVALID_ADDRESS | Invalid Address |
404 | Not Found | - Token not found (Token has expired. When a new token is created, the old token has expired) - Path not found - Service not found |
406 | Not Acceptable | - Booking time not valid - Address not valid - Request not valid - Distance not valid - Invalid pickup area - Invalid delivery area - Concurrent order not allowed (If partner not in token) - Large COD not allowed for first time user - Post paid not set for partner - Not supported payment method - Not enough credit - User’s phone number associated with - Token has been used for a partner - Child order status not valid (When creating parent order) - Parent order existed for #ABCXYZ (When creating a parent order but child orders already had a parent) - Idle until not valid (When client sent idle_until < current_time) - COD is not valid ( When total COD exceeds the maximum value which was configured in service) - Number of stop points are not valid |
408 | Request timeout | Google Distance API does not return results in 10 seconds. |
409 | Conflict | - New order not allow (Not allow 2 consecutive orders in 1 minute) - Tracking number duplicated (Not allow to create duplicated tracking number within 60s) |
500 | Internal Server Error | We had a problem with our server. Try again later. |
503 | Service Unavailable | We're temporarily offline for maintenance. Please try again later. |