In-App purchases Android: Setup connection to the Play Store

Modified on Tue, 10 Aug, 2021 at 3:45 PM

General Information


If you want to offer in-app purchases in your Purple DS Android App you need to setup a connection between the Purple Manager and Google Play.


The setup requires 2 steps: 


1. Setting up purchase validation (required once per Google Play account) 

2. Setting up Real time developer notifications (required for each individual App) 



Instructions

1. Purchase validation

Purchases are validated against the Google Play Store to protect against fraud. 


Note: This setup has to be done once per Play Store account. 


  • All apps in a Purple Manager team need to be in the same Google Play account. 
  • We currently do not support different Google Play accounts when using one Purple Manager team


Setup

If there are points that are not clear please refer to the official Google Play documentation.


You will need to complete the following steps: 


  1. Open the Google Play Console as the Google Play Developer Account owner 
  2. In the menu navigate to Settings > Developer account > API access
  3. Accept the terms of service
    Note: If you already setup API access before this step is optional

  4. If no project is currently linked, you will be asked to Link existing project or Create new project
    • Make the selection depending on if you already have a Google Cloud project that you want to link or create a new project

  5. Once the project has been linked, verify that there is a service account listed under Service accounts 
    • If no service account is listed, you need to create one by clicking on Create new service accountand follow the steps listed in the popup message
      1. When creating the service account, make sure to grant the role Project > Viewer in step 2 Grant this service account access to project
      2. After the account has been created, open the details for the new account
      3. In the Keys section first select Add key and then Create new key
        1. Choose JSON format and confirm with Create
        2. Download the JSON file and make sure to backup this file
      4. Return to the Google Play Console and click on Done
      5. The newly created service account should now be listed in the table
      6. Click on Grant access in the row of the new service account
      7. The Invite user screen opens
      8. Select only View app information and download bulk reports and View financial data permissions
      9. Confirm invite with Invite user and then Send invite
  6. Go your team in the Purple Manager
  7. Click on settings


  8. Upload the downloaded JSON file to Google API Service Account and save




Note: It may be neccesary to open and save one in-app product/subscription in the Google Play console for the new settings to take effect. No changes need to be made to the product.


2. Real-time developer notifications

Real-time developer notifications (RTDN) is a mechanism to receive notifications from Google whenever there is a change in a user's entitlement within your app. These notifications allow us to react immediately to subscription state changes.


Note: You need to setup this to be able to use Google Play subscriptions with Purple Apps.

  • This setup has to be done for each Android app separately. 
  • You can re-use the same Pub/Sub topic for all apps of the same Google Play account.
  • If there are points that are not clear please refer to the official Google Play documentation.

Setup: 

Please complete the following steps: 

  1. Go to https://console.cloud.google.com/cloudpubsub/topic/list 
    • Make sure to select the correct project in the project dropdown

  2. Click on Create topic
  3. Enter a Topic ID and confirm with Create topic
    • Use a name that references the app if you re-use the same Google Cloud project for multiple apps

  4. Switch to Subscriptions in the left side menu
  5. Click on Create subscription
  6. Enter a Subscription ID, e.g. the name of your Topic ID
  7. Select the previously created topic in Select a Cloud Pub/Sub topic
  8. Choose Push as Delivery type
  9. Enter the Endpoint URL depending on the environment you are using:
    1. Production: https://receipts.purplemanager.com/api/v1/notifications/google
    2. Staging: https://staging-receipts.purplemanager.com/api/v1/notifications/google
  10. For Retry policy select Retry after exponential backoff delay with the following values:
    1. Minimum backoff (seconds): 10
    2. Maximum backoff (seconds): 600

  11. Click on Create to create the subscription
  12. Configure permissions for you topic as described at:
    https://developer.android.com/google/play/billing/getting-ready#grant-rights

  13. Configure Real-time developer notifications for your app as described at:
    https://developer.android.com/google/play/billing/getting-ready#enable-rtdn

  14. After configuring the topic in the Google Play Console press Send test notification
  15. In the Purple Manager go to the App Status tab of the corresponding App


  16. RTDN Status should show the time when the test notification was triggered




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article