이 cordova-plugin-purchase 대안 많은 Capacitor 팀이 기존 도구를 벗어나 선택하는 CdvPurchase.store 워크플로입니다 @capgo/native-purchases. 이 플러그인은 iOS의 StoreKit 2와 그리고 Android의 Google Play Billing 7과 다음과 같은 promise 메서드를 통해 통신합니다: getProducts, purchaseProduct, 그리고 restorePurchases, 그중 transactionUpdated 체인 대신 리스너를 사용합니다. 이 가이드에서는 이러한 트레이드오프가 적합한 시점, 플러그인 설치 방법, 그리고 일반적인 store.when() 호출을 매핑하는 방법을 설명합니다. cordova-plugin-purchase calls.
새로운 Capacitor code에서 cordova-plugin-purchase를 대체하는 이유
cordova-plugin-purchase 적극적으로 유지 관리되고 있습니다. npm는 버전을 표시합니다 13.20.0 마지막으로 modified 의 날짜 2026년 10월 27일. README에 따르면 이 플러그인은 Capacitor부터 capacitor-plugin-cdv-purchase 그리고 전역 CdvPurchase.store 제품 등록을 지원하는 facade로, store.initialize(), 그리고 store.when() 승인된 핸들러를 사용합니다.
팀들이 여전히 이 플러그인을 선택하는 이유 @capgo/native-purchases Capacitor 마이그레이션 시:
- 더 단순한 API 구조. Capgo은 스토어 동작별로 하나의 메서드를 노출합니다 (
purchaseProduct,getPurchases,acknowledgePurchase) 대신 FSM 스타일store.when().productUpdated().approved()pipeline을 사용합니다. - README에 명시된 네이티브 결제 스택. iOS 15+의 StoreKit 2와 Android의 Google Play Billing 7.x, 그리고 아래에 문서화된 iOS 구독 커밋 헬퍼
/docs/plugins/native-purchases/. - Capacitor 우선 패키징. 다음으로 설치합니다
npm install @capgo/native-purchases그리고cap syncCordova 글로벌 변수나 별도의capacitor-plugin-cdv-purchase브릿지를 사용하지 않습니다. CdvPurchase에서 Braintree 결제 요청이 여전히 필요한 경우를 제외하고요. - 오픈소스 유지보수. Capgo 수정 사항은 사람이 매일 50개 이상의 pull request를 검토, 테스트 및 병합하는 공개 저장소를 통해 배포됩니다.
Braintree 결제 요청이나 Iaptic 검증기 단축키와 같은 CdvPurchase 전용 기능에 의존하고 있다면, 계속 cordova-plugin-purchase 또는 체크아웃 플로우를 이식하는 동안 두 플러그인을 일시적으로 함께 실행하세요.
설치
bun add @capgo/native-purchases
bunx cap sync
Android: 결제 권한 추가:
<uses-permission android:name="com.android.vending.BILLING" />
App Store Connect와 Google Play Console에서 제품을 구성한 후, 에서 링크된 플랫폼 테스트 가이드를 따르세요. 플러그인 README (docs/iOS_TESTING_GUIDE.md 그리고 docs/ANDROID_TESTING_GUIDE.md).
사용 예시
import { NativePurchases, PURCHASE_TYPE } from '@capgo/native-purchases';
const productId = 'com.example.premium.monthly';
export async function buySubscription() {
const { isBillingSupported } = await NativePurchases.isBillingSupported();
if (!isBillingSupported) {
throw new Error('Billing unavailable');
}
await NativePurchases.addListener('transactionUpdated', (event) => {
console.log('Transaction', event.transaction?.transactionId);
});
const { products } = await NativePurchases.getProducts({
productIdentifiers: [productId],
productType: PURCHASE_TYPE.SUBS,
});
await NativePurchases.purchaseProduct({
productIdentifier: productId,
productType: PURCHASE_TYPE.SUBS,
planIdentifier: 'monthly-plan',
quantity: 1,
});
}
호출하세요 restorePurchases() 설정 화면에서 manageSubscriptions() 사용자가 스토어 구독 UI가 필요할 때.
Cordova에서 Capacitor로 마이그레이션
Cordova 제거 cordova-plugin-purchase 또는 아직 이식하지 않은 화면에만 유지하세요. 가져오기 NativePurchases 및 교체 store 오케스트레이션을 명시적인 async 플로우로 대체하세요. 플랫폼 규칙에 따라 거래를 완료하거나 확인하려면 finishTransaction() iOS의 acknowledgePurchase() 또는 consumePurchase() 를 Android에서 README가 요구하는 대로 사용하세요.
API 매핑 테이블
cordova-plugin-purchase (CdvPurchase.store) |
@capgo/native-purchases |
|---|---|
store.register([{ id, type }]) |
getProducts({ productIdentifiers, productType }) |
store.initialize([Platform.APPLE, Platform.GOOGLE]) |
isBillingSupported() 그다음 getProducts() |
store.ready() / store.update() |
await getProducts() 결제 확인 후 |
store.get(productId) |
getProduct({ productIdentifier, productType }) |
store.order(offer) / product.getOffer().order() |
purchaseProduct({ productIdentifier, productType, planIdentifier, quantity }) |
store.requestPayment(...) (Braintree) |
Capgo 플러그인에 없음, CdvPurchase 또는 Stripe 유지 |
store.restore() |
restorePurchases() |
store.owned(productId) |
검사 getPurchases() 결과 또는 서버 권한 |
store.when().approved(handler) |
addListener('transactionUpdated', ...) |
store.validator = url |
서버에서 영수증 또는 구매 토큰 검증 |
store.refresh() |
getProducts() 또는 getPurchases() |
product.transaction.finish() |
finishTransaction({ transactionIdentifier }) |
| 소비형 consume | consumePurchase({ purchaseToken }) (Android) |
PURCHASE_TYPE.INAPP 소비형 및 비소비형 제품으로 매핑됩니다. PURCHASE_TYPE.SUBS 유료 구독으로 매핑됩니다. Play Console의 Android 기본 플랜 ID는 그대로 전달됩니다 planIdentifier 켜짐 purchaseProduct(), 시작 가이드에 문서화되어 있습니다.
링크 및 다음 단계
- 플러그인 문서: https://capgo.app/docs/plugins/native-purchases/
- 마케팅 페이지: /plugins/capacitor-native-purchases/
- npm: https://www.npmjs.com/package/@capgo/native-purchases
- GitHub: https://github.com/Cap-go/capacitor-native-purchases/
- cordova-plugin-purchase: https://github.com/j3k0/cordova-plugin-purchase
빌링 규칙 변경 시 네이티브 리빌드가 필요합니다. 사용 Capgo 빌드 서명된 아티팩트에 대해. Paywall 카피와 가격 UI를 Live Update로 더 빠르게 배포할 수 있습니다 Capgo Live Update 사용하기 스토어 바이너리가 최신 상태가 되면. 참고 Cordova에서 Capacitor로 마이그레이션 더 넓은 마이그레이션 체크리스트를 확인하세요.