2018-01-10 17:21:52 +09:00
|
|
|
# inAppPurchase
|
2017-11-30 14:27:33 +01:00
|
|
|
|
2018-01-10 16:55:49 +09:00
|
|
|
> In-app purchases on Mac App Store.
|
2018-01-10 16:37:05 +09:00
|
|
|
|
2018-01-10 16:55:49 +09:00
|
|
|
Process: [Main](../glossary.md#main-process)
|
|
|
|
|
|
|
|
## Events
|
|
|
|
|
|
|
|
The `inAppPurchase` module emits the following events:
|
|
|
|
|
2018-01-10 17:18:23 +09:00
|
|
|
### Event: 'transactions-updated'
|
2018-01-10 16:55:49 +09:00
|
|
|
|
2018-01-10 17:18:23 +09:00
|
|
|
Emitted when one or more transactions have been updated.
|
2018-01-10 16:55:49 +09:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
* `event` Event
|
2018-02-27 10:22:29 -08:00
|
|
|
* `transactions` Transaction[] - Array of [`Transaction`](structures/transaction) objects.
|
2017-11-30 14:27:33 +01:00
|
|
|
|
2018-01-10 16:37:05 +09:00
|
|
|
## Methods
|
2017-11-30 14:27:33 +01:00
|
|
|
|
|
|
|
The `inAppPurchase` module has the following methods:
|
|
|
|
|
|
|
|
### `inAppPurchase.purchaseProduct(productID, quantity, callback)`
|
2018-01-10 16:37:05 +09:00
|
|
|
|
2017-11-30 14:27:33 +01:00
|
|
|
* `productID` String - The id of the product to purchase. (the id of `com.example.app.product1` is `product1`).
|
|
|
|
* `quantity` Integer (optional) - The number of items the user wants to purchase.
|
2018-03-02 14:25:37 +01:00
|
|
|
* `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`.
|
2017-11-30 14:27:33 +01:00
|
|
|
|
|
|
|
### `inAppPurchase.canMakePayments()`
|
|
|
|
|
|
|
|
Returns `true` if the user can make a payment and `false` otherwise.
|
|
|
|
|
|
|
|
### `inAppPurchase.getReceiptURL()`
|
|
|
|
|
2018-01-10 16:37:05 +09:00
|
|
|
Returns `String`, the path to the receipt.
|