コンテンツにジャンプする

iOS 月々のコミットメント請求計画

GitHub

Appleは、12か月の契約期間で毎月請求されるサブスクリプションをサポートしています。StoreKitと実行中のOSがこの請求計画をサポートしている場合、 @capgo/native-purchases StoreKitは価格条件を公開し、購入時に毎月請求する計画を選択し、取引と更新情報のコミットメントメタデータを返します。

年間サブスクリプションのオファーに使用します。ユーザーは毎月の支払いを好みますが、コミットメントされた年間期間の保持と予測可能性を維持したい場合。

要件

要件
  • App Store ConnectまたはXcodeのStoreKit Testingで、12か月のコミットメント請求計画を毎月に設定します。
  • Build the iOS app with an Xcode SDK that contains StoreKit pricingTerms and billingPlanType.
  • 実行中のiOSバージョンがStoreKitコミットメント請求計画をサポートしている場合に実行します。
  • 標準の請求オプションを保持して、コミットメント価格条件を返さないデバイスまたはストアフロントで利用可能なようにします。

呼び出し getProducts() context pricingTerms.

import { NativePurchases, PURCHASE_TYPE } from '@capgo/native-purchases';
const { products } = await NativePurchases.getProducts({
productIdentifiers: ['com.example.app.premium.yearly'],
productType: PURCHASE_TYPE.SUBS,
});
const premiumYearly = products.find(
(product) => product.identifier === 'com.example.app.premium.yearly',
);
const monthlyCommitment = premiumYearly?.pricingTerms?.find(
(term) => term.billingPlanType === 'monthly',
);

コピー

コピーする店頭から提供された値を表示するのではなく、ハードコードされた価格を表示します:
billingDisplayPriceフィールド
billingPeriod使用するには
commitmentInfo.priceStringユーザーのショップで表示される合計コミットメント価格。
commitmentInfo.periodコミットメント期間の全期間。
subscriptionOffers価格条件に付随する導入的またはプロモーショナルなオファー。

例のペイウォールコピー:

function commitmentLabel(term: NonNullable<typeof monthlyCommitment>) {
const total = term.commitmentInfo?.priceString;
return total
? `${term.billingDisplayPrice} billed monthly, ${total} total commitment`
: term.billingDisplayPrice;
}

ユーザーが月間コミットメントプランを選択した場合、パス billingPlanType: 'monthly'.

const transaction = await NativePurchases.purchaseProduct({
productIdentifier: 'com.example.app.premium.yearly',
productType: PURCHASE_TYPE.SUBS,
billingPlanType: 'monthly',
appAccountToken: userStoreUuid,
});

使用 billingPlanType: 'upFront' 標準の前払い請求プランを明示的に選択する必要がある場合のみ使用します。省略した場合、 billingPlanTypeStoreKitはデフォルトの購入動作を使用します。

クリップボードにコピー

if (transaction.billingPlanType === 'monthly') {
console.log('Current billing period:', transaction.commitmentInfo?.billingPeriodNumber);
console.log('Total billing periods:', transaction.commitmentInfo?.totalBillingPeriods);
console.log('Commitment ends:', transaction.commitmentInfo?.expirationDate);
console.log('Commitment total:', transaction.commitmentInfo?.price);
}

クリップボードにコピー

const { purchases } = await NativePurchases.getPurchases({
productType: PURCHASE_TYPE.SUBS,
onlyCurrentEntitlements: true,
});
for (const purchase of purchases) {
const commitment = purchase.renewalInfo?.commitmentInfo;
if (!commitment) continue;
console.log('Renews into another commitment:', commitment.willAutoRenew);
console.log('Next billing plan:', commitment.renewalBillingPlanType);
console.log('Next renewal date:', commitment.renewalDate);
}

そして expirationDate そして isActive iOS 月間コミットメント commitmentInfo.expirationDate コミットメントの決定に必要なフィールドを使用します。

  • 購入前に、繰り返し請求価格と合計コミットメント価格を表示します。
  • 購入ボタン近くでコミットメント期間を明確に表示します。
  • を使用して、 product.title, product.priceString, pricingTerms[].billingDisplayPriceからStoreKitの代わりにハードコードされた価格を使用します。 pricingTerms[].commitmentInfo.priceString 購入画面またはアカウント画面で購入の復元とサブスクリプションの管理アクションを提供します。
  • 関連ガイド
iOS 月間コミットメント

iOS 月次コミットメント請求計画から続ける

「iOS 月次コミットメント請求計画から続ける」セクション

Capgo を使用している場合 iOS 月次コミットメント請求計画を使用して支払いと購入を計画している場合 Capgo の native-purchases を使用して Capgo の native capability と Capgo の native-purchases を接続する Using @capgo/native-purchases for the native capability in Using @capgo/native-purchases, Capgo Pricing for the product workflow in Capgo Pricing, 決済システム 決済システムの実装詳細のために @capgo/native-purchases 実装詳細のために@capgo/native-purchases、 はじめに はじめにの実装詳細のために