#honkotonk
1 messages · Page 1 of 1 (latest)
Hi there
You are asking how you can catch an invalid Stripe initialization client-side?
Correct
Hmm and you are saying that you can't handle this in your catch block because you see the error come from Stripe.JS itself?
Like i said i can catch the initial Setupintend, but the API key is getting sent later to Stripe and that i cannot catch
Well it gets returned as an error message from Stripe and i would like to catch that and publish in an error message container inside the app
here you can see the message I'm talking about
How are you initializing Stripe.JS?
If you wrap your stripe initialization in a try/catch you should be able to catch this
Like this:
try { stripe = Stripe(Config.stripe_test_clientid); } catch (error) { BBB.renderMessages({ "error": [error.message] }); }
Hmm actually yeah maybe not
Are you creating a plugin?
Just curious why there would potentially be an incorrect publishable key set to begin with
Well you know our stuff is getting testet in an CI/CD pipline in the cloud and there almost every scenario gets checked. If an error like this is not catched the tests always fails.
Sure. Thanks.
Are you trying to use Payment Element here?
Yes
Can you try catching using loaderror: https://stripe.com/docs/js/element/events/on_loaderror
Works! Would have never found that one. Thanks!