Apple Pay
接入准备
- 请向
Onerway
提供测试环境域名进行Apple Pay
域名报备,否则会无法完成付款 - 测试
Apple Pay
支付之前,请商户先创建一个测试账户,注意账户地区不要选择中国大陆 - 创建好测试账户后,请在
Apple
测试设备绑定非大陆测试卡 - 请使用
Apple
钱包进行绑卡,如果绑卡时只有国内银行,请修改测试设备设置中的国家与地区为非大陆国家,如美国
详情请参考 Apple Pay 测试指南
重要
Apple Pay 支持订阅和标准信用卡支付
Apple Pay 配置
Apple Pay 需要更新options
中的 mode
字段为ApplePay
,config字段请参考下方config字段说明
js
const options = {
// ...
locale: 'zh', // 支持语言,详见下方 locale 字段说明
mode: 'ApplePay',
config: {
// Apple Pay config字段,详见下方 config 字段说明
}
// ...
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
创建 config
js
const config = {
applePayButtonType: '', // 'add-money' | 'book' | 'buy' | 'check-out' | 'continue' | 'contribute' | 'donate' | 'order' | 'plain' | 'reload' | 'rent' | 'subscribe' | 'support' | 'tip' | 'top-up' | 'pay'
applePayButtonColor: '', // 'black' | 'white' | 'white-outline'
buttonWidth: '', // 按钮宽度
buttonHeight: '', // 按钮高度
buttonRadius: '', // 按钮圆角边框
}
1
2
3
4
5
6
7
2
3
4
5
6
7
Apple Pay config字段说明
属性 | 类型 | 必填 | 说明 |
---|---|---|---|
applePayButtonType | string | No | Apple Pay 按钮类型add-money 、book 、buy 、check-out 、continue 、contribute 、donate 、order 、plain 、reload 、rent 、subscribe 、support 、tip 、top-up 、pay |
applePayButtonColor | string | No | Apple Pay 按钮主题,支持black 、white 、white-outline |
buttonWidth | string | No | 按钮宽度 例: 200px |
buttonHeight | string | No | 按钮高度 例: 40px |
buttonRadius | string | No | 按钮圆角边框 例: 4px |
Apple Pay Locale
语言 | 描述 | 是否支持Apple Pay |
---|---|---|
ar | 阿拉伯语 | 是 |
ca | 加泰罗尼亚语 | 是 |
cs | 捷克语 | 是 |
da | 丹麦语 | 是 |
de | 德语 | 是 |
el | 希腊语 | 是 |
en | 英语 | 是 |
es | 西班牙语 | 是 |
fi | 芬兰语 | 是 |
fr | 法语 | 是 |
hr | 克罗地亚语 | 是 |
id | 印度尼西亚语 | 是 |
it | 意大利语 | 是 |
ja | 日语 | 是 |
ko | 韩语 | 是 |
ms | 马来语 | 是 |
no | 挪威语 | 是 |
nl | 荷兰语 | 是 |
pl | 波兰语 | 是 |
pt | 葡萄牙语 | 是 |
ru | 俄语 | 是 |
sk | 斯洛伐克语 | 是 |
sv | 瑞典语 | 是 |
th | 泰语 | 是 |
tr | 土耳其语 | 是 |
uk | 乌克兰语 | 是 |
zh | 简体中文 | 是 |
vi | 越南语 | 是 |
he | 希伯来语 | 是 |
hi | 印地语 | 是 |
hu | 匈牙利语 | 是 |
ro | 罗马尼亚语 | 是 |
zh-TW | 繁体中文 | 是 |
bg | 保加利亚语 | 否 |
et | 爱沙尼亚语 | 否 |
sr | 塞尔维亚语 | 否 |
sl | 斯洛文尼亚语 | 否 |
SDK Apple Pay代码示例
js
const transactionId = '下单接口返回的 transactionId'; //当前交易ID
const redirectUrl = '下单接口返回的 redirectUrl';
const options = {
container: 'pacypay_checkout', // 按钮嵌入的容器
locale: "zh", // 支持语言
environment: 'sandbox', // sandbox、production
mode: 'ApplePay', // GooglePay、ApplePay
redirectUrl: redirectUrl, // 此字段由服务端下单接口返回,用于客户端唤起SDK。
config: {
applePayButtonType: 'buy', // 'add-money' | 'book' | 'buy' | 'check-out' | 'continue' | 'contribute' | 'donate' | 'order' | 'plain' | 'reload' | 'rent' | 'subscribe' | 'support' | 'tip' | 'top-up' | 'pay'
applePayButtonColor: 'black', // 'black' | 'white' | 'white-outline'
buttonWidth: '100px', // 按钮宽度
buttonHeight: '40px', // 按钮高度
buttonRadius: '4px', // 按钮圆角边框
},
onPaymentCompleted: function (res) { // 成功支付后回调方法
const txtInfo = res.data; // 返回交易结果详情
const respCode = res.respCode; // 响应码
const respMsg = res.respMsg; // 响应信息
if(respCode === '20000') { // respCode 为 20000 表示交易正常
switch (txtInfo.status) { // 交易状态判断
case 'S': // status 为 'S' 表示成功
// 支付最终状态以异步通知结果为准
break
case 'F': // status 为 'F' 表示失败
break;
}
} else {
// 交易失败
}
},
onError: function (err) {
//支付异常回调方法
console.log('res', err);
}
}
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
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