Google Play 结算 V6 显示错误 DF-DFERH-01

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

您好,我正在将 Google Play 计费库集成到 Android Studio 中的一个片段上的项目中以销售订阅,我已经在 Google Play 控制台中进行了设置,在内部测试中上传我的应用程序并制定订阅基本计划,然后我继续为了按照文档中的步骤在我的应用程序中进行逻辑处理,一切都很好,我检查了产品列表,它有订阅信息,但是当应用程序尝试显示谷歌播放窗口时,它会出现下一个错误信息: error 我在互联网上搜索,他们说清除数据,谷歌Play商店和谷歌播放服务的缓存并重新启动手机我做到了,但它不起作用,我打开另一个订阅的应用程序,它显示了谷歌播放的窗口订阅没有问题,所以我不认为问题出在谷歌游戏商店 otherAppSubscription

我已经尝试了很多东西,从谷歌游戏商店下载应用程序(内部测试),更改活动的片段,使用库的降级版本,但没有任何效果,我向您分享我的代码,提前感谢

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view = inflater.inflate(R.layout.fragment_sin_anuncios, container, false);
        PurchasesUpdatedListener purchasesUpdatedListener = new PurchasesUpdatedListener() {
            @Override
            public void onPurchasesUpdated(BillingResult billingResult, List<Purchase> purchases) {
                // To be implemented in a later section.
            }
        };

        billingClient = BillingClient.newBuilder(getContext())
                .setListener(purchasesUpdatedListener)
                .enablePendingPurchases()
                .build();

        connectToGooglePlayBilling();

        return view;
    }

    private void connectToGooglePlayBilling(){

        billingClient.startConnection(new BillingClientStateListener() {
            @Override
            public void onBillingSetupFinished(BillingResult billingResult) {

                if (billingResult.getResponseCode() ==  BillingClient.BillingResponseCode.OK) {
                    // The BillingClient is ready. You can query purchases here.
                    getProductDeatils();

                }

            }
            @Override
            public void onBillingServiceDisconnected() {
                // Try to restart the connection on the next request to
                // Google Play by calling the startConnection() method.
                Toast.makeText(getContext(), "No se pudo conectar a GooglePlay, revisa tu conexion a internet.\nIntentando conectarse nuevamente.", Toast.LENGTH_SHORT).show();
                connectToGooglePlayBilling();
                
            }
        });

    }


    private void getProductDeatils(){

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

        Activity activity = getActivity();

        billingClient.queryProductDetailsAsync(
                queryProductDetailsParams,
                new ProductDetailsResponseListener() {
                    public void onProductDetailsResponse(BillingResult billingResult,
                                                         List<ProductDetails> productDetailsList) {
                        // check billingResult
                        // process returned productDetailsList

                        if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && productDetailsList != null){
                            TextView descripcion = view.findViewById(R.id.textViewSinAnuncios);
                            descripcion.setText(productDetailsList.get(0).getDescription());

                            Button BotonSinAnuncios = (Button) view.findViewById(R.id.buttonSinAnuncios);
                            BotonSinAnuncios.setOnClickListener(new View.OnClickListener()
                            {

                                @Override
                                public void onClick(View v)
                                {
                                    Log.d("GoogleBillingService", "onBillingSetupFinished: billingResult: " + billingResult);
                                    Log.d("GoogleBillingService", "Product detatils: " + productDetailsList.get(0));

                                    ImmutableList productDetailsParamsList =
                                            ImmutableList.of(
                                                    BillingFlowParams.ProductDetailsParams.newBuilder()
                                                            // retrieve a value for "productDetails" by calling queryProductDetailsAsync()
                                                            .setProductDetails(productDetailsList.get(0))
                                                            // to get an offer token, call ProductDetails.getSubscriptionOfferDetails()
                                                            // for a list of offers that are available to the user
                                                            .setOfferToken(String.valueOf(productDetailsList.get(0).getSubscriptionOfferDetails()))
                                                            .build()
                                            );


                                    BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
                                            .setProductDetailsParamsList(productDetailsParamsList)
                                            .build();


                                    // Launch the billing flow
                                    billingClient.launchBillingFlow(activity, billingFlowParams);

                                }
                            });


                        }
                    }
                }
        );

    }

}
java android in-app-purchase in-app-billing
1个回答
0
投票

当将不正确的数据传递到计费库时,通常会发生此错误。

根据您的情况,请找到相关的

offerToken

String offerToken = productDetailsList.get(0).getSubscriptionOfferDetails().get(0).getOfferToken();

(当然,这只是一个例子,我省略了各种检查。我假设第一个产品是订阅,并且您想要的报价是

getSubscriptionOfferDetails()
返回的列表中的第一个。您应该使用您的自定义逻辑来找到合适的报价。)

然后,尝试用

.setOfferToken(String.valueOf(productDetailsList.get(0).getSubscriptionOfferDetails()))
 删除行 
setOfferToken(offerToken)

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