mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
Merge pull request #26913 from thchia/react-stripe-elements-payment-request
[react-stripe-elements] - Add payment request to StripeProps
This commit is contained in:
+1
-1
@@ -34,8 +34,8 @@ export namespace ReactStripeElements {
|
||||
|
||||
interface StripeProps {
|
||||
createSource(sourceData?: SourceOptions): Promise<SourceResponse>;
|
||||
|
||||
createToken(options?: TokenOptions): Promise<PatchedTokenResponse>;
|
||||
paymentRequest: stripe.Stripe['paymentRequest'];
|
||||
}
|
||||
|
||||
interface InjectOptions {
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user