[英]The plugin firebase_database requires a higher Android SDK version
[英]Problem with firebase stripe extention and sdk version 9
我在将官方源代码中的 firebase 条带扩展 sdk 版本 8 代码升级到版本 9 时遇到问题。
即使我设法升级了一次性购买和订阅购买,我还是不知道如何将重定向升级到门户代码。
他们提供的版本 8 代码是这样的:
`const functionRef = firebase
.app()
.functions('${param:LOCATION}')
.httpsCallable('${function:createPortalLink.name}');
const { data } = await functionRef({
returnUrl: window.location.origin,
locale: "auto", // Optional, defaults to "auto"
configuration: "bpc_1JSEAKHYgolSBA358VNoc2Hs", // Optional ID of a portal configuration: https://stripe.com/docs/api/customer_portal/configuration
});
window.location.assign(data.url);`
经过一些挖掘,我想出了这段代码,但它不起作用
`import { getFunctions, httpsCallable } from "firebase/functions";
constructor(private initialize: InitializeService, private afApp: FirebaseApp) { }
functions = getFunctions(this.afApp, "europe-west1");
async customerPortal() {
const functionRef = httpsCallable(this.functions, 'ext-firestore-stripe-subscriptions- createPortalLink');
functionRef({
returnUrl: window.location.origin
}).then((result) => {
const data = result.data;
});`
我得到的错误要么被 Cors 阻止,要么当我在浏览器上禁用 cors 时(无论如何都不是最佳的)是 FirebaseError: permission-denied GET 403。
即使我在 firebase 扩展配置条带密钥或条带公钥时将访问受限的条带 API 密钥放置,我也会收到这些错误
有什么想法吗??
先感谢您:)
根据您使用的扩展程序版本,Firebase function可能有不同的名称(在版本0.2.2
Stripe 中将其重命名为ext-firestore-stripe-payments
)。
如果您使用的是0.2.2
或更新版本,那么您分享的示例中的 Firebase function 名称是错误的。 它应该是ext-firestore-stripe-payments-createPortalLink
。 使用 Firebase 客户端的 v9,像这样的东西应该可以工作:
import { getFunctions, httpsCallable } from 'firebase/functions'
const functions = getFunctions(firebase, 'europe-west2')
const billingPortalSession = httpsCallable(functions, 'ext-firestore-stripe-payments-createPortalLink')
const { data } = await billingPortalSession({
returnUrl: window.location.origin
})
window.location.assign(data.url)
此外,请确保传递给getFunctions
的regionOrCustomDomain
参数是您的 Firebase 实例所在的区域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.