inAppPurchase
History
| Version(s) | Changes |
|---|---|
None | API ADDED |
Mac 应用商店内购买。
进程:主进程
🌐 Process: Main
事件
🌐 Events
inAppPurchase 模块会触发以下事件:
🌐 The inAppPurchase module emits the following events:
Event: 'transactions-updated'
History
| Version(s) | Changes |
|---|---|
None | API ADDED |
返回:
🌐 Returns:
event事件transactionsTransaction[] -Transaction对象的数组。
当一项或多项事务已更新时发出。
🌐 Emitted when one or more transactions have been updated.
方法
🌐 Methods
inAppPurchase 模块具有以下方法:
🌐 The inAppPurchase module has the following methods:
inAppPurchase.purchaseProduct(productID[, opts])
History
| Version(s) | Changes |
|---|---|
None | This method now returns a Promise instead of using a callback function. |
None | Added |
None | API ADDED |
productID字符串optsInteger | Object(optional)- 如果指定为整数,则定义数量。quantityInteger(optional)- 用户想购买的商品数量。usernamestring(optional)- 将交易与你服务上的用户账户关联的字符串(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)
History
| Version(s) | Changes |
|---|---|
None | This method now returns a Promise instead of using a callback function. |
None | API ADDED |
productIDsstring[] - 要获取的产品标识符。
返回 Promise<Product[]> - 解析为包含 Product 对象的数组。
🌐 Returns Promise<Product[]> - Resolves with an array of Product objects.
检索产品描述。
🌐 Retrieves the product descriptions.
inAppPurchase.canMakePayments()
History
| Version(s) | Changes |
|---|---|
None | API ADDED |
返回 boolean - 用户是否可以进行支付。
🌐 Returns boolean - whether a user can make a payment.
inAppPurchase.restoreCompletedTransactions()
History
| Version(s) | Changes |
|---|---|
None | API ADDED |
恢复已完成的交易。此方法可用于在其他设备上安装购买内容,或恢复用户删除并重新安装的应用的购买内容。
🌐 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()
History
| Version(s) | Changes |
|---|---|
None | API ADDED |
返回 string - 收据的路径。
🌐 Returns string - the path to the receipt.
inAppPurchase.finishAllTransactions()
History
| Version(s) | Changes |
|---|---|
None | API ADDED |
完成所有待处理的事务。
🌐 Completes all pending transactions.
inAppPurchase.finishTransactionByDate(date)
History
| Version(s) | Changes |
|---|---|
None | API ADDED |
datestring - 交易完成的 ISO 格式日期。
完成对应日期的待处理事务。
🌐 Completes the pending transactions corresponding to the date.