将 play 计费库更新到 v5 后无法获取订阅价格

问题描述 投票:0回答:1

将 google play 计费库从 v4 更新到 v5 后,我无法获得订阅价格。 计费流程运行良好,我也可以购买产品。

我能够在 v4 上获得订阅产品的价格。

我已经试过了,但我没有得到价格。

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());

                }
            });
        } 

我没有收到任何错误或警告

任何帮助将不胜感激

java android in-app-purchase in-app-subscription play-billing-library
1个回答
0
投票

您可以检查 billingClient 的响应值,如果功能不支持,告诉用户升级他们的 Play 商店。

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);
                }
            }
    );
}

详见官方文档:https://developer.android.com/google/play/billing/integrate#process-the-result

© www.soinside.com 2019 - 2024. All rights reserved.