| Start |
|---|
| Consumable In-app Purchases Consumable Managed Products are products that can be bought multiple times such as in-game currency, game lives, power-ups, etc. In this example, we are going to implement 4 different consumable managed products Steps in summary:
Step 1:First of all, we will need to add the AIDL file to your project as clearly explained in Google Documentation here (opens new window).
Step 2:After adding the AIDL file, add BILLING permission in Step 3:Generate a signed apk, and upload it to Google Developers Console. This is required so that we can start defining our in-app products there. Step 4:Define all your products with different productID, and set a price to each one of them. There are 2 types of products (Managed Products and Subscriptions). As we already said, we are going to implement 4 different consumable managed products Step 5:After doing all the steps above, you are now ready to start implementing the code itself in your own activity. MainActivity: Step 6:After implementing the code, you can test it by deploying your apk to beta/alpha channel, and let other users test the code for you. However, real in-app purchases can't be made while in testing mode. You have to publish your app/game first to Play Store so that all the products are fully activated. More info on testing In-app Billing can be found here (opens new window). |
| (Third party) In-App v3 Library Step 1: First of all follow these two steps to add in app functionality : 1. Add the library using : 2. Add permission in manifest file. Step 2: Initialise your billing processor: and implement Billing Handler : BillingProcessor.IBillingHandler which contains 4 methods : a. onBillingInitialized(); b. onProductPurchased(String productId, TransactionDetails details) : This is where you need to handle actions to be performed after successful purchase c. onBillingError(int errorCode, Throwable error) : Handle any error occurred during purchase process d. onPurchaseHistoryRestored() : For restoring in app purchases Step 3: How to purchase a product. To purchase a managed product : And to Purchase a subscription : Step 4 : Consuming a product. To consume a product simply call consumePurchase method. bp.consumePurchase("YOUR PRODUCT ID FROM GOOGLE PLAY CONSOLE HERE"); For other methods related to in app visit github (opens new window) |
Read Article
https://develop.horje.com/learn/1434/reference