@@ -63,6 +63,7 @@ const MultiGatewayDonationInner: React.FC<Props> = (props) => {
6363 const [ transactionFee , setTransactionFee ] = useState < number > ( 0 ) ;
6464 const [ payFee , setPayFee ] = useState < number > ( 0 ) ;
6565 const [ total , setTotal ] = useState < number > ( 0 ) ;
66+ const [ coverFee , setCoverFee ] = useState < boolean > ( false ) ;
6667 const [ paymentMethodName , setPaymentMethodName ] = useState < string > (
6768 props ?. paymentMethods ?. length > 0 ? `${ props . paymentMethods [ 0 ] . name } ${ props . paymentMethods [ 0 ] . last4 ? `****${ props . paymentMethods [ 0 ] . last4 } ` : props . paymentMethods [ 0 ] . email || "" } ` : ""
6869 ) ;
@@ -146,6 +147,7 @@ const MultiGatewayDonationInner: React.FC<Props> = (props) => {
146147 const d = { ...donation } as MultiGatewayDonationInterface ;
147148 d . amount = checked ? fundsTotal + transactionFee : fundsTotal ;
148149 const showFee = checked ? transactionFee : 0 ;
150+ setCoverFee ( checked ) ;
149151 setTotal ( d . amount ) ;
150152 setPayFee ( showFee ) ;
151153 setDonation ( d ) ;
@@ -352,9 +354,15 @@ const MultiGatewayDonationInner: React.FC<Props> = (props) => {
352354 setTotal ( updatedAmount ) ;
353355 setPayFee ( fee ) ;
354356 setDonation ( prev => ( { ...prev , amount : updatedAmount } ) ) ;
357+ } else if ( coverFee ) {
358+ // User has opted in to cover fees — recalculate total with the updated fee
359+ const updatedAmount = totalAmount + fee ;
360+ setTotal ( updatedAmount ) ;
361+ setPayFee ( fee ) ;
362+ setDonation ( prev => ( { ...prev , amount : updatedAmount } ) ) ;
355363 }
356364 } , 500 ) ;
357- } , [ donation , funds , gateway , selectedGatewayObj ?. id , selectedGateway , getTransactionFee ] ) ;
365+ } , [ donation , funds , gateway , selectedGatewayObj ?. id , selectedGateway , getTransactionFee , coverFee ] ) ;
358366
359367 useEffect ( ( ) => {
360368 loadFunds ( ) ;
@@ -593,7 +601,7 @@ const MultiGatewayDonationInner: React.FC<Props> = (props) => {
593601 ) : (
594602 < FormGroup >
595603 < FormControlLabel
596- control = { < Checkbox /> }
604+ control = { < Checkbox checked = { coverFee } /> }
597605 name = "transaction-fee"
598606 label = { Locale . label ( "donation.donationForm.cover" ) . replace ( "{}" , CurrencyHelper . formatCurrencyWithLocale ( transactionFee , gateway ?. currency || "USD" ) ) }
599607 onChange = { handleCheckChange }
0 commit comments