虚拟商品充值API
签名规则可参考文档MD5签名规则。对接过程中出现签名问题可通过签名排查工具进行自排查,其他问题,可参考文档常见问题处理。
输入参数:
参数 | 是否必须 | 参数类型 | 限制长度 | 参数说明 |
---|---|---|---|---|
appKey | yes | string | 255 | 接口appKey,应用的唯一标识 |
orderNum | yes | string | 255 | 兑吧订单号 |
developBizId | yes | string | 255 | 开发者订单号(独立活动该参数值固定为null) |
uid | yes | string | 255 | 用户id |
params | yes | string | 255 | 虚拟商品标识符(用于开发者识别要充值的商品) |
timestamp | yes | long | 20 | 1970-01-01开始的时间戳,毫秒。 |
sign | yes | string | 255 | MD5签名,详见 签名规则 |
description | no | string | 255 | 文案描述(来源活动的名称) |
account | no | string | 255 | 用户兑换虚拟商品时输入的账号,只有在打开虚拟商品账号输入开关时,才会传输此参数。 |
响应参数:
参数 | 是否必须 | 参数类型 | 限制长度 | 参数说明 |
---|---|---|---|---|
status | yes | string | 255 | success成功,fail失败,process处理中 |
credits | yes | long | 255 | credits为0 |
supplierBizId | yes | string | 255 | 订单流水号,开发者返回给兑吧的凭据 |
errorMessage | yes | string | 255 | status=fail时需返回失败原因,成功可不填 |
响应示例:
成功:
{"status":"success","credits":"0", "supplierBizId":"no123456"}
处理中:
{"status":"process",credits:"0" , "supplierBizId":"no123456"}
失败:
{"status":"fail", "errorMessage":"签名签证失败", "supplierBizId":"no123456"}
服务端开发包下载地址
代码示例(Java)
public VirtualParams virtualConsume(HttpServletRequest request) throws Exception{
if(!appKey.equals(request.getParameter("appKey"))){
throw new Exception("appKey不匹配");
}
if(request.getParameter("timestamp")==null){
throw new Exception("请求中没有带时间戳");
}
boolean verify=SignTool.signVerify(appSecret, request);
if(!verify){
throw new Exception("签名验证失败");
}
VirtualParams params=new VirtualParams();
params.setAppKey(appKey);
params.setUid(request.getParameter("uid"));
params.setSupplierBizId(request.getParameter("developBizId"));
params.setTimestamp(new Date(Long.valueOf(request.getParameter("timestamp"))));
params.setDescription(request.getParameter("description"));
params.setOrderNum(request.getParameter("orderNum"));
if(request.getParameter("account")!=null){
params.setAccount(request.getParameter("account"));
}
params.setParams(request.getParameter("params"));
return params;
}
php [开发工具包]
.net [开发工具包]
虚拟商品通知API
接口地址:
http://www.duiba.com.cn/confirm/confirm?
输入参数:
参数 | 是否必须 | 参数类型 | 限制长度 | 参数说明 |
---|---|---|---|---|
appKey | yes | string | 255 | 接口appKey,应用的唯一标识 |
orderNum | yes | string | 255 | 兑吧订单号 |
success | yes | string | 255 | 虚拟商品充值成功(true)/失败(false) |
errorMsg | yes | string | 255 | 本次充值的失败原因,成功可不填 |
credits | yes | long | 255 | credits为0 |
timestamp | yes | long | 20 | 1970-01-01开始的时间戳,毫秒。 |
sign | yes | string | 255 | MD5签名 详见 签名规则 |
响应参数:
兑吧处理回调请求成功时,将返回字符串 ok
,除了 ok
之外,其他返回值意味着处理失败或者未收到通知,需重复通知(建议重试5次,每次间隔10分钟)。
响应示例:
成功:ok
失败:(除ok
以外任何响应)
服务端开发包下载地址
代码示例(Java)
//构建虚拟商品通知的接口
CreditTool tool = new CreditTool(appKey,appSecret);
Map<String, String> params=new HashMap<String, String>();
String timestamp=String.valueOf(new Date().getTime());
params.put("timestamp",timestamp);
params.put("orderNum","orderNum");
params.put("success","true");
params.put("uid","uid");
params.put("credits",0);
params.put("errorMsg","");
url=tool.buildUrlWithSign("http://www.duiba.com.cn/confirm/confirm?",params);
php [点击打开]
.net [点击打开]