Skip to content

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mvojtkovszky committed Jun 7, 2024
2 parents 63f70d6 + f48759a commit c3a92bc
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 16 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## 3.0.0 (2024-06-07)
* add `´billingBuilderConfig` to `BillingHelper` constructor holding all parameters related to alternative billing and pending purchases support
* move `enableAlternativeBillingOnly` and `enableExternalOffer` to `BillingBuilderConfig`
* bump Google Billing to 7.0.0
* bump Gradle plugin to 8.3.2, core-ktx to 1.13.1
* `minSdkVersion` has been raised from 19 to 21

## 2.4.0 (2024-04-08)
* `BillingHelper.billingClient` is now public.
* Add `enableAlternativeBillingOnly` and `enableExternalOffer` properties to constructor.
Expand Down
4 changes: 2 additions & 2 deletions billinghelper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ android {

dependencies {
/* https://developer.android.com/jetpack/androidx/releases/core */
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.core:core-ktx:1.13.1'
/*
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.2.0'
api 'com.android.billingclient:billing-ktx:7.0.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.4.0
versionName=3.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.vojtkovszky.billinghelper

import com.android.billingclient.api.BillingClient
import com.android.billingclient.api.UserChoiceBillingListener

/**
* Configuration used when building [BillingClient].
*
* @param enableAlternativeBillingOnly build client with [BillingClient.Builder.enableAlternativeBillingOnly]
* For more info see [https://developer.android.com/reference/com/android/billingclient/api/BillingClient.Builder#enableAlternativeBillingOnly()]
* @param enableExternalOffer build client with [BillingClient.Builder.enableExternalOffer]
* For more info see [https://developer.android.com/reference/com/android/billingclient/api/BillingClient.Builder#enableExternalOffer()]
* @param enablePendingPurchasesOneTimeProducts build client [BillingClient.Builder.enablePendingPurchases] with pending purchase for one-time products enabled
* For more info see [https://developer.android.com/reference/com/android/billingclient/api/PendingPurchasesParams.Builder#enableOneTimeProducts()]
* @param enablePendingPurchasesPrepaidPlans build client [BillingClient.Builder.enablePendingPurchases] with pending purchase for prepaid plans enabled
* For more info see [https://developer.android.com/reference/com/android/billingclient/api/PendingPurchasesParams.Builder#enablePrepaidPlans()]
* @param userChoiceBillingListener build client with [BillingClient.Builder.enableUserChoiceBilling] and provide given listener.
* For more info see [https://developer.android.com/reference/com/android/billingclient/api/UserChoiceBillingListener]
* and [https://support.google.com/googleplay/android-developer/answer/13821247]
*/
class BillingBuilderConfig(
val enableAlternativeBillingOnly: Boolean = false,
val enableExternalOffer: Boolean = false,
val enablePendingPurchasesOneTimeProducts: Boolean = true,
val enablePendingPurchasesPrepaidPlans: Boolean = true,
val userChoiceBillingListener: UserChoiceBillingListener? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@ import com.android.billingclient.api.*
* @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 key app's license key. If provided, it will be used to verify purchase signatures.
* @param billingBuilderConfig additional configuration used when building [BillingClient]. Default covers most common use cases.
* @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 @@ -36,13 +33,12 @@ class BillingHelper(
private val productSubscriptions: List<String>?,
private val startConnectionImmediately: Boolean = true,
private var key: String? = null,
private var billingBuilderConfig: BillingBuilderConfig = BillingBuilderConfig(),
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
billingListener: BillingListener? = null,
) {
companion object {
private const val TAG = "BillingHelper"
Expand Down Expand Up @@ -134,14 +130,27 @@ class BillingHelper(
// build client
billingClient = BillingClient.newBuilder(context)
.apply {
if (enableAlternativeBillingOnly) {
if (billingBuilderConfig.enableAlternativeBillingOnly) {
enableAlternativeBillingOnly()
}
if (enableExternalOffer) {
if (billingBuilderConfig.enableExternalOffer) {
enableExternalOffer()
}
if (billingBuilderConfig.enablePendingPurchasesPrepaidPlans ||
billingBuilderConfig.enablePendingPurchasesOneTimeProducts) {
val pendingPurchasesParams = PendingPurchasesParams.newBuilder()
if (billingBuilderConfig.enablePendingPurchasesPrepaidPlans) {
pendingPurchasesParams.enablePrepaidPlans()
}
if (billingBuilderConfig.enablePendingPurchasesOneTimeProducts) {
pendingPurchasesParams.enableOneTimeProducts()
}
enablePendingPurchases(pendingPurchasesParams.build())
}
billingBuilderConfig.userChoiceBillingListener?.let {
enableUserChoiceBilling(it)
}
}
.enablePendingPurchases()
.setListener { billingResult, purchases -> // PurchasesUpdatedListener
val billingEvent = when {
billingResult.isResponseOk() && purchases != null -> {
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.3.1'
classpath 'com.android.tools.build:gradle:8.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
}
Expand All @@ -24,5 +24,5 @@ allprojects {
}

tasks.register('clean', Delete) {
delete rootProject.buildDir
delete rootProject.layout.buildDirectory
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ kotlin.code.style=official
# base versions
buildToolsVersion=34.0.0
compileSdkVersion=34
minSdkVersion=19
minSdkVersion=21
targetSdkVersion=34
javaVersion=17

0 comments on commit c3a92bc

Please sign in to comment.