小编tms*_*mst的帖子

在 Firebase 9 上的 Https Callable 函数中设置位置(条带客户门户)

我正在尝试为用户设置一个按钮来管理他的 Stripe 客户门户及其 Firebase 集成的订阅。

问题,该文档对旧版本的 Firebase (8) 有效,而我正在使用新版本 Firebase 9。

我们在客户端,这就是 React.js。

这是他们调用该函数的js代码(您可以在这里看到完整的代码:https://github.com/stripe-samples/firebase-subscription- payments/blob/master/public/ javascript/app.js):

const functionLocation = 'us-east1';
    
const functionRef = firebase
      .app()
      .functions(functionLocation)
      .httpsCallable('ext-firestore-stripe-subscriptions-createPortalLink');
    const { data } = await functionRef({ returnUrl: window.location.origin });
    window.location.assign(data.url);
  });
Run Code Online (Sandbox Code Playgroud)

对于 Firebase 9,它应该是这样的:

const functions = getFunctions(firebaseApp)

export async function goToBillingPortal() {
       const functionRef = httpsCallable(functions, 'ext-firestore-stripe-subscriptions-createPortalLink');
    
       const { data } = await functionRef({ returnUrl: window.location.origin });
       window.location.assign(data.url);
 }
Run Code Online (Sandbox Code Playgroud)

控制台显示3个错误:

Access to fetch at 'https://us-central1-xxxxxxxxd76.cloudfunctions.net/ext-firestore-stripe-subscriptions-createPortalLink' from origin 'http://localhost:3000' has been …
Run Code Online (Sandbox Code Playgroud)

javascript stripe-payments firebase google-cloud-platform google-cloud-functions

1
推荐指数
1
解决办法
1003
查看次数