handle credit card script failure

This commit is contained in:
Sean Yesmunt 2020-02-04 23:47:23 -05:00
parent 2c36a0642d
commit 574ac1f566

View file

@ -37,6 +37,7 @@ class CardVerify extends React.Component {
super(props); super(props);
this.state = { this.state = {
open: false, open: false,
scriptFailedToLoad: false,
}; };
} }
@ -117,7 +118,7 @@ class CardVerify extends React.Component {
}; };
onScriptError = (...args) => { onScriptError = (...args) => {
throw new Error('Unable to load credit validation script.'); this.setState({ scriptFailedToLoad: true });
}; };
onClosed = () => { onClosed = () => {
@ -159,13 +160,21 @@ class CardVerify extends React.Component {
}; };
render() { render() {
const { scriptFailedToLoad } = this.props;
return ( return (
<Button <div>
button="primary" {scriptFailedToLoad && (
label={this.props.label} <div className="error-text">There was an error connecting to Stripe. Please try again later.</div>
disabled={this.props.disabled || this.state.open || this.hasPendingClick} )}
onClick={this.onClick.bind(this)}
/> <Button
button="primary"
label={this.props.label}
disabled={this.props.disabled || this.state.open || this.hasPendingClick}
onClick={this.onClick.bind(this)}
/>
</div>
); );
} }
} }