In App Purchase - Android Setup
An in-app purchase (or IAP) allows developers to charge users for specific functionality or content while using an app. Implementing IAPs is particularly compelling for several reasons:
It’s an extra way to earn money, in addition to simply selling the app for a fee upfront. Some users are willing to spend a lot more on extra content or features.
An app can be offered for free, which makes it a no-brainer download for most people. Free apps will typically get many more downloads than paid apps. If users enjoy the app, then they can purchase more content or functionality later.
You can display advertisements to the user in a free app with an option to remove them by purchasing an IAP.
Following the initial release of an app, new paid content can be added to the same app instead of having to develop a brand new app to earn more money.
You can use Google Play to sell the following types of products:
One-time products: A one-time product is a product that users can purchase with a single, non-recurring charge to the user's form of payment. Examples of one-time products include additional game levels, premium loot boxes, and media files. One-time products are either consumable or non-consumable.
Consumable product: A consumable product is one that a user consumes to receive in-game content. For example, a user might purchase an in-game currency product such as a stack of coins. When the user consumes the product, your app then dispenses a fixed number of coins to the user, and the purchased stack of coins product is no longer available. Consumable products can be purchased multiple times.
Non-consumable product: A non-consumable product is a product that is purchased once and provides a permanent benefit. Once purchased, these products are permanently associated with the user's Google account. Examples of non-consumable products include premium upgrades and level packs.
Subscription: A subscription is a set of benefits that users can access during a stated time period. You can have multiple subscriptions within the same app, either to represent entirely different benefits (for example, a streaming video app could have separate “news” and “sports” subscriptions), or different tiers of a single set of benefits (for example, a cloud storage app could have 100 GB, 1 TB, and 10 TB subscriptions).
Users gain access (or entitlement) to a subscription by purchasing a base plan or offer, either in your app or on Google Play.
Make sure that you have set up your android app on Google PlayStore.
To integrate the in-app-purchase for your android app you can just follow the steps below
Add products in play console
Steps for adding one-time purchases
-
Go to the App Dashboard and inside the "Monetise" section you’ll find options for adding "In-app products".
-
Tap on In-app products and then click on create product. Fill the details and we will need this product id later.
-
Set price and then apply prices. You’ve successfully added a one time product.
Steps for adding subscriptions
-
Go to the App Dashboard and inside the "Monetise" section you’ll find options for adding "Subscriptions".
-
Then click on create subscription and fill details, we will need this product id later.
-
Then find base plans and offers by scrolling a bit. You can add multiple base plans.
-
Fill in the relevant details
-
Set price and select countries
-
Click on set price and then after entering amount tap on update
Then click on "Save" and then "Activate" the plan.
You have successfully added your one base plan. You can have multiple base plans in a single subscription. You can add offers to each base plan by clicking on add offer.
Creating a user guide for implementing in-app purchases (IAP) in an Android app can help developers understand the process and effectively integrate it into their applications. Here's a draft for such a guide:
Implementing In-App Purchases in Your Android App
In-app purchases (IAP) enable you to offer digital content or features within your Android application. Whether it's unlocking premium features, purchasing virtual goods, or subscribing to content, implementing in-app purchases can enhance the monetization and user experience of your app.
This guide will walk you through the steps to set up in-app purchases in your Android app and explain how to initiate purchases and query user purchases using JavaScript.
Setting Up In-App Purchases
- Google Developer Account Setup:
- If you haven't already, set up in-app purchases in your Google Developer account. Follow the guidelines provided by Google to configure your app's billing system.
Initiating In-App Purchases
Plain JS Method
window.WTN.inAppPurchase({
productId: 'Product Id of IAP',
productType: 'Product Type of IAP',
isConsumable: true or false,
callback: function(data) {
var receiptData = data.receiptData;
if (data.isSuccess) {
// Handle successful purchase
}
}
});
ES6+ Method
import { inAppPurchase } from "webtonative/InAppPurchase"
inAppPurchase({
productId: 'Product Id of IAP',
productType: 'Product Type of IAP',
isConsumable: true or false,
callback: function(data) {
var receiptData = data.receiptData;
if (data.isSuccess) {
// Handle successful purchase
}
}
});
Querying User Purchases
Plain JS Method
window.WTN.getAllPurchases({
callback: function(data) {
var receiptData = data.receiptData;
if (data.isSuccess) {
// Handle successful purchase query
}
}
});
ES6+ Method
import { getAllPurchases } from "webtonative/InAppPurchase"
getAllPurchases({
callback: function(data) {
var purchaseData = data.purchaseData;
// Handle purchase data retrieval
}
});
Understanding Parameters
- productId: The unique identifier for the product, as defined in your Google Developer Console.
- productType: Specifies whether the product is a one-time purchase ('INAPP') or a subscription ('SUBS').
- isConsumable: Indicates whether the product is consumable (can be purchased multiple times) or non-consumable (can be purchased only once).
- callback: A function to handle the response data from the in-app purchase or purchase query.
Conclusion
Integrating in-app purchases into your Android app can unlock new revenue streams and enhance user engagement. By following the steps outlined in this guide, you can seamlessly implement in-app purchases and provide users with a smooth purchasing experience.
For more detailed documentation and troubleshooting, refer to the official Android developer resources and Google Play Billing documentation.