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

  • productId String (Required)
  • quantity Number (Optional)
    Defaults to 1.
  • username String (Optional)
    The string that associates the transaction with a user account on your service.

Returns

  • success Boolean
    Returns true if the product is valid and added to the payment queue.
  • message String
    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

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Finish Transaction

macOS Marks a transaction as finished.

await window.deskifier.purchases.finish({ arguments })

Arguments

  • transactionDateIso String (Required)
    The transaction date ISO

Returns

  • success Boolean
    If the update was checked.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Finish All Transactions

macOS Marks all transactions as finished.

await window.deskifier.purchases.finishAll()

Returns

  • success Boolean
    If the update was checked.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Properties

Get Products

macOS Retrieves the product descriptions.

await window.deskifier.purchases.getProducts({ arguments })

Arguments

  • productIds Array of String (Required)
    The product identifiers to look up.

Returns

  • success Boolean
    Returns true if the products were retrieved successfully.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • products Array of Electron.Product

Get Active Transactions

macOS A list of all transactions that currently aren't finished.

await window.deskifier.purchases.getActiveTransactions()

Returns

  • success Boolean
    Returns true if the product is valid and added to the payment queue.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • activeTransactions Array 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

  • success Boolean
    Returns true if the product is valid and added to the payment queue.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • receiptUrl String

Can Make Payments

macOS Whether a user can make a payment.

await window.deskifier.purchases.canMakePayments()

Returns

  • canMakePayments Boolean

Events

Transaction Updated

macOS Fires when one or more transactions have been updated.

window.deskifier.purchases.onTransactionUpdated((data) => { })

Arguments