You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Stripe PaymentElement通过Google Pay获取用户邮箱与手机号可行吗?

使用Stripe PaymentElement从Google Pay获取邮箱和手机号的方法

可以实现,不过PaymentElement不像ExpressCheckoutElement或旧版PaymentRequestButtonElement那样直接提供emailRequired/phoneNumberRequired配置项,而是通过配置Payment Intent(或Setup Intent)的参数来触发Google Pay请求用户的邮箱和手机号。

具体操作:

  • 获取邮箱:创建Payment Intent时,不要预先设置customer_email字段。当用户选择Google Pay支付时,Stripe会自动请求Google Pay获取用户的关联邮箱,支付完成后该邮箱会存入Payment Intent的payment_method.billing_details.email字段。
  • 获取手机号:创建Payment Intent时,在payment_method_options.card.billing_details.phone中指定'required',强制要求收集手机号。Google Pay会在支付流程中提示用户提供该信息,最终手机号会存放在Payment Intent的payment_method.billing_details.phone字段里。

代码示例(Node.js):

const stripe = require('stripe')('your_stripe_secret_key');

const createPaymentIntent = async () => {
  const paymentIntent = await stripe.paymentIntents.create({
    amount: 1000, // 金额单位为分
    currency: 'usd',
    payment_method_types: ['card'],
    // 不设置customer_email,触发Google Pay请求邮箱
    payment_method_options: {
      card: {
        billing_details: {
          phone: 'required' // 强制收集手机号
        }
      }
    }
  });
  return paymentIntent.client_secret;
};

补充说明:

  • 如果是仅设置支付方式而非直接支付,使用Setup Intent时配置逻辑完全一致,只需将paymentIntents.create替换为setupIntents.create。
  • 部分地区的Google Pay服务可能对收集手机号有限制,需确保业务覆盖区域支持该功能。
  • 支付完成后,可通过Webhook或直接查询Payment Intent的方式获取用户的邮箱和手机号。

内容的提问来源于stack exchange,提问作者Taras

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 12:25:08