Matthew Jeter M. Ziemba

Quote-to-cash billing platform

Signups provision themselves and bill monthly, with HubSpot as the control plane over NetSuite, the provider’s own platform, a Snowflake warehouse and an AWS identity bridge.

For
A services company
Role
Sole external engineer, from requirements to production
When
April 2026 to now
Status
In production since September 2026
Systems
HubSpot, NetSuite, Snowflake, dbt, Hex and AWS

One control plane, from signup to invoice

Signup formsSignup formsHubSpot, the CRM control planeHubSpot, the CRM control planePrivate app, Agreement objectWorkersWorkersHubSpot custom-coded actionsThe service platformThe service platformNetSuite, the ERPNetSuite, the ERPSuiteScript RESTletSnowflake, dbt and HexSnowflake, dbt and HexAWS identity bridgeAWS identity bridgeLambdaNode 20, token authRDS MariaDBIdentity tableCustomersCustomersStaged recordsProvisioning readyUsers, sites, numbersCustomer recordIdentity rows, by tokenMonthly invoice draftsPDF and email, after SendUsage, replicatedIdentity mirror, replicatedHourly usage writebackQuotes and emailsKey: type, agreement, monthIND-A-1001-202610Upsert by external idKey derived on the serverParking brakePark gatePayer-first routingSend gateInternal-domain guardManual-resend guardToken checkPrivate VPCSecrets ManagerDatabase credentialsIdempotent batch upsert, retries with backoffCutoverFrom the cutover runbookFreeze +0:00ERP swap +4:06Platform swap +9:52Live test passedKeep production about +59:00 Signup formsSignup formsHubSpotHubSpotWorkersWorkersService platformService platformNetSuiteNetSuiteWarehouseWarehouseAWS bridgeAWS bridgeLambdaRDS MariaDBCustomersCustomersabcdefghijkSecrets Manager
  1. Signup forms send staged records to HubSpot, the CRM control plane, where a private app and an Agreement custom object run billing.
  2. When a deal reaches provisioning ready, HubSpot custom-coded actions run as workers.
  3. The workers create users, sites and phone numbers on the service platform, upsert the customer in NetSuite by external id, and write identity rows to an AWS identity bridge with a token.
  4. The identity bridge is a Node 20 Lambda function inside a private VPC, in front of a MariaDB table on RDS. Secrets Manager holds the database credentials.
  5. HubSpot sends customers their quotes and service agreements from branded templates, and emails from HubSpot templates.
  6. Each month, finance generates invoice drafts in NetSuite from HubSpot agreements, one per agreement per month, keyed so that generating again creates nothing new.
  7. After a person reviews the drafts and presses Send, a SuiteScript RESTlet in NetSuite renders each invoice as a PDF and emails it.
  8. Six guards sit on the invoice path: a parking brake, a park gate, payer-first routing, a send gate, an internal-domain guard and a manual-resend guard.
  9. Platform usage and the identity table replicate into Snowflake. dbt models shape the usage, and Hex writes it back to HubSpot every hour, in batches that retry with backoff.
  10. HubSpot workflows open a high-priority task and post an alert to the team’s Slack when a quote is blocked.
  11. Cutover: a freeze of about 59 minutes, two credential swaps, a live production test that passed every hard gate, and the verdict to keep production.

Legend

  • Systems
  • Data paths
  • Guards and keys

Systems

  • System: Signup forms Vendor: HubSpot Role: Where new customers sign up
  • System: HubSpot, the CRM control plane Vendor: HubSpot Role: Holds every customer, quote and agreement, runs billing and alerts the team in Slack
  • System: Workers Vendor: HubSpot Role: Provision each new customer across the other systems
  • System: The service platform Vendor: The provider’s own Role: Runs the service the customer pays for
  • System: NetSuite, the ERP Vendor: NetSuite Role: Keeps the books, and renders and emails each invoice through a SuiteScript RESTlet
  • System: Snowflake, dbt and Hex Vendor: Snowflake, dbt, Hex Role: Turns platform usage into billing inputs
  • System: AWS identity bridge Vendor: AWS Role: Records which platform user belongs to which customer
  • System: Customers Role: Receive quotes and emails from HubSpot, and the monthly invoice from NetSuite

5 systems (3 roles on HubSpot), 6 vendors, 1 private network

Data paths

  • a Staged records
  • b Provisioning ready
  • c Users, sites, numbers
  • d Customer record
  • e Identity rows, by token
  • f Monthly invoice drafts
  • g PDF and email, after Send
  • h Usage, replicated
  • i Identity mirror, replicated
  • j Hourly usage writeback
  • k Quotes and emails

Trace

Sample data

One sample signup

Time Step
10:02:00 Provisioning ready
10:02:04 Billing code minted
10:02:09 ERP customer upserted
10:02:12 Agreement created
10:02:19 Platform busy, retried
10:02:31 2 users, 1 site, 1 number
10:02:52 3 identity rows written
10:03:46 Agreement active

8 steps, 1 held and retried, 1 min 46 s from provisioning ready to active.

Production results

In end-to-end tests across 11 account types, provisioning ready to active took about 70 to 130 seconds.

Keys and retries

  • Key: type, agreement, month
  • Upsert by external id
  • Key derived on the server
  • Idempotent batch upsert, retries with backoff

Guards on the invoice path

  • Parking brake
  • Park gate
  • Payer-first routing
  • Send gate
  • Internal-domain guard
  • Manual-resend guard

Guards

Sample data

October drafts for 12 sample agreements

Guard Checked Held
Parking brake 12 1
Park gate 10 1
Payer-first routing 9 0
8 to the payer, 4 of them instead of the user; 1 with no matching contact
Send gate 9 1
Internal-domain guard 8 1
Manual-resend guard 1 1

7 ready for Send, all addressed to the payer. 5 held.

Nothing goes out until a person reviews the drafts and presses Send.

Show the data
[
  {"agreement":"A-1001","type":"IND","parked":"no","action":"send","billingEmail":"accounts@alderpay.example","contacts":[{"role":"user","email":"m.reyes@mail.example"},{"role":"payer","email":"accounts@alderpay.example"}]},
  {"agreement":"A-1002","type":"IND","parked":"no","action":"send","billingEmail":"billing@coastline.example","contacts":[{"role":"user","email":"t.ho@mail.example"},{"role":"payer","email":"billing@coastline.example"}]},
  {"agreement":"A-1003","type":"ORG","parked":"no","action":"send","billingEmail":"ap@ridgeway.example","contacts":[{"role":"payer","email":"ap@ridgeway.example"}]},
  {"agreement":"A-1004","type":"GRP","parked":"no","action":"send","billingEmail":"finance@eastgate.example","contacts":[{"role":"payer","email":"finance@eastgate.example"}]},
  {"agreement":"A-1005","type":"IND","parked":"before-draft","action":"send","billingEmail":"accounts@alderpay.example","contacts":[{"role":"user","email":"k.osei@mail.example"},{"role":"payer","email":"accounts@alderpay.example"}]},
  {"agreement":"A-1006","type":"IND","parked":"after-draft","action":"send","billingEmail":"billing@coastline.example","contacts":[{"role":"user","email":"l.ferro@mail.example"},{"role":"payer","email":"billing@coastline.example"}]},
  {"agreement":"A-1007","type":"IND","parked":"no","action":"send","billingEmail":"acounts@alderpay.example","contacts":[{"role":"user","email":"d.park@mail.example"},{"role":"payer","email":"accounts@alderpay.example"}]},
  {"agreement":"A-1008","type":"ORG","parked":"no","action":"send","billingEmail":"accounts@provider.example","contacts":[{"role":"payer","email":"accounts@provider.example"}]},
  {"agreement":"A-1009","type":"IND","parked":"after-draft","action":"manual-resend","billingEmail":"invoices@northfield.example","contacts":[{"role":"user","email":"r.basu@mail.example"},{"role":"payer","email":"invoices@northfield.example"}]},
  {"agreement":"A-1010","type":"IND","parked":"no","action":"send","billingEmail":"billing@coastline.example","contacts":[{"role":"user","email":"a.silva@mail.example"},{"role":"payer","email":"billing@coastline.example"}]},
  {"agreement":"A-1011","type":"GRP","parked":"no","action":"send","billingEmail":"finance@eastgate.example","contacts":[{"role":"payer","email":"finance@eastgate.example"}]},
  {"agreement":"A-1012","type":"IND","parked":"no","action":"send","billingEmail":"invoices@northfield.example","contacts":[{"role":"user","email":"p.lam@mail.example"},{"role":"payer","email":"invoices@northfield.example"}]}
]

Identity bridge

Sample data
  • Token check
  • Private VPC
  • Secrets Manager

Four sample writes

Request Key Result
1 user-A-1020-1 Stored, new row
2 site-A-1020-1 Stored, new row
3 user-A-1020-1 Same key, updated in place
4 user-A-1021-1 Refused: no token

4 requests: 2 rows stored, 1 retry landed on the same row, 1 refused.

Show the data
[
  {"n":1,"op":"upsert","token":"rw","fields":{"record":"user","agreement":"A-1020","slot":1}},
  {"n":2,"op":"upsert","token":"rw","fields":{"record":"site","agreement":"A-1020","slot":1}},
  {"n":3,"op":"upsert","token":"rw","fields":{"record":"user","agreement":"A-1020","slot":1},"note":"Retry of request 1"},
  {"n":4,"op":"upsert","token":"none","fields":{"record":"user","agreement":"A-1021","slot":1}}
]

Production results

29 of 29 end-to-end tests passed in production, where the bridge has run since July 2026.

I designed the bridge and wrote its handler and schema; the provider’s DevOps team deployed it from that code with Terraform.

Production results

29 of 29 end-to-end tests passed in production, where the bridge has run since July 2026.

I designed the bridge and wrote its handler and schema; the provider’s DevOps team deployed it from that code with Terraform.

Cutover

From the cutover runbook

A freeze of about 59 minutes, two credential swaps and a live production test that passed every hard gate. Verdict: keep production, my go-live call.

  1. Freeze +0:00
  2. ERP swap +4:06
  3. Platform swap +9:52
  4. Live test passed
  5. Keep production about +59:00

Production results

First billing run: 1,154 of 1,154 live agreements settled, 0 duplicate invoice numbers.

1,073 October invoices sent, with 1,916 of 1,923 recipient deliveries completed.

Production results

First billing run: 1,154 of 1,154 live agreements settled, 0 duplicate invoice numbers.

1,073 October invoices sent, with 1,916 of 1,923 recipient deliveries completed.

Billing ran on a spreadsheet, a script and a CSV import

About 1,000 invoices a month were built from a spreadsheet, HubSpot lists, a staff member’s script and a CSV file imported into NetSuite by hand. HubSpot and the service platform were not linked, so staff matched people by email, and no usage reached HubSpot. The new system had to take over without a double bill or a wrong payer while the old process kept running.

What I built

What the guards protect against

The risk The guard
Generate runs twice, and an agreement is billed twice for the same month. Key: type, agreement, month One draft per agreement per month. Generating again finds the key and makes nothing new.
A retried call creates a duplicate customer in the ERP. Upsert by external id A repeated call updates the same ERP customer instead of creating a second one.
A retried write adds a duplicate row to the identity table. Key derived on the server The bridge builds each row’s key from its fields, so a retried write lands on the same row.
An agreement not yet released for billing is drafted and billed. Parking brake A parked agreement gets no draft.
A draft made before its agreement was parked still goes out. Park gate A draft whose agreement was parked after drafting is not sent.
The invoice goes to the person using the service instead of the payer. Payer-first routing The invoice goes to the payer, the contact whose email matches the billing email, not the person using the service.
An invoice goes out to an address that does not match the billing email. Send gate Nothing is sent unless the addressee’s email matches the billing email.
Invoices are mailed to the provider’s own inbox, even when its address is hidden in a list. Internal-domain guard Nothing is sent to the provider’s own domain, even inside a list of addresses.
A manual resend skips the checks the first send had to pass. Manual-resend guard A manual resend passes the same checks as the first send.
A caller without a valid token reads or writes identity rows. Token check A request without a valid token is refused.
The identity database can be reached from outside the provider’s private network. Private VPC The Lambda and the database sit inside the provider’s private network.
Database credentials end up in workflow code, outside the private network. Secrets Manager Database credentials stay in Secrets Manager, never in workflow code.
A failed call leaves usage out of date in HubSpot, or a rerun creates duplicate records. Idempotent batch upsert, retries with backoff Records are upserted in batches by HubSpot id, and failed calls retry with backoff.

Decisions

  1. Bill in drafts that a person sends, behind a parking brake

    Chose
    The engine only makes drafts: finance presses Generate, reviews and deselects, then presses Send. Every migrated agreement stayed parked until someone released it on purpose.
    Instead of
    • A scheduled run that bills and emails on its own. Drafts leave a window for a person to check every invoice and its recipient before anything goes out.
    • Migrating the book ready to bill. The old process kept billing until cutover, so an agreement live in both could have been billed twice.
    Trade-off
    Finance takes two deliberate steps every month, and each parked agreement needs its own release.
  2. Use production’s own billing run as the answer key

    Chose
    Score a whole-book sandbox dry run, agreement by agreement, against production’s real September run, pulled read-only, and settle open questions from production’s send history.
    Instead of
    • A clean sandbox run. A run with no errors shows that the engine works, not that it bills what production bills.
    • Sending finance a list of 117 open questions. Production’s send history settled them from evidence, leaving 16 genuine holds for people to decide.
    Trade-off
    Production had to be read without ever being written to, and every round of changes meant a fresh whole-book dry run, scored agreement by agreement.
  3. Prove each credential swap with a live production test

    Chose
    Swap the ERP and platform credentials inside a timed freeze, with both set to roll back together, and keep them only after a live production test reads back right in both systems.
    Instead of
    Calling the swap done once the new secret was saved. Saving a secret shows nothing about which secret live runs use; only a live run that reads back right in both systems does.
    Trade-off
    No changes for about 59 minutes, while a live production test passed every hard gate and the go-live call was made.
  4. Run provisioning inside HubSpot, not on a new AWS layer

    Chose
    Provisioning runs as HubSpot custom-coded actions that fan out one worker per seat and per site. AWS keeps only a small identity bridge inside the provider’s private network.
    Instead of
    A Lambda orchestrator on AWS, as first planned. It would have been one more system for the provider to run, and custom code in HubSpot could call the platform and the ERP directly, with its secrets kept in HubSpot.
    Trade-off
    Every action must finish inside HubSpot’s 20-second limit, even for fleets of 60 to 100 sites, and may run again on a retry, so every create had to be idempotent.

Results

  • First billing run: 1,154 of 1,154 live agreements settled, 0 duplicate invoice numbers.
  • 1,073 October invoices sent, with 1,916 of 1,923 recipient deliveries completed.
  • 29 of 29 end-to-end tests passed in production, where the bridge has run since July 2026.
  • In end-to-end tests across 11 account types, provisioning ready to active took about 70 to 130 seconds.

A new secret reaches test runs at once but live runs only after its status reads Available, so the runbook waits for Available plus 30 minutes before any live test.

Facts

  • Recipient model checked against 18,074 invoices from five years: 95.5% coverage
  • Load test: 100 sites and 40 seats armed in one orchestrator run, with zero watchdog retries
  • Usage writeback: 1,106 of 1,148 agreements exact and 42 dormant, with 0 defects
  • Quotes and service agreements go out from 11 branded HubSpot templates, beside 16 HubSpot email templates
  • Invoices are emailed by a SuiteScript RESTlet in NetSuite, with no change to account-wide settings
  • A blocked quote opens a high-priority task for the deal and posts its reason to the team’s Slack

Panels marked Sample data compute from fictional records in this page. Production figures are counts from real run records, logs and git history, with client names left out.

  1. Two-way ERP sync

    Date: Aug 2026

    Fact: 11,598 deals linked to the ERP

    Client: For a commercial roofing contractor

    Systems: Dataforma

    Status: In production

  2. ERP project automation

    Date: Oct 2026

    Fact: Customer key collision-free across 6,025 contacts

    Client: For a residential roofing and exteriors contractor

    Systems: Acumatica

    Status: In production

  3. Multi-tenant event processor

    Date: Jun 2026

    Fact: 10,630 events in 7 days through the queue that replaced Make.com

    Client: For a multi-brand roofing company

    Systems: AccuLynx and Make.com

    Status: In production