diff --git a/client/src/components/Donation/PaypalButton.js b/client/src/components/Donation/PaypalButton.js index baa7a65ce5..230d2fb30e 100644 --- a/client/src/components/Donation/PaypalButton.js +++ b/client/src/components/Donation/PaypalButton.js @@ -35,10 +35,17 @@ export class PaypalButton extends Component { return { ...configurationObj }; } - handleApproval = data => { + handleApproval = (data, isSubscription) => { const { amount, duration } = this.state; const { skipAddDonation = false } = this.props; - if (!skipAddDonation || duration === 'oneTime') { + // Skip the api if user is not signed in or if its a one-time donation + if (skipAddDonation || !isSubscription) { + this.props.onDonationStateChange( + true, + false, + data.error ? data.error : '' + ); + } else { this.props.handleProcessing( duration, amount, @@ -63,12 +70,6 @@ export class PaypalButton extends Component { }; this.props.onDonationStateChange(false, false, data.error); }); - } else { - this.props.onDonationStateChange( - true, - false, - data.error ? data.error : '' - ); } }; @@ -97,9 +98,8 @@ export class PaypalButton extends Component { }); }} isSubscription={isSubscription} - on={true} onApprove={data => { - this.handleApproval(data); + this.handleApproval(data, isSubscription); }} onCancel={() => { this.props.onDonationStateChange(