Digital Goods API (Play Billing in a TWA)
Lets a Play Store web app sell in app items through Google Play.
In one line
Can sell in app items in a Play Store web app through Google Play
Lets a Play Store web app sell in app items through Google Play.
Lists products and past purchases of the account inside a TWA; needs Play account.
What it can and can't do
What the user does: You tap Buy on an in app item inside a Play Store web app.
It can
- Show the items for sale and their prices from Google Play
- Open the Google Play payment sheet
- Check which items you already own
It cannot
- Charge you without the Play Billing sheet
- Work in Safari, Firefox, Edge or on iPhone
- Work in a plain web page that is not installed from the Play Store
- See your card number
How it differs between platforms: Only Android Chrome inside a Play Store app (a TWA) supports it. iPhone has nothing like it for web apps.
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Partial | 101 | 2022-04-26 | ChromeOS TWA only |
| Edge | Not supported | Not available | Not listed | None |
| Firefox | Not supported | Not available | Not listed | None |
| Safari | Not supported | Not available | Not listed | None |
| Safari on iPhone | Not supported | Not available | Not listed | None |
| Chrome on Android | Supported | 101 | 2022-04-26 | TWA only |
| Samsung Internet | Not supported | Not available | Not listed | None |
How a site asks for it
| API | const svc = await window.getDigitalGoodsService('https://play.google.com/billing'); svc.getDetails(), svc.listPurchases() |
| Browser compat keys | api.DigitalGoodsService |
| How access is granted | install |
| What the user sees | Play Billing sheet |
| Needs a secure context (HTTPS) | Yes |
| Needs a user gesture | No |
| How long it lasts | Per origin |
| How to take it back | Site settings |
| Inside an iframe | Same as top level; cross-origin iframes need a permissions policy where listed |
Typical flow
- Call the API
- Browser applies its access rules
- Page receives the result
Data you get
What comes back: Lets a Play Store web app sell in app items through Google Play.
Shape: object
How often: on demand
| Field | Type | Unit | Range | Precision |
|---|---|---|---|---|
itemDetails.price | object | None | currency and value | Not listed |
purchases[].purchaseToken | string | None | from PaymentRequest details | acknowledge on the backend |
Technical limits
- Only inside a TWA published on Google Play
- Play refunds unacknowledged purchases after 3 days
- Requires Play Developer and Google Payments accounts and Digital Asset Links
The story
What it is
A Play Store web app can sell items and subscriptions through Google Play.
For you
You buy a subscription in an Android app that is secretly a website, and Google Play handles the payment and bill.
For makers
Makers who put a web app on the Play Store must use Play Billing for digital goods. This API lets the web code do it without a separate native app.
Where you see it
| Type | Example | Apps |
|---|---|---|
| games | A casual web game sold on Google Play adds coins and removes ads with in app purchases. | None named |
| media | A news PWA sells monthly subscriptions through Play. | None named |
| music | A music practice app sells premium lessons. | None named |
| education | A language learning PWA sells a yearly plan. | None named |
| productivity | A notes app unlocks pro features with a one time purchase. | None named |
| ads | A free app sells 'remove ads' as a one time item. | None named |
Risks
- Store lock in
- Only some Android apps
What the platform says
- Google: Digital Goods API. Chrome's docs explain how Trusted Web Activity apps can take payments with Play Billing.
Good uses and abuse
Legitimate uses
- Subscriptions in a PWA
Known abuse
- None notable
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 3 of 5 | How revealing the data is |
| Utility | 3 of 5 | How useful it is to honest apps |
| Friction | 1 of 5 | How much the user has to do |
| Fingerprint bits | Not rated | Rough identifying entropy, when known |
History
- 2021-10, Chrome 101: Digital Goods API on Android and ChromeOS in a TWA
Sources
How well checked: Checked against real behavior.