fix(client): update logic for non-signedin users

This commit is contained in:
Mrugesh Mohapatra
2020-04-25 00:00:43 +05:30
parent a45df11de1
commit d866766223

View File

@ -35,10 +35,17 @@ export class PaypalButton extends Component {
return { ...configurationObj }; return { ...configurationObj };
} }
handleApproval = data => { handleApproval = (data, isSubscription) => {
const { amount, duration } = this.state; const { amount, duration } = this.state;
const { skipAddDonation = false } = this.props; 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( this.props.handleProcessing(
duration, duration,
amount, amount,
@ -63,12 +70,6 @@ export class PaypalButton extends Component {
}; };
this.props.onDonationStateChange(false, false, data.error); 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} isSubscription={isSubscription}
on={true}
onApprove={data => { onApprove={data => {
this.handleApproval(data); this.handleApproval(data, isSubscription);
}} }}
onCancel={() => { onCancel={() => {
this.props.onDonationStateChange( this.props.onDonationStateChange(