firebase - Firebase Stripe Extension - adding custom claims to user
问题描述
I'm integrating Stripe with firebase and firestore using the Run Subscription Payments with Stripe extension. When a user subscribes to the service I need to be able to decode the JWT and see if they are subscribed or not through a custom claim.
The logs on the function show that it is invalidating the custom claim. I'm unsure why this is happening.
解决方案
从您提供的日志来看,您似乎有多个订阅(sub_KBpVfFzNclrhaG 和 sub_KBpV10rxE6jkkH),它们都绑定到同一个用户/客户。订阅 sub_KBpVfFzNclrhaG 的状态为活动或试用,因此自定义声明已正确添加。但是,订阅 sub_KBpV10rxE6jkkH 是在不久之后创建的(我假设状态为非活动或试用),它再次将用户的自定义声明更新为 null。您可以通过检查仪表板中两个订阅的状态来确认这是否正在发生。
您需要确保每个客户只有一个活动/试用订阅,这将是您在应用程序逻辑中检查的内容。这里有一个如何检查客户的活动/试用订阅的示例(https://github.com/stripe-samples/firebase-subscription-payments/blob/4cf116c163ba69f0f46bcc782e4162e0edf452a4/public/javascript/app.js#L121)
推荐阅读
- angular - Angular Authentification Guard Cookie Heroku
- c# - Rebus - 如何注册处理程序的实例
- java - 从具有主复合键的关联表中删除
- python - Mypy:属性设置器的分配类型不兼容
- php - 获取 favicon.ico 时出现 504 网关超时错误
- javascript - Highcharts arearange draggableHigh 和 draggableLow 不起作用
- javascript - 防止向触发 ajax 调用的按钮发送垃圾邮件
- c# - 测试 - .net core 3
- regex - 正则表达式不允许单词之间有空格
- scala - Elastic4s ngram 映射