跳过内容

@capgo/native-purchases

轻松实现内购

概述

概述

简化内购。

核心功能

核心功能
  • Native in-app purchases and subscriptions with StoreKit 2 and Google Play Billing.
  • Product metadata loaded directly from the stores, including localized titles and prices.
  • iOS StoreKit pricing terms for monthly subscriptions with 12-month commitments.
  • Purchase, restore, entitlement refresh, and native subscription management flows.
  • App Transaction helpers for migration from older business models.

公共API

公共API
方法描述
restorePurchases恢复用户之前的购买并将他们的appUserIDs与使用相同的用户关联。
getAppTransaction获取App Transaction信息,提供有关用户最初下载或购买应用的详细信息。
isEntitledToOldBusinessModel比较App Transaction中的原始应用版本与目标版本,以确定用户是否有权从较早的商业模式中获得特征。
purchaseProduct启动本机购买流程。支持的iOS版本中,传递 billingPlanType: 'monthly' 以购买一个月的计费计划,12个月的承诺。
getProducts获取与产品标识符相关的产品信息。支持的iOS版本中,订阅产品可以包括 pricingTerms.
getProduct获取单个产品标识符的产品信息。
isBillingSupported检查当前设备是否支持计费。
getPluginVersion获取本机Capacitor插件版本。
getPurchases获取用户的所有购买记录(包括应用内购买和订阅)。此方法查询当前用户的平台购买历史。
manageSubscriptions打开平台的本机订阅管理页面。允许用户查看、修改或取消订阅。
acknowledgePurchase手动确认/完成购买交易。
consumePurchase在Android上消耗应用内购买。
addListener监听Apple的Transaction.updates传递的StoreKit交易更新。iOS中只触发一次应用启动,如果有未完成的交易,之后任何更新都触发。
addListener监听Apple的Transaction.updates传递的StoreKit交易验证失败。iOS中只触发验证结果未验证时。
removeAllListeners移除所有已注册的监听器。

此参考资料是从 src/definitions.tscapacitor-native-purchases.

如果您正在使用 @capgo/native-purchases 来规划付款和购买,连接它与 使用 @capgo/native-purchases 为使用@capgo/native-purchases的原生能力 Capgo Pricing 为Capgo Pricing中的产品工作流 支付系统 为支付系统中的实现细节 开始使用 为开始使用中的实现细节, 和 营收指南 为营收指南中的实现细节