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

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

30966c6e1a52faf6b287b59a01195938?s=47 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.

30966c6e1a52faf6b287b59a01195938?s=128

Kai Koenig

December 14, 2020
Tweet

Transcript

  1. GOOGLE PLAY BILLING LIBRARY 3 
 IS EVERYTHING DIFFERENT AND

    NEW AGAIN? KAI KOENIG (@AGENTK)
  2. None
  3. None
  4. None
  5. GOOGLE PLAY IN-APP BILLING SERVICE

  6. 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
  7. GOOGLE PLAY BILLING LIBRARY https://www.flickr.com/photos/vpickering/6488181673/

  8. Client Server APP Google Play Google Play Server G
 P


    B
 L Backend application Google Play 
 Developer API
  9. REAL-TIME NOTIFICATIONS GOOGLE PLAY BILLING GCP Pub/Sub Backend application Google

    Play 
 Developer API
  10. 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
  11. 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
  12. GOOGLE PLAY BILLING LIBRARY GOOGLE PLAY BILLING

  13. BILLINGCLIENT & FRIENDS GOOGLE PLAY BILLING

  14. READ THE COMMENTS GOOGLE PLAY BILLING

  15. NATIVE CALLBACKS GOOGLE PLAY BILLING

  16. MANAGEMENT AND HELPERS GOOGLE PLAY BILLING

  17. CONNECTION - INTERNAL GOOGLE PLAY BILLING

  18. GPBL AND IN-APP-BILLING SERVICE VERSIONS GOOGLE PLAY BILLING

  19. GPBL HISTORY https://www.flickr.com/photos/shallom/2367314991/

  20. 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
  21. 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
  22. 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
  23. 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
  24. 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???
  25. PLAY STORE CHANGES

  26. GENERAL ▸ Google Play Billing Library sits in a wider

    context ▸ General policies and legislation ▸ Google Play Store features and policies PLAY STORE CHANGES
  27. 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
  28. GPBL UPDATE DEADLINES PLAY STORE CHANGES

  29. RECENT CHANGES

  30. 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
  31. 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
  32. 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
  33. PLAY STORE CHANGES

  34. 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
  35. 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
  36. 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
  37. 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
  38. PAUSE (II) PLAY STORE CHANGES

  39. PAUSE (III) PLAY STORE CHANGES

  40. 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
  41. SUBSCRIPTION STATES PLAY STORE CHANGES

  42. WHAT NEXT? https://www.flickr.com/photos/tschiae/8080742303/ https://www.flickr.com/photos/37149125@N04/10170683255

  43. 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?
  44. 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?
  45. 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?
  46. OTHER THINGS GET IN TOUCH Kai Koenig Email: kai@ventego-creative.co.nz Work:

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

  47. 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/

  48. 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