Step 1 to getting your code to live in Firebase and be ready for you to use is to prepare your environment. Watch this short video and follow the steps to prepare your Google Cloud environment to accept and host the required code
In order to complete the following actions you need to have a few HTTPS callable functions that live in the cloud. These actions will come in handy when you need to validate that a user should or should not have access to certain areas or content within your app. You'll need this to complete the following in-app processes
To be clear: once a purchase has been made, the only way to get an updated status on that purchase is to set up a backend that listens and waits for incoming data from the to the stores OR to directly ping the store and request the information manually. Our current process covers the later, though in the future documentation will be setup such that developers will bee able to ping their own backend Firebase server for subscription/purchase info which is much faster.
These steps are necessary when restoring purchases. Per app store polices, all apps that include IAP must also include a way for the user to restore those in app purchases should they ever need to delete/reinstall an app for any reason.
Acknowledge Android Subscriptions
if you don't do this step, subscriptions revert within 3 days of the original purchase
Verify Android Subscriptions
useful to ensure that a subscription is still valid.
Verify Android Purchases
useful to ensure users did not request refunds/charge backs after they made the original purchase
Verify iOS Purchases
Verify iOS Subscriptions
useful to ensure that a subscription is still valid.
Please be mindful. This page is almost identical to the previous with exceptions in the function name and code.
These codes will allow you to acknowledge and verify purchases or subscriptions. There is 1 call for each type of transaction.
androidPurchaseHandler should be the name you use here
the name used here should match the name used in Step 3 above
This allows any device with your endpoint URL the ability to verify purchases made via your app
Select the function you want to make public. (the function you just created)
Click the Permissions tab.
Click Add Principle
In the Add members field, type allUsers
Select the Cloud Function Invoker role from the Select a role drop-down menu.
Click Add.
These codes will allow you to acknowledge and verify purchases or subscriptions. There is 1 call for each type of transaction.
androidSubscriptionHandler should be the name you use here
the name used here should match the name used in Step 3 above
This allows any device with your endpoint URL the ability to verify purchases made via your app
Select the function you want to make public. (the function you just created)
Click the Permissions tab.
Click Add Principle
In the Add members field, type allUsers
Select the Cloud Function Invoker role from the Select a role drop-down menu.
Click Add.
These should be created and deployed like the previous 3 functions
serverLog should be the name you use here
the name used here should match the name used in Step 3 above
This allows any device with your endpoint URL the ability to verify purchases made via your app
Select the function you want to make public. (the function you just created)
Click the Permissions tab.
Click Add Principle
In the Add members field, type allUsers
Select the Cloud Function Invoker role from the Select a role drop-down menu.
Click Add.
Please be mindful. This page is almost very similar but different than the last page. Differences in service account, code, package.json.
These codes will allow you to acknowledge and verify purchases or subscriptions. There is 1 call for each type of transaction.
verifyiOSPurchase should be the name you use here
the name used here should match the name used in Step 3 above
This allows any device with your endpoint URL the ability to verify purchases made via your app
Select the function you want to make public. (the function you just created)
Click the Permissions tab.
Click Add Principle
In the Add members field, type allUsers
Select the Cloud Function Invoker role from the Select a role drop-down menu.
Click Add.