I’m using Stripe extension for Firebase with firebase functions. Since I refactored a bit my code for firebase v9 modular SDK, I’m getting the following console error with my Stripe createPortalLink() function:
Uncaught (in promise) TypeError: _firebase__WEBPACK_IMPORTED_MODULE_2__.default.functions is not a function at createPortalLink (Subscription.js:99:1)
Here is my function:
async function createPortalLink() { const functionRef = app .functions("europe-west1") .httpsCallable("ext-firestore-stripe-payments-createPortalLink"); const { data } = await functionRef({ returnUrl: `${window.location.origin}/dashboard-pro/abonnement/`, locale: "auto", }); window.location.assign(data.url); }
Can anyone please advise?
Thanks
Advertisement
Answer
You need to use the getFunctions()
and httpsCallable()
functions in the new Modular SDK as shown below:
import { getFunctions, httpsCallable } from "firebase/functions"; // after initializing Firebase const functions = getFunctions(); const functionRef = httpsCallable(functions, 'ext-firestore-stripe-payments-createPortalLink'); functionRef({ returnUrl: `${window.location.origin}/dashboard-pro/abonnement/`, locale: "auto", }) .then((result) => { const data = result.data; });
Checkout the documentation for more details.