JSAPI调起支付分授权页
更新时间:2025.02.25||
商户通过商户预授权接口获取授权的必要参数apply_permissions_token后,可使用微信支付提供的JS调起微信支付分小程序,引导用户授权商户支付分服务(公众号端)
接口说明
字段说明
请求参数
businessType 必填 string(16)
固定值,请传入wxpayScoreEnable。
queryString 必填 string(2048)
使用URL的query string方式传递参数,格式为key=value&key2=value2,其中value,value2需要进行UrlEncode处理。
 | 属性 |
| apply_permissions_token 必填 string(300) 【预授权token】调用商户预授权接口返回的预授权token(1小时内有效)。
scene 选填 string 【授权场景】服务商交易场景授权需填入ORDER。 |
请求示例

1let wechatInfo = navigator.userAgent.match(/MicroMessenger\/([\d\.]+)/i);
2let wechatVersion = wechatInfo[1];
3
4if (compareVersion(wechatVersion, '7.0.5') >= 0) {
5 goToWXScore();
6} else {
7
8 window.href = 'https://support.weixin.qq.com/cgi-bin/readtemplate?t=page/common_page__upgrade&
9 text=text005&btn_text=btn_text_0'
10}
11
12
13
14
15function goToWXScore() {
16 wx.checkJsApi({
17 jsApiList: ['openBusinessView'],
18 success: function (res) {
19
20
21 if (res.checkResult.openBusinessView) {
22 wx.invoke(
23 'openBusinessView', {
24 businessType: 'wxpayScoreEnable',
25 queryString
26:'apply_permissions_token=AAQTnZoAAAABAAAAAAA-82Zwq2wMeohrOrWEZiAAAABcwQVtru-5k9MmEOZJ_Pv_Nq7Cw56dNKKN5EjZKnt5jf2ELJMexxwojyqA5EXan-WSwpRhLgBZYm-e9iZ7nLLhTzJLT4qakuzmTPoY64kYxO-8G7Frx8D3sScFf7QOZt8ZMnyXGF-jHx6TMjlGdWti6K0jqAYp_CyALFJxBrEbOvLlJ_vdllvc33W5XV8'
27 },
28 function (res) {
29
30 if (parseint(res.err_code) === 0) {
31
32 } else {
33
34 }
35 });
36 }
37 }
38 });
39 }
40
41
42
43
44
45
46
47
48function compareVersion(v1, v2) {
49 v1 = v1.split('.')
50 v2 = v2.split('.')
51 const len = Math.max(v1.length, v2.length)
52
53 while (v1.length < len) {
54 v1.push('0')
55 }
56 while (v2.length < len) {
57 v2.push('0')
58 }
59
60 for (let i = 0; i < len; i++) {
61 const num1 = parseint(v1[i])
62 const num2 = parseint(v2[i])
63
64 if (num1 > num2) {
65 return 1
66 } else if (num1 < num2) {
67 return -1
68 }
69 }
70
71 return 0
72 }
返回参数
err_code 必填 Number/string(32)
返回码,由于iOS和Android实现的差异,err_code类型可能为Number或string
err_msg 必填 string(128)
返回信息。
extraData 选填 Object
当err_code为0时,extraData才返回
 | 属性 |
| appid 必填 string(32) 支付分小程序appid,固定值wxd8f3793ea3b935b8。 |