-
Notifications
You must be signed in to change notification settings - Fork 453
Payments test mode #858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Payments test mode #858
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.
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
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.
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.
"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.
creationSource
column toSubscription
model inschema.prisma
andmigration.sql
.SubscriptionCreationSource
added with valuesPURCHASE_PAGE
andTEST_MODE
.test-mode-purchase-session
inroute.tsx
for handling test mode purchases.purchase-session
andvalidate-code
routes to support test mode.page-client.tsx
to handle test mode bypass and display relevant UI elements.handleBypass
function to simulate test mode purchases.purchase-session.test.ts
andvalidate-code.test.ts
for test mode scenarios.admin-interface.ts
andadmin-app.ts
to includetestModePurchase
function.tailwind.config.ts
for animations.This description was created by
for fd52134. You can customize this summary. It will automatically update as commits are pushed.