Skip to content
This repository has been archived by the owner on Mar 27, 2021. It is now read-only.

Commit

Permalink
Fix bug in demo component
Browse files Browse the repository at this point in the history
  • Loading branch information
rynobax committed Oct 7, 2018
1 parent 20258c3 commit 25556e8
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions demo/demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,6 @@ class _PaymentRequestForm extends React.Component<
},
});

paymentRequest.on('token', ({complete, token, ...data}) => {
console.log('Received Stripe token: ', token);
console.log('Received customer information: ', data);
complete('success');
});

paymentRequest.canMakePayment().then((result) => {
this.setState({canMakePayment: !!result});
});

this.state = {
canMakePayment: false,
paymentRequest,
Expand All @@ -187,6 +177,18 @@ class _PaymentRequestForm extends React.Component<
paymentRequest: Object,
};

componentDidMount() {
this.state.paymentRequest.on('token', ({complete, token, ...data}) => {
console.log('Received Stripe token: ', token);
console.log('Received customer information: ', data);
complete('success');
});

this.state.paymentRequest.canMakePayment().then((result) => {
this.setState({canMakePayment: !!result});
});
}

render() {
return this.state.canMakePayment ? (
<PaymentRequestButtonElement
Expand Down

0 comments on commit 25556e8

Please sign in to comment.