Skip to content

Conversation

@ashleyyli
Copy link
Contributor

@ashleyyli ashleyyli commented Nov 4, 2025

Switch to enable ACH for Stripe link (currently disabled)

Addresses #377

Screenshot 2025-11-04 at 17 22 23

Summary by CodeRabbit

  • New Features

    • Added an "Enable ACH Payment (upcoming)" toggle to the invoice link creation form. It defaults to off, is rendered disabled, and will display "Feature not yet available" if users attempt to enable it. The control prepares the UI for future ACH payment support and preserves current invoice link behavior.
  • Tests

    • Updated tests to include the new toggle in form payloads.

@ashleyyli ashleyyli requested a review from devksingh4 November 4, 2025 23:22
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 4, 2025

Walkthrough

Added a new boolean achPaymentsEnabled to the Stripe invoice link POST schema/type, wired into the CreateLink form as a disabled Switch (initially false) with validation that forbids enabling; test updated to include achPaymentsEnabled: false in the createLink payload.

Changes

Cohort / File(s) Summary
Stripe Type System
src/common/types/stripe.ts
Added optional achPaymentsEnabled: boolean to invoiceLinkPostRequestSchema, updating the inferred PostInvoiceLinkRequest type.
Invoice Link Creation UI
src/ui/pages/stripe/CreateLink.tsx
Added achPaymentsEnabled form field (initial false), imported/rendered a disabled Switch labeled "Enable ACH Payment (upcoming)", and added validation returning "Feature not yet available" when true.
CreateLink Tests
src/ui/pages/stripe/CreateLink.test.tsx
Updated test payload to include achPaymentsEnabled: false when asserting the createLink call; test flow and assertions otherwise unchanged.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant UI as CreateLink Component
  participant Validator
  participant API as createLink

  User->>UI: Open Create Link form
  Note right of UI `#eef2ff`: achPaymentsEnabled default = false\nSwitch rendered disabled
  User->>UI: (attempt to) toggle Switch
  UI-->>User: Switch is disabled (no state change)

  UI->>Validator: validate form (incl. achPaymentsEnabled=false)
  Validator-->>UI: validation OK
  UI->>API: submit payload { ..., achPaymentsEnabled: false }
  API-->>UI: success response
  UI-->>User: show success
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Check schema optional/default behavior in src/common/types/stripe.ts.
  • Verify Switch disabled prop, form wiring, and validation message in src/ui/pages/stripe/CreateLink.tsx.
  • Ensure tests in src/ui/pages/stripe/CreateLink.test.tsx match the expected payload shape.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add Stripe links ACH option' directly and specifically describes the main change: adding an ACH payment option to Stripe links via a form field.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-ach-option

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

💰 Infracost report

Monthly estimate generated

This comment will be updated when code changes.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 922d017 and bca6cae.

📒 Files selected for processing (2)
  • src/common/types/stripe.ts (2 hunks)
  • src/ui/pages/stripe/CreateLink.tsx (4 hunks)
🧰 Additional context used
🪛 ESLint
src/common/types/stripe.ts

[error] 13-13: Insert ,

(prettier/prettier)


[error] 37-37: Insert

(prettier/prettier)

⏰ 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). (2)
  • GitHub Check: Run Unit Tests
  • GitHub Check: Build Application
🔇 Additional comments (4)
src/ui/pages/stripe/CreateLink.tsx (4)

9-9: LGTM: Switch import added correctly.

The Switch component import is properly added to support the new ACH payment toggle.


46-46: LGTM: Form state initialized correctly.

The achPaymentsEnabled field is correctly initialized to false, which aligns with the disabled state of the UI Switch.


57-58: Good defensive validation for upcoming feature.

The validation logic prevents form submission if achPaymentsEnabled is somehow set to true, which is good defensive coding even though the Switch is currently disabled. This ensures the feature can't be accidentally enabled through browser dev tools or other means.


117-124: LGTM: UI clearly indicates upcoming feature.

The disabled Switch with the "(upcoming)" label and descriptive text clearly communicates that this is a future feature. The component is properly bound to the form state using getInputProps.


export const invoiceLinkPostRequestSchema = z.object({
invoiceId: z.string().min(1),
invoiceAmountUsd: z.number().min(50),
Copy link
Contributor

@coderabbitai coderabbitai bot Nov 4, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Schema mismatch with frontend validation.

The backend schema enforces a minimum of 50 (dollars) for invoiceAmountUsd, but the frontend validation in CreateLink.tsx (line 52) allows amounts as low as $0.50. This mismatch will cause the backend to reject valid frontend submissions, resulting in runtime errors and poor UX.

Apply this diff to align the backend schema with the frontend validation:

-  invoiceAmountUsd: z.number().min(50),
+  invoiceAmountUsd: z.number().min(0.5),

Alternatively, if $50 is the correct minimum, update the frontend validation:

In src/ui/pages/stripe/CreateLink.tsx:

       invoiceAmountUsd: (value) =>
-        value < 0.5 ? "Amount must be at least $0.50" : null,
+        value < 50 ? "Amount must be at least $50.00" : null,

And update the placeholder:

-          placeholder="100"
-          min={0.5}
+          placeholder="100"
+          min={50}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
invoiceAmountUsd: z.number().min(50),
invoiceAmountUsd: z.number().min(0.5),
🤖 Prompt for AI Agents
In src/common/types/stripe.ts around line 10, the zod schema sets
invoiceAmountUsd to a minimum of 50 which conflicts with the frontend allowing
$0.50; change the schema to z.number().min(0.5) to match the frontend validation
(or alternatively, if $50 is intended, update src/ui/pages/stripe/CreateLink.tsx
validation and its placeholder to enforce and display $50 minimum) — ensure
types, tests, and any API docs are updated accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

@ashleyyli please reconcile now that we're here. We want it to be 50 cents

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!


export type GetInvoiceLinksResponse = z.infer<
typeof invoiceLinkGetResponseSchema>;
typeof invoiceLinkGetResponseSchema>;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix formatting issue flagged by ESLint.

Apply this diff:

-  typeof invoiceLinkGetResponseSchema>;
+  typeof invoiceLinkGetResponseSchema
+>;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
typeof invoiceLinkGetResponseSchema>;
typeof invoiceLinkGetResponseSchema
>;
🧰 Tools
🪛 ESLint

[error] 37-37: Insert

(prettier/prettier)

🤖 Prompt for AI Agents
In src/common/types/stripe.ts around line 37, fix the ESLint formatting problem
on the type line by correcting the trailing punctuation and spacing so the
generic/type expression is formatted consistently with project style (remove the
stray/misplaced semicolon or extra whitespace around the closing angle bracket),
then run or apply eslint --fix / prettier to ensure the file matches project
formatting.

Copy link
Member

@devksingh4 devksingh4 left a comment

Choose a reason for hiding this comment

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

@ashleyyli is there a real eslint issue?


export const invoiceLinkPostRequestSchema = z.object({
invoiceId: z.string().min(1),
invoiceAmountUsd: z.number().min(50),
Copy link
Member

Choose a reason for hiding this comment

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

@ashleyyli please reconcile now that we're here. We want it to be 50 cents

@devksingh4 devksingh4 self-requested a review November 8, 2025 03:08
@devksingh4 devksingh4 self-requested a review November 8, 2025 03:09
Copy link
Member

@devksingh4 devksingh4 left a comment

Choose a reason for hiding this comment

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

See to fix unnit tests

contactName: z.string().min(1),
contactEmail: z.string().email()
contactEmail: z.string().email(),
achPaymentsEnabled: z.boolean(),
Copy link
Member

Choose a reason for hiding this comment

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

should be z.optional(z.boolean()) and default false

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
src/ui/pages/stripe/CreateLink.test.tsx (1)

33-43: Consider adding test coverage for the ACH switch rendering.

While the current test verifies the existing form fields, it doesn't confirm that the new ACH payment switch is rendered correctly. Consider adding an assertion to verify the switch exists and is in the expected disabled state.

Example enhancement:

  it("renders the form fields correctly", async () => {
    await renderComponent();

    expect(screen.getByText("Invoice ID")).toBeInTheDocument();
    expect(screen.getByText("Invoice Amount")).toBeInTheDocument();
    expect(screen.getByText("Invoice Recipient Name")).toBeInTheDocument();
    expect(screen.getByText("Invoice Recipient Email")).toBeInTheDocument();
+   expect(screen.getByRole("checkbox", { name: /ACH/i })).toBeDisabled();
    expect(
      screen.getByRole("button", { name: "Create Link" }),
    ).toBeInTheDocument();
  });

Note: Adjust the role and name matcher based on the actual label/accessibility attributes used in the CreateLink component.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 3271500 and 34564a8.

📒 Files selected for processing (1)
  • src/ui/pages/stripe/CreateLink.test.tsx (1 hunks)
⏰ 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). (2)
  • GitHub Check: Run Unit Tests
  • GitHub Check: Build Application
🔇 Additional comments (1)
src/ui/pages/stripe/CreateLink.test.tsx (1)

75-75: LGTM! Correctly adds the new field to the test payload.

The addition of achPaymentsEnabled: false properly aligns with the updated PostInvoiceLinkRequest type and matches the form's initial state.

@devksingh4 devksingh4 enabled auto-merge (squash) November 9, 2025 04:28
@devksingh4 devksingh4 self-requested a review November 9, 2025 04:28
@devksingh4 devksingh4 disabled auto-merge November 9, 2025 05:55
@devksingh4 devksingh4 merged commit 2d0db6a into main Nov 9, 2025
12 of 13 checks passed
@devksingh4 devksingh4 deleted the add-ach-option branch November 9, 2025 05:55
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.

3 participants