跳过内容

创建 Android 自动续订订阅

GitHub

自动续订的订阅提供对应用程序中的内容、服务或高级功能的持续访问。 本指南将帮助您在Google Play Console中创建和配置订阅.

订阅将在每个 billing 期间结束时自动续订,直到用户取消。它们适用于:

  • 高级内容访问
  • 广告免费体验
  • 云存储
  • 持续服务
  1. 前往订阅

    在 Google Play Console 中,选择您的应用程序并选择 monetize > 订阅 从左侧菜单中

    点击__CAPGO_KEEP_0__ 创建订阅 开始按钮.

    前往订阅

  2. 输入基本信息

    请输入订阅名称和产品ID。产品ID用于在应用中配置,且不可更改。

    输入订阅详细信息

  3. 创建基本计划

    Google Play要求每个订阅至少有一个基本计划。native-purchases插件仅支持一个基本计划,以保持与iOS的兼容性。

    点击 添加基本计划 继续.

    创建基本计划

  4. 配置基本计划详细信息

    输入:

    • 基本计划 ID: 本计划的唯一标识符
    • 计费周期: 用户每次被收费的频率(每周、每月、每年等)
    • 宽限期: Google 在重试支付前维持订阅的时间窗口

    配置基本计划

  5. 设置定价

    访问定价部分并选择您希望提供订阅的所有国家/地区

    选择区域

  6. 配置价格

    在您的主要货币中设置您的基本价格。Google Play会自动将其转换为当地货币。

    设置价格

  7. 查看区域定价

    查看Google Play自动转换的每个国家的价格。您可以根据需要调整单独的价格。

    查看定价

  8. 保存配置

    保存您的定价配置。

    保存定价

  9. 激活订阅

    点击 激活 button to make your subscription product live and available for purchase.

    激活订阅

重要注意事项

重要注意事项

基本计划限制

基本计划限制

native-purchases 插件要求每个订阅都有一个基本计划,以保持与 iOS 订阅处理的一致性。支持的基本计划数量为 1。

宽限期

宽限期

宽限期允许 Google Play 重试失败的支付,同时保持用户的订阅访问。常见的宽限期包括:

  • 每月订阅 3 天
  • 较长订阅 7 天

订阅状态

订阅状态

创建后,订阅将处于“草稿”状态,直到激活。您可以在沙盒模式下测试草稿订阅。

在您的应用中使用

在您的应用中使用

创建后,请使用产品ID引用订阅:

import { NativePurchases, PURCHASE_TYPE } from '@capgo/native-purchases';
// Load subscription info
const { 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 state
const { 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
}

下一步

下一步

__CAPGO_KEEP_2__

__CAPGO_KEEP_3__

__CAPGO_KEEP_4__

  • __CAPGO_KEEP_5__
  • __CAPGO_KEEP_6__
  • __CAPGO_KEEP_7__
  • __CAPGO_KEEP_8__

__CAPGO_KEEP_9__

  • __CAPGO_KEEP_10__
  • __CAPGO_KEEP_11__
  • 检查账单周期是否有效

价格问题:

  • 确认至少选择一个国家
  • 验证基础价格大于允许的最小价格
  • 检查汇率是否可接受

继续从创建 Android Auto-Renewable 订阅

标题:继续从创建 Android Auto-Renewable 订阅

如果您正在使用 创建 Android Auto-Renewable 订阅 以计划商店审批和分发为目的,连接它与 使用 @capgo/native-purchases 为使用 @capgo/native-purchases 的原生能力 @capgo/capacitor-in-app-评论 for the implementation detail in @capgo/capacitor-in-app-评论, Using @capgo/capacitor-in-app-评论 for the native capability in Using @capgo/capacitor-in-app-评论, @capgo/capacitor-native市场 for the implementation detail in @capgo/capacitor-native市场, and Using @capgo/capacitor-native市场 for the native capability in Using @capgo/capacitor-native市场.