|
| 1 | +import {NativeModules, Alert} from 'react-native'; |
| 2 | +import moment from 'moment'; |
| 3 | + |
| 4 | +export const printBitcoinize = async ( |
| 5 | + description, |
| 6 | + timestamp, |
| 7 | + ispaid, |
| 8 | + payment_hash, |
| 9 | + amt, |
| 10 | +) => { |
| 11 | + try { |
| 12 | + await NativeModules.PrintModule.printText(description, 32); |
| 13 | + await NativeModules.PrintModule.paperOut(24); |
| 14 | + |
| 15 | + await NativeModules.PrintModule.printText('Payment made in Bitcoin', 24); |
| 16 | + await NativeModules.PrintModule.paperOut(24); |
| 17 | + |
| 18 | + await NativeModules.PrintModule.printText( |
| 19 | + moment(timestamp * 1000).format('DD/MM/YY HH:mm:ss'), |
| 20 | + 24, |
| 21 | + ); |
| 22 | + await NativeModules.PrintModule.paperOut(24); |
| 23 | + |
| 24 | + await NativeModules.PrintModule.printText( |
| 25 | + amt + ' sats ' + (ispaid ? '(PAID)' : '(PENDING)'), |
| 26 | + 32, |
| 27 | + ); |
| 28 | + await NativeModules.PrintModule.paperOut(24); |
| 29 | + |
| 30 | + await NativeModules.PrintModule.printText(payment_hash, 24); |
| 31 | + await NativeModules.PrintModule.paperOut(24); |
| 32 | + await NativeModules.PrintModule.printQRCode( |
| 33 | + JSON.stringify({payment_hash: payment_hash}), |
| 34 | + 400, |
| 35 | + 400, |
| 36 | + ); |
| 37 | + |
| 38 | + await NativeModules.PrintModule.paperOut(100); |
| 39 | + } catch (e) { |
| 40 | + Alert.alert('Error', 'There was an error when printing ' + e.message, [ |
| 41 | + {text: 'OK', onPress: () => console.log('OK Pressed')}, |
| 42 | + ]); |
| 43 | + } |
| 44 | +}; |
| 45 | + |
| 46 | +export const printCiontek = async ( |
| 47 | + description, |
| 48 | + timestamp, |
| 49 | + ispaid, |
| 50 | + payment_hash, |
| 51 | + amt, |
| 52 | +) => { |
| 53 | + try { |
| 54 | + await NativeModules.PrintModule.printTextCiontek(description, 32); |
| 55 | + await NativeModules.PrintModule.paperOutCiontek(); |
| 56 | + |
| 57 | + await NativeModules.PrintModule.printTextCiontek( |
| 58 | + 'Payment made in Bitcoin', |
| 59 | + 24, |
| 60 | + ); |
| 61 | + await NativeModules.PrintModule.paperOutCiontek(); |
| 62 | + |
| 63 | + await NativeModules.PrintModule.printTextCiontek( |
| 64 | + moment(timestamp * 1000).format('DD/MM/YY HH:mm:ss'), |
| 65 | + 24, |
| 66 | + ); |
| 67 | + await NativeModules.PrintModule.paperOutCiontek(); |
| 68 | + |
| 69 | + await NativeModules.PrintModule.printTextCiontek( |
| 70 | + amt + ' sats ' + (ispaid ? '(PAID)' : '(PENDING)'), |
| 71 | + 32, |
| 72 | + ); |
| 73 | + await NativeModules.PrintModule.paperOutCiontek(); |
| 74 | + |
| 75 | + await NativeModules.PrintModule.printTextCiontek(payment_hash, 24); |
| 76 | + await NativeModules.PrintModule.paperOutCiontek(); |
| 77 | + await NativeModules.PrintModule.printQRCodeCiontek( |
| 78 | + JSON.stringify({payment_hash: payment_hash}), |
| 79 | + 360, |
| 80 | + 360, |
| 81 | + ); |
| 82 | + |
| 83 | + await NativeModules.PrintModule.paperOutCiontek(); |
| 84 | + await NativeModules.PrintModule.paperOutCiontek(); |
| 85 | + await NativeModules.PrintModule.paperOutCiontek(); |
| 86 | + } catch (e) { |
| 87 | + Alert.alert('Error', 'There was an error when printing ' + e.message, [ |
| 88 | + {text: 'OK', onPress: () => console.log('OK Pressed')}, |
| 89 | + ]); |
| 90 | + } |
| 91 | +}; |
0 commit comments