GoogleChrome / android-browser-helper

The Android Browser Helper library helps developers use Custom Tabs and Trusted Web Activities on top of the AndroidX browser support library.
Apache License 2.0
694 stars 288 forks source link

Base Plans are not supported in subscriptions #449

Open tintin10q opened 1 year ago

tintin10q commented 1 year ago

I am working on a new twa that is close to launching but I am currently a bit lost on how to get subscription base plans to work in a bubblewrap twa.

Describe the bug

Base plans are not supported in a bubblewrap TWA. You can only query the base plan selected as backwards compatible.

I have enabled google play billing during bubblewrap setup. Like described here. This is also the guide I am following to implement the payment request.

So I have a subscription (in the google play console) with the id: premium_membership.

This subscription has 3 base plans:

The premium-membership base plan is the one marked as the backwards compatible base plan for the premium_membership subscription.

I expected that I would be able to query the information about the base plans like this:

const service = await window.getDigitalGoodsService('https://play.google.com/billing');
const details = await service.getDetails(['premium-membership', 'premium-membership-half-yearly', 'premium-membership-yearly']); 
console.log(details); // empty list

But this does not work. You can only do getDetails for the subscription id. In this case that is premium_membership.

A PaymentRequest also does not work with base plans. You get an error if you try to make an payment request with a base plan. See below.

To Reproduce

Steps to reproduce the behavior:

First do this setup:

  1. Go to the developer console
  2. Make a subscription
  3. Make a couple base plans

Then: Try to query the details for a baseplan with the code above.

Or try to subscribe to a baseplan with something like

await new PaymentRequest([{supportedMethods: "https://play.google.com/billing", data:{ sku: 'premium-membership-half-yearly'  }}], {}).show();

You will get Payment app returned RESULT_CANCELED code. This is how payment apps can close their activity programmatically.

The PaymentRequest only works with the subscription id, which in this case is premium_membership. This payment request will give you the base plan that you have marked as backwards compatible in the google play console. To me it seems currently impossible to subscribe to other base plans of a subscription in a bubble wrap twa.

Work around

As I currently cannot access the base plans besides the backwards compatible one. You would be forced to make different subscriptions for each subscription duration. This is really inconvenient because these different subscriptions are not really linked in any way. This means that it makes it impossible for a subscriber to upgrade or downgrade their current subscription without canceling it and resubscribing to a different subscription.

Expected behavior

I expect the subscription base plans to work in the bubblewrap twa.

Smartphone (please complete the following information):

Additional context

Am I missing something? I could not find anyone talking about not being able to select a base plan in a bubblewrap twa.