Skip to content

Latest commit

 

History

History
39 lines (34 loc) · 2.23 KB

File metadata and controls

39 lines (34 loc) · 2.23 KB

Android_Billing_v4up_PurchaseManager

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.

Preparing:

  • 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:
    allprojects {
      repositories {
        ...
        maven { url 'https://jitpack.io' }
      }
    }
    
    to the app build.gradle:
    dependencies {
          implementation 'com.github.Almaren:Android_Billing_v4up_PurchaseManager:1.0.1'
    }
    

How to use:

All methods of PurchaseManager must be called from the main ui thread.

  1. Edit PurchaseType enum class. The enum value names must be exactly as defined in Google Play Console in app products names.
  2. 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.
  3. Call onResume() from Activity.onResume()
  4. Call dispose() from Activity.onDestroy()
  5. IAP methods: getItemPrices() and purchaseItem(itemType: PurchaseType)