Skip to content

Conversation

@joeauyeung
Copy link
Contributor

@joeauyeung joeauyeung commented Nov 17, 2025

What does this PR do?

Adds support for configurable trial periods on organization subscriptions through the STRIPE_ORG_TRIAL_DAYS environment variable. When set, new organization subscriptions will include a trial period before billing begins.

Additionally adds a warning message to all steps of the organization creation wizard informing users about the workspace structure implications of using the Organizations trial.

https://www.loom.com/share/3b8c2d2675f6459f827f7890fcae237d

Link to Devin run: https://app.devin.ai/sessions/80afb60fc6bf469985140065e7b5c6f4
Requested by: [email protected] (@joeauyeung)

Changes Made

1. Trial Days Implementation

  • Added STRIPE_ORG_TRIAL_DAYS environment variable to .env.example
  • Implemented trial days logic in OrganizationPaymentService.ts (organization onboarding flow)
  • Implemented trial days logic in payments.ts (purchaseTeamOrOrgSubscription function)
  • Added environment variable to turbo.json for build configuration

2. Organization Wizard Warning

  • Extended WizardLayout component with optional footer prop to support content below form cards
  • Added warning to all 6 steps of organization creation wizard:
    • Step 1: create-new-view.tsx
    • Step 1 (resume): resume-view.tsx
    • Step 2: about-view.tsx
    • Step 3: add-teams-view.tsx
    • Step 4: onboard-members-view.tsx
    • Step 5: payment-status-view.tsx
  • Added translation string organization_trial_workspace_warning to common.json

3. Code Quality

  • Fixed pre-existing linting issues in CreateANewOrganizationForm.tsx (regex escaping, removed unnecessary try-catch)
  • Added ESLint disable comments for turbo/no-undeclared-env-vars warnings

⚠️ Critical Issues for Review

1. Environment Variable Naming Inconsistency 🚨

The diff shows TWO different environment variable names:

  • STRIPE_ORG_TRIAL_DAYS used in OrganizationPaymentService.ts and payments.ts
  • ORGANIZATION_TRIAL_DAYS declared in turbo.json (line 347)

This needs to be fixed before merging! The code will not work correctly with mismatched env var names.

2. Shared Component Change

Modified WizardLayout to add optional footer prop. This is a shared component but the change is opt-in (only used when footer prop is provided). Please verify this doesn't break other wizards.

3. Two Implementation Paths

Trial days logic is implemented in both:

  • OrganizationPaymentService.ts (lines 281-290)
  • payments.ts (lines 174-177, 205)

Please verify both implementations are necessary and correct for different flows.

How should this be tested?

Environment Variables:

# Add to .env file
STRIPE_ORG_TRIAL_DAYS=14  # or any positive integer
# Ensure these are also set: STRIPE_ORG_PRODUCT_ID, STRIPE_ORG_MONTHLY_PRICE_ID

Test Steps:

  1. Navigate to /settings/organizations/new
  2. Verify the warning message appears below the form card on ALL wizard steps (steps 1-5)
  3. Complete the organization setup flow with billing enabled
  4. Verify the Stripe checkout session includes the trial period
  5. Check Stripe dashboard to confirm the subscription has the correct trial period

Expected Behavior:

  • If STRIPE_ORG_TRIAL_DAYS is set and > 0: Stripe checkout should include trial_period_days
  • If STRIPE_ORG_TRIAL_DAYS is not set or ≤ 0: No trial period should be added
  • Warning message should appear on all 6 wizard steps

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • CRITICAL: Fix environment variable naming inconsistency (STRIPE_ORG_TRIAL_DAYS vs ORGANIZATION_TRIAL_DAYS)
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

Checklist

  • Verify environment variable naming is consistent across all files
  • Confirm both trial days implementations (OrganizationPaymentService + payments.ts) are necessary
  • Test Stripe checkout flow with trial days enabled
  • Verify warning appears correctly on all 6 wizard steps
  • Confirm WizardLayout footer prop doesn't break other wizards using WizardLayout
  • Verify the warning message is appropriate for all wizard steps (not just step 1)
  • Check that trial days logic handles edge cases (NaN, negative numbers, non-numeric strings)

devin-ai-integration bot and others added 3 commits November 17, 2025 15:39
- Add ORGANIZATION_TRIAL_DAYS environment variable for configurable trial periods
- Implement trial days in Stripe checkout session (only when env var is set)
- Add warning message to organization setup page about workspace structure
- Add translation string for organization trial workspace warning
- Add ORGANIZATION_TRIAL_DAYS to turbo.json env vars
- Fix pre-existing linting warnings in CreateANewOrganizationForm.tsx
- Add ESLint disable comments for turbo/no-undeclared-env-vars warnings

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions github-actions bot added the ❗️ .env changes contains changes to env variables label Nov 17, 2025
@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Nov 17, 2025
- Add optional footer prop to WizardLayout component
- Use footer prop in create-new-view.tsx to render warning at spot 3
- Remove warning from inside CreateANewOrganizationForm component
- Warning now appears below the form card as requested

Co-Authored-By: [email protected] <[email protected]>
@vercel
Copy link

vercel bot commented Nov 17, 2025

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

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
cal Ignored Ignored Nov 20, 2025 4:01pm
cal-eu Ignored Ignored Nov 20, 2025 4:01pm

@devin-ai-integration devin-ai-integration bot changed the title feat: Add trial days to organization subscriptions and workspace warning feat: Add configurable trial days to organization subscriptions Nov 17, 2025
- Add warning footer to step 2 (about-view.tsx)
- Add warning footer to step 3 (add-teams-view.tsx)
- Add warning footer to step 4 (onboard-members-view.tsx)
- Add warning footer to step 5 (payment-status-view.tsx)
- Add warning footer to resume-view.tsx (step 1 resume page)
- Warning now appears on all steps of the organization creation wizard

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration devin-ai-integration bot changed the title feat: Add configurable trial days to organization subscriptions feat: Add configurable trial days to org subscriptions + wizard warning Nov 17, 2025
devin-ai-integration bot and others added 2 commits November 17, 2025 18:51
- Changed ORGANIZATION_TRIAL_DAYS to STRIPE_ORG_TRIAL_DAYS in turbo.json
- This matches the actual usage in OrganizationPaymentService.ts and payments.ts
- Ensures the environment variable is properly recognized by the build system

Co-Authored-By: [email protected] <[email protected]>
- Create OrganizationWizardLayout component that wraps WizardLayout
- Centralizes the trial warning footer logic in one place
- Update all 6 wizard pages to use the shared component:
  - create-new-view.tsx
  - about-view.tsx
  - add-teams-view.tsx
  - onboard-members-view.tsx
  - payment-status-view.tsx
  - resume-view.tsx
- Remove duplicate useLocale/Alert imports and footer props from pages
- Simplifies maintenance by having warning logic in a single location

Co-Authored-By: [email protected] <[email protected]>
@joeauyeung joeauyeung marked this pull request as ready for review November 17, 2025 23:31
@joeauyeung joeauyeung requested review from a team as code owners November 17, 2025 23:31
@graphite-app graphite-app bot requested a review from a team November 17, 2025 23:32
Copy link
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.

1 issue found across 14 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/features/ee/teams/lib/payments.ts">

<violation number="1" location="packages/features/ee/teams/lib/payments.ts:174">
The parsing logic for `STRIPE_ORG_TRIAL_DAYS` is inconsistent and less safe in `payments.ts` compared to `OrganizationPaymentService.ts`. The implementation in `payments.ts` lacks validation for positive integers and could pass invalid data (e.g., negative numbers) to the Stripe API.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

Copy link
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

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

One small bug caught by Cubic.

@github-actions github-actions bot marked this pull request as draft November 18, 2025 05:40
Copy link
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.

1 issue found across 15 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/lib/constants.ts">

<violation number="1" location="packages/lib/constants.ts:258">
Negative STRIPE_ORG_TRIAL_DAYS values remain truthy and are forwarded as `trial_period_days`, causing Stripe to reject the checkout; clamp the value to a positive integer before exporting it.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

@github-actions
Copy link
Contributor

github-actions bot commented Nov 18, 2025

E2E results are ready!

hariombalhara
hariombalhara previously approved these changes Nov 19, 2025
@joeauyeung joeauyeung enabled auto-merge (squash) November 19, 2025 18:51
Copy link
Contributor

@Udit-takkar Udit-takkar left a comment

Choose a reason for hiding this comment

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

LGTM.

Should we add some tests later?

Copy link
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.

No issues found across 15 files

@joeauyeung joeauyeung disabled auto-merge November 20, 2025 16:45
@joeauyeung joeauyeung enabled auto-merge (squash) November 20, 2025 16:45
@joeauyeung joeauyeung merged commit dc3df12 into main Nov 20, 2025
40 checks passed
@joeauyeung joeauyeung deleted the devin/1763390447-add-org-trial-days branch November 20, 2025 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ❗️ .env changes contains changes to env variables ready-for-e2e size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants