Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Google Play Billing Library 3 - Is everything new and different again?

Kai Koenig
December 14, 2020

Google Play Billing Library 3 - Is everything new and different again?

Over the last two years, Google has released multiple new versions of Google Play Billing Library, also known as BillingClient.

We're now in the 3.x line of library releases and quite a lot of things have changed again - both on the side of your Android application as well as on a backend flow implementation.

There is now a need to acknowledge payments and a flurry of new subscription features like restore and hold. But how many of all these new features are really required and have to be supported by your app?

Before you spend weeks on potentially unnecessary work, this session will provide you with a quick and easy way to catch up. If you have been working with GPBL 1.x or 2.x for a while and want to upgrade, this is the place to be.

Kai Koenig

December 14, 2020
Tweet

More Decks by Kai Koenig

Other Decks in Technology

Transcript

  1. OVERVIEW ▸ Service that lets you sell digital content on

    Android: ▸ One-off purchases (consumable and non-consumable) ▸ Recurring subscriptions ▸ Can be accessed via IPC/AIDL or Google Play Billing library (GPBL) GOOGLE PLAY BILLING
  2. Client Server APP Google Play Google Play Server G
 P


    B
 L Backend application Google Play 
 Developer API
  3. FROM 30,000 FEET (I) ▸ In your app: Google Play

    Billing library ▸ Retrieve products, subscriptions, prices etc ▸ Check previous purchases ▸ Buy and consume products ▸ Acknowledge purchases ▸ Start subscriptions GOOGLE PLAY BILLING
  4. FROM 30,000 FEET (II) ▸ On the back end: Google

    Play Developer API ▸ Implement an integration between your server and the REST API ▸ Verify product purchases or subscriptions ▸ Notify back end when customers change or cancel subscriptions GOOGLE PLAY BILLING
  5. HISTORY (I) ▸ 3 major releases since 2017 ▸ 1.0

    (September 2017): ▸ BillingClient as core class, management of SKUs ▸ Fundamental support for querying and buying one-off products and subscriptions ▸ 1.1 (May 2018): ▸ Better support for proration ▸ Some additional callbacks for failure scenarios GOOGLE PLAY BILLING
  6. HISTORY (II) ▸ 1.2 (September 2018): ▸ Support for price

    changes in subscriptions ▸ API changes around SKU management ▸ 1.2.2 (March 2019): ▸ Rewarded products ▸ AIDL service calls use background threads ▸ API tweaks GOOGLE PLAY BILLING
  7. HISTORY (III) ▸ 2.0-2.0.3 (May-August 2019): ▸ Acknowledgement of purchases

    is required ▸ Developer payload can be passed to Google ▸ Pending purchases ▸ BillingResponse integer -> BillingResult object ▸ 2.1 (December 2019): ▸ Kotlin Extensions and API changes to setOldSku() GOOGLE PLAY BILLING
  8. HISTORY (IV) ▸ 2.2 (March 2020): ▸ Unity support ▸

    Developer payload introduced in 2.0 is deprecated in favour of an API to send obfuscated profile and account ids to Google’s backend: ▸ BillingFlowParams.setObfuscatedAccountId() ▸ BillingFlowParams.setObfuscatedProfileId() ▸ Purchase.getAccountIdentifiers() GOOGLE PLAY BILLING
  9. CURRENT ▸ 3.0-3.0.2 (June 2020): ▸ Purchase Attribution instead of

    Developer Payload ▸ Cash payments support (SE Asia) ▸ Bugfixes & removal of deprecated functionality GOOGLE PLAY BILLING HUH???
  10. GENERAL ▸ Google Play Billing Library sits in a wider

    context ▸ General policies and legislation ▸ Google Play Store features and policies PLAY STORE CHANGES
  11. FEATURE <> LIBRARY CYCLE ▸ Continuous loop of: ▸ New

    feature X in GPBL and initial optional support in Play Store. ▸ X becomes the default in Play Store and you have to take action to disable. ▸ X becomes mandatory from certain date onwards. ▸ Typical there are 1-2 of these mandatory feature “deadlines” per year. PLAY STORE CHANGES
  12. ACKNOWLEDGING PURCHASES/SUBSCRIPTIONS ▸ Purchases and Subscriptions need to be re-acknowledged

    since GPBL 2.0 ▸ It’s kind of a manual callback you have to consciously make ▸ If not done, automatic refund after 72hrs ▸ 2 options: ▸ from Android client via GPBL: BillingClient.acknowledgePurchase(…) or .consumeAsync(…) ▸ via backend-to-backend API: purchases.subscriptions.acknowledge PLAY STORE CHANGES
  13. PENDING PURCHASES ▸ Support for transactions that require additional steps

    between purchasing and processing payment: cash or vouchers. ▸ Introduced in GPBL 2.0 and so far only applicable to Purchases ▸ Enable: BillingClient.enablePendingPurchases(…) ▸ Android client via GPBL: queryPurchases() and getPurchaseState() ▸ via backend Real-Time Notification: ONE_TIME_PRODUCT_PURCHASED PLAY STORE CHANGES
  14. DEVELOPER PAYLOAD (I) ▸ Use case: ▸ You want to

    pass-through customer or member information in the actual payment request via GPBL. ▸ Then via backend-to-backend API or Real-Time Notifications your backend can retrieve this information for your own purposes. ▸ Introduced in GPBL 2.0, very flexible solution ▸ Deprecated in GPBL 2.2 (replaced with obfuscated profile/account ids) ▸ Removed in GPBL 3.0 PLAY STORE CHANGES
  15. DEVELOPER PAYLOAD (II) ▸ The obfuscated information is later available

    in the backend-to-backend API. ▸ obfuscatedExternalAccountId and obfuscatedExternalProfileId in two response resources: ▸ SubscriptionPurchase ▸ ProductPurchase ▸ Available from GPBL 2.2 and if you’re moving to 3.0, the original developer payload is gone! PLAY STORE CHANGES
  16. RESTORE SUBSCRIPTIONS ▸ Gives users the option to restore a

    cancelled, but not yet expired subscription. ▸ Used to be optional, is required since 1 November 2020. Users get communication from Google Play. ▸ If your app doesn’t have a backend, this is hard to support properly. ▸ Best: via backend Real-Time Notification: SUBSCRIPTION_RESTARTED PLAY STORE CHANGES
  17. ACCOUNT HOLD ▸ Subscriptions fall into account hold when payments

    fail (99.99% is CC expiry). ▸ Used to be optional, became mandatory to support 1 November 2020. Users get communication from Google Play. ▸ Disable user’s access or subscribed features & communicate. ▸ If your app doesn’t have a backend, this is - once again - hard to support properly. ▸ Best: via backend Real-Time Notification: SUBSCRIPTION_ON_HOLD and SUBSCRIPTION_RECOVERED PLAY STORE CHANGES
  18. PAUSE (I) ▸ Gives users the option to pause a

    subscription (1 week to 3 months). ▸ Since 1 November 2020, this is enabled by default in Google Play, but can be switched off. ▸ Probably the most complex flow in the GPBL subscriptions ecosystem. ▸ If your app doesn’t have a backend, this is - once again - hard to support properly. PLAY STORE CHANGES
  19. RESUBSCRIBE ▸ Gives users the option to resubscribe to a

    cancelled and expired subscription. ▸ Since 1 November 2020, this is enabled by default in Google Play, but can be switched off. ▸ If your app doesn’t have a backend, this is - once again - hard to support properly. ▸ Very similar to a restored subscription, but: ▸ new purchaseToken ▸ additional linkedPurchaseToken PLAY STORE CHANGES
  20. USING AIDL OR GPBL 1.X? ▸ You need to have

    migrated off either by mid-2021. ▸ Depending on when you act, this would be to GPBL 3.x or a future 4.x release. ▸ When you migrate from AIDL: welcome to the new world. ▸ Biggest changes when switching from 1.x: ▸ Acknowledge your purchases ▸ Lots of new subscription behaviours to adhere to WHAT NEXT?
  21. USING GPBL 2.X? ▸ You need to have migrated off

    2.x by mid-2021. ▸ Depending on when you act, this would be to GPBL 3.x or a future 4.x release. ▸ Reasonably small migration, but be aware of subscription changes WHAT NEXT?
  22. EVERYONE ▸ Don’t just look at GPBL releases. ▸ Check

    the ongoing Google Play Store policy and feature changes. ▸ Don’t miss deadlines for mandatory changes, it will cost you money. WHAT NEXT?
  23. OTHER THINGS GET IN TOUCH Kai Koenig Email: [email protected] Work:

    http://www.ventego-creative.co.nz Twitter: @AgentK Slides: https://speakerdeck.com/therealagentk 

  24. OTHER THINGS RESOURCES (I) ▸ Google Play Billing library release

    notes:
 https://developer.android.com/google/play/billing/ billing_library_releases_notes.html ▸ Google Play Billing library developer docs:
 https://developer.android.com/google/play/billing/billing_overview ▸ Google Play Developer API:
 https://developers.google.com/android-publisher/

  25. OTHER THINGS RESOURCES (II) ▸ Various in-app-billing sample apps:
 https://github.com/googlesamples/android-play-billing

    ▸ Google Play Developer API for purchases and subscriptions:
 https://developers.google.com/android-publisher/api-ref/purchases/products
 https://developers.google.com/android-publisher/api-ref/purchases/ subscriptions