fix(donate): handle missing stripe keys (#37847)
* fix: gracefully handle missing stripe keys * fix: remove state updates from render (donate)
This commit is contained in:
committed by
mrugesh
parent
81bb677def
commit
c660b389a8
@ -51,6 +51,19 @@ exports.createPages = function createPages({ graphql, actions, reporter }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!env.stripePublicKey || !env.servicebotId) {
|
||||||
|
if (process.env.FREECODECAMP_NODE_ENV === 'production') {
|
||||||
|
throw new Error(
|
||||||
|
'Stripe public key and Servicebot id are required to start the client!'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
reporter.info(
|
||||||
|
'Stripe public key or Servicebot id missing or invalid. Required for' +
|
||||||
|
' donations.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
const { createPage } = actions;
|
const { createPage } = actions;
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -60,6 +60,7 @@ class DonateFormChildViewForHOC extends Component {
|
|||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
this.postDonation = this.postDonation.bind(this);
|
this.postDonation = this.postDonation.bind(this);
|
||||||
this.resetDonation = this.resetDonation.bind(this);
|
this.resetDonation = this.resetDonation.bind(this);
|
||||||
|
this.hideAmountOptions(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserEmail() {
|
getUserEmail() {
|
||||||
@ -226,7 +227,6 @@ class DonateFormChildViewForHOC extends Component {
|
|||||||
reset: this.resetDonation
|
reset: this.resetDonation
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.hideAmountOptions(false);
|
|
||||||
return this.renderDonateForm();
|
return this.renderDonateForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,11 +61,12 @@ export class DonatePage extends Component {
|
|||||||
|
|
||||||
handleStripeLoad() {
|
handleStripeLoad() {
|
||||||
// Create Stripe instance once Stripe.js loads
|
// Create Stripe instance once Stripe.js loads
|
||||||
console.info('stripe has loaded');
|
if (stripePublicKey) {
|
||||||
this.setState(state => ({
|
this.setState(state => ({
|
||||||
...state,
|
...state,
|
||||||
stripe: window.Stripe(stripePublicKey)
|
stripe: window.Stripe(stripePublicKey)
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enableDonationSettingsPage(enableSettings = true) {
|
enableDonationSettingsPage(enableSettings = true) {
|
||||||
|
@ -30,8 +30,14 @@ const locations = {
|
|||||||
|
|
||||||
module.exports = Object.assign(locations, {
|
module.exports = Object.assign(locations, {
|
||||||
locale,
|
locale,
|
||||||
stripePublicKey,
|
stripePublicKey:
|
||||||
servicebotId,
|
!stripePublicKey || stripePublicKey === 'pk_from_stripe_dashboard'
|
||||||
|
? null
|
||||||
|
: stripePublicKey,
|
||||||
|
servicebotId:
|
||||||
|
!servicebotId || servicebotId === 'servicebot_id_from_servicebot_dashboard'
|
||||||
|
? null
|
||||||
|
: servicebotId,
|
||||||
algoliaAppId:
|
algoliaAppId:
|
||||||
!algoliaAppId || algoliaAppId === 'Algolia app id from dashboard'
|
!algoliaAppId || algoliaAppId === 'Algolia app id from dashboard'
|
||||||
? null
|
? null
|
||||||
|
Reference in New Issue
Block a user