import * as React from 'react'; import { StripeProvider, CardElement, Elements, injectStripe, CardNumberElement, CardExpiryElement, CardCvcElement, CardCVCElement, IbanElement, IdealBankElement, PostalCodeElement, PaymentRequestButtonElement, ReactStripeElements, } from 'react-stripe-elements'; import InjectedStripeProps = ReactStripeElements.InjectedStripeProps; import ElementChangeResponse = stripe.elements.ElementChangeResponse; import ElementsOptions = stripe.elements.ElementsOptions; import ElementsCreateOptions = stripe.elements.ElementsCreateOptions; import HTMLStripeElement = ReactStripeElements.HTMLStripeElement; import TokenResponse = ReactStripeElements.TokenResponse; const cardElementProps: ElementsOptions = { iconStyle: 'solid', style: { base: { color: '#32325d', lineHeight: '24px', fontFamily: 'Roboto, "Helvetica Neue", sans-serif', fontSmoothing: 'antialiased', fontSize: '16px', '::placeholder': { color: '#aab7c4', }, }, invalid: { color: '#B71C1C', iconColor: '#B71C1C', }, }, hidePostalCode: true, classes: { base: 'field', complete: 'complete', empty: 'is-empty', focus: 'is-focused', invalid: 'is-invalid', webkitAutofill: 'webkit-autofill', }, hideIcon: true, }; const fontElementsProps: ElementsCreateOptions = { fonts: [ { cssSrc: 'https://fonts.googleapis.com/css?family=Dosis', }, { family: 'Dosis, sanz', src: 'url(https://somewebsite.com/path/to/font.woff)', style: 'normal', weight: 'bold', unicodeRange: 'U+26', }, ], locale: 'es', }; const ElementsWithPropsTest: React.FC = () => (
void 0} onBlur={(event: ElementChangeResponse) => void 0} onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} onClick={(event: ElementChangeResponse) => void 0} />
); interface ComponentProps { tokenCallback(token: TokenResponse): void; } class WrappedComponent extends React.Component { constructor(props: ComponentProps & InjectedStripeProps) { super(props); // Test for paymentRequest const paymentRequest = props.stripe && props.stripe.paymentRequest({ country: 'US', currency: 'usd', total: { label: 'Demo total', amount: 1, }, }); if (paymentRequest) { paymentRequest.on('token', ({ complete, token, ...data }) => undefined); paymentRequest.canMakePayment().then(res => undefined); } } onSubmit = () => { const elements = this.props.elements; // createToken(options?: TokenOptions) this.props .stripe!.createToken({ name: '', address_line1: '', address_line2: '', address_city: '', address_state: '', address_zip: '', address_country: '', currency: '', }) .then((response: TokenResponse) => this.props.tokenCallback(response)); // createToken(options?: BankAccountTokenOptions) this.props .stripe!.createToken({ country: '', currency: '', routing_number: '', account_number: '', account_holder_name: '', account_holder_type: '', }) .then((response: TokenResponse) => this.props.tokenCallback(response)); } isFormValid = () => { // use onChange callbacks from *Element components to detect if form is valid for submission return false; } render() { return (