Skip to content

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.

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)
  1. Tradehall issues the invoice and fires invoicing.InvoiceIssued.
  2. 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.
  3. A client with autopay on gets a charge_automatically invoice against their newest saved card, and Stripe charges it and retries declines. Everyone else gets a send_invoice invoice, and Stripe emails it.
  4. 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.
  5. Stripe’s invoice.paid webhook marks the Tradehall invoice paid with invoicing.MarkPaid, which fires InvoicePaid as before, so projects still marks milestones paid.
  6. 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”.

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.
  1. Set STRIPE_SECRET, STRIPE_WEBHOOK_SECRET, and STRIPE_CURRENCY as before.
  2. Point a webhook endpoint at /stripe/webhook with these events: invoice.paid, invoice.payment_failed, invoice.voided, invoice.marked_uncollectible, credit_note.created, plus checkout.session.completed and payment_intent.succeeded for payments started before this change.
  3. 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.
  4. 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.
  5. STRIPE_PAYMENT_METHODS (for example card,us_bank_account) overrides the Dashboard’s payment methods for every invoice. Leave it empty to use the Dashboard’s.
  • “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.

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