Repository navigation
Configure Capve Stripe billing and invoice reconciliation - #48
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 16 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7fd17adbd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf939d542c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| WHERE account_id = ? AND stripe_event_created <= ? | ||
| AND (? = 1 OR stripe_event_created = ?) | ||
| AND COALESCE(stripe_subscription_id, '') = COALESCE(?, '')`) |
There was a problem hiding this comment.
Detect concurrent writes between invoice reconciliations
When two invoice/Checkout handlers overlap for the same subscription, both can read the same stripe_event_created and subscription ID, retrieve different subscription states, and successfully update the row. These handlers leave both guard values unchanged, so an older active snapshot can overwrite a newer past_due snapshot without triggering the 503 retry, incorrectly leaving reporting enabled after the trial expires. The reverse ordering can lock out a recovered subscriber. Use a separate reconciliation revision that advances on every write and retry when its compare-and-swap fails, while retaining the independent subscription-event watermark.
Useful? React with 👍 / 👎.
What changes
Connect Capve's hosted billing implementation to the live resources created in the confirmed CodepushGo, LLC Stripe account. Starter is $74.50/month and Pro is $149.50/month. Production configuration records the real Price IDs and dedicated customer portal ID while keeping billing and automatic tax explicitly disabled.
Checkout now collects and persists billing addresses and business tax IDs, uses flexible subscription billing, and supports separately enabled automatic tax. Signed invoice and Checkout events reconcile the current subscription without granting reporting access based on a paid invoice or completion alone. Independent event streams preserve the subscription-event timestamp; concurrent subscription changes cause losing subscription and invoice handlers to retry.
The dedicated portal supports invoice history, billing/payment updates, prorated upgrades, period-end downgrades and cancellation. Setup documentation includes the actual resource IDs, planner receipt, remaining secret setup, tax prerequisites and activation order.
Live Stripe setup completed
capve_starterandcapve_pro, with monthly USD Prices matching the published plans.bpc_1UUFeHPth1byRSsb0svtijZb.we_1UUFfqPth1byRSsblazybdxgat the production billing URL, pinned to2026-09-30.endive; currently disabled until secrets and deployment are ready.No Customers, subscriptions, payments, tax registrations or Worker deployments were created. The MCP connection cannot issue a runtime API key. Stripe Dashboard login is required to create a restricted key; install it and the endpoint signing secret privately in Cloudflare before activation. No tax registrations are recorded in Stripe, so automatic tax remains disabled pending confirmed registration and pricing details. Martin handles production deployment per AGENTS.md.
Validation
bun run test: 146 tests across 21 files pass.bun run typecheck: passes.bun run build: passes (existing bundle-size warning).This PR changes no UI. Sandbox payment and tax collection validation remain required before launch; mocked integration tests do not replace them.