Google Pay
如何设置
要使用Headless checkout接受Google Pay支付:
- 添加
show_fields事件处理以显示额外字段。
Copy
- typescript
1headlessCheckout.form.onNextAction((nextAction) => {
2 switch (nextAction.type) {
3 case 'show_fields':
4 this.handleShowFieldsAction(nextAction);
5 }
6});
- 在支付UI的HTML标记中添加
psdk-payment-form组件以显示额外字段。
Copy
- html
1<psdk-payment-form></psdk-payment-form>
2<psdk-submit-button text="Pay" />
- 添加显示Google Pay支付按钮的事件处理。
Copy
- typescript
1headlessCheckout.form.onNextAction((nextAction) => {
2 switch (nextAction.type) {
3 ...
4 case 'special_button': {
5 if (nextAction.data.buttonName === 'google-pay') {
6 showGoogleButton = true;
7 }
8 }
9 }
10});
- 在支付UI的HTML标记中添加Google Pay按钮组件。
Copy
- html
1@if (showGoogleButton) {
2 <psdk-google-pay-button></psdk-google-pay-button>
3}
一键支付
一键支付允许用户在支持的设备上使用Google Pay,从而提供熟悉且安全的原生支付方式。要配置一键支付,请按以下方式更新SDK初始化脚本:
Copy
- typescript
1const config: InitialOptions = {
2 isWebview: false,
3 theme: 'default',
4 language: parameters.language,
5 isGooglePayInstantFlowEnabled: true
6};
7
8await headlessCheckout.init(config);
本文对您的有帮助吗?
感谢您的反馈!
我们会查看您的留言并运用它改进用户体验。发现了错别字或其他内容错误? 请选择文本,然后按Ctrl+Enter。