ApplePay 订阅支付集成
Apple Pay 支持订阅支付模式,允许商户为用户设置定期自动扣费服务。
# 集成流程
# Step1 首笔支付
首次订阅支付需要通过跳转收银台模式完成,用于建立订阅关系并获取支付令牌。使用统一下单接口。
关键参数说明:
| 参数名称 | 参数说明 | 是否必填 |
|---|---|---|
merchantUserId | 商户用户唯一标识 | 必填 |
createToken | 是否创建支付令牌,固定值"Y" | 必填 |
bizType | 业务类型,固定值"CodeGrant" | 必填 |
recurringInfo | 订阅信息对象 | 必填 |
recurringInfo 订阅信息参数:
| 参数名称 | 参数说明 | 示例值 |
|---|---|---|
recurringPaymentStartDate | 订阅开始时间 | "2025-06-01 00:00:00" |
recurringPaymentIntervalUnit | 扣费周期单位 | "month" |
recurringPaymentIntervalCount | 扣费周期数量 | "6" |
recurringPaymentEndDate | 订阅结束时间 | "2025-12-01 00:00:00" |
完整请求示例:
{
"acquirerType": "CHECKOUT",
"accId": "2023042011040310224447",
"amount": "200",
"currency": "USD",
"requestId": "PMR-1751341035131",
"merchantTransactionId": "PMT-1751341035131",
"paymentType": "DEBIT",
"payType":"APM",
"bizType": "CodeGrant",
"merchantUserId":"126048960513465",
"createToken":"Y",
"notificationUrl": "https://test-acquirerpay.pingpongx.com/qa/notify",
"shopperResultUrl": "https://test-acquirerpay.pingpongx.com/qa/result.html",
"signType": "MD5",
"sign": "46A676FDEA4F3DD0BC9E34C5CFACED69",
"paymentBrand":"ApplePay",
"customer": {
"firstName": "May",
"lastName": "Rally",
"email": "test@pingpongx.com"
},
"goods": [
{
"name": "商品名称mepsking1",
"description": "商品描述",
"sku": "产品SKU111",
"averageUnitPrice": "1",
"number": "10",
"imgUrl": "https://xiu.mepsking.top/material/1/16606169805015585.png"
}
]
}
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
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
完整响应示例:
{
"accId": "2023042011040310224447",
"clientId": "2023042011040310224",
"code": "001000",
"description": "Successful request",
"innerJsUrl": "https://pay-cdn.pingpongx.com/production-fra/static/pp-checkout/sandbox/pp-checkout.js?token=EU:_4yVcxYyb2iT7VF_gTIZJUrWIrUCkm_tBzCbNBSvTmG6tqrh2JSgesOF_vRyliLU",
"merchantTransactionId": "PMT-1751340150033",
"paymentUrl": "https://sandbox-safepay.pingpongx.com?token=EU:_4yVcxYyb2iT7VF_gTIZJUrWIrUCkm_tBzCbNBSvTmG6tqrh2JSgesOF_vRyliLU",
"sign": "E1B6189D341BC24EBDC571321607732B",
"signType": "MD5",
"token": "EU:_4yVcxYyb2iT7VF_gTIZJUrWIrUCkm_tBzCbNBSvTmG6tqrh2JSgesOF_vRyliLU"
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
订阅支付特殊参数:
| 参数名称 | 参数值 |
|---|---|
bizType | "CodeGrant" |
createToken | "Y" |
merchantUserId | "126048960513465" |
recurringInfo 参数示例:
"recurringInfo": {
"recurringPaymentStartDate": "2025-06-01 00:00:00",
"recurringPaymentIntervalUnit": "month",
"recurringPaymentIntervalCount": "6",
"recurringPaymentEndDate": "2025-12-01 00:00:00"
}
1
2
3
4
5
6
2
3
4
5
6
# Step2 获取支付令牌
首笔支付成功后,系统会通过交易异步通知返回支付令牌(token)。
重要提醒
- 只有首次交易状态为
SUCCESS时才能获取有效的支付令牌 - 请妥善保存令牌,用于后续自动扣费
- 令牌与
merchantUserId绑定,请确保一致性
# Step3 后续自动扣费
使用获取的令牌进行后续自动扣费,调用统一下单接口。
关键参数:
| 参数名称 | 参数说明 | 是否必填 |
|---|---|---|
bizType | 业务类型,固定值"CodeGrant" | 必填 |
merchantUserId | 与首笔支付保持一致 | 必填 |
token | 从首笔支付异步通知中获取 | 必填 |
二次扣款请求示例:
{
"acquirerType": "PAY",
"accId": "2023042011040310224447",
"amount": "200",
"currency": "USD",
"requestId": "PMR-1751341675362",
"merchantTransactionId": "PMT-1751341675362",
"paymentType": "DEBIT",
"payType":"APM",
"bizType": "CodeGrant",
"merchantUserId":"23214214123",
"notificationUrl": "https://test-acquirerpay.pingpongx.com/qa/notify",
"shopperResultUrl": "https://test-acquirerpay.pingpongx.com/qa/result.html",
"signType": "MD5",
"sign": "D7E1352C2EAB141D93BA7C63EE31BE78",
"paymentBrand":"ApplePay",
"tokenDetail": {
"token": "93cf697a33321d201b87b532e044a321"
},
"customer": {
"firstName": "May",
"lastName": "Rally",
"email": "test@pingpongx.com"
},
"goods": [
{
"name": "商品名称mepsking1",
"description": "商品描述",
"sku": "产品SKU111",
"averageUnitPrice": "1",
"number": "10",
"imgUrl": "https://xiu.mepsking.top/material/1/16606169805015585.png"
}
]
}
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
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
二次扣款特殊参数:
| 参数名称 | 参数值 |
|---|---|
bizType | "CodeGrant" |
merchantUserId | "126048960513465" |
token | "81cf697a30731d407b87b680e044a351" |
# 注意事项
- 令牌管理:支付令牌有效期为20年,请关注令牌状态并及时处理失效情况
- 订阅周期:合理设置订阅周期,避免过于频繁的扣费
- 用户体验:建议在订阅前明确告知用户扣费规则和取消方式
- 异常处理:做好扣费失败的处理逻辑,如重试机制、用户通知等
上次更新: 2025/07/01, 15:03:26