Skip to content

Commit

Permalink
Merge pull request #38 from orbitalsonic/master
Browse files Browse the repository at this point in the history
Billing
  • Loading branch information
hypersoftdev authored Mar 12, 2024
2 parents 8791d5f + afa565c commit 77c1c16
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions billing/src/main/java/com/hypersoft/billing/utils/QueryUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal class QueryUtils(private val billingClient: BillingClient) {
}

suspend fun queryProductDetailsAsync(params: List<QueryProductDetailsParams.Product>): List<ProductDetails> {
if (billingClient.isReady.not()) {
if (billingClient.isReady.not() || params.isEmpty()) {
Result.setResultState(ResultState.CONNECTION_INVALID)
return emptyList()
}
Expand All @@ -56,10 +56,22 @@ internal class QueryUtils(private val billingClient: BillingClient) {
if (continuation.isActive) {
billingClient.queryProductDetailsAsync(queryParams) { billingResult, productDetailsList ->
if (BillingResponse(billingResult.responseCode).isOk) {
continuation.resume(productDetailsList)
if (continuation.isActive){
try {
continuation.resume(productDetailsList)
}catch (ex:Exception){
Log.e(TAG, "${ex.message}")
}
}
} else {
if (continuation.isActive){
try {
continuation.resume(emptyList())
}catch (ex:Exception){
Log.e(TAG, "${ex.message}")
}
}
Log.e(TAG, "queryProductDetailsAsync: Failed to query product details. Response code: ${billingResult.responseCode}")
continuation.resume(emptyList())
}
}
}
Expand Down

0 comments on commit 77c1c16

Please sign in to comment.