Andrew P
Andrew P

Reputation: 31

How to remove non-consumable and buy it again (while testing an Android app)?

How do you test non-consumables in your Android apps? ("noADs" as instance) If "noAds" already purchased All I do (reinstall the game, install it on other device) it doesn't lead to anything: I don't see the purchase again (it always restores automatically).

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

Yes, it works. May be after the /adb shell pm clear com.android.vending/ But it really hard to do it every time.

So, do you really do it the same way each time?!! Is there no way (for example) to add a cheat to the app: if it's activated, the device doesn't send the request to purchase restoring. Or doesn't receive the server answer... or something else?? Or does Google Play Billing do all of these automatically and block all attempts to interfere?

Upvotes: 3

Views: 3393

Answers (3)

egldev
egldev

Reputation: 181

I had this problem and solved it as follows:

  1. Go to Google Play Console.
  2. Select "Order Management" in the left menu.

enter image description here


  1. Select the test purchase to view order details, for example: "Test: noADs".

enter image description here


  1. Select the "Refund" button.

enter image description here


  1. Check the "Remove entitlement" box, don't forget to do this!

enter image description here


  1. Finish refunding the order by selecting the "Refund" button.

Done, now you can buy your non-consumable test again!


Did you forget check the "Remove entitlement" box?

If you forgot to check the "Remove entitlement" box, don't worry, there is a solution: consume the purchase.

Add this temporary JAVA code and run it in your app:

public void testConsumePurchase(Purchase purchase) {
    billingClient.consumeAsync(ConsumeParams.newBuilder().setPurchaseToken(purchase.getPurchaseToken()).build(), new ConsumeResponseListener() {
        @Override
        public void onConsumeResponse(@NonNull BillingResult billingResult, @NonNull String s) {
            Log.i("onConsumeResponse", "Consumed!");
        }
    });
}

Or you can copy the "purchase token" from Google Play Console and use the following method:


enter image description here


public void testConsumePurchase(String purchaseToken) {
    billingClient.consumeAsync(ConsumeParams.newBuilder().setPurchaseToken(purchaseToken).build(), new ConsumeResponseListener() {
        @Override
        public void onConsumeResponse(@NonNull BillingResult billingResult, @NonNull String s) {
            Log.i("onConsumeResponse", "Consumed!");
        }
    });
}

After this, remove the code. Done, now you can buy your non-consumable test again!

If you use Kotlin, I recommended you visit: here.

Note: I am using the Google Play Billing Library 4.1.0 version.

I hope this is useful, regards! 😁/.

Upvotes: 12

zoirs
zoirs

Reputation: 631

Go to https://play.google.com/apps/publish/

In the left menu tab "Order management"

The page will contain a list of payments. You can make a refund here.

Upvotes: 2

lolloCreator
lolloCreator

Reputation: 75

I recommend you to use:

BillingClient.acknowledgePurchase()

Take a look here: https://developer.android.com/google/play/billing/integrate#process

Upvotes: 0

Related Questions