Commit b8a251259bb8bf60f4d7bcbfdd83d030c6647a1f

Authored by 李康
1 parent df0eaeed21
Exists in master

增加登录校验

Showing 1 changed file with 20 additions and 5 deletions Inline Diff

doc/server_document.md
1 1. 充值通知第三方服务端接口(需提供回调地址) 1 1. 充值通知第三方服务端接口(需提供回调地址)
2 ----------------------------- 2 -----------------------------
3 参数列表: 3 参数列表:
4 orderId: parter订单号 4 orderId: parter订单号
5 tradId: 平台订单号 5 tradId: 平台订单号
6 appId: 游戏接入分配appid 6 appId: 游戏接入分配appid
7 userId: 平台用户id 7 userId: 平台用户id
8 product: 购买商品名字(50字符) 8 product: 购买商品名字(50字符)
9 currency: 币种 (目前仅有CNY) 9 currency: 币种 (目前仅有CNY)
10 amount: 充值金额(分) 10 amount: 充值金额(分)
11 channel:支付渠道(对应详情见3) 11 channel:支付渠道(对应详情见4)
12 sig: 签名(算法详见2) 12 sig: 签名(算法详见3)
13 13
14 第三方server端返回值: 14 第三方server端返回值:
15 如果第三方验证成功,则返回字符串"success"即可,否则会通知10次后停止.如重复通知,注意校验平台订单号,如重复忽略. 15 如果第三方验证成功,则返回字符串"success"即可,否则会通知10次后停止.如重复通知,注意校验平台订单号,如重复忽略.
16
17
18 2. 登录验证
19 -----------------------------------
20 url: http://inner-sdk.letsgame.mobi/v1/sdk/login_verify.do
21 参数:
22 userId:uid
23 appKey:第三方渠道的key
24 sessionKey:验证key
25
26 返回值:
27 {
28 "code":100000(100000:成功,100012:用户不存在,-1:失败),
29 "msg":"xxxxxx",
30 "userId":1234
31 }
16 32
17 33 3.签名算法
18 2.签名算法
19 -------------------------------- 34 --------------------------------
20 35
21 注意:签名参数不能写成固定数量,一定要获取全部参数并且除sig参数外,然后按照字母升序排列。 36 注意:签名参数不能写成固定数量,一定要获取全部参数并且除sig参数外,然后按照字母升序排列。
22 ```java 37 ```java
23 38
24 /** 39 /**
25 * 签名算法 40 * 签名算法
26 * @param request 41 * @param request
27 * @return 42 * @return
28 */ 43 */
29 public String sig(HttpServletRequest request, String key){ 44 public String sig(HttpServletRequest request, String key){
30 45
31 Enumeration names = request.getParameterNames(); 46 Enumeration names = request.getParameterNames();
32 SortedSet<String> allParams = Sets.newTreeSet(); 47 SortedSet<String> allParams = Sets.newTreeSet();
33 48
34 while (names.hasMoreElements()) { 49 while (names.hasMoreElements()) {
35 String name = (String) names.nextElement(); 50 String name = (String) names.nextElement();
36 if (name.equals("sig")) { 51 if (name.equals("sig")) {
37 continue; 52 continue;
38 } 53 }
39 54
40 try { 55 try {
41 allParams.add(name + "=" + URLEncoder.encode(request.getParameter(name), "utf-8")); 56 allParams.add(name + "=" + URLEncoder.encode(request.getParameter(name), "utf-8"));
42 } catch (UnsupportedEncodingException e) { 57 } catch (UnsupportedEncodingException e) {
43 e.printStackTrace(); 58 e.printStackTrace();
44 } 59 }
45 } 60 }
46 61
47 String params = Joiner.on("&").join(allParams)+key; 62 String params = Joiner.on("&").join(allParams)+key;
48 String computedToken = DigestUtils.md5DigestAsHex(params.getBytes()); 63 String computedToken = DigestUtils.md5DigestAsHex(params.getBytes());
49 return computedToken; 64 return computedToken;
50 } 65 }
51 ``` 66 ```
52 67
53 68
54 69
55 注意:参数是按字母升序排列 akey=value&bkey=value.... + secretkey(对应渠道的应用ID) 70 注意:参数是按字母升序排列 akey=value&bkey=value.... + secretkey(对应渠道的应用ID)
56 71
57 3.channel详情(部分上线) 72 4.channel详情(部分上线)
58 -------------------------------- 73 --------------------------------
59 74
60 100100:丫丫玩 75 100100:丫丫玩
61 100200:小皮 76 100200:小皮
62 100300:安智 77 100300:安智
63 100400:豌豆荚 78 100400:豌豆荚
64 100500:应用汇 79 100500:应用汇
65 100600:机锋 80 100600:机锋
66 100700:泡椒 81 100700:泡椒
67 100800:木蚂蚁 82 100800:木蚂蚁
68 100900:靠谱助手 83 100900:靠谱助手
69 101000:游戏群(熊猫玩) 84 101000:游戏群(熊猫玩)