#poczikdavid
1 messages ยท Page 1 of 1 (latest)
Hi! Let me help you with this.
Hi, thanks in advance
Yes, you can listen to "change" events: https://stripe.com/docs/js/element/input_validation
What version of Stripe.js are you using?
The latest version is 1.54.0. Could you try updating it? https://www.npmjs.com/package/@stripe/stripe-js
That's an Address Element by the way.
Could you listen for changes in the Payment Element?
i could but i wan to listen to every input element of the form.
so
addressElement
authenticationElement
paymentElement
okok
Do you see the error if you listen to paymentElement?
give me a sec, i'll try
change is not working with paymentElement
it works with authentication and addressElement
and i upgraded the stripejs package
What do you mean it's not working?
i mean change event is not triggered for paymentElement
Could you please share the code?
What are you getting back when do:
console.log(this.stripeElements.getElement("payment"));
console.log(this.stripeElements.getElement("authentication"));
console.log(this.stripeElements.getElement("address"));
๐ taking over for my colleague. Let me catch up.
hi, thanks
I'm not really sure I understand what's the issue here
im trying to get access to stripe form input validation error messages
and push them to google analytics data layer
but right now i cannot access the error messages on validation
I just saw it
the problem is in this callback
console.log(event);
console.log(this.stripeElements.getElement("payment"));
console.log(this.stripeElements.getElement("authentication"));
console.log(this.stripeElements.getElement("address"));
}
even though you're trying to bind the function with the this, I think there's something wrong with that
a better way of achieving what you want
is to create the callback as an arrow function
and remove the bind
something like
const eventCallback = (event)=> {
console.log(event);
console.log(this.stripeElements.getElement("payment"));
console.log(this.stripeElements.getElement("authentication"));
console.log(this.stripeElements.getElement("address"));
}
this.addressElement = this.elements.create(this.fields.address.name, this.fields.address.options);
this.authenticationElement = this.elements.create(this.fields.authentication.name, this.fields.authentication.options);
this.paymentElement = this.elements.create(this.fields.payment.name, this.fields.payment.options);
this.addressElement.on('change', (e)=> eventCallback(e));
this.authenticationElement.on('change', (e)=> eventCallback(e));
this.paymentElement.on('change', (e)=> eventCallback(e));
try this out
is it a self-signed certificate?
yes
don't use an SSL certificate on test mode https://stripe.com/docs/security/guide#:~:text=If need be%2C you can test your integration without using HTTPS%2C and enable it once youโre ready to accept live charges. However%2C all interactions between your server and Stripe must use TLS 1.2 (i.e%2C when using our libraries).
okok thanks for the help