Created
March 20, 2020 01:38
-
-
Save ahmaxed/c5039387839f03bf262ce80bd0261866 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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