diff --git a/.env.production b/.env.production index 9c1b3341..f9b510c1 100644 --- a/.env.production +++ b/.env.production @@ -20,4 +20,7 @@ SENTRY_AUTH_TOKEN= SOURCE_VERSION= RECURRENCY=true -TRACKING_KEY= \ No newline at end of file +TRACKING_KEY= + +ENABLE_APPLE_PAY= +ENABLE_GOOGLE_PAY= \ No newline at end of file diff --git a/next.config.js b/next.config.js index 29ea5bb9..12f79d42 100644 --- a/next.config.js +++ b/next.config.js @@ -115,6 +115,9 @@ const nextConfig = { ESRI_CLIENT_SECRET: process.env.ESRI_CLIENT_SECRET, RECURRENCY: process.env.RECURRENCY, TRACKING_KEY: process.env.TRACKING_KEY, + ENABLE_GOOGLE_PAY: process.env.ENABLE_GOOGLE_PAY, + ENABLE_APPLE_PAY: process.env.ENABLE_APPLE_PAY, + DISABLE_VERCEL_REDIRECT: process.env.DISABLE_VERCEL_REDIRECT, }, trailingSlash: false, reactStrictMode: true, diff --git a/pages/_app.tsx b/pages/_app.tsx index 39c3fa57..dd5b986a 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -87,7 +87,10 @@ function MyApp({ process.env.VERCEL_URL && typeof window !== "undefined" ) { - if (process.env.VERCEL_URL !== window.location.hostname) { + if ( + process.env.VERCEL_URL !== window.location.hostname && + process.env.DISABLE_VERCEL_REDIRECT !== "true" + ) { router.replace(`https://${process.env.VERCEL_URL}`); } } diff --git a/src/Donations/Components/DonationsForm.tsx b/src/Donations/Components/DonationsForm.tsx index 6652bff0..c230d144 100644 --- a/src/Donations/Components/DonationsForm.tsx +++ b/src/Donations/Components/DonationsForm.tsx @@ -108,7 +108,7 @@ function DonationsForm(): ReactElement { //Only used for native pay. Is this still applicable, or should this be removed? const onPaymentFunction = async ( paymentMethod: PaymentMethod, - paymentRequest: PaymentRequest, + paymentRequest: PaymentRequest ) => { // eslint-disable-next-line no-underscore-dangle setPaymentType(paymentRequest._activeBackingLibraryName); //TODOO - is _activeBackingLibraryName a private variable? @@ -223,7 +223,7 @@ function DonationsForm(): ReactElement { amount: getFormatedCurrency( i18n.language, currency, - paymentSetup.unitCost * quantity, + paymentSetup.unitCost * quantity ), }); break; @@ -233,7 +233,7 @@ function DonationsForm(): ReactElement { amount: getFormatedCurrency( i18n.language, currency, - paymentSetup.unitCost * quantity, + paymentSetup.unitCost * quantity ), }); break; @@ -389,13 +389,11 @@ function DonationsForm(): ReactElement { paymentSetup?.gateways?.stripe?.account && currency ? ( { + const isApplePayEnabled = process.env.ENABLE_APPLE_PAY === "true" || false; + const isGooglePayEnabled = process.env.ENABLE_GOOGLE_PAY === "true" || false; const { t, ready } = useTranslation(["common"]); const { paymentRequest, setPaymentRequest } = useContext(QueryParamContext); @@ -53,6 +51,10 @@ export const PaymentRequestCustomButton = ({ const [canMakePayment, setCanMakePayment] = useState(false); const [paymentLoading, setPaymentLoading] = useState(false); + useEffect(() => { + setPaymentRequest(null); + }, []); + useEffect(() => { if ( stripe && @@ -108,6 +110,7 @@ export const PaymentRequestCustomButton = ({ useEffect(() => { if (paymentRequest && !paymentLoading) { setPaymentLoading(true); + paymentRequest.off("paymentmethod"); paymentRequest.on( "paymentmethod", ({ complete, paymentMethod }: PaymentRequestPaymentMethodEvent) => { @@ -119,14 +122,9 @@ export const PaymentRequestCustomButton = ({ } return () => { if (paymentRequest && !paymentLoading) { - paymentRequest.off( - "paymentmethod", - ({ complete, paymentMethod }: PaymentRequestPaymentMethodEvent) => { - onPaymentFunction(paymentMethod, paymentRequest); - complete("success"); - setPaymentLoading(false); - } - ); + paymentRequest.off("paymentmethod", () => { + setPaymentLoading(false); + }); } }; }, [paymentRequest, onPaymentFunction]); @@ -215,8 +213,6 @@ export const PaymentRequestCustomButton = ({ /* 9 May 2023 - Apple Pay / Google Pay is disabled currently as it is not working correctly*/ interface NativePayProps { - isApplePayEnabled: boolean; - isGooglePayEnabled: boolean; country: string; currency: string; amount: number; @@ -231,8 +227,6 @@ interface NativePayProps { frequency: string | null; } export const NativePay = ({ - isApplePayEnabled = false, - isGooglePayEnabled = false, country, currency, amount, @@ -279,8 +273,6 @@ export const NativePay = ({ paymentLabel={paymentLabel} frequency={frequency} paymentSetup={paymentSetup} - isApplePayEnabled={isApplePayEnabled} - isGooglePayEnabled={isGooglePayEnabled} /> );