【发布时间】:2018-09-11 22:07:11
【问题描述】:
我正在尝试将 Stripe 与 Firebase 一起使用,并遵循链接的 Firestripe example project。当用户注册应用程序时,会在 Firebase 中触发以下函数,该函数会在 Stripe 中创建一个 Customer 对象。
exports.createStripeCustomer = functions.auth.user().onCreate(event => {
const data = event.data;
return stripe.customers.create({
}).then(customer => {
return admin.database().ref(`/stripe_customers/${data.uid}/customer_id`).set(customer.id);
});
});
上述函数的最后一行应该将 Stripe 客户 ID 作为 Firebase UID 的子项写入数据库中,它成功完成了。
现在在客户端 (iOS - Swift) 上,当尝试通过使用以下方式获取其 UID 来写入同一经过身份验证的用户时:
let userID = Auth.auth().currentUser!.uid
Database.database().reference(fromURL: "https://REDACTED.firebaseio.com/").child("stripe_customers").child(uid).child("sources").setValue([
"token": token.tokenId,
])
它在/stripe_customers/ 下创建了一个完全不同的孩子,这意味着 UID 不匹配......
如何继续从客户端获取用户的真实 UID?还是我做错了什么?任何帮助或见解将不胜感激。
【问题讨论】:
标签: ios swift firebase firebase-realtime-database stripe-payments