# 周期付款
1.点击申请开通商家扣款 (opens new window)
效果浏览

nodejs demo
// 这个在最外面申明公共方法即可
const alipaySdk = new AlipaySdk.AlipaySdk({
appId,
privateKey,
alipayPublicKey,
});
// 结束
//支付宝 周期扣款
async nmxcdsfAction() {
const obj = this.post()
const period = parseInt(obj.qishu)
const {
openid
} = await this.zfbUser.where({
openid: this.openid
}).find()
if (openid) {
// App 支付接口,生成请求字符串,
const orderStr = alipaySdk.sdkExecute('alipay.user.agreement.page.sign', {
bizContent: {
"product_code": "GENERAL_WITHHOLDING", //商家扣款场景固定为 GENERAL_WITHHOLDING
"personal_product_code": "GENERAL_WITHHOLDING_P", //使用商家扣款产品时必传,其它支付产品无需传入
"sign_scene": "INDUSTRY|DEFAULT_SCENE", //签约场景
"sign_validity_period": "2m", //当前用户签约请求的协议有效周期
"external_agreement_no": obj.external_agreement_no, //商户签约号
"access_params": { //接入渠道
"channel": "ALIPAYAPP"
},
"period_rule_params": { //周期管控规则
"period_type": "MONTH", //周期类型枚举值为DAY和MONTH
period, //周期数
"execute_time": this.timeCycleer(new Date().getTime()), //商户发起首次扣款的时间
"single_amount": parseInt(obj.single_amount), //每次发起扣款时限制的最大金额单位为元
"total_amount": period, //周期内允许扣款的总金额,单位为元
},
},
returnUrl: 'https://duxinggj.com'
});
this.success(encodeURIComponent(orderStr))
} else {
this.fail("重新登录")
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
← 支付 windows服务环境搭建 →