@@ -13,7 +13,6 @@ import {
1313 initializeAndActivatePinPad ,
1414 doPayment ,
1515 refundPayment ,
16- generatePixQRCode ,
1716 useTransactionEvent ,
1817 getTerminalSerialNumber ,
1918 PaymentType ,
@@ -124,6 +123,38 @@ export default function App() {
124123 setIsProcessing ( false ) ;
125124 } ;
126125
126+ // Credit payment
127+ const handlePIXPayment = async ( ) => {
128+ if ( ! isInitialized ) {
129+ Alert . alert ( '⚠️ Aviso' , 'Por favor, inicialize o terminal primeiro' ) ;
130+ return ;
131+ }
132+
133+ setIsProcessing ( true ) ;
134+ try {
135+ const result = await doPayment ( {
136+ amount : 1500 , // R$ 15.00
137+ type : PaymentType . PIX ,
138+ } ) ;
139+ setLastPayment ( result ) ;
140+
141+ if ( result . result === ErrorCode . OK ) {
142+ Alert . alert (
143+ '✅ Pagamento Aprovado' ,
144+ `Transação realizada com sucesso!\nCódigo: ${ result . transactionCode } \nValor: R$ 25,00`
145+ ) ;
146+ } else {
147+ Alert . alert (
148+ '❌ Pagamento Negado' ,
149+ result . message || 'Transação falhou'
150+ ) ;
151+ }
152+ } catch ( e : any ) {
153+ Alert . alert ( '❌ Erro' , e . message ) ;
154+ }
155+ setIsProcessing ( false ) ;
156+ } ;
157+
127158 // Installment payment
128159 const handleInstallmentPayment = async ( ) => {
129160 if ( ! isInitialized ) {
@@ -158,16 +189,6 @@ export default function App() {
158189 setIsProcessing ( false ) ;
159190 } ;
160191
161- // Generate PIX QR code
162- const handleGeneratePix = async ( ) => {
163- try {
164- const qrString = await generatePixQRCode ( 5000 ) ; // R$ 50.00
165- Alert . alert ( 'Código QR PIX' , qrString ) ;
166- } catch ( e : any ) {
167- Alert . alert ( '❌ Erro PIX' , e . message ) ;
168- }
169- } ;
170-
171192 // Refund last payment
172193 const handleRefund = async ( ) => {
173194 if ( ! lastPayment ?. transactionCode || ! lastPayment . transactionId ) {
@@ -263,6 +284,14 @@ export default function App() {
263284 < Text style = { styles . buttonText } > Pagamento Débito - R$ 15,00</ Text >
264285 </ TouchableOpacity >
265286
287+ < TouchableOpacity
288+ style = { styles . button }
289+ onPress = { handlePIXPayment }
290+ disabled = { isProcessing || ! isInitialized }
291+ >
292+ < Text style = { styles . buttonText } > PIX - R$ 15,00</ Text >
293+ </ TouchableOpacity >
294+
266295 < TouchableOpacity
267296 style = { styles . button }
268297 onPress = { handleInstallmentPayment }
@@ -273,10 +302,6 @@ export default function App() {
273302 </ Text >
274303 </ TouchableOpacity >
275304
276- < TouchableOpacity style = { styles . button } onPress = { handleGeneratePix } >
277- < Text style = { styles . buttonText } > Gerar QR PIX - R$ 50,00</ Text >
278- </ TouchableOpacity >
279-
280305 < TouchableOpacity
281306 style = { [ styles . button , styles . refundButton ] }
282307 onPress = { handleRefund }
0 commit comments