diff --git a/client/src/components/Donation/DonateForm.js b/client/src/components/Donation/DonateForm.js index dcdd8348cd..5d22056442 100644 --- a/client/src/components/Donation/DonateForm.js +++ b/client/src/components/Donation/DonateForm.js @@ -233,7 +233,7 @@ class DonateForm extends Component { render() { const { donationAmount, donationDuration } = this.state; - const { handleProcessing } = this.props; + const { handleProcessing, isSignedIn } = this.props; const { donationState: { processing, success, error } } = this.state; @@ -268,6 +268,7 @@ class DonateForm extends Component { donationDuration={donationDuration} handleProcessing={handleProcessing} onDonationStateChange={this.onDonationStateChange} + skipAddDonation={!isSignedIn} /> diff --git a/client/src/components/Donation/PaypalButton.js b/client/src/components/Donation/PaypalButton.js index fd39f35db9..8503d043df 100644 --- a/client/src/components/Donation/PaypalButton.js +++ b/client/src/components/Donation/PaypalButton.js @@ -33,27 +33,39 @@ export class PaypalButton extends Component { handleApproval = data => { const { amount, duration } = this.state; - this.props.handleProcessing(duration, amount, 'Paypal payment submission'); - this.props.onDonationStateChange(false, true, ''); - verifySubscriptionPaypal(data) - .then(response => { - const data = response && response.data; - this.props.onDonationStateChange( - true, - false, - data.error ? data.error : '' - ); - }) - .catch(error => { - const data = - error.response && error.response.data - ? error.response.data - : { - error: - 'Something is not right. Please contact team@freecodecamp.org' - }; - this.props.onDonationStateChange(false, false, data.error); - }); + const { skipAddDonation = false } = this.props; + if (!skipAddDonation) { + this.props.handleProcessing( + duration, + amount, + 'Paypal payment submission' + ); + this.props.onDonationStateChange(false, true, ''); + verifySubscriptionPaypal(data) + .then(response => { + const data = response && response.data; + this.props.onDonationStateChange( + true, + false, + data.error ? data.error : '' + ); + }) + .catch(error => { + const data = + error.response && error.response.data + ? error.response.data + : { + error: `Something is not right. Please contact team@freecodecamp.org` + }; + this.props.onDonationStateChange(false, false, data.error); + }); + } else { + this.props.onDonationStateChange( + true, + false, + data.error ? data.error : '' + ); + } }; render() { @@ -101,7 +113,8 @@ const propTypes = { donationDuration: PropTypes.string, handleProcessing: PropTypes.func, isDonating: PropTypes.bool, - onDonationStateChange: PropTypes.func + onDonationStateChange: PropTypes.func, + skipAddDonation: PropTypes.bool }; const mapStateToProps = createSelector(