#xignotic
1 messages · Page 1 of 1 (latest)
Yep, absolutely should work. Can you share your code?
What do you mean by 'clientSecret becomes undefined'?
useEffect(() => {
const fetchClientSecret = async () => {
const data = await axios.get('/api/stripe').then(r => r.data)
setClientSecret(data.client_secret)
}
fetchClientSecret()
return () => {
}
}, [])```
<Tabs isLazy={true} index={activeStep}>
<TabPanels>
<Elements stripe={stripePromise} options={options} appearance={options.appearance}>
<form>
<TabPanel>
<DetailsTab/>
</TabPanel>
<TabPanel>
<PaymentDetailsTab/>
</TabPanel>
</form>
</Elements>
</TabPanels>
</Tabs>```
Then in DetailsTab and PaymentDetailsTab I have the AddressElement and PaymentElement
So if I remove DetailsTab or PaymentDetails the client secret is defined but if I add the other it gives an error and it becomes undefined when I console log it
Specifically this error
My guess is your code that initialises the Elements group is rendering before your effect to create the Payment Intent has run. You likely need to wrap a conditional around it to check if clientSecret is falsy
Ah shoot, that's a little embarrassing
I have one last quesiton, is there any way to provide some type of summary page, with the users inputted data, before having the user proceed to payment?
What kind of data exactly?
I want to display the some address information such as email, name phone number and then a partial card number?
Should be possible yes, but you're going to probably need to adjust your integration
Do you know if I can do this through stripe or would I have to just listen to each input field?
Thanks ynnoj, I appreciate it, have a nice day!
You can get the address values: https://stripe.com/docs/js/elements_object/get_value_address_element
But for the payment details you'd need to inspect the Payment Method object that is created as a part of the flow I just shared
You can't get those from the Payment Element