In-App Billing test: android.test.purchased already owned

后端 未结 16 1353
情深已故
情深已故 2020-12-07 08:09

I am currently testing In-App Billing for a future app, and after I successfully \"bought\" the test item \"android.test.purchased\" the first time, I now receive the respon

16条回答
  •  囚心锁ツ
    2020-12-07 08:30

    For testing purposes I also suggest you to insert a piece of code that will be clearing all the products that you've bought before calling a method that initializes gp purchase flow. That is especially comfortable, when you test just one item at the moment. E.g. like this:

    PurchasesResult purchasesResult = mBillingClient.queryPurchases(BillingClient.SkuType.INAPP);
        for (Purchase sourcePurchase : purchasesResult.getPurchasesList()) {
            if(sourcePurchase != null){
    
                ConsumeResponseListener listener = new ConsumeResponseListener() {
                    @Override
                    public void onConsumeResponse(String outToken, @BillingResponse int responseCode) {
    
                        System.out.println("all consumed");
                    }
                };
                mBillingClient.consumeAsync(sourcePurchase.getPurchaseToken(), listener);
            }else{
                System.out.println("null");
            }
        }
    
    // and then initiate whole process with clear "shoping basket"
    
    BillingFlowParams.Builder builder = new BillingFlowParams.Builder()
            .setSku(itemName).setType(BillingClient.SkuType.INAPP);
    

提交回复
热议问题