Skip to Content
Platform.Ontology

Digital Goods API (Play Billing in a TWA)

Lets a Play Store web app sell in app items through Google Play.

Works without askingPayments and shoppingIn appWeb browsersWhile you use it

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

BrowserStatusFirst versionReleasedNote
ChromePartial1012022-04-26ChromeOS TWA only
EdgeNot supportedNot availableNot listedNone
FirefoxNot supportedNot availableNot listedNone
SafariNot supportedNot availableNot listedNone
Safari on iPhoneNot supportedNot availableNot listedNone
Chrome on AndroidSupported1012022-04-26TWA only
Samsung InternetNot supportedNot availableNot listedNone

How a site asks for it

APIconst svc = await window.getDigitalGoodsService('https://play.google.com/billing'); svc.getDetails(), svc.listPurchases()
Browser compat keysapi.DigitalGoodsService
How access is grantedinstall
What the user seesPlay Billing sheet
Needs a secure context (HTTPS)Yes
Needs a user gestureNo
How long it lastsPer origin
How to take it backSite settings
Inside an iframeSame as top level; cross-origin iframes need a permissions policy where listed

Typical flow

  1. Call the API
  2. Browser applies its access rules
  3. 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

FieldTypeUnitRangePrecision
itemDetails.priceobjectNonecurrency and valueNot listed
purchases[].purchaseTokenstringNonefrom PaymentRequest detailsacknowledge 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

TypeExampleApps
gamesA casual web game sold on Google Play adds coins and removes ads with in app purchases.None named
mediaA news PWA sells monthly subscriptions through Play.None named
musicA music practice app sells premium lessons.None named
educationA language learning PWA sells a yearly plan.None named
productivityA notes app unlocks pro features with a one time purchase.None named
adsA free app sells 'remove ads' as a one time item.None named

Risks

  • Store lock in
  • Only some Android apps

What the platform says

Good uses and abuse

Legitimate uses

  • Subscriptions in a PWA

Known abuse

  • None notable

Scores

ScoreValueMeaning
Sensitivity3 of 5How revealing the data is
Utility3 of 5How useful it is to honest apps
Friction1 of 5How much the user has to do
Fingerprint bitsNot ratedRough 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.

On this page