Skip to content

(feat): Integration And Push - #8

Merged
Koded0214h merged 1 commit into
mainfrom
feat/polish
Jul 1, 2026
Merged

(feat): Integration And Push#8
Koded0214h merged 1 commit into
mainfrom
feat/polish

Conversation

@Koded0214h

Copy link
Copy Markdown
Collaborator

☐ VPS deployment: Docker Compose on Contabo, env vars, HTTPS ☐ Smoke test: create merchant → plan → subscribe → bill → charge → webhook → gym app shows active ☐ Recovery test: force failure → transfer VA issued → simulate push → reconcile → active ☐ payment_uncertain test: timeout → freeze → verify → resolves ☐ Hard bug fixes from integration
☐ Proration end-to-end: upgrade mid-cycle → correct charge fires ☐ Two-merchant isolation proof: same instance, fully isolated data ☐ billing_lag_seconds metric: log time from next_bill_date to charge_attempt created ☐ queue_depth log: consumer lag on billing partition every 60s ☐ recovery_rate metric: past_due healed / total past_due ☐ Integration test: full billing cycle (create → bill → heal) ☐ Integration test: payment_uncertain → verify pass → active

(tests): All tests green, connected with the server bash scripts, integration tests and unit tests

NOTES

Deployment fixed

  • HTTPS was never actually wired up despite a valid cert sitting on disk — nginx only had a port-80 block, and that block was proxying to the wrong app (an unrelated ship-cli project sharing the box). Fixed both; https://somba.ddns.net now correctly terminates TLS and routes to Somba.
  • Docker port mismatch: PORT env var was used for both the host-side publish port and leaked into the container, so uvicorn bound to the wrong port internally — app was unreachable. Fixed.
  • The scheduler wasn't running at all — only the API server was in docker-compose.yml. Nothing was ever billing, delivering webhooks, or reconciling in production. Added it as a proper service.
  • Nomba LIVE credentials are live and verified working, including the parent/sub-account header split your hackathon email specified (auth uses the parent account, resource calls use the sub-account — the client mixed these up before).

Real bugs found and fixed (via actual deployment, not local tests)

  1. Two competing billing-sweep implementations shared one lock; only the dead-end one was scheduled — subscriptions would never have been charged automatically.
  2. Two schema-drift bugs: customers and webhook_deliveries tables were missing columns the ORM models expected (migrations never wrote them). Added a permanent regression test that diffs every migration against the live models.
  3. Subscriptions never advanced their billing period after a successful charge — the most serious one. Every subscription would've been billed again the very next day, and the second charge would have crashed outright on a DB constraint. Fixed, with a regression test proving two consecutive billing cycles now work.
  4. ChargeAttempt.order_reference collided on retries — any second attempt on the same intent (a retry, or reprocessing an "uncertain" charge) crashed with a UniqueViolation. Fixed.
  5. VA (virtual account) creation was never actually wired up — the recovery engine's "transfer" path just emitted an event; nothing ever called Nomba to issue the account. Now it does, using the correct (undocumented-in-the-obvious-place) parent-account endpoint variant for sub-accounts — confirmed against live Nomba, real VA numbers get issued.
  6. Fixed a bug in my own test script (reused a hardcoded fake transaction ID across runs, which tripped Somba's real duplicate-detection).

Webhook — tested as requested

Stood up a real echo receiver, drove a real delivery through the deployed emitter, and independently recomputed the HMAC-SHA256 signature against the merchant's secret — byte-for-byte match. Signing and
delivery are solid.

TESTS

To run it yourself

bash scripts/live/run_all.sh # full suite
bash scripts/live/02_recovery_test.sh # any script individually

☐  VPS deployment: Docker Compose on Contabo, env vars, HTTPS
☐  Smoke test: create merchant → plan → subscribe → bill → charge → webhook → gym app shows active
☐  Recovery test: force failure → transfer VA issued → simulate push → reconcile → active
☐  payment_uncertain test: timeout → freeze → verify → resolves
☐  Hard bug fixes from integration
☐  Proration end-to-end: upgrade mid-cycle → correct charge fires
☐  Two-merchant isolation proof: same instance, fully isolated data
☐  billing_lag_seconds metric: log time from next_bill_date to charge_attempt created
☐  queue_depth log: consumer lag on billing partition every 60s
☐  recovery_rate metric: past_due healed / total past_due
☐  Integration test: full billing cycle (create → bill → heal)
☐  Integration test: payment_uncertain → verify pass → active

(tests): All tests green, connected with the server bash scripts, integration tests and unit tests

NOTES
-----
  Deployment fixed

  - HTTPS was never actually wired up despite a valid cert sitting on disk — nginx only had a port-80 block, and that block was proxying to the wrong app (an unrelated ship-cli project sharing the box).
  Fixed both; https://somba.ddns.net now correctly terminates TLS and routes to Somba.
  - Docker port mismatch: PORT env var was used for both the host-side publish port and leaked into the container, so uvicorn bound to the wrong port internally — app was unreachable. Fixed.
  - The scheduler wasn't running at all — only the API server was in docker-compose.yml. Nothing was ever billing, delivering webhooks, or reconciling in production. Added it as a proper service.
  - Nomba LIVE credentials are live and verified working, including the parent/sub-account header split your hackathon email specified (auth uses the parent account, resource calls use the sub-account — the
  client mixed these up before).

  Real bugs found and fixed (via actual deployment, not local tests)

  1. Two competing billing-sweep implementations shared one lock; only the dead-end one was scheduled — subscriptions would never have been charged automatically.
  2. Two schema-drift bugs: customers and webhook_deliveries tables were missing columns the ORM models expected (migrations never wrote them). Added a permanent regression test that diffs every migration
  against the live models.
  3. Subscriptions never advanced their billing period after a successful charge — the most serious one. Every subscription would've been billed again the very next day, and the second charge would have
  crashed outright on a DB constraint. Fixed, with a regression test proving two consecutive billing cycles now work.
  4. ChargeAttempt.order_reference collided on retries — any second attempt on the same intent (a retry, or reprocessing an "uncertain" charge) crashed with a UniqueViolation. Fixed.
  5. VA (virtual account) creation was never actually wired up — the recovery engine's "transfer" path just emitted an event; nothing ever called Nomba to issue the account. Now it does, using the correct
  (undocumented-in-the-obvious-place) parent-account endpoint variant for sub-accounts — confirmed against live Nomba, real VA numbers get issued.
  6. Fixed a bug in my own test script (reused a hardcoded fake transaction ID across runs, which tripped Somba's real duplicate-detection).

  Webhook — tested as requested

  Stood up a real echo receiver, drove a real delivery through the deployed emitter, and independently recomputed the HMAC-SHA256 signature against the merchant's secret — byte-for-byte match. Signing and
  delivery are solid.

TESTS
-----
  To run it yourself

  bash scripts/live/run_all.sh              # full suite
  bash scripts/live/02_recovery_test.sh     # any script individually
@Koded0214h
Koded0214h merged commit 2030be5 into main Jul 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant