Support nonprofit.metadata.disabledPaymentFlowOptions#445
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for disabling specific payment flow options through the nonprofit metadata configuration. The change enables nonprofits to control which payment methods are available in the donation widget by specifying disabled options in their metadata.
- Added
disabledPaymentFlowOptionsfield to theNonprofittype interface - Implemented filtering logic to exclude disabled payment methods from the available options list
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/donate-button-v4/src/components/widget/types/Nonprofit.ts | Added optional disabledPaymentFlowOptions string field to nonprofit metadata interface |
| packages/donate-button-v4/src/components/widget/components/PaymentProcess/PaymentMethodSelect/index.tsx | Added filtering logic to exclude payment methods specified in nonprofit's disabled options |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| nteeCode: string | null; | ||
| metadata?: { | ||
| customTaxDeductible?: string; | ||
| disabledPaymentFlowOptions?: string; |
There was a problem hiding this comment.
The disabledPaymentFlowOptions field should be an array of strings rather than a single string, as it represents multiple payment options that can be disabled. Consider changing the type to string[] for better type safety and clearer API design.
| disabledPaymentFlowOptions?: string; | |
| disabledPaymentFlowOptions?: string[]; |
| if ( | ||
| nonprofit?.metadata?.disabledPaymentFlowOptions?.includes(method) | ||
| ) { |
There was a problem hiding this comment.
Using includes() on a string will check if method exists as a substring, not as a discrete value. If disabledPaymentFlowOptions is intended to be a comma-separated string, it should be split first: nonprofit?.metadata?.disabledPaymentFlowOptions?.split(',').includes(method). Otherwise, the type should be changed to string[].
| if ( | |
| nonprofit?.metadata?.disabledPaymentFlowOptions?.includes(method) | |
| ) { | |
| const disabledOptions = nonprofit?.metadata?.disabledPaymentFlowOptions; | |
| const disabledOptionsArr = Array.isArray(disabledOptions) | |
| ? disabledOptions | |
| : typeof disabledOptions === 'string' | |
| ? disabledOptions.split(',').map(opt => opt.trim()).filter(Boolean) | |
| : []; | |
| if (disabledOptionsArr.includes(method)) { |
| nteeCode: string | null; | ||
| metadata?: { | ||
| customTaxDeductible?: string; | ||
| disabledPaymentFlowOptions?: string; |
No description provided.