In-App Billing v3 - Don't detect refund

后端 未结 4 1736
我在风中等你
我在风中等你 2020-12-08 06:53

I\'ve followed the training about \"In-App Billing v3\" of Google. I get to do a buy of a item but I\'ve a problem.

https://developer.android.com/training/in-app-bil

4条回答
  •  情书的邮戳
    2020-12-08 07:39

    You can easily negate the purchase for test purposes by consuming the item.

    Using Trivial Drive sample I added the following code in MainActivity.java which will "consume" the premium upgrade when the app starts:

            // Do we have the premium upgrade?
            Purchase premiumPurchase = inventory.getPurchase(SKU_PREMIUM);
            mIsPremium = (premiumPurchase != null && verifyDeveloperPayload(premiumPurchase));
            Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM"));
    
            // dss added for test: Consume the premium upgrade for test purposes.
            boolean testConsume = true;
            if (mIsPremium && testConsume) {
                Log.d(TAG, "NOT FOR PRODUCTION: We have a premium upgrade. Consuming it.");
                mHelper.consumeAsync(inventory.getPurchase(SKU_PREMIUM), mConsumeFinishedListener);
                mIsPremium = false;
            } //dss end add
    

    As a bonus you get a free quarter tank of gas when you consume the upgrade just because the sample treats all consumption as gasoline elsewhere. Search MainActivity for "Provisioning" to find where.

提交回复
热议问题