Skip to content

Commit

Permalink
- Downgrade to billing v7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hannanshahid committed Dec 24, 2024
1 parent a7c5e63 commit 4f4c6d8
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 321 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Add Funsol Billing Helper dependencies in App level build.gradle.
```kotlin

dependencies {
implementation 'com.github.Funsol-Projects:Funsol-Billing-Helper:v2.0.3'
implementation 'com.github.Funsol-Projects:Funsol-Billing-Helper:v2.0.5'
}

```
Expand Down
4 changes: 2 additions & 2 deletions funsol-billing-utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ afterEvaluate {
from components.release
groupId = 'com.github.Funsol-Projects'
artifactId = 'Funsol-Billing-Helper'
version = 'v2.0.4'
version = 'v2.0.5'
}
debug(MavenPublication) {
from components.debug
groupId = 'com.github.Funsol-Projects'
artifactId = 'Funsol-Billing-Helper'
version = 'v2.0.4'
version = 'v2.0.5'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.funsol.iap.billing.helper.billingPrefernces.BillingSharedPrefsManager
import com.funsol.iap.billing.helper.billingPrefernces.PurchasedHistoryUtils
import com.funsol.iap.billing.helper.billingPrefernces.PurchasedProduct
import com.funsol.iap.billing.helper.logFunsolBilling
import com.funsol.iap.billing.helper.toFunsolPurchases
import com.funsol.iap.billing.listeners.BillingClientListener
import com.funsol.iap.billing.listeners.BillingEventListener
import com.funsol.iap.billing.model.ErrorType
Expand Down Expand Up @@ -235,7 +236,7 @@ class FunSolBillingHelper(private val context: Context) {
buyProducts.handlePurchase(purchase = purchase)
}
}
billingEventListener?.onProductsPurchased(purchasedSubsProductList)
billingEventListener?.onProductsPurchased(purchasedSubsProductList.toFunsolPurchases())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ class BuyProducts {
type = productInfo.productType,
price = productPriceInfo.price,
priceMicro = productPriceInfo.priceMicro,
currencyCode = productPriceInfo.currencyCode,
currencySymbol = productPriceInfo.currencySymbol)
currencyCode = productPriceInfo.currencyCode)
}

} else {
Expand Down Expand Up @@ -210,7 +209,7 @@ class BuyProducts {
else -> logFunsolBilling("Unknown product type while acknowledging purchase")
}
billingClientListener?.onPurchasesUpdated()
billingEventListener?.onPurchaseAcknowledged(purchase)
billingEventListener?.onPurchaseAcknowledged(purchase.toFunsolPurchase())
} else {
logFunsolBilling("Acknowledge error: ${result.debugMessage} (code: ${result.responseCode})")
billingEventListener?.onBillingError(ErrorType.ACKNOWLEDGE_ERROR)
Expand All @@ -236,7 +235,7 @@ class BuyProducts {
billingClient.consumeAsync(consumeParams) { result, _ ->
if (result.responseCode == BillingClient.BillingResponseCode.OK) {
logFunsolBilling("Purchase consumed")
billingEventListener?.onPurchaseConsumed(purchase)
billingEventListener?.onPurchaseConsumed(purchase.toFunsolPurchase())
} else {
logFunsolBilling("Failed to consume purchase: ${result.debugMessage} (code: ${result.responseCode})")
billingEventListener?.onBillingError(ErrorType.CONSUME_ERROR)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,2 +1,43 @@
package com.funsol.iap.billing.helper

import com.android.billingclient.api.Purchase
import com.funsol.iap.billing.model.FunsolPurchase

fun List<Purchase>.toFunsolPurchases(): List<FunsolPurchase> {
return this.map { purchase ->
FunsolPurchase(
products = purchase.products.toMutableList(),
purchaseState = purchase.purchaseState,
purchaseToken = purchase.purchaseToken,
isAcknowledged = purchase.isAcknowledged,
packageName = purchase.packageName,
developerPayload = purchase.developerPayload,
isAutoRenewing = purchase.isAutoRenewing,
orderId = purchase.orderId,
originalJson = purchase.originalJson,
purchaseTime = purchase.purchaseTime,
quantity = purchase.quantity,
signature = purchase.signature,
skus = purchase.skus
)
}
}

fun Purchase.toFunsolPurchase(): FunsolPurchase {
return FunsolPurchase(
products = this.products.toMutableList(),
purchaseState = this.purchaseState,
purchaseToken = this.purchaseToken,
isAcknowledged = this.isAcknowledged,
packageName = this.packageName,
developerPayload = this.developerPayload,
isAutoRenewing = this.isAutoRenewing,
orderId = this.orderId,
originalJson = this.originalJson,
purchaseTime = this.purchaseTime,
quantity = this.quantity,
signature = this.signature,
skus = this.skus

)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase

@Database(entities = [PurchasedProduct::class], version = 2, exportSchema = false)
@Database(entities = [PurchasedProduct::class], version = 1, exportSchema = false)
abstract class PurchaseDatabase : RoomDatabase() {
abstract fun purchaseDao(): PurchaseDao

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ data class PurchasedProduct(
@ColumnInfo(name = "price") var price: String? = null,
@ColumnInfo(name = "price_micro") var priceMicro: Long? = null,
@ColumnInfo(name = "currency_code") var currencyCode: String? = null,
@ColumnInfo(name = "currency_symbol") var currencySymbol: String? = null,
@ColumnInfo(name = "purchase_time") var purchaseTime: Long = System.currentTimeMillis(),
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.funsol.iap.billing.listeners

import com.android.billingclient.api.Purchase
import com.funsol.iap.billing.model.ErrorType

import com.funsol.iap.billing.model.FunsolPurchase

interface BillingEventListener {
fun onProductsPurchased(purchases: List<Purchase?>)
fun onPurchaseAcknowledged(purchase: Purchase)
fun onPurchaseConsumed(purchase: Purchase)
fun onProductsPurchased(purchases: List<FunsolPurchase?>)
fun onPurchaseAcknowledged(purchase: FunsolPurchase)
fun onPurchaseConsumed(purchase: FunsolPurchase)
fun onBillingError(error: ErrorType)

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ data class ProductPriceInfo(
var price: String = "",
var priceMicro: Long = 0L,
var currencyCode: String = "",
var currencySymbol: String = "",
var productCompleteInfo: ProductDetails? = null
)

0 comments on commit 4f4c6d8

Please sign in to comment.