inAppPurchase
Mac App Store中的应用内购买
进程:主进程
In-app purchases on Mac App Store.
Process: Main
事件
inAppPurchase
模块触发以下事件:
Events
The inAppPurchase
module emits the following events:
事件:'transactions-updated'
一个或多个 transactions 更新时会触发这一事件。
返回:
event
Eventtransactions
Transaction[] - Array ofTransaction
objects.
Event: 'transactions-updated'
Emitted when one or more transactions have been updated.
Returns:
event
Eventtransactions
Transaction[] - Array ofTransaction
objects.
方法
inAppPurchase
模块包含以下方法:
Methods
The inAppPurchase
module has the following methods:
inAppPurchase.purchaseProduct(productID, quantity, callback)
productID
String - 预付款商品的ID (com.example.app.product1
的ID是product1
).quantity
Integer (可选) - 用户所要购买的商品数量.callback
Function (可选) - 当购买事件被推到 PaymentQueue中时触发这个回调函数.isProductValid
Boolean - 用来表示商品是否已经添加到支付队列中。
在调用purchaseProduct
之前,你应该尽可能快的监听transactions-updated
事件
即将弃用
inAppPurchase.purchaseProduct(productID, quantity, callback)
productID
String - The identifiers of the product to purchase. (The identifier ofcom.example.app.product1
isproduct1
).quantity
Integer (optional) - The number of items the user wants to purchase.callback
Function (optional) - The callback called when the payment is added to the PaymentQueue.isProductValid
Boolean - Determine if the product is valid and added to the payment queue.
You should listen for the transactions-updated
event as soon as possible and certainly before you call purchaseProduct
.
Deprecated Soon
inAppPurchase.purchaseProduct(productID, quantity)
productID
String - 预付款商品的ID (com.example.app.product1
的ID是product1
).quantity
Integer (可选) - 用户所要购买的商品数量.
Returns Promise<Boolean>
- Returns true
if the product is valid and added to the payment queue.
在调用purchaseProduct
之前,你应该尽可能快的监听transactions-updated
事件
inAppPurchase.purchaseProduct(productID, quantity)
productID
String - The identifiers of the product to purchase. (The identifier ofcom.example.app.product1
isproduct1
).quantity
Integer (optional) - The number of items the user wants to purchase.
Returns Promise<Boolean>
- Returns true
if the product is valid and added to the payment queue.
You should listen for the transactions-updated
event as soon as possible and certainly before you call purchaseProduct
.
inAppPurchase.getProducts(productIDs, callback)
productIDs
String[] - 预购商品IDcallback
Function - 当商品不存在时,被商品对象或空数组调用的回调products
Product[] -Product
对象的数据
检索商品的描述
即将弃用
inAppPurchase.getProducts(productIDs, callback)
productIDs
String[] - The identifiers of the products to get.callback
Function - The callback called with the products or an empty array if the products don't exist.products
Product[] - Array ofProduct
objects
Retrieves the product descriptions.
Deprecated Soon
inAppPurchase.getProducts(productIDs)
productIDs
String[] - 预购商品ID
Returns Promise<Product[]>
- Resolves with an array of Product
objects.
检索商品的描述
inAppPurchase.getProducts(productIDs)
productIDs
String[] - The identifiers of the products to get.
Returns Promise<Product[]>
- Resolves with an array of Product
objects.
Retrieves the product descriptions.
inAppPurchase.canMakePayments()
返回 Boolean
, 用来判断用户是否可以发起支付.
inAppPurchase.canMakePayments()
Returns Boolean
, whether a user can make a payment.
inAppPurchase.getReceiptURL()
返回 String
, 指收据路径.
inAppPurchase.getReceiptURL()
Returns String
, the path to the receipt.
inAppPurchase.finishAllTransactions()
完成所有待处理的交易
inAppPurchase.finishAllTransactions()
Completes all pending transactions.
inAppPurchase.finishTransactionByDate(date)
date
String - 待完成交易的ISO标准日期格式
完成与日期对应的待处理事务
inAppPurchase.finishTransactionByDate(date)
date
String - The ISO formatted date of the transaction to finish.
Completes the pending transactions corresponding to the date.