#Empress Brosephine-stripejs-cardelement
1 messages ยท Page 1 of 1 (latest)
Thanks!
can you clarify what error you're getting? didn't see an error msg or a stack trace etc
so I think its just not picking up the CardElement
got it to actually give me a full error
let's start small, CardElement is rendering fine, right?
before pressing any button, when it is rendered, can you open your browser console and get a reference to that <div> by doing what you're doing at line elements.getElement(...) and see if that by itself works
thanks for the help.
so the card element is rendering fine yeah, trying to get a reference to it though doesn't return anything
ok so that helps. What happens when you log out elements in your console? I'm guessing it returns undefined ?
yeah, elements is not defined
{clientSecret && (
<Elements options={options} stripe={stripePromise}>
<RegistrationForm selected={selected} details={details} clientSecret = {clientSecret} id={customerId}/>
</Elements>
)}
thats the call to the form
ah React, not my strongest suite so bear with me while I wrap my head around this
no worries and I appreciate all the help
if it helps, this is for the stripe certification ๐
so I changed elements.getElement(CardElement) to just CardElement and I got this
ok...so it looks like the setupIntent is actually working just it "crashes" right after for some odd reason
Can you try using elements.getElement('card')?
I am looking through things and testing myself but from the Javascript SDK reference, it looks like that function is just expecting a string https://stripe.com/docs/js/elements_object/get_element#elements_get_element-type
And it links to our create function where we define type the same way and demonstrate passing 'card' in to it
let me try that!
negative, still produces a "undefined has no properties" error
it seems to make the object / request / whatever but then causees a error for some odd reason lol
reserveLesson RegistrationForm.js:70
React 17
unstable_runWithPriority scheduler.development.js:653
React 15
unstable_runWithPriority scheduler.development.js:653
React 26
js index.js:8```
Can you send me the ID of a setup intent that you used here? I can check in to if we can see the confirm on our side
Spinning up my test react project to try this myself...
sweet thanks, yeah one moment
https://stripe.com/docs/js/setup_intents/payment_method?type=card
stripe.confirmCardSetup is what I was using
@surreal girder its very weird...like I can get it to make the session but something after crashes it lol
https://codesandbox.io/s/stoic-almeida-metxe6?file=/src/RegistrationForm.js
I uploaded the two files im working with here if you need to see. Its Lessons.js & RegistrationForm.js
Thank you. I was about to ask for more code, I was able to make this call successfully using
stripe.confirmCardSetup(
clientSecret,
{
payment_method: {
card: elements.getElement(CardElement),
billing_details: {
name: 'Named person',
},
},
}
).then(function(result) {
if (result.error) {
// Display error.message in your UI.
console.log(result.error)
} else {
console.log(result)
// The setup has succeeded. Display a success message.
}
});```
let me try that
hmmmmmmm same thing
maybe some kind of error in the stripe boilerplate provided for the test?
@serene echo do you have an end to end reproduction I can look at?
I can upload it, one second
@potent karma do you have a gitusername I can give access too? if not I can make it public
I have a feeling this is going to be really stupid on my end lmao
unfortunately no. And I don't want to see git
I want to see a live page with the exact bug
or a reproduction of the bug on a page somewhere like jsfiddle or codesandbox
Oh uh I don't think you can publish the stripe boilerplate test I think it was in the rules
@potent karma https://codesandbox.io/s/github/thomaslanenh/gitchal
See if this works
not sure what I am supposed to look at
where am I supposed to click to see the live behaviour?
Eh I dunno I'll get a live version up in a bit
Really all I need is a basic JS runnable demo. Like on jsfiddle or whatever. Without any of the boilerplate and such
@serene echo do you have ngrok or similar?
I could maybe look at your local page without you having to redo everything
yeah ill be back on the computer in a bit and I can do that then I believe
@potent karma https://2661-2603-7080-c940-9f-fc03-791d-90e1-7faa.ngrok.io/lessons
try to book now
ty again
so you have multiple separate errors on load
are those expected? That doesn't bode well already ๐
I think so, its from the boilerplate from Stripe
before I touched anything those were popping up also
so it makes me wonder if the boilerplate Stripe provided is bugged up or something
possible. Sorry I know absolutely nothing about react but I can start with that at least
no worries
I dunno if you have access to the Stripe github account but this is what they gave us to clone and operate off of:
https://github.com/stripe-certification/payments_node_react_thomaslanenh_challenge
who is "they"
Are you trying to pass a certification and not really building a real integration ๐
wait wait wait
You're a developer passing a certification, not a developer building a real integration?
yeah
Hum
It feels quite off that we'd solve that for you
though I appreciate you being forward and transparent about this since you could have just pretended otherwise
Yeah no worries. Don't neccesarily need it solved, it was mostly just the weird bug that I was getting and there was no documentation around it
sounds good, I'm asking someone on my team, it's easier now that we can repro
no worries, thank you
im convinced it has to do with the boilerplate we were given because like you guys, I can replicate the same outside of this , even in React
agreed!!! lol
We're looking, sorry it's hard to try and piece code written by another random person that you then try and make sense of and modified
understandable, I appreciate you all helping
I was like "im tired of bashing my head over this just so these stupid tests work on their end, i'll reach out to them" lol
๐
Okay in your handleSubmit function, before you confirmSetupIntent can you add: if (!stripe || !elements) { console.log("stripe: ", stripe); console.log("elements: ", elements); return; }
Sorry this is specifically your reserveLesson function
No worries, will do in a few mins
Okay I think I know what is going on
You are calling:
setProcessing('Processing Payment Information, Please Hold.');
Immediately upon reserveLesson
This is before you attempt confirmation
That is unmounting your Card Element
Which is attempting to be used in the confirmCardSetup function that happens afterward
So confirmCardSetup is trying to grab info from Card Element but it isn't there anymore
Instead of using an if/else if here based on setProcessing, you want to use something like a loading spinner and disable the pay button.
hmmm good catch let me try that
You can see an example in our Payment Element quickstart (https://stripe.com/docs/payments/quickstart?client=react) where we do something like <form id="payment-form" onSubmit={handleSubmit}> <PaymentElement id="payment-element" /> <button disabled={isLoading || !stripe || !elements} id="submit"> <span id="button-text"> {isLoading ? <div className="spinner" id="spinner"></div> : "Pay now"} </span> </button>
same thing ๐ฆ
Can you update the ngrok so I can see it?
yep, ripped out all of those elements and same ๐ฆ
sure one sec
should be all updated
You are mixing await and .then which isn't super kosher
Let's just simplify greatly. Change const {setupIntent, error} = await stripe.confirmCardSetup( clientSecret, { payment_method: { card: elements.getElement(CardElement), billing_details: { name: event.target[0].value, email: event.target[1].value } } } ).then((res)=>{ console.log(res.setupIntent) // // setShowProcessing(false); // setProcessing(''); })
to
clientSecret,
{
payment_method: {
card: elements.getElement(CardElement),
billing_details: {
name: event.target[0].value,
email: event.target[1].value
}
}
}
)
console.log(res);```
๐
The initial issue was that you were tearing down the Card Element before it was used
gotcha
our main developer uses coldfusion and you folks said he couldn't do this test in it so this got passed to me and i'm a assembly programmer lmao so sorry for al lthis