myussufz / react-native-ipay88-sdk

React Native for integrating with iPay88 payment gateway's mobile SDK
18 stars 17 forks source link

Can't find variable: authorizationCode after payment is successed #8

Open haolun1996 opened 5 years ago

haolun1996 commented 5 years ago

the problem is like this, after my payment was successed then it prompt Can't find variable: authorizationCode in my console log and my app get forced to stop and closed. Any solution to solve this? my successNotify method is same as in readme.md file

"react": "16.6.0-alpha.8af6728", "react-native": "0.57.4", "ipay88-sdk": "^1.0.2"

haolun1996 commented 5 years ago

I found out that 3 method onSuccess, onCanceled and onFailed called twice,so it will cause the data received twice,but the first received data got the authorizationCode but undefind on the second received. Can it be change the componentWillMount to the componentDidMount, so that the DeviceEventEmitter will not added twice and received twice of the data. FYI:If you ever need to render your app on the server (SSR/isomorphic/other buzzwords), componentWillMount will actually be called twice – once on the server, and again on the client – which is probably not what you want. Putting the data loading code in componentDidMount will ensure that data has been rendered once..(https://daveceddia.com/where-fetch-data-componentwillmount-vs-componentdidmount/)