diff --git a/api-server/server/boot/donate.js b/api-server/server/boot/donate.js index 33e2c80fcc..a3788bca81 100644 --- a/api-server/server/boot/donate.js +++ b/api-server/server/boot/donate.js @@ -1,6 +1,5 @@ import Stripe from 'stripe'; import debug from 'debug'; -import crypto from 'crypto'; import { isEmail, isNumeric } from 'validator'; import { @@ -223,45 +222,6 @@ export default function donateBoot(app, done) { }); } - function createHmacHash(req, res) { - const { user, body } = req; - - if (!user || !body) { - return res - .status(500) - .send({ error: 'User must be signed in for this request.' }); - } - - const { email } = body; - - if (!isEmail('' + email)) { - return res - .status(500) - .send({ error: 'The email is invalid for this request.' }); - } - - if (!user.donationEmails.includes(email)) { - return res.status(500).send({ - error: `User does not have the email: ${email} associated with their donations.` - }); - } - - log(`creating HMAC hash for ${email}`); - return Promise.resolve(email) - .then(email => - crypto - .createHmac('sha256', keys.servicebot.hmacKey) - .update(email) - .digest('hex') - ) - .then(hash => res.status(200).json({ hash })) - .catch(() => - res - .status(500) - .send({ error: 'Donation failed due to a server error.' }) - ); - } - function addDonation(req, res) { const { user, body } = req; @@ -304,7 +264,6 @@ export default function donateBoot(app, done) { const secKey = keys.stripe.secret; const paypalKey = keys.paypal.client; const paypalSec = keys.paypal.secret; - const hmacKey = keys.servicebot.hmacKey; const stripeSecretInvalid = !secKey || secKey === 'sk_from_stripe_dashboard'; const stripPublicInvalid = !stripeKey || stripeKey === 'pk_from_stripe_dashboard'; @@ -313,12 +272,11 @@ export default function donateBoot(app, done) { !paypalKey || paypalKey === 'id_from_paypal_dashboard'; const paypalPublicInvalid = !paypalSec || paypalSec === 'secret_from_paypal_dashboard'; - const hmacKeyInvalid = - !hmacKey || hmacKey === 'secret_key_from_servicebot_dashboard'; + const paypalInvalid = paypalPublicInvalid || paypalSecretInvalid; const stripeInvalid = stripeSecretInvalid || stripPublicInvalid; - if (stripeInvalid || paypalInvalid || hmacKeyInvalid) { + if (stripeInvalid || paypalInvalid) { if (process.env.FREECODECAMP_NODE_ENV === 'production') { throw new Error('Donation API keys are required to boot the server!'); } @@ -326,7 +284,6 @@ export default function donateBoot(app, done) { done(); } else { api.post('/charge-stripe', createStripeDonation); - api.post('/create-hmac-hash', createHmacHash); api.post('/add-donation', addDonation); hooks.post('/update-paypal', updatePaypal); donateRouter.use('/donate', api); diff --git a/client/gatsby-node.js b/client/gatsby-node.js index 270ed7da40..aa356dc1a3 100644 --- a/client/gatsby-node.js +++ b/client/gatsby-node.js @@ -52,15 +52,12 @@ exports.createPages = function createPages({ graphql, actions, reporter }) { } } - if (!env.stripePublicKey || !env.servicebotId) { + if (!env.stripePublicKey) { if (process.env.FREECODECAMP_NODE_ENV === 'production') { - throw new Error( - 'Stripe public key and Servicebot id are required to start the client!' - ); + throw new Error('Stripe public key is required to start the client!'); } else { reporter.info( - 'Stripe public key or Servicebot id missing or invalid. Required for' + - ' donations.' + 'Stripe public key missing or invalid. Required for donations.' ); } } diff --git a/client/src/components/Donation/Donation.css b/client/src/components/Donation/Donation.css index 34d0fbc4d5..90a84f3e68 100644 --- a/client/src/components/Donation/Donation.css +++ b/client/src/components/Donation/Donation.css @@ -177,9 +177,6 @@ li.disabled > a { [name='payment-method'] { font-family: 'Lato', sans-serif; } -.servicebot-embed-panel .panel { - padding: 20px; -} @media (max-width: 991px) { .donate-text { diff --git a/client/src/utils/ajax.js b/client/src/utils/ajax.js index 13be9430c9..091a8c1f55 100644 --- a/client/src/utils/ajax.js +++ b/client/src/utils/ajax.js @@ -66,10 +66,6 @@ export function verifySubscriptionPaypal(body) { return post('/donate/add-donation', body); } -export function postCreateHmacHash(body) { - return post(`/donate/create-hmac-hash`, body); -} - export function putUpdateLegacyCert(body) { return post('/update-my-projects', body); } diff --git a/client/src/utils/scriptLoaders.js b/client/src/utils/scriptLoaders.js index 404db62234..c343fe9958 100644 --- a/client/src/utils/scriptLoaders.js +++ b/client/src/utils/scriptLoaders.js @@ -26,14 +26,6 @@ export const stripeScriptLoader = onload => onload ); -export const servicebotScriptLoader = () => - scriptLoader( - 'servicebot-billing-settings-embed.js', - 'servicebot-billing-settings-embed.js', - true, - 'https://js.servicebot.io/embeds/servicebot-billing-settings-embed.js' - ); - export const mathJaxScriptLoader = () => scriptLoader( 'mathjax', diff --git a/config/env.js b/config/env.js index a11ed84645..dbfe80155d 100644 --- a/config/env.js +++ b/config/env.js @@ -16,7 +16,6 @@ const { NEWS_LOCATION: news, LOCALE: locale, STRIPE_PUBLIC_KEY: stripePublicKey, - SERVICEBOT_ID: servicebotId, ALGOLIA_APP_ID: algoliaAppId, ALGOLIA_API_KEY: algoliaAPIKey, PAYPAL_CLIENT_ID: paypalClientId, @@ -38,10 +37,6 @@ module.exports = Object.assign(locations, { !stripePublicKey || stripePublicKey === 'pk_from_stripe_dashboard' ? null : stripePublicKey, - servicebotId: - !servicebotId || servicebotId === 'servicebot_id_from_servicebot_dashboard' - ? null - : servicebotId, algoliaAppId: !algoliaAppId || algoliaAppId === 'Algolia app id from dashboard' ? null diff --git a/config/secrets.js b/config/secrets.js index bd28a5d1f8..d8b38810b8 100644 --- a/config/secrets.js +++ b/config/secrets.js @@ -31,9 +31,6 @@ const { STRIPE_PUBLIC_KEY, STRIPE_SECRET_KEY, - SERVICEBOT_ID, - - SERVICEBOT_HMAC_SECRET_KEY, PAYPAL_CLIENT_ID, PAYPAL_SECRET, @@ -109,10 +106,5 @@ module.exports = { verifyWebhookURL: PAYPAL_VERIFY_WEBHOOK_URL, tokenUrl: PAYPAL_API_TOKEN_URL, webhookId: PAYPAL_WEBHOOK_ID - }, - - servicebot: { - servicebotId: SERVICEBOT_ID, - hmacKey: SERVICEBOT_HMAC_SECRET_KEY } }; diff --git a/sample.env b/sample.env index 89747ffcfb..62a8701e93 100644 --- a/sample.env +++ b/sample.env @@ -35,8 +35,6 @@ ALGOLIA_API_KEY=api_key_from_algolia_dashboard STRIPE_CREATE_PLANS=true STRIPE_PUBLIC_KEY=pk_from_stripe_dashboard STRIPE_SECRET_KEY=sk_from_stripe_dashboard -SERVICEBOT_ID=servicebot_id_from_servicebot_dashboard -SERVICEBOT_HMAC_SECRET_KEY=secret_key_from_servicebot_dashboard # PayPal PAYPAL_SUPPORTERS=1703 PAYPAL_CLIENT_ID=id_from_paypal_dashboard