InApp Покупка в порядке, но диалог не появляется - PullRequest
0 голосов
/ 02 марта 2019

Проблема в том, что при реализации InApp Purchase и нажатии кнопки результат ответа ОК, но диалоговое окно для покупки не появляется Вот код

 //To query Google Play for in-app product details, call this method
    mBillingClient.querySkuDetailsAsync(params.build(),
            new SkuDetailsResponseListener() {
                @Override
                public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) {
                    Log.d(TAG, "response from query -> " + responseCode);
                    if (responseCode == BillingClient.BillingResponse.OK
                            && skuDetailsList != null) {
                        for (SkuDetails skuDetails : skuDetailsList) {
                            String sku = skuDetails.getSku();
                            String price = skuDetails.getPrice();
                            if ("minimum".equals(sku)) {
                                //Retrieving a product’s price is an important step before
                                // a user can purchase a product because the price is different
                                // for each user based on their country of origin.
                                mOneDollarPurchasePrice = price;
                                BillingFlowParams flowParams = BillingFlowParams.newBuilder()
                                        .setSkuDetails(skuDetails)
                                        .build();
                                responseCode = mBillingClient.launchBillingFlow(ShopActivity.this, flowParams);
                            } else  {
                                //TODO Handle other scenarios of SKU
                            }
                        }

1 Ответ

0 голосов
/ 04 марта 2019

Вы должны потреблять продукт после покупки.

  private void consumeFromLibrary() {
    ConsumeResponseListener listener = new ConsumeResponseListener() {
        @Override
        public void onConsumeResponse(@BillingClient.BillingResponse int responseCode, String outToken) {
            Log.d(TAG, "Consume response -> " + responseCode);
            if (responseCode == BillingClient.BillingResponse.OK) {
                // Handle the success of the consume operation.
                // For example, increase the number of coins inside the user's basket.
            } else if (responseCode == BillingClient.BillingResponse.SERVICE_DISCONNECTED) {
                Log.d(TAG, "SERVICE DISCONNECTED");

            }
        }
    };
    Purchase.PurchasesResult purchasesResult = mBillingClient.queryPurchases(BillingClient.SkuType.INAPP);
    List<Purchase> purchaseList = purchasesResult.getPurchasesList();
    for (Purchase purchase : purchaseList) {
        mBillingClient.consumeAsync(purchase.getPurchaseToken(), listener);
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...