Skip to main content

inAppPurchase

In-app purchases on Mac App Store.在Mac app Store上进行应用内购买。

Process:进程:Main

Events事件

The inAppPurchase module emits the following events:inAppPurchase模块会发出以下事件:

Event: 'transactions-updated'

Emitted when one or more transactions have been updated.当一个或多个事务已更新时发出。

Returns:返回:

Methods方法

The inAppPurchase module has the following methods:inAppPurchase模块具有以下方法:

inAppPurchase.purchaseProduct(productID[, quantity])

  • productID string - The identifiers of the product to purchase. 要购买的产品的标识符。(The identifier of com.example.app.product1 is product1).com.example.app.product1的标识符是product1)。
  • quantity Integer (optional) - The number of items the user wants to purchase.用户想要购买的商品数量。

Returns返回Promise<boolean> - Returns true if the product is valid and added to the payment queue.如果产品有效并已添加到付款队列,则返回true

You should listen for the transactions-updated event as soon as possible and certainly before you call purchaseProduct.您应该尽快监听transactions-updated事件,当然在调用purchaseProduct之前。

inAppPurchase.getProducts(productIDs)

  • productIDs string[] - The identifiers of the products to get.要获取的产品的标识符。

Returns返回Promise<Product[]> - Resolves with an array of Product objects.使用一组Product对象进行解析。

Retrieves the product descriptions.检索产品描述。

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()

Completes all pending transactions.完成所有待处理的交易。

inAppPurchase.finishTransactionByDate(date)

  • date string - The ISO formatted date of the transaction to finish.ISO格式的事务处理完成日期。

Completes the pending transactions corresponding to the date.完成与日期对应的待处理交易。