Skip to content

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mvojtkovszky committed Nov 21, 2022
2 parents 9b8146d + 560e655 commit b6dbefa
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 25 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# CHANGELOG

## 2.1.0 (2022-11-21)
* update Google billing client to 5.1.0
* bump Kotlin to 1.7.20

## 2.0.0 (2022-09-12)
* update Google billing client to 5.0.0 and adjust to all changes required to support it
* renamed all references from "sku" to "product" to reflect Google's billing client naming conventions.
* add `PriceUtil` object to simplify price formatting.
* bump Kotlin to 1.7.10, Gradle plugin to 7.2.2, core-ktx to 1.9.0
* bump buildToolsVersion to 33.0.0, compileSdkVersion and targetSdkVersion to 33

## 1.10.0 (2022-04-29)
* update Google billing client to 4.1.0
Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# BillingHelper
Wrapper around Google Play Billing Library, simplifying its use.
Handles client connection, querying product details, owned purchase, different purchase types, acknowledging purchases etc.
Wrapper around Google Play Billing Library (v5.1), simplifying its use.
Handles client connection, querying product details, owned purchases, different purchase types,
acknowledging purchases, verify purchase signatures etc.

## How does it work?
Your app requires Billing permission in the manifest
``` xml
<uses-permission android:name="com.android.vending.BILLING" />
```

<br/>Make sure your Activity/Fragment implements BillingListener and initializes BillingHelper
Make sure your `Activity`/`Fragment` implements `BillingListener` and initializes `BillingHelper`
``` kotlin
class MainActivity: AppCompatActivity(), BillingListener {

Expand All @@ -17,8 +13,8 @@ class MainActivity: AppCompatActivity(), BillingListener {
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
super.onCreate(savedInstanceState, persistentState)

// Construct helper - by default, connection will be initialized immediately with product details
// and owned purchases queried. All events are reported via billingListener.
// Construct helper - by default, connection will be initialized immediately with product
// details and owned purchases queried. All events are reported via billingListener.
// At least one of productInAppPurchases or productSubscriptions is required.
// For more configuration options, check BillingHelper constructor parameters.
billing = BillingHelper(
Expand All @@ -41,15 +37,14 @@ class MainActivity: AppCompatActivity(), BillingListener {
}
```

<br/>Use any of its public methods or attributes, BillingHelper will do all the heavy lifting and always report changes via BillingListener
<br/>Use any of its public methods or attributes, `BillingHelper` will do all the heavy lifting and always report changes via `BillingListener`
``` kotlin
fun consumePurchase(purchase: Purchase)
fun endClientConnection()
fun getPurchaseForProductName(productName: String): Purchase?
fun getProductDetails(productName: String): ProductDetails?
fun isPurchased(productName: String): Boolean
fun launchPurchaseFlow(activity: Activity, productName: String)
fun launchPriceChangeConfirmationFlow(activity: Activity, productDetails: ProductDetails)
fun initClientConnection(queryForProductDetailsOnConnected: Boolean, queryForOwnedPurchasesOnConected: Boolean)
fun initQueryOwnedPurchases()
fun initQueryProductDetails()
Expand All @@ -58,18 +53,23 @@ fun isFeatureSupported(feature: String)
fun addBillingListener(listener: BillingListener)
fun removeBillingListener(listener: BillingListener)

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

val billingReady: Boolean
val connectionState: Int
val purchasesQueried: Boolean
val productDetailsQueried: Boolean
val isConnectionFailure: Boolead
val purchasesQueriedOrConnectionFailure: Boolean
var purchasesQueried: Boolean
private set
var productDetailsQueried: Boolean
private set
var isConnectionFailure: Boolead
private set
val purchasesPresentable: Boolean
```

<br/>BillingEvent includes all of the things you might be interested in, served via BillingListener
<br/>`BillingEvent` includes all of the things you might be interested in, served via `BillingListener`
``` kotlin
enum class BillingEvent {
BILLING_CONNECTED,
Expand Down
6 changes: 3 additions & 3 deletions billinghelper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ 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:5.0.0'
api 'com.android.billingclient:billing-ktx:5.1.0'

/* https://developer.android.com/jetpack/androidx/releases/test */
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
}

apply from: "$rootDir/gradle-mvn-push.gradle"
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.0.0
versionName=2.1.0
7 changes: 6 additions & 1 deletion billinghelper/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<manifest package="com.example.billinghelper" />
<manifest package="com.example.billinghelper"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="com.android.vending.BILLING" />

</manifest>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript {
ext {
kotlin_version = "1.7.10" /* https://github.com/JetBrains/kotlin */
dokka_version = '1.7.10' /* https://github.com/Kotlin/dokka/releases */
kotlin_version = "1.7.20" /* https://github.com/JetBrains/kotlin */
dokka_version = '1.7.20' /* https://github.com/Kotlin/dokka/releases */
}

repositories {
Expand Down

0 comments on commit b6dbefa

Please sign in to comment.