From 17fe1f572ef6e9a0fd7491f1dce93f29db3f39f0 Mon Sep 17 00:00:00 2001 From: Marcel Vojtkovszky Date: Thu, 7 Dec 2023 12:14:05 +0100 Subject: [PATCH 1/8] bump version to 2.3.1-SNAPSHOT --- billinghelper/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/billinghelper/gradle.properties b/billinghelper/gradle.properties index 29ae4d6..a7efe56 100644 --- a/billinghelper/gradle.properties +++ b/billinghelper/gradle.properties @@ -3,4 +3,4 @@ buildTypes=debug,release groupId=com.github.mvojtkovszky artifactId=BillingHelper moduleId=billinghelper -versionName=2.3.0 \ No newline at end of file +versionName=2.3.1-SNAPSHOT \ No newline at end of file From d8f98025f476c191ef86dbeb6cc81df54ce598fa Mon Sep 17 00:00:00 2001 From: Marcel Vojtkovszky Date: Sat, 9 Dec 2023 16:07:25 +0100 Subject: [PATCH 2/8] * BillingHelper.billingClient is now public * bump Gradle plugin to 8.2.0 --- CHANGELOG.md | 4 ++++ README.md | 4 +++- .../com/vojtkovszky/billinghelper/BillingHelper.kt | 10 ++++++++-- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d166ec2..f0b3d70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 2.3.1 (TBD) +* `BillingHelper.billingClient` is now public. +* bump Gradle plugin to 8.2.0 + ## 2.3.0 (2023-12-07) * rename param from "skuNames" to "productNames" for `BillingHelper.isPurchasedAnyOf` * fix issue where purchase will still be present even if not included in the result from additional call to `BillingHelper.initQueryOwnedPurchases` diff --git a/README.md b/README.md index 805d6af..bcae035 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # BillingHelper -Wrapper around Google Play Billing Library (v6.0.1), simplifying its use. +Simplify the use of Google Play Billing Library (v6.1.0). Handles client connection, querying product details, owned purchases, different purchase types, acknowledging purchases, verify purchase signatures etc. @@ -58,6 +58,8 @@ var queryOwnedPurchasesOnConnected: Boolean var autoAcknowledgePurchases: Boolean var enableLogging: Boolean +var billingClient: BillingClient + private set val billingReady: Boolean val connectionState: Int var purchasesQueried: Boolean diff --git a/billinghelper/src/main/kotlin/com/vojtkovszky/billinghelper/BillingHelper.kt b/billinghelper/src/main/kotlin/com/vojtkovszky/billinghelper/BillingHelper.kt index 8adc611..f7b223e 100644 --- a/billinghelper/src/main/kotlin/com/vojtkovszky/billinghelper/BillingHelper.kt +++ b/billinghelper/src/main/kotlin/com/vojtkovszky/billinghelper/BillingHelper.kt @@ -45,8 +45,6 @@ class BillingHelper( private const val TAG = "BillingHelper" } - // billing client - private var billingClient: BillingClient // represents list of all currently owned purchases private val purchases = mutableListOf() // represents details of all available sku details @@ -54,6 +52,14 @@ class BillingHelper( // callback listeners private val billingListeners = mutableListOf() + /** + * Reference to the main [BillingClient]. + * Note that most logic for the client is handled by the helper implicitly already, so ideally + * only use this to access additional functionalities like alternative billing or use choice billing. + */ + var billingClient: BillingClient + private set + // keep track if we've actually queried purchases and sku details /** * Determine if billingClient is ready. Based on [BillingClient.isReady] diff --git a/build.gradle b/build.gradle index 7f82e04..e658112 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:8.1.4' + classpath 'com.android.tools.build:gradle:8.2.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e3ad95f..90f79e9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Jul 28 12:37:27 CEST 2023 +#Sat Dec 09 15:54:42 CET 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From ad1f25c9b387be722013d8c38b8afa87f3909213 Mon Sep 17 00:00:00 2001 From: Marcel Vojtkovszky Date: Fri, 5 Apr 2024 14:32:48 +0200 Subject: [PATCH 3/8] add enableAlternativeBillingOnly and enableExternalOffer properties to constructor. --- .../billinghelper/BillingHelper.kt | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/billinghelper/src/main/kotlin/com/vojtkovszky/billinghelper/BillingHelper.kt b/billinghelper/src/main/kotlin/com/vojtkovszky/billinghelper/BillingHelper.kt index f7b223e..09934cd 100644 --- a/billinghelper/src/main/kotlin/com/vojtkovszky/billinghelper/BillingHelper.kt +++ b/billinghelper/src/main/kotlin/com/vojtkovszky/billinghelper/BillingHelper.kt @@ -15,16 +15,17 @@ import com.android.billingclient.api.* * @param context required to build [BillingClient]. * @param productInAppPurchases list of product names of in app purchases supported by the app. * @param productSubscriptions list of product names of subscriptions supported by the app. - * @param startConnectionImmediately set whether [initClientConnection] should be called automatically - * when [BillingHelper] is initialized. + * @param startConnectionImmediately set whether [initClientConnection] should be called automatically when [BillingHelper] is initialized. * @param key app's license key. If provided, it will be used to verify purchase signatures. - * @param querySkuDetailsOnConnected set whether [initQueryProductDetails] should be called automatically - * right after client connects (when [initClientConnection] succeeds). - * @param queryOwnedPurchasesOnConnected set whether [initQueryOwnedPurchases] should be called automatically - * right after client connects (when [initClientConnection] succeeds). + * @param querySkuDetailsOnConnected set whether [initQueryProductDetails] should be called automatically right after client connects (when [initClientConnection] succeeds). + * @param queryOwnedPurchasesOnConnected set whether [initQueryOwnedPurchases] should be called automatically right after client connects (when [initClientConnection] succeeds). * @param autoAcknowledgePurchases All purchases require acknowledgement. * By default, this is handled automatically every time state of purchases changes. * If set to [Boolean.false], make sure [acknowledgePurchases] is used manually. + * @param enableAlternativeBillingOnly build client with [BillingClient.Builder.enableAlternativeBillingOnly] + * For more details see [https://developer.android.com/reference/com/android/billingclient/api/BillingClient.Builder#enableAlternativeBillingOnly()] + * @param enableExternalOffer build client with [BillingClient.Builder.enableExternalOffer] + * For more details see [https://developer.android.com/reference/com/android/billingclient/api/BillingClient.Builder#enableExternalOffer()] * @param enableLogging toggle output of status logs * @param billingListener default listener that'll be added as [addBillingListener]. */ @@ -38,6 +39,8 @@ class BillingHelper( var querySkuDetailsOnConnected: Boolean = true, var queryOwnedPurchasesOnConnected: Boolean = true, var autoAcknowledgePurchases: Boolean = true, + enableAlternativeBillingOnly: Boolean = false, + enableExternalOffer: Boolean = false, var enableLogging: Boolean = false, billingListener: BillingListener? = null ) { @@ -53,7 +56,7 @@ class BillingHelper( private val billingListeners = mutableListOf() /** - * Reference to the main [BillingClient]. + * Reference to the main [BillingClient]. Initialized in [BillingHelper] init. * Note that most logic for the client is handled by the helper implicitly already, so ideally * only use this to access additional functionalities like alternative billing or use choice billing. */ @@ -130,6 +133,14 @@ class BillingHelper( // build client billingClient = BillingClient.newBuilder(context) + .apply { + if (enableAlternativeBillingOnly) { + enableAlternativeBillingOnly() + } + if (enableExternalOffer) { + enableExternalOffer() + } + } .enablePendingPurchases() .setListener { billingResult, purchases -> // PurchasesUpdatedListener val billingEvent = when { From bfd0a27c0b05becdb06268b2c9913378fe2150f9 Mon Sep 17 00:00:00 2001 From: Marcel Vojtkovszky Date: Fri, 5 Apr 2024 14:33:23 +0200 Subject: [PATCH 4/8] bump billing client to 6.2.0 --- billinghelper/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/billinghelper/build.gradle b/billinghelper/build.gradle index 29d5fd5..eb6ec52 100644 --- a/billinghelper/build.gradle +++ b/billinghelper/build.gradle @@ -43,7 +43,7 @@ dependencies { https://developer.android.com/google/play/billing/billing_library_overview https://developer.android.com/google/play/billing/release-notes */ - api 'com.android.billingclient:billing-ktx:6.1.0' + api 'com.android.billingclient:billing-ktx:6.2.0' /* https://developer.android.com/jetpack/androidx/releases/test */ testImplementation 'junit:junit:4.13.2' From 0abc69cfcdd1a2a1318353c1ad273c977dcdb5b4 Mon Sep 17 00:00:00 2001 From: Marcel Vojtkovszky Date: Fri, 5 Apr 2024 14:33:57 +0200 Subject: [PATCH 5/8] bump gradle plugin to 8.3.1 * bump kotlin to 1.9.23 --- build.gradle | 6 +++--- gradle-mvn-push.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index e658112..4f74651 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ buildscript { ext { - kotlin_version = "1.9.10" /* https://github.com/JetBrains/kotlin */ - dokka_version = '1.9.10' /* https://github.com/Kotlin/dokka/releases */ + kotlin_version = "1.9.23" /* https://github.com/JetBrains/kotlin */ + dokka_version = '1.9.20' /* https://github.com/Kotlin/dokka/releases */ } repositories { @@ -10,7 +10,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:8.2.0' + classpath 'com.android.tools.build:gradle:8.3.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" } diff --git a/gradle-mvn-push.gradle b/gradle-mvn-push.gradle index a04f17c..db2a114 100644 --- a/gradle-mvn-push.gradle +++ b/gradle-mvn-push.gradle @@ -3,7 +3,7 @@ apply plugin: 'maven-publish' tasks.register('javadocJar', Jar) { dependsOn dokkaJavadoc archiveClassifier.set('javadoc') - from "$buildDir/dokka/javadoc" + from "${rootProject.layout.buildDirectory}/dokka/javadoc" } afterEvaluate { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 90f79e9..4799d4e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Dec 09 15:54:42 CET 2023 +#Fri Apr 05 14:06:29 CEST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 9e640544661c8fd2f5cf7c14e0de3d05ddedbf07 Mon Sep 17 00:00:00 2001 From: Marcel Vojtkovszky Date: Fri, 5 Apr 2024 14:34:28 +0200 Subject: [PATCH 6/8] bump version to 2.4.0-SNAPSHOT and update changelog --- CHANGELOG.md | 6 ++++-- billinghelper/gradle.properties | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0b3d70..e490925 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ # CHANGELOG -## 2.3.1 (TBD) +## 2.4.0 (TBD) * `BillingHelper.billingClient` is now public. -* bump Gradle plugin to 8.2.0 +* Add `enableAlternativeBillingOnly` and `enableExternalOffer` properties to constructor. +* bump Google Billing to 6.2.0 +* bump Gradle plugin to 8.3.1, Kotlin to 1.9.23 ## 2.3.0 (2023-12-07) * rename param from "skuNames" to "productNames" for `BillingHelper.isPurchasedAnyOf` diff --git a/billinghelper/gradle.properties b/billinghelper/gradle.properties index a7efe56..6adbc49 100644 --- a/billinghelper/gradle.properties +++ b/billinghelper/gradle.properties @@ -3,4 +3,4 @@ buildTypes=debug,release groupId=com.github.mvojtkovszky artifactId=BillingHelper moduleId=billinghelper -versionName=2.3.1-SNAPSHOT \ No newline at end of file +versionName=2.4.0-SNAPSHOT \ No newline at end of file From 3b48cac4f68cd252abe46fe2b00c8777882e4165 Mon Sep 17 00:00:00 2001 From: Marcel Vojtkovszky Date: Fri, 5 Apr 2024 14:55:00 +0200 Subject: [PATCH 7/8] prepare 2.4.0 --- CHANGELOG.md | 2 +- billinghelper/gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e490925..fd10ce5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # CHANGELOG -## 2.4.0 (TBD) +## 2.4.0 (2024-04-05) * `BillingHelper.billingClient` is now public. * Add `enableAlternativeBillingOnly` and `enableExternalOffer` properties to constructor. * bump Google Billing to 6.2.0 diff --git a/billinghelper/gradle.properties b/billinghelper/gradle.properties index 6adbc49..0502813 100644 --- a/billinghelper/gradle.properties +++ b/billinghelper/gradle.properties @@ -3,4 +3,4 @@ buildTypes=debug,release groupId=com.github.mvojtkovszky artifactId=BillingHelper moduleId=billinghelper -versionName=2.4.0-SNAPSHOT \ No newline at end of file +versionName=2.4.0 \ No newline at end of file From aaf60f7c58640f27dc290ddc94ae9e75315fa999 Mon Sep 17 00:00:00 2001 From: Marcel Vojtkovszky Date: Mon, 8 Apr 2024 11:21:25 +0200 Subject: [PATCH 8/8] update changelog and readme --- CHANGELOG.md | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd10ce5..034746e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # CHANGELOG -## 2.4.0 (2024-04-05) +## 2.4.0 (2024-04-08) * `BillingHelper.billingClient` is now public. * Add `enableAlternativeBillingOnly` and `enableExternalOffer` properties to constructor. * bump Google Billing to 6.2.0 @@ -109,4 +109,4 @@ * fix bug where cancelled flow gets reported incorrectly * fix invoke listeners in try/catch block * add support for `obfuscatedAccountId`, `obfuscatedProfileId` and `setVrPurchaseFlow -* bump Kotlin to 1.4.10 \ No newline at end of file +* bump Kotlin to 1.4.10 diff --git a/README.md b/README.md index bcae035..b2bee60 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # BillingHelper -Simplify the use of Google Play Billing Library (v6.1.0). +Simplify the use of Google Play Billing Library (v6.2.0). Handles client connection, querying product details, owned purchases, different purchase types, acknowledging purchases, verify purchase signatures etc.