inAppPurchase
Mac 应用商店内购买。
进程:主进程
🌐 Process: Main
事件
🌐 Events
inAppPurchase 模块会触发以下事件:
🌐 The inAppPurchase module emits the following events:
Event: 'transactions-updated'
返回:
🌐 Returns:
event活动transactions交易[] -Transaction对象的数组。
当一项或多项事务已更新时发出。
🌐 Emitted when one or more transactions have been updated.
方法
🌐 Methods
inAppPurchase 模块具有以下方法:
🌐 The inAppPurchase module has the following methods:
inAppPurchase.purchaseProduct(productID[, opts])
productID字符串opts整数 | 对象(可选)- 如果指定为整数,则定义数量。quantity整数(可选)- 用户想要购买的商品数量。username字符串(可选)- 用于将交易与你服务中的用户账户关联的字符串(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)
productIDsstring[] - 要获取的产品标识符。
返回 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.
支付队列 为每个可以恢复的已完成交易提供一笔新交易。每笔交易都包含原始交易的副本。
inAppPurchase.getReceiptURL()
返回 string - 收据的路径。
🌐 Returns string - the path to the receipt.
inAppPurchase.finishAllTransactions()
完成所有待处理的事务。
🌐 Completes all pending transactions.
inAppPurchase.finishTransactionByDate(date)
date字符串 - 交易完成的 ISO 格式日期。
完成对应日期的待处理事务。
🌐 Completes the pending transactions corresponding to the date.