I'm trying to handle credit card payments using stripe and reactjs. I'm following the tutorial here https://github.com/stripe-archive/react-stripe-elements. See the get started section. The only problem I have is that I need to submit the credit card form on the component page where the code is (the first page that is created) and not the CheckoutForm page. How do I do that?
I tried doing the following
var elements = useElements();
const card = elements.getElement(CardElement);
const result = await stripePromise.createToken(card);
if (result.error) {
console.dir(result.error.message);
} else {
console.dir(result.token);
}
but I'm not able to use a hook function useElements in a class compomnent.