Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Other AI code review bot(s) detectedCodeRabbit 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 skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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.sqland the new API route security implementation
17 files reviewed, 2 comments
apps/backend/src/app/api/latest/internal/payments/test-mode-purchase-session/route.tsx
Outdated
Show resolved
Hide resolved
apps/backend/src/app/api/latest/internal/payments/test-mode-purchase-session/route.tsx
Outdated
Show resolved
Hide resolved
apps/e2e/tests/backend/endpoints/api/v1/payments/purchase-session.test.ts
Show resolved
Hide resolved
Review by RecurseML🔍 Review performed on c22bf3c..03c06a2
✅ Files analyzed, no issues (3)• ⏭️ Files skipped (low suspicion) (12)• |
apps/backend/src/app/api/latest/payments/purchases/validate-code/route.ts
Show resolved
Hide resolved
apps/e2e/tests/backend/endpoints/api/v1/payments/purchase-session.test.ts
Show resolved
Hide resolved
| expect(response).toMatchInlineSnapshot(` | ||
| NiceResponse { | ||
| "status": 400, | ||
| "body": "Price not found on offer associated with this purchase code", |
There was a problem hiding this comment.
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.
| "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" }, |
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.
creationSourcecolumn toSubscriptionmodel inschema.prismaandmigration.sql.SubscriptionCreationSourceadded with valuesPURCHASE_PAGEandTEST_MODE.test-mode-purchase-sessioninroute.tsxfor handling test mode purchases.purchase-sessionandvalidate-coderoutes to support test mode.page-client.tsxto handle test mode bypass and display relevant UI elements.handleBypassfunction to simulate test mode purchases.purchase-session.test.tsandvalidate-code.test.tsfor test mode scenarios.admin-interface.tsandadmin-app.tsto includetestModePurchasefunction.tailwind.config.tsfor animations.This description was created by
for fd52134. You can customize this summary. It will automatically update as commits are pushed.