Skip to main content

inAppPurchase

inAppPurchase

Mac App Store 上的应用内购买。

¥In-app purchases on Mac App Store.

进程:主进程

¥Process: Main

事件

¥Events

inAppPurchase 模块发出以下事件:

¥The inAppPurchase module emits the following events:

事件:'transactions-updated'

¥Event: 'transactions-updated'

当一项或多项事务已更新时发出。

¥Emitted when one or more transactions have been updated.

返回:

¥Returns:

  • event 事件

    ¥event Event

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

    ¥transactions Transaction[] - Array of Transaction objects.

方法

¥Methods

inAppPurchase 模块有以下方法:

¥The inAppPurchase module has the following methods:

inAppPurchase.purchaseProduct(productID[, opts])

  • productID 字符串

    ¥productID string

  • opts Integer | Object (optional) - 如果指定为整数,则定义数量。

    ¥opts Integer | Object (optional) - If specified as an integer, defines the quantity.

    • quantity 整数(可选) - 用户想要购买的商品数量。

      ¥quantity Integer (optional) - The number of items the user wants to purchase.

    • username 字符串(可选) - 将事务与服务上的用户账户关联的字符串 (applicationUsername)。

      ¥username string (optional) - The string that associates the transaction with a user account on your service (applicationUsername).

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

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

你应该尽快监听 transactions-updated 事件,当然是在调用 purchaseProduct 之前。

¥You should listen for the transactions-updated event as soon as possible and certainly before you call purchaseProduct.

inAppPurchase.getProducts(productIDs)

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

    ¥productIDs string[] - The identifiers of the products to get.

返回 Promise<Product[]> - 使用 Product 对象数组进行解析。

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

检索产品描述。

¥Retrieves the product descriptions.

inAppPurchase.canMakePayments()

返回 boolean - 用户是否可以付款。

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

返回 string - 收据的路径。

¥Returns string - the path to the receipt.

inAppPurchase.finishAllTransactions()

完成所有待处理的事务。

¥Completes all pending transactions.

inAppPurchase.finishTransactionByDate(date)

  • date 字符串 - ISO 格式的事务完成日期。

    ¥date string - The ISO formatted date of the transaction to finish.

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

¥Completes the pending transactions corresponding to the date.