JSAPI调起支付分授权页
更新时间:2024.10.09||
商户通过商户预授权接口获取授权的必要参数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];
3if (compareVersion(wechatVersion, '7.0.5') >= 0) {
4 goToWXScore();
5} else {
6
7 window.href = 'https://support.weixin.qq.com/cgi-bin/readtemplate?t=page/common_page__upgrade&
8 text=text005&btn_text=btn_text_0'
9}
10
11
12
13function goToWXScore() {
14 wx.checkJsApi({
15 jsApiList: ['openBusinessView'],
16 success: function (res) {
17
18
19 if (res.checkResult.openBusinessView) {
20 wx.invoke(
21 'openBusinessView', {
22 businessType: 'wxpayScoreEnable',
23 queryString
24:'apply_permissions_token=AAQTnZoAAAABAAAAAAA-82Zwq2wMeohrOrWEZiAAAABcwQVtru-5k9MmEOZJ_Pv_Nq7Cw56dNKKN5EjZKnt5jf2ELJMexxwojyqA5EXan-WSwpRhLgBZYm-e9iZ7nLLhTzJLT4qakuzmTPoY64kYxO-8G7Frx8D3sScFf7QOZt8ZMnyXGF-jHx6TMjlGdWti6K0jqAYp_CyALFJxBrEbOvLlJ_vdllvc33W5XV8'
25 },
26 function (res) {
27
28 if (parseint(res.err_code) === 0) {
29
30 } else {
31
32 }
33 });
34 }
35 }
36 });
37 }
38
39
40
41
42
43
44
45function compareVersion(v1, v2) {
46 v1 = v1.split('.')
47 v2 = v2.split('.')
48 const len = Math.max(v1.length, v2.length)
49
50 while (v1.length < len) {
51 v1.push('0')
52 }
53 while (v2.length < len) {
54 v2.push('0')
55 }
56
57 for (let i = 0; i < len; i++) {
58 const num1 = parseint(v1[i])
59 const num2 = parseint(v2[i])
60
61 if (num1 > num2) {
62 return 1
63 } else if (num1 < num2) {
64 return -1
65 }
66 }
67
68 return 0
69 }返回参数
返回对象: WXOpenBusinessView.Resp
businessType 必填 string(16)
在授权场景下返回类型为:wxpayScoreEnable。
extMsg 必填 string
支付分返回的业务数据,json格式。
 | 属性 |
| appid 必填 string(32)
支付分小程序appid,固定值wxd8f3793ea3b935b8。 |