#honkotonk

1 messages · Page 1 of 1 (latest)

shrewd depotBOT
flint peak
#

Hi there

#

You are asking how you can catch an invalid Stripe initialization client-side?

empty grove
#

Correct

flint peak
#

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?

empty grove
#

Like i said i can catch the initial Setupintend, but the API key is getting sent later to Stripe and that i cannot catch

flint peak
#

What is the use-case here?

#

Why do you want to catch an incorrect publishable key?

empty grove
#

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

flint peak
#

How are you initializing Stripe.JS?

empty grove
flint peak
#

If you wrap your stripe initialization in a try/catch you should be able to catch this

empty grove
#

Like this:
try { stripe = Stripe(Config.stripe_test_clientid); } catch (error) { BBB.renderMessages({ "error": [error.message] }); }

flint peak
#

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

empty grove
#

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.

flint peak
#

Hmm okay

#

Give me a moment to check further

empty grove
#

Sure. Thanks.

flint peak
#

Are you trying to use Payment Element here?

empty grove
#

Yes

flint peak
empty grove
#

Works! Would have never found that one. Thanks!