Why am I reading this?
- Mobile applications are surrounded by so many modules in addition to that, the IN-APP Purchase and Subscriptions play a good amount of role, where you as an owner of the app, can generate revenue by selling consumable and non-consumable goods such as Coins for Games, Subscription plans for your app many things.
- Now, as you are selling some goods on your app, there must be a way to validate that purchase or get the details. But obviously, you can do it from the app itself as Google does provide SDK for the same. (SDK – Software Development Kit). But, we are living in a world where Android and iOS exist and in a very competitive market!
- Google Play Developer API gives us the power to check the user’s transaction from the RESTful APIs which leads you to read this blog.
- With the RESTful API, we can do this call from the BACKEND and leave the app standalone and do other stuff
Offering
Google Play Developer API lets you manage the two main components in your project- The Publishing API lets you upload and publish apps, and perform other publishing-related tasks.
- The Subscription and IN-APP Purchase API lets you manage in-app purchases and subscriptions. [We are going to explore these APIs]
Objective
To verify the Google In-App Purchase and Subscriptions (IAP)Requirements
- Google Play Developer Console Access
- Google Cloud Console Access
Tip: If you already have an existing project over Google Cloud Console then it should be using the same google account you used for the Google Play Console. If you have a different account setup then there are certain steps and roles with which we can achieve this.
Here are the main steps we are focusing on:
- Set up a new or existing Google Cloud Project
- Use a service account to access the Google Play Developer API
- Access the RESTful APIs for analyzing the app
Let’s Start
Linking your account and project
Before you can access the Google Play Developer API, you must link your Google Play Developer Account to a Google Cloud Project. In most cases, we recommend that you create a new Google Cloud Project dedicated to your Google Play Developer Account, but you can link an existing project. Keep in mind that each Google Play Developer Account can only be linked to a single Google Cloud Project. If you have multiple apps in the same Google Play Developer Account, they all must share the same Google Cloud Project.Access Google Play Developer Console
- Login to Google Play Developer Console Play Console (google.com)
- Select your account
- On the side avigation menu, select Setup>API Access
- Agree with API terms of services (Just follow the on-screen instructions if any)
- Once done, you will be seeing options to link your existing project or create a new project
Link Existing Project
If you already have a Google Cloud Project then you can Link that project or you can create a new project.Select the existing project by clicking on Choose Project dropdown menu If your project isn’t listed, verify that your Google Play Console account is with the role OWNER and Google Play Developer API is enabled for the project. If not then you can do it quickly by following, how to do it?
After saving the project, You will be seeing a screenshot below. Now, we need to work on the Service Accounts section. If you already have a service account then you will be seeing it listed. If not then we will create a new service account.
Create New Project
Select the option Create New Project and click the SAVE button
A new project will be created and you can see that project as listed. You can rename the project later on.
Configure Service Accounts
Most common secure software service which will access the API.
Service accounts must be used in a secure environment, such as your server. The service account credentials need to be securely managed so they are not revealed to anyone that is not authorized to use the API.
Once we have the project linked or created, our main goal is to Create new Service Account or give access to an already created service account.
Create new service account
- Read the instruction once you click this button, “CREATE NEW SERVICE ACCOUNT”
- Click on option #1, Go to the Google Cloud Platform and open that URL in the new tab
- Now, you are on the Google Console.
- Click on "CREATE SERVICE ACCOUNT"
- Name your service account and provide the description. No need to alter the field, "Service account" which will be auto-generated based on the service account name you provide.
- Click on "CREATE AND CONTINUE" to define ROLE in step 2.
- Search for "Service Account Admin" and select it.
- Click on the "CONTINUE"
- Nothing to do on step 3, so just click the button "DONE"
- Your service account has been created and listed on the same page.
- Select the account and switch to KEYS tab. We are going to add key to this service account.
- Click on ADD KEY and select "Create new key"
- Select the "Key type" as JSON and click on the "CREATE" button
- The key will be created and will ask you to download it. Save the file as it is. We will need this for the development and will ask you to provide that. Close this dialog box.
- You can see the created key listed on the page.
Grant access to the Service Account
Now, as we have created the service account with help of the above steps, you can see the newly created service account under the SERVICE ACCOUNTS section
After sending the invitation, if you are not seeing the new service account added as a user then please enable Google Play Developer Android API.
Enable Google Play Developer API
Need to enable Google Play Developer API from the Google Cloud Console. Open the Google Cloud Console.
- Click on the HAMBURGER menu (Navigation drawer) and select "APIs and services > Library"
- Search for "Google Play Android Developer API" and select the searched result
- Enable this API.
Comments