Skip to content

Commit

Permalink
feat: disables native payments by default
Browse files Browse the repository at this point in the history
- requires explicit enabling of native payments
  • Loading branch information
mohitb35 committed Jan 15, 2024
1 parent e9c24eb commit 6887189
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/Donations/PaymentMethods/PaymentRequestCustomButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface PaymentButtonProps {
amount: number;
onPaymentFunction: (
paymentMethod: PaymentMethod,
paymentRequest: PaymentRequest,
paymentRequest: PaymentRequest
) => Promise<void>;
continueNext: () => void;
isPaymentPage: boolean;
Expand All @@ -42,18 +42,18 @@ export const PaymentRequestCustomButton = ({
frequency,
paymentSetup,
}: PaymentButtonProps): ReactElement | null => {
const isApplePayEnabled = process.env.ENABLE_APPLE_PAY === "true" || true;
const isGooglePayEnabled = process.env.ENABLE_GOOGLE_PAY === "true" || true;
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);

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

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

View check run for this annotation

codefactor.io / CodeFactor

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

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

useEffect(()=> {
setPaymentRequest(null);
},[])
useEffect(() => {
setPaymentRequest(null);
}, []);

useEffect(() => {
if (
Expand All @@ -71,7 +71,6 @@ export const PaymentRequestCustomButton = ({
requestPayerName: true,
requestPayerEmail: true,
});
console.log("Stripe PR: ", pr);
// Check the availability of the Payment Request API.
pr.canMakePayment().then((result) => {
if (result) {
Expand All @@ -90,7 +89,6 @@ export const PaymentRequestCustomButton = ({
}, [country, currency, amount]);

useEffect(() => {
console.log("Context PR: ", paymentRequest);
let subscribed = true;
if (paymentRequest) {
paymentRequest
Expand Down Expand Up @@ -119,7 +117,7 @@ export const PaymentRequestCustomButton = ({
onPaymentFunction(paymentMethod, paymentRequest);
complete("success");
setPaymentLoading(false);
},
}
);
}
return () => {
Expand Down Expand Up @@ -220,7 +218,7 @@ interface NativePayProps {
amount: number;
onPaymentFunction: (
paymentMethod: PaymentMethod,
paymentRequest: PaymentRequest,
paymentRequest: PaymentRequest
) => Promise<void>;
paymentSetup: PaymentOptions;
continueNext: () => void;
Expand All @@ -242,7 +240,7 @@ export const NativePay = ({
const { i18n } = useTranslation();
const [stripePromise, setStripePromise] =
useState<null | Promise<Stripe | null>>(() =>
getStripe(paymentSetup, i18n.language),
getStripe(paymentSetup, i18n.language)
);

useEffect(() => {
Expand Down

0 comments on commit 6887189

Please sign in to comment.