In this tutorial we’ll look at integrating the Google Play store with the brainCloud marketplace. By doing this, Google Android users will have the ability to validate purchased items from the Google Play store with brainCloud.
Note that apps still have to make the purchase directly with the Google Play Store. For more information on this process refer to the Google Play developer site.
brainCloud Portal Setup
Here are the steps to configure brainCloud for Google Play purchases.
- You should have setup your products in the brainCloud marketplace. Please refer to the Marketplace Configuration guide.
- You should have created the Google Store In-App products per the Google Developer documentation
Associate Google In-App Products with brainCloud Products
After setting up your products in the brainCloud marketplace, you’ll want to associate them with the Google product ids. In particular we will be grabbing the product ids from the Google Play developer site and entering them into the appropriate brainCloud products.
- Log into the Google Play Developer site
- Select your App and go to the “In-App Products” section
- Select your IAP and grab the Google Product ID
(for this tutorial we’ll assume that the product id is com.braincloud.mygame.goldsack1)
- Log into the brainCloud Portal
- Go to the “Marketplace | Products” page in the Design tab
Google Certificates and Credentials
Once the products have been configured, you will need to add the appropriate Google credentials to brainCloud.
- Navigate to the Application IDs page
- Click the Google icon and notice the following fields
- The following sections will show you where to find the appropriate information
Google Package Name
- Log into the Google Play developer site
- Select your application
- Grab the package name
Google Service Account Email & p12 Certificate File
To validate purchases, brainCloud requires usage of a Service Account to communicate with the Google Play backend servers.
- Log into the Google Console developer site
- Create a project (or select an existing project). Note that the Google Service Account can be used across multiple apps.
- Enable the Google Play Android Developer API
- Navigate to the Credentials page
- Create a new Service Account
- Select the p12 key type and click Create
- This should create a new Service Account and immediately download the p12 key file to your computer. If for some reason the browser did not download the p12 key file try Chrome.
- Upload the p12 key file to the brainCloud portal.
- Also the Service Account should now show up on the Credentials page. Important: Grab the email address and save it to the brainCloud portal – Design | Core App Info | Application IDs, Google platform tab, Google Service Account Email field.
Linking the Google Console project to the Google Play app
For the Service Account to be active, you will need to link the console project to the Google Play app and give the Service Account permission to View Financial Reports. Note you will need to be the account owner in order to complete these steps.
- Log into the Google Play Developer Console
- Go to Settings | API Access
- Select the Google Console project to link to
- Verify that the project is linked and the Games Services Publishing API access is ON
- Next navigate to User accounts & rights
- Select the Service Account and turn on “View Financial Reports” permission. All other permissions can be disabled
- You should now be able to validate purchase with brainCloud.