Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. timer = null
  2. ScanCode_Change_Event = (e) => {
  3. clearTimeout(this.timer);
  4. this.timer = setTimeout(() => { this.triggerChange() }, 500);
  5. }
  6. triggerChange = async () => {
  7. await this._onSendSignature();
  8. }
  9.  
  10. _onSendSignature = async () => {
  11. const BarcodeNo = this.state.BarcodeNo;
  12. const valueToHash = MerchantKey + BarcodeNo + Amount.replace('.', '').replace(',', '');
  13. sha256(valueToHash).then( hash => {
  14. // This can show the signature
  15. ToastAndroid.show('Signature: ' + hash, ToastAndroid.LONG, ToastAndroid.BOTTOM);
  16. this.setState({
  17. hashSignature: hash
  18. })
  19. })
  20. // This cannot show the signature
  21. ToastAndroid.show('Signature: ' + this.state.hashSignature, ToastAndroid.LONG, ToastAndroid.BOTTOM);
  22. }
  23.  
  24. <Input style={{ color: 'brown' }}
  25. placeholder='Scan Barcode'
  26. placeholderTextColor='rgba(0, 0, 0, 0.3)'
  27. autoFocus={true}
  28. onChange={evt => this.ScanCode_Change_Event(evt)}
  29. onChangeText={(BarcodeNo) => this.setState({ BarcodeNo})}>{this.state.BarcodeNo}</Input>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement