Skip to content

Commit

Permalink
Merge branch 'release/3.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mvojtkovszky committed Dec 27, 2024
2 parents 7c7ab63 + 4d1d3bd commit 0d99404
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 53 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# CHANGELOG

## 3.4.0 (2024-12-27)
* add support for purchase history records. New methods and properties:
- `BillingHelper.purchaseHistoryRecordsQueried`, `BillingHelper.initQueryPurchaseHistoryRecords` and `BillingHelper.getPurchaseHistoryRecords`
- `BillingEvent.QUERY_PURCHASES_HISTORY_RECORDS_COMPLETE` and `BillingEvent.QUERY_PURCHASES_HISTORY_RECORDS_FAILED`
- `queryPurchaseHistoryRecordsOnConnected` in `BillingHelper` constructor
* fix `ProductDetails.getFormattedPriceDivided` to cover cases where price is formatted using comma and dot.
* rename `querySkuDetailsOnConnected` to `queryProductDetailsOnConnected`.
* rename `getPurchaseWithProductName` to `getPurchasesWithProductName` as multiple purchases can exist for a single product name.
(f.ex. when updating a subscription). Otherwise `.last()` is the one you're after.
* bump Kotlin to 2.0.21, Gradle plugin to 8.7.3

## 3.3.0 (2024-11-11)
* Added optional `subscriptionPurchaseParams` to `launchPurchaseFlow` method to unify subscription purchase definitions.
Added optional parameters `basePlanId: String?` and `offerId: String?`, which replaced old index parameters.
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class MainActivity: AppCompatActivity(), BillingListener {
// For more configuration options, check BillingHelper constructor parameters.
billing = BillingHelper(
context = this,
productInAppPurchases = listOf("inAppPurchaseSkuName1", "inAppPurchaseSkuName2"),
productSubscriptions = listOf("subscriptionSkuName"),
productInAppPurchases = listOf("inAppPurchaseProductName1", "inAppPurchaseProductName2"),
productSubscriptions = listOf("subscriptionProductName"),
billingListener = this
)
}
Expand All @@ -41,20 +41,22 @@ class MainActivity: AppCompatActivity(), BillingListener {
``` kotlin
fun consumePurchase(purchase: Purchase)
fun endClientConnection()
fun getPurchaseForProductName(productName: String): Purchase?
fun getPurchasesWithProductName(productName: String): List<Purchase>
fun getProductDetails(productName: String): ProductDetails?
fun isPurchased(productName: String): Boolean
fun launchPurchaseFlow(activity: Activity, productName: String)
fun initClientConnection(queryForProductDetailsOnConnected: Boolean, queryForOwnedPurchasesOnConected: Boolean)
fun initQueryOwnedPurchases()
fun initQueryProductDetails()
fun initQueryPurchaseHistoryRecords()
fun acknowledgePurchases(purchases: List<Purchase>)
fun isFeatureSupported(feature: String)
fun addBillingListener(listener: BillingListener)
fun removeBillingListener(listener: BillingListener)

var querySkuDetailsOnConnected: Boolean
var queryProductDetailsOnConnected: Boolean
var queryOwnedPurchasesOnConnected: Boolean
var queryPurchaseHistoryRecordsOnConnected: Boolean
var autoAcknowledgePurchases: Boolean
var enableLogging: Boolean

Expand All @@ -66,6 +68,8 @@ var purchasesQueried: Boolean
private set
var productDetailsQueried: Boolean
private set
var purchaseHistoryRecordsQueried: Boolean
private set
var isConnectionFailure: Boolean
private set
val purchasesPresentable: Boolean
Expand All @@ -81,6 +85,8 @@ enum class BillingEvent {
QUERY_PRODUCT_DETAILS_FAILED,
QUERY_OWNED_PURCHASES_COMPLETE,
QUERY_OWNED_PURCHASES_FAILED,
QUERY_PURCHASES_HISTORY_RECORDS_COMPLETE,
QUERY_PURCHASES_HISTORY_RECORDS_FAILED,
PURCHASE_COMPLETE,
PURCHASE_FAILED,
PURCHASE_CANCELLED,
Expand All @@ -94,8 +100,8 @@ enum class BillingEvent {
<br/>You can also make use of provided `PriceUtil` object to format prices in various ways
``` kotlin
// Get formatted price for a product
val formattedPrice = getProductDetails(yourSkuName).getFormattedPrice() // formattedPrice: "16.80 EUR"
val dividedPrice = getProductDetails(yourSkuName).getFormattedPriceDivided(4) // formattedPrice: "4.20 EUR"
val formattedPrice = getProductDetails(yourProductName).getFormattedPrice() // "16.80 EUR"
val dividedPrice = getProductDetails(yourProductName).getFormattedPriceDivided(4) // "4.20 EUR"
```

## Best practices
Expand Down
1 change: 0 additions & 1 deletion billinghelper/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'org.jetbrains.dokka'
id 'maven-publish'
}

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=3.3.0
versionName=3.4.0
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ enum class BillingEvent {
*/
QUERY_OWNED_PURCHASES_FAILED,

/**
* Success from [BillingClient.queryPurchaseHistory]
*/
QUERY_PURCHASES_HISTORY_RECORDS_COMPLETE,

/**
* Failure from [BillingClient.queryPurchaseHistory]
*/
QUERY_PURCHASES_HISTORY_RECORDS_FAILED,

/**
* Success from [BillingClient.launchBillingFlow]
*/
Expand Down Expand Up @@ -88,7 +98,7 @@ enum class BillingEvent {
val isFailure: Boolean
get() = listOf(
BILLING_CONNECTION_FAILED, QUERY_PRODUCT_DETAILS_FAILED, QUERY_OWNED_PURCHASES_FAILED,
PURCHASE_FAILED, CONSUME_PURCHASE_FAILED
QUERY_PURCHASES_HISTORY_RECORDS_FAILED, PURCHASE_FAILED, CONSUME_PURCHASE_FAILED
).contains(this)

/**
Expand All @@ -97,7 +107,8 @@ enum class BillingEvent {
val isSuccess: Boolean
get() = listOf(
BILLING_CONNECTED, QUERY_PRODUCT_DETAILS_COMPLETE, QUERY_OWNED_PURCHASES_COMPLETE,
PURCHASE_COMPLETE, PURCHASE_ACKNOWLEDGE_SUCCESS, CONSUME_PURCHASE_SUCCESS
QUERY_PURCHASES_HISTORY_RECORDS_COMPLETE, PURCHASE_COMPLETE, PURCHASE_ACKNOWLEDGE_SUCCESS,
CONSUME_PURCHASE_SUCCESS
).contains(this)

/**
Expand Down Expand Up @@ -153,6 +164,14 @@ enum class BillingEvent {
QUERY_OWNED_PURCHASES_COMPLETE, QUERY_OWNED_PURCHASES_FAILED
).contains(this)

/**
* Determine if event belongs to query purchase history flow.
*/
val isQueryPurchaseHistoryFlow: Boolean
get() = listOf(
QUERY_PURCHASES_HISTORY_RECORDS_COMPLETE, QUERY_PURCHASES_HISTORY_RECORDS_FAILED
).contains(this)

/**
* Determine if event belongs to consume purchase flow.
*/
Expand Down
Loading

0 comments on commit 0d99404

Please sign in to comment.