Im trying to capture any card errors on stripe elements
Right now I load the stripe element
<div id="card-element" class="form-control" style='height: 2.6em; padding-top: .7em;'>
</div>
<!-- Used to display form errors. -->
<div id="card-errors" class="text-danger text-center" style="font-size: 15px" role="alert"></div>
Then on the mounted hook, I load the method
this.includeStripe('js.stripe.com/v3/', function(){
this.configureStripe();
}.bind(this) );
and then within that method, I load the element and also add a change event to capture errors
configureStripe(){
this.stripe = Stripe( this.stripeAPIToken );
this.elements = this.stripe.elements();
this.card = this.elements.create('card');
this.card.mount('#card-element');
this.card.addEventListener('change', event => {
var displayError = document.getElementById('card-errors');
if (event.error) {
displayError.textContent = event.error.message;
} else {
displayError.textContent = '';
}
});
},
Right now any failing errors, card declined etc do not show but can see the network returns. Any ideas would be welcomed