# 变现

> PWA 的广告、Web 支付、数字商品、订阅与联盟链接，以及在开放 Web 与商店构建两种场景下，分别由哪条书面商店或广告网络政策约束。

PWA 可以靠广告、Web 支付、数字商品、订阅或联盟链接获得收入。同一套代码从不同渠道分发，适用的规则也不同。
从浏览器安装时，结账不在商店结算政策的范围内；同一源打包成 Trusted Web Activity 并经 Google Play 分发后，就须遵守 Play 的结算政策。

## 工作原理

商店政策适用于分发的应用包。从浏览器安装的 PWA 适用广告网络和支付服务商的条款；同一个源若经 Play 或 Microsoft Store 分发，还须遵守相应商店的付款条款。

### 广告

Google 的 AdSense 计划政策（最近更新于 2026-08-04）允许 AdSense 代码放在网页上，禁止「integrated into a software application (does not apply to AdMob) of any kind, including toolbars」。同一政策列出了可以从应用内展示 Web 广告的展示容器：Android 上是「Chrome Custom Tabs and Trusted Web Activities」；普通 `WebView` 则必须通过 WebView API for Ads 配合 Google Mobile Ads SDK 注册。从浏览器安装的 PWA 是该浏览器渲染的网页，适用 Web 规则；TWA 属于政策列明的容器；套 `WebView` 的原生壳走 SDK 路径。各广告网络的具体要求见[广告网络](/zh/ecosystem/ad-networks/)。

### Web 支付

在开放 Web 上，PWA 通过 [Payment Request API](/zh/compatibility/payment-request/)、钱包（Apple Pay、Google Pay）或服务商的 JavaScript SDK 收款，没有商店分发这个页面，也就没有商店结算政策可言。可用的支付方式取决于浏览器。Firefox 把 Payment Request 放在 `dom.payments.request.enabled` 偏好之后（[browser-compat-data](https://github.com/mdn/browser-compat-data/blob/main/api/PaymentRequest.json)）；Safari 只支持 Apple Pay 这一种支付方式（[Apple](https://developer.apple.com/documentation/apple_pay_on_the_web/payment_request_api)）。各方式的覆盖情况见[支付](/zh/ecosystem/payments/)。

### 商店构建内的数字商品

Google Play 付款政策第 2 节要求「requiring or accepting payment for access to in-app features or services」的应用使用 Google Play 结算系统，除非第 3、8、9 节适用；第 3 节把实体商品、实体服务、账单、个人间转账与赌博列为例外。在 TWA 内，网页通过 Chrome 101 及以后的 [Digital Goods API](/zh/reference/capabilities/digital-goods/) 访问 Play 结算：先调用 `window.getDigitalGoodsService('https://play.google.com/billing')`，再把同一字符串作为 `supportedMethods` 传给 `PaymentRequest`，方法数据为 `{ sku }`。Microsoft Store 的范围更窄：政策 10.8.1（7.20 版，2026-10-22 生效）要求游戏（PC 游戏订阅产品中的游戏除外）与 Xbox 主机产品使用 Store 应用内购买 API；其他 PC 产品可以使用「a secure third-party purchase API」。Apple 指南 3.1.1 要求用应用内购买解锁功能，但它只适用于 App Store 应用，而 Apple 没有记载 PWA 的提交路径。

### 订阅与联盟链接

Play 要求使用 Play 结算的清单里有「subscription services」，所以经 Play 分发的 TWA 要通过 Play 结算售卖订阅（Chrome 指南把 Digital Goods API 与 Payment Request 搭配使用），除非第 3、8、9 节适用；浏览器安装的那份可以继续使用服务商的周期计费。联盟链接不需要任何 API，限制来自政策：Play 的垃圾内容政策拒绝「whose primary purpose is to drive affiliate traffic to a website」的应用，因此主要内容是外链优惠的 TWA 存在上架风险。同一页面作为浏览器安装不在 Play 这条规则之内，不过 AdSense 对联盟带来的流量另有限制。

| 路径 | 浏览器安装 | Trusted Web Activity（Play） | Microsoft Store 包 |
|---|---|---|---|
| 广告 | AdSense Web 规则 | AdSense Web 规则（被点名的框架） | AdSense Web 规则，加 Store 政策 10.10 |
| 一次性数字商品 | 任意 PSP | 经 Digital Goods API 的 Play 结算（第 3、8、9 节适用时除外） | 任意安全 PSP；游戏与 Xbox 用 Store API（10.8.1） |
| 订阅 | 任意 PSP | 经 Digital Goods API 的 Play 结算（第 3、8、9 节适用时除外） | 任意安全 PSP；游戏与 Xbox 用 Store API（10.8.1） |
| 实体商品 | 任意 PSP | 任意 PSP（付款政策第 3 节） | Payment Request 或第三方 API（10.8.2） |
| 联盟链接 | 无商店规则（投放广告时有 AdSense 流量限制） | 若为主要目的则触发垃圾内容政策 | 10.1.1 如实描述 |

## 实测行为

:::caution
Chrome 的 [Play 结算指南](https://developer.chrome.com/docs/android/trusted-web-activity/receive-payments-play-billing)（2021-01-26 更新）写明：页面经 `http` 提供时 `getDigitalGoodsService` 为 `undefined`。在开发设备上测试时，指南要求 Android 9 及以后并开启开发者模式、Chrome 101 或更新版本，以及 `chrome://flags/#enable-debug-for-store-billing`；从 Play 商店下载的应用不需要这个标志。在 Bubblewrap 1.8.2 及以后启用结算要改 `twa-manifest.json` 里的两处：`"features": { "playBilling": { "enabled": true } }` 与 `"alphaDependencies": { "enabled": true }`，再执行 `bubblewrap update` 与 `bubblewrap build`。
:::

同一指南还指出，`PaymentRequest` 要求提供 `paymentDetails.total`，Play 结算却会忽略这个值。后端未确认的购买会在三天后退款并撤销。

## 另请参阅

- [Google Play Payments policy](https://support.google.com/googleplay/android-developer/answer/9858738)（support.google.com）
- [AdSense Program policies](https://support.google.com/adsense/answer/48182)（support.google.com）
- [Receive payments via Google Play Billing with the Digital Goods API](https://developer.chrome.com/docs/android/trusted-web-activity/receive-payments-play-billing)（developer.chrome.com）
- [支付](/zh/ecosystem/payments/)
- [广告网络](/zh/ecosystem/ad-networks/)
- [Digital Goods API](/zh/reference/capabilities/digital-goods/)
- [PWA 变现](/zh/guides/monetization/)

← 返回[生态](/zh/ecosystem/)总览。