In App Purchases
Handle in app purchases when running as a Mac App Store app.
Methods
Purchase Product
macOS Creates an in app purchase.
You should be sure to "finish" a transaction once you are done processing the events for it (ex. once a transaction is updated to a terminal state like "failed", or "purchased")
await window.deskifier.purchases.purchase({ arguments })
Arguments
productIdString (Required)quantityNumber (Optional)
Defaults to1.usernameString (Optional)
The string that associates the transaction with a user account on your service.
Returns
successBoolean
Returnstrueif the product is valid and added to the payment queue.messageString
Additional confirmation, or error details if action was unsuccessful.
Example
const result = await window.deskifier.purchases.purchase({
productId: "example1"
});
console.log(result.success); // true
Restore Completed Transactions
macOS Generates previously finished transactions. This method can be called either to install purchases on additional devices, or to restore purchases for an application that the user deleted and reinstalled.
await window.deskifier.purchases.restore()
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Finish Transaction
macOS Marks a transaction as finished.
await window.deskifier.purchases.finish({ arguments })
Arguments
transactionDateIsoString (Required)
The transaction date ISO
Returns
successBoolean
If the update was checked.messageString
Additional confirmation, or error details if action was unsuccessful.
Finish All Transactions
macOS Marks all transactions as finished.
await window.deskifier.purchases.finishAll()
Returns
successBoolean
If the update was checked.messageString
Additional confirmation, or error details if action was unsuccessful.
Properties
Get Products
macOS Retrieves the product descriptions.
await window.deskifier.purchases.getProducts({ arguments })
Arguments
productIdsArray of String (Required)
The product identifiers to look up.
Returns
successBoolean
Returnstrueif the products were retrieved successfully.messageString
Additional confirmation, or error details if action was unsuccessful.productsArray of Electron.Product
Get Active Transactions
macOS A list of all transactions that currently aren't finished.
await window.deskifier.purchases.getActiveTransactions()
Returns
successBoolean
Returnstrueif the product is valid and added to the payment queue.messageString
Additional confirmation, or error details if action was unsuccessful.activeTransactionsArray of Electron.Transaction
Get Receipt URL
macOS Retrieves a URL with a link to all of the user's transactions for the given app.
await window.deskifier.purchases.getReceiptUrl()
Returns
successBoolean
Returnstrueif the product is valid and added to the payment queue.messageString
Additional confirmation, or error details if action was unsuccessful.receiptUrlString
Can Make Payments
macOS Whether a user can make a payment.
await window.deskifier.purchases.canMakePayments()
Returns
canMakePaymentsBoolean
Events
Transaction Updated
macOS Fires when one or more transactions have been updated.
window.deskifier.purchases.onTransactionUpdated((data) => { })
Arguments
transactionsArray of Electron.Transaction