#xequinox-loadstripe
1 messages · Page 1 of 1 (latest)
after loading the credit card form using the client_secret, I want to confirm payment
but I don't have the stripe object
only stripePromise
I don't know what that means.
Can you provide more context or exact code? What's the problem, which doc are you following exactly, etc.
var [stripeOptions, setStripeOptions] = useState<StripeElementsOptions>({
clientSecret: "",
});
const stripePromise = loadStripe('');
<Elements stripe={stripePromise} options={stripeOptions}>
<PaymentElement />
</Elements>
Okay so you're using React? What's the problem?
I want to confirm the payment after the credit details have been put in
the documentation says use stripe.confirmPayment
I only have the stripePromise
no stripe
im not using the useStripe hook
because I am using the ```
const stripePromise = loadStripe(PK)
from import {loadStripe} from '@stripe/stripe-js';
I am sorry, React is not my forte but the doc you mention literally does loadStripe() and uses useStripe(). So why can't you do what the docs do?
I dont want to use react hooks
for the stripe object
I think I am mixing the vanilla JS documentation and react docs
one sec
ok
I am using the useStripe hook
and I get Error: Could not find Elements context; You need to wrap the part of your app that calls useStripe() in an <Elements> provider.
but the elments provider is on the elements
kinda sucks to wrap all my page with it
Sorry I'm strugglign to follow you. Is this just a comment while you figured out your problem? Something else?
but you said "I don't want to use this" then you say "I use this"
the useStripe call is a hook
I'm sorry I have no idea what you're asking
Does https://stripe.com/docs/stripe-js/react#elements-consumer work for you instead?
Hi @copper inlet can you share with us the details of the error?
I have a page that is a function component
it returns an element to the client
before I return the element
I am using loadStripe()
and the useStripe() hook
I can't wrap the useStripe hook with the elements provider
because its in the function and not the returned elements
OK, React hooks (e.g., useStripe()) works best with functional components, can you help me understand if there's anything prevent you from using hooks in your components?
I fixed it by using a React Context in a custom per page layout
OK, so is your problem resovled?
yes except now it is erroring because the initial page load doesnt have a valid clientSecret
Uncaught IntegrationError: Invalid value for elements(): clientSecret should be a client secret of the form ${id}_secret_${secret}. You specified: test.
is it possible to disable it until the clientSecret is received
You need to create a PaymentIntent at your backend, and pass the PaymentIntent's client secret to frontend and set it to the Element's options