Google Pay
要使用Headless checkout接受Google Pay支付:
- 添加
show_fields
事件处理以显示额外字段。
示例:
Copy
- typescript
headlessCheckout.form.onNextAction((nextAction) => {
switch (nextAction.type) {
case 'show_fields':
this.handleShowFieldsAction(nextAction);
}
});
- 在支付UI的HTML标记中添加
psdk-payment-form
组件以显示额外字段。
示例:
Copy
- html
@if (showAdditionalFields) {
<psdk-payment-form></psdk-payment-form>
<psdk-submit-button text="Pay" />
}
- 添加显示Google Pay支付按钮的事件处理。
示例:
Copy
- typescript
headlessCheckout.form.onNextAction((nextAction) => {
switch (nextAction.type) {
...
case 'special_button': {
if (nextAction.data.buttonName === 'google-pay') {
showGoogleButton = true;
}
}
}
});
- 在支付UI的HTML标记中添加Google Pay按钮组件。
示例:
Copy
- html
@if (showGoogleButton) {
<psdk-google-pay-button></psdk-google-pay-button>
}
本文对您的有帮助吗?
感谢您的反馈!
我们会查看您的留言并运用它改进用户体验。发现了错别字或其他内容错误? 请选择文本,然后按Ctrl+Enter。