freeCodeCamp/config/donation-settings.js

111 lines
2.4 KiB
JavaScript
Raw Normal View History

2020-03-17 15:46:08 +00:00
const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
// Configuration for client side
const durationsConfig = {
year: 'yearly',
2020-03-20 06:12:57 +00:00
// month: 'monthly', // We have disabled montly payments
onetime: 'one-time'
};
const amountsConfig = {
year: [100000, 25000, 6000],
2020-03-20 06:12:57 +00:00
month: [5000, 3500, 500],
onetime: [100000, 25000, 6000]
};
const defaultAmount = {
year: 6000,
2019-12-20 10:44:16 +00:00
month: 3500,
onetime: 25000
};
const defaultStateConfig = {
donationAmount: defaultAmount['year'],
donationDuration: 'year'
};
2019-12-20 10:44:16 +00:00
const modalDefaultStateConfig = {
donationAmount: 6000,
donationDuration: 'year'
2019-12-20 10:44:16 +00:00
};
// Configuration for server side
const durationKeysConfig = ['year', 'month', 'onetime'];
2020-03-20 06:12:57 +00:00
const donationOneTimeConfig = [100000, 25000, 6000];
const donationSubscriptionConfig = {
duration: {
year: 'Yearly',
month: 'Monthly'
},
plans: {
2020-03-20 06:12:57 +00:00
year: [100000, 25000, 6000],
month: [5000, 3500, 500]
}
};
2020-03-13 09:25:57 +00:00
// Shared paypal configuration
const paypalConfigTypes = {
live: {
month: {
'500': {
planId: 'P-1L11422374370240ULZKX3PA'
}
},
year: {
'6000': {
planId: 'P-9Y661558DW462253NLZZ2IMQ'
},
'25000': {
planId: 'P-3NN39392MK1889318LZZ2KQY'
},
'100000': {
planId: 'P-7YN43286C4599382LLZZ2JUI'
2020-03-13 09:25:57 +00:00
}
}
},
staging: {
month: {
'500': {
planId: 'P-37N14480BW163382FLZYPVMA'
}
},
year: {
'6000': {
planId: 'P-0UY77185EM3077131LZYP6VY'
2020-03-17 15:46:08 +00:00
},
'25000': {
planId: 'P-7K1585908S634694XLZZTHUQ'
},
'100000': {
planId: 'P-0J5231134H608574XLZZTDLQ'
2020-03-13 09:25:57 +00:00
}
}
}
};
2020-03-17 15:46:08 +00:00
const paypalConfig =
process.env.DEPLOYMENT_ENV && process.env.DEPLOYMENT_ENV === 'live'
? paypalConfigTypes['live']
: paypalConfigTypes['staging'];
const paypalConfigurator = (donationAmount, donationDuration) => {
if (donationDuration === 'onetime') {
return { amount: donationAmount, duration: donationDuration };
}
return {
amount: donationAmount,
duration: donationDuration,
planId: paypalConfig[donationDuration]['' + donationAmount].planId
};
};
module.exports = {
durationsConfig,
amountsConfig,
defaultAmount,
defaultStateConfig,
durationKeysConfig,
donationOneTimeConfig,
2019-12-20 10:44:16 +00:00
donationSubscriptionConfig,
2020-03-13 09:25:57 +00:00
modalDefaultStateConfig,
paypalConfig,
paypalConfigurator
};