Skip to content

Commit

Permalink
Merge branch 'release/2.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mvojtkovszky committed Apr 8, 2024
2 parents 8821c20 + aaf60f7 commit 63f70d6
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 18 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## 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
* 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`
* fix issue where purchase will still be present even if not included in the result from additional call to `BillingHelper.initQueryOwnedPurchases`
Expand Down Expand Up @@ -103,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
* bump Kotlin to 1.4.10
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.2.0).
Handles client connection, querying product details, owned purchases, different purchase types,
acknowledging purchases, verify purchase signatures etc.

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion billinghelper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion billinghelper/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ buildTypes=debug,release
groupId=com.github.mvojtkovszky
artifactId=BillingHelper
moduleId=billinghelper
versionName=2.3.0
versionName=2.4.0
Original file line number Diff line number Diff line change
Expand Up @@ -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].
*/
Expand All @@ -38,22 +39,30 @@ 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
) {
companion object {
private const val TAG = "BillingHelper"
}

// billing client
private var billingClient: BillingClient
// represents list of all currently owned purchases
private val purchases = mutableListOf<Purchase>()
// represents details of all available sku details
private val productDetailsList = mutableListOf<ProductDetails>()
// callback listeners
private val billingListeners = mutableListOf<BillingListener>()

/**
* 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.
*/
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]
Expand Down Expand Up @@ -124,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 {
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -10,7 +10,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.1.4'
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"
}
Expand Down
2 changes: 1 addition & 1 deletion gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jul 28 12:37:27 CEST 2023
#Fri Apr 05 14:06:29 CEST 2024
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.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 63f70d6

Please sign in to comment.