This repository was archived by the owner on Mar 27, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -166,16 +166,6 @@ class _PaymentRequestForm extends React.Component<
166
166
} ,
167
167
} ) ;
168
168
169
- paymentRequest . on ( 'token' , ( { complete, token, ...data } ) => {
170
- console . log ( 'Received Stripe token: ' , token ) ;
171
- console . log ( 'Received customer information: ' , data ) ;
172
- complete ( 'success' ) ;
173
- } ) ;
174
-
175
- paymentRequest . canMakePayment ( ) . then ( ( result ) => {
176
- this . setState ( { canMakePayment : ! ! result } ) ;
177
- } ) ;
178
-
179
169
this . state = {
180
170
canMakePayment : false ,
181
171
paymentRequest,
@@ -187,6 +177,18 @@ class _PaymentRequestForm extends React.Component<
187
177
paymentRequest : Object ,
188
178
} ;
189
179
180
+ componentDidMount ( ) {
181
+ this . state . paymentRequest . on ( 'token' , ( { complete, token, ...data } ) = > {
182
+ console . log ( 'Received Stripe token: ' , token ) ;
183
+ console . log ( 'Received customer information: ' , data ) ;
184
+ complete ( 'success' ) ;
185
+ } ) ;
186
+
187
+ this . state . paymentRequest . canMakePayment ( ) . then ( ( result ) => {
188
+ this . setState ( { canMakePayment : ! ! result } ) ;
189
+ } ) ;
190
+ }
191
+
190
192
render ( ) {
191
193
return this . state . canMakePayment ? (
192
194
< PaymentRequestButtonElement
You can’t perform that action at this time.
0 commit comments