2 min read

Billing on Android, Goodbye AIDL


Google released the Billing library which makes it considerably easier to handle subscriptions and consumables in Android apps. The reason it is easier to integrate is removing the need to communicate across AIDL (Android Interface Design Language), which added a lot of complexity on top of an already complex cognitive domain of showing products and verifying purchases.

The old way of doing things required making an Intent referencing the com.android.vending.billing.InAppBillingService in order to establish a ServiceConnection to obtain a Service defined as an interface against InAppBillingService. If that didn't already make your head spin, try dealing with any of the resulting errors.

I never did. Got on the Google Billing Library bandwagon at the first available production ready version (roughly 1.2.2) and never looked back.

I have seen questions about how to implement payment validation client-side only, and it just doesn't make sense from a business perspective once the business makes enough to employ more than one engineer. The loss of revenue due to fraud is mostly going to be prevalent in the more popular applications since there will both be supply of tools and demand to avoid payment.

level 1kaeawcHinge5 points·1 year ago

It's last commits are a few days old, specifically the samples that make use of the Google Billing Library which makes an abstraction around the old AIDL interface. There was an issue with that library in 1.2.1 that could cause an ANR, which is why the 1.2.2 release exists. If you have any questions about it I'm happy to help, I've been working with it since it was first released.

If you're still trying to just determine whether user previously purchased a subscription and don't care about fraud then you can just use the queryPurchaseHistory API.

If you're trying to determine whether a user previously purchased a consumable, you're out of luck in terms of the Google Billing API since consuming the product removes it from queryable history.

If you're looking to find whether a given purchase has been refunded via the Billing library, but another API might help you with that - the Google Play Developer API for purchases - though again that should happen from a private server and not an Android client on a users phone. Both methods require using a private key that should not be exposed, and anything you put in the APK that goes out to users phones should be considered exposed information.