状态回调
功能: 行程状态发生改变时,通知第三方。第三方需提供一个固定的接收webhook通知的地址,稳定性99.5%,不保证实时通知,但最大延迟不超过5分钟
注: 数据主体与详情接口一致,同时需要验证header签名
HEADER:
[
"Authorization: oLi7zlNlVlx43lHOUp9bm6TcBdA=",
"Content-Type: application/json"
]
签名函数(php版本,其他语言版本准备中):
/**
* @Param $mParams 需要加密的参数(所有请求参数)
* @Param $sSignKey 签名key(每个接入方独立的签名key,测试环境签名key为DIDI_OPENAPI_WEBHOOK_SECRET)
*/
function createCallbackHMacSign( $mParams, $sSignKey )
{
if ( is_array( $mParams ) ) { //判断请求数据,如果是数组,直接编码为json格式(中文转成UTF8)
$sSignStr = json_encode( $mParams );
} else {
$sSignStr = $mParams;
}
//使用hmac-sha1签名算法,签名结果base64编码,防止出现乱码
$sign = base64_encode( hash_hmac( 'sha1', $sSignStr, $sSignKey, TRUE ) );
return $sign;
}
注: 中文会转换成 Unicode 编码
示例:
$mParams : 数组
{
"event_id": "350cf97888622f8ccbfc10af866d00c2_2016-09-01T11:57:14+0800",
"event_type": "ride.status.updated",
"occurred_at": "2016-09-01T11:57:14+0800",
"event": {
"didi_oid": "didi32A1396E7247D3808C9F1FBD0CFACB66596420A303938F8A7891822FEB2752A6",
"request_time": "2016-08-30T20:01:56+0800",
"product_type": "private-car",
"ride_type": "compact",
"status": "PassengerCancelled",
"passenger_phone": "11000030000",
"origin": {
"name": "上地十街|尚东数字山谷",
"lat": "39.988169",
"lng": "116.340709"
},
"destination": {
"name": "成府路|五道口购物中心",
"lat": "40.042655",
"lng": "116.290943"
},
"process": [
{
"status": "Pending",
"time": "2016-08-30T20:01:56+0800",
"lat": "39.988169",
"lng": "116.340709"
},
{
"status": "PassengerCancelled",
"time": "2016-08-30T20:04:08+0800",
"lat": "0.000000",
"lng": "0.000000"
}
],
"pay_type":0,//pay_type 类型类型见请求行程
"oid": "",
"remark": ""
},
"pay_status": {
"is_pay": 1,
"permit": 0,
"type": 0
}
}
$sSignStr :
{"event_id":"350cf97888622f8ccbfc10af866d00c2_2016-09-01T11:57:14+0800","event_type":"ride.status.updated","occurred_at":"2016-09-01T11:57:14+0800","event":{"didi_oid":"didi32A1396E7247D3808C9F1FBD0CFACB66596420A303938F8A7891822FEB2752A6","request_time":"2016-08-30T20:01:56+0800","product_type":"private-car","ride_type":"compact","status":"PassengerCancelled","passenger_phone":"11000030000","origin":{"name":"\u4e0a\u5730\u5341\u8857|\u5c1a\u4e1c\u6570\u5b57\u5c71\u8c37","lat":"39.988169","lng":"116.340709"},"destination":{"name":"\u6210\u5e9c\u8def|\u4e94\u9053\u53e3\u8d2d\u7269\u4e2d\u5fc3","lat":"40.042655","lng":"116.290943"},"process":[{"status":"Pending","time":"2016-08-30T20:01:56+0800","lat":"39.988169","lng":"116.340709"},{"status":"PassengerCancelled","time":"2016-08-30T20:04:08+0800","lat":"0.000000","lng":"0.000000"}],"oid":"","remark":""}}
$sSignKey : DIDI_OPENAPI_WEBHOOK_SECRET
$sign : GgPJWiGw3gHK6ShVKCNJhPfcIZ0=
回调数据说明:
- 司机接单
{
"event_id": "537e885b3d0ede6d498d42b8cf2e0f1c_2016-07-02T01:58:45+0800", //唯一id,可以用来识别消息是否已处理
"event_type": "ride.status.updated", //通知时间类型
"occurred_at": "2016-07-02T01:58:45+0800", //事件发生时间
"event": { //通知内容数据主体
"oid": "123123123",
"didi_oid": "didi109FBF3FC10E9CAC9612365759560F50D7653CBED254FFE3C85527CF2BE2461A", //行程id
"request_time": "2016-07-02T00:28:11+0800", //行程请求时间
"product_type": "private-car", //行程请求的产品类型
"ride_type": "compact", //行程请求的运力类型
"status": "Accepted", //当前状态
"passenger_phone": "13900000000", //乘客手机
"origin": { //乘客约定的出发地
"name": "上地十街|西二旗地铁站",
"lat": "40.058922",
"lng": "116.312615"
},
"destination": { //乘客约定的目的地
"name": "成府路|五道口购物中心",
"lat": "39.998568",
"lng": "116.344434"
},
"driver": { //司机信息
"phone_number": "05298545DE3D4BB065B780783537|1", //司机电话,已加密,需解密处理
"name": "车师傅"
},
"vehicle": { //车辆信息
"car_type": "奥迪A4L",
"license_plate": "京**1234",
"picture_url": ""
},
"process": [ //各状态及发生的时间,出租车无本字段
{
"status": "Pending",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Accepted",
"time": "2016-07-02T00:28:11+0800"
}
]
},
"pay_status": {
"is_pay": 0,
"permit": 0,
"type": 0
}
}
- 司机到达
{
"event_id": "537e885b3d0ede6d498d42b8cf2e0f1c_2016-07-02T01:58:45+0800",
"event_type": "ride.status.updated",
"occurred_at": "2016-07-02T01:58:45+0800",
"event": {
"oid": "123123123",
"didi_oid": "didi109FBF3FC10E9CAC9612365759560F50D7653CBED254FFE3C85527CF2BE2461A",
"request_time": "2016-07-02T00:28:11+0800",
"product_type": "private-car",
"ride_type": "compact",
"status": "Arrived",
"passenger_phone": "13900000000",
"origin": {
"name": "上地十街|西二旗地铁站",
"lat": "40.058922",
"lng": "116.312615"
},
"destination": {
"name": "成府路|五道口购物中心",
"lat": "39.998568",
"lng": "116.344434"
},
"driver": {
"phone_number": "05298545DE3D4BB065B780783537|1",
"name": "车师傅"
},
"vehicle": {
"car_type": "奥迪A4L",
"license_plate": "京**1234",
"picture_url": ""
},
"process": [
{
"status": "Pending",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Accepted",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Arrived",
"time": "2016-07-02T00:28:11+0800"
}
]
},
"pay_status": {
"is_pay": 0,
"permit": 0,
"type": 0
}
}
- 司机开始计费
{
"event_id": "537e885b3d0ede6d498d42b8cf2e0f1c_2016-07-02T01:58:45+0800",
"event_type": "ride.status.updated",
"occurred_at": "2016-07-02T01:58:45+0800",
"event": {
"oid": "123123123",
"didi_oid": "didi109FBF3FC10E9CAC9612365759560F50D7653CBED254FFE3C85527CF2BE2461A",
"request_time": "2016-07-02T00:28:11+0800",
"product_type": "private-car",
"ride_type": "compact",
"status": "Charging",
"passenger_phone": "13900000000",
"origin": {
"name": "上地十街|西二旗地铁站",
"lat": "40.058922",
"lng": "116.312615"
},
"destination": {
"name": "成府路|五道口购物中心",
"lat": "39.998568",
"lng": "116.344434"
},
"driver": {
"phone_number": "05298545DE3D4BB065B780783537|1",
"name": "车师傅"
},
"vehicle": {
"car_type": "奥迪A4L",
"license_plate": "京**1234",
"picture_url": ""
},
"process": [
{
"status": "Pending",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Accepted",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Arrived",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Charging",
"time": "2016-07-02T00:28:11+0800"
}
]
},
"pay_status": {
"is_pay": 0,
"permit": 0,
"type": 0
}
}
- 到达目的地
{
"event_id": "537e885b3d0ede6d498d42b8cf2e0f1c_2016-07-02T01:58:45+0800",
"event_type": "ride.status.updated",
"occurred_at": "2016-07-02T01:58:45+0800",
"event": {
"oid": "123123123",
"didi_oid": "didi109FBF3FC10E9CAC9612365759560F50D7653CBED254FFE3C85527CF2BE2461A",
"request_time": "2016-07-02T00:28:11+0800",
"product_type": "private-car",
"ride_type": "compact",
"status": "Finished",
"passenger_phone": "13900000000",
"origin": {
"name": "上地十街|西二旗地铁站",
"lat": "40.058922",
"lng": "116.312615"
},
"destination": {
"name": "成府路|五道口购物中心",
"lat": "39.998568",
"lng": "116.344434"
},
"driver": {
"phone_number": "05298545DE3D4BB065B780783537|1",
"name": "车师傅"
},
"vehicle": {
"car_type": "奥迪A4L",
"license_plate": "京**1234",
"picture_url": ""
},
"process": [
{
"status": "Pending",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Accepted",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Arrived",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Charging",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Finished",
"time": "2016-07-02T00:28:11+0800"
}
],
"price": {
"currency": "CNY",
"amount": 1120,
"type": "totalFee",
"description": "total fee"
},
"charges": [
{
"currency": "CNY",
"amount": 1000,
"type": "startPrice",
"description": "starting price"
},
{
"currency": "CNY",
"amount": 100,
"type": "highwayFee",
"description": "highway tolls"
},
{
"currency": "CNY",
"amount": 20,
"type": "timeFee",
"description": "time fee"
}
]
},
"pay_status": {
"is_pay": 0,
"permit": 0,
"type": 0
}
}
- 司机取消(会自动重新发单,订单id不变):
{
"event_id": "537e885b3d0ede6d498d42b8cf2e0f1c_2016-07-02T01:58:45+0800",
"event_type": "ride.status.updated",
"occurred_at": "2016-07-02T01:58:45+0800",
"event": {
"oid": "123123123",
"didi_oid": "didi109FBF3FC10E9CAC9612365759560F50D7653CBED254FFE3C85527CF2BE2461A",
"request_time": "2016-07-02T00:28:11+0800",
"product_type": "private-car",
"ride_type": "compact",
"status": "DriverCancelled",
"passenger_phone": "13900000000",
"origin": {
"name": "上地十街|西二旗地铁站",
"lat": "40.058922",
"lng": "116.312615"
},
"destination": {
"name": "成府路|五道口购物中心",
"lat": "39.998568",
"lng": "116.344434"
},
"driver": {
"phone_number": "05298545DE3D4BB065B780783537|1",
"name": "车师傅"
},
"vehicle": {
"car_type": "奥迪A4L",
"license_plate": "京**1234",
"picture_url": ""
},
"process": [
{
"status": "Pending",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Accepted",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Arrived",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "DriverCancelled",
"time": "2016-07-02T00:28:11+0800"
}
],
"price": {
"currency": "CNY",
"amount": 500,
"type": "totalFee",
"description": "total fee"
},
"charges": [
{
"currency": "CNY",
"amount": 500,
"type": "waitFee",
"description": "waiting fee"
}
]
},
"pay_status": {
"is_pay": 0,
"permit": 0,
"type": 0
}
}
- 滴滴客服关单(订单在司机接单后,订单支付前都能被客服关单,关单之后不重新派单,关单可能需要支付费用)
{
"event_id": "537e885b3d0ede6d498d42b8cf2e0f1c_2016-07-02T01:58:45+0800",
"event_type": "ride.status.updated",
"occurred_at": "2016-07-02T01:58:45+0800",
"event": {
"oid": "123123123",
"didi_oid": "didi109FBF3FC10E9CAC9612365759560F50D7653CBED254FFE3C85527CF2BE2461A",
"request_time": "2016-07-02T00:28:11+0800",
"product_type": "private-car",
"ride_type": "compact",
"status": "ServiceCancelled",
"passenger_phone": "13900000000",
"origin": {
"name": "上地十街|西二旗地铁站",
"lat": "40.058922",
"lng": "116.312615"
},
"destination": {
"name": "成府路|五道口购物中心",
"lat": "39.998568",
"lng": "116.344434"
},
"process": [
{
"status": "Pending",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Accepted",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "Arrived",
"time": "2016-07-02T00:28:11+0800"
},
{
"status": "ServiceCancelled",
"time": "2016-07-02T00:28:11+0800"
}
],
"price": {
"currency": "CNY",
"amount": 500,
"type": "totalFee",
"description": "total fee"
},
"charges": [
{
"currency": "CNY",
"amount": 500,
"type": "waitFee",
"description": "waiting fee"
}
]
},
"pay_status": {
"is_pay": 0,
"permit": 0,
"type": 0
}
}