---
title: "Recipe: selling a subscription or a tip"
description: "@exact/purchases sells through the store on iOS, macOS and Android (LLP 1133.015)."
modificationDate: "2026-11-11"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe: selling a subscription or a tip

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/recipes/purchases: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

`@exact/purchases` sells through the store on iOS, macOS and Android (LLP
1133.015). Elsewhere `purchasesStatus().available` is false and the lists are
empty. A screen gates on **`listPurchases()`**, what the person holds;
delivery reads **`unfinishedPurchases()`**, the store's queue, and nothing
else.

```prompt Sell a subscription or a tip
Add in-app purchases (a subscription or a tip) to the Exact app in this folder. Use https://github.com/expo/exact/blob/main/docs/recipes/purchases.md as the source for each step. The Exact checkout has the same page at docs/recipes/purchases.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me. Find the Exact checkout (the folder with scripts/exact.mjs); if you cannot find it, ask me where it is.
2. Ask me which items to sell, with their store IDs, and which are consumable (a tip) and which are a subscription. Do not invent item IDs. The store sells on iOS, macOS and Android only; elsewhere the lists are empty.
3. Install the package: `bun <exact2>/scripts/exact.mjs add purchases .`. Name the test catalogue in app.json (`"purchases": {"catalog": "store/catalog.json"}`) and write it with my items.
4. In app.contract, gate each screen on `listPurchases()`, show each price with `displayPrice`, and send `purchase(itemId=...)` from a press. Use the purchase's answer only for the screen ("Waiting for approval" while pending); never deliver from it.
5. In app.ts, deliver from `unfinishedPurchases()` only, once per `purchaseToken`: keep the credit and the token together, then `consume` a consumable and `acknowledge` the rest. Finish every purchase.
6. Put Restore behind a button. Never put `requestReview()` behind a button.
7. Add tests in app.test.contract with the agent's `purchase` ticket: a purchase (`buy`), a cancelled one (`cancel`) and a pending one (`pending`), and that a delivered tip counts once.
8. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 9) and report it; do not keep trying.
9. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
10. Tell me what you changed, what the tests and verify reported, and what I must still set up in each store before a real purchase works. `apps/weatherlight` in the Exact checkout is the whole app.
```

```text
use getDetails, listPurchases, unfinishedPurchases, purchase, ItemDetails, PurchaseDetails from "@exact/purchases"

shape Delivery
  tips: number

component App
  resource owned = listPurchases() as shape PurchaseDetails[] else empty()
  resource queue = unfinishedPurchases() as shape PurchaseDetails[] else empty()
  resource plans = getDetails(itemIds=["plus.yearly", "tip.small"]) as shape ItemDetails[] else empty()
  mutation bought as shape PurchaseDetails
  mutation delivered as shape Delivery
  derive due = queue.filter(p => p.purchaseState == "purchased").map(p => p.purchaseToken).join(",")
  action buy(itemId: string)
    send bought = purchase(itemId=itemId)
  action deliver
    send delivered = deliverPurchases()
  task delivering when due != "" key=due
    after(1, deliver)
```

The loop, in data code, delivers once by token, then finishes:

```text
for (const p of await unfinishedPurchases()) {
  if (p.purchaseState !== 'purchased') continue;     // pending: nothing yet
  if (p.itemId === 'tip.small') {
    if (!kept.tokens.includes(p.purchaseToken)) {
      kept.tips += 1; kept.tokens.push(p.purchaseToken);
      await save(kept);                              // credit and token together
    }
    await consume({ purchaseToken: p.purchaseToken });
  } else await acknowledge({ purchaseToken: p.purchaseToken });
}
```

- Show `displayPrice`, the store's own string.
- `purchase`'s answer is for the screen ("Waiting for approval" when
  `pending`); never deliver from it.
- Finish everything: Apple redelivers at every launch, Play refunds after
  three days.
- Restore sits behind a button (Apple); `requestReview()` is never a button.
- On Apple the package sets `SKIncludeConsumableInAppPurchaseHistory`, so
  StoreKit keeps finished consumables in `Transaction.all` (iOS 18 and
  macOS 15 on).

Under the agent each purchase is a `purchase` ticket (`buy`, `cancel`,
`pending`, `unavailable`, `fail`) over the catalogue `app.json` names
(`"purchases": {"catalog": "store/catalog.json"}`); `prefer extension
purchases.storeEvent={"op":"approve"|"renew"|"revoke"|"purchase",…}` is the
store acting alone. `apps/weatherlight` is the whole app.
