> 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/engineering-reference/db/tables/viewpoint-13.md).

# Billing tables

{% hint style="info" %}
Generated from the staging database schema, with descriptions drafted by agents ([how to read these docs](https://docs.snapfix.com/how-to-read.md)). [Source on GitHub](https://github.com/snapfix/docs/blob/main/spec/db/tables/viewpoint-13.md).
{% endhint %}

## Description

Plans and packages, the billing organisation (`tPri_Org`) with its Stripe, GoCardless, Xero and HubSpot deal records, in-app purchases, the paywall, support minutes and currencies.

## Tables

| Name                                                                                                                               | Columns | Comment                                                                                                                                                                                                                                                                                                                                                                                                                      | Type       |
| ---------------------------------------------------------------------------------------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| [package\_bundle\_server](https://docs.snapfix.com/engineering-reference/db/tables/package_bundle_server.md)                       | 14      | Links a server package to a marketing bundle, with an active flag and dates. Only a migration names it, and no row is newer than 2021-01 \[[ASK-242](https://github.com/snapfix/docs/blob/main/ASK.md#ask-242-can-the-unused-copy-and-scratch-tables-be-dropped)].                                                                                                                                                           | BASE TABLE |
| [package\_client](https://docs.snapfix.com/engineering-reference/db/tables/package_client.md)                                      | 15      | php-apis's copy of a server package (same uuid, without the Stripe and start-date columns), made the first time a site that has the package reads its packages.                                                                                                                                                                                                                                                              | BASE TABLE |
| [package\_client\_parent](https://docs.snapfix.com/engineering-reference/db/tables/package_client_parent.md)                       | 14      | Links a site to its package\_client copy; php-apis copies it from the site's package\_server\_parent row, with the type, active flag and dates.                                                                                                                                                                                                                                                                              | BASE TABLE |
| [package\_marketing\_bundle](https://docs.snapfix.com/engineering-reference/db/tables/package_marketing_bundle.md)                 | 15      | One marketing bundle that groups server packages, with a Stripe bundle ID and dates.                                                                                                                                                                                                                                                                                                                                         | BASE TABLE |
| [package\_server](https://docs.snapfix.com/engineering-reference/db/tables/package_server.md)                                      | 24      | One package (plan) sold to sites, with its Stripe product, type, JSON package definition, allowed payment methods, test flag and start-date rules.                                                                                                                                                                                                                                                                           | BASE TABLE |
| [package\_server\_parent](https://docs.snapfix.com/engineering-reference/db/tables/package_server_parent.md)                       | 15      | Links a site to a server package, with its Stripe subscription, type, active flag and dates.                                                                                                                                                                                                                                                                                                                                 | BASE TABLE |
| [package\_server\_pricing](https://docs.snapfix.com/engineering-reference/db/tables/package_server_pricing.md)                     | 22      | One Stripe price of a server package, with amount, currency, billing interval and quantity limits.                                                                                                                                                                                                                                                                                                                           | BASE TABLE |
| [std\_currencies](https://docs.snapfix.com/engineering-reference/db/tables/std_currencies.md)                                      | 10      | Reference list of ISO currencies; snapfix\_supported marks the ones a package price may use.                                                                                                                                                                                                                                                                                                                                 | BASE TABLE |
| [stripe\_log](https://docs.snapfix.com/engineering-reference/db/tables/stripe_log.md)                                              | 9       | One Stripe webhook event stored in full, with the event name and the event JSON (up to 60,000 characters); apipy writes it and php-apis reads payment events back from it.                                                                                                                                                                                                                                                   | BASE TABLE |
| [stripe\_product\_detail\_retired](https://docs.snapfix.com/engineering-reference/db/tables/stripe_product_detail_retired.md)      | 14      | Retired copy of Stripe product details, 4 rows, none newer than 2021-01; only a migration names it \[[ASK-242](https://github.com/snapfix/docs/blob/main/ASK.md#ask-242-can-the-unused-copy-and-scratch-tables-be-dropped)].                                                                                                                                                                                                 | BASE TABLE |
| [stripe\_subscription](https://docs.snapfix.com/engineering-reference/db/tables/stripe_subscription.md)                            | 11      | One Stripe subscription of a site (uuid\_tParent, subscription\_id); apipy's Stripe handler updates it from webhook events.                                                                                                                                                                                                                                                                                                  | BASE TABLE |
| [tPri\_IAP\_History](https://docs.snapfix.com/engineering-reference/db/tables/tpri_iap_history.md)                                 | 11      | A record of an App Store in-app purchase for a site, as the store sent it. No in-scope code writes or reads it, yet staging has 113 rows, the newest from 2026-08 \[[ASK-143](https://github.com/snapfix/docs/blob/main/ASK.md#ask-143-how-does-an-app-store-purchase-reach-a-sites-plan), [ASK-243](https://github.com/snapfix/docs/blob/main/ASK.md#ask-243-which-service-writes-the-tables-that-no-in-scope-code-names)]. | BASE TABLE |
| [tPri\_Org](https://docs.snapfix.com/engineering-reference/db/tables/tpri_org.md)                                                  | 23      | A customer organisation that groups sites (tPri\_Parent.uuid\_tOrg), with its address, invoice and renewal dates and links to its Stripe, Xero and HubSpot records. No row is newer than 2024-08.                                                                                                                                                                                                                            | BASE TABLE |
| [tPri\_Org\_GoCardlessMandateUrlLog](https://docs.snapfix.com/engineering-reference/db/tables/tpri_org_gocardlessmandateurllog.md) | 13      | One GoCardless mandate sign-up link made for a site's HubSpot deal, with the GoCardless customer ID. The staff admin deal endpoints read it, no in-scope code writes it, and staging has no rows.                                                                                                                                                                                                                            | BASE TABLE |
| [tPri\_Org\_GoCardlessPaymentLog](https://docs.snapfix.com/engineering-reference/db/tables/tpri_org_gocardlesspaymentlog.md)       | 21      | One GoCardless payment for a site, linked to its HubSpot deal and line item. The staff admin deal endpoints read it, no in-scope code writes it, and staging has no rows.                                                                                                                                                                                                                                                    | BASE TABLE |
| [tPri\_Org\_GoCardlessWebhookLog](https://docs.snapfix.com/engineering-reference/db/tables/tpri_org_gocardlesswebhooklog.md)       | 33      | One GoCardless webhook event (payment, payout, mandate or billing request). Rows keep arriving, but no in-scope code names the table, so its writer is unknown \[[ASK-243](https://github.com/snapfix/docs/blob/main/ASK.md#ask-243-which-service-writes-the-tables-that-no-in-scope-code-names)].                                                                                                                           | BASE TABLE |
| [tPri\_Org\_HubspotDealState](https://docs.snapfix.com/engineering-reference/db/tables/tpri_org_hubspotdealstate.md)               | 50      | One HubSpot deal with its billing state (trial, won or lost, with their times), owner, pipeline and lead source; one row per object\_id. The staff admin deal list reads the won deals and counts their Stripe checkout links, and no in-scope code writes it.                                                                                                                                                               | BASE TABLE |
| [tPri\_Org\_Stripe](https://docs.snapfix.com/engineering-reference/db/tables/tpri_org_stripe.md)                                   | 45      | One Stripe customer of an organisation (tPri\_Org.uuid\_tOrgStripe), with its latest subscription and invoice, mostly as text. No in-scope code writes it, and no row is newer than 2024-09.                                                                                                                                                                                                                                 | BASE TABLE |
| [tPri\_Org\_StripeCheckoutUrlLog](https://docs.snapfix.com/engineering-reference/db/tables/tpri_org_stripecheckouturllog.md)       | 13      | One Stripe Checkout link made for a site and its HubSpot deal, with the Stripe customer ID. php-apis writes it, the staff admin deal list counts the links per deal, and no row is newer than 2025-04.                                                                                                                                                                                                                       | BASE TABLE |
| [tPri\_Org\_StripeWebhookLog](https://docs.snapfix.com/engineering-reference/db/tables/tpri_org_stripewebhooklog.md)               | 9       | One Stripe webhook event, kept as its full JSON. Rows keep arriving, but no in-scope code names the table \[[ASK-243](https://github.com/snapfix/docs/blob/main/ASK.md#ask-243-which-service-writes-the-tables-that-no-in-scope-code-names)].                                                                                                                                                                                | BASE TABLE |
| [tPri\_Org\_Xero](https://docs.snapfix.com/engineering-reference/db/tables/tpri_org_xero.md)                                       | 19      | One Xero contact of an organisation (tPri\_Org.uuid\_tOrgXero), with name, email, status and bank details, all as text. No in-scope code writes it, and no row is newer than 2024-09.                                                                                                                                                                                                                                        | BASE TABLE |
| [tPri\_ParentSupportAccount](https://docs.snapfix.com/engineering-reference/db/tables/tpri_parentsupportaccount.md)                | 15      | One line of a site's support-time account, a note, deposit, withdrawal or credit of support minutes, with its approval. apipy adds the lines up to the site's remaining minutes, and no row is newer than 2024-07.                                                                                                                                                                                                           | BASE TABLE |
| [tPri\_UserPaywall](https://docs.snapfix.com/engineering-reference/db/tables/tpri_userpaywall.md)                                  | 14      | A user's in-app purchase offer for a site. Staging has one row, and no repo writes the 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)].                                                                                                                                                                           | BASE TABLE |
| [xero\_contacts](https://docs.snapfix.com/engineering-reference/db/tables/xero_contacts.md)                                        | 82      | One contact copied from Xero, with names, addresses, phone numbers and bank details, as text. apipy's Xero routes list it (nothing calls them), no in-scope code writes it, and no row is newer than 2022-05.                                                                                                                                                                                                                | BASE TABLE |
| [xero\_contacts\_parent](https://docs.snapfix.com/engineering-reference/db/tables/xero_contacts_parent.md)                         | 10      | Links a site (uuid\_tParent) to a Xero contact (uuid\_xero\_contacts). apipy's link route writes it (nothing calls it), and no row is newer than 2022-06.                                                                                                                                                                                                                                                                    | BASE TABLE |
| [xero\_sales\_invoices](https://docs.snapfix.com/engineering-reference/db/tables/xero_sales_invoices.md)                           | 36      | One sales invoice copied from Xero, with number, contact, status and totals; the dates are datetimes and the rest is text. apipy's Xero routes list it (nothing calls them), no in-scope code writes it, and no row is newer than 2022-06.                                                                                                                                                                                   | BASE TABLE |
| [xero\_sales\_invoices\_parent](https://docs.snapfix.com/engineering-reference/db/tables/xero_sales_invoices_parent.md)            | 10      | Links a site to a Xero sales invoice. apipy's link route writes it (nothing calls it), and staging has no rows.                                                                                                                                                                                                                                                                                                              | BASE TABLE |

## Relations

```mermaid
erDiagram


"package_bundle_server" {
}
"package_client" {
}
"package_client_parent" {
}
"package_marketing_bundle" {
}
"package_server" {
}
"package_server_parent" {
}
"package_server_pricing" {
}
"std_currencies" {
}
"stripe_log" {
}
"stripe_product_detail_retired" {
}
"stripe_subscription" {
}
"tPri_IAP_History" {
}
"tPri_Org" {
}
"tPri_Org_GoCardlessMandateUrlLog" {
}
"tPri_Org_GoCardlessPaymentLog" {
}
"tPri_Org_GoCardlessWebhookLog" {
}
"tPri_Org_HubspotDealState" {
}
"tPri_Org_Stripe" {
}
"tPri_Org_StripeCheckoutUrlLog" {
}
"tPri_Org_StripeWebhookLog" {
}
"tPri_Org_Xero" {
}
"tPri_ParentSupportAccount" {
}
"tPri_UserPaywall" {
}
"xero_contacts" {
}
"xero_contacts_parent" {
}
"xero_sales_invoices" {
}
"xero_sales_invoices_parent" {
}
```

***

> Generated by [tbls](https://github.com/k1LoW/tbls)


---

# 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/engineering-reference/db/tables/viewpoint-13.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.
