Skip to content

Instantly share code, notes, and snippets.

@ahmaxed
Created March 20, 2020 01:38
Show Gist options
  • Save ahmaxed/c5039387839f03bf262ce80bd0261866 to your computer and use it in GitHub Desktop.
Save ahmaxed/c5039387839f03bf262ce80bd0261866 to your computer and use it in GitHub Desktop.
render() {
const { amount, duration, planId } = this.state;
const isOneTimePayment = duration === "onetime";
if (!isOneTimePayment) {
return (
<PayPalButton
createSubscription={(data, actions) => {
return actions.subscription.create({
plan_id: planId
});
}}
onApprove={data => {
this.handleApproval(data);
}}
onCancel={() => {
this.props.onDonationStateChange(
false,
false,
"Payment has been canceled."
);
}}
onError={() =>
this.props.onDonationStateChange(false, false, "Please try again.")
}
options={{
vault: true,
disableFunding: "card",
clientId: paypalClientId
}}
style={{
tagline: false,
height: 43
}}
/>
);
} else return "";
return (
<PayPalButton
amount={amount}
onApprove={data => {
this.handleApproval(data);
}}
onCancel={() => {
this.props.onDonationStateChange(
false,
false,
'Payment has been canceled.'
);
}}
onError={() =>
this.props.onDonationStateChange(false, false, 'Please try again.')
}
options={{
vault: true,
disableFunding: 'card',
clientId: paypalClientId
}}
style={{
tagline: false,
height: 43
}}
/>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment