getAvailablePurchases

Get the user's purchases held by the store — owned non-consumables, active subscriptions, and any pending transactions not yet finished.

iOS: By default iterates Transaction.all (the full StoreKit 2 history, including refunded / revoked entries). Pass onlyIncludeActiveItemsIOS = true to switch to Transaction.currentEntitlements, which narrows the result to active non-consumables and live subscriptions. Apple docs. Android: Calls BillingClient.queryPurchasesAsync for both INAPP and SUBS and merges. Only returns purchases still owned by the user. Google docs.

Signature

swift
func getAvailablePurchases(_ options: PurchaseOptions?) async throws -> [Purchase]

Parameters#

Pass an optional PurchaseOptions:

  • alsoPublishToEventListenerIOS (optional, boolean, default false) iOS. Re-emit results on purchaseUpdatedListener.
  • onlyIncludeActiveItemsIOS (optional, boolean, default true) iOS. Use Transaction.currentEntitlements (active only). Pass false to use Transaction.all instead.
  • includeSuspendedAndroid (optional, boolean, default false) Android (Billing 8.1+). Include suspended subscriptions in the result. Suspended entries (isSuspendedAndroid === true) should NOT grant entitlements — direct the user to the subscription center to resolve payment first.

Returns#

Promise<Purchase[]> — owned/available purchases held by the store.

Failure semantics#

In SDK APIs that surface failures and in Godot's result-bearing API, an empty purchase list is an authoritative store result: the store query completed and found no purchases. Native transaction verification, serialization, or bridge decoding failures reject the whole query (or return success = false) with an error such as billing-response-json-parse-error; OpenIAP does not return a partial list.

Godot keeps get_available_purchases() for compatibility, so that array-only method still maps a failure to an empty array. Code that restores purchases, grants entitlements, or clears cached ownership must call get_available_purchases_result() and check success before using purchases. Never revoke or clear entitlements after a failed query.

Example

swift
let purchases = try await OpenIapModule.shared.getAvailablePurchases(nil)