diff --git a/packages/donations/src/components/FundDonation.tsx b/packages/donations/src/components/FundDonation.tsx index a1d53e2..e091140 100644 --- a/packages/donations/src/components/FundDonation.tsx +++ b/packages/donations/src/components/FundDonation.tsx @@ -1,8 +1,8 @@ "use client"; import React from "react"; -import { FundDonationInterface, FundInterface } from "@churchapps/helpers"; -import { FormControl, Grid, InputLabel, MenuItem, Select, TextField } from "@mui/material"; +import { FundDonationInterface, FundInterface, CurrencyHelper } from "@churchapps/helpers"; +import { FormControl, Grid, Icon, InputLabel, MenuItem, Select, TextField, Typography } from "@mui/material"; import type { SelectChangeEvent } from "@mui/material"; import { Locale } from "../helpers"; @@ -12,6 +12,7 @@ interface Props { index: number, updatedFunction: (fundDonation: FundDonationInterface, index: number) => void, params?: any, + currency?: string, } export const FundDonation: React.FC = (props) => { @@ -42,7 +43,7 @@ export const FundDonation: React.FC = (props) => { <> - + {props.currency ? CurrencyHelper.getCurrencySymbol(props.currency) : "$"} }} /> diff --git a/packages/donations/src/components/FundDonations.tsx b/packages/donations/src/components/FundDonations.tsx index 2475196..cdfb610 100644 --- a/packages/donations/src/components/FundDonations.tsx +++ b/packages/donations/src/components/FundDonations.tsx @@ -5,7 +5,7 @@ import { FundDonation } from "."; import { FundDonationInterface, FundInterface } from "@churchapps/helpers"; import { Locale } from "../helpers"; -interface Props { fundDonations: FundDonationInterface[], funds: FundInterface[], params?: any, updatedFunction: (fundDonations: FundDonationInterface[]) => void } +interface Props { fundDonations: FundDonationInterface[], funds: FundInterface[], params?: any, updatedFunction: (fundDonations: FundDonationInterface[]) => void, currency?: string } export const FundDonations: React.FC = (props) => { const handleUpdated = (fundDonation: FundDonationInterface, index: number) => { @@ -26,7 +26,7 @@ export const FundDonations: React.FC = (props) => { const result = []; for (let i = 0; i < props.fundDonations.length; i++) { const fd = props.fundDonations[i]; - result.push(); + result.push(); } return result; diff --git a/packages/donations/src/components/NonAuthDonationInner.tsx b/packages/donations/src/components/NonAuthDonationInner.tsx index ff0e498..40d4966 100644 --- a/packages/donations/src/components/NonAuthDonationInner.tsx +++ b/packages/donations/src/components/NonAuthDonationInner.tsx @@ -9,7 +9,7 @@ import { ApiHelper, DateHelper, CurrencyHelper } from "@churchapps/helpers"; import { Locale, DonationHelper, StripePaymentMethod } from "../helpers"; import { FundDonationInterface, FundInterface, PersonInterface, StripeDonationInterface, UserInterface, ChurchInterface } from "@churchapps/helpers"; import { - Grid, Alert, TextField, Button, FormControl, InputLabel, Select, MenuItem, FormGroup, FormControlLabel, Checkbox, Typography + Grid, Alert, TextField, Button, FormControl, InputLabel, Select, MenuItem, FormGroup, FormControlLabel, Checkbox, Typography } from "@mui/material"; import type { PaperProps } from "@mui/material/Paper"; @@ -208,7 +208,8 @@ export const NonAuthDonationInner: React.FC = ({ mainContainerCssProps, s ...donation, church: churchObj, provider: gateway?.provider || "stripe", - gatewayId: gateway?.id + gatewayId: gateway?.id, + currency: gateway?.currency || "USD" }; if (donationType === "once") results = await ApiHelper.post("/donate/charge", donationPayload, "GivingApi"); if (donationType === "recurring") results = await ApiHelper.post("/donate/subscribe", donationPayload, "GivingApi"); @@ -281,7 +282,7 @@ export const NonAuthDonationInner: React.FC = ({ mainContainerCssProps, s try { const response = await ApiHelper.post( "/donate/fee?churchId=" + props.churchId, - { amount, provider: gateway?.provider || "stripe", gatewayId: gateway?.id }, + { amount, provider: gateway?.provider || "stripe", gatewayId: gateway?.id, currency: gateway?.currency || "USD" }, "GivingApi" ); return response.calculatedFee; @@ -298,7 +299,7 @@ export const NonAuthDonationInner: React.FC = ({ mainContainerCssProps, s return (<>

{Locale.label("donation.donationForm.funds")}

- + ); } }; @@ -306,96 +307,96 @@ export const NonAuthDonationInner: React.FC = ({ mainContainerCssProps, s useEffect(init, []); //eslint-disable-line - if (donationComplete) return {Locale.label("donation.donationForm.thankYou")}; - else { - return ( - - - - - - - - - - - - - - - - - - - - { - setCaptchaResponse(""); - }} - onErrored={() => { - setCaptchaResponse("error"); - }} - /> - - - {gateway?.provider?.toLowerCase() === "stripe" && ( - - -
- -
-
- -
- -
-
- -
- -
-
-
- )} - {donationType === "recurring" - && - - - {Locale.label("donation.donationForm.frequency")} - - - - - - - - } - {getFundList()} - -
- {fundsTotal > 0 - && <> - {(gateway?.payFees === true) - ? *{Locale.label("donation.donationForm.fees").replace("{}", CurrencyHelper.formatCurrency(transactionFee))} - : ( - - } name="transaction-fee" label={Locale.label("donation.donationForm.cover").replace("{}", CurrencyHelper.formatCurrency(transactionFee))} onChange={handleCheckChange} /> - - )} -

Total Donation Amount: ${total}

- - } -
-
- ); - } + if (donationComplete) return {Locale.label("donation.donationForm.thankYou")}; + else { + return ( + + + + + + + + + + + + + + + + + + + + { + setCaptchaResponse(""); + }} + onErrored={() => { + setCaptchaResponse("error"); + }} + /> + + + {gateway?.provider?.toLowerCase() === "stripe" && ( + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+ )} + {donationType === "recurring" + && + + + {Locale.label("donation.donationForm.frequency")} + + + + + + + + } + {getFundList()} + +
+ {fundsTotal > 0 + && <> + {(gateway?.payFees === true) + ? *{Locale.label("donation.donationForm.fees").replace("{}", CurrencyHelper.formatCurrencyWithLocale(transactionFee, gateway?.currency || "USD"))} + : ( + + } name="transaction-fee" label={Locale.label("donation.donationForm.cover").replace("{}", CurrencyHelper.formatCurrencyWithLocale(transactionFee, gateway?.currency || "USD"))} onChange={handleCheckChange} /> + + )} +

Total Donation Amount: {CurrencyHelper.formatCurrencyWithLocale(total, gateway?.currency || "USD")}

+ + } +
+
+ ); + } }; diff --git a/packages/donations/src/helpers/PaymentMethod.ts b/packages/donations/src/helpers/PaymentMethod.ts index c33bff0..d770743 100644 --- a/packages/donations/src/helpers/PaymentMethod.ts +++ b/packages/donations/src/helpers/PaymentMethod.ts @@ -15,4 +15,5 @@ export interface PaymentGateway { productId?: string; payFees?: boolean; enabled?: boolean; + currency?: string; }