Skip to content

Commit

Permalink
Merge pull request #576 from qonversion/feature/acknowledgeFix
Browse files Browse the repository at this point in the history
Updated logic to fix rare cases for acknowledging purchases issue
  • Loading branch information
suriksarkisyan authored Apr 10, 2024
2 parents b23d8c2 + 735590f commit 9968ee1
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ internal class QProductCenterManager internal constructor(
private var advertisingID: String? = null
private var pendingInitRequestData: InitRequestData? = null

private var processingPurchases: List<Purchase> = emptyList()

private var converter: PurchaseConverter = GooglePurchaseConverter()

@Volatile
Expand Down Expand Up @@ -616,6 +618,8 @@ internal class QProductCenterManager internal constructor(
val completedPurchases =
purchases.filter { it.purchaseState == Purchase.PurchaseState.PURCHASED }

processingPurchases = completedPurchases

val purchasesInfo = converter.convertPurchases(completedPurchases)

val handledPurchasesCallback =
Expand Down Expand Up @@ -658,6 +662,13 @@ internal class QProductCenterManager internal constructor(

loadStoreProductsIfPossible()

if (processingPurchases.isNotEmpty()) {
handledPurchasesCache.saveHandledPurchases(processingPurchases)

billingService.consumePurchases(processingPurchases.toList())
processingPurchases = emptyList()
}

handleCachedPurchases()

callback?.onSuccess(launchResult)
Expand Down

0 comments on commit 9968ee1

Please sign in to comment.