cordova-plugin-netcontroll-integration 1.0.77 → 1.0.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Versao 1.0.77
1
+ Versao 1.0.80
2
2
 
3
3
  Funções internas de integração XMenu / NetControll
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-netcontroll-integration",
3
- "version": "1.0.77",
3
+ "version": "1.0.80",
4
4
  "description": "Plugin cordova de integracao para uso interno (NetControll/ XMenu)",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-netcontroll-integration",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="cordova-plugin-netcontroll-integration" version="1.0.77"
2
+ <plugin id="cordova-plugin-netcontroll-integration" version="1.0.80"
3
3
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  xmlns:android="http://schemas.android.com/apk/res/android">
5
5
 
@@ -832,7 +832,7 @@ public class CieloLioLocal {
832
832
  print_initialize();
833
833
  printerManager.printImage(bitmap, alignCenter, printerListener);
834
834
  boolean result = print_SimpleText(
835
- "\n\n\n\n\n",
835
+ "\n\n\n\n\n\n\n",
836
836
  0,
837
837
  18,
838
838
  8,
@@ -6,7 +6,6 @@ import org.apache.cordova.CallbackContext;
6
6
  import org.apache.cordova.CordovaInterface;
7
7
  import org.apache.cordova.CordovaWebView;
8
8
 
9
-
10
9
  import org.json.JSONArray;
11
10
  import org.json.JSONException;
12
11
  import org.json.JSONObject;
@@ -42,7 +41,6 @@ import rede.smartrede.sdk.Receipt;
42
41
  import rede.smartrede.sdk.RedePaymentValidationError;
43
42
  import rede.smartrede.sdk.RedePayments;
44
43
 
45
-
46
44
  import android.graphics.Paint;
47
45
  import android.graphics.Typeface;
48
46
 
@@ -88,7 +86,6 @@ import com.izettle.html2bitmap.Html2Bitmap;
88
86
  import com.izettle.html2bitmap.content.WebViewContent;
89
87
  import java.io.ByteArrayOutputStream;
90
88
 
91
-
92
89
  public class RedeGPos700 {
93
90
  //public class RedeGPos700 extends CordovaPlugin {
94
91
  //Cordova/Java Params
@@ -98,14 +95,13 @@ public class RedeGPos700 {
98
95
  private CordovaWebView webView;
99
96
 
100
97
  //Rede
101
- CordovaPlugin useRedeResultCordovaPlugin;
98
+ // CordovaPlugin useRedeResultCordovaPlugin;
102
99
 
103
100
  //Intents CODES
104
101
  private static int PAYMENT_REQUEST_CODE = 890001;
105
102
  private static int REVERSAL_REQUEST_CODE = 890002;
106
103
  private static int REPRINT_REQUEST_CODE = 890003;
107
104
 
108
-
109
105
  public static final String G700 = "GPOS700";
110
106
  private static final String version = "v1.0.0";
111
107
 
@@ -114,15 +110,12 @@ public class RedeGPos700 {
114
110
  private ConfigPrint configPrint = new ConfigPrint();
115
111
  public static String Model = Build.MODEL;
116
112
 
117
-
118
-
119
113
  //CallbacksOnActivityResult
120
114
  private CallbackContext selecionarImagemCallbackContext;
121
115
 
122
116
  //cutPaper boolean for resultActivity
123
117
  private boolean cutPaper = false;
124
118
 
125
-
126
119
  // @Override
127
120
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
128
121
  // super.initialize(cordova, webView);
@@ -139,73 +132,6 @@ public class RedeGPos700 {
139
132
  }
140
133
 
141
134
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
142
- try {
143
- if (useRedeResultCordovaPlugin == null) {
144
- useRedeResultCordovaPlugin = new CordovaPlugin() {
145
- @Override
146
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
147
- if (requestCode == PAYMENT_REQUEST_CODE) {
148
- if (resultCode == RESULT_OK) {
149
- if (data != null) {
150
- Payment payment = RedePayments.getPaymentFromIntent(data);
151
- if (payment.getStatus() == PaymentStatus.AUTHORIZED) {
152
- // Receipt receipt = payment.getReceipt();
153
-
154
- String varResultStrJson = parseObjToJsonSrtring(payment);
155
- callbackContext.success(varResultStrJson);
156
- } else if (payment.getStatus() == PaymentStatus.FAILED) {
157
- callbackContext.success(parseObjToJsonSrtring(payment));
158
- } else if (payment.getStatus() == PaymentStatus.DECLINED) {
159
- callbackContext.success(parseObjToJsonSrtring(payment));
160
- }
161
- }
162
- } else if (resultCode == RESULT_CANCELED) {
163
- callbackContext.error("Operação cancelada pelo usuário");
164
- }
165
- } else if (requestCode == REVERSAL_REQUEST_CODE) {
166
- if (resultCode == RESULT_OK) {
167
- if (data != null) {
168
- Payment payment = RedePayments.getPaymentFromIntent(data);
169
- if (payment.getStatus() == PaymentStatus.AUTHORIZED) {
170
- callbackContext.success(parseObjToJsonSrtring(payment));
171
- } else if (payment.getStatus() == PaymentStatus.FAILED) {
172
- callbackContext.success(parseObjToJsonSrtring(payment));
173
- } else if (payment.getStatus() == PaymentStatus.DECLINED) {
174
- callbackContext.success(parseObjToJsonSrtring(payment));
175
- }
176
- }
177
- } else if (resultCode == RESULT_CANCELED) {
178
- callbackContext.error("Operação cancelada pelo usuário");
179
- }
180
- } else if (requestCode == REPRINT_REQUEST_CODE) {
181
- if (resultCode == RESULT_OK) {
182
- callbackContext.success("Reimpressão efetuada com sucesso");
183
- // if (data != null) {
184
- // Payment payment = RedePayments.getPaymentFromIntent(data);
185
- // if (payment.getStatus() == PaymentStatus.AUTHORIZED) {
186
- // callbackContext.success(parseObjToJsonSrtring(payment));
187
- // } else if (payment.getStatus() == PaymentStatus.FAILED) {
188
- // callbackContext.success(parseObjToJsonSrtring(payment));
189
- // } else if (payment.getStatus() == PaymentStatus.DECLINED) {
190
- // callbackContext.success(parseObjToJsonSrtring(payment));
191
- // }
192
- // }
193
- } else if (resultCode == RESULT_CANCELED) {
194
- callbackContext.error("Reimpressão cancelada pelo usuário");
195
- }
196
- }
197
- }
198
- };
199
- }
200
-
201
-
202
- // callbackContext.success("Testardo");
203
- } catch (Exception e) {
204
- callbackContext.error("Testar error: " + e.toString());
205
- }
206
-
207
-
208
-
209
135
  if (action.equals("Testar")) {
210
136
  try {
211
137
 
@@ -525,7 +451,40 @@ public class RedeGPos700 {
525
451
  Intent collectPaymentIntent = redePayments
526
452
  .intentForPaymentBuilder(tipoTransacaoObj, valor)
527
453
  .setInstallments(numeroParcelas).build();
528
- mCordova.startActivityForResult(useRedeResultCordovaPlugin, collectPaymentIntent, PAYMENT_REQUEST_CODE);
454
+
455
+ CordovaPlugin paymentResultCordovaPlugin = new CordovaPlugin() {
456
+ @Override
457
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
458
+ if (requestCode == PAYMENT_REQUEST_CODE) {
459
+ if (resultCode == RESULT_OK) {
460
+ if (data != null) {
461
+ Payment payment = RedePayments.getPaymentFromIntent(data);
462
+ Gson gson = new Gson();
463
+ if (payment.getStatus() == PaymentStatus.AUTHORIZED) {
464
+ //Receipt receipt = payment.getReceipt();
465
+ // String varResultStrJson = parseObjToJsonSrtring(payment);
466
+ // callbackContext.success(varResultStrJson);
467
+ // callbackContext.success("PAGAMENTO OK");
468
+
469
+ String paymentJsonString = gson.toJson(payment);
470
+
471
+ callbackContext.success(paymentJsonString);
472
+ // callbackContext.success(payment.toString());
473
+ } else if (payment.getStatus() == PaymentStatus.FAILED) {
474
+ callbackContext.success(gson.toJson(payment));
475
+ } else if (payment.getStatus() == PaymentStatus.DECLINED) {
476
+ callbackContext.success(gson.toJson(payment));
477
+ }
478
+ }
479
+ } else if (resultCode == RESULT_CANCELED) {
480
+ callbackContext.error("Operação cancelada pelo usuário");
481
+ }
482
+ } else {
483
+ callbackContext.error("Pagamento result não encontrado");
484
+ }
485
+ }
486
+ };
487
+ mCordova.startActivityForResult(paymentResultCordovaPlugin, collectPaymentIntent, PAYMENT_REQUEST_CODE);
529
488
  return true;
530
489
  } catch (RedePaymentValidationError ex) {
531
490
  callbackContext.error("Pagamentos - Intent Pagamentos not found: " + ex.toString());
@@ -536,7 +495,31 @@ public class RedeGPos700 {
536
495
  } else if (action.equals("EstornarPagamento")) {
537
496
  try {
538
497
  Intent reversal = redePayments.intentForReversal();
539
- mCordova.startActivityForResult(useRedeResultCordovaPlugin, reversal, REVERSAL_REQUEST_CODE);
498
+ CordovaPlugin reversalResultCordovaPlugin = new CordovaPlugin() {
499
+ @Override
500
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
501
+ if (requestCode == REVERSAL_REQUEST_CODE) {
502
+ if (resultCode == RESULT_OK) {
503
+ if (data != null) {
504
+ Gson gson = new Gson();
505
+ Payment payment = RedePayments.getPaymentFromIntent(data);
506
+ if (payment.getStatus() == PaymentStatus.AUTHORIZED) {
507
+ callbackContext.success(gson.toJson(payment));
508
+ } else if (payment.getStatus() == PaymentStatus.FAILED) {
509
+ callbackContext.success(gson.toJson(payment));
510
+ } else if (payment.getStatus() == PaymentStatus.DECLINED) {
511
+ callbackContext.success(gson.toJson(payment));
512
+ }
513
+ }
514
+ } else if (resultCode == RESULT_CANCELED) {
515
+ callbackContext.error("Operação cancelada pelo usuário");
516
+ }
517
+ } else {
518
+ callbackContext.error("Estorno result não encontrado");
519
+ }
520
+ }
521
+ };
522
+ mCordova.startActivityForResult(reversalResultCordovaPlugin, reversal, REVERSAL_REQUEST_CODE);
540
523
  return true;
541
524
  } catch (RedePaymentValidationError ex) {
542
525
  callbackContext.error("Pagamentos - Intent Pagamentos not found: " + ex.toString());
@@ -547,7 +530,21 @@ public class RedeGPos700 {
547
530
  } else if (action.equals("ReimprimirPagamento")) {
548
531
  try {
549
532
  Intent reprint = redePayments.intentForReprint();
550
- mCordova.startActivityForResult(useRedeResultCordovaPlugin, reprint, REPRINT_REQUEST_CODE);
533
+ CordovaPlugin reprintResultCordovaPlugin = new CordovaPlugin() {
534
+ @Override
535
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
536
+ if (requestCode == REPRINT_REQUEST_CODE) {
537
+ if (resultCode == RESULT_OK) {
538
+ callbackContext.success("Reimpressão efetuada com sucesso");
539
+ } else if (resultCode == RESULT_CANCELED) {
540
+ callbackContext.error("Reimpressão cancelada pelo usuário");
541
+ }
542
+ } else {
543
+ callbackContext.error("Reimpressão result não encontrado");
544
+ }
545
+ }
546
+ };
547
+ mCordova.startActivityForResult(reprintResultCordovaPlugin, reprint, REPRINT_REQUEST_CODE);
551
548
  return true;
552
549
  } catch (RedePaymentValidationError ex) {
553
550
  callbackContext.error("Pagamentos - Intent Pagamentos not found: " + ex.toString());
@@ -599,7 +596,6 @@ public class RedeGPos700 {
599
596
  return result;
600
597
  }
601
598
 
602
-
603
599
  private String ConverterTextoImpressoToHtml(String linhasImpressos) {
604
600
  try {
605
601
  String htmlStr = this.ConverterImpressaoToHtmlInicio();
@@ -780,7 +776,6 @@ public class RedeGPos700 {
780
776
  " <div class='printer-ticket'>\n" +
781
777
  " <div class='row'>\n";
782
778
 
783
-
784
779
  return htmlResult;
785
780
  }
786
781
 
@@ -903,7 +898,6 @@ public class RedeGPos700 {
903
898
  " <div class='printer-ticket'>\n" +
904
899
  " <div class='row'>\n";
905
900
 
906
-
907
901
  return htmlResult;
908
902
  }
909
903
 
@@ -1069,7 +1063,6 @@ public class RedeGPos700 {
1069
1063
  String textoQrCodeResult = "<img src=\"data:image/png;base64," + baseQrCodeBase64 + "\" >";
1070
1064
  texto = textoQrCodeResult;
1071
1065
 
1072
-
1073
1066
  }
1074
1067
 
1075
1068
  result = "<div class='row'>\n" +
@@ -1224,7 +1217,6 @@ public class RedeGPos700 {
1224
1217
  return encoded;
1225
1218
  }
1226
1219
 
1227
-
1228
1220
  public class ConfigPrint {
1229
1221
 
1230
1222
  private String fonte = "NORMAL";
@@ -1404,7 +1396,6 @@ public class RedeGPos700 {
1404
1396
 
1405
1397
  public class GertecPrinter {
1406
1398
 
1407
-
1408
1399
  // Definições
1409
1400
  private final String IMPRESSORA_ERRO = "Impressora com erro.";
1410
1401
 
@@ -1427,7 +1418,6 @@ public class RedeGPos700 {
1427
1418
  private ConfigPrint configPrint;
1428
1419
  private Typeface typeface;
1429
1420
 
1430
-
1431
1421
  /**
1432
1422
  * Método construtor da classe usando o GPOS 700
1433
1423
  * @param c = Context atual que esta sendo inicializada a class
@@ -1456,15 +1446,15 @@ public class RedeGPos700 {
1456
1446
  **/
1457
1447
  private void startIGEDI() {
1458
1448
  new Thread(() -> {
1459
- GEDI.init(this.context);
1460
- this.iGedi = GEDI.getInstance(this.context);
1461
- this.iPrint = this.iGedi.getPRNTR();
1462
- try {
1463
- new Thread().sleep(250);
1464
- icl = GEDI.getInstance().getCL();
1465
- } catch (InterruptedException e) {
1466
- e.printStackTrace();
1467
- }
1449
+ GEDI.init(this.context);
1450
+ this.iGedi = GEDI.getInstance(this.context);
1451
+ this.iPrint = this.iGedi.getPRNTR();
1452
+ try {
1453
+ new Thread().sleep(250);
1454
+ icl = GEDI.getInstance().getCL();
1455
+ } catch (InterruptedException e) {
1456
+ e.printStackTrace();
1457
+ }
1468
1458
  }).start();
1469
1459
  }
1470
1460
 
@@ -1759,7 +1749,6 @@ public class RedeGPos700 {
1759
1749
  }
1760
1750
  }
1761
1751
 
1762
-
1763
1752
  /**
1764
1753
  * Método que faz a impressão de imagens
1765
1754
  *