创建 Android Auto-Renewable 订阅
复制一个包含安装步骤和本插件完整 Markdown 指南的设置提示。
自动续订订阅提供对应用程序内容、服务或高级功能的持续访问。 本指南将帮助您在 Google Play Console 中创建和配置订阅。
订阅将在每个 billing 期间结束时自动续订,直到用户取消订阅。它们适用于:
- 高级内容访问
- 广告免费体验
- 云存储
- 持续服务
创建订阅
订阅创建-
前往订阅
在 Google Play Console 中,选择您的应用并选择 Monetize > Subscriptions from the left menu.
Click the Create subscription button to begin.

-
Enter Basic Information
点击创建订阅按钮开始。前往订阅

-
创建基本计划
Google Play 需要每个订阅恰好有一个基本计划。 native-purchases 插件仅支持一个基本计划以保持与 iOS 的兼容性。
点击 添加基本计划 继续。

-
配置基本计划详细信息
输入:
- 基本计划 ID: 本计划的唯一标识符
- 计费周期: How often users are charged (weekly, monthly, yearly, etc.)
- Grace period:

-
Configure base plan
Set Up Pricing

-
Configure Price
Configure Price

-
Review Regional Pricing
Review the automatically converted prices for each country. You can adjust individual prices if needed.

-
保存配置
保存您的价格配置。

-
激活订阅
点击 激活 按钮以使您的订阅产品活跃并可供购买。

重要考虑
标题为“重要考虑”的部分基础计划限制
基本计划限制native-purchases 插件需要每个订阅都有一个基本计划以确保与 iOS 订阅处理一致。多个基本计划不受支持。
宽限期
宽限期宽限期允许 Google Play 重试失败的支付,同时保持用户的订阅访问。常见的宽限期是:
- 每月订阅 3 天
- 较长订阅 7 天
在您的应用中使用
创建后,使用产品 ID 在您的应用程序中引用订阅:
import { NativePurchases, PURCHASE_TYPE } from '@capgo/native-purchases';
// Load subscription infoconst { products } = await NativePurchases.getProducts({ productIdentifiers: ['com.example.premium.monthly'], productType: PURCHASE_TYPE.SUBS,});
const product = products[0];console.log(`${product.title} — ${product.priceString}`);
// Purchase (planIdentifier = Base Plan ID from Google Play Console)const transaction = await NativePurchases.purchaseProduct({ productIdentifier: 'com.example.premium.monthly', planIdentifier: 'monthly-plan', // REQUIRED on Android, ignored on iOS productType: PURCHASE_TYPE.SUBS,});
console.log('Transaction ID', transaction.transactionId);
// Later, check purchase stateconst { purchases } = await NativePurchases.getPurchases({ productType: PURCHASE_TYPE.SUBS,});
const subscription = purchases.find( (purchase) => purchase.productIdentifier === 'com.example.premium.monthly',);
if (subscription && subscription.purchaseState === 'PURCHASED' && subscription.isAcknowledged) { console.log('Subscription active locally'); // For expiration/cancellation, validate purchaseToken through your backend}下一步
标题为“下一步”故障排除
标题为“故障排除”订阅未在应用程序中出现:
- 确认产品 ID 与实际匹配
- 确保订阅已激活
- 检查您的应用程序是否具有正确的包名
- 激活后等待 2-3 小时让变化传播
基础计划错误:
- 确保您有一个基础计划
- 确认所有必填字段已填写
- 检查账单周期是否有效
价格问题:
- 确认至少选择一个国家
- 确认基础价格大于允许的最小价格
- 检查货币汇率是否可接受
继续从创建 Android 自动续订订阅
继续从创建 Android 自动续订订阅如果您正在使用 创建 Android 自动续订订阅 规划商店审批和分发时,连接它与 使用 @capgo/native-purchases 在使用 @capgo/native-purchases 中的本机能力 @capgo/capacitor-in-app-review 在 @capgo/capacitor-in-app-review 中的实现细节 使用 @capgo/capacitor-in-app-review 在使用 @capgo/capacitor-in-app-review 中的本机能力 @capgo/capacitor-native-market 对于 @capgo/capacitor-native-market 的实现细节 使用 @capgo/capacitor-native-market 对于 @capgo/capacitor-native-market 的本地能力