Skip to content

Commit 2d5e2be

Browse files
authored
Support nonprofit.metadata.disabledPaymentFlowOptions (#445)
* Support nonprofit.metadata.disabledPaymentFlowOptions * Type explanation
1 parent 518fc81 commit 2d5e2be

File tree

2 files changed

+11
-0
lines changed
  • packages/donate-button-v4/src/components/widget

2 files changed

+11
-0
lines changed

packages/donate-button-v4/src/components/widget/components/PaymentProcess/PaymentMethodSelect/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from 'src/components/widget/components/PaymentProcess/PaymentMethodSelect/styles';
1313
import {legendCss} from 'src/components/widget/components/PaymentProcess/styles';
1414
import {useConfigContext} from 'src/components/widget/hooks/useConfigContext';
15+
import {useNonprofitOrError} from 'src/components/widget/hooks/useNonprofit';
1516
import {useWidgetContext} from 'src/components/widget/hooks/useWidgetContext';
1617
import {AppleIcon} from 'src/components/widget/icons/AppleIcon';
1718
import {GoogleIcon} from 'src/components/widget/icons/GoogleIcon';
@@ -38,11 +39,18 @@ interface PaymentMethodListItemProps {
3839
const usePaymentMethods = () => {
3940
const {methods, frequency: fixedFrequency, previewMode} = useConfigContext();
4041
const {paymentRequestAvailable} = useWidgetContext();
42+
const nonprofit = useNonprofitOrError();
4143

4244
const filteredMethods = useMemo(
4345
() =>
4446
methods
4547
.filter((method) => {
48+
if (
49+
nonprofit?.metadata?.disabledPaymentFlowOptions?.includes(method)
50+
) {
51+
return false;
52+
}
53+
4654
if (
4755
fixedFrequency === DonationFrequency.Monthly &&
4856
OneTimeFrequencyMethods.includes(method)

packages/donate-button-v4/src/components/widget/types/Nonprofit.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export interface Nonprofit {
1818
nteeCode: string | null;
1919
metadata?: {
2020
customTaxDeductible?: string;
21+
// Note that multiple payment methods can be disabled, but it still arrives as a single
22+
// comma-separated string from the API eg "card,paypal" so we type it as such here
23+
disabledPaymentFlowOptions?: string;
2124
disablePrivateNotes?: boolean;
2225
granteeName?: string;
2326
prefixWithThe?: boolean;

0 commit comments

Comments
 (0)