Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Google Play's new subscription model and APIs #1338

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

tomwadeson
Copy link
Contributor

What does this change?

This PR migrates us to Google Play's new subscription model (and associated APIs.) See here for more details: https://developer.android.com/google/play/billing/compatibility

Outstanding

How to test

This is a good question!

There is an existing absence of test coverage for the affected area of the codebase due, I suspect, to the difficulty (impossibility?) of automating any useful/non-trivial integration tests:

To test this manually requires access to the Google Play project; a user account that has license testing privileges (and potentially in the right state—i.e., having not already taken out a subscription, or having not previously benefited from a free trial); and a debug build of the Android app that is configured to surface the underlying purchaseToken. Testing the lifecycle of subscriptions also has slow feedback loops as we must wait for subscriptions to progress through their various states of activation, renewal and expiry etc. without having the means to control this programmatically.

We have conducted many manual tests of this migration effort (and refined the implementation as a result of edge cases that we've encountered), but I suspect that to be entirely confident of this change prior to pushing it live, we would want to run it in parallel with the existing implementation to compare (hopefully) like-for-like.

How can we measure success?

Have we considered potential risks?

Images

Accessibility

Copy link
Member

@tjmw tjmw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good! I've left a handful of comments but nothing major - all nitpicky stuff to take or leave.

typescript/src/services/google-play.ts Outdated Show resolved Hide resolved
typescript/src/services/google-play.ts Show resolved Hide resolved
typescript/src/services/google-play.ts Outdated Show resolved Hide resolved
typescript/src/services/google-play.ts Outdated Show resolved Hide resolved
typescript/src/services/google-play.ts Outdated Show resolved Hide resolved
tjmw added a commit that referenced this pull request Jun 10, 2024
Use the purchases.subscriptionsv2 [1] endpoint to retrieve data about Android
Feast subs, instead of purchases.subscriptions v1 [2] (which we use for the
live app).

The reason for the migration is that when using the v1 endpoint, we rely on
being able to map a product ID to a billing duration. This mapping is defined
here [3].

This isn't very robust (in the past, new products have been added in the Play
store, but not reflected here, meaning we get rows without a billing period).
Furthermore, the was the Feast app has been configured in the Play store, it's
not actually possible to map things this way. Instead, if we use the v2
endpoint, we can retrieve the billing period using Play store APIs.

Some back story on the v2 endpont: Tom Wadeson did some work to implement the
v2 endpoint. In prod there's a test which uses the v2 endpoint in parallel with
the v1 endpoint for x% of requests to the subscriptions endpoint. There's a
draft PR #1338 to use the new endpoint everywhere, but not merged yet. Using
this for Feast feels like a nice step in the migration path as we're using it
for real but in a focused context.

[1]: https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2
[2]: https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions
[3]: https://github.com/guardian/mobile-purchases/blob/bb1632ea1e53d0fb2ca0e870b67677558a4ea2b9/typescript/src/services/productBillingPeriod.ts#L4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants