Skip to content

Conversation

BilalG1
Copy link
Collaborator

@BilalG1 BilalG1 commented Aug 21, 2025

https://www.loom.com/share/7f61024ffa354850a70779ac7a20c138?sid=b523394b-b243-4bd2-819c-e36ebab1ab92


Important

Introduce test mode for payment subscriptions, including database schema updates, new API routes, client-side handling, and comprehensive test coverage.

  • Database:
    • Add creationSource column to Subscription model in schema.prisma and migration.sql.
    • Enum SubscriptionCreationSource added with values PURCHASE_PAGE and TEST_MODE.
  • API:
    • New route test-mode-purchase-session in route.tsx for handling test mode purchases.
    • Modify purchase-session and validate-code routes to support test mode.
  • Client:
    • Update page-client.tsx to handle test mode bypass and display relevant UI elements.
    • Add handleBypass function to simulate test mode purchases.
  • Testing:
    • Add tests in purchase-session.test.ts and validate-code.test.ts for test mode scenarios.
  • Misc:
    • Update admin-interface.ts and admin-app.ts to include testModePurchase function.
    • Minor updates to tailwind.config.ts for animations.

This description was created by Ellipsis for fd52134. You can customize this summary. It will automatically update as commits are pushed.

Copy link

vercel bot commented Aug 21, 2025

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

Project Deployment Preview Comments Updated (UTC)
stack-backend Ready Ready Preview Comment Aug 25, 2025 5:34pm
stack-dashboard Ready Ready Preview Comment Aug 25, 2025 5:34pm
stack-demo Ready Ready Preview Comment Aug 25, 2025 5:34pm
stack-docs Ready Ready Preview Comment Aug 25, 2025 5:34pm

Copy link
Contributor

coderabbitai bot commented Aug 21, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch payments-test-mode

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR implements test mode functionality for the payments system, allowing developers and administrators to simulate payment flows without processing real transactions through Stripe. The implementation includes several key components:

Backend Infrastructure: A new database migration adds a SubscriptionCreationSource enum with PURCHASE_PAGE and TEST_MODE values, and makes the stripeSubscriptionId field nullable to support test subscriptions that don't have real Stripe subscription IDs. A new API route (/internal/payments/test-mode-purchase-session) handles test mode purchases by creating subscriptions directly in the database with calculated period dates, bypassing Stripe entirely.

Admin Interface: The StackAdminInterface gains a new testModePurchase method that allows admin users to simulate purchases using a price ID and validation code. This method is exposed through the admin app implementation with proper parameter mapping from camelCase to snake_case.

Dashboard UI: The purchase flow is enhanced with bypass functionality for project owners. When authenticated as a project owner, users see a "Test mode bypass" card that allows skipping payment processing. The purchase return page handles bypass scenarios by showing test mode success messages instead of validating Stripe payment intents.

Schema Updates: The offer schema now requires a customerType field (previously optional) to ensure proper categorization, and the default customer type in organization configs is changed from undefined to "user" for better data consistency.

UI Enhancements: A new fadeIn animation is added to Tailwind configuration to support smooth transitions in the payment interface, and JSON parsing is improved using a safer utility function for better error handling.

Testing: New E2E tests validate both the security aspects (tenancy validation) and functionality (subscription creation with item allocation) of the test mode feature.

Confidence score: 1/5

  • This PR has a critical database migration issue that will prevent deployment to production environments with existing subscription data
  • Score reflects a migration that adds a required column without a default value, which will cause immediate failure on non-empty tables
  • Pay close attention to the database migration file 20250821175509_test_mode_subscriptions/migration.sql and the new API route security implementation

17 files reviewed, 2 comments

Edit Code Review Bot Settings | Greptile

Copy link

recurseml bot commented Aug 21, 2025

Review by RecurseML

🔍 Review performed on c22bf3c..03c06a2

Severity Location Issue
Medium apps/e2e/tests/backend/endpoints/api/v1/payments/purchase-session.test.ts:219 Using camelCase for REST API parameter instead of required snake_case
Medium packages/stack-shared/src/interface/admin-interface.ts:502 REST API parameters not using snake_case convention
✅ Files analyzed, no issues (3)

apps/backend/src/app/api/latest/internal/payments/test-mode-purchase-session/route.tsx
apps/dashboard/src/app/(main)/purchase/[code]/page-client.tsx
apps/backend/src/app/api/latest/payments/purchases/validate-code/route.ts

⏭️ Files skipped (low suspicion) (12)

apps/backend/prisma/migrations/20250821175509_test_mode_subscriptions/migration.sql
apps/backend/prisma/schema.prisma
apps/backend/src/lib/stripe.tsx
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/payments/page-client.tsx
apps/dashboard/src/app/(main)/purchase/return/page-client.tsx
apps/dashboard/src/app/(main)/purchase/return/page.tsx
apps/dashboard/src/lib/utils.tsx
apps/dashboard/tailwind.config.ts
packages/stack-shared/src/config/schema.ts
packages/stack-shared/src/schema-fields.ts
packages/template/src/lib/stack-app/apps/implementations/admin-app-impl.ts
packages/template/src/lib/stack-app/apps/interfaces/admin-app.ts

Need help? Join our Discord

@BilalG1 BilalG1 assigned N2D4 and unassigned BilalG1 Aug 21, 2025
@N2D4 N2D4 assigned BilalG1 and unassigned N2D4 Aug 22, 2025
expect(response).toMatchInlineSnapshot(`
NiceResponse {
"status": 400,
"body": "Price not found on offer associated with this purchase code",
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure the error response shapes are consistent across endpoints. Here, the invalid price_id error returns a plain string while other errors return an object—standardizing this can improve client handling.

Suggested change
"body": "Price not found on offer associated with this purchase code",
"body": { "code": "PRICE_NOT_FOUND", "error": "Price not found on offer associated with this purchase code" },

@BilalG1 BilalG1 merged commit 68c66d5 into payments-ui-fixes Aug 25, 2025
20 checks passed
@BilalG1 BilalG1 deleted the payments-test-mode branch August 25, 2025 17:50
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.

2 participants