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

Release January 2024 #458

Merged
merged 20 commits into from
Jan 22, 2024
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cd00b92
refactor: remove conditions
prachigarg19 Nov 9, 2023
1966965
console paymenrequest
prachigarg19 Nov 22, 2023
de0c599
deleted commented code
norbertschuler Dec 7, 2023
0741a44
fix: prevents repeated Google/ApplePay charges
mohitb35 Jan 3, 2024
2d16d70
feat: adds env vars to enable Google/ApplePay
mohitb35 Jan 3, 2024
057c639
fix: initializes`paymentRequest` on project change
mohitb35 Jan 8, 2024
1800075
chore(deps): bump axios from 0.21.4 to 1.6.0
dependabot[bot] Jan 9, 2024
5bbb787
feat: conditionally prevent redirect to VERCEL_URL
mohitb35 Jan 12, 2024
e9c24eb
enable ApplePay by default like GooglePay is enabled by default
norbertschuler Jan 13, 2024
6887189
feat: disables native payments by default
mohitb35 Jan 15, 2024
67b1d1b
Merge pull request #447 from Plant-for-the-Planet-org/feature/enable-…
mariahosfeld Jan 15, 2024
a3d9ba2
Merge pull request #448 from Plant-for-the-Planet-org/dependabot/npm_…
mariahosfeld Jan 15, 2024
996493f
chore(deps): bump follow-redirects from 1.15.2 to 1.15.5
dependabot[bot] Jan 15, 2024
260f44c
Merge pull request #459 from Plant-for-the-Planet-org/dependabot/npm_…
mohitb35 Jan 15, 2024
9050c73
fix: resolves bugs with planetcash switch
mohitb35 Jan 16, 2024
2ab3093
fix: shows a loader while refreshing native pay btns
mohitb35 Jan 16, 2024
37cf052
fix: corrects paymentLabel for payment request while donating to pcash
mohitb35 Jan 17, 2024
8ccd0d1
fix: fixes issues with native payments to pcash
mohitb35 Jan 17, 2024
a2d8163
feat: enables auth on custom domain by preventing redirects based on …
mohitb35 Jan 17, 2024
d720673
Merge pull request #460 from Plant-for-the-Planet-org/feature/planetc…
mariahosfeld Jan 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: fixes issues with native payments to pcash
- ensures amount is always correct
- ensures event handler is always attached
- cleans up event handler on unmount
mohitb35 committed Jan 17, 2024
commit 8ccd0d129ce9355f27e8c5d3a3a0df1c27378943
11 changes: 11 additions & 0 deletions src/Donations/Components/DonationsForm.tsx
Original file line number Diff line number Diff line change
@@ -68,6 +68,7 @@ function DonationsForm(): ReactElement {
utmMedium,
utmSource,
isPackageWanted,
setPaymentRequest,
} = React.useContext(QueryParamContext);
const { t, i18n } = useTranslation(["common", "country", "donate"]);

@@ -78,6 +79,16 @@ function DonationsForm(): ReactElement {
React.useState(false);
const router = useRouter();

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

React.useEffect(() => {
if (isPlanetCashActive) {
setPaymentRequest(null);
}
}, [isPlanetCashActive]);

React.useEffect(() => {
setMinAmt(getMinimumAmountForCurrency(currency));
}, [currency]);
10 changes: 6 additions & 4 deletions src/Donations/Components/PaymentsForm.tsx
Original file line number Diff line number Diff line change
@@ -82,6 +82,7 @@ function PaymentsForm(): ReactElement {
utmMedium,
utmSource,
isPackageWanted,
setPaymentRequest,
} = React.useContext(QueryParamContext);

const [stripePromise, setStripePromise] =
@@ -100,6 +101,7 @@ function PaymentsForm(): ReactElement {

React.useEffect(() => {
setPaymentType("CARD");
setPaymentRequest(null);
}, []);

const sofortCountries = ["AT", "BE", "DE", "IT", "NL", "ES"];
@@ -111,7 +113,7 @@ function PaymentsForm(): ReactElement {
| string
| PaymentMethod
| PaypalApproveData
| PaypalErrorData,
| PaypalErrorData
) => {
if (!paymentSetup || !donationID) {
console.log("Missing payment options"); //TODOO - better error handling
@@ -144,7 +146,7 @@ function PaymentsForm(): ReactElement {
// Seems to work only for native pay. Should this be removed?
const onPaymentFunction = async (
paymentMethod: PaymentMethod,
paymentRequest: PaymentRequest,
paymentRequest: PaymentRequest
) => {
setPaymentType(paymentRequest._activeBackingLibraryName); //TODOO --_activeBackingLibraryName is a private variable?
const gateway = "stripe";
@@ -289,7 +291,7 @@ function PaymentsForm(): ReactElement {
query: { ...router.query, step: CONTACT },
},
undefined,
{ shallow: true },
{ shallow: true }
);
}}
className="d-flex"
@@ -420,7 +422,7 @@ function PaymentsForm(): ReactElement {
totalCost={getFormatedCurrency(
i18n.language,
currency,
paymentSetup?.unitCost * quantity,
paymentSetup?.unitCost * quantity
)}
onPaymentFunction={(providerObject: PaymentMethod) =>
onSubmitPayment("stripe", "card", providerObject)
17 changes: 7 additions & 10 deletions src/Donations/PaymentMethods/PaymentRequestCustomButton.tsx
Original file line number Diff line number Diff line change
@@ -32,32 +32,28 @@
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" || false;
const { t, ready } = useTranslation(["common"]);
const { paymentRequest, setPaymentRequest } = useContext(QueryParamContext);

const stripe = useStripe();
const [canMakePayment, setCanMakePayment] = useState(false);
const [paymentLoading, setPaymentLoading] = useState(false);
// Tracks if native pay buttons were shown at least once to prevent layout jerks
const [wasNativePayInit, setWasNativePayInit] = useState(false);

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

codefactor.io / CodeFactor

src/Donations/PaymentMethods/PaymentRequestCustomButton.tsx#L35-L56

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

useEffect(() => {
if (
stripe &&
@@ -85,11 +81,9 @@
}, [stripe, paymentRequest, country, currency, amount]);

useEffect(() => {
if (stripe && paymentRequest) {
setPaymentRequest(null);
setCanMakePayment(false);
setPaymentLoading(false);
}
setPaymentRequest(null);
setCanMakePayment(false);
setPaymentLoading(false);
}, [country, currency, amount]);

useEffect(() => {
@@ -125,7 +119,10 @@
);
}
return () => {
if (paymentRequest && !paymentLoading) {
if (
paymentRequest &&
paymentRequest.hasRegisteredListener("paymentmethod")
) {
paymentRequest.off("paymentmethod", () => {
setPaymentLoading(false);
});

Unchanged files with check annotations Beta

}
}, [isLoading, isAuthenticated, loadProfile]);
useEffect(() => {
const regex = /^pcash_/;
if (router.query.to && regex.test(router.query.to as string)) {
router.push("/");
} else if (router.query.to?.toString().toLowerCase() === "planetcash") {
if (
!queryToken &&
!router.query.token &&
!isLoading &&
!isAuthenticated
) {
loginWithRedirect({
redirectUri: window?.location.href,
});
} else {
if (profile && profile?.planetCash?.account) {
loadPaymentSetup({
projectGUID: profile?.planetCash?.account,
paymentSetupCountry: country,
shouldSetPaymentDetails: true,
});
setdonationStep(1);
} else if (!profile?.planetCash) {
if (router.query.token) {
if (validateToken(router.query.token as string)) {
if (!profile) {
loadProfile();
} else if (!profile?.planetCash && profile?.displayName) {
showPlanetCashSignUpScreen();
}
} else {
// If token is invalid force user to login
router.push("/?to=planetcash&step=donate");
}
} else if (profile?.displayName) {
showPlanetCashSignUpScreen();
}
}
}
}
}, [
router.query.to,
country,
profile,
isLoading,
isAuthenticated,
router.query.token,
]);

Check notice on line 347 in src/Layout/QueryParamContext.tsx

codefactor.io / CodeFactor

src/Layout/QueryParamContext.tsx#L299-L347

Complex Method
useEffect(() => {
const regex = /^pcash_/;
if (