In-App billing connect to Firebase and get Products

Viewed 5703

I'm starting to create an APP where I can buy items from it. Could be like this: image] where you can see an Image, Name of product, and Price. Well, I allready have a Sign-in with Google made with Authentication Firebase and I store it on Firebase database, I'd like to create the following this structure that @Alex Mamo recommend to me :

Firebase-root
    |
    --- users
    |     |
    |     --- uid1
    |          |
    |          --- //user details (name, age, address, email and so on)
    |          |
    |          --- products
    |                |
    |                --- productId1 : true
    |                |
    |                --- productId2 : true
    |
    --- products
    |     |
    |     --- productId1
    |     |     |
    |     |     --- productName: "Apples"
    |     |     |
    |     |     --- price: 11
    |           |
    |           |
    |           --- users
    |                |
    |                --- uid1: true
    |                |
    |                --- uid2: true
    |
    --- purchasedProducts
         |      |
         |      --- uid1
         |           |
         |           --- productId1: true
         |           |
         |           --- productId2: true
         |
         --- paidProducts
         |      |
         |      --- uid2
         |           |
         |           --- productId3: true
         |
         --- availableProducts
         |      |
         |      --- uid3
         |           |
         |           --- productId4: true

Looks fine to make an easy app like mine. Because the scenario is as easy as :

  • User loggs in the APP
  • User see the free products and can buy some products
  • User can see that products that has allready paid for them

From start I store the uid inside the users. What I do not know is;

  1. Do I have to create the same products on Google Play Console to Firebase database? I've already created 1 product to test it on Google Play Console, I have to create the product as well on my app (I mean on Firebase database)?

To implement in-app billing I'm following this tutorial but I've found this android-inapp-billing-v3 library and looks good though.

If there is any of you that has worked with in-app-purchased and has created items and know how to get them from Google Play Console please feel free to share a demo of how to.

EDIT

I allready got how to purchase items I ended up using this Library, the thing is that on my Login page I have the db create of firebase I mean there I put the id of user and email... Do I have to add all the products there aswell?

3 Answers

In-app Billing API tracks the purchases but managing the user inventory is the developer job. You can get what have been purchased by using getPurchases so you don't need to save them into the database but is not the case for free products cause you can't add them to in-app billing products list,so you need to save them into Firebase. .Finally about the adapter if what you are querying is simple then use the FirebaseRecycleradapter else use Recycleradapter.

Related