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<
166166 } ,
167167 } ) ;
168168
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-
179169 this . state = {
180170 canMakePayment : false ,
181171 paymentRequest,
@@ -187,6 +177,18 @@ class _PaymentRequestForm extends React.Component<
187177 paymentRequest : Object ,
188178 } ;
189179
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+
190192 render ( ) {
191193 return this . state . canMakePayment ? (
192194 < PaymentRequestButtonElement
You can’t perform that action at this time.
0 commit comments