Skip to content

Commit 4eea984

Browse files
authored
Merge pull request #703 from ResearchHub/endaoment-only-for-non-profit-fundraises
Show Endaoment for non-profit associated fundraises only
2 parents 1e5cfac + d20003f commit 4eea984

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

components/Funding/PaymentStep.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ interface PaymentStepProps {
4141
fundraiseId: ID;
4242
/** Wallet payment method availability from Stripe (resolved at modal level) */
4343
walletAvailability: WalletAvailability;
44+
/** Whether the fundraise has a non-profit org (shows Endaoment option) */
45+
hasNonprofit?: boolean;
4446
/** Whether the action is being processed */
4547
isProcessing?: boolean;
4648
/** Error message to display */
@@ -70,6 +72,7 @@ export function PaymentStep({
7072
rscBalance,
7173
fundraiseId,
7274
walletAvailability,
75+
hasNonprofit = false,
7376
isProcessing = false,
7477
error,
7578
onConfirmPayment,
@@ -207,6 +210,7 @@ export function PaymentStep({
207210
onStripeReady={onStripeReady}
208211
hideButton
209212
walletAvailability={walletAvailability}
213+
hasNonprofit={hasNonprofit}
210214
/>
211215

212216
{/* Receipt-style line items */}

components/Funding/PaymentWidget.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ interface PaymentWidgetProps {
6161
hideButton?: boolean;
6262
/** Wallet payment method availability from Stripe */
6363
walletAvailability: WalletAvailability;
64+
/** Whether the fundraise has a non-profit org attached */
65+
hasNonprofit?: boolean;
6466
}
6567

6668
/**
@@ -84,6 +86,7 @@ export function PaymentWidget({
8486
onStripeReady,
8587
hideButton = false,
8688
walletAvailability,
89+
hasNonprofit = false,
8790
}: PaymentWidgetProps) {
8891
const { isExpanded, selectedMethod, toggleExpanded, selectMethod } = usePaymentMethod({
8992
initialMethod: selectedPaymentMethod,
@@ -184,6 +187,7 @@ export function PaymentWidget({
184187
];
185188

186189
// Filter payment methods based on actual device capabilities from Stripe.
190+
// - Hide Endaoment if the fundraise has no associated non-profit
187191
// - Hide Apple Pay if not available on this device
188192
// - Hide Google Pay if not available OR if Apple Pay is available
189193
// (Stripe's PaymentRequestButtonElement renders Apple Pay preferentially
@@ -192,6 +196,9 @@ export function PaymentWidget({
192196
// options that may not be available
193197
const visiblePaymentOptions = paymentOptions.filter((option) => {
194198
if (HIDDEN_PAYMENT_METHODS.includes(option.id)) return false;
199+
if (option.id === 'endaoment') {
200+
return hasNonprofit;
201+
}
195202
if (option.id === 'apple_pay') {
196203
return !walletAvailability.checking && walletAvailability.applePay;
197204
}

components/modals/ContributeToFundraiseModal.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { BaseModal } from '@/components/ui/BaseModal';
2525
import { SwipeableDrawer } from '@/components/ui/SwipeableDrawer';
2626
import { useIsMobile } from '@/hooks/useIsMobile';
2727
import { EndaomentProvider } from '@/contexts/EndaomentContext';
28+
import { useNonprofitByFundraiseId } from '@/hooks/useNonprofitByFundraiseId';
2829

2930
// Import inline deposit views
3031
import { DepositRSCView } from './DepositRSCView';
@@ -89,6 +90,8 @@ function ContributeToFundraiseModalInner({
8990
const walletAvailability = useWalletAvailability();
9091
const { exchangeRate } = useExchangeRate();
9192
const isMobile = useIsMobile();
93+
const { nonprofit } = useNonprofitByFundraiseId(fundraise.id);
94+
const hasNonprofit = nonprofit !== null;
9295
const [amountUsd, setAmountUsd] = useState(100);
9396
const [isContributing, setIsContributing] = useState(false);
9497
const [error, setError] = useState<string | null>(null);
@@ -468,6 +471,7 @@ function ContributeToFundraiseModalInner({
468471
isProcessing={isContributing}
469472
error={error}
470473
walletAvailability={walletAvailability}
474+
hasNonprofit={hasNonprofit}
471475
onConfirmPayment={handleConfirmPayment}
472476
onPaymentRequestSuccess={handlePaymentRequestSuccess}
473477
onEndaomentPaymentConfirm={handleEndaomentPaymentConfirm}

0 commit comments

Comments
 (0)