Android/Google In App Purchase Subscription Guide

Android/Google Play Billing Library In App Purchase Subscription Instruction Guide And Information


Please Subscribe Youtube| Like Facebook | Follow Twitter

Introduction

This is guide for how to use in app purchase subscription code which can be downloaded from here.

Instruction to use template app

1. Create Product/Subscription ID’s on your Google play console account.

a. Create Consumable items in Google play console

 Go to Google Play Console -> Select your app -> Go to Monetize -> Products -> In-app products.

Click on create and fill necessary info then save and activate the product items. Create three product items and give them id “c1”, “c2”, “c3” respectively.

b. Create Non Consumable product items in Google play console

  Go to Google Play Console -> Select your app ->  Go to Monetize -> Products -> In-app products.

Click on create and fill necessary info then save and activate the product items. Create three product items and give them id “p1”, “p2”, “p3” respectively.

c. Create Subscription items in Google play console

 Go to Google Play Console -> Select your app -> Go to Monetize -> Products -> Subscriptions

Click on create subscription and fill necessary info then save and activate the Subscription items. Create three Subscription items (weekly,monthly,yearly) and give them id “s1”, “s2”, “s3” respectively.

Subscription option includes Free Trail: Disabled, Introductory price: None, Grace Period: None, Resubscribe: Enabled for all.

After creating subscription item will be displayed inside Manage Subscription.

We have used Default Subscription Setting which are as follows

Account hold : Enabled , Pause : Enabled , Subscription restore : Enabled and Free Trail Limit : One Across All Subscriptions.

2. Change package name according to yours.

Change package name (i.e package inapp.purchase.subscription) according to your application package name.

3. Copy base64Key key from Google play console account and paste it inside base64Key variable in code under MainActivity.

For old Play Console Design To get key.

 Go to Google Play Console -> Select your app ->  Development Tools -> Services & APIs.

For new Play Console Design To get key.

 Go to Google Play Console -> Select your app ->  Monetize -> Monetization setup

Then paste that key to String variable base64Key inside MainActivity.

i.e.

For java

static String base64Key = “Add Your Key Here”;

For Kotlin

var base64Key = “Add Your Key Here”

4. Copy created Product/subscription ID’s from Google play console account and paste it inside variable(s) in code under MainActivity. (If you have set extra or changed(different) product ids)

i.e

For Java

static String consumableItem1ID = "c1";
static String consumableItem2ID = "c2";
static String nonConsumableItem1ID = "p1";
static String nonConsumableItem2ID = "p2";
static String subscribeItem1ID = "s1";
static String subscribeItem2ID = "s2";

For kotlin

var consumableItem1ID = "c1"
var consumableItem2ID = "c2"
var nonConsumableItem1ID = "p1"
var nonConsumableItem2ID = "p2"
var subscribeItem1ID = "s1"
var subscribeItem2ID = "s2"

5. Finally upload app inside play store and then test the application.

Note: App must be uploaded to playstore in alpha or production track and must pass the review in order to test In App Purchase/Subscription.

Short Guide

Instruction To use Code

1. Create Product/Subscription ID’s on your Google play console account.

2. Change package name according to yours.

3. Copy base64Key key from Google play console account and paste it inside base64Key variable in code under MainActivity.

4. Copy created Product/subscription ID’s from Google play console account and paste it inside variable(s) in code under MainActivity.

i.e

  • consumableItem1ID
  • nonConsumableItem1ID
  • subscribeItem1ID

5. Upload app inside playstore and then test the application.

Note: App must be uploaded to playstore in alpha or production track and must pass the review in order to test In App Purchase/Subscription.

Extra Info

For any query feel free to contact us at [email protected] or whatsapp us at +92 3083941692

In-app product types

Google Play Billing can be used to sell the following types of in-app products:

1)  One-time products: An in-app product requiring a single, non-recurring charge to the user’s form of payment. Additional game levels, premium loot boxes, and media files are examples of one-time products. The Google Play Console refers to one-time products as managed products, and the Google Play Billing library calls them “INAPP”.

Google Play Billing supports the following types of one-time products:

  • Non-consumable one-time products are products that provide a permanent effect, such as a premium upgrade. To avoid users from repurchasing these products, you shouldn’t indicate them as being consumed. Same User can not purchase same product again.
  • Consumable one-time products are products that provide temporary benefits and can be repurchased, such as additional in-game currency or extra game lives. To make a consumable one-time product available for purchase again, you need to send a consumption request to Google Play. Same User can purchase same product again.

2)  Subscriptions: An in-app product requiring a recurring charge to the user’s form of payment. Online service is example of subscription. The Google Play Billing Library calls these “SUBS”. User charged periodically for a product/service Either (Weekly, Monthly, Yearly).

FAQ

Q1. What are pre requirements to use this template app?

You need Google Play Console Account to add in app products inside play console and android application (built in java or kotlin) to add those in app product in your app.
This Template App’s Source Code can be used to add in product(s) in your android application.

Q2. What programming language used in this template app?

Template app Source Code is written in two programming languages (Java and kotlin). You can use either java or kotlin according to your requirement.

Q3. What Version of Android Google Play Billing Library template is using?

Template is using Latest Android Google Play Billing Library Version 5.

Q4. Can I get only Separate Module or as well as whole modules depend upon my requirement?

Yes you can get separate module for either (consumable or non consumable or subscription product only). As well as whole modules (includes all) according to your requirements.

In Android Application there is option to choose and on Fiverr & Upwork you can request.

Note: Module with Fetching Price of each item from play console and displaying it on textview is also available. Contact us at [email protected] for any query.

Screen Shoots

Q5. What security verification method template app is using for purchase?

Template app is using client side verification via base64 key from play account to verify purchase token from google play store. Every time on app launch purchase status is checked and verified from google play store and then updated status is saved in application’s shared preference.

Sample Demo Video

Please Subscribe Youtube| Like Facebook | Follow Twitter


Leave a Reply

Your email address will not be published. Required fields are marked *