Is that possible to make in app billing in Android instant apps?

Viewed 707

Here's my implementation:

private IabHelper mIabHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mIabHelper = new IabHelper(this, GOOGLE_BASE64_KEY);
    mIabHelper.startSetup(this);
}

@Override
public void onIabSetupFinished(IabResult result) {
    if (result.isSuccess()){
        mIabHelper.queryInventoryAsync(true, this);
    } else {
        Log.e("test","onIabSetupFinished-result:"+result.getMessage());
    }
}

Then I got this:

08-09 21:44:00.859 5839-5839/? D/IabHelper: IAB helper created.
08-09 21:44:00.859 5839-5839/? D/IabHelper: Starting in-app billing setup.
08-09 21:44:00.923 5839-5839/? D/IabHelper: Billing service connected.
08-09 21:44:00.925 5839-5839/? D/IabHelper: Checking for in-app billing 3 support.
08-09 21:44:00.934 17057-17069/? I/Finsky: [430] com.google.android.finsky.billing.iab.z.b(44): ...: Account from first account - [...]
08-09 21:44:00.937 17057-17069/? W/Finsky: [430] com.google.android.finsky.billing.iab.z.a(64): Package name ... does not match UID 99089
08-09 21:44:00.938 5839-5839/? E/test: onIabSetupFinished-result:Error checking for billing v3 support. (response: 5:Developer Error)
3 Answers

As of this writing, 10/12/19, I found I could do in app purchases from the 'instant' version of my own game app. I could find absolutely nothing online or in the docs on this specifically so I just had to experiment myself.

When you do an in app purchase from your own app in the installation version, it does it as a 'test purchase' and doesn't actually charge you. Google Play didn't have payment info on me until I started purchasing items from my instant version. Unfortunately you are not recognized as the developer in the instant version of your own app, at least I wasn't, so it asks for payment info and actually charges you. This is irritating as it interferes with my stats and introduces questions like whether I should refund myself from the developer console or let google keep their cut (would refund requests look bad?).

I found in app purchases from the installation and instant versions appear to be kept separate. Queries yield different results from each version. I was hoping instant purchases would carry over to the installation version. My installation version isn't free, whether or not that makes a difference. I'm doing further testing on this, but if it won't carry over I'll have to remove in app instant app purchasing to not disappoint players who later install the full app.

Getting rid of test purchases is notoriously difficult, by the way. Even when you uninstall your app, go offline, and reinstall it from android studio, an inventory query will find your past purchases as it stores it on your device. Even clearing the caches of the Play Store and the app itself doesn't get rid of it. You have to have a secret button or the like on your release version to 'consume' test purchases with the appropriate code.

Related