Stripe Product metadata not returning to Firebase's authenticated user instance when using Run Payments with Stripe Firebase Extension

Viewed 147

I'm using the Run Payments with Stripe Firebase Extension.

I set a metadata field in the Stripe Product of: userRole: premium.

The webhook returns userRole: premium in Firestore under Users >> subscriptions >> metadata.userRole.

But I expected the webhook to attach userRole to Firebase's auth.currentUser instance. Which I was planning to query for using the function below.

How can I make the webhook return this metadata to auth.currentUser?

import { auth } from '../src/utils/init-firebase';

export default async function isUserPremium() {
    await auth.currentUser?.getIdToken(true);

    const decodedToken = await auth.currentUser?.getIdTokenResult();
    console.log(decodedToken);

    return decodedToken?.claims?.userRole ? true : false;
    // return decodedToken?.claims?.stripeRole ? true : false;
}
1 Answers

I had changed the metadata name to userRole.

It must be firebaseRole for users to get assigned a custom claim role to give them access to certain data when subscribed to a specific product.

Related