use of com.android.billingclient.api.PurchasesResponseListener in project Android-InAppBilling by LiteKite.
the class BillingManager method queryPurchasesAsync.
/**
* Queries InApp and Subscribed purchase results from Google Play Locally.
*
* @param purchases this list contains all the product purchases made, has InApp and
* Subscription purchased results.
* @param skuType InApp or Subscription.
* @param executeWhenFinished Once the InApp product purchase results are given, then
* subscription based purchase results are queried and results are placed into the {@link
* #myPurchasesResultList}
*/
private void queryPurchasesAsync(final List<Purchase> purchases, @SkuType final String skuType, final Runnable executeWhenFinished) {
PurchasesResponseListener purchasesResponseListener = (billingResult, list) -> {
if (billingResult.getResponseCode() == BillingResponseCode.OK) {
purchases.addAll(list);
if (executeWhenFinished != null) {
executeWhenFinished.run();
}
} else {
MonetizeApp.printLog(TAG, "queryPurchasesAsync() got an error response code: " + billingResult.getResponseCode());
logErrorType(billingResult);
}
if (executeWhenFinished == null) {
processPurchases(purchases);
}
};
executeServiceRequest(() -> myBillingClient.queryPurchasesAsync(skuType, purchasesResponseListener));
}
Aggregations