gpt4 book ai didi

iOS Firebase Stripe Integration with/Cloud Functions,相当于 iOS 中的 push() 和 push Id

转载 作者:搜寻专家 更新时间:2023-11-01 07:03:36 29 4
gpt4 key购买 nike

我正在使用 Firebase 云函数来处理我的 Stripe 支付。我有一些设置正确。当用户进行身份验证时,它会自动创建一个 strip 用户。效果很好。

Firebase 在“添加付款来源”下提供的示例中显示

exports.addPaymentSource = functions.database.ref('/stripe_customers/{userId}/sources/{pushId}/token').onWrite((event) =>

它应该获取 stripe 提供的支付 token 并写入实时数据库,并使用该 token 为用户更新 stripe。

然而,'pushID' 代表什么是非常不清楚的。我已经创建了很多尝试,比如这个

let payment: NSMutableDictionary = ["sources":"stripeCustomerID" ]
self.root.child("stripe_customers").child("FIREBASE USER ID").updateChildValues(payment as! [AnyHashable : Any])

但这似乎并没有触发任何 Stripe 。

有没有人知道如何构造此调用或推送 ID 是什么?

firebase 示例中的评论说

Add a payment source (card) for a user by writing a stripe payment source token to Realtime database

最佳答案

在 Firebase 中,pushId 表示您的数据库的任何键名。您可以使用 childByAutoId()

设置唯一键

设置您的 child 的路径,您希望设置自动推送 ID 之类的。

let sourcesRef = root.child("stripe_customers").child("FIREBASE USER ID").child("sources")

sourcesRef.child(sourcesRef.childByAutoId().key).child("token").setValue("tokenValue")

read more

关于iOS Firebase Stripe Integration with/Cloud Functions,相当于 iOS 中的 push() 和 push Id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49587871/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com