codecamp

支付签名生成算法

以查询游戏币余额的接口为例


原始请求信息

  1. 支付秘钥 key: da8d182e1cashjkulkof6ae22a4a918457
  2. HTTP 请求方式: POST
  3. 请求的 URI: /api/apps/game/wallet/get_balance


签名算法

  1. 参与签名请求参数
    {
      "openid": "fge35vh5h3f2",
      "appid": "tthdch45hd2df",
      "zone_id": "1",
      "access_token": "hds2rt6bhgh5wfg5nf4gdh6",
      "ts": 1507530737,
      "pf": "android"
    }
  2. 对参与签名的参数按照key=value的格式,并按照参数名 ASCII 字典序升序排序如下:
    stringA="access_token=hds2rt6bhgh5wfg5nf4gdh6&appid=tthdch45hd2df&openid=fge35vh5h3f2&pf=android&ts=1507530737&zone_id=1"
  3. 拼接uri、method:
    stringB=stringA+"&org_loc=/api/apps/game/wallet/get_balance&method=POST"
  4. 把支付秘钥作为 key,使用 HMAC-SHA256 得到签名sig=hmac_sha256(key,stringB)。
    sig=hmac_sha256(key,stringB)
       ="4317496a530d0593fa4365ca87714a12c9e6edd4df1fea5fe1f5e5d6a1781a78"
游戏币赠送接口
tt.createWorker
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

无标题目录

无标题文章

无标题文章

无标题文章

无标题文章

无标题文章

无标题文章

无标题文章

无标题文章

无标题文章

无标题文章

无标题文章

无标题文章

无标题文章

无标题文章

无标题目录

无标题文章

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }