Create Android Auto-Renewable Subscription
复制一个包含安装步骤和本插件的完整 Markdown 指南的配置提示。
自动续订订阅提供对应用程序内容、服务或高级功能的持续访问。这个指南将帮助您在 Google Play Console 中创建和配置订阅。
订阅将在每个计费周期结束时自动续订,直到用户取消。它们适用于:
- 高级内容访问
- 无广告体验
- 云存储
- Ongoing services
Creating a Subscription
Section titled “Creating a Subscription”-
Navigate to Subscriptions
In Google Play Console, select your app and choose Monetize > Subscriptions from the left menu.
Click the Create subscription button to begin.

-
Enter Basic Information
提供一个订阅名称和产品ID。产品ID用于在您的应用中配置,且不可更改。

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

-
配置基本计划详细信息
输入:
- 基本计划ID:此计划的唯一标识符
- Billing period: How often users are charged (weekly, monthly, yearly, etc.)
- Grace period: Time window during which Google maintains the subscription while retrying payment before cancellation

-
Set Up Pricing
Access the pricing section and select all countries/regions where you want to offer the subscription.

-
Configure Price
Set your base price in your primary currency. Google Play automatically converts this to local currencies.

-
Review Regional Pricing
[__CAPGO_KEEP_0__]

-
查看价格
保存配置

-
保存价格
激活订阅 点击 激活

激活订阅
重要考虑因素基础计划限制
标题:基础计划限制native-purchases 插件需要每个订阅都有一个基础计划,以确保与 iOS 订阅处理一致。多个基础计划不受支持。
宽限期
标题:宽限期宽限期允许 Google Play 重试失败的付款,同时保持用户的订阅访问。常见的宽限期是:
- 每月订阅 3 天
- 较长订阅 7 天
订阅状态
标题:订阅状态创建后,订阅将处于“草稿”状态,直到激活。您可以在沙盒模式下测试草稿订阅。
在您的应用中使用
Section titled “在您的应用中使用”Once created, reference the subscription in your app using the product 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的原生能力