From 5924aa10c4275af224a12f41e8f09c04deb79426 Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:01:03 +0530 Subject: [PATCH 01/29] docs: adds explanation (handleStripeSCAPayment) --- src/Donations/PaymentMethods/PaymentFunctions.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Donations/PaymentMethods/PaymentFunctions.ts b/src/Donations/PaymentMethods/PaymentFunctions.ts index e0495966..e3693638 100644 --- a/src/Donations/PaymentMethods/PaymentFunctions.ts +++ b/src/Donations/PaymentMethods/PaymentFunctions.ts @@ -466,6 +466,7 @@ export async function handleStripeSCAPayment({ } try { const payDonationData = { + // method not sent here as it was already captured in the 1st request. paymentProviderRequest: { account: paymentSetup.gateways.stripe.account, gateway: "stripe" as const, From 53345a01bedec103357dd3df1973b74b53b0987f Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:45:56 +0530 Subject: [PATCH 02/29] chore: updates planet-sdk --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1fd66929..3efee66b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@mui/material": "^5.11.8", "@next/bundle-analyzer": "^10.1.3", "@paypal/react-paypal-js": "^7.8.2", - "@planet-sdk/common": "^0.1.8", + "@planet-sdk/common": "^0.1.21", "@sentry/browser": "^6.2.5", "@sentry/integrations": "^6.2.5", "@sentry/node": "^6.2.5", @@ -1078,9 +1078,9 @@ "dev": true }, "node_modules/@planet-sdk/common": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.8.tgz", - "integrity": "sha512-1K3NACqgom4ZgA0GRWPXWRnTA72I4HHwBDbWOSTnRZkKE7Pl9fAwWjYyy72xJ5D654q66KmLSy4dMvRmcvBUMA==", + "version": "0.1.21", + "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.21.tgz", + "integrity": "sha512-XDrA0eylGezdA+Y4WcJVV9kzQ9HtlYIf5w7t+HMdsIXKV6UCc1Rb65J/rQPp4YKaUIYhCkmF9Sgd+BlVt5R1Ew==", "dependencies": { "@types/geojson": "^7946.0.10" } @@ -8722,9 +8722,9 @@ } }, "@planet-sdk/common": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.8.tgz", - "integrity": "sha512-1K3NACqgom4ZgA0GRWPXWRnTA72I4HHwBDbWOSTnRZkKE7Pl9fAwWjYyy72xJ5D654q66KmLSy4dMvRmcvBUMA==", + "version": "0.1.21", + "resolved": "https://registry.npmjs.org/@planet-sdk/common/-/common-0.1.21.tgz", + "integrity": "sha512-XDrA0eylGezdA+Y4WcJVV9kzQ9HtlYIf5w7t+HMdsIXKV6UCc1Rb65J/rQPp4YKaUIYhCkmF9Sgd+BlVt5R1Ew==", "requires": { "@types/geojson": "^7946.0.10" } diff --git a/package.json b/package.json index 9a8a1186..4d99351b 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "@mui/material": "^5.11.8", "@next/bundle-analyzer": "^10.1.3", "@paypal/react-paypal-js": "^7.8.2", - "@planet-sdk/common": "^0.1.8", + "@planet-sdk/common": "^0.1.21", "@sentry/browser": "^6.2.5", "@sentry/integrations": "^6.2.5", "@sentry/node": "^6.2.5", From 476b00fa21c5c3e6aa233d1c8899ea5d4a1e1fce Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:54:16 +0530 Subject: [PATCH 03/29] feat: adds `unitType` (`PaymentOptions` interface) - marks `unit` as deprecated - updates to `unitType` throughout code --- src/Common/Types/index.tsx | 4 ++-- src/Donations/Micros/DonationTypes/BouquetDonations.tsx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Common/Types/index.tsx b/src/Common/Types/index.tsx index c2d6dacd..4aba52c9 100644 --- a/src/Common/Types/index.tsx +++ b/src/Common/Types/index.tsx @@ -143,12 +143,12 @@ export interface PaymentOptions extends FetchedProjectDetails { frequencies: Frequencies; gateways: Gateways; recurrency: Recurrency; + /** @deprecated - use unitType instead */ unit: string; + unitType: string; unitCost: number; currency: string; destination: string; - isApproved: boolean; - isTopProject: boolean; } interface Frequencies { diff --git a/src/Donations/Micros/DonationTypes/BouquetDonations.tsx b/src/Donations/Micros/DonationTypes/BouquetDonations.tsx index 4bf8a149..f368d7e8 100644 --- a/src/Donations/Micros/DonationTypes/BouquetDonations.tsx +++ b/src/Donations/Micros/DonationTypes/BouquetDonations.tsx @@ -108,7 +108,7 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { setCustomInputValue( getFormattedNumber( i18n.language, - paymentSetup.unit !== "currency" + paymentSetup.unitType !== "currency" ? newQuantity : newQuantity * paymentSetup.unitCost ) @@ -227,7 +227,7 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { }} > {paymentSetup.purpose === "conservation" - ? t(paymentSetup.unit) + ? t(paymentSetup.unitType) : []}
@@ -238,7 +238,7 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { >{" "} - {paymentSetup.unit === "currency" + {paymentSetup.unitType === "currency" ? t("customAmount") : t("custom")}
From a04b1f157d46a42bf828c4c722af52fac20a40df Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Fri, 4 Aug 2023 11:51:33 +0530 Subject: [PATCH 04/29] feat: integrate unitType in DonationsForm - only for tree/conservation projects --- public/locales/en/common.json | 6 ++++++ src/Common/Types/index.tsx | 3 ++- src/Donations/Micros/DonationAmount.tsx | 4 ++-- .../Micros/DonationTypes/BouquetDonations.tsx | 16 +++++++++++++--- .../Micros/DonationTypes/TreeDonation.tsx | 16 ++++++++++++---- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 7bb657ef..fc22f358 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -3,6 +3,8 @@ "fortreeCountTrees_other": "for {{treeCount}} Trees", "forQuantitym2": "for {{quantity}} m²", "m2": "m²", + "tree_one": "tree", + "tree_other": "trees", "recipientName": "Recipient Name", "recipientNameRequired": "Recipient Name is required", "email": "Email", @@ -37,6 +39,10 @@ "orgNamePublishedTax": "Company name is visible on our leaderboard and app. Tax-deduction receipts will be issued for the same name.", "orgNamePublished": "Company name is visible on our leaderboard and app.", "paymentDetails": "Payment Details", + "perUnit": { + "tree": "per tree", + "m2": "per m²" + }, "perTree": "per tree", "perm2": "per m²", "youWillReceiveTaxDeduction": "You will receive a tax deduction receipt for ", diff --git a/src/Common/Types/index.tsx b/src/Common/Types/index.tsx index 4aba52c9..01c1df9b 100644 --- a/src/Common/Types/index.tsx +++ b/src/Common/Types/index.tsx @@ -10,6 +10,7 @@ import { ContactDetails, BankTransferDetails, PaymentGateway, + CurrencyCode, } from "@planet-sdk/common"; /** planet-donations only allows direct or invitation gifts */ @@ -145,7 +146,7 @@ export interface PaymentOptions extends FetchedProjectDetails { recurrency: Recurrency; /** @deprecated - use unitType instead */ unit: string; - unitType: string; + unitType: "tree" | "m2" | "currency" | CurrencyCode; unitCost: number; currency: string; destination: string; diff --git a/src/Donations/Micros/DonationAmount.tsx b/src/Donations/Micros/DonationAmount.tsx index 3fcd60ec..454837a1 100644 --- a/src/Donations/Micros/DonationAmount.tsx +++ b/src/Donations/Micros/DonationAmount.tsx @@ -21,12 +21,12 @@ function DonationAmount(): ReactElement { paymentSetup.unitCost * quantity )} - {paymentSetup.purpose === "trees" + {paymentSetup.unitType === "tree" ? t("fortreeCountTrees", { count: Number(quantity), treeCount: getFormattedNumber(i18n.language, Number(quantity)), }) - : paymentSetup.purpose === "conservation" + : paymentSetup.unitType === "m2" ? t("forQuantitym2", { quantity: getFormattedNumber(i18n.language, Number(quantity)), }) diff --git a/src/Donations/Micros/DonationTypes/BouquetDonations.tsx b/src/Donations/Micros/DonationTypes/BouquetDonations.tsx index f368d7e8..3893f92d 100644 --- a/src/Donations/Micros/DonationTypes/BouquetDonations.tsx +++ b/src/Donations/Micros/DonationTypes/BouquetDonations.tsx @@ -165,7 +165,11 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { currency, option.quantity * paymentSetup.unitCost )}{" "} - {paymentSetup.purpose === "conservation" ? t("m2") : []} + {/* Below condition is redundant currently, but is left here as a reminder while refactoring */} + {paymentSetup.purpose === "conservation" && + paymentSetup.unitType === "m2" + ? t(paymentSetup.unitType) + : []} @@ -226,7 +230,9 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { fontWeight: "800", }} > - {paymentSetup.purpose === "conservation" + {/* Below condition is redundant currently, but is left here as a reminder while refactoring */} + {paymentSetup.purpose === "conservation" && + paymentSetup.unitType === "m2" ? t(paymentSetup.unitType) : []} @@ -282,7 +288,11 @@ function BouquetDonations({ setopenCurrencyModal }: Props): ReactElement { ) : []}{" "} - {paymentSetup.purpose === "conservation" ? t("perm2") : []} + {/* Below condition is redundant currently, but is left here as a reminder while refactoring */} + {paymentSetup.purpose === "conservation" && + paymentSetup.unitType === "m2" + ? t("perUnit.m2") + : []} ) : ({option.quantity}
- {t("trees")} + + {t(paymentSetup.unitType, { count: option.quantity })} +{t("donate")}
)} {/* show PlanetCashSelector only if user is signed up and have a planetCash account */} - {projectDetails.purpose !== "funds" && + {paymentSetup?.unitType === "tree" && + projectDetails.purpose !== "funds" && projectDetails.purpose !== "planet-cash" && !(isGift && giftDetails.recipientName === "") && !(onBehalf && onBehalfDonor.firstName === "") && diff --git a/src/Donations/Micros/DonationTypes/TreeDonation.tsx b/src/Donations/Micros/DonationTypes/TreeDonation.tsx index 3d812c93..b959dabe 100644 --- a/src/Donations/Micros/DonationTypes/TreeDonation.tsx +++ b/src/Donations/Micros/DonationTypes/TreeDonation.tsx @@ -180,7 +180,7 @@ function TreeDonation({ setopenCurrencyModal }: Props): ReactElement { )} ) : ( -