> For the complete documentation index, see [llms.txt](https://assetstore.essentialkit.voxelbusters.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://assetstore.essentialkit.voxelbusters.com/features/billing-services/playmaker/use-cases/use-case-3-restore-purchases.md).

# 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:

* `successEvent` → `GetRestoreResult`
* `failureEvent` → (Optional) `BillingServicesGetRestorePurchasesError`

### 5. GetRestoreResult

Run `BillingServicesGetRestorePurchasesSuccessResult` → `restoredCount`.

### 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.
