INNER CODE UNIT · TypeScript
customerPortal
ekzhang/setwithfriends · functions/src/index.ts:324
export const customerPortal = functions.https.onCall(async (data, context) => {
if (!context.auth) {
throw new functions.https.HttpsError(
"failed-precondition",
"This function must be called while authenticated.",
);
}
const user = await getAuth().getUser(context.auth.uid);
if (!user.email) {
throw new functions.https.HttpsError(
"failed-precondition",
"This function must be called by an authenticated user with email.",
);
}
const customerResponse = await stripe.customers.list({ email: user.email });
if (!customerResponse.data.length) {