From 10a3a77b5e63f3251c82ebe22d2b8c480f83f67f Mon Sep 17 00:00:00 2001 From: Thomas Chia Date: Thu, 28 Jun 2018 19:34:55 +0800 Subject: [PATCH] Add payment request to StripeProps Add test --- types/react-stripe-elements/index.d.ts | 2 +- .../react-stripe-elements-tests.tsx | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/types/react-stripe-elements/index.d.ts b/types/react-stripe-elements/index.d.ts index abc08cc3e1..27d124f78a 100644 --- a/types/react-stripe-elements/index.d.ts +++ b/types/react-stripe-elements/index.d.ts @@ -34,8 +34,8 @@ export namespace ReactStripeElements { interface StripeProps { createSource(sourceData?: SourceOptions): Promise; - createToken(options?: TokenOptions): Promise; + paymentRequest: stripe.Stripe['paymentRequest']; } interface InjectOptions { diff --git a/types/react-stripe-elements/react-stripe-elements-tests.tsx b/types/react-stripe-elements/react-stripe-elements-tests.tsx index 88b703b141..324f76aa4d 100644 --- a/types/react-stripe-elements/react-stripe-elements-tests.tsx +++ b/types/react-stripe-elements/react-stripe-elements-tests.tsx @@ -110,6 +110,22 @@ interface ComponentProps { class WrappedComponent extends React.Component< ComponentProps & InjectedStripeProps > { + 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 = () => { this.props.stripe! .createToken({