Search code examples
javafirebasefirebase-realtime-databasegoogle-pay

Linking Google Firebase to Google Billing Subscription - Android Studio java


I am trying to link my firebase application to google billing subscription. Because I am trying to provide a subscription-based service but with a variable. The user will have 8 tries, he gets 8 new each month and resets to default by the end of the month.

I have looked into so many documentation and couldn't find any way to link them, the only thing I could come up with was making a server that handles this issue but that is not possible at the time.

if(subscription) {                    
    database.getReference("Business").child(user.getUid()).child("ordercount").setValue(8);
}
else {
    database.getReference("Business").child(user.getUid()).child("ordercount").setValue(0);
}

This is the code that I want to be executed at the end of each subscription month if subscription still on. Note I am trying to figure out how to check for the boolean (subscription) from the users' Gmail service. So I expect to get a return of 0 or 8 based on the subscription state of the user.


Solution

  • There is nothing built into Firebase to connect it with Google Pay, not is there anything built into Google Pay to connect it with Firebase. You'll have to write the code that connects the two yourself. And since this involves payment processing, you'll likely have to do this in a trusted environment. This can be your development machine, a server you control, or Cloud Functions.

    For an example of integrating payment processing with Firebase through Cloud Functions, have a look at this example using Stripe (also explained in this video), or this example using PayPal.