How to set up in apps purchase in Android (for client)

You can only set up a one-time or recurring plan on your platform. Both types cannot be used at the same time.

To find out how to create test account and how to test in-apps purchase with real device, please refer How to set up in apps purchase in Android (for dev)

ADD ANDROID APP PACKAGE NAME

  1. Go to Google Play Console: https://play.google.com/console
  2. Copy your App Package nameinapp_android_1

3. Open Admin Panel, click on Subscription menu 

inapp_android_2

4. Paste the App Package name that you copy to Android app package name field and save changes

inapp_android_3

SET UP IN-APPS PURCHASES FOR BUYING RECURRING SUBSCRIPTION

  1. Open your site, go to AdminCP -> System Admin -> Subscription -> Manage Packages.
  2. Edit Package -> create new Plan -> setting all information and click the Save Changes button

(1) Plan Type: select One Time plan

(2) Title: enter plan title

(3) Price: enter plan price

(4) Plan Duration: setting plan duration

(5) Expiration Reminder: setting expiration reminder

(6) Show at: select Manage Membership

(7) Android Product Id:  enter Android Product Id. This is a unique alphanumeric ID. After you use an Android Product ID for one product, it can’t be used again, even if the product is deleted.

(8) Ios Product Id:

(9) App recurring: tick on

(10) Enable Plan: tick on

3. Go to Play consolehttps://play.google.com/apps/publish

4. Select your app

5. Scroll to Monetize, click on Subscription (under Product)

6. Click on Create subscription button

7. Enter Product ID and Name and click the Create button. Product ID is the Android Product Id that you create in step #2.

Product ID must be unique for your app, and they can’t be changed or reused after they’ve been created.

8. After creating a new subscription, you will be redirected to this subscription detail page. At Base plans and offers section, click on Add base plan.

9. Enter base plan information

(1) Base plan ID: enter a base plan ID. The base plan ID must be unique for your app, and it can’t be changed or reused after it’s been created.

(2) Type: select Auto-renewing.

(3) Billing period: select the period matches the Plan Duration that you setting in step #2.

(4) Grace period: can use the default value (3 days).

(5) Customer base plan and offer changes: select Charge immediately.

(6) Resubscribe: select allow.

10. Scroll to the Price and availability section, click on Set prices.

11. Select all the countries and click on Set price button.

12. Enter price and select currency that match the Price you setting in step #2 and click on Update button.

13. Click on Save button.

Note: Please do not delete products and base plan (step #7 and step #9). You cannot reuse the Product ID and Base plan ID even if you delete the package.

 

SET UP SERVER TO RECEIVE PLAY STORE SERVER NOTIFICATION

  1. Go to Google console: https://console.cloud.google.com/
  2. At Navigation menu, scroll to ANALYTICS section, click on Pub/Subinapp_android_4
  1. Click on CREATE TOPIC

inapp_android_5

  1. Enter Topic ID and click on CREATE BUTTON

inapp_android_6

  1. After creating a new topic, you will be redirected to this topic detail page. Copy Topic name.

inapp_android_7

  1. Click on ADD PRINCIPAL button

inapp_android_8

  1. Enter principal information and click on SAVE button

(1) New principal: enter “google-play-developer-notifications@system.gserviceaccount.com

(2) Role: select Pub/Sub -> Pub/Sub Publisher

8. When creating a topic, the system will automatically create a subscription. Click on this subscription to view subscription detail page

inapp_android_9

9. Click on EDIT

inapp_android_10

10. Setting subscription and click on UPDATE button

  1. Delivery type: select Push
  2. Endpoint URL: enter [yourwebsite]/subscription/subscribe_public/notification_android

Ex: https://moosocial.com/subscription/subscribe_public/notification_android

inapp_android_11

11. Go to Play console: https://play.google.com/apps/publish

12. Select your app

13. Scroll to Monetize, click on Monetization setup

inapp_android_12

14.  Enter the Topic name that you copy in step #5 and click on Save Changes button

inapp_android_13

SETUP SERVICE ACCOUNT

  1. Go to Google consolehttps://console.cloud.google.com/
  2. At Navigation menu, scroll to APIs & Services section, click on Library

inapp_android_14

  1. Search to find “Google Play Android Developer API

inapp_android_15

  1. Open Google Play Android Developer API and enable

  1. At Navigation menu, scroll to IAM & Admin section, click on Service Accounts

inapp_android_16

 

  1. Click on CREATE SERVICE ACCOUNT

  1. Create service account

7.1. Service account details:

(1) Service account name: Enter an arbitrary Service account name

(2) Service account ID: Service account ID will be automatically generated from your Service account name. You don’t need to change it

(3) Service account description: This is optional field

(4). CREATE AND CONTINUE: click to create account and move to next step

7.2. Grant this service account access to project:

(1) Select a role: Open dropdown and select Basic -> Editor

(2) ADD ANOTHER ROLE: click to add more role
You need to add one more role: 
IAM -> Security Admin

(3) CONTINUE: click to move to next step

7.3. Grant users access to this service account

You do not need to set up this step. Click Continue

  1. There is an email that will be automatically generated. Please copy this email for use in the next stage. I will refer to this email as Email (1) for the rest of the tutorial.

Click on the email just created.

  1. Select KEYS

  1. Click on CREATE KEY button, select Create new key

  1. Select Key type is JSON and click on CREATE button

Now, you will download a json file. Please change the file name to “service_account.json” and keep this file for use in the next stage.

UPLOAD JSON FILE

  1. Go to your host server -> open database
  2. Redirect to ../app/Plugin/Subscription/Lib/
  3. Upload the file “service_account.json

ADD USERS AND PERMISSIONS

  1. Go to https://play.google.com/console/
  2. Click on Users and Permissions menu

inapp_android_18

  1. Click on Invite new users

inapp_android_19

  1. Email address: Enter Email (1)

inapp_android_20

  1. Click on Add app, select the app you want to set up users and click on Apply

inapp_android_21

  1. Select the permissions and click on Apply:
  • View app information (read-only)
  • View app quality information (read-only)
  • View financial data
  • Manage orders and subscriptions

inapp_android_22

  1. Click on Inviter user and confirm to send invite

inapp_android_23

Last Updated On June 05, 2024