invertase / stripe-firebase-extensions

Repository of Firebase Extensions built by Stripe.
https://firebase.google.com/products/extensions
Apache License 2.0
433 stars 162 forks source link

Custom claim stripeRole is not set on the user #193

Closed MitchelSt closed 3 years ago

MitchelSt commented 3 years ago

Bug report

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

  1. Add a new product firebaseRole with value 'premium'
  2. Check if product with metadata field is added to firestore
  3. Make a payment for this specific product (using the price_hash in a test environment)
  4. Check if payment was made successfully
  5. Run the following snippet in React

async function getCustomClaimRole() { await firebase.auth().currentUser.getIdToken(true); const decodedToken = await firebase.auth().currentUser.getIdTokenResult(); console.log(decodedToken.claims.stripeRole); }

  1. Console logs undefined (just logging claims, obviously, also doesn't show it)
  2. Logout, clear application data, sign in again => same as 6

Expected behavior

user.claims.stripeRole should contain a value

System information

thorsten-stripe commented 3 years ago

Do you have your webhook handler configured correctly? If so you should see this in the logs for the ext-firestore-stripe-subscriptions-handleWebhookEvents function:

🚦 Added custom claim [stripeRole: premium] for user [ly9Vm...].

Can you double check your webhook configuration and the function logs please?

MitchelSt commented 3 years ago

I just re-configured everything from scratch, checked the logs; but without success.

Could this perhaps be the case since one-time payments are not supported?

thorsten-stripe commented 3 years ago

@MitchelSt custom claims are not supported for one-time products, only for recurring products

mschmid commented 2 years ago

@thorsten-stripe I also stumbled over this. In my opinion, support for one-time products would really be a benefit - because then a product can also be bought via one-time payment.

What would be your recommended way to enable premium service for users who bought a one-time product?

andrewsrichardson commented 2 years ago

did anyone find a clean way of doing this?

lifetime plans of premium subscriptions seems like it would be a common use-case

sabindev commented 1 year ago

@thorsten-stripe im also experiencing the same issue

udit99 commented 5 months ago

@thorsten-stripe me too!