Implementing In-app Billing Android




An Important page to implement in-app purchases in your android app.

Many tutorial in google documentation itself makes it confusing, which one to follow. So I, Framed this page here which include everthing you want.






Note: To see a complete implementation and learn how to test your application, see the Selling In-app Products training class. The training class provides a complete sample In-app Billing application, including convenience classes to handle key tasks that are related to setting up your connection, sending billing requests, processing responses from Google Play, and managing background threading so that you can make In-app Billing calls from your main activity.
Before you start, read the In-app Billing Overview to familiarize yourself with concepts that make it easier for you to implement In-app Billing.
Complete these steps to implement In-app Billing in your application:
  1. Add the In-app Billing library to your project.
  2. Update your AndroidManifest.xml file.
  3. Create a ServiceConnection and bind it to the IInAppBillingService.
  4. Send In-app Billing requests from your application to IInAppBillingService.
  5. Handle In-app Billing responses from Google Play.

Adding the AIDL file to your project


The IInAppBillingService.aidl is an Android Interface Definition Language (AIDL) file that defines the interface to the In-app Billing Version 3 service. You can use this interface to make billing requests by invoking interprocess communication (IPC) method calls.
You can find the IInAppBillingService.aidl file in the Trivial Drive sample app. To add the In-app Billing library to your project, follow these instructions:
  1. In Android Studio, import the IInAppBillingService.aidl file to your project as described in the following steps:
    1. Create a directory named aidl under src/main.
    2. Add a new package com.android.vending.billing in this directory.
    3. Import the IInAppBillingService.aidl file into this package.
  2. Build your application. You should see a generated file named IInAppBillingService.java in the gen/ directory of your project.
  3. Add the helper classes from the util/ directory of the Trivial Drive sample to your project. Remember to change the package name declarations in those files accordingly so that your project compiles.
  4. Updating your app's manifest


    In-app billing relies on the Google Play application, which handles all of the communication between your application and the Google Play server. To use the Google Play application, your application must request the proper permission. You can do this by adding the com.android.vending.BILLINGpermission to your AndroidManifest.xml file. If your application does not declare the In-app Billing permission, but attempts to send billing requests, Google Play refuses the requests and responds with an error.
    To give your app the necessary permission, add this line in the AndroidManifest.xml file:
    <uses-permission android:name="com.android.vending.BILLING" />








Comments

Popular posts from this blog

Failed to sync Gradle project 'MyApp' Error:Unknown host 'services.gradle.org'.

Using Roboto font android

Windows 10 Slow Performance issue fixed !!!