Android Billing v4+ implementation for non consumable products. Written in Kotlin using coroutines. Serverless verifying approval method of a purchased token. No UI sample. Android IAP Library.
An official integration. And a sample.
My implemenation is much easy to use, you can adapt it also for subscriptions and for consumable products. PurchaseManager.kt is well documented.
- First put your developer Base64-encoded RSA public key (from Google Play Console: your app -> monetization setup) in: /local.properties/base64EncodedPublicKey=YOUR_KEY
- In order to test billing - Release your application with an integrated billing library but not yet implemented to any testing track (internal testing is better). Just adding 'com.android.billingclient:billing:4+' is enough at this stage.
- For debugging testing: in Google Developers Console (Not Play Console) add your debug key SHA1.
- In Google Play Console create a testers group.
- Add to your project build.gradle:
to the app build.gradle:
allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
dependencies { implementation 'com.github.Almaren:Android_Billing_v4up_PurchaseManager:1.0.1' }
All methods of PurchaseManager must be called from the main ui thread.
- Edit PurchaseType enum class. The enum value names must be exactly as defined in Google Play Console in app products names.
- Call init(activity: Activity, listener: PurchaseListener) from Activity.onCreate(..). Via PurchaseListener you will receive available products to purchase, a purchased items, a result from the recent purchase.
- Call onResume() from Activity.onResume()
- Call dispose() from Activity.onDestroy()
- IAP methods: getItemPrices() and purchaseItem(itemType: PurchaseType)