-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Sumeet Rukeja edited this page Jun 11, 2021
·
7 revisions
EasyIAP is an Android library backed with power of Kotlin coroutines to handle In-App purchases with minimal code.
- Written in Kotlin
- No boilerplate code
- Easy initialisation
- Supports InApp & Subscription products
- Simple configuration for consumable products
- Leverages Kotlin coroutines & flow
- Add the JitPack repository to your project level build.gradle file.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the library dependency in your app level build.gradle file.
dependencies {
implementation 'com.github.smokelaboratory:easy-iap:2.0.0'
}
val easyIapConnector = EasyIapConnector(context)
.enableAutoAcknowledge(
consumableSkuList = listOf("<sku>"),
subscriptionSkuList = listOf("<sku>")
)
/**
* add base64 key to enable client-side purchase verification. for security reasons, it should be handled at server side
*/
.setEncodedBase64Key("<key>")
.connect()
easyIapConnector.getIapListener { iapErrorFlow, iapPurchaseResultFlow ->
lifecycleScope.launch {
iapErrorFlow.collect {
Log.d(tag, "Error => ${it.responseCode} : ${it.debugMessage}")
}
}
lifecycleScope.launch {
iapPurchaseResultFlow.collect {
if (it.first.responseCode == OK)
Log.d(tag, "Purchase => ${it.second}")
else
Log.d(
tag,
"Acknowledgement error => ${it.first.responseCode} : ${it.first.debugMessage}"
)
}
}
}
/**
* in-app products
*/
easyIapConnector.getInAppProducts(listOf("<sku>"))
/**
* subscriptions
*/
easyIapConnector.getSubscriptionProducts(listOf("<sku>"))
easyIapConnector.purchaseProduct(activity, <sku>)
easyIapConnector.acknowledgePurchase(purchase, <skuType>)
Copyright © 2021 smokelaboratory
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.