> For the complete documentation index, see [llms.txt](https://docs.snapfix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snapfix.com/product/features/billing/in-app-purchase.md).

# In-app purchase

{% hint style="info" %}
Draft, written by an agent and not yet checked by a person ([how to read these docs](https://docs.snapfix.com/how-to-read.md)). [Source on GitHub](https://github.com/snapfix/docs/blob/main/product/features/in-app-purchase.md).
{% endhint %}

On iOS, a signed-in user can buy a Snapfix **plan** as an App Store in-app purchase, from the "Subscriptions" row of the Settings tab. The plan screen sells two monthly products, "Snapfix - Fix" and "Snapfix - Plan". The user picks the **site** the purchase is for, and Apple takes the payment. The app checks the receipt with Apple, but no Snapfix server is told about the purchase, so it changes no plan in Snapfix \[[ASK-143](https://github.com/snapfix/docs/blob/main/ASK.md#ask-143-how-does-an-app-store-purchase-reach-a-sites-plan)]. Android has no reachable purchase screen \[[ASK-10](https://github.com/snapfix/docs/blob/main/ASK.md#ask-10-which-differences-between-the-ios-and-android-apps-are-intended)], and the web sells plans through [payment links](https://docs.snapfix.com/product/features/billing/payment-links.md).

## Rules

### Who sees the purchase

* The "Subscriptions" row shows when any site in the user's [paywall](https://docs.snapfix.com/engineering-reference/api/billing.md#post-actionpaywall) answer has its in-app flag on (ios @ aa31967ac8, `SnapFix/New Profile/Profile Settings/View Model/ProfileSettingViewModel.swift:188-199`). Android shows its "Upgrade your Snapfix" card under the same condition ([Choose plan: platform differences](https://docs.snapfix.com/how-the-apps-work/screens/billing/choose-plan.md#platform-differences)).
* The flag is on for every site unless a [`tPri_UserPaywall`](https://docs.snapfix.com/engineering-reference/db/tables/tpri_userpaywall.md) row for that user and site turns it off, and no code in the repos writes that table \[[ASK-144](https://github.com/snapfix/docs/blob/main/ASK.md#ask-144-who-may-buy-an-in-app-plan-for-a-site-and-who-sets-the-in-app-purchase-switch)]. The old rule that turned the flag off for sites that are not free or churned is commented out, so paying sites show it too (php-apis @ 238ca4414e, `htmlphp/api/snapfix/class/class.functions.php:39954-39977`).
* The paywall answer lists the sites where the user is in a group or is an admin. The app checks no role, so a member who does not administer a site can buy for it \[[ASK-144](https://github.com/snapfix/docs/blob/main/ASK.md#ask-144-who-may-buy-an-in-app-plan-for-a-site-and-who-sets-the-in-app-purchase-switch)].

### What is sold

* The plan screen asks the App Store for two monthly products, "Snapfix - Fix" and "Snapfix - Plan", and shows a card for each one the store returns, with the store's currency, the amount and " / Month". "Buy Annual" never shows, because neither product is yearly ([Choose plan: layout](https://docs.snapfix.com/how-the-apps-work/screens/billing/choose-plan.md#layout)).
* The code also knows "Per User" and "Snapfix Pro", but never asks the store for them, so their cards never show \[[ASK-145](https://github.com/snapfix/docs/blob/main/ASK.md#ask-145-should-the-ios-plan-screen-sell-per-user-and-snapfix-pro)]. Their rows and "Buy Monthly" buttons in Settings sit in a container that the storyboard hides, and the buttons have no action \[[ASK-145](https://github.com/snapfix/docs/blob/main/ASK.md#ask-145-should-the-ios-plan-screen-sell-per-user-and-snapfix-pro)].

### Buying

* "Buy Monthly" first checks the connection; offline, it shows "You must be connected to the Internet to carry out this task. Please connect and try again." ([Choose plan: actions](https://docs.snapfix.com/how-the-apps-work/screens/billing/choose-plan.md#actions)).
* The user then picks a site. Only a site whose customer type is `0` or churned can be bought for; any other site gets the full-access alert and no purchase ([Choose plan: dialogs](https://docs.snapfix.com/how-the-apps-work/screens/billing/choose-plan.md#dialogs-and-sheets)). A user whose sites all have full access still sees the row \[[ASK-144](https://github.com/snapfix/docs/blob/main/ASK.md#ask-144-who-may-buy-an-in-app-plan-for-a-site-and-who-sets-the-in-app-purchase-switch)].
* The app then loads the product and opens Apple's purchase sheet. The purchase carries the ID of the user's group membership in the chosen site, or nothing when the user is in no group there (ios @ aa31967ac8, `AppUtility.swift:249-261`). No Snapfix server reads it.
* After a purchase, the plan screen closes and the app asks Apple's `verifyReceipt`, at the production or the sandbox address according to the app's `pushForProduction` setting (ios @ aa31967ac8, `APIManagers/APIManager.swift:246`). The request carries the App Store shared secret built into the app. The app also checks the receipt each time the group list loads (`SnapFix/BusinessListingVC.swift:110`).
* The receipt result only sets a flag, which only commented-out code reads; the free-limit check it was meant for returns `false` first, so iOS never refuses status changes \[[ASK-20](https://github.com/snapfix/docs/blob/main/ASK.md#ask-20-should-ios-enforce-the-free-plan-limit-on-status-changes)] (`AppUtility.swift:3876-3893`).
* "Restore Purchases" asks the App Store to restore completed purchases, shows nothing whatever the result, and sends nothing to Snapfix.

### Android

* The Android plan screen (`InAppPlanActivity`) is in the app, but every place that opened it is commented out \[[ASK-10](https://github.com/snapfix/docs/blob/main/ASK.md#ask-10-which-differences-between-the-ios-and-android-apps-are-intended)] ([Choose plan: platform differences](https://docs.snapfix.com/how-the-apps-work/screens/billing/choose-plan.md#platform-differences)). Its "Upgrade your Snapfix" card opens a sheet whose "Get in touch" opens the sales page.

## Flow

```mermaid
flowchart TD
  settings["Settings tab"] --> flag{"A listed site has the in-app flag?"}
  flag -- "no" --> norow["No Subscriptions row"]
  flag -- "yes" --> plan["Plan screen: Snapfix - Fix, Snapfix - Plan"]
  plan --> buy["Buy Monthly"]
  buy --> online{"Online?"}
  online -- "no" --> offline["Offline alert"]
  online -- "yes" --> sheet["Pick a site"]
  sheet --> type{"Customer type 0 or churn?"}
  type -- "no" --> full["Full-access alert, no purchase"]
  type -- "yes" --> apple["Apple purchase sheet"]
  apple --> receipt["App checks the receipt with Apple"]
  receipt --> nothing["Nothing sent to Snapfix: no plan change"]
```

## Platforms

| Capability                             | Web                                                                                         | iOS                                                                                                                         | Android                                                                                                                                                                 |
| -------------------------------------- | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Buy a plan in the app                  | No; see [Payment links](https://docs.snapfix.com/product/features/billing/payment-links.md) | Yes: monthly "Snapfix - Fix" and "Snapfix - Plan"                                                                           | No: the plan screen is unreachable \[[ASK-10](https://github.com/snapfix/docs/blob/main/ASK.md#ask-10-which-differences-between-the-ios-and-android-apps-are-intended)] |
| Entry point                            | None                                                                                        | "Subscriptions" row in Settings, when the flag is on                                                                        | "Upgrade your Snapfix" card, when the flag is on; opens a sales sheet                                                                                                   |
| Restore purchases                      | No                                                                                          | Yes, with no visible result                                                                                                 | No                                                                                                                                                                      |
| Purchase recorded on Snapfix's servers | No                                                                                          | No \[[ASK-143](https://github.com/snapfix/docs/blob/main/ASK.md#ask-143-how-does-an-app-store-purchase-reach-a-sites-plan)] | No                                                                                                                                                                      |

## Screens

* [Choose plan](https://docs.snapfix.com/how-the-apps-work/screens/billing/choose-plan.md): the iOS plan screen, its site sheet and alerts, and Android's card and sheet.
* [Settings](https://docs.snapfix.com/how-the-apps-work/screens/account/app-settings.md): the Settings tab that holds the "Subscriptions" row.

## API and data

* [`POST ?action=paywall`](https://docs.snapfix.com/engineering-reference/api/billing.md#post-actionpaywall): the sites the user can buy for, with each site's in-app flag.
* No Snapfix endpoint receives a purchase or a receipt. Apple holds the products, the purchases and the receipts.
* Tables: [`tPri_UserPaywall`](https://docs.snapfix.com/engineering-reference/db/tables/tpri_userpaywall.md) (a row can turn the in-app flag off for a user and a site; nothing writes it) and [`tPri_IAP_History`](https://docs.snapfix.com/engineering-reference/db/tables/tpri_iap_history.md) (meant for App Store purchases; no code in the repos reads or writes it).

## Depends on

* [Subscriptions](https://docs.snapfix.com/product/features/billing/subscriptions.md): the plans, the free limit and the other way to pay.
* [Payment links](https://docs.snapfix.com/product/features/billing/payment-links.md): the Stripe purchase on the web.
* [Profile and settings](https://docs.snapfix.com/product/features/account/profile.md): the Settings tab.
* [Site users](https://docs.snapfix.com/product/features/console/site-users.md) and [Group members](https://docs.snapfix.com/product/features/groups/group-members.md): the memberships that decide which sites are listed.
* Apple's App Store, which takes the payment.

## Edge cases

* **Offline:** buying and restoring check the connection; loading the products does not ([Choose plan: states](https://docs.snapfix.com/how-the-apps-work/screens/billing/choose-plan.md#states)).
* **Store does not answer:** "Please Wait..." stays up and no cards show.
* **Purchase cannot start:** when the product cannot be loaded or the device does not allow payments, "Please Wait..." stays up.
* **Failed purchases:** every failure, a network error included, says "Purchase cancelled!".
* **Transaction observer:** the plan screen adds itself as a payment queue observer each time it opens and never removes itself.
* **Planner lock:** the planner tab's plan lock never runs, so the planner never opens this screen \[[ASK-146](https://github.com/snapfix/docs/blob/main/ASK.md#ask-146-is-the-ios-planner-tab-lock-still-meant-to-exist)].
* **Time zones:** none.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.snapfix.com/product/features/billing/in-app-purchase.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
