cordova-plugin-netcontroll-integration 1.0.70 → 1.0.73

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.70
1
+ Versao 1.0.73
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.70",
3
+ "version": "1.0.73",
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.70"
2
+ <plugin id="cordova-plugin-netcontroll-integration" version="1.0.73"
3
3
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  xmlns:android="http://schemas.android.com/apk/res/android">
5
5
 
@@ -1,6 +1,7 @@
1
1
  package cordova.plugin.netcontroll.integration;
2
2
 
3
3
  import org.apache.cordova.CordovaPlugin;
4
+ import org.apache.cordova.PluginResult;
4
5
  import org.apache.cordova.CallbackContext;
5
6
  import org.apache.cordova.CordovaInterface;
6
7
  import org.apache.cordova.CordovaWebView;
@@ -51,6 +52,7 @@ public class NetControllCordovaPluginsIntegration extends CordovaPlugin {
51
52
  //Cordova/Java Params
52
53
  private Activity mActivity;
53
54
  private Context mContext;
55
+ private CordovaInterface mCordova;
54
56
  private CordovaWebView webView;
55
57
 
56
58
  @Override
@@ -61,6 +63,9 @@ public class NetControllCordovaPluginsIntegration extends CordovaPlugin {
61
63
  mActivity = cordova.getActivity();
62
64
  mContext = cordova.getActivity().getApplicationContext();
63
65
 
66
+ // cordova.setActivityResultCallback(this);
67
+
68
+ mCordova = cordova;
64
69
  }
65
70
 
66
71
  private void initializeElginM10Terminal() {
@@ -100,7 +105,7 @@ public class NetControllCordovaPluginsIntegration extends CordovaPlugin {
100
105
 
101
106
  @Override
102
107
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
103
- try {
108
+ try {
104
109
  String result = "Sem resultado";
105
110
  String[] actionProviderList = action.split("\\.");
106
111
  String provider = actionProviderList[0];
@@ -119,11 +124,6 @@ public class NetControllCordovaPluginsIntegration extends CordovaPlugin {
119
124
 
120
125
 
121
126
  switch (provider.toLowerCase()) {
122
- case "helpers":
123
- String helpersAction = actionProviderList[1];
124
- boolean resultHelperExecute = this.myExecute(helpersAction, args, callbackContext);
125
- return resultHelperExecute;
126
-
127
127
  case "elgin":
128
128
  String elginProduct = actionProviderList[1];
129
129
  switch (elginProduct.toLowerCase()) {
@@ -183,56 +183,4 @@ public class NetControllCordovaPluginsIntegration extends CordovaPlugin {
183
183
  }
184
184
  return false;
185
185
  }
186
-
187
- public boolean myExecute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
188
- if (action.equals("ConverterHtmlToBitmap")) {
189
- JSONObject params = args.getJSONObject(0);
190
- try {
191
- String htmlString = params.getString("htmlStr");
192
- new AsyncTask<Void, Void, Bitmap>() {
193
- @Override
194
- protected Bitmap doInBackground(Void... voids) {
195
- Bitmap bitmapResult = new Html2Bitmap.Builder().setContext(mContext).setContent(WebViewContent.html(htmlString)).build().getBitmap();
196
- return bitmapResult;
197
- }
198
-
199
- @Override
200
- protected void onPostExecute(Bitmap bitmap) {
201
- // if (bitmap != null) {
202
-
203
- // ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
204
- // //bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
205
- // bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
206
-
207
- // byte[] byteArray = byteArrayOutputStream .toByteArray();
208
- // String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);
209
-
210
- // callbackContext.success(encoded);
211
- // //imageView.setImageBitmap(bitmap);
212
- // }
213
-
214
- if (bitmap != null) {
215
-
216
-
217
-
218
-
219
-
220
- }
221
- }
222
- }.execute();
223
- return true;
224
- } catch (Exception error1) {
225
- callbackContext.error("Result - ConverterHtmlToBitmap: " + "Error Detail: " + error1);
226
- }
227
- return false;
228
- }
229
- return false;
230
- }
231
-
232
-
233
- // public static Bitmap ParseHtmlToBitmap(string htmlString) {
234
-
235
- // }
236
-
237
-
238
186
  }
@@ -1,10 +1,12 @@
1
1
  package cordova.plugin.netcontroll.integration;
2
2
 
3
3
  import org.apache.cordova.CordovaPlugin;
4
+ import org.apache.cordova.PluginResult;
4
5
  import org.apache.cordova.CallbackContext;
5
6
  import org.apache.cordova.CordovaInterface;
6
7
  import org.apache.cordova.CordovaWebView;
7
8
 
9
+
8
10
  import org.json.JSONArray;
9
11
  import org.json.JSONException;
10
12
  import org.json.JSONObject;
@@ -27,12 +29,16 @@ import android.graphics.Matrix;
27
29
 
28
30
  import android.util.Base64;
29
31
 
32
+ import static android.app.Activity.RESULT_CANCELED;
30
33
  import static android.app.Activity.RESULT_OK;
31
34
 
32
35
  import java.util.HashMap;
33
36
  import java.util.Map;
34
37
 
35
38
  import rede.smartrede.sdk.FlexTipoPagamento;
39
+ import rede.smartrede.sdk.Payment;
40
+ import rede.smartrede.sdk.PaymentStatus;
41
+ import rede.smartrede.sdk.Receipt;
36
42
  import rede.smartrede.sdk.RedePaymentValidationError;
37
43
  import rede.smartrede.sdk.RedePayments;
38
44
 
@@ -42,6 +48,7 @@ import android.graphics.Typeface;
42
48
 
43
49
  import com.elgin.e1.Pagamento.Controller.TipoImpressao;
44
50
  import com.elgin.e1.Pagamento.ElginPay;
51
+ import com.google.gson.annotations.SerializedName;
45
52
  import com.google.zxing.WriterException;
46
53
  import com.google.zxing.MultiFormatWriter;
47
54
  import com.google.zxing.common.BitMatrix;
@@ -63,7 +70,9 @@ import br.com.gertec.gedi.structs.GEDI_PRNTR_st_BarCodeConfig;
63
70
  import br.com.gertec.gedi.structs.GEDI_PRNTR_st_PictureConfig;
64
71
  import br.com.gertec.gedi.structs.GEDI_PRNTR_st_StringConfig;
65
72
 
66
-
73
+ //Json Serialize
74
+ import com.google.gson.Gson;
75
+ import com.google.gson.GsonBuilder;
67
76
 
68
77
  import java.util.List;
69
78
  import com.google.zxing.EncodeHintType;
@@ -71,6 +80,7 @@ import android.os.AsyncTask;
71
80
 
72
81
  import androidx.annotation.NonNull;
73
82
 
83
+ import java.lang.reflect.Type;
74
84
  import java.util.ArrayList;
75
85
  import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
76
86
  import java.util.EnumMap;
@@ -80,11 +90,22 @@ import java.io.ByteArrayOutputStream;
80
90
 
81
91
 
82
92
  public class RedeGPos700 {
93
+ //public class RedeGPos700 extends CordovaPlugin {
83
94
  //Cordova/Java Params
84
95
  private Activity mActivity;
85
96
  private Context mContext;
97
+ private CordovaInterface mCordova;
86
98
  private CordovaWebView webView;
87
99
 
100
+ //Rede
101
+ CordovaPlugin useRedeResultCordovaPlugin;
102
+
103
+ //Intents CODES
104
+ private static int PAYMENT_REQUEST_CODE = 890001;
105
+ private static int REVERSAL_REQUEST_CODE = 890002;
106
+ private static int REPRINT_REQUEST_CODE = 890003;
107
+
108
+
88
109
  public static final String G700 = "GPOS700";
89
110
  private static final String version = "v1.0.0";
90
111
 
@@ -101,12 +122,16 @@ public class RedeGPos700 {
101
122
  //cutPaper boolean for resultActivity
102
123
  private boolean cutPaper = false;
103
124
 
125
+
126
+ // @Override
104
127
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
105
- this.webView = webView;
128
+ // super.initialize(cordova, webView);
129
+
130
+ // this.webView = webView;
106
131
  mActivity = cordova.getActivity();
107
132
  mContext = cordova.getActivity().getApplicationContext();
108
-
109
- redePayments = RedePayments.getInstance(mContext);
133
+ mCordova = cordova;
134
+ redePayments = RedePayments.getInstance(mActivity);
110
135
  }
111
136
 
112
137
  public String Teste() {
@@ -114,6 +139,73 @@ public class RedeGPos700 {
114
139
  }
115
140
 
116
141
  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
+
117
209
  if (action.equals("Testar")) {
118
210
  try {
119
211
 
@@ -423,20 +515,40 @@ public class RedeGPos700 {
423
515
  } else if (action.equals("IniciarPagamento")) {
424
516
  try {
425
517
  JSONObject params = args.getJSONObject(0);
426
- int tipoTransacao = params.getInt("tipoTransacao");
518
+
519
+ String tipoTransacao = params.getString("tipoTransacao");
520
+ FlexTipoPagamento tipoTransacaoObj = GetFlexTipoPagamentoEnumByName(tipoTransacao);
521
+
427
522
  int valor = params.getInt("valor");
428
- int tipoFinanciamento = params.getInt("tipoFinanciamento");
429
523
  int numeroParcelas = params.getInt("numeroParcelas");
430
- int tipoImpressao = params.getInt("tipoImpressao");
431
524
 
432
525
  Intent collectPaymentIntent = redePayments
433
- .intentForPaymentBuilder(FlexTipoPagamento.CREDITO_PARCELADO, valor)
526
+ .intentForPaymentBuilder(tipoTransacaoObj, valor)
434
527
  .setInstallments(numeroParcelas).build();
435
-
436
-
528
+ mCordova.startActivityForResult(useRedeResultCordovaPlugin, collectPaymentIntent, PAYMENT_REQUEST_CODE);
529
+ return true;
530
+ } catch (RedePaymentValidationError ex) {
531
+ callbackContext.error("Pagamentos - Intent Pagamentos not found: " + ex.toString());
532
+ } catch (Exception e) {
533
+ callbackContext.error("IniciarPagamento error: " + e.toString());
534
+ }
535
+ return false;
536
+ } else if (action.equals("EstornarPagamento")) {
537
+ try {
538
+ Intent reversal = redePayments.intentForReversal();
539
+ mCordova.startActivityForResult(useRedeResultCordovaPlugin, reversal, REVERSAL_REQUEST_CODE);
540
+ return true;
541
+ } catch (RedePaymentValidationError ex) {
542
+ callbackContext.error("Pagamentos - Intent Pagamentos not found: " + ex.toString());
543
+ } catch (Exception e) {
544
+ callbackContext.error("IniciarPagamento error: " + e.toString());
545
+ }
546
+ return false;
547
+ } else if (action.equals("ReimprimirPagamento")) {
548
+ try {
549
+ Intent reprint = redePayments.intentForReprint();
550
+ mCordova.startActivityForResult(useRedeResultCordovaPlugin, reprint, REPRINT_REQUEST_CODE);
437
551
  return true;
438
- // } catch (ActivityNotFoundExeption ex) {
439
- // log.e("Pagamentos", "Application Pagamentos not found");
440
552
  } catch (RedePaymentValidationError ex) {
441
553
  callbackContext.error("Pagamentos - Intent Pagamentos not found: " + ex.toString());
442
554
  } catch (Exception e) {
@@ -447,11 +559,52 @@ public class RedeGPos700 {
447
559
  return false;
448
560
  }
449
561
 
562
+ private FlexTipoPagamento GetFlexTipoPagamentoEnumByName(String receiptTypeName) {
563
+ FlexTipoPagamento flexTipoPagamento = FlexTipoPagamento.CREDITO_A_VISTA;
564
+ switch (receiptTypeName) {
565
+ case "CREDITO_A_VISTA":
566
+ flexTipoPagamento = FlexTipoPagamento.CREDITO_A_VISTA;
567
+ break;
568
+ case "CREDITO_PARCELADO":
569
+ flexTipoPagamento = FlexTipoPagamento.CREDITO_PARCELADO;
570
+ break;
571
+ case "CREDITO_PARCELADO_EMISSOR":
572
+ flexTipoPagamento = FlexTipoPagamento.CREDITO_PARCELADO_EMISSOR;
573
+ break;
574
+ case "DEBITO":
575
+ flexTipoPagamento = FlexTipoPagamento.DEBITO;
576
+ break;
577
+ case "VOUCHER":
578
+ flexTipoPagamento = FlexTipoPagamento.VOUCHER;
579
+ break;
580
+ case "PIX":
581
+ flexTipoPagamento = FlexTipoPagamento.PIX;
582
+ break;
583
+ default:
584
+ flexTipoPagamento = FlexTipoPagamento.CREDITO_A_VISTA;
585
+ break;
586
+ }
587
+ return flexTipoPagamento;
588
+ }
589
+
590
+ protected < T > T parseJsonStringToObj(String objJson, Type objectClass) {
591
+ Gson gson = new Gson();
592
+ T result = gson.fromJson(objJson, objectClass);
593
+ return result;
594
+ }
595
+
596
+ protected String parseObjToJsonSrtring(Object obj) {
597
+ Gson gson = new Gson();
598
+ String result = gson.toJson(obj);
599
+ return result;
600
+ }
601
+
602
+
450
603
  private String ConverterTextoImpressoToHtml(String linhasImpressos) {
451
604
  try {
452
605
  String htmlStr = this.ConverterImpressaoToHtmlInicio();
453
606
 
454
- List<String> linhas = ConverterImpressaoToHtmlLinhasHtml(linhasImpressos);
607
+ List < String > linhas = ConverterImpressaoToHtmlLinhasHtml(linhasImpressos);
455
608
 
456
609
  for (String linha: linhas) {
457
610
  htmlStr += linha;
@@ -467,7 +620,7 @@ public class RedeGPos700 {
467
620
 
468
621
  private boolean ConverterHtmlToBitmap(String htmlString, CallbackContext callbackContext) {
469
622
  try {
470
- AsyncTask<Void, Void, Bitmap> taskBitMap = new AsyncTask <Void, Void, Bitmap> () {
623
+ AsyncTask < Void, Void, Bitmap > taskBitMap = new AsyncTask < Void, Void, Bitmap > () {
471
624
  @Override
472
625
  protected Bitmap doInBackground(Void...voids) {
473
626
  Html2Bitmap build = new Html2Bitmap.Builder().setContext(mContext).setContent(WebViewContent.html(htmlString)).setBitmapWidth(380).setMeasureDelay(300).setScreenshotDelay(300).setStrictMode(true).setTimeout(15).setTextZoom(100).build();
@@ -507,125 +660,125 @@ public class RedeGPos700 {
507
660
 
508
661
  private String ConverterImpressaoToHtmlInicio() {
509
662
  String htmlResult = "<!DOCTYPE html>\n" +
510
- "<html lang='en'>\n" +
511
- "\n" +
512
- "<head>\n" +
513
- " <!-- <meta charset='UTF-8'>\n" +
514
- " <meta http-equiv='X-UA-Compatible' content='IE=edge'>\n" +
515
- " <meta name='viewport' content='width=380, initial-scale=1.0'>\n" +
516
- " <title>Document</title> -->\n" +
517
- "\n" +
518
- " <style>\n" +
519
- " /* @media print {\n" +
520
- " .printer-ticket {\n" +
521
- " border: none !important;\n" +
522
- " }\n" +
523
- " } */\n" +
524
- "\n" +
525
- " body {\n" +
526
- " margin: 0px;\n" +
527
- " width: 380px;\n" +
528
- " /*border: 1px solid black;*/\n" +
529
- " }\n" +
530
- "\n" +
531
- "\n" +
532
- "\n" +
533
- " .printer-ticket {\n" +
534
- " /* background-color: #ffffcc; */\n" +
535
- " background-color: white;\n" +
536
- " font-size: 16px;\n" +
537
-
538
- " /* padding: 10px; */\n" +
539
- " max-width: 380px;\n" +
540
- " /* border: solid 1px black; */\n" +
541
- " /* text-align: center; */\n" +
542
- " /*padding-left: 10px;*/\n" +
543
- " /*padding-right: 10px;*/\n" +
544
- " }\n" +
545
- "\n" +
546
- " /* @media (max-width: 979px) {\n" +
547
- " .section-printer--ticket {\n" +
548
- " position: initial;\n" +
549
- " top: 0;\n" +
550
- " }\n" +
551
- " } */\n" +
552
- "\n" +
553
- " .printer-ticket table {\n" +
554
- " margin: auto;\n" +
555
- "\n" +
556
- " }\n" +
557
- "\n" +
558
- " .printer-ticket * {\n" +
559
- " font-family: monospace;\n" +
560
- " /* font-family: Consolas, Regular;*/\n" +
561
- " /* font-size: 100%; */\n" +
562
- " color: black;\n" +
563
- " /* line-height: 80%; */\n" +
564
- " max-width: 380px;\n" +
565
- " /* line-height: normal; */\n" +
566
- " /* padding-left: 15px; */\n" +
567
- " }\n" +
568
- "\n" +
569
- " [data-normal='true'] {\n" +
570
- " /* letter-spacing: 1px;\n" +
571
- " font-size: 30px;\n" +
572
- " text-align: left; */\n" +
573
- " /* padding-left: 15px; */\n" +
574
- " }\n" +
575
- "\n" +
576
- "\n" +
577
- " [data-expandido='true'] {\n" +
578
- " letter-spacing: 1px;\n" +
579
- " font-size: 30px !important;\n" +
580
- " /* text-align: left !important; */\n" +
581
- " /* padding-left: 15px; */\n" +
582
- " }\n" +
583
- "\n" +
584
- " [data-condensado='true'] {\n" +
585
- " letter-spacing: -2px;\n" +
586
- " font-size: 15px !important;\n" +
587
- " /* text-align: left !important; */\n" +
588
- " /* padding-left: 10px; */\n" +
589
- " }\n" +
590
- "\n" +
591
- " [data-negrito='true'] {\n" +
592
- " font-weight: bold;\n" +
593
- " }\n" +
594
- "\n" +
595
- " [data-reverse='true'] {\n" +
596
- " background-color: black !important;\n" +
597
- " color: white;\n" +
598
- " -webkit-print-color-adjust: exact;\n" +
599
- " }\n" +
600
- "\n" +
601
- " [data-qrcode='true'] {\n" +
602
- " text-align: center;\n" +
603
- " }\n" +
604
- "\n" +
605
- " [data-barcode128='true'] {\n" +
606
- " text-align: center;\n" +
607
- " }\n" +
608
- "\n" +
609
- "\n" +
610
- " [data-alinhamento='1'] {\n" +
611
- " text-align: left;\n" +
612
- " }\n" +
613
- "\n" +
614
- " [data-alinhamento='2'] {\n" +
615
- " text-align: center;\n" +
616
- " }\n" +
617
- "\n" +
618
- " [data-alinhamento='3'] {\n" +
619
- " text-align: right;\n" +
620
- " }\n" +
621
- " </style>\n" +
622
- "</head>\n" +
623
- "\n" +
624
- "<body>\n" +
625
- "\n" +
626
- "\n" +
627
- " <div class='printer-ticket'>\n" +
628
- " <div class='row'>\n";
663
+ "<html lang='en'>\n" +
664
+ "\n" +
665
+ "<head>\n" +
666
+ " <!-- <meta charset='UTF-8'>\n" +
667
+ " <meta http-equiv='X-UA-Compatible' content='IE=edge'>\n" +
668
+ " <meta name='viewport' content='width=380, initial-scale=1.0'>\n" +
669
+ " <title>Document</title> -->\n" +
670
+ "\n" +
671
+ " <style>\n" +
672
+ " /* @media print {\n" +
673
+ " .printer-ticket {\n" +
674
+ " border: none !important;\n" +
675
+ " }\n" +
676
+ " } */\n" +
677
+ "\n" +
678
+ " body {\n" +
679
+ " margin: 0px;\n" +
680
+ " width: 380px;\n" +
681
+ " /*border: 1px solid black;*/\n" +
682
+ " }\n" +
683
+ "\n" +
684
+ "\n" +
685
+ "\n" +
686
+ " .printer-ticket {\n" +
687
+ " /* background-color: #ffffcc; */\n" +
688
+ " background-color: white;\n" +
689
+ " font-size: 16px;\n" +
690
+
691
+ " /* padding: 10px; */\n" +
692
+ " max-width: 380px;\n" +
693
+ " /* border: solid 1px black; */\n" +
694
+ " /* text-align: center; */\n" +
695
+ " /*padding-left: 10px;*/\n" +
696
+ " /*padding-right: 10px;*/\n" +
697
+ " }\n" +
698
+ "\n" +
699
+ " /* @media (max-width: 979px) {\n" +
700
+ " .section-printer--ticket {\n" +
701
+ " position: initial;\n" +
702
+ " top: 0;\n" +
703
+ " }\n" +
704
+ " } */\n" +
705
+ "\n" +
706
+ " .printer-ticket table {\n" +
707
+ " margin: auto;\n" +
708
+ "\n" +
709
+ " }\n" +
710
+ "\n" +
711
+ " .printer-ticket * {\n" +
712
+ " font-family: monospace;\n" +
713
+ " /* font-family: Consolas, Regular;*/\n" +
714
+ " /* font-size: 100%; */\n" +
715
+ " color: black;\n" +
716
+ " /* line-height: 80%; */\n" +
717
+ " max-width: 380px;\n" +
718
+ " /* line-height: normal; */\n" +
719
+ " /* padding-left: 15px; */\n" +
720
+ " }\n" +
721
+ "\n" +
722
+ " [data-normal='true'] {\n" +
723
+ " /* letter-spacing: 1px;\n" +
724
+ " font-size: 30px;\n" +
725
+ " text-align: left; */\n" +
726
+ " /* padding-left: 15px; */\n" +
727
+ " }\n" +
728
+ "\n" +
729
+ "\n" +
730
+ " [data-expandido='true'] {\n" +
731
+ " letter-spacing: 1px;\n" +
732
+ " font-size: 30px !important;\n" +
733
+ " /* text-align: left !important; */\n" +
734
+ " /* padding-left: 15px; */\n" +
735
+ " }\n" +
736
+ "\n" +
737
+ " [data-condensado='true'] {\n" +
738
+ " letter-spacing: -2px;\n" +
739
+ " font-size: 15px !important;\n" +
740
+ " /* text-align: left !important; */\n" +
741
+ " /* padding-left: 10px; */\n" +
742
+ " }\n" +
743
+ "\n" +
744
+ " [data-negrito='true'] {\n" +
745
+ " font-weight: bold;\n" +
746
+ " }\n" +
747
+ "\n" +
748
+ " [data-reverse='true'] {\n" +
749
+ " background-color: black !important;\n" +
750
+ " color: white;\n" +
751
+ " -webkit-print-color-adjust: exact;\n" +
752
+ " }\n" +
753
+ "\n" +
754
+ " [data-qrcode='true'] {\n" +
755
+ " text-align: center;\n" +
756
+ " }\n" +
757
+ "\n" +
758
+ " [data-barcode128='true'] {\n" +
759
+ " text-align: center;\n" +
760
+ " }\n" +
761
+ "\n" +
762
+ "\n" +
763
+ " [data-alinhamento='1'] {\n" +
764
+ " text-align: left;\n" +
765
+ " }\n" +
766
+ "\n" +
767
+ " [data-alinhamento='2'] {\n" +
768
+ " text-align: center;\n" +
769
+ " }\n" +
770
+ "\n" +
771
+ " [data-alinhamento='3'] {\n" +
772
+ " text-align: right;\n" +
773
+ " }\n" +
774
+ " </style>\n" +
775
+ "</head>\n" +
776
+ "\n" +
777
+ "<body>\n" +
778
+ "\n" +
779
+ "\n" +
780
+ " <div class='printer-ticket'>\n" +
781
+ " <div class='row'>\n";
629
782
 
630
783
 
631
784
  return htmlResult;
@@ -633,129 +786,129 @@ public class RedeGPos700 {
633
786
 
634
787
  private String ConverterImpressaoToHtmlInicioTentativa1() {
635
788
  String htmlResult = "<!DOCTYPE html>\n" +
636
- "<html lang='en'>\n" +
637
- "\n" +
638
- "<head>\n" +
639
- " <meta charset='UTF-8'>\n" +
640
- " <meta http-equiv='X-UA-Compatible' content='IE=edge'>\n" +
641
- " <meta name='viewport' content='width=380, initial-scale=1.0'>\n" +
642
- " <title>Document</title>\n" +
643
- "\n" +
644
- " <style>\n" +
645
- " /* @media print {\n" +
646
- " .printer-ticket {\n" +
647
- " border: none !important;\n" +
648
- " }\n" +
649
- " } */\n" +
650
- "\n" +
651
- " body {\n" +
652
- " margin: 0px;\n" +
653
- " width: 380px;\n" +
654
- " border: 1px solid black;\n" +
655
- " }\n" +
656
- "\n" +
657
- "\n" +
658
- "\n" +
659
- " .printer-ticket {\n" +
660
- " /* background-color: #ffffcc; */\n" +
661
- " background-color: white;\n" +
662
- " /* padding: 10px; */\n" +
663
- " max-width: 380px;\n" +
664
- " /* border: solid 1px black; */\n" +
665
- " /* text-align: center; */\n" +
666
- " padding-left: 10px;\n" +
667
- " padding-right: 10px;\n" +
668
- " }\n" +
669
- "\n" +
670
- " /* @media (max-width: 979px) {\n" +
671
- " .section-printer--ticket {\n" +
672
- " position: initial;\n" +
673
- " top: 0;\n" +
674
- " }\n" +
675
- " } */\n" +
676
- "\n" +
677
- " .printer-ticket table {\n" +
678
- " margin: auto;\n" +
679
- "\n" +
680
- " }\n" +
681
- "\n" +
682
- " .printer-ticket * {\n" +
683
- " font-family: monospace;\n" +
684
- " /* font-size: 100%; */\n" +
685
- " color: black;\n" +
686
- " /* line-height: 80%; */\n" +
687
- " max-width: 380px;\n" +
688
- " /* line-height: normal; */\n" +
689
- " /* padding-left: 15px; */\n" +
690
- " }\n" +
691
- "\n" +
692
- " [data-normal='true'] {\n" +
693
- " /* letter-spacing: 1px;\n" +
694
- " font-size: 30px;\n" +
695
- " text-align: left; */\n" +
696
- " /* padding-left: 15px; */\n" +
697
- " }\n" +
698
- "\n" +
699
- "\n" +
700
- " [data-expandido='true'] {\n" +
701
- " letter-spacing: 1px;\n" +
702
- " font-size: 30px !important;\n" +
703
- " /* text-align: left !important; */\n" +
704
- " /* padding-left: 15px; */\n" +
705
- " }\n" +
706
- "\n" +
707
- " [data-condensado='true'] {\n" +
708
- " letter-spacing: -2px;\n" +
709
- " font-size: 15px !important;\n" +
710
- " /* text-align: left !important; */\n" +
711
- " /* padding-left: 10px; */\n" +
712
- " }\n" +
713
- "\n" +
714
- " [data-negrito='true'] {\n" +
715
- " font-weight: bold;\n" +
716
- " }\n" +
717
- "\n" +
718
- " [data-reverse='true'] {\n" +
719
- " background-color: black !important;\n" +
720
- " color: white;\n" +
721
- " -webkit-print-color-adjust: exact;\n" +
722
- " }\n" +
723
- "\n" +
724
- " [data-qrcode='true'] {\n" +
725
- " text-align: center;\n" +
726
- " }\n" +
727
- "\n" +
728
- " [data-barcode128='true'] {\n" +
729
- " text-align: center;\n" +
730
- " }\n" +
731
- "\n" +
732
- "\n" +
733
- " [data-alinhamento='1'] {\n" +
734
- " text-align: left;\n" +
735
- " }\n" +
736
- "\n" +
737
- " [data-alinhamento='2'] {\n" +
738
- " text-align: center;\n" +
739
- " }\n" +
740
- "\n" +
741
- " [data-alinhamento='3'] {\n" +
742
- " text-align: right;\n" +
743
- " }\n" +
744
- " </style>\n" +
745
- "</head>\n" +
746
- "\n" +
747
- "<body>\n" +
748
- "\n" +
749
- "\n" +
750
- " <div class='printer-ticket'>\n" +
751
- " <div class='row'>\n";
789
+ "<html lang='en'>\n" +
790
+ "\n" +
791
+ "<head>\n" +
792
+ " <meta charset='UTF-8'>\n" +
793
+ " <meta http-equiv='X-UA-Compatible' content='IE=edge'>\n" +
794
+ " <meta name='viewport' content='width=380, initial-scale=1.0'>\n" +
795
+ " <title>Document</title>\n" +
796
+ "\n" +
797
+ " <style>\n" +
798
+ " /* @media print {\n" +
799
+ " .printer-ticket {\n" +
800
+ " border: none !important;\n" +
801
+ " }\n" +
802
+ " } */\n" +
803
+ "\n" +
804
+ " body {\n" +
805
+ " margin: 0px;\n" +
806
+ " width: 380px;\n" +
807
+ " border: 1px solid black;\n" +
808
+ " }\n" +
809
+ "\n" +
810
+ "\n" +
811
+ "\n" +
812
+ " .printer-ticket {\n" +
813
+ " /* background-color: #ffffcc; */\n" +
814
+ " background-color: white;\n" +
815
+ " /* padding: 10px; */\n" +
816
+ " max-width: 380px;\n" +
817
+ " /* border: solid 1px black; */\n" +
818
+ " /* text-align: center; */\n" +
819
+ " padding-left: 10px;\n" +
820
+ " padding-right: 10px;\n" +
821
+ " }\n" +
822
+ "\n" +
823
+ " /* @media (max-width: 979px) {\n" +
824
+ " .section-printer--ticket {\n" +
825
+ " position: initial;\n" +
826
+ " top: 0;\n" +
827
+ " }\n" +
828
+ " } */\n" +
829
+ "\n" +
830
+ " .printer-ticket table {\n" +
831
+ " margin: auto;\n" +
832
+ "\n" +
833
+ " }\n" +
834
+ "\n" +
835
+ " .printer-ticket * {\n" +
836
+ " font-family: monospace;\n" +
837
+ " /* font-size: 100%; */\n" +
838
+ " color: black;\n" +
839
+ " /* line-height: 80%; */\n" +
840
+ " max-width: 380px;\n" +
841
+ " /* line-height: normal; */\n" +
842
+ " /* padding-left: 15px; */\n" +
843
+ " }\n" +
844
+ "\n" +
845
+ " [data-normal='true'] {\n" +
846
+ " /* letter-spacing: 1px;\n" +
847
+ " font-size: 30px;\n" +
848
+ " text-align: left; */\n" +
849
+ " /* padding-left: 15px; */\n" +
850
+ " }\n" +
851
+ "\n" +
852
+ "\n" +
853
+ " [data-expandido='true'] {\n" +
854
+ " letter-spacing: 1px;\n" +
855
+ " font-size: 30px !important;\n" +
856
+ " /* text-align: left !important; */\n" +
857
+ " /* padding-left: 15px; */\n" +
858
+ " }\n" +
859
+ "\n" +
860
+ " [data-condensado='true'] {\n" +
861
+ " letter-spacing: -2px;\n" +
862
+ " font-size: 15px !important;\n" +
863
+ " /* text-align: left !important; */\n" +
864
+ " /* padding-left: 10px; */\n" +
865
+ " }\n" +
866
+ "\n" +
867
+ " [data-negrito='true'] {\n" +
868
+ " font-weight: bold;\n" +
869
+ " }\n" +
870
+ "\n" +
871
+ " [data-reverse='true'] {\n" +
872
+ " background-color: black !important;\n" +
873
+ " color: white;\n" +
874
+ " -webkit-print-color-adjust: exact;\n" +
875
+ " }\n" +
876
+ "\n" +
877
+ " [data-qrcode='true'] {\n" +
878
+ " text-align: center;\n" +
879
+ " }\n" +
880
+ "\n" +
881
+ " [data-barcode128='true'] {\n" +
882
+ " text-align: center;\n" +
883
+ " }\n" +
884
+ "\n" +
885
+ "\n" +
886
+ " [data-alinhamento='1'] {\n" +
887
+ " text-align: left;\n" +
888
+ " }\n" +
889
+ "\n" +
890
+ " [data-alinhamento='2'] {\n" +
891
+ " text-align: center;\n" +
892
+ " }\n" +
893
+ "\n" +
894
+ " [data-alinhamento='3'] {\n" +
895
+ " text-align: right;\n" +
896
+ " }\n" +
897
+ " </style>\n" +
898
+ "</head>\n" +
899
+ "\n" +
900
+ "<body>\n" +
901
+ "\n" +
902
+ "\n" +
903
+ " <div class='printer-ticket'>\n" +
904
+ " <div class='row'>\n";
752
905
 
753
906
 
754
907
  return htmlResult;
755
908
  }
756
909
 
757
- private List<String> ConverterImpressaoToHtmlLinhasHtml(String textoImpresso) {
758
- List<String> result = new ArrayList<String>();;
910
+ private List < String > ConverterImpressaoToHtmlLinhasHtml(String textoImpresso) {
911
+ List < String > result = new ArrayList < String > ();;
759
912
  try {
760
913
  String[] linhas = textoImpresso.split("\n");
761
914
  for (String item: linhas) {
@@ -920,8 +1073,8 @@ public class RedeGPos700 {
920
1073
  }
921
1074
 
922
1075
  result = "<div class='row'>\n" +
923
- " <div class='col-12' " + textoExpandido + textoCondensado + textoNegrito + textoReverse + textoBarCode + textoQrCode + " >" + texto + "</div>\n" +
924
- " </div>";
1076
+ " <div class='col-12' " + textoExpandido + textoCondensado + textoNegrito + textoReverse + textoBarCode + textoQrCode + " >" + texto + "</div>\n" +
1077
+ " </div>";
925
1078
  return result;
926
1079
  } catch (Exception ex) {
927
1080
  throw ex;
@@ -930,9 +1083,9 @@ public class RedeGPos700 {
930
1083
 
931
1084
  private String ConverterImpressaoToHtmlFinal() {
932
1085
  String htmlResult = " </div> " +
933
- "</div>" +
934
- "</body>" +
935
- "</html>";
1086
+ "</div>" +
1087
+ "</body>" +
1088
+ "</html>";
936
1089
 
937
1090
  return htmlResult;
938
1091
  }
@@ -1101,13 +1254,13 @@ public class RedeGPos700 {
1101
1254
  }
1102
1255
 
1103
1256
  public ConfigPrint(String fonte,
1104
- String alinhamento,
1105
- int tamanho,
1106
- int offSet,
1107
- int lineSpace,
1108
- boolean negrito,
1109
- boolean italico,
1110
- boolean sublinhado) {
1257
+ String alinhamento,
1258
+ int tamanho,
1259
+ int offSet,
1260
+ int lineSpace,
1261
+ boolean negrito,
1262
+ boolean italico,
1263
+ boolean sublinhado) {
1111
1264
  this.fonte = fonte;
1112
1265
  this.alinhamento = alinhamento;
1113
1266
  this.tamanho = tamanho;
@@ -1119,15 +1272,15 @@ public class RedeGPos700 {
1119
1272
  }
1120
1273
 
1121
1274
  public ConfigPrint(String fonte,
1122
- String alinhamento,
1123
- int tamanho,
1124
- int offSet,
1125
- int iHeight,
1126
- int iWidth,
1127
- int lineSpace,
1128
- boolean negrito,
1129
- boolean italico,
1130
- boolean sublinhado) {
1275
+ String alinhamento,
1276
+ int tamanho,
1277
+ int offSet,
1278
+ int iHeight,
1279
+ int iWidth,
1280
+ int lineSpace,
1281
+ boolean negrito,
1282
+ boolean italico,
1283
+ boolean sublinhado) {
1131
1284
  this.fonte = fonte;
1132
1285
  this.alinhamento = alinhamento;
1133
1286
  this.tamanho = tamanho;
@@ -1289,10 +1442,10 @@ public class RedeGPos700 {
1289
1442
  * @param a = Activity atual que esta sendo inicializada a class
1290
1443
  *
1291
1444
  public GertecPrinter(Activity a) {
1292
- this.activity = a;
1293
- startIGEDI(a);
1445
+ this.activity = a;
1446
+ startIGEDI(a);
1294
1447
  }
1295
- */
1448
+ */
1296
1449
 
1297
1450
  /**
1298
1451
  * Método que instância a classe GEDI da lib deve ser usado apenas para o GPOS 700
@@ -1303,15 +1456,15 @@ public class RedeGPos700 {
1303
1456
  **/
1304
1457
  private void startIGEDI() {
1305
1458
  new Thread(() -> {
1306
- GEDI.init(this.context);
1307
- this.iGedi = GEDI.getInstance(this.context);
1308
- this.iPrint = this.iGedi.getPRNTR();
1309
- try {
1310
- new Thread().sleep(250);
1311
- icl = GEDI.getInstance().getCL();
1312
- } catch (InterruptedException e) {
1313
- e.printStackTrace();
1314
- }
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
+ }
1315
1468
  }).start();
1316
1469
  }
1317
1470
 
@@ -1323,18 +1476,18 @@ public class RedeGPos700 {
1323
1476
  * Não alterar...
1324
1477
  *
1325
1478
  private void startIGEDI(Activity a) {
1326
- new Thread(() -> {
1327
- iGedi = new Gedi(a);
1328
- this.iGedi = GEDI.getInstance(a);
1329
- this.iPrint = this.iGedi.getPRNTR();
1330
- try {
1331
- new Thread().sleep(250);
1332
- } catch (InterruptedException e) {
1333
- e.printStackTrace();
1334
- }
1335
- }).start();
1479
+ new Thread(() -> {
1480
+ iGedi = new Gedi(a);
1481
+ this.iGedi = GEDI.getInstance(a);
1482
+ this.iPrint = this.iGedi.getPRNTR();
1483
+ try {
1484
+ new Thread().sleep(250);
1485
+ } catch (InterruptedException e) {
1486
+ e.printStackTrace();
1487
+ }
1488
+ }).start();
1336
1489
  }
1337
- */
1490
+ */
1338
1491
 
1339
1492
  /**
1340
1493
  * Método que recebe a configuração para ser usada na impressão
@@ -1634,12 +1787,12 @@ public class RedeGPos700 {
1634
1787
 
1635
1788
  if (RedeGPos700.Model.equals(RedeGPos700.G700)) {
1636
1789
  id = context.getResources().getIdentifier(imagem, "drawable",
1637
- context.getPackageName());
1790
+ context.getPackageName());
1638
1791
  bmp = BitmapFactory.decodeResource(context.getResources(), id);
1639
1792
  } else {
1640
1793
  id = this.activity.getApplicationContext().getResources().getIdentifier(
1641
- imagem, "drawable",
1642
- this.activity.getApplicationContext().getPackageName());
1794
+ imagem, "drawable",
1795
+ this.activity.getApplicationContext().getPackageName());
1643
1796
  bmp = BitmapFactory.decodeResource(this.activity.getApplicationContext().getResources(), id);
1644
1797
  }
1645
1798
 
@@ -1881,6 +2034,17 @@ public class RedeGPos700 {
1881
2034
  return retorno;
1882
2035
  }
1883
2036
 
1884
- }
2037
+ // protected <T> T parseJsonStringToObj(String objJson, Type objectClass) {
2038
+ // Gson gson = new Gson();
2039
+ // T result = gson.fromJson(objJson, objectClass);
2040
+ // return result;
2041
+ // }
1885
2042
 
2043
+ protected String parseObjToJsonSrtring(Object obj) {
2044
+ // Gson gson = new Gson();
2045
+ // String result = gson.toJson(obj);
2046
+ String result = "testes";
2047
+ return result;
2048
+ }
2049
+ }
1886
2050
  }
package/src/build.gradle CHANGED
@@ -46,7 +46,7 @@ dependencies {
46
46
  //adicionamos a implementação desses atributos em específicos, assim não será necessário que o plugin depende de alguma dependência como app-compat ou similares.
47
47
  implementation 'com.android.support:design:28.0.0'
48
48
 
49
- implementation 'com.google.code.gson:gson:2.8.9'
49
+ implementation 'com.google.code.gson:gson:2.8.5'
50
50
 
51
51
 
52
52
 
@@ -40,8 +40,12 @@ exports.IniciarPagamento = function (params, success, error) {
40
40
  exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.Gpos700.IniciarPagamento', [params]);
41
41
  }
42
42
 
43
- exports.IniciarCancelamentoVenda = function (params, success, error) {
44
- exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.Gpos700.IniciarCancelamentoVenda', [params]);
43
+ exports.EstornarPagamento = function (params, success, error) {
44
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.Gpos700.EstornarPagamento', [params]);
45
+ }
46
+
47
+ exports.ReimprimirPagamento = function (params, success, error) {
48
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.Gpos700.ReimprimirPagamento', [params]);
45
49
  }
46
50
 
47
51