firebase-subscription-payments icon indicating copy to clipboard operation
firebase-subscription-payments copied to clipboard

Customer Portal: Doesn't work with Firebase 9

Open tommtt opened this issue 3 years ago • 3 comments

I'm trying to trigger the customer portal with the new Firebase 9, but it doesn't work. This is the code:

import { initializeApp } from "firebase/app";
import { getApp } from "@firebase/app";
import { getFunctions, httpsCallable } from "firebase/functions";

const firebaseApp = initializeApp({
  apiKey: "AIzxxxxxxxxxxxxxxxxxxxxxvc",
  authDomain: "xxxxxxxxxxxx",
  projectId: "bloxxxxxxxxxxxxxxxxd76",
  ....
});

const app = getApp();

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);
}

Errors:

Access to fetch at 'https://us-central1-xxxxxxxxxx-6ed76.cloudfunctions.net/ext-firestore-stripe-subscriptions-createPortalLink' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

service.ts:206 POST https://us-central1-xxxxxxxxx-6ed76.cloudfunctions.net/ext-firestore-stripe-subscriptions-createPortalLink net::ERR_FAILED

Uncaught (in promise) FirebaseError: internal

tommtt avatar Nov 24 '21 00:11 tommtt

I have the same issue, I hope they update the docs soon to work with V9

rasoulMO avatar Nov 24 '21 21:11 rasoulMO

Hi! I'm a beginner at all of firebase and js. However, the following changes in app.js will work.

ext-firestore-stripe-subscriptions-createPortalLink ->ext-firestore-stripe-payments-createPortalLink

It makes some ssl errors, but it will show customer portal.

Methanon46 avatar Jan 20 '22 21:01 Methanon46

Hi! I'm a beginner at all of firebase and js. However, the following changes in app.js will work.

ext-firestore-stripe-subscriptions-createPortalLink ->ext-firestore-stripe-payments-createPortalLink

It makes some ssl errors, but it will show customer portal.

Can you post your code for billing I am having same issues still not solved using firebase v9

aryan1107 avatar Feb 03 '22 10:02 aryan1107