메인 콘텐츠로 건너뛰기
@capgo/자연결 구매 상업 오픈 소스

네이티브 구매 Capacitor 플러그인

API을 사용하여 간단한 native in-app 구매, 구독 및 iOS StoreKit 의무 청구 계획을 implement하세요.

설치

bun add @capgo/native-purchases bunx cap sync
npm, pnpm 또는 yarn
  • npm install @capgo/native-purchases
  • pnpm add @capgo/native-purchases
  • yarn add @capgo/native-purchases

사용 설명서

Capacitor에서 Native Purchases 사용하는 방법

장치에서 테스트

Capgo 앱을 다운로드한 후 QR code를 스캔하세요.

네이티브 구매 플러그인 미리보기 QR code

@capgo/native-purchases 사용

앱 내 구매가 쉬워졌습니다.

설치

bun add @capgo/native-purchases
bunx cap sync

이 플러그인이 제공하는 것

  • restorePurchases - 사용자의 이전 구매를 복원하고 사용자 ID를 연결하여 사용자 ID가 동일한 다른 사용자도 사용하는 것을 연결합니다.
  • getAppTransaction - 앱 트랜잭션 정보를 가져옵니다. 이 정보는 사용자가 원래 앱을 다운로드하거나 구매한 날짜에 대한 세부 정보를 제공합니다.
  • isEntitledToOldBusinessModel - 원래 앱 버전과 목표 버전을 비교하여 사용자가 이전 비즈니스 모델에서 특정 기능에 대한 권리를 갖는지 결정합니다.
  • getProducts - iOS 구독 가격 조건을 포함하여 스토어 제품 메타데이터를 로드합니다.
  • purchaseProduct - 사용자가 선택한 제품과 청구 계획에 대한 구매 프로세스를 시작합니다.

- 예시 사용법

restorePurchases

- 사용자의 이전 구매 정보를 복원하고 앱 사용자 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

- App 거래 정보의 원래 앱 버전을 App 거래 정보의 대상 버전과 비교하여 사용자가 이전 비즈니스 모델에서 특정 기능에 대한 권리를 갖는지 결정합니다.

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 구독을 지원하는 경우 1년 동안 월별 청구를 제공하는 구독을 전달하세요. 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 월간 약속 구독

- 구매 전에 구매 화면에 표시할 수 있는 구독 조건을 보여주세요: 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);
}

- iOS 구독 가격 조건을 포함하여 스토어 제품 메타데이터를 로드합니다.

Using @capgo/native-purchases

이러한 기능을 사용하는 경우 Using @capgo/native-purchases 결제와 구매를 계획하고 관리하기 위해 @__CAPGO_KEEP_0__/native-purchases @capgo/자연스러운 구매 @capgo/native-purchases Getting Started Getting Started Capgo 가격 정책 Capgo 가격 정책을 위한 제품 워크플로우에 대해 결제 시스템 결제 시스템의 구현 세부 사항에 대해 수익 전략서 수익 전략서의 구현 세부 사항에 대해

FAQ

Native Purchases 플러그인 FAQ

Native Purchases 플러그인을 Capacitor 앱에 설치하는 방법은?

Run &quot;bun add @capgo/native-purchases&quot; (or &quot;npm install @capgo/native-purchases&quot;), then run &quot;bunx cap sync&quot; so the iOS and Android projects pick up the native code. Import it from &quot;@capgo/native-purchases&quot; in your app code.

@capgo/native-purchases는 React, Vue 및 Angular와 함께 작동하나요?

Yes. Native Purchases is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/native-purchases support?

Capgo plugins follow Capacitor&#39;s major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

@capgo/native-purchases는 무료이고 오픈 소스인가요?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-native-purchases/ and the package is free to install from npm. Bug reports and pull requests are welcome.

code 업데이트가 App Store 리뷰 없이 Native Purchases를 사용할 수 있나요?

플러그인을 설치하거나 업그레이드하면 Native code이 변경되므로 새로운 스토어 빌드를 필요로 합니다. 그 후에 플러그인을 호출하는 JavaScript, HTML 및 CSS 변경 사항은 Capgo 라이브 업데이트와 함께 즉시 배포할 수 있습니다.

앱 리뷰 기다리지 않고 Native Purchases 변경을 배포하세요

플러그인이 스토어 빌드에 포함된 후, Capgo 라이브 업데이트 기능은 사용자에게 몇 분만에 JavaScript, HTML 및 CSS 변경을 푸시합니다.

Capgo로 시작하세요