Skip to content

[comp] Production Deploy#2736

Merged
carhartlewis merged 32 commits intoreleasefrom
main
May 1, 2026
Merged

[comp] Production Deploy#2736
carhartlewis merged 32 commits intoreleasefrom
main

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 1, 2026

This is an automated pull request to release the candidate branch into production, which will trigger a deployment.
It was created by the [Production PR] action.


Summary by cubic

Launches the Stripe-backed billing platform using a SKU-first catalog via @trycompai/billing, with admin/customer UIs, entitlement gating, secure webhooks, and add‑ons/trial support. Also refreshes the integrations catalog and adds billing audit logging with more robust webhook processing.

  • New Features

    • API: BillingModule with subscriptions, entitlements, credits, invoices, preferences, and webhook at /v1/billing/webhook (raw‑body enabled) with idempotent event store and better error preservation; usage ledger now favors the newest event.
    • Catalog: integrates @trycompai/billing; build includes packages/billing.
    • Admin: billing controller/services for preferences, plan changes, credits, and audit logging; interceptor maps billing actions to org audit events and writes an audit entry when a subscription is set.
    • Background checks: Stripe customer creation, invoice listing, setup sessions, stricter redirect URL validation, included‑usage consumption before charging, and safer invoice rollback on failures.
    • Pentests: create/run gated by entitlements; usage consumption and refunds wired into services and tests.
    • App: Billing settings with plans, add‑ons, trials, invoices, payment method portal, preferences, and usage table; Admin Billing tab added; improved invoices table and copy/links in background check flow.
  • Migration

    • Configure Stripe envs and webhook secret; register webhook to /v1/billing/webhook.
    • Set NEXT_PUBLIC_APP_URL/APP_URL (or BETTER_AUTH_URL) to a valid HTTPS origin; only localhost may use HTTP.
    • Ensure deploy builds packages/billing (Dockerfile/buildspec updated).

Written for commit 40180c8. Summary will update on new commits.

carhartlewis and others added 28 commits April 30, 2026 20:48
…e management

- Added functions to find or create a billing customer in Stripe and list billing invoices.
- Introduced validation for redirect URLs in billing processes.
- Updated BackgroundCheckBillingService to utilize new billing customer and invoice functionalities.
- Enhanced BackgroundCheckPaymentService to handle invoice creation and payment processing.
- Created BillingInvoicesTable component for displaying invoices in the UI.
- Updated tests to cover new billing features and ensure proper functionality.
- Refactored the layout of the BillingInvoicesTable component to improve responsiveness.
- Changed Stack component to a div with flex properties for better alignment on larger screens.
- Adjusted width properties for the search input to enhance UI consistency.
…L validation

- Introduced unit tests for the findOrCreateBackgroundCheckBillingCustomer function to ensure proper handling of concurrent requests and Stripe customer updates.
- Added tests for validateBackgroundCheckBillingRedirectUrl to validate app URL configurations and handle malformed URLs.
- Enhanced BackgroundCheckPaymentService tests to cover invoice voiding scenarios when invoice item creation or finalization fails.
…services

- Added the @trycompai/billing package to the workspace and integrated it into the API.
- Updated BackgroundCheckPaymentService to utilize the new BillingEntitlementsService for managing billing entitlements and usage.
- Refactored background check billing logic to improve invoice handling and payment processing.
- Introduced new billing-related endpoints and services, including billing customer management and usage tracking.
- Enhanced tests for billing functionalities to ensure robust coverage of new features.
- Updated BackgroundCheckBillingService to utilize resolveBillingCatalogEnvironment for improved SKU resolution.
- Refactored BackgroundCheckPaymentService to streamline payment processing and error handling.
- Introduced new billing setup session management with createBillingSetupSession and handleBillingSetupSuccess functions.
- Enhanced BillingService to support subscription plan changes and trial eligibility checks.
- Added new billing-related utility functions for managing subscriptions and usage tracking.
- Updated tests to cover new billing functionalities and ensure robust integration with Stripe.
- Added "allowImportingTsExtensions" option to tsconfig.json for improved module resolution.
- Updated import statement in index.ts to include the .ts extension for sku-definitions.
- Changed import statement in index.ts to use .js extension for sku-definitions.
- Added sku-definitions.js to export createSkus from sku-definitions.ts.
- Implemented proxy handling for billing add-ons in the proxy.ts file.
- Enhanced BillingAddOnsOverview component to display trial eligibility badges and messages.
- Updated BillingSettingsClient to pass trial eligibility data.
- Created a new catch-all page for billing add-ons to handle dynamic routing.
- Added layout component for billing add-ons section.
- Updated tests to cover new billing add-ons features and trial eligibility scenarios.
- Added AdminBillingActionsService to handle subscription management, including cancellation, resumption, and credit granting.
- Created AdminBillingController to expose billing endpoints for managing organization billing preferences and subscriptions.
- Introduced DTOs for billing actions to validate incoming requests.
- Implemented billing audit logging for actions performed by admins.
- Enhanced billing data fetching and context management for organizations.
- Added `tsup` as a dev dependency for building the billing package.
- Updated billing package.json to include proper exports for module types.
- Modified buildspec.yml and Dockerfile to include billing package in the build process.
…rhaul

# Conflicts:
#	apps/app/src/app/(app)/[orgId]/admin/organizations/[adminOrgId]/components/AdminOrgTabs.tsx
#	apps/app/src/app/(app)/[orgId]/people/[employeeId]/components/EmployeeBackgroundCheck.test.tsx
#	apps/app/src/app/(app)/[orgId]/people/[employeeId]/components/EmployeeBackgroundCheck.tsx
[dev] [carhartlewis] lewis/comp-stripe-overhaul
@vercel
Copy link
Copy Markdown

vercel Bot commented May 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app (staging) Ready Ready Preview, Comment May 1, 2026 9:34pm
comp-framework-editor (staging) Ready Ready Preview, Comment May 1, 2026 9:34pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
portal (staging) Skipped Skipped May 1, 2026 9:34pm

Request Review

5 added, 0 updated, 0 removed. Total: 574 / 9 categories.

Added: airbrake, logz-io, monday-com, octopus-deploy, snipe-it

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

10 issues found across 131 files

Confidence score: 2/5

  • Several high-confidence billing-path issues are user-impacting (idempotency collisions and stale usage selection), so merge risk is elevated rather than routine.
  • The most severe concern is in apps/api/src/billing/billing-customer.ts: a per-org idempotency key combined with variable email can trigger Stripe idempotency errors under concurrent requests.
  • There are additional runtime/behavior risks in apps/api/src/billing/billing-entitlements.service.ts (missing @Optional() for DI), apps/api/src/admin-organizations/admin-audit-log.interceptor.ts (overbroad context parsing), and apps/api/src/billing/billing-webhook.service.ts (original errors can be swallowed).
  • Pay close attention to apps/api/src/billing/billing-customer.ts, apps/api/src/billing/billing-usage.ts, apps/api/src/billing/billing-webhook.service.ts - these affect billing correctness, Stripe interaction reliability, and error visibility.

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed. cubic prioritises the most important files to review.

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/app/src/app/(app)/[orgId]/settings/billing/billingPreferencesFormSchema.ts">

<violation number="1" location="apps/app/src/app/(app)/[orgId]/settings/billing/billingPreferencesFormSchema.ts:17">
P2: `getCountryLabel` uppercases input, but the `No country` option is stored as lowercase `none`, so `getCountryLabel('none')` returns `NONE` instead of the expected label.</violation>
</file>

<file name="apps/api/src/billing/billing-usage.ts">

<violation number="1" location="apps/api/src/billing/billing-usage.ts:70">
P2: `Map` construction here can select an older usage event per source instead of the latest one, causing stale billing type/SKU in usage rows.</violation>
</file>

<file name="apps/api/src/billing/billing-entitlements.service.ts">

<violation number="1" location="apps/api/src/billing/billing-entitlements.service.ts:21">
P2: Missing `@Optional()` decorator on the `credits` constructor parameter. NestJS DI ignores TypeScript's `?` — without `@Optional()`, this dependency is treated as required at runtime. The null-checks on `this.credits` elsewhere in the class will be dead code unless the decorator is added.</violation>
</file>

<file name="apps/api/src/admin-organizations/admin-audit-log.interceptor.ts">

<violation number="1" location="apps/api/src/admin-organizations/admin-audit-log.interceptor.ts:160">
P2: This condition is too broad and unintentionally changes `context` audit parsing. It should only apply to `billing`; otherwise `context` entries get `entityId = orgId` and lose correct entity-name resolution.</violation>
</file>

<file name="apps/api/src/billing/billing-webhook.service.ts">

<violation number="1" location="apps/api/src/billing/billing-webhook.service.ts:58">
P2: If `markStripeWebhookFailed` throws (e.g., DB is down), the original processing error is swallowed. Wrap the failure-recording call so the original error is always re-thrown.</violation>
</file>

<file name="apps/api/src/billing/billing-subscription-plans.ts">

<violation number="1" location="apps/api/src/billing/billing-subscription-plans.ts:101">
P2: Idempotency key lacks a temporal or sequence component, so an upgrade→downgrade→upgrade cycle within 24 hours would hit Stripe's cached response and silently skip the second upgrade. Consider including a timestamp, sequence counter, or the current `skuKey` being changed *from* in the key.</violation>
</file>

<file name="apps/api/src/billing/billing-credits.types.ts">

<violation number="1" location="apps/api/src/billing/billing-credits.types.ts:31">
P2: `eventType` is typed as `string` instead of the local `BillingCreditEventType` union, which weakens type safety for credit event payloads.</violation>
</file>

<file name="apps/app/src/app/(app)/[orgId]/people/[employeeId]/components/BackgroundCheckDetailsForm.tsx">

<violation number="1" location="apps/app/src/app/(app)/[orgId]/people/[employeeId]/components/BackgroundCheckDetailsForm.tsx:110">
P2: Use `next/link` instead of a plain `<a>` for this internal billing route to avoid full page reload navigation.</violation>
</file>

<file name="apps/api/src/billing/billing-customer.ts">

<violation number="1" location="apps/api/src/billing/billing-customer.ts:25">
P1: Using a per-organization idempotency key with a variable `email` field can trigger Stripe idempotency errors on concurrent calls with different `customerEmail` values.</violation>
</file>

<file name="apps/api/src/admin-organizations/admin-billing.service.ts">

<violation number="1" location="apps/api/src/admin-organizations/admin-billing.service.ts:233">
P2: Missing audit log for the checkout-session path. When `'changed' in result` is true (subscription created immediately), the method returns without calling `writeBillingAudit`, so the admin action goes untracked. Consider writing the audit entry before the early return in this branch.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread apps/api/src/billing/billing-customer.ts Outdated
Comment thread apps/api/src/billing/billing-usage.ts Outdated
Comment thread apps/api/src/billing/billing-entitlements.service.ts Outdated
Comment thread apps/api/src/admin-organizations/admin-audit-log.interceptor.ts Outdated
Comment thread apps/api/src/billing/billing-webhook.service.ts Outdated
Comment thread apps/api/src/billing/billing-subscription-plans.ts
Comment thread apps/api/src/billing/billing-credits.types.ts Outdated
Comment thread apps/api/src/admin-organizations/admin-billing.service.ts Outdated
chore(integrations-catalog): refresh 2026-05-01 round 4
…ling

- Updated AdminBillingService to write an audit event when an admin sets a subscription.
- Enhanced billing webhook error handling to preserve processing errors.
- Added a new function to assert valid credit event types.
- Refactored usage event handling to ensure the newest event is used for each source resource.
- Improved the BackgroundCheckDetailsForm to use Link component for navigation.
- Minor adjustments to billing preferences schema and other related files for consistency.
[dev] [carhartlewis] lewis/comp-stripe-overhaul-fix
@vercel vercel Bot temporarily deployed to staging – portal May 1, 2026 21:30 Inactive
@carhartlewis carhartlewis merged commit 8c58ab9 into release May 1, 2026
14 checks passed
@claudfuen
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.42.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants