Improve in-app purchase for MacOS (#12464)
* Add methods to finish transactions * Add a method to get the product descriptions from the App Store * Improve the documentation of a transaction structure * Add a tutorial for In App Purchase * Fix typo in In-App Purchase tutorial * Fix style of In-App Purchase files * Fix In-App-Purchase product structure conversion in amr64 * Fix code style in In-App Purchase tutorial documentation * Fix typos in In-App Purchase documentation * Fix typo in In-App Purchase spec * Slight style fixes
This commit is contained in:
parent
52b1065b3b
commit
5486a65702
13 changed files with 481 additions and 22 deletions
|
@ -21,15 +21,24 @@ Returns:
|
|||
|
||||
The `inAppPurchase` module has the following methods:
|
||||
|
||||
|
||||
### `inAppPurchase.purchaseProduct(productID, quantity, callback)`
|
||||
|
||||
* `productID` String - The id of the product to purchase. (the id of `com.example.app.product1` is `product1`).
|
||||
* `productID` String - The identifiers of the product to purchase. (The identifier of `com.example.app.product1` is `product1`).
|
||||
* `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.
|
||||
* `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`.
|
||||
|
||||
### `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 of [`Product`](structures/product) objects
|
||||
|
||||
Retrieves the product descriptions.
|
||||
|
||||
### `inAppPurchase.canMakePayments()`
|
||||
|
||||
Returns `true` if the user can make a payment and `false` otherwise.
|
||||
|
@ -37,3 +46,15 @@ Returns `true` if the user can make a payment and `false` otherwise.
|
|||
### `inAppPurchase.getReceiptURL()`
|
||||
|
||||
Returns `String`, the path to the receipt.
|
||||
|
||||
|
||||
### `inAppPurchase.finishAllTransactions()`
|
||||
|
||||
Completes all pending transactions.
|
||||
|
||||
|
||||
### `inAppPurchase.finishTransactionByDate(date)`
|
||||
|
||||
* `date` String - The ISO formatted date of the transaction to finish.
|
||||
|
||||
Completes the pending transactions corresponding to the date.
|
||||
|
|
10
docs/api/structures/product.md
Normal file
10
docs/api/structures/product.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Product Object
|
||||
|
||||
* `productIdentifier` String - The string that identifies the product to the Apple App Store.
|
||||
* `localizedDescription` String - A description of the product.
|
||||
* `localizedTitle` String - The name of the product.
|
||||
* `contentVersion` String - A string that identifies the version of the content.
|
||||
* `contentLengths` Number[] - The total size of the content, in bytes.
|
||||
* `price` Number - The cost of the product in the local currency.
|
||||
* `formattedPrice` String - The locale formatted price of the product.
|
||||
* `downloadable` Boolean - A Boolean value that indicates whether the App Store has downloadable content for this product.
|
|
@ -1,11 +1,11 @@
|
|||
# Transaction Object
|
||||
|
||||
* `transactionIdentifier` String
|
||||
* `transactionDate` String
|
||||
* `originalTransactionIdentifier` String
|
||||
* `transactionIdentifier` String - A string that uniquely identifies a successful payment transaction.
|
||||
* `transactionDate` String - The date the transaction was added to the App Store’s payment queue.
|
||||
* `originalTransactionIdentifier` String - The identifier of the restored transaction by the App Store.
|
||||
* `transactionState` String - The transaction sate (`"purchasing"`, `"purchased"`, `"failed"`, `"restored"`, or `"deferred"`)
|
||||
* `errorCode` Integer
|
||||
* `errorMessage` String
|
||||
* `errorCode` Integer - The error code if an error occurred while processing the transaction.
|
||||
* `errorMessage` String - The error message if an error occurred while processing the transaction.
|
||||
* `payment` Object
|
||||
* `productIdentifier` String
|
||||
* `quantity` Integer
|
||||
* `productIdentifier` String - The identifier of the purchased product.
|
||||
* `quantity` Integer - The quantity purchased.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue