Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
fix: Consider the Purchased Products Only
Browse files Browse the repository at this point in the history
The billing SDK's queryPurchases returns a list of purchases that
are currently in a purchased, pending, or unspecified state. For
the unfulfilled purchase flow, we only need to consider the
'purchased' state.

Fixes: LEARNER-9878
  • Loading branch information
HamzaIsrar12 committed Mar 5, 2024
1 parent 53be9ca commit d74b621
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.android.billingclient.api.ConsumeParams
import com.android.billingclient.api.ProductDetails
import com.android.billingclient.api.ProductDetailsResult
import com.android.billingclient.api.Purchase
import com.android.billingclient.api.Purchase.PurchaseState
import com.android.billingclient.api.PurchasesUpdatedListener
import com.android.billingclient.api.QueryProductDetailsParams
import com.android.billingclient.api.QueryPurchasesParams
Expand Down Expand Up @@ -242,7 +243,7 @@ class BillingProcessor @Inject constructor(
QueryPurchasesParams.newBuilder()
.setProductType(BillingClient.ProductType.INAPP)
.build()
).purchasesList
).purchasesList.filter { it.purchaseState == PurchaseState.PURCHASED }
}

suspend fun consumePurchase(purchaseToken: String): BillingResult {
Expand Down

0 comments on commit d74b621

Please sign in to comment.