fix(client): update logic for non-signedin users
This commit is contained in:
@ -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(
|
||||||
|
Reference in New Issue
Block a user