inAppPurchase
Mac App Store 中的应用内购买。
进程:主进程
事件
inAppPurchase 模块会发出以下事件
事件:'transactions-updated'
返回
eventEventtransactionsTransaction[] - Transaction 对象的数组。
当一个或多个交易更新时发出。
方法
inAppPurchase 模块具有以下方法
inAppPurchase.purchaseProduct(productID[, opts])
productIDstringoptsInteger | Object (可选) - 如果指定为整数,则表示数量。quantityInteger (可选) - 用户想要购买的商品数量。usernamestring (可选) - 将交易与您服务上的用户帐户关联的字符串 (applicationUsername)。
返回 Promise<boolean> - 如果产品有效并已添加到付款队列,则返回 true。
您应该尽快监听 transactions-updated 事件,并且肯定要在调用 purchaseProduct 之前。
inAppPurchase.getProducts(productIDs)
productIDsstring[] - 要获取的产品的标识符。
返回 Promise<Product[]> - 解析为 Product 对象的数组。
检索产品描述。
inAppPurchase.canMakePayments()
返回 boolean - 用户是否可以进行付款。
inAppPurchase.restoreCompletedTransactions()
恢复已完成的交易。可以调用此方法来在其他设备上安装购买的商品,或恢复用户已删除并重新安装的应用程序的购买记录。
付款队列会为每个可恢复的先前已完成交易传递一个新交易。每个交易都包含原始交易的副本。
inAppPurchase.getReceiptURL()
返回 string - 收据的路径。
inAppPurchase.finishAllTransactions()
完成所有待处理的交易。
inAppPurchase.finishTransactionByDate(date)
datestring - 要完成交易的 ISO 格式日期。
完成与该日期对应的待处理交易。