-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Support Stripe sandbox for app testing #2784
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
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds a Stripe "mode" concept (test/sandbox/live) across webhook routing, client creation, handlers, utilities, scripts, and call sites; introduces a Changes
Sequence Diagram(s)sequenceDiagram
participant Stripe as Stripe (external)
participant Sandbox as /webhook/sandbox
participant Shared as /webhook (shared POST)
participant Route as Route (mode resolver)
participant Handlers as Webhook Handlers
rect rgb(245,250,255)
Note right of Sandbox: lightweight re-export → Shared.POST
end
Stripe->>Sandbox: POST /webhook/sandbox (payload + sig)
Sandbox->>Shared: forward POST
Shared->>Route: parse pathname → determine mode ("test"/"sandbox"/"live")
Route->>Route: select webhookSecret for mode
Route->>Route: verify signature with webhookSecret
alt signature valid
Route->>Handlers: invoke handler(event, mode)
Handlers-->>Route: returns success
Route-->>Stripe: 200 OK
else invalid
Route-->>Stripe: 400/401
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (1)
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. Comment |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/web/app/(ee)/api/stripe/integration/webhook/sandbox/route.ts
(1 hunks)packages/stripe-app/stripe-app.json
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/stripe-app/stripe-app.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (1)
apps/web/app/(ee)/api/stripe/integration/webhook/sandbox/route.ts (1)
16-16
: LGTM!The re-export of the POST handler is clean and enables code reuse for the sandbox endpoint.
…g. Updated webhook functions and utility methods to accept mode parameter, ensuring consistent behavior across test, sandbox, and live environments.
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.
Actionable comments posted: 0
♻️ Duplicate comments (5)
apps/web/lib/firstpromoter/update-stripe-customers.ts (1)
11-13
: Same conditional pattern as in create-discount.ts.See the review comment on
apps/web/lib/actions/partners/create-discount.ts
(lines 21-23) regarding theVERCEL_ENV
conditional pattern.apps/web/lib/tolt/update-stripe-customers.ts (1)
11-13
: Same conditional pattern as in create-discount.ts.See the review comment on
apps/web/lib/actions/partners/create-discount.ts
(lines 21-23) regarding theVERCEL_ENV
conditional pattern.apps/web/lib/stripe/create-stripe-discount-code.ts (1)
5-7
: Same conditional pattern as in create-discount.ts.See the review comment on
apps/web/lib/actions/partners/create-discount.ts
(lines 21-23) regarding theVERCEL_ENV
conditional pattern.apps/web/lib/partnerstack/update-stripe-customers.ts (1)
13-15
: Same conditional pattern as in create-discount.ts.See the review comment on
apps/web/lib/actions/partners/create-discount.ts
(lines 21-23) regarding theVERCEL_ENV
conditional pattern.apps/web/lib/stripe/disable-stripe-discount-code.ts (1)
3-5
: Same conditional pattern as in create-discount.ts.See the review comment on
apps/web/lib/actions/partners/create-discount.ts
(lines 21-23) regarding theVERCEL_ENV
conditional pattern.
🧹 Nitpick comments (1)
apps/web/lib/actions/partners/create-discount.ts (1)
21-23
: Clarify the VERCEL_ENV conditional pattern.The conditional spread
...(process.env.VERCEL_ENV && { mode: "live" })
meansmode
is only explicitly set whenVERCEL_ENV
is present. WhenVERCEL_ENV
is not set (e.g., local development),mode
is omitted entirely, relying onstripeAppClient
's default behavior.If
stripeAppClient
already defaults to"live"
whenmode
is omitted, this conditional adds complexity without changing behavior. If the intent is to use a different mode in local development (e.g.,"test"
), consider making this explicit.Verify the intent and consider one of these alternatives:
Option 1: If the default is always "live", remove the conditional:
-const stripe = stripeAppClient({ - ...(process.env.VERCEL_ENV && { mode: "live" }), -}); +const stripe = stripeAppClient({ mode: "live" });Option 2: If local dev should use "test" mode explicitly:
-const stripe = stripeAppClient({ - ...(process.env.VERCEL_ENV && { mode: "live" }), -}); +const stripe = stripeAppClient({ + mode: process.env.VERCEL_ENV ? "live" : "test", +});
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
apps/web/app/(ee)/api/stripe/integration/webhook/charge-refunded.ts
(1 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts
(7 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts
(3 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/route.ts
(3 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/utils/get-connected-customer.ts
(1 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/utils/get-promotion-code.ts
(1 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/utils/get-subscription-product-id.ts
(1 hunks)apps/web/lib/actions/partners/create-discount.ts
(1 hunks)apps/web/lib/firstpromoter/update-stripe-customers.ts
(1 hunks)apps/web/lib/partnerstack/update-stripe-customers.ts
(1 hunks)apps/web/lib/stripe/create-stripe-discount-code.ts
(1 hunks)apps/web/lib/stripe/disable-stripe-discount-code.ts
(1 hunks)apps/web/lib/stripe/index.ts
(2 hunks)apps/web/lib/tolt/update-stripe-customers.ts
(1 hunks)apps/web/lib/types.ts
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (8)
apps/web/lib/stripe/index.ts (1)
apps/web/lib/types.ts (1)
StripeMode
(652-652)
apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts (1)
apps/web/lib/types.ts (1)
StripeMode
(652-652)
apps/web/app/(ee)/api/stripe/integration/webhook/utils/get-connected-customer.ts (2)
apps/web/lib/types.ts (1)
StripeMode
(652-652)apps/web/lib/stripe/index.ts (1)
stripeAppClient
(13-35)
apps/web/app/(ee)/api/stripe/integration/webhook/utils/get-subscription-product-id.ts (2)
apps/web/lib/types.ts (1)
StripeMode
(652-652)apps/web/lib/stripe/index.ts (1)
stripeAppClient
(13-35)
apps/web/app/(ee)/api/stripe/integration/webhook/charge-refunded.ts (2)
apps/web/lib/types.ts (1)
StripeMode
(652-652)apps/web/lib/stripe/index.ts (2)
stripe
(4-10)stripeAppClient
(13-35)
apps/web/app/(ee)/api/stripe/integration/webhook/utils/get-promotion-code.ts (2)
apps/web/lib/types.ts (1)
StripeMode
(652-652)apps/web/lib/stripe/index.ts (1)
stripeAppClient
(13-35)
apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts (3)
packages/ui/src/icons/payout-platforms/stripe.tsx (1)
Stripe
(3-19)apps/web/lib/types.ts (1)
StripeMode
(652-652)apps/web/app/(ee)/api/stripe/integration/webhook/utils/get-promotion-code.ts (1)
getPromotionCode
(4-28)
apps/web/app/(ee)/api/stripe/integration/webhook/route.ts (4)
apps/web/lib/types.ts (1)
StripeMode
(652-652)apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts (1)
checkoutSessionCompleted
(38-510)apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts (1)
invoicePaid
(19-265)apps/web/app/(ee)/api/stripe/integration/webhook/charge-refunded.ts (1)
chargeRefunded
(8-117)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (12)
apps/web/lib/types.ts (1)
651-652
: LGTM! Clean type definition for mode-based Stripe configuration.The
StripeMode
type clearly defines the three supported Stripe environments. This enables the mode-based configuration pattern introduced across webhook handlers and client initialization.apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts (1)
7-7
: AllinvoicePaid
calls updated to passmode
. The breaking-change signature is fully covered byroute.ts
.apps/web/app/(ee)/api/stripe/integration/webhook/charge-refunded.ts (1)
3-3
: LGTM! Mode parameter correctly threaded through.The import, function signature update, and propagation to
stripeAppClient
are consistent with the mode-based refactor.Also applies to: 8-8, 13-13
apps/web/app/(ee)/api/stripe/integration/webhook/utils/get-subscription-product-id.ts (1)
2-2
: LGTM! Mode parameter correctly integrated.The function signature update and mode propagation to
stripeAppClient
align with the mode-based approach.Also applies to: 7-7, 11-11, 19-19
apps/web/app/(ee)/api/stripe/integration/webhook/utils/get-connected-customer.ts (1)
2-2
: LGTM! Mode parameter correctly integrated.The function signature and mode propagation are consistent with the refactor.
Also applies to: 7-7, 11-11, 19-19
apps/web/app/(ee)/api/stripe/integration/webhook/utils/get-promotion-code.ts (1)
2-2
: LGTM! Mode parameter correctly integrated.The function signature update and inline mode propagation are consistent with the refactor.
Also applies to: 7-7, 11-11, 18-23
apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts (3)
15-20
: LGTM! Function signature correctly updated.The import and function signature updates are consistent with the mode-based refactor.
Also applies to: 38-41
191-191
: LGTM! Mode correctly propagated to helper functions.The mode parameter is correctly passed to
attributeViaPromoCode
andgetConnectedCustomer
calls.Also applies to: 218-218, 235-235
416-416
: LGTM! Mode correctly propagated in program flow.The mode parameter is correctly passed to
getSubscriptionProductId
, theattributeViaPromoCode
helper function signature is updated, andgetPromotionCode
receives mode.Also applies to: 515-520, 527-527
apps/web/app/(ee)/api/stripe/integration/webhook/route.ts (2)
2-2
: LGTM! Path-based mode resolution is correctly implemented.The logic to determine mode from the request pathname and select the appropriate webhook secret is sound and follows a clear pattern.
Ensure that webhook secrets are configured for all modes in your deployment environment:
STRIPE_APP_WEBHOOK_SECRET_TEST
for test modeSTRIPE_APP_WEBHOOK_SECRET_SANDBOX
for sandbox modeSTRIPE_APP_WEBHOOK_SECRET
for live modeYou can verify this with the script provided in the review for
apps/web/lib/stripe/index.ts
.Also applies to: 33-45
80-80
: LGTM! Mode correctly propagated to webhook handlers.The mode parameter is correctly passed to the three handlers that require it:
checkoutSessionCompleted
,invoicePaid
, andchargeRefunded
. Other handlers that don't use Stripe app client calls correctly omit the parameter.Also applies to: 83-83, 86-86
apps/web/lib/stripe/index.ts (1)
13-35
: Stripe secret keys are not configured – stripeAppClient will always throwNone of STRIPE_APP_SECRET_KEY_TEST, STRIPE_APP_SECRET_KEY_SANDBOX, or STRIPE_APP_SECRET_KEY is set in your environment; define these variables in your test, sandbox, and live deployments to prevent runtime errors.
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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/scripts/stripe/backfill-stripe-webhook-events.ts (1)
29-38
: Make Stripe mode configurable for operational flexibility.Hardcoding
mode: "test"
in a backfill script is risky because:
- Backfill scripts typically operate on production data to fix data issues
- The script queries the production database (lines 8-20), but searches test Stripe customers
- This creates a mismatch: production DB records will never find corresponding test Stripe customers
- If someone replaces the placeholder
stripeAccountId
with a real production account ID, the script will fail silently or produce incorrect resultsMake the mode configurable via an environment variable or command-line argument to match the target environment:
+const stripeMode = (process.env.STRIPE_MODE || "live") as "test" | "sandbox" | "live"; + async function main() { const customers = await prisma.customer.findMany({ // ... }); await Promise.allSettled( customers.map(async (customer) => { if (!customer.email) return; if (customer.stripeCustomerId) return; const stripeCustomer = await stripeAppClient({ - mode: "test", + mode: stripeMode, }).customers.list(
🧹 Nitpick comments (2)
apps/web/scripts/stripe/search-customers.ts (1)
7-9
: LGTM! Consider making the mode configurable for flexibility.The change to
mode: "test"
correctly aligns with the new mode-based Stripe client configuration. For a development script, hardcoding "test" mode is reasonable.To improve flexibility when testing across different Stripe environments (test/sandbox/live), consider making the mode configurable via an environment variable:
+const mode = (process.env.STRIPE_MODE as "test" | "sandbox" | "live") || "test"; + const stripeCustomers = await stripeAppClient({ - mode: "test", + mode, }).customers.search(apps/web/scripts/stripe/get-connected-customer.ts (1)
5-9
:"test"
is valid—consider makingmode
configurable via an environment variable or CLI argument (optional).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
apps/web/app/(ee)/api/stripe/integration/webhook/sandbox/route.ts
(1 hunks)apps/web/scripts/stripe/backfill-stripe-webhook-events.ts
(1 hunks)apps/web/scripts/stripe/get-connected-customer.ts
(1 hunks)apps/web/scripts/stripe/search-customers.ts
(1 hunks)apps/web/scripts/stripe/update-stripe-customers.ts
(1 hunks)packages/stripe-app/stripe-app.json
(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/web/app/(ee)/api/stripe/integration/webhook/sandbox/route.ts
🔇 Additional comments (1)
apps/web/scripts/stripe/update-stripe-customers.ts (1)
34-43
: Outdated review – ignore suggestion
The snippet in apps/web/scripts/stripe/update-stripe-customers.ts no longer matches (it useslivemode: true
while stripeAppClient acceptsmode
), so the original recommendation doesn’t apply.Likely an incorrect or invalid review comment.
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/web/lib/stripe/index.ts
(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/web/lib/stripe/index.ts (1)
apps/web/lib/types.ts (1)
StripeMode
(652-652)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
@coderabbitai full review |
✅ Actions performedFull review triggered. |
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/app/(ee)/api/stripe/integration/webhook/route.ts (1)
33-51
: Improve error diagnostics for missing webhook secrets.When an environment variable like
STRIPE_APP_WEBHOOK_SECRET_SANDBOX
is not configured, the current error response "Invalid request" doesn't indicate which secret is missing, making production debugging difficult.Consider logging the specific mode or missing secret:
if (!sig || !webhookSecret) { + console.error(`Missing webhook configuration for mode: ${mode}`); return new Response("Invalid request", { status: 400, }); }
Additionally, you might extract the mode detection logic into a helper function for better testability:
function detectWebhookMode(pathname: string): { mode: StripeMode; webhookSecret: string | undefined } { if (pathname.endsWith("/test")) { return { mode: "test", webhookSecret: process.env.STRIPE_APP_WEBHOOK_SECRET_TEST }; } else if (pathname.endsWith("/sandbox")) { return { mode: "sandbox", webhookSecret: process.env.STRIPE_APP_WEBHOOK_SECRET_SANDBOX }; } else { return { mode: "live", webhookSecret: process.env.STRIPE_APP_WEBHOOK_SECRET }; } }
♻️ Duplicate comments (2)
packages/stripe-app/stripe-app.json (1)
60-60
:connect_permissions
should be an array, notnull
.Stripe's manifest schema requires
connect_permissions
to be an array. Usingnull
will cause validation failures when uploading the app configuration.Apply this diff:
- "connect_permissions": null, + "connect_permissions": [],Alternatively, remove the field entirely if no permissions are needed.
apps/web/lib/stripe/index.ts (1)
22-22
: Add validation for missing environment variables.The non-null assertion is unsafe. If the environment variable for the selected mode is undefined, the Stripe client will be constructed with
undefined
, causing runtime errors during API calls rather than failing fast with a clear error message.Add validation before constructing the Stripe client:
export const stripeAppClient = ({ mode }: { mode?: StripeMode }) => { const appSecretKey = secretMap[mode ?? "test"]; + if (!appSecretKey) { + throw new Error( + `Missing Stripe app secret key for mode "${mode ?? "test"}". Please set the corresponding environment variable.` + ); + } + - return new Stripe(appSecretKey!, { + return new Stripe(appSecretKey, { apiVersion: "2025-05-28.basil", appInfo: { name: "Dub.co", version: "0.1.0", }, }); };
🧹 Nitpick comments (2)
apps/web/lib/stripe/index.ts (1)
20-20
: Reconsider the default mode selection.Defaulting to
"test"
mode when no mode is specified could lead to unexpected behavior in production if callers forget to pass the mode explicitly. Consider either:
- Making
mode
required (remove the optional?
and default), forcing callers to be explicit- Defaulting to
"live"
mode for production safety- Using an environment variable to determine the default mode
For example, to make the mode required:
-export const stripeAppClient = ({ mode }: { mode?: StripeMode }) => { +export const stripeAppClient = ({ mode }: { mode: StripeMode }) => { - const appSecretKey = secretMap[mode ?? "test"]; + const appSecretKey = secretMap[mode];Or to use an environment-based default:
export const stripeAppClient = ({ mode }: { mode?: StripeMode }) => { - const appSecretKey = secretMap[mode ?? "test"]; + const defaultMode = process.env.NODE_ENV === "production" ? "live" : "test"; + const appSecretKey = secretMap[mode ?? defaultMode];apps/web/app/(ee)/api/stripe/integration/webhook/route.ts (1)
32-32
: Update comment to mention sandbox route.The comment references the test route but should also mention the sandbox route for consistency with the new sandbox support.
- // @see https://github.com/dubinc/dub/blob/main/apps/web/app/(ee)/api/stripe/integration/webhook/test/route.ts + // @see https://github.com/dubinc/dub/blob/main/apps/web/app/(ee)/api/stripe/integration/webhook/test/route.ts + // @see https://github.com/dubinc/dub/blob/main/apps/web/app/(ee)/api/stripe/integration/webhook/sandbox/route.ts
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (22)
apps/web/app/(ee)/api/stripe/integration/webhook/charge-refunded.ts
(1 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts
(7 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts
(3 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/route.ts
(3 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/sandbox/route.ts
(1 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/utils/get-connected-customer.ts
(1 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/utils/get-promotion-code.ts
(1 hunks)apps/web/app/(ee)/api/stripe/integration/webhook/utils/get-subscription-product-id.ts
(1 hunks)apps/web/lib/actions/partners/create-discount.ts
(1 hunks)apps/web/lib/firstpromoter/update-stripe-customers.ts
(1 hunks)apps/web/lib/partnerstack/update-stripe-customers.ts
(1 hunks)apps/web/lib/stripe/create-stripe-discount-code.ts
(1 hunks)apps/web/lib/stripe/disable-stripe-discount-code.ts
(1 hunks)apps/web/lib/stripe/index.ts
(2 hunks)apps/web/lib/tolt/update-stripe-customers.ts
(1 hunks)apps/web/lib/types.ts
(1 hunks)apps/web/scripts/stripe/backfill-stripe-webhook-events.ts
(1 hunks)apps/web/scripts/stripe/get-connected-customer.ts
(1 hunks)apps/web/scripts/stripe/search-customers.ts
(1 hunks)apps/web/scripts/stripe/update-stripe-customers.ts
(1 hunks)packages/stripe-app/README.md
(1 hunks)packages/stripe-app/stripe-app.json
(3 hunks)
🔇 Additional comments (17)
apps/web/scripts/stripe/backfill-stripe-webhook-events.ts (1)
29-31
: LGTM! Migration to mode-based configuration.The change from
livemode: false
tomode: "test"
is consistent with the broader migration to theStripeMode
type. Using "test" mode is appropriate for this backfill script.apps/web/app/(ee)/api/stripe/integration/webhook/sandbox/route.ts (1)
1-16
: LGTM! Route path comment has been corrected.The previously flagged issue regarding the incorrect route path in the comment has been addressed. The comment at Line 2 now correctly references
/api/stripe/integration/webhook/sandbox
, matching the actual route. The re-export pattern is clean and aligns with the mode-based webhook routing architecture.packages/stripe-app/stripe-app.json (1)
3-3
: LGTM! Version and sandbox support additions.The version bump to 0.0.18 and the addition of
sandbox_install_compatible: true
anddistribution_type: "public"
align with the PR's objective to support Stripe sandbox for app testing.Also applies to: 87-88
apps/web/lib/actions/partners/create-discount.ts (1)
21-23
: LGTM! Consistent migration to mode-based configuration.The change from
livemode: true
tomode: "live"
is consistent with the StripeMode migration. Using "live" mode whenVERCEL_ENV
is set is appropriate for production deployments.apps/web/lib/partnerstack/update-stripe-customers.ts (1)
13-15
: LGTM! Consistent migration to mode-based configuration.The change from
livemode: true
tomode: "live"
aligns with the broader StripeMode migration and is appropriate for production customer data handling.apps/web/lib/tolt/update-stripe-customers.ts (1)
11-13
: LGTM! Consistent migration to mode-based configuration.The change from
livemode: true
tomode: "live"
is consistent with the StripeMode migration and appropriate for production customer operations.apps/web/lib/stripe/create-stripe-discount-code.ts (1)
5-7
: LGTM! Consistent migration to mode-based configuration.The change from
livemode: true
tomode: "live"
aligns with the StripeMode migration and is appropriate for creating discount codes in production environments.apps/web/scripts/stripe/search-customers.ts (1)
7-9
: LGTM! Appropriate use of test mode for scripts.The change from
livemode: true
tomode: "test"
is consistent with the StripeMode migration. Using "test" mode is appropriate for ad-hoc customer search scripts, preventing unintended queries against live production data.apps/web/scripts/stripe/update-stripe-customers.ts (1)
35-35
: Verify the mode change from live to test.The script previously used
livemode: true
(production mode) but now usesmode: "test"
. This changes the script to query test Stripe data instead of live production data. Ensure this is intentional, as it will affect which Stripe customers are retrieved and updated.If this script is meant for production use, consider using
mode: "live"
or making the mode configurable via an environment variable.apps/web/lib/types.ts (1)
655-655
: LGTM!The
StripeMode
type definition is clean and clearly defines the three supported Stripe modes.apps/web/scripts/stripe/get-connected-customer.ts (1)
6-6
: LGTM!The change from
livemode: false
tomode: "test"
is consistent with the previous behavior and aligns with the script's testing purpose (note the placeholder IDs).apps/web/lib/firstpromoter/update-stripe-customers.ts (1)
12-12
: LGTM!The change maintains the same production behavior by conditionally using
mode: "live"
whenVERCEL_ENV
is set, which is semantically equivalent to the previouslivemode: true
.apps/web/lib/stripe/disable-stripe-discount-code.ts (1)
4-4
: LGTM!Consistent with the mode-based migration pattern used across the codebase, maintaining production behavior when
VERCEL_ENV
is set.apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts (1)
7-7
: LGTM!The refactoring properly introduces the
mode
parameter, imports theStripeMode
type, and propagates the mode through the call chain togetConnectedCustomer
. The changes are clean and consistent with the mode-based migration.Also applies to: 19-19, 37-37
apps/web/app/(ee)/api/stripe/integration/webhook/charge-refunded.ts (1)
3-3
: LGTM!The refactoring follows the same pattern as other webhook handlers, properly introducing the
mode
parameter and using it in thestripeAppClient
initialization.Also applies to: 8-8, 13-13
apps/web/app/(ee)/api/stripe/integration/webhook/route.ts (2)
2-2
: LGTM!Type import is clean and necessary for the mode-aware webhook routing.
72-97
: No additional handlers require mode. Checked all other webhook handlers; none perform Stripe API calls needing the mode context.
/bug0 run |
1 similar comment
/bug0 run |
Summary by CodeRabbit
New Features
Chores
Documentation