fix(donate): remove call to verification when not signed in

This commit is contained in:
Mrugesh Mohapatra
2020-03-20 13:07:02 +05:30
parent 08ec29fa1b
commit 8866ed74c2
2 changed files with 37 additions and 23 deletions

View File

@@ -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(