Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull Request Overview
Purpose: Align disabled payment method handling with expected API shape by removing legacy workaround for comma-separated single-element arrays and switching to direct array membership checks.
- Removed legacy comments and substring workaround for malformed disabledPaymentFlowOptions response.
- Simplified filtering logic to rely on Array.includes for disabled payment methods.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/donate-button-v4/src/components/widget/types/Nonprofit.ts | Removed explanatory comment about prior malformed API response. |
| packages/donate-button-v4/src/components/widget/components/PaymentProcess/PaymentMethodSelect/index.tsx | Replaced fallback substring parsing logic with direct Array.includes check. |
Comments suppressed due to low confidence (1)
packages/donate-button-v4/src/components/widget/types/Nonprofit.ts:1
- [nitpick] The removal of this comment eliminates context about a previously known API quirk. If the API has been corrected, consider adding a brief replacement comment stating that disabledPaymentFlowOptions is now a proper string[] and the old workaround was intentionally removed, to clarify the rationale for future maintainers.
// TODO: add more accurate type
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if ( | ||
| nonprofit?.metadata?.disabledPaymentFlowOptions?.length === 1 && | ||
| nonprofit?.metadata?.disabledPaymentFlowOptions[0]?.includes(method) | ||
| nonprofit?.metadata?.disabledPaymentFlowOptions?.includes(method) |
There was a problem hiding this comment.
Replacing the previous substring check removes support for the malformed API case where disabledPaymentFlowOptions could be ["card,paypal"]. With the new logic, methods like "card" or "paypal" inside a single comma-separated element will no longer be filtered out. If that response shape can still occur, retain a fallback by splitting a single comma-containing element: const disabled = nonprofit?.metadata?.disabledPaymentFlowOptions; if (disabled?.length === 1 && disabled[0]?.includes(',')) { const parts = disabled[0].split(',').map(p => p.trim()); if (parts.includes(method)) return false; } else if (disabled?.includes(method)) return false;
No description provided.