Google Pay

要使用Headless checkout接受Google Pay支付:

  1. 添加show_fields事件处理以显示额外字段。

示例

Copy
Full screen
Small screen
headlessCheckout.form.onNextAction((nextAction) => {
  switch (nextAction.type) {
    case 'show_fields':
      this.handleShowFieldsAction(nextAction);
  }
});
  1. 在支付UI的HTML标记中添加psdk-payment-form组件以显示额外字段。

示例

Copy
Full screen
Small screen
@if (showAdditionalFields) {
  <psdk-payment-form></psdk-payment-form>
  <psdk-submit-button text="Pay" />
}
  1. 添加显示Google Pay支付按钮的事件处理。

示例

Copy
Full screen
Small screen
headlessCheckout.form.onNextAction((nextAction) => {
  switch (nextAction.type) {
    ...
    case 'special_button': {
      if (nextAction.data.buttonName === 'google-pay') {
        showGoogleButton = true;
      }
    }
  }
});
  1. 在支付UI的HTML标记中添加Google Pay按钮组件。

示例

Copy
Full screen
Small screen
@if (showGoogleButton) {
  <psdk-google-pay-button></psdk-google-pay-button>
}
实现示例
请参考GitHub上的详细示例。
本文对您的有帮助吗?
谢谢!
我们还有其他可改进之处吗? 留言
非常抱歉
请说明为何本文没有帮助到您。 留言
感谢您的反馈!
我们会查看您的留言并运用它改进用户体验。
上次更新时间: 2025年3月3日

发现了错别字或其他内容错误? 请选择文本,然后按Ctrl+Enter。

报告问题
我们非常重视内容质量。您的反馈将帮助我们做得更好。
请留下邮箱以便我们后续跟进
感谢您的反馈!