#redapse

1 messages · Page 1 of 1 (latest)

marble turretBOT
humble root
#

Hello 👋
Can you walk me through your logic of rendering elements? What happens first? Do you make a fetch the SetupIntent and then initialise elements? What error are you getting?

reef orbit
#

Hello hanzo, thanks for the reply

#

sure, so stripe gets initialized via the publishable key, then from the browser I request from our API to build a new SetupIntent. That SetupIntent is returned to the browser. I use that SetupIntent to build options that I feed into stripe.elements()

After that I create the 'payment' element and mount it

humble root
#

I see.
What error are you getting?

reef orbit
humble root
#

huh are you sure that's coming from Stripe.js?
Is this page public? If so, would you be able to share the URL?

reef orbit
#

yes, it's coming from the controller js script that stripe loads

#

here's a codepen, but you need to insert a brand new SetupIntent

#

if I wait say 5 seconds, it works, but... thats no fun

humble root
#

hmm your code looks fine tbh

#

It loaded right away for me

reef orbit
#

yep exactly. I just wonder if the SetupIntent needs to be like X number of seconds old before it will process correctly on Stripe's side

#

is this plausible

#

I wonder if the setupintent storage is decoupled from the API the stripe.js elements use

humble root
#

I've not heard of any similar cases before. It is possible that your API might be a little slow to respond with SetupIntent clientSecret.

reef orbit
#

nah it's waiting to initialize the rest of the stripe JS code AFTER the browser receives from my API the SetupIntent

#

so my API can take as long as it wants to, because only after the browser gets it does it start the elements process

#

But if I throw a delay between when I generate the SetupIntent say of 5 seconds, and then I try to create the element, it works

humble root
#

When you rest of the Stripe JS code, does it also include following?

stripe = window.Stripe("pk_test_xxx")

reef orbit
#

but this seems fragile

#

not sure what you mean

humble root
#

Are you intializing Stripe with public key, before or after retrieving the SetupIntent?
We usually recommend you initialise it as soon as the page loads.

reef orbit
#

it's being initialized before the setupintent is being retrieved from your API

humble root
#

also does the behavior change if you move following tag before <form> tag?

<script src="https://js.stripe.com/v3/">

I noticed you're not using defer keyword

reef orbit
#

no change moving the script or adding defer

#

I wonder if there are background processes happening at Stripe and SetupIntents just need to be a few seconds old before doing anything with them

#

if that's the case I can work around it, I just would rather like to know and build in better safeguards against a SetupIntent being too young

#

or does stripe.js (and initialized) need to be loaded on the page for like 5 seconds or something

humble root
#

I don't think its that.
Have you tried using a different browser?

reef orbit
#

OK I did try it in Firefox without the delay, and surprisingly I cannot reproduce the error

Any way to file a chrome bug with the stripe team or something

#

idk if it's possible to disable fingerprinting or something until this is fixed

humble root
#

Hmm what chrome version are you running?

reef orbit
#

Version 109.0.5414.61 (Official Build) beta (64-bit)

humble root
#

Might be something with the beta version?
Would you mind trying on the stable version/official build?

reef orbit
#

looks like it's due to the version I'm on, yep

#

Still probably want to track this though, you don't want the new version of Chrome to break ya stuff

humble root
#

Sure thing!

reef orbit
#

if you could pass on any sort of issue tracker # or what not I would appreciate it. thanks for your help

humble root
#

We don't have an issue tracker as such. You can write in to our support team and they should be able to create a ticket for this in case you want to follow up

https://support.stripe.com/?contact=true