Capgo 가이드
네이티브 구매에 대한 튜토리얼
@capgo/자연어 구매
앱 내 구독을 쉽게 관리하세요.
설치
bun add @capgo/native-purchases
bunx cap sync
이 플러그인은 다음을 제공합니다.
restorePurchases- 사용자의 이전 버전을 복원하고 사용자 ID를 연결합니다. 사용자가 동일한 ID를 사용하는 다른 사용자와 연결합니다.getAppTransaction- 앱 트랜잭션 정보를 가져옵니다. 사용자가 앱을 처음 다운로드하거나 구매한 날짜와 시간을 제공합니다.isEntitledToOldBusinessModel- 앱 트랜잭션에서 원래 앱 버전을 대상 버전과 비교하여 사용자가 이전 비즈니스 모델에서 특정 기능을 사용할 자격이 있는지 결정합니다.getProducts- iOS 구독 가격 조건을 포함하여 스토어 제품 메타데이터를 로드합니다.purchaseProduct- 선택한 제품과 청구 계획을 시작하여 구매 프로세스를 시작합니다.
예시 사용법
restorePurchases
사용자의 이전 버전을 복원하고 사용자 ID를 연결합니다. 사용자가 동일한 ID를 사용하는 다른 사용자와 연결합니다.
import { NativePurchases } from '@capgo/native-purchases';
await NativePurchases.restorePurchases();
getAppTransaction
사용자가 앱을 처음 다운로드하거나 구매한 날짜와 시간을 제공하는 앱 트랜잭션 정보를 가져옵니다.
import { NativePurchases } from '@capgo/native-purchases';
const { appTransaction } = await NativePurchases.getAppTransaction();
// Check if user downloaded before version 2.0.0 (when subscription was added)
if (compareVersions(appTransaction.originalAppVersion, '2.0.0') < 0) {
// User gets free access - they downloaded before subscriptions
grantFreeAccess();
}
isEntitledToOldBusinessModel
사용자가 이전 비즈니스 모델에서 특정 기능을 사용할 자격이 있는지 결정합니다.
import { NativePurchases } from '@capgo/native-purchases';
// Check if user downloaded before version 2.0.0/build 42 (when subscription was added)
const result = await NativePurchases.isEntitledToOldBusinessModel({
targetVersion: '2.0.0',
targetBuildNumber: '42'
});
if (result.isOlderVersion) {
console.log(`User downloaded v${result.originalAppVersion}, granting free access`);
grantFreeAccess();
}
purchaseProduct
선택한 제품에 대한 구매 프로세스를 시작합니다. 안드로이드 구독의 경우 Google Play 기본 플랜 ID를 전달하세요. planIdentifier. iOS 월간 결제 약정 서비스를 지원하는 iOS 구독을 위해 12 개월의 약정 기간을 제공하는 경우 billingPlanType: 'monthly'.
import { NativePurchases, PURCHASE_TYPE } from '@capgo/native-purchases';
await NativePurchases.purchaseProduct({
productIdentifier: 'com.example.premium.monthly',
planIdentifier: 'monthly-plan',
productType: PURCHASE_TYPE.SUBS,
});
iOS 월간 약정 구독
iOS 버전에서 지원되는 경우, StoreKit은 12 개월의 약정 기간을 제공하는 월간 결제 계획을 노출할 수 있습니다. pricingTerms. 구매 전 구매 대금을 지불하기 전에 다음 항목을 표시하십시오:
import { NativePurchases, PURCHASE_TYPE } from '@capgo/native-purchases';
const { products } = await NativePurchases.getProducts({
productIdentifiers: ['com.example.premium.yearly'],
productType: PURCHASE_TYPE.SUBS,
});
const yearlyProduct = products.find(
(product) => product.identifier === 'com.example.premium.yearly',
);
const monthlyCommitment = yearlyProduct?.pricingTerms?.find(
(term) => term.billingPlanType === 'monthly',
);
if (yearlyProduct && monthlyCommitment) {
console.log('Monthly price:', monthlyCommitment.billingDisplayPrice);
console.log('Total commitment:', monthlyCommitment.commitmentInfo?.priceString);
const transaction = await NativePurchases.purchaseProduct({
productIdentifier: yearlyProduct.identifier,
productType: PURCHASE_TYPE.SUBS,
billingPlanType: 'monthly',
});
console.log('Billing plan:', transaction.billingPlanType);
console.log('Commitment ends:', transaction.commitmentInfo?.expirationDate);
}
전체 참조
- GitHub: https://github.com/Cap-go/capacitor-native-purchases/
- 문서: /docs/plugins/native-purchases/
- iOS 월간 약정 안내: /docs/plugins/native-purchases/ios-monthly-commitment/
Using @capgo/native-purchases에서 계속 진행하세요.
이러한 기능을 사용하는 경우 Using @capgo/native-purchases 결제와 구매를 계획하고 연결하려면 @capgo/native-purchases @capgo/native-purchases의 구현 세부 정보에 대해 Getting Started Getting Started의 구현 세부 정보에 대해 Capgo Pricing Capgo Pricing의 제품 워크플로에 대해 Payment system Payment system의 구현 세부 정보에 대해 Revenue Playbook Revenue Playbook의 구현 세부 정보에 대해