跳到主内容

inAppPurchase

Mac App Store 内购。

进程:主进程

事件

inAppPurchase 模块触发以下事件

事件:'transactions-updated'

返回

  • event Event
  • transactions Transaction[] - Transaction 对象数组。

当一个或多个交易更新时触发。

方法

inAppPurchase 模块有以下方法

inAppPurchase.purchaseProduct(productID[, opts])

  • productID string
  • opts Integer | Object (可选) - 如果指定为整数,则定义数量。
    • quantity Integer (可选) - 用户想要购买的商品数量。
    • username string (可选) - 将交易与您服务上的用户帐户关联的字符串 (applicationUsername)。

返回 Promise<boolean> - 如果产品有效且已添加到支付队列,则返回 true

您应尽快监听 transactions-updated 事件,尤其是在调用 purchaseProduct 之前。

inAppPurchase.getProducts(productIDs)

  • productIDs string[] - 要获取的产品的标识符。

返回 Promise<Product[]> - 解析为一个 Product 对象数组。

检索产品描述。

inAppPurchase.canMakePayments()

返回 boolean - 用户是否可以进行支付。

inAppPurchase.restoreCompletedTransactions()

恢复已完成的交易。此方法可用于在额外设备上安装购买的项目,或恢复用户删除并重新安装的应用程序的购买项目。

支付队列 为每个可以恢复的先前完成的交易提供一个新的交易。每个交易都包含原始交易的副本。

inAppPurchase.getReceiptURL()

返回 string - 收据的路径。

inAppPurchase.finishAllTransactions()

完成所有待处理的交易。

inAppPurchase.finishTransactionByDate(date)

  • date string - 要完成的交易的 ISO 格式日期。

完成对应日期的待处理交易。