コンテンツにジャンプ

Create Android Auto-Renewable Subscription

GitHub

自動更新可能なサブスクリプションは、ユーザーがキャンセルするまで、毎回の請求期間の終わりで自動的に更新されます。

概要

概要

サブスクリプションは、以下の用途に適しています。

  • プレミアムコンテンツへのアクセス
  • 広告なしのエクスペリエンス
  • クラウドストレージ
  • 継続的なサービス

サブスクリプションの作成

サブスクリプションの作成
  1. サブスクリプションに移動

    Google Play Consoleでアプリを選択し、左のメニューから Monetize > サブスクリプション をクリックしてください。

    サブスクリプションを作成 サブスクリプションに移動 基本情報を入力

    サブスクリプション名と製品IDを入力してください。製品IDはアプリ内で設定する必要がありますが、後で変更することはできません。

  2. __CAPGO_KEEP_0__

    __CAPGO_KEEP_1__

    __CAPGO_KEEP_2__

  3. Base Planを作成

    Google Playでは、1つのサブスクリプションにつき1つの基本プランが必要です。native-purchasesプラグインは、iOSの互換性を維持するために、1つの基本プランのみをサポートしています。

    Click 基本プランを追加して続行 を続行

    Base Planを作成

  4. 基本プランの詳細を設定

    入力

    • 基本プランID基本プランIDは一意の識別子です
    • 請求期間ユーザーが請求される頻度を指定します(週、月、年など)
    • grace period: __CAPGO_KEEP_0__ window during which Google maintains the subscription while retrying payment before cancellation

    Configure base plan

  5. Set Up Pricing

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

    Select regions

  6. Configure Price

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

    Set price

  7. Review Regional Pricing

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

    Review pricing

  8. __CAPGO_KEEP_0__

    __CAPGO_KEEP_1__

    __CAPGO_KEEP_2__

  9. __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__

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
}

アプリ内にサブスクリプションが表示されない場合:

  • 製品IDが正確に一致していることを確認
  • __CAPGO_KEEP_0__を有効化する
  • __CAPGO_KEEP_1__が正しいパッケージ名を持つことを確認する
  • __CAPGO_KEEP_0__が有効化された後、2-3時間待って変更が反映される

基本プランエラー:

  • __CAPGO_KEEP_0__が1つだけあることを確認する
  • 必要なすべてのフィールドが入力されていることを確認する
  • 請求期間が有効であることを確認する

価格に関する問題:

  • 少なくとも1つの国を選択していることを確認する
  • 基本価格が許可されている最小価格より大きいことを確認する
  • 通貨変換レートが受け入れられることを確認する

Create Android Auto-Renewable Subscriptionから続ける

Android Auto-Renewable サブスクリプションの作成から続ける

Capgoを使用している場合 Android Auto-Renewable サブスクリプションの作成 Capgoを使用して Using @capgo/native-purchases for the native capability in Using @capgo/native-purchases, @capgo/capacitor-in-app-review for the implementation detail in @capgo/capacitor-in-app-review, Using @capgo/capacitor-in-app-review for the native capability in Using @capgo/capacitor-in-app-review, @capgo/capacitor-native-market for the implementation detail in @capgo/capacitor-native-market, and 使用@capgo/capacitor-native-market for the native capability in 使用@capgo/capacitor-native-market。