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 };
}
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(