inAppPurchase

Mac App Store中的应用内购买

进程:主进程

事件

inAppPurchase 模块触发以下事件:

事件:’transactions-updated’

一个或多个 transactions 更新时会触发这一事件。

返回:

  • event Event
  • transactions Transaction[] - Array of Transaction objects.

方法

inAppPurchase 模块包含以下方法:

inAppPurchase.purchaseProduct(productID[, quantity])

  • productID String - 预付款商品的ID (com.example.app.product1 的ID是 product1).
  • quantity Integer (可选) - 用户所要购买的商品数量.

Returns Promise<Boolean> - Returns true if the product is valid and added to the payment queue.

在调用purchaseProduct之前,你应该尽可能快的监听transactions-updated事件

inAppPurchase.getProducts(productIDs)

  • productIDs String[] - 预购商品ID

Returns Promise<Product[]> - Resolves with an array of Product objects.

检索商品的描述

inAppPurchase.canMakePayments()

Returns Boolean - whether a user can make a payment.

inAppPurchase.restoreCompletedTransactions()

Restores finished transactions. This method can be called either to install purchases on additional devices, or to restore purchases for an application that the user deleted and reinstalled.

The payment queue delivers a new transaction for each previously completed transaction that can be restored. Each transaction includes a copy of the original transaction.

inAppPurchase.getReceiptURL()

Returns String - the path to the receipt.

inAppPurchase.finishAllTransactions()

完成所有待处理的交易

inAppPurchase.finishTransactionByDate(date)

  • date String - 待完成交易的ISO标准日期格式

完成与日期对应的待处理事务