简体   繁体   中英

How to remove test IAP purchase from Android Google Play

I set up a beta account to test IAP for google app that I am working on, the issue I have is, once I have purchased One-time products(non-recurring charge) the test IAP, I cannot 'remove it' as such, so now, even when I delete the app and re-install, it remembers the purchase, that's great in the real world for a user, but not great when trying to fix the bugs!

Is there any way (short of making a ton of gmail accounts to test with) to remove the purchase from the account?

This is an old question but if someone is still looking for a solution then go to:

There you can refund / cancel test purchases. Then clear the purchase state using this command:

adb shell pm clear com.android.vending

The only way I know is to force a consume in your app. You can then remove that code.

I am using cc.fovea.cordova.purchase plugin for cordova to manage my IAP purchases. To get my test Non-Consumables to be deleted I changed my registration from Non-consumable to Consumable.

store.register({
      id: this.predatorID,
      alias: 'Predator Pack',
      type: store.CONSUMABLE //store.NON_CONSUMABLE
    });

Also, apparently there are reserved keywords you could use instead (if you're into that). - https://developer.android.com/google/play/billing/billing_testing.html

I encountered the same situation and started to research. Unfortunately, the directions made here did not produce a solution.

I want to share the solution that worked for me.

If you call the method below in the right place, the solution will be produced. Source : Link

/**
     * Recall that Google Play Billing only supports two SKU types:
     * [in-app products][BillingClient.SkuType.INAPP] and
     * [subscriptions][BillingClient.SkuType.SUBS]. In-app products are actual items that a
     * user can buy, such as a house or food; subscriptions refer to services that a user must
     * pay for regularly, such as auto-insurance. Subscriptions are not consumable.
     *
     * Play Billing provides methods for consuming in-app products because they understand that
     * apps may sell items that users will keep forever (i.e. never consume) such as a house,
     * and consumable items that users will need to keep buying such as food. Nevertheless, Google
     * Play leaves the distinction for which in-app products are consumable entirely up to you.
     *
     * If an app wants its users to be able to keep buying an item, it must call
     * [BillingClient.consumeAsync] each time they buy it. This is because Google Play won't let
     * users buy items that they've previously bought but haven't consumed. In Trivial Drive, for
     * example, consumeAsync is called each time the user buys gas; otherwise they would never be
     * able to buy gas or drive again once the tank becomes empty.
     */

    private fun clearIapHistory() {
            billingClient!!.queryPurchases(BillingClient.SkuType.INAPP).purchasesList
                .forEach {
                    val params =
                        ConsumeParams.newBuilder().setPurchaseToken(it.purchaseToken).build()
                    billingClient!!.consumeAsync(params) { responseCode, purchaseToken ->
                        when (responseCode.responseCode) {
                            BillingClient.BillingResponseCode.OK -> {

                            }
                            else -> {
                                Log.w(LOG_TAG, responseCode.debugMessage)
                            }
                        }
                    }
                }
        }
if (inventory.getPurchase(ITEM_SKU) != null ) {
                try {
                    mIabHelper.consumeAsync(premiumPurchase, new IabHelper.OnConsumeFinishedListener() {
                        @Override
                        public void onConsumeFinished(Purchase purchase, IabResult result) {
                            Toast.makeText(MainActivity.this, "Consumed the test purchase successfully", Toast.LENGTH_SHORT).show();
                        }
                    });
                } catch (IabHelper.IabAsyncInProgressException e) {
                    e.printStackTrace();
                }
             }

However refund() and revoke() methods don't support test purchases and you are left with only consumeAsync() option.

Just:

Purchase unlockedPurchase = inventory.getPurchase(SKU_UNLOCKED);
// Log unlockedPurchase.getOrderId();

Go to your Google Play panel, Order management, look for that order id and refund it (it should say Test order if it is your own order).

I guess the only method working is to...

Consume It!

For further info, get to the consuming document and search for "consume": https://developer.android.com/google/play/billing/integrate

Here are the important steps for you:

  1. Dependence setup.
  2. Billing client connection.
  3. Query the Purchase.
  4. Consume(Purchase).

Good Luck~

Test non-consumable products

To perform multiple test purchases for the same non-consumable product, you can refund and revoke purchases using Google Play Console.

I had a similar issue. Fortunately, the app I'm working with is WebView-based, so I can easily inject a link or button to trigger some Javascript to call back into the application to consume the test orders. Since test orders have an empty string for the orderId , it is easy to identify them to consume them. Once consumed, the item can be "purchased" again. Removing the button requires commenting out one line of code BUT if the button accidentally makes it into the final published app, it won't cause any problems since the code only consumes test orders - that is, real orders are not affected. That button will just be embarrassing instead of a disaster.

I'm working on a device without a credit card associated with it. I set up some promo codes and use the "Redeem Code" option for my test orders. Promo codes result in no risk of money exchanging hands and I'm able to completely verify IAB functionality in my app with real products without having to resort to the IAB test codes.

Nothing shows up for me in Google Wallet as per the post by Martin Kool.

You can refund the test purchase of non-consumable product and it will work just fine.

Using the Play Console website

  1. Open Play Console.
  2. On All Apps page left side, select Order Management
  3. Use the "Search orders" box to search by order ID or the user's full email address.
  4. Open order, click on Refund button. Select Entitlement checkbox and refund.

More details here about refunds: https://support.google.com/googleplay/android-developer/answer/2741495

Google Play Purchases are stored in Google Wallet.

https://wallet.google.com

When signed, go to "Transactions" on the left. Test purchases can be cancelled from there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM