In-app Billing is a Google Play service that lets you sell digital content from inside your applications. You can use the service to sell a wide range of content, including downloadable content such as media files or photos, virtual content such as game levels or potions, premium services and features, and more.
Open the Android SDK Manager.In the SDK Manager, expand the Extras section.Select Google Play Billing Library.Click Install packages to complete the download.The sample files will be installed to <sdk>/extras/google/play_billing/.
Monetize your app_with_google_subscriptions_v3_services_intuit
Monetize your app with Google
Subscriptions V3 services:
Benefits and best practices
Types of In-App Billing
• Standard in-app products (one-time billing)
• Subscriptions, (recurring, automated billing)
Its Hassle Free
• Google Play handles all credit card related
activities for the user of your app.
• Stores the card details along with Google
Wallet . No need to enter the data again
during the time of purchase.
• Charges the app user’s card and credits your
Google Merchant account.
Its Free for developers
• Any application that you publish through
Google Play can implement In-app Billing.
• No special account or registration is required
other than a Google Play Developer Console
account and a Google Wallet merchant
Download the Sample
• The sample files will be installed to
Add Your Application to the Developer
• In the Services & APIs tab, find and make a
note of the public license key that Google Play
generated for your application
Add the In-app Billing Library
• To use the In-app Billing Version 3
features, you must add the
IInAppBillingService.aidl file to your Android
• This Android Interface Definition Language
(AIDL) file defines the interface to the Google
Set the Billing Permission
• To have permission to communicate request
and response messages to the Google Play’s
billing service, add this line in your
AndroidManifest.xml manifest file:
Initiate a Connection with Google Play
• You must bind your Activity to Google
Play’s In-app Billing service to send Inapp Billing requests to Google Play
from your application.
Specify In-app Products in Google Play
• Build a signed APK file for your In-app Billing
application. Make sure that you are using your
final (not debug) certificate and private key to
sign your application.
• Click on the APK tab then click on Upload new
APK. Don’t publish the app yet!
• Navigate to the uploaded app listing, and click
on In-app Products.
• Complete the form to specify the product
information such as the item’s unique product
ID (also called its SKU), description, price, and
• Once you have completed the form, activate
the product so that your application can
Query Items Available for Purchase
• You can query Google Play to
programmatically retrieve details of the in-app
products that are associated with your
application (such as the product’s
price, title, description, and type)
Purchase an Item
• To start a purchase request from your
app, call launchPurchaseFlow(Activity, String,
int, OnIabPurchaseFinishedListener, String) o
n your IabHelper instance. You must make
this call from the main thread of your Activity.
Query Purchased Items
• To retrieve the user’s purchases from your
shedListener) on your IabHelper instance.
Consume a Purchase
• You must send a consumption request for the
item before Google Play makes it available for
purchase again. All managed in-app products
are consumable. Subscriptions need not be
Test with Static Responses
• Test your In-app Billing application with static
responses by using Google Play’s reserved
• There are four reserved product IDs for
testing static In-app Billing responses:
Test with Your Own Product IDs
• In the Developer Console, add one or more
tester accounts to the developer account that
you are using to publish your application.
– Click Settings > Account details, then in
the License Testing section, add the Google
email addresses for your tester accounts.
• Build a signed and final (not debug) certificate
APK file for your In-app Billing.
• Make sure that you have uploaded the signed
APK for your application to the Developer
Console.You don't need to publish the
application on Google Play to test
• Install the APK file to your physical test device
by using the adb tool.
• Login to the test device by using a tester
Important Security Considerations
• Perform signature verification tasks on a
server so that this makes it difficult for
attackers to break the verification process by
reverse engineering your .apk file.
• Modify all sample application code
• Set the developer payload string when making
• Protect your Google Play public key.