Skip to content

Allow for an onClick property to be run before opening the checkout #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions StripeCheckout.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class ReactStripeCheckout extends React.Component {
showLoadingDialog: React.PropTypes.func,
// Hide the loading indicator
hideLoadingDialog: React.PropTypes.func,

// Run this method when the scrupt fails to load. Will run if the internet
// connection is offline when attemting to load the script.
onScriptError: React.PropTypes.func,
Expand All @@ -72,7 +72,12 @@ export default class ReactStripeCheckout extends React.Component {
// Your publishable key (test or live).
// can't use "key" as a prop in react, so have to change the keyname
stripeKey: React.PropTypes.string.isRequired,


// Run this method when you want some behaviour before opening stripe
// checkout. If this method returns false, it will prevent the checkout
// from opening.
onClick: React.PropTypes.func,

// The callback to invoke when the Checkout process is complete.
// function(token)
// token is the token object created.
Expand Down Expand Up @@ -343,6 +348,10 @@ export default class ReactStripeCheckout extends React.Component {
if (this.props.disabled) {
return;
}

if (this.props.onClick && !this.props.onClick()) {
return;
}

if (scriptDidError) {
try {
Expand Down