* change DonationTextComponent extension to tsx * migrate DonationTextComponents to ts * change DonationModal extension to tsx * add @types/react-redux * migrate DonationModal to ts * change PaypalButton extension to ts * change DonateCompletion extension to tsx * migrate DonateCompletion to TypeScript * change PayPalButtonLoader extension to tsx * first changes in paypal button (help needed) * first changes in PayPalButtonScriptLoader (help needed) * change DonateForm extension to tsx * migrate donate module to ts * Update client/src/components/Donation/DonateForm.tsx Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * Update client/src/components/Donation/DonationModal.tsx Co-authored-by: Shaun Hamilton <shauhami020@gmail.com> * Update client/src/components/Donation/DonationModal.tsx Co-authored-by: Shaun Hamilton <shauhami020@gmail.com> * Update client/src/components/Donation/DonateForm.tsx Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * Update client/src/components/Donation/DonateForm.tsx Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * Delete console.log client/src/components/Donation/DonationModal.tsx Co-authored-by: Shaun Hamilton <shauhami020@gmail.com> * applied changes requested * fix: readjust default one time amount * fix types Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * chore: restore comments.json * fix: type assertion * fix: specific DonateForm props * Apply suggestions from code review Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * Update client/src/components/Donation/PaypalButton.tsx Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * fix:set default stat for paypalbutton Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Shaun Hamilton <shauhami020@gmail.com> Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>
108 lines
2.8 KiB
JavaScript
108 lines
2.8 KiB
JavaScript
// Configuration for client side
|
|
const durationsConfig = {
|
|
month: 'monthly',
|
|
onetime: 'one-time'
|
|
};
|
|
const amountsConfig = {
|
|
month: [1000, 2000, 3000, 4000, 5000],
|
|
onetime: [2500, 5000, 7500, 10000, 15000]
|
|
};
|
|
const defaultAmount = {
|
|
month: 500,
|
|
onetime: 7500
|
|
};
|
|
const defaultDonation = {
|
|
donationAmount: defaultAmount['month'],
|
|
donationDuration: 'month'
|
|
};
|
|
const modalDefaultDonation = {
|
|
donationAmount: 500,
|
|
donationDuration: 'month'
|
|
};
|
|
|
|
const onetimeSKUConfig = {
|
|
live: [
|
|
{ amount: '15000', id: 'sku_IElisJHup0nojP' },
|
|
{ amount: '10000', id: 'sku_IEliodY88lglPk' },
|
|
{ amount: '7500', id: 'sku_IEli9AXW8DwNtT' },
|
|
{ amount: '5000', id: 'sku_IElhJxkNh9UgDp' },
|
|
{ amount: '2500', id: 'sku_IElhQtqLgKZC8y' }
|
|
],
|
|
staging: [
|
|
{ amount: '15000', id: 'sku_IEPNpHACYJmUwz' },
|
|
{ amount: '10000', id: 'sku_IEPMY1OXxnY4WU' },
|
|
{ amount: '7500', id: 'sku_IEPLOotEqlMOWC' },
|
|
{ amount: '5000', id: 'sku_IEPKAxxAxfMnUI' },
|
|
{ amount: '2500', id: 'sku_IEPIgLRzViwq5z' }
|
|
]
|
|
};
|
|
|
|
// Configuration for server side
|
|
const durationKeysConfig = ['month', 'onetime'];
|
|
const donationOneTimeConfig = [100000, 25000, 6000];
|
|
const donationSubscriptionConfig = {
|
|
duration: {
|
|
month: 'Monthly'
|
|
},
|
|
plans: {
|
|
month: [25000, 3500, 500]
|
|
}
|
|
};
|
|
|
|
// Shared paypal configuration
|
|
// keep the 5 dollars for the modal
|
|
const paypalConfigTypes = {
|
|
live: {
|
|
month: {
|
|
500: { planId: 'P-1L11422374370240ULZKX3PA' },
|
|
1000: { planId: 'P-61K21421WY874920PL6E36YI' },
|
|
2000: { planId: 'P-31999436LF709112VL6E374A' },
|
|
3000: { planId: 'P-1KY930839N8045117L6E4BKY' },
|
|
4000: { planId: 'P-0JW4843250567551AL6E4CAI' },
|
|
5000: { planId: 'P-0WR49877YD949401BL6E4CTA' }
|
|
}
|
|
},
|
|
staging: {
|
|
month: {
|
|
500: { planId: 'P-37N14480BW163382FLZYPVMA' },
|
|
1000: { planId: 'P-28B62039J8092810UL6E3FXA' },
|
|
2000: { planId: 'P-7HR706961M9170433L6HI5VI' },
|
|
3000: { planId: 'P-35V33574BU596924JL6HI6XY' },
|
|
4000: { planId: 'P-45M45060289267734L6HJSXA' },
|
|
5000: { planId: 'P-0MD70861FY4172444L6HJTUQ' }
|
|
}
|
|
}
|
|
};
|
|
|
|
const paypalConfigurator = (donationAmount, donationDuration, paypalConfig) => {
|
|
if (donationDuration === 'onetime') {
|
|
return { amount: donationAmount, duration: donationDuration, planId: null };
|
|
}
|
|
return {
|
|
amount: donationAmount,
|
|
duration: donationDuration,
|
|
planId: paypalConfig[donationDuration]['' + donationAmount].planId
|
|
};
|
|
};
|
|
|
|
//
|
|
const donationUrls = {
|
|
successUrl: 'https://www.freecodecamp.org/news/thank-you-for-donating/',
|
|
cancelUrl: 'https://freecodecamp.org/donate'
|
|
};
|
|
|
|
module.exports = {
|
|
durationsConfig,
|
|
amountsConfig,
|
|
defaultAmount,
|
|
defaultDonation,
|
|
durationKeysConfig,
|
|
donationOneTimeConfig,
|
|
donationSubscriptionConfig,
|
|
modalDefaultDonation,
|
|
onetimeSKUConfig,
|
|
paypalConfigTypes,
|
|
paypalConfigurator,
|
|
donationUrls
|
|
};
|