Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable native payments #447

Merged
merged 9 commits into from
Jan 15, 2024
Prev Previous commit
Next Next commit
feat: adds env vars to enable Google/ApplePay
mohitb35 committed Jan 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2d16d702165d5a2f795613e7f12a7887d311a115
5 changes: 4 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -20,4 +20,7 @@ SENTRY_AUTH_TOKEN=
SOURCE_VERSION=
RECURRENCY=true

TRACKING_KEY=
TRACKING_KEY=

ENABLE_APPLE_PAY=
ENABLE_GOOGLE_PAY=
4 changes: 3 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ const nextConfig = {
stripPrefix: ["webpack://_N_E/"],
urlPrefix: `~${basePath}/_next`,
release: COMMIT_SHA,
})
}),
);
}
return config;
@@ -115,6 +115,8 @@ 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,
},
trailingSlash: false,
reactStrictMode: true,
8 changes: 6 additions & 2 deletions src/Donations/PaymentMethods/PaymentRequestCustomButton.tsx
Original file line number Diff line number Diff line change
@@ -31,22 +31,24 @@
paymentSetup: PaymentOptions;
}

export const PaymentRequestCustomButton = ({
country,
currency,
amount,
onPaymentFunction,
continueNext,
isPaymentPage,
paymentLabel,
frequency,
paymentSetup,
}: PaymentButtonProps): ReactElement | null => {
const isApplePayEnabled = process.env.ENABLE_APPLE_PAY === "true" || false;
const isGooglePayEnabled = process.env.ENABLE_GOOGLE_PAY === "true" || true;
const { t, ready } = useTranslation(["common"]);
const { paymentRequest, setPaymentRequest } = useContext(QueryParamContext);

const stripe = useStripe();
const [canMakePayment, setCanMakePayment] = useState(false);

Check notice on line 51 in src/Donations/PaymentMethods/PaymentRequestCustomButton.tsx

codefactor.io / CodeFactor

src/Donations/PaymentMethods/PaymentRequestCustomButton.tsx#L34-L51

Complex Method
const [paymentLoading, setPaymentLoading] = useState(false);

useEffect(() => {
@@ -140,7 +142,8 @@
(frequency !== "once"
? paymentSetup?.recurrency?.methods?.includes("card")
: true) ? (
paymentRequest._canMakePaymentAvailability.APPLE_PAY ? ( //TODOO - is _canMakePaymentAvailability a private variable?
paymentRequest._canMakePaymentAvailability.APPLE_PAY &&
isApplePayEnabled ? ( //TODOO - is _canMakePaymentAvailability a private variable?
<div className="w-100">
<button
onClick={() => paymentRequest.show()}
@@ -163,7 +166,8 @@
<div className="separator-text mb-10">{t("or")}</div>
)}
</div>
) : paymentRequest._canMakePaymentAvailability.GOOGLE_PAY ? ( //TODOO - is _canMakePaymentAvailability a private variable?
) : paymentRequest._canMakePaymentAvailability.GOOGLE_PAY &&
isGooglePayEnabled ? ( //TODOO - is _canMakePaymentAvailability a private variable?
<div className="w-100">
<button
onClick={() => {