sampl / firefly

Web app boilerplate for beginners based on Firebase and React 🔥
http://getfirefly.org/
234 stars 42 forks source link

Cannot set property 'id' of undefined #167

Open geraldoramos opened 5 years ago

geraldoramos commented 5 years ago

Hi,

I'm getting this error while trying to create a new stripe subscription.

Error is happening on this function (function/lib/subscription.js):

const getUser = userId => {
  return admin.firestore()
    .collection('users')
    .doc(userId)
    .get()
    .then(doc => {
      const user = doc.data()
      user.id = doc.id
      return user
    })
}

image

This happens after I try to create the subscription for a logged user. Looks like it was able to save the subscription to firestore but the cloud function is failing at this point. I have a product setup on stripe and a plan and included the plan_id in the cloud function variables. I also double checked the keys are all correct (public key in the React app and private key in the function env file).

Thanks in advance,

Geraldo