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