Skip to content

Configure Capve Stripe billing and invoice reconciliation - #48

Merged
riderx merged 3 commits into
mainfrom
cursor/stripe-setup-1798
Oct 25, 2026
Merged

riderx merged 3 commits into
mainfrom
cursor/stripe-setup-1798

Conversation

@riderx

@riderx riderx commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

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

  • Products capve_starter and capve_pro, with monthly USD Prices matching the published plans.
  • Portal configuration bpc_1UUFeHPth1byRSsb0svtijZb.
  • Webhook endpoint we_1UUFfqPth1byRSsblazybdxg at the production billing URL, pinned to 2026-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).
  • Regression coverage includes invoice failure/recovery, unknown Customers/prices, mismatched subscription Customers, delayed events, concurrent subscription updates, incomplete Checkout, portal configuration, tax on/off parameters and Checkout retry/trial preservation.

This PR changes no UI. Sandbox payment and tax collection validation remain required before launch; mocked integration tests do not replace them.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-25T01:09:31.914647Z 0971636 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

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

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 7d35ee3f-d7a3-46b5-ab6a-b95c8dc424fd
Commits

Reviewing files that changed from the base of the PR and between 0e5039a and 0971636.

Files selected for processing: 8
  • docs/billing-setup.md
  • docs/stripe-integration-plan.md
  • migrations/0028_billing_reconciliation_revision.sql
  • tests/billing.test.ts
  • tests/schema.ts
  • worker/routes/billing.ts
  • worker/types.ts
  • wrangler.toml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread worker/routes/billing.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread worker/routes/billing.ts Outdated
Comment on lines +204 to +206
WHERE account_id = ? AND stripe_event_created <= ?
AND (? = 1 OR stripe_event_created = ?)
AND COALESCE(stripe_subscription_id, '') = COALESCE(?, '')`)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@riderx
riderx merged commit ec6a08d into main Oct 25, 2026
5 checks 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