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

如何在Firebase Stripe扩展的订阅结账链接中传递用户stripeId?

解决Stripe购买链接关联现有客户的问题

要让Stripe识别现有客户(而非重复创建新客户),你只需在购买链接的URL后追加customer查询参数,参数值为Firebase Stripe扩展生成的用户stripeId即可。

具体操作步骤:

  1. 获取用户的stripeId:从Firebase的用户数据中读取对应的stripeId——Firebase Stripe扩展通常会将这个ID存储在用户的Firestore文档,或是Firebase Auth的自定义声明(custom claims)中,根据你的扩展配置读取即可。
  2. 修改购买链接:将customer={用户的stripeId}作为查询参数添加到每个购买链接的末尾。

修改后的代码示例:

假设你已经通过前端或后端逻辑拿到了用户的stripeCustomerId,链接可修改为:

<a class="btn btn-primary" href="https://buy.stripe.com/test_5kA8x65CAeF23Cg8ww?customer=stripe_xxxxxx" role="button">BASIC</a>
<a class="btn btn-primary" href="https://buy.stripe.com/test_7sI00A0igbsQ4Gk7st?customer=stripe_xxxxxx" role="button">Premium</a>

注意事项:

  • 确保传递的customer值是Stripe平台中已存在的客户ID(即Firebase扩展生成的stripeId),否则Stripe会返回错误。
  • 仅当用户已登录并成功获取到stripeId时,才添加该参数;未登录用户可引导其先登录,或不传递参数让Stripe创建新客户。
  • 添加参数后,Stripe结账页面会自动填充该客户已有的账单信息,优化购买流程。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 20:51:20