Finance on Stripe
Tradehall leans on Stripe for the money side of invoicing, so it doesn’t have to build what Stripe already does well. This page says which system owns what, how they stay in step, and what is left for later.
Who owns what
Section titled “Who owns what”Tradehall is the system of record for the work: clients, projects, timesheets, billable items, recurring plans, and the invoice itself (its number, lines, and dates). Every invoice is still issued in Tradehall, by a person, an agent, a recurring plan, or billing.Record intake from another module.
Stripe owns collecting the money once an invoice exists:
| Need | Stripe feature |
|---|---|
| Invoice email to the client | Stripe Invoicing sends it |
| PDF invoices and receipts | Stripe’s invoice PDF, linked from Tradehall |
| Paying online | Stripe’s hosted invoice page (card, ACH bank debit, and whatever else the Stripe account turns on) |
| Overdue reminders | Stripe’s automatic reminders, set in the Stripe Dashboard |
| Failed card retries | Stripe’s Smart Retries on autopay invoices |
| Sales tax | Stripe Tax, when STRIPE_TAX=true |
| Credit notes and refunds | Issued in the Stripe Dashboard, recorded on the client’s timeline |
| Saved cards | Stripe’s customer portal (unchanged) |
How an invoice flows
Section titled “How an invoice flows”- Tradehall issues the invoice and fires
invoicing.InvoiceIssued. - The Stripe module queues
stripe.sync-invoice. It creates a Stripe customer for the client if needed, a draft Stripe invoice with the same number and due date, one invoice item per line (an amount with a description such as “Support hours (2.5 x $95.00)”, since Stripe quantities are whole numbers), then finalizes it. - A client with autopay on gets a
charge_automaticallyinvoice against their newest saved card, and Stripe charges it and retries declines. Everyone else gets asend_invoiceinvoice, and Stripe emails it. - The hosted page URL, the PDF URL, and any Stripe Tax amount come back to invoicing through
invoicing.AttachDocument(see below). The portal’s “Pay online” button opens the hosted page, and “Download PDF” opens Stripe’s PDF. - Stripe’s
invoice.paidwebhook marks the Tradehall invoice paid withinvoicing.MarkPaid, which firesInvoicePaidas before, so projects still marks milestones paid. - When staff record a payment in Tradehall instead (a check, cash), the Stripe module marks the Stripe invoice paid out of band so Stripe stops sending reminders.
Every Stripe call carries an idempotency key built from the Tradehall invoice ID, and the module remembers how far each sync got, so a retried job picks up where it stopped. An invoice issued before Stripe was set up syncs the first time a client presses “Pay online”.
How invoicing hears about Stripe
Section titled “How invoicing hears about Stripe”The Stripe module never writes invoicing’s tables. Invoicing exports two small pieces for it:
invoicing.Courier, an interface a module implements to say it emails issued invoices and receipts itself. While one is active, invoicing skips its own emails, so clients don’t get two.invoicing.AttachDocument(ctx, invoice, invoicing.Document{...}), which stores the PDF link and the tax a provider calculated. The invoice pages show “Download PDF” in place of the print page when a PDF exists, and show tax and amount due when tax isn’t zero.
- Set
STRIPE_SECRET,STRIPE_WEBHOOK_SECRET, andSTRIPE_CURRENCYas before. - Point a webhook endpoint at
/stripe/webhookwith these events:invoice.paid,invoice.payment_failed,invoice.voided,invoice.marked_uncollectible,credit_note.created, pluscheckout.session.completedandpayment_intent.succeededfor payments started before this change. - In the Stripe Dashboard, under Settings, Billing, Invoices: turn on emailing finalized invoices and reminders, pick the payment methods clients may use (turn on ACH Direct Debit for bank payments), and set the branding.
- For sales tax, turn on Stripe Tax, add each client’s address to their Stripe customer, and set
STRIPE_TAX=true. Stripe refuses to finalize an invoice for a customer it can’t locate, so set the addresses first. STRIPE_PAYMENT_METHODS(for examplecard,us_bank_account) overrides the Dashboard’s payment methods for every invoice. Leave it empty to use the Dashboard’s.
What changed for existing behavior
Section titled “What changed for existing behavior”- “Pay online” opens Stripe’s hosted invoice page in place of a Checkout session. Checkout and autopay payments started before the change still settle through the webhook.
- Autopay no longer makes its own PaymentIntent. Stripe charges the invoice, retries declines, and emails the receipt.
- Tradehall’s own invoice and receipt emails go out only while Stripe isn’t set up.
Voiding
Section titled “Voiding”Staff void an open invoice from its page (or an agent with invoicing_void_invoice), with a reason the client sees. The invoice keeps its number, any billable work it billed goes back to unbilled for the next invoice, and invoicing.InvoiceVoided fires. The Stripe module then voids the Stripe invoice, which closes its payment page and stops reminders, or deletes it if it was still a draft. Voiding an invoice in the Stripe Dashboard fires invoice.voided, which voids it in Tradehall too. A paid invoice can’t be voided; refund it in Stripe and issue a credit note instead.
Quotes
Section titled “Quotes”Quotes live in Tradehall, in the invoicing module. Staff send one from Quotes (or an agent with invoicing_send_quote), and the client gets an email with a link to accept or decline it in the portal before it expires. Accepting issues a Tradehall invoice with the same lines, due the quote’s number of days later, and that invoice flows to Stripe like any other. The quote has a printable page like an invoice.
Stripe Quotes were left out on purpose. Accepting one creates the invoice in Stripe, which would make Stripe the source of that invoice, and Stripe has no page where a client accepts a quote: someone marks it accepted in the Dashboard. Every Stripe Quote line also needs a Stripe Product. All Stripe would add is its PDF, which the print page covers.
- Uncollectible. Marking an invoice uncollectible in Stripe only adds a note to the client’s timeline for staff.
- Tax on Tradehall’s side. Tax is whatever Stripe calculated at finalization. Totals and MRR in Tradehall still exclude tax.
- Client addresses. Clients have no address in Tradehall, so Stripe Tax relies on the address kept in Stripe.
- Invoice numbers. Stripe invoices carry the Tradehall number, and Stripe refuses a number its account already used. Two Tradehall installations sharing one Stripe account would collide, so give each its own account. A refusal shows on the client’s timeline for staff.
- Clients without an email. Stripe emails the customer’s address, taken from the client’s first portal contact or the client’s own email. A client with neither gets no invoice email; staff see the invoice in Tradehall as usual.