aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-30 22:50:58 -0700
committerAllan Wang <me@allanwang.ca>2017-06-30 22:50:58 -0700
commitd24ee840005af340b1decc2ed9863a742e78a4e1 (patch)
tree1bacf1433a3c0fe49a17d808845e46ab6423b37d /app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt
parentfb4f71ef83d1bfbd3ae89701dc17f6ae31a35eb7 (diff)
downloadfrost-d24ee840005af340b1decc2ed9863a742e78a4e1.tar.gz
frost-d24ee840005af340b1decc2ed9863a742e78a4e1.tar.bz2
frost-d24ee840005af340b1decc2ed9863a742e78a4e1.zip
Set up billing cyclev1.0
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt19
1 files changed, 11 insertions, 8 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt
index 431ba0b6..ec63cce3 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt
@@ -34,6 +34,13 @@ object IAB {
}
}
}
+
+ /**
+ * If user has pro, check if it's valid and destroy the helper
+ */
+ fun validatePro(activity: Activity) {
+
+ }
}
private const val FROST_PRO = "frost_pro"
@@ -68,19 +75,15 @@ fun Activity.openPlayPurchase(key: String, code: Int) {
IAB.helper!!.queryInventoryAsync {
res, inv ->
if (res.isFailure) return@queryInventoryAsync playStoreGenericError("Query res error")
- if (inv == null) return@queryInventoryAsync playStoreGenericError("Empty inventory")
+ if (inv?.getSkuDetails(key) != null) return@queryInventoryAsync playStoreAlreadyPurchased(key)
L.d("IAB: inventory ${inv.allOwnedSkus}")
- val donation = inv.getSkuDetails(key) ?: return@queryInventoryAsync playStoreGenericError("Donation null")
- IAB.helper!!.launchPurchaseFlow(this@openPlayPurchase, donation.sku, code) {
+ IAB.helper!!.launchPurchaseFlow(this@openPlayPurchase, key, code) {
result, _ ->
- if (result.isSuccess) materialDialogThemed {
- title(R.string.play_thank_you)
- content(R.string.play_purchased_pro)
- positiveText(R.string.kau_ok)
- } else playStoreGenericError("Result: ${result.message}")
+ if (result.isSuccess) playStorePurchasedSuccessfully(key)
frostAnswers {
logPurchase(PurchaseEvent()
.putItemId(key)
+ .putCustomAttribute("result", result.message)
.putSuccess(result.isSuccess))
}
}