Skip to content

Instantly share code, notes, and snippets.

@SimonHoiberg
Created June 19, 2020 14:57
Show Gist options
  • Save SimonHoiberg/01197bb1564072a01081e12c87cac161 to your computer and use it in GitHub Desktop.
Save SimonHoiberg/01197bb1564072a01081e12c87cac161 to your computer and use it in GitHub Desktop.
const CheckoutForm = () => {
// Include these hooks:
const stripe = useStripe();
const elements = useElements();
const [nameInput, setNameInput] = useState('');
const [retry, setRetry] = useState(!!localStorage.getItem('invoice_retry'));
const handleSubmitPayment = async () => {
// Not implemented yet
};
const handleRetryPayment = async () => {
// Not implemented yet
};
const buttonAction = retry ? handleRetryPayment : handleSubmitPayment;
return (
<div>
<input
placeholder='Name on card'
value={nameInput}
onChange={(e) => setNameInput(e.currentTarget.value)}
/>
<CardNumberElement />
<CardExpiryElement />
<CardCvcElement />
<button onClick={buttonAction}></button>
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment