add error toast for card page
This commit is contained in:
parent
2dfc51e9f9
commit
553722a42f
1 changed files with 22 additions and 5 deletions
|
@ -19,9 +19,6 @@ if (STRIPE_PUBLIC_KEY.indexOf('pk_live') > -1) {
|
||||||
stripeEnvironment = 'live';
|
stripeEnvironment = 'live';
|
||||||
}
|
}
|
||||||
|
|
||||||
const APIS_DOWN_ERROR_RESPONSE = __('There was an error from the server, please try again later');
|
|
||||||
const CARD_SETUP_ERROR_RESPONSE = __('There was an error getting your card setup, please try again later');
|
|
||||||
|
|
||||||
// eslint-disable-next-line flowtype/no-types-missing-file-annotation
|
// eslint-disable-next-line flowtype/no-types-missing-file-annotation
|
||||||
type Props = {
|
type Props = {
|
||||||
disabled: boolean,
|
disabled: boolean,
|
||||||
|
@ -60,6 +57,8 @@ class SettingsStripeCard extends React.Component<Props, State> {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
let that = this;
|
let that = this;
|
||||||
|
|
||||||
|
console.log(this.props);
|
||||||
|
|
||||||
let doToast = this.props.doToast;
|
let doToast = this.props.doToast;
|
||||||
|
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
|
@ -101,6 +100,8 @@ class SettingsStripeCard extends React.Component<Props, State> {
|
||||||
let topOfDisplay = customer.email.split('@')[0];
|
let topOfDisplay = customer.email.split('@')[0];
|
||||||
let bottomOfDisplay = '@' + customer.email.split('@')[1];
|
let bottomOfDisplay = '@' + customer.email.split('@')[1];
|
||||||
|
|
||||||
|
console.log(customerStatusResponse.Customer);
|
||||||
|
|
||||||
let cardDetails = {
|
let cardDetails = {
|
||||||
brand: card.brand,
|
brand: card.brand,
|
||||||
expiryYear: card.exp_year,
|
expiryYear: card.exp_year,
|
||||||
|
@ -132,6 +133,8 @@ class SettingsStripeCard extends React.Component<Props, State> {
|
||||||
},
|
},
|
||||||
'post'
|
'post'
|
||||||
).then((customerSetupResponse) => {
|
).then((customerSetupResponse) => {
|
||||||
|
console.log(customerSetupResponse);
|
||||||
|
|
||||||
clientSecret = customerSetupResponse.client_secret;
|
clientSecret = customerSetupResponse.client_secret;
|
||||||
|
|
||||||
// instantiate stripe elements
|
// instantiate stripe elements
|
||||||
|
@ -151,10 +154,14 @@ class SettingsStripeCard extends React.Component<Props, State> {
|
||||||
that.setState({
|
that.setState({
|
||||||
customerTransactions: customerTransactionsResponse,
|
customerTransactions: customerTransactionsResponse,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(customerTransactionsResponse);
|
||||||
});
|
});
|
||||||
// if the status call fails, either an actual error or need to run setup first
|
// if the status call fails, either an actual error or need to run setup first
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
|
console.log(error);
|
||||||
|
|
||||||
// errorString passed from the API (with a 403 error)
|
// errorString passed from the API (with a 403 error)
|
||||||
const errorString = 'user as customer is not setup yet';
|
const errorString = 'user as customer is not setup yet';
|
||||||
|
|
||||||
|
@ -174,6 +181,8 @@ class SettingsStripeCard extends React.Component<Props, State> {
|
||||||
},
|
},
|
||||||
'post'
|
'post'
|
||||||
).then((customerSetupResponse) => {
|
).then((customerSetupResponse) => {
|
||||||
|
console.log(customerSetupResponse);
|
||||||
|
|
||||||
clientSecret = customerSetupResponse.client_secret;
|
clientSecret = customerSetupResponse.client_secret;
|
||||||
|
|
||||||
// instantiate stripe elements
|
// instantiate stripe elements
|
||||||
|
@ -181,10 +190,14 @@ class SettingsStripeCard extends React.Component<Props, State> {
|
||||||
});
|
});
|
||||||
// 500 error from the backend being down
|
// 500 error from the backend being down
|
||||||
} else if (error === 'internal_apis_down') {
|
} else if (error === 'internal_apis_down') {
|
||||||
doToast({ message: APIS_DOWN_ERROR_RESPONSE, isError: true });
|
var displayString = 'There was an error from the server, please let support know';
|
||||||
|
doToast({ message: displayString, isError: true });
|
||||||
} else {
|
} else {
|
||||||
// probably an error from stripe
|
// probably an error from stripe
|
||||||
doToast({ message: CARD_SETUP_ERROR_RESPONSE, isError: true });
|
var displayString = 'There was an error getting your card setup, please let support know';
|
||||||
|
doToast({ message: displayString, isError: true });
|
||||||
|
|
||||||
|
console.log('Unseen before error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 250);
|
}, 250);
|
||||||
|
@ -253,6 +266,8 @@ class SettingsStripeCard extends React.Component<Props, State> {
|
||||||
})
|
})
|
||||||
.then(function (result) {
|
.then(function (result) {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
|
console.log(result);
|
||||||
|
|
||||||
changeLoadingState(false);
|
changeLoadingState(false);
|
||||||
var displayError = document.getElementById('card-errors');
|
var displayError = document.getElementById('card-errors');
|
||||||
displayError.textContent = result.error.message;
|
displayError.textContent = result.error.message;
|
||||||
|
@ -336,6 +351,8 @@ class SettingsStripeCard extends React.Component<Props, State> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(result);
|
||||||
|
|
||||||
changeLoadingState(false);
|
changeLoadingState(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue