How to migrate to Google Play Billing Library 4.0.0

At the end of May 2021, Google announced Play Billing Library version 4.0.0 which will open up new opportunities for growing apps’ engagement and revenue. With these updates, app owners will access a number of new features for in-app purchase managing and monetization strategy improvements. Among these features is the ability to sell a few items at a time from the cart and multiple products as part of a single subscription. 

In our previous blog post, we shared in great detail and gave practical advice on how you can implement Google Billing Library version 3 into mobile applications. In this article, we will outline which changes you should consider while migrating to Google Play Billing Library 4.0.0 release to benefit from all these exciting features. 

Please take a note: use of Google Play Billing Library version 3 or later is a must

Technical overview on Google Billing Library 4.0.0 updates

1. Background threads instead of UI

In the new version of the Library, callbacks methods are called on the background thread (in the previous version it was the main thread). 

To make sure, just print the current thread title/identifier to the LogCat, for instance, in the onBillingSetupFinished callback:

Log.d("TestThread",  "Thread - ${Thread.currentThread().name} Yippee! Billing setup finished")

For the Google Play Billing Library v4, the result will be as follows:

D/TestThread: Thread - PlayBillingLibrary-1 Yippee! Billing setup finished

For the Google Play Billing Library v3 it looked like that:

D/TestThread: Thread - main Yippee! Billing setup finished

We think this is the most significant update of the new version. You can’t interact with the UI layer right from the background thread before you switch back to the main thread. If you want to modify the UI from the callback, please don’t forget about it.

2. Retrieve previous purchases: queryPurchasesAsync() substitutes queryPurchases()

The queryPurchases() method is deprecated now. To retrieve all active subscriptions and non-consumed in-app purchases you should call the queryPurchasesAsync() method. 

private fun queryPurchasesAsync() {
   // Fetch active subscriptions and one-time purchases
   billingClient.queryPurchasesAsync(BillingClient.SkuType.SUBS, this)
   billingClient.queryPurchasesAsync(BillingClient.SkuType.INAPP, this)

To get a response from the method implement BillingClientStateListener in your class and override the onQueryPurchasesResponse function:

* Callback that will be executed when queryPurchasesAsync is called
override fun onQueryPurchasesResponse(
   billingResult: BillingResult,
   purchases: MutableList<Purchase>
) {
   // process purchases

3. New way to subscriptions upgrade/downgrade

Previously to update subscription you had to provide skuDetails, old purchase sku, old purchase token and ProrationMode (optional):

private fun updatePurchase(skuDetails: SkuDetails) {
   val params = BillingFlowParams.newBuilder()
       .setOldSku("oldSku", "oldPurchaseToken")
   billingClient.launchBillingFlow(this, params)

With Google Play Billing Library 4.0.0 to update subscription you have to call BillingFlowParams.Builder.setSubscriptionUpdateParams() and pass an instance of SubscriptionUpdateParams as a parameter. Note that the setOldSku() method has been removed. 

private fun updatePurchase(skuDetails: SkuDetails) {
   val updateParams = BillingFlowParams.SubscriptionUpdateParams.newBuilder()
   val billingFlowParams = BillingFlowParams.newBuilder()
   billingClient.launchBillingFlow(this, billingFlowParams)

4. Multi-quantity purchases (not released yet)

Google announced plans to release a new way of in-app purchases: selling multiple consumable in-app products at the same time. You can customize which product is available for multi quantities in the Google Play console. Users will be able to choose the number of digital products they want to purchase right from the cart.

It optimizes the way you sell and simplifies in-app purchases for users: they can purchase a few packages of items (coins, mana points, or anything else) in one click instead of ordering it several times.  

To get the quantity of the purchased item, call new methods: Purchase.getQuantity() and PurchaseHistoryRecord.getQuantity().

5. Multi-line subscriptions (not released yet)

In addition to the previous feature, Google will allow selling multiple products as part of a single subscription. Users can manage (add, remove, upgrade or downgrade) products during the subscription lifecycle.

In two words, users will be allowed to subscribe to different content threads – for instance, lessons to HIIT and stretching courses as one subscription, and make changes in this bundle during the subscription period.

To get product ID of in-app purchase or subscription use Purchase.getSkus() and PurchaseHistoryRecord.getSkus(). Earlier you would call Purchase.getSku() and PurchaseHistoryRecord.getSku() that are not actual anymore. 

Qonversion SDKs support Google Play Billing Library 4.0.0

To be prepared for announced Google’s updates that we shared above, we added Google Billing Library version 4.0.0 support in our SDKs for Android, Unity, Flutter, React Native, and Cordova platforms. The latest SDKs versions can be found here.

Other Google Play updates you should know about

In addition to Google Billing Library 4.0.0. changes we find important to highlight other updates Google announced during last I/O 2021.

Subscription duration settings and Prepaid plans 

Google announced plans to release prepaid plans, which allow you to offer users the possibility to subscribe for a fixed period of time. Users can also set the duration of subscriptions by extending their access at any time prior to or after plan expiration.

15% service fee for the first $1M revenue

Google’s fee for the first $1M revenue is now 15%. If you are not enrolled yet, this is the right moment. This program is applicable for every Google Play developer, regardless of the size of the company and total revenue, to enroll you just need to take a few steps. This reduction is aimed to allow each developer and app owner to boost success and invest more resources into the growth – and this chance should not be missed.

Peers benchmark

As analytics nerds, we couldn’t pass by the announced Google’s peers comparison tool. The company launched benchmarks that allow you to compare your app’s metrics such as MAU/DAU, ARPDAU, Average purchase value, Users, User acquisitions, and others vs those of similar apps (to learn more on these KPIs read the blog post on essential mobile app metrics). From now on, Android developers and marketers can benchmark their app engagement and monetization metrics against up to 250 competitors.

Although this tool is meant to examine overall app trends, essential in-app purchase metrics are missed. Information about the revenue trend, install-to-trial conversion, trial-to-paid conversion, trial and subscription cancelations rates could be found in our Qonversion report – from what we believe is the first-ever mobile subscription benchmark. At this moment only iOS app insights are available, but they are still informative to understand users’ behavior patterns. 

Summary of the new Google Play Billing Library 4.0.0 features

The new Google Play Billing Library 4.0.0 optimizes in-app purchases processes and unlocks new capabilities for products distribution. These are great tools for growing apps’ revenue, but you should implement it with a strategic approach.

The fact that users are free to choose the duration and the set of the subscription means that they can predict the period this application or exact feature will be relevant for them. To retain this user, you need to explain the long-term value of your feature and suggest to users new offerings, incentives, discounts – anything that they might find as a good reason to renew. You can also use Google Play promo code as a mechanics. To simplify this process and win back lapsed customers, send automation notifications triggered by user behavior.  

Experiments with your product offerings, trial, and subscription duration also could be your winning strategy. With our A/B testing tool, you can define the most attractive product bundle and see how it affects your revenue. Don’t miss the chance to analyze and test – it might be time-consuming, but this is the only way to make smart decisions that work for your business. 

At Qonversion we are happy to bring our expertise to accelerate your subscriptions app business. Learn more on how you can increase your revenue with AutomationAnalytics integrations, and A/B Testing for in-app purchases, and more.