For the complete documentation index, see llms.txt. This page is also available as Markdown.

Restore Previous Purchases

Goal

Restore non-consumables and subscriptions (for example after reinstall or on a new device).

Actions Required

Action
Purpose

BillingServicesInitializeStore

Load product catalog

BillingServicesRestorePurchases

Trigger restore process

BillingServicesOnRestorePurchasesComplete

Listen for restore completion

BillingServicesGetRestorePurchasesSuccessResult

Get restored count

BillingServicesGetRestoredTransactionInfo

Read restored transaction details

BillingServicesFinishTransactions

Finish restored transactions

BillingServicesGetRestorePurchasesError

Read cached restore error after failure (optional)

Variables Needed

  • restoredCount (Int)

  • transactionIndex (Int)

  • productId (String)

  • receiptVerificationState (Enum: BillingReceiptVerificationState)

Implementation Steps

1. InitializeStore

Run BillingServicesInitializeStore and wait for successEvent.

2. RegisterRestoreListener (persistent)

Run BillingServicesOnRestorePurchasesComplete in a state that stays active (for example in your settings scene while the restore flow runs).

  • This action is what fires the completion events and caches data for the extractor actions.

3. TriggerRestore (user taps “Restore Purchases”)

Run BillingServicesRestorePurchases (forceRefresh optional).

4. Wait for completion

Your BillingServicesOnRestorePurchasesComplete listener will fire:

  • successEventGetRestoreResult

  • failureEvent → (Optional) BillingServicesGetRestorePurchasesError

5. GetRestoreResult

Run BillingServicesGetRestorePurchasesSuccessResultrestoredCount.

6. Loop restored items

Loop transactionIndex = 0..restoredCount-1:

  • BillingServicesGetRestoredTransactionInfo(transactionIndex)productId, transactionState, receiptVerificationState

  • Grant content only when:

    • transactionState == Purchased

    • receiptVerificationState == Success

  • If verification failed, do not restore the entitlement

7. FinishRestore

Run BillingServicesFinishTransactions (either finish all cached/pending, or only the restored IDs you collected).

Notes

  • Consumables are not restorable (by design).

  • Prefer showing restore from a Settings screen rather than auto-restoring every launch.

  • Restored purchases should still pass local verification. A restored transaction that is not ReceiptVerificationState.Success should not grant content.

Last updated