5

I'm developing an app which uses Google In-App Billing (IAB) for users to subscribe to the app. Available subscription options are 1 month, 6 months and 1 year.

It also uses Firebase Authentication with Google and Email/Password sign in options.

I have created a collection named users where each document represents a user having fields: displayName, emailId, photoUrl, creationDate, lastLoginDate, isSubscribed.

I also intend to give access of premium content (available on Firebase Storage) to only paid subscribers (isSubscribed = true).

Consider the following scenario:

  1. User downloads the app using Play store email id user123@gmail.com
  2. User signs into the app using Google sign in and with email id user123@gmail.com (same as Play Store ID)
  3. User purchases a 1 month subscription.
  4. A couple of days later, user signs out and sign in again using Google sign in with email id user456@gmail.com

At this stage, if the current user (user456@gmail.com) tries to purchase 1 month subscription, he is not allowed as this product has already been purchased.

What it shows is that IAB recognizes the Google Play Store email ID user123@gmail.com which was used to download the app and it is not concerned with the current user signed into the app. It also shows that the ongoing 1 month subscription will be available to all the many users that are created by this instance of the app. On the other hand, Firebase is not concerned with which Google Play Store email ID was used to download the app; it is concerned with which email ID was used to sign into the app.

If above understanding is true, following questions arise:

  1. How can I implement the above mentioned per user restrictive access to premium content when all the users created above will be considered as paid subscribers?

  2. If this app is later downloaded using Google Play Store email id user456@gmail.com (on a different or even the same device) and Google sign in option is used with the same email id user456@gmail.com, this user will still be considered as a paid user (because isSubscribed = true) although Google Play Store ID user456@gmail.com never purchased the subscription. How to deal with this anomaly?

If above understanding is wrong, please explain how!

I'm unable to find a solution to this whole billing implementation due to this gap between Google IAB and Firebase Or may be I'm not understanding it properly.

Kindly point me in the right direction!

Shahood ul Hassan
  • 745
  • 2
  • 9
  • 19

0 Answers0