【发布时间】:2022-01-03 08:14:54
【问题描述】:
我在我的 Web 应用程序中使用 Firebase JS V9。我正在尝试将 Firebase 中的 Stripe Etension 实施到我的应用中。
此扩展程序的文档尚未更新以支持 Firebase v9。我已在 Twitter 上确认文档将更新,但目前没有 ETA :)
这是他们在以前的 Firebase 版本中的做法:
const docRef = await db
.collection('customers')
.doc(currentUser.uid)
.collection('checkout_sessions')
.add({
price: 'price_1GqIC8HYgolSBA35zoTTN2Zl',
success_url: window.location.origin,
cancel_url: window.location.origin,
});
// Wait for the CheckoutSession to get attached by the extension
docRef.onSnapshot((snap) => {
const { error, url } = snap.data();
if (error) {
// Show an error to your customer and
// inspect your Cloud Function logs in the Firebase console.
alert(`An error occured: ${error.message}`);
}
if (url) {
// We have a Stripe Checkout URL, let's redirect.
window.location.assign(url);
}
});
所以我正在尝试这样做,但使用 v9 中的新内容,一切都不同了。我在网上搜索过,我能找到的唯一解决方案是关于以前的 Firebase 版本。
这是我第一次使用 Firebase,所以也没有用。
有人知道如何在 Firebase JS SDK V9 中执行上述代码 sn-p 吗?
谢谢!
【问题讨论】:
-
看起来 Stripe 团队和 Firebase 团队正在努力更新这些代码示例。等待他们是最好的。同时,试试 Web SDK (github.com/stripe/stripe-firebase-extensions/tree/next/…) 怎么样?它应该不受 Firebase 版本的影响
标签: firebase google-cloud-firestore next.js stripe-payments saas