GoogleChrome / GoogleChrome/android-browser-helper
Base Plans are not supported in subscriptions
- Dominant language
- Java
- Stars
- 832
- Forks
- 370
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 6
Description
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](https://github.com/GoogleChromeLabs/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](https://developer.chrome.com/docs/android/trusted-web-activity/receive-payments-play-billing/). 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:
- `premium-membership`
- `premium-membership-half-yearly`
- `premium-membership-yearly`
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:
```js
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
```js
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):**
- OS: Android 13
- Browser Chrome
- Version: 116
**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.
Contributor guide
Assessment
This issue has not been assessed yet.