TECH

Simplifying Google Play Console & Cloud Project Setup for In-App Purchases

Hey developers! Feeling confused about setting up in-app purchases? I’ve been there too. After much trial and error, I successfully integrated in-app

Hitesh Verma May 21, 2024 · 5 min. read
Photo by <a href="https://unsplash.com/@kommumikation" target="_blank">Mika Baumeister</a> on <a href="https://unsplash.com" target="_blank">Unsplash</a>
Photo by Mika Baumeister on Unsplash

Hey developers! Feeling confused about setting up in-app purchases? I’ve been there too. After much trial and error, I successfully integrated in-app purchases and want to simplify the process for you. This guide breaks down the setup step-by-step in straightforward language.

Google Cloud Project Setup

Let's start from here so we don’t need to go back and forth.

1. Create a project.
If you have a Firebase project for your app, you can also use that same project .

2. Enable "Google Play Android Developer API"
Go to APIs & Services > Enable APIs & services > Search for Google Play Android Developer API & click enable.

3. Create a Service Account
Go to IAM & Admin > Service Accounts > Click on Create Sevice Account
a. Give a service account name in step 1, let’s say “Backend Server”.
b. Give the “Editor” role in step 2. Assigning the “Editor” role for simplicity. If you know how to manage roles, choose one that can access Android Publisher APIs (for one-time/managed products) and/or Google Pub/Sub (for subscriptions)
c. Skip step 3.
Copy the service account email address and save it. You'll need this for the Google Play Console setup.
Click on the service account, go to "KEYS" tab, click on "ADD KEY" > Create new key > Select JSON format and then create. Save this JSON file and share it with your backend developer.

4. [For Subscriptions Only] Enable Pub/Sub API
Go to APIs & Services > Enable APIs & services > Search for Cloud Pub/Sub API & click enable.

5. [For Subscriptions Only] Create a topic
Go to Pub/Sub > Topics > Click on "CREATE TOPIC"
a. Give a Topic ID , let's say "in-app-purchase"
b. Keep other settings as default and click create
c. Find your topic, and open the permissions details.

Accessing configuration for the Permissions topic.
Accessing configuration for the Permissions topic.

d. Add the service account google-play-developer-notifications@system.gserviceaccount.com, and grant it the role of Pub/Sub Publisher. Then, click Save.

Adding Google Play service account as publisher
Adding Google Play service account as publisher

e. Note down the topic name for the Play Console setup.

Google Play Console Setup

1. Create and Purchase a Google Play Console Account. (Skip if you already have one).

2. Create an App and fill out the necessary details. (Skip if you already created the app).

3. Add Your Payment Profile
Go to Main Screen (All apps screen) > Settings > Payments Profile

4. Add License Testing
a. Go to Main Screen (All apps screen) > Settings > License testing
b. Create a testers email list , it will be later used for internal testing of in-app purchases

5. Add service account as a user
a. Go to Main Screen (All apps screen) > Users and Permissions > Click on "Invite new users"
b. Add service account email here (copied in Google Cloud Project Setup step 3) and grant all permissions under “Financial data”.
Now your server can verify one-time / managed product in-app purchases using this service account.

6. [For one-time / managed products only] Create in-app products
Go to the app > Products (under Monetize) > In-app products > Click on Create product & fill the necessary details.

7. [For Subscriptions Only] Create subscriptions
Go to the app > Products (under Monetize) > Subscriptions > Click on Create subscription & fill the necessary details.

8. [For Subscriptions Only] Monetization setup
a. Go to the app > Monetization setup (under Monetize)
b. Enable the "Subscriptions settings"
c. Enable real-time notifications under Google Play Billing
d. add pub/sub topic name (copied in Google Cloud Project Setup step 5(e))
e. Save changes
Now your topic subscription will receive notifications whenever a subscription is purchased or its status changes (renewed, cancelled, etc.)

Now your setup is complete! Use the managed and subscription product IDs in your app, and publish it for internal testing. Your server can use the service account key from Cloud setup step 3 to verify in-app purchases and receive subscription notifications.

By following these steps, you'll have a seamless setup for in-app purchases. Happy coding!

Read next

Play Store in-app purchase verification on the server | Subscription product

In this guide, we’ll walk you through how to verify a subscription on your server after an in-app purchase is completed in your Android app. We'll be

Hitesh Verma Jun 6, 2024 · 5 min read