import * as React from 'react'; import { injectStripe } from 'react-stripe-elements'; import { Input, IInputProps } from "../Input"; import { CardSection } from "../CardSection"; import { Button, ButtonSize } from "../Button"; interface ICheckoutFormProps { onSubmit: (token: string, email: string) => void purchaseText: string input?: Partial; } class CheckoutForm extends React.Component { public ref: React.RefObject constructor(props) { super(props); this.ref = React.createRef(); } public handleSubmit = (e: React.FormEvent) => { // We don't want to let default form submission happen here, which would refresh the page. e.preventDefault(); // You can also use createToken to create tokens. // See our tokens documentation for more: // https://stripe.com/docs/stripe-js/reference#stripe-create-token // @ts-ignore this.props.stripe .createToken({type: 'card'}) .then(({ token }) => { const tokenId = token.id; const email = this.ref.current.value; this.props.onSubmit(tokenId, email); }); // token type can optionally be inferred if there is only one one Element // with which to create tokens // this.props.stripe.createToken({name: 'Jenny Rosen'}); }; public render() { return (