Webhook & Luồng callback
Phương pháp Authentication
Ahamove hỗ trợ 3 loại authorization header (API-KEY
, BEARER-TOKEN
, BASIC-AUTH
)
API Key
Đối tác đặt API key vào Authorization header
Header: { apikey: "auth_token" }
Ex: { "apikey": "KJhb4seu82dHe3hkDgyU7mQoh5AB1o" }
Bearer Token
Đối tác gửi token vào Authorization header khi tạo requests
Header: { Authorization: "Bearer + auth_token" }
Ex: { "Authorization": "Bearer KJhb4seu82dHe3hkDgyU7mQoh5AB1o"}
Basic Auth
Với phương thức này, Đối tác để một username: password vài trong request header. Username and password được encoded với Base64
Header: { Authorization: "Basic {b64.StdEncoding.EncodeToString([]byte({username}:{password})}" }
Ex: { "Authorization": "Basic KJhb4seu82dHe3hkDgyU7mQoh5AB1o"}
Luồng Callback
Mẫu Callback
{
"_id": "22VMV54W",
"accept_time": 0,
"board_time": 0,
"cancel_by_user": false,
"cancel_comment": "",
"cancel_image_url": "",
"cancel_time": 0,
"city_id": "SGN",
"complete_time": 0,
"create_time": 1665742305.9305305,
"currency": "VND",
"order_time": 1665742305.9305305,
"partner": "",
"path": [
{
"address": "725 Hẻm số 7 Thành Thái, Phường 14, Quận 10, Hồ Chí Minh, Việt Nam",
"cod": 0,
"por_info": "",
"short_address": "Quận 10",
"formatted_address": "",
"mobile": "09xxxxxxxx",
"status": "",
"complete_lat": 0,
"complete_lng": 0,
"fail_lat": 0,
"fail_lng": 0,
"complete_time": 0,
"fail_time": 0,
"return_time": 0,
"pod_info": "",
"fail_comment": "",
"name": "Anh",
"remarks": "call me"
},
{
"address": "Chợ Bến Thành, Bến Thành, Quận 01, Hồ Chí Minh, Việt Nam",
"cod": 0,
"por_info": "",
"short_address": null,
"formatted_address": "",
"mobile": "09xxxxxxxx",
"status": "",
"complete_lat": 0,
"complete_lng": 0,
"fail_lat": 0,
"fail_lng": 0,
"complete_time": 0,
"fail_time": 0,
"return_time": 0,
"pod_info": "",
"fail_comment": "",
"name": "Bao"
}
],
"payment_method": "CASH",
"pickup_time": 0,
"service_id": "SGN-BIKE",
"status": "ASSIGNING",
"sub_status": "",
"supplier_id": "",
"supplier_name": "",
"surcharge": 1.1,
"user_id": "",
"user_name": "",
"total_pay": 33000,
"promo_code": "",
"stoppoint_price": 0,
"special_request_price": 1000,
"vat": 0,
"distance_price": 32000,
"voucher_discount": 0,
"subtotal_price": 33000,
"total_price": 33000,
"surge_rate": 1.1,
"api_key": "<API_KEY_STG>",
"shared_link": "https://cloudstg.ahamove.com/share-order/22VMV54W/84911434061",
"insurance_portal_url": "https://claim-dev.globalcare.vn/claim/ahamove/intransit?platform=app&code=22VMV54W&phone=84xxxxxxxxx",
"app": "Ahamove",
"store_id": 0,
"distance": 4.68
}
Đối tác cần cung cấp một webhook URL để nhận các cập nhật trạng thái từ Ahamove. Ahamove sẽ gọi API này mỗi lần trạng thái đơn hàng thay đổi. Ví dụ, Ahamove gọi POST url bên dưới khi một tài xế hoàn thành đơn hàng
https://example.com/partner/update_ahamove_status
Cách để test Webhook
- Thiết lập webhook url để nhận thông tin order_id & status, sau đó gửi URL để Ahamove cài đặt vào hệ thống
- Sử dụng link download để cài đặt Ahamove Driver staging app trên thiết bị có hệ điều hành Android
- Đăng ký tài khoản, đăng nhập và bật trực tuyến
- Sử dụng order/create API để tạo đơn hàng trong vòng bán kính 1km kể từ địa chỉ của tài xế
- App của tài xế sẽ nhận một thông báo, nhấn vào thông báo để chấp nhận đơn hàng
- Hệ thống Ahamove sẽ bắn trạng thái ACCEPTED đến webhook URL
- Thử hoàn thành đơn hàng trên app tài xế, hệ thống Ahamove sẽ bắn những trạng thái tương ứng đến webhook URL