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
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ SENTRY_AUTH_TOKEN=
SOURCE_VERSION=
RECURRENCY=true

TRACKING_KEY=
TRACKING_KEY=

ENABLE_APPLE_PAY=
ENABLE_GOOGLE_PAY=
8 changes: 7 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ const scheme =
: "https";

let APPUrl;
if (process.env.NEXT_PUBLIC_VERCEL_ENV === "preview") {
if (
process.env.NEXT_PUBLIC_VERCEL_ENV === "preview" &&
process.env.DISABLE_VERCEL_REDIRECT !== "true"
) {
APPUrl = `${scheme}://${process.env.VERCEL_URL}`;
} else {
APPUrl = process.env.APP_URL;
Expand Down Expand Up @@ -115,6 +118,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,
Expand Down
59 changes: 44 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@sparticuz/chromium": "^106.0.2",
"@stripe/react-stripe-js": "^1.4.0",
"@stripe/stripe-js": "^1.13.2",
"axios": "^0.21.1",
"axios": "^1.6.0",
"dom-to-image": "^2.6.0",
"geocoder-arcgis": "^2.0.5",
"i18next": "^22.4.10",
Expand Down
5 changes: 4 additions & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
}
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
"billingAddress": "Contact Details",
"treesInCountry": "{{treeCount}} trees, Plant-for-the-Planet",
"fundingPaymentLabel": "Donate {{amount}}, Plant-for-the-Planet",
"pcashPaymentLabel": "Load {{amount}} PlanetCash, Plant-for-the-Planet",
"bouquetPaymentLabel": "Donate {{amount}}, Plant-for-the-Planet",
"errorOccurred": "Something went wrong. Please feel free to take a screenshot and email us at [email protected].",
"dedicatedTo": "Dedicated to",
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Types/QueryParamContextInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export default interface QueryParamContextInterface {
paymentSetupCountry: string;
shouldSetPaymentDetails?: boolean;
}) => Promise<void>;
isPlanetCashActive: boolean;
setIsPlanetCashActive: Dispatch<SetStateAction<boolean>>;
isPlanetCashActive: boolean | null;
setIsPlanetCashActive: Dispatch<SetStateAction<boolean | null>>;
onBehalf: boolean;
setOnBehalf: Dispatch<SetStateAction<boolean>>;
onBehalfDonor: OnBehalfDonor;
Expand Down
22 changes: 20 additions & 2 deletions src/Donations/Components/DonationsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function DonationsForm(): ReactElement {
utmMedium,
utmSource,
isPackageWanted,
setPaymentRequest,
} = React.useContext(QueryParamContext);
const { t, i18n } = useTranslation(["common", "country", "donate"]);

Expand All @@ -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]);
Expand Down Expand Up @@ -241,6 +252,15 @@ function DonationsForm(): ReactElement {
),
});
break;
case "planet-cash":
paymentLabel = t("pcashPaymentLabel", {
amount: getFormatedCurrency(
i18n.language,
currency,
paymentSetup.unitCost * quantity
),
});
break;
case "bouquet":
case "conservation":
paymentLabel = t("bouquetPaymentLabel", {
Expand Down Expand Up @@ -400,8 +420,6 @@ function DonationsForm(): ReactElement {
paymentSetup?.gateways?.stripe?.account &&
currency ? (
<NativePay
isApplePayEnabled={false}
isGooglePayEnabled={false}
country={country}
currency={currency}
amount={formatAmountForStripe(
Expand Down
10 changes: 6 additions & 4 deletions src/Donations/Components/PaymentsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function PaymentsForm(): ReactElement {
utmMedium,
utmSource,
isPackageWanted,
setPaymentRequest,
} = React.useContext(QueryParamContext);

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

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

const sofortCountries = ["AT", "BE", "DE", "IT", "NL", "ES"];
Expand All @@ -111,7 +113,7 @@ function PaymentsForm(): ReactElement {
| string
| PaymentMethod
| PaypalApproveData
| PaypalErrorData,
| PaypalErrorData
) => {
if (!paymentSetup || !donationID) {
console.log("Missing payment options"); //TODOO - better error handling
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -289,7 +291,7 @@ function PaymentsForm(): ReactElement {
query: { ...router.query, step: CONTACT },
},
undefined,
{ shallow: true },
{ shallow: true }
);
}}
className="d-flex"
Expand Down Expand Up @@ -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)
Expand Down
43 changes: 26 additions & 17 deletions src/Donations/Micros/PlanetCashSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const PlanetCashSelector: FC = () => {
country,
setcountry,
frequency,
paymentRequest,
} = useContext(QueryParamContext);
const router = useRouter();

Expand All @@ -37,20 +36,28 @@ const PlanetCashSelector: FC = () => {
}, [paymentSetup?.unitCost, quantity, setIsPlanetCashActive]);

useEffect(() => {
// On Load If selected country is planetCash Country and balance is sufficient activate planetCash.

if (
country === profile?.planetCash?.country &&
paymentSetup &&
paymentSetup.unitCost * quantity <=
profile.planetCash.balance / 100 + profile.planetCash.creditLimit / 100
) {
setIsPlanetCashActive(true);
}
if (frequency !== "once") {
if (frequency !== "once" && isPlanetCashActive !== null) {
setIsPlanetCashActive(false);
} else {
if (
isPlanetCashActive === null &&
country === profile?.planetCash?.country &&
paymentSetup &&
paymentSetup.unitCost * quantity <=
(profile.planetCash.balance + profile.planetCash.creditLimit) / 100
) {
setIsPlanetCashActive(true);
}
}
}, [paymentRequest, frequency]);
}, [
country,
profile,
paymentSetup,
quantity,
frequency,
isPlanetCashActive,
frequency,
]);

useEffect(() => {
// This is done to lock the transaction with PlanetCash in a single currency.
Expand Down Expand Up @@ -208,11 +215,13 @@ const PlanetCashSelector: FC = () => {
</div>
<div title={disabledReason() ? disabledReason() : ""}>
<ToggleSwitch
checked={isPlanetCashActive}
checked={isPlanetCashActive === true}
disabled={shouldPlanetCashDisable()}
onChange={() =>
setIsPlanetCashActive((isPlanetCashActive) => !isPlanetCashActive)
}
onChange={() => {
setIsPlanetCashActive(
(isPlanetCashActive) => !isPlanetCashActive
);
}}
/>
</div>
</div>
Expand Down
11 changes: 9 additions & 2 deletions src/Donations/PaymentMethods/PaymentMethodTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ export default function PaymentMethodTabs({
),
});
break;
case "planet-cash":
paymentLabel = t("pcashPaymentLabel", {
amount: getFormatedCurrency(
i18n.language,
currency,
paymentSetup.unitCost * quantity
),
});
break;
case "bouquet":
case "conservation":
paymentLabel = t("bouquetPaymentLabel", {
Expand Down Expand Up @@ -218,8 +227,6 @@ export default function PaymentMethodTabs({
{/*9 May 2023 - Apple Pay / Google Pay is disabled currently as it is not working correctly*/}
{showNativePay && (
<NativePay
isApplePayEnabled={false}
isGooglePayEnabled={false}
country={country}
currency={currency}
amount={formatAmountForStripe(
Expand Down
Loading
Loading