2

I am unable to get subscription price after updating google play billing library from v4 to v5. Billing flow is working perfectly and I am also able to purchase the product.

I was able to get prices of subscription products on v4.

I've tried this but I am not getting price.

if (billingClient.isReady()) {

            QueryProductDetailsParams queryProductDetailsParams =
                    QueryProductDetailsParams.newBuilder()
                            .setProductList(
                                    ImmutableList.of(
                                            QueryProductDetailsParams.Product.newBuilder()
                                                  .setProductId(ITEM_SKU_SUBSCRIBE)
                                                  .setProductType(BillingClient.ProductType.SUBS)
                                                    .build())).build();

            billingClient.queryProductDetailsAsync(queryProductDetailsParams, new
ProductDetailsResponseListener() {
                @Override
                public void onProductDetailsResponse(@NonNull BillingResult billingResult, @NonNull List<ProductDetails> list) {

                    if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {

                            monthlyPriceTV.setText(list.get(0).getSubscriptionOfferDetails().get(0).getPricingPhases().getPricingPhaseList().get(0).getFormattedPrice());

                }
            });
        } 

I am not getting any errors or warnings

Any help will be really appreciated

BhavitBJ
  • 42
  • 1
  • 11
  • 2
    As per my testing, I am also not able to get any callback `billingManager.queryProductDetailsAsync`. No error message, no logging. Based on https://stackoverflow.com/a/72631462/72437 , it is due to Google Play is not updated. I think it is better for us to stick with v4 for a while, as we do not want our billing feature break, just because end users have a slightly older version of Google Play. – Cheok Yan Cheng Oct 06 '22 at 06:28
  • is the billing only can be tested under prod? – Ben Jun 20 '23 at 21:49

1 Answers1

0

You can check the response value of billingClient, if feature not support, tell user to upgrade their Play Store.

private void queryProduct() {
    QueryProductDetailsParams queryProductDetailsParams =
            QueryProductDetailsParams.newBuilder()
                    .setProductList(productList)
                    .build();
    billingClient.queryProductDetailsAsync(
            queryProductDetailsParams,
            (billingResult, list) -> {
                // process returned productDetailsList
                if (billingResult.getResponseCode() == BillingResponseCode.OK) {
                    setProductDetailsList(list);
                    this.billingListener.onQueryProductSuccess(list);
                } else if (billingResult.getResponseCode() == BillingResponseCode.FEATURE_NOT_SUPPORTED) {
                    Log.e(TAG, "Feature not supported");
                    ToastUtil.show(context, "Feature not supported, Please upgrade your Google Play Store");
                    this.billingListener.onQueryProductFailed(billingResult);
                } else {
                    Log.e(TAG, billingResult.getDebugMessage());
                    this.billingListener.onQueryProductFailed(billingResult);
                }
            }
    );
}

See the official documentation for details: https://developer.android.com/google/play/billing/integrate#process-the-result

zdd
  • 8,258
  • 8
  • 46
  • 75