3. Types of In-App Billing
• Standard in-app products (one-time billing)
• Subscriptions, (recurring, automated billing)
4. 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.
5. 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
account.
8. Add Your Application to the Developer
Console
• In the Services & APIs tab, find and make a
note of the public license key that Google Play
generated for your application
9. 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
project.
• This Android Interface Definition Language
(AIDL) file defines the interface to the Google
Play service.
11. 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:
• <uses-permission
android:name="com.android.vending.BILLING
" />
12. 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.
14. 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.
15.
16. • Complete the form to specify the product
information such as the item’s unique product
ID (also called its SKU), description, price, and
country availability
• Once you have completed the form, activate
the product so that your application can
purchase.
17.
18. 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)
19.
20. 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.
21.
22. Query Purchased Items
• To retrieve the user’s purchases from your
app, queryInventoryAsync(QueryInventoryFini
shedListener) on your IabHelper instance.
23. 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
consumed.
25. Test with Static Responses
• Test your In-app Billing application with static
responses by using Google Play’s reserved
product IDs.
• There are four reserved product IDs for
testing static In-app Billing responses:
1.
2.
3.
4.
android.test.purchased
android.test.canceled
android.test.refunded
android.test.item_unavailable
26. 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.
27. • 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
account.
28. 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
purchase requests.
• Protect your Google Play public key.
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/.