JSAPI调起支付分-签约计划
更新时间:2025.02.20||
商户通过调用签约计划接口打开微信支付分小程序,引导用户签约计划(Web端)。
简介
接口兼容
接口参数
businessType 必填 string(16)
【跳转类型】 固定配置:wxpayScorePlan
queryString 必填 string(2048)
【业务参数】 使用URL的query string方式传递参数,格式为key=value&key2=value2,其中value,value2需要进行UrlEncode处理。
 | 属性 |
| package 必填 string(2048)
【预签约token】 用于跳转到微信侧小程序签约数据,跳转到微信侧小程序传入,有效期为2小时;package可以从《创建用户的签约计划API》接口的返回参数中获取。 |
query示例

1package=AARupJoAAAABAAAAAADSh9ra0Xzx
示例

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/
8 common_page__upgrade&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: 'wxpayScorePlan',
23 queryString: 'package=AARupJoAAAABAAAAAADSh9ra0Xzx'
24 },
25 function (res) {
26
27 if (parseint(res.err_code) === 0) {
28
29 } else {
30
31 }
32 });
33 }
34 }
35 });
36 }
37
38
39
40
41
42function compareVersion(v1, v2) {
43 v1 = v1.split('.')
44 v2 = v2.split('.')
45 const len = Math.max(v1.length, v2.length)
46
47 while (v1.length < len) {
48 v1.push('0')
49 }
50 while (v2.length < len) {
51 v2.push('0')
52 }
53
54 for (let i = 0; i < len; i++) {
55 const num1 = parseint(v1[i])
56 const num2 = parseint(v2[i])
57
58 if (num1 > num2) {
59 return 1
60 } else if (num1 < num2) {
61 return -1
62 }
63 }
64
65 return 0
66 }