cordova-plugin-netcontroll-integration 1.0.8 → 1.0.11

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,9 +1,5 @@
1
- Version 0.0.2 - Adição de Keywords, ajustes na configuração do plugin (plugin.xml e package.json) e adição de conteúdo ao README.
2
- Version 0.0.3 - Versão da bibloteca E1 atualizada para 1.0.16 (corte extra no imprimeXMLNFCE removido), atualização de imports e adição de comentários.
1
+ Versao 1.0.9
3
2
 
4
- É necessário instalar o plugin que permite a compilação de projetos/plugins que referenciem tanto as librarys do Android Support e AndroidX, que é o caso da versão mais atual da lib "E1":
5
- #cordova-plugin-androidx-adapter
6
-
7
- clobbers:
8
- cordova.plugins.elgin.minipdv
3
+ Funções internas de integração XMenu / NetControll
9
4
 
5
+ - Finalização completa de integração Elgin Terminal M10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-netcontroll-integration",
3
- "version": "1.0.8",
3
+ "version": "1.0.11",
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.8"
2
+ <plugin id="cordova-plugin-netcontroll-integration" version="1.0.11"
3
3
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  xmlns:android="http://schemas.android.com/apk/res/android">
5
5
 
@@ -9,6 +9,8 @@ import org.json.JSONArray;
9
9
  import org.json.JSONException;
10
10
  import org.json.JSONObject;
11
11
 
12
+ // import androidx.annotation.NonNull;
13
+ import androidx.annotation.NonNull;
12
14
  import android.app.Activity;
13
15
  import android.graphics.Bitmap;
14
16
  import android.content.Context;
@@ -17,6 +19,7 @@ import android.widget.Toast;
17
19
  import android.net.Uri;
18
20
  import android.content.Intent;
19
21
  import android.provider.MediaStore;
22
+ import android.os.Build;
20
23
 
21
24
  import static android.app.Activity.RESULT_OK;
22
25
 
@@ -27,34 +30,60 @@ import javax.security.auth.callback.Callback;
27
30
 
28
31
  import java.util.List;
29
32
 
30
- //Cielo Package
31
- import cielo.orders.domain.Credentials;
33
+ //Json Serialize
34
+ import com.google.gson.Gson;
35
+ import com.google.gson.GsonBuilder;
36
+
37
+
38
+ //Cielo Package Sdk
32
39
 
40
+ import cielo.orders.domain.CancellationRequest;
41
+ import cielo.orders.domain.Credentials;
42
+ import cielo.orders.domain.DeviceModel;
33
43
  import cielo.orders.domain.Item;
34
- import cielo.orders.domain.CheckoutRequest;
35
44
  import cielo.orders.domain.Order;
36
45
  import cielo.orders.domain.product.PrimaryProduct;
37
46
  import cielo.orders.domain.product.SecondaryProduct;
47
+ import cielo.orders.domain.CheckoutRequest;
38
48
  import cielo.orders.domain.ResultOrders;
49
+ import cielo.orders.domain.PrinterAttributes;
50
+ import cielo.orders.domain.Settings;
39
51
 
40
52
  import cielo.sdk.order.OrderManager;
53
+ import cielo.sdk.order.cancellation.CancellationListener;
41
54
  import cielo.sdk.order.ServiceBindListener;
55
+ import cielo.sdk.order.payment.Payment;
42
56
  import cielo.sdk.order.payment.PaymentCode;
43
57
  import cielo.sdk.order.payment.PaymentListener;
44
58
  import cielo.sdk.order.payment.PaymentError;
45
-
46
-
47
-
59
+ import cielo.sdk.order.PrinterListener;
60
+ import cielo.sdk.printer.PrinterManager;
61
+ import cielo.sdk.info.InfoManager;
48
62
 
49
63
 
50
64
  /**
51
65
  * This class echoes a string called from JavaScript.
52
66
  */
53
67
  public class CieloLioLocal {
54
- //Cielo
68
+
69
+ //Cielo Package Sdk
55
70
  public OrderManager orderManager;
71
+ public InfoManager infoManager;
72
+
73
+
74
+ //Cielo Variables
75
+ Credentials _credentials ;
56
76
  public boolean orderManagerServiceBinded = false;
77
+ public Order order;
78
+ public Payment payment;
79
+
57
80
 
81
+ //Cielo Printer
82
+ private PrinterManager printerManager;
83
+ private PrinterListener printerListener;
84
+ private HashMap<String, Integer> alignCenter = new HashMap<>();
85
+ private HashMap<String, Integer> alignLeft = new HashMap<>();
86
+ private HashMap<String, Integer> alignRight = new HashMap<>();
58
87
 
59
88
  //Cordova/Java Params
60
89
  private Activity mActivity;
@@ -71,126 +100,671 @@ public class CieloLioLocal {
71
100
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
72
101
  this.webView = webView;
73
102
  mActivity = cordova.getActivity();
74
- mContext = cordova.getActivity().getApplicationContext();
103
+ // mContext = cordova.getActivity().getApplicationContext();
104
+ mContext = this.webView.getContext();
105
+ }
106
+
107
+ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
108
+ if (action.equals("ConfigureSdk")) {
109
+ JSONObject params = args.getJSONObject(0);
110
+ try {
111
+ this.configSDK(params.getString("clientId"),params.getString("accessToken"), callbackContext);
112
+ return true;
113
+ } catch (Exception error1) {
114
+ callbackContext.error("Result - Cielo - LioLocal - ConfigureSdk: " + "Error Detail: " + error1);
115
+ }
116
+ return false;
117
+ }
118
+ if (action.equals("OrderManagerBind")) {
119
+ try {
120
+ this.orderManagerBind(callbackContext);
121
+ return true;
122
+ } catch (Exception error1) {
123
+ callbackContext.error("Result - Cielo - LioLocal - OrderManagerBind: " + "Error Detail: " + error1);
124
+ }
125
+ return false;
126
+ }
127
+
128
+
129
+ else if (action.equals("CreateDraftOrder")) {
130
+ JSONObject params = args.getJSONObject(0);
131
+ try {
132
+ boolean result = this.createDraftOrder(params.getString("orderReference"), callbackContext);
133
+ return result;
134
+ } catch (Exception error1) {
135
+ callbackContext.error("Result - Cielo - LioLocal CreateDraftOrder: " + "Error Detail: " + error1);
136
+ }
137
+ return false;
138
+ }
139
+ else if (action.equals("AddOrderItem")) {
140
+ JSONObject params = args.getJSONObject(0);
141
+ try {
142
+ boolean result = this.addOrderItem(
143
+ params.getString("sku"),
144
+ params.getString("name"),
145
+ params.getInt("unitPrice"),
146
+ params.getInt("quantity"),
147
+ params.getString("unityOfMeasure"),
148
+ callbackContext
149
+ );
150
+ return result;
151
+ } catch (Exception error1) {
152
+ callbackContext.error("Result - Cielo - LioLocal AddOrderItem: " + "Error Detail: " + error1);
153
+ }
154
+ return false;
155
+ }
156
+ else if (action.equals("MakePayment")) {
157
+ JSONObject params = args.getJSONObject(0);
158
+ try {
159
+ boolean result = this.makePayment(
160
+ params.getString("orderReference"),
161
+ params.getString("orderId"),
162
+ params.getInt("amount"),
163
+ params.getString("ec"),
164
+ params.getInt("installments"),
165
+ params.getString("email"),
166
+ params.getString("paymentCode"),
167
+ callbackContext
168
+ );
169
+ return result;
170
+ } catch (Exception error1) {
171
+ callbackContext.error("Result - Cielo - LioLocal MakePayment: " + "Error Detail: " + error1);
172
+ }
173
+ return false;
174
+ }
175
+ else if (action.equals("OrderManagerUnbind")) {
176
+ try {
177
+ orderManager.unbind();
178
+ orderManagerServiceBinded = false;
179
+ callbackContext.success("Unbind: Success");
180
+ return true;
181
+ } catch (Exception error1) {
182
+ callbackContext.error("Result - Cielo - LioLocal Unbind: " + "Error Detail: " + error1);
183
+ }
184
+ return false;
185
+ }
186
+
187
+
188
+
189
+
190
+
191
+ else if (action.equals("ListOrders")) {
192
+ JSONObject params = args.getJSONObject(0);
193
+ try {
194
+ boolean result = this.listOrders(params.getInt("pageSize"), params.getInt("page"), callbackContext);
195
+ return result;
196
+ } catch (Exception error1) {
197
+ callbackContext.error("Result - Cielo - LioLocal ListOrders: " + "Error Detail: " + error1);
198
+ }
199
+ }
200
+
201
+ else if (action.equals("CancelPayment")) {
202
+ JSONObject paramsObj = args.getJSONObject(0);
203
+ try {
204
+ boolean result = this.cancelPayment(paramsObj, callbackContext);
205
+ return result;
206
+ } catch (Exception error1) {
207
+ callbackContext.error("Result - Cielo - LioLocal ListOrders: " + "Error Detail: " + error1);
208
+ }
209
+ }
210
+
211
+
212
+ else if (action.equals("TerminalInformation")) {
213
+ JSONObject params = args.getJSONObject(0);
214
+ try {
215
+ boolean result = this.terminalInformation(params.getString("informatitonType"), callbackContext);
216
+ return result;
217
+ } catch (Exception error1) {
218
+ callbackContext.error("Result - Cielo - LioLocal ListOrders: " + "Error Detail: " + error1);
219
+ }
220
+ }
221
+
222
+
223
+ else if (action.equals("PrintSimpleText")) {
224
+ JSONObject params = args.getJSONObject(0);
225
+ try {
226
+ boolean result = this.print_SimpleText(
227
+ params.getString("textToPrint"),
228
+ params.getInt("textAlign"),
229
+ params.getInt("textSize"),
230
+ params.getInt("textTypeFace"),
231
+ 0,
232
+ 0,
233
+ 0,
234
+ 0,
235
+ 0,
236
+ 0,
237
+ //params.getInt("textMarginLeft"),
238
+ //params.getInt("textMarginRight"),
239
+ //params.getInt("textMarginTop"),
240
+ //params.getInt("textMarginBotton"),
241
+ //params.getInt("textLineSpace"),
242
+ //params.getInt("textWeight"),
243
+ callbackContext);
244
+ return result;
245
+ } catch (Exception error1) {
246
+ callbackContext.error("Result - Cielo - LioLocal PrintSimpleText: " + "Error Detail: " + error1);
247
+ }
248
+ }
249
+
250
+ else if (action.equals("PrintQrCode")) {
251
+ JSONObject params = args.getJSONObject(0);
252
+ try {
253
+ boolean result = this.print_QrCode(
254
+ params.getString("textToPrint"),
255
+ params.getInt("textAlign"),
256
+ params.getInt("size"),
257
+ callbackContext);
258
+ return result;
259
+ } catch (Exception error1) {
260
+ callbackContext.error("Result - Cielo - LioLocal PrintQrCode: " + "Error Detail: " + error1);
261
+ }
262
+ }
263
+
264
+ else if (action.equals("PrintBarCode")) {
265
+ JSONObject params = args.getJSONObject(0);
266
+ try {
267
+ boolean result = this.print_BarCode(
268
+ params.getString("textToPrint"),
269
+ params.getInt("textAlign"),
270
+ params.getInt("barcodeWidth"),
271
+ params.getInt("barcodeHeight"),
272
+ callbackContext);
273
+ return result;
274
+ } catch (Exception error1) {
275
+ callbackContext.error("Result - Cielo - LioLocal PrintBarCode: " + "Error Detail: " + error1);
276
+ }
277
+ }
278
+
279
+ return false;
75
280
  }
76
281
 
77
- public String Teste() {
78
- return "Result - CieloLioLocalClass: ok";
282
+
283
+ // Cielo Functions Helpers
284
+ private cielo.sdk.order.payment.PaymentCode GetPaymentCodeFromName(String paymentCodeName) {
285
+ cielo.sdk.order.payment.PaymentCode paymentCode = null;
286
+ switch (paymentCodeName) {
287
+ case "DEBITO_AVISTA":
288
+ paymentCode = PaymentCode.DEBITO_AVISTA;
289
+ break;
290
+ case "DEBITO_PREDATADO":
291
+ paymentCode = PaymentCode.DEBITO_PREDATADO;
292
+ break;
293
+ case "CREDITO_AVISTA":
294
+ paymentCode = PaymentCode.CREDITO_AVISTA;
295
+ break;
296
+ case "CREDITO_PARCELADO_LOJA":
297
+ paymentCode = PaymentCode.CREDITO_PARCELADO_LOJA;
298
+ break;
299
+ case "CREDITO_PARCELADO_ADM":
300
+ paymentCode = PaymentCode.CREDITO_PARCELADO_ADM;
301
+ break;
302
+ case "CREDITO_PARCELADO_BNCO":
303
+ paymentCode = PaymentCode.CREDITO_PARCELADO_BNCO;
304
+ break;
305
+ case "CARTAO_LOJA_AVISTA":
306
+ paymentCode = PaymentCode.CARTAO_LOJA_AVISTA;
307
+ break;
308
+ case "CARTAO_LOJA_PARCELADO_LOJA":
309
+ paymentCode = PaymentCode.CARTAO_LOJA_PARCELADO_LOJA;
310
+ break;
311
+ case "CARTAO_LOJA_PARCELADO":
312
+ paymentCode = PaymentCode.CARTAO_LOJA_PARCELADO;
313
+ break;
314
+ case "PRE_AUTORIZACAO":
315
+ paymentCode = PaymentCode.PRE_AUTORIZACAO;
316
+ break;
317
+ case "VOUCHER_ALIMENTACAO":
318
+ paymentCode = PaymentCode.VOUCHER_ALIMENTACAO;
319
+ break;
320
+ case "VOUCHER_REFEICAO":
321
+ paymentCode = PaymentCode.VOUCHER_REFEICAO;
322
+ break;
323
+ case "VISAVALE_REFEICAO":
324
+ paymentCode = PaymentCode.VISAVALE_REFEICAO;
325
+ break;
326
+ case "VISAVALE_ALIMENTACAO":
327
+ paymentCode = PaymentCode.VISAVALE_ALIMENTACAO;
328
+ break;
329
+ default:
330
+ break;
331
+ }
332
+ return paymentCode;
79
333
  }
80
334
 
81
- public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
82
335
 
83
- if (action.equals("Teste")) {
84
- int arg1 = args.getInt(0);
85
- if (arg1 == 0) {
86
- Credentials credentials = new Credentials("M2vcq2fr0oWKbKd5bvpDoGZvHXQ8IneDLBJEulDjxNA59MOA2D/ EMOfYfErX7Y537JZgJvlgG0r805v5jYTxCgNiPtxm500bBUSxh", "NMgpwK4N5dcLCWnOr2kYbDIFcQdLPEn5M2ObKUTULEOdhxzFZu");
87
- orderManager = new OrderManager(credentials, mContext);
88
- if (credentials == null) {
89
- callbackContext.success("Result - CieloLioLocalClass: Erro Credencial " + action);
90
- return false;
91
- } else {
92
- callbackContext.success("Result - CieloLioLocalClass: Tem Credencial " + action + " Token: " + credentials.getAccessToken().toString());
93
- return true;
94
-
95
- }
96
-
97
-
98
- // callbackContext.success("Result - CieloLioLocalClass: ok " + action);
99
- // return false;
100
- }
101
- else {
102
- callbackContext.success("Result - CieloLioLocalClass: noOk " + action);
103
- return false;
336
+ // Cielo Functions
337
+
338
+ protected void configSDK(String clientId, String accessToken, CallbackContext callbackContext) {
339
+ this._credentials = new Credentials(clientId, accessToken);
340
+ this.orderManager = new OrderManager(this._credentials, this.mContext);
341
+ callbackContext.success("configSDK: ok");
342
+ }
343
+
344
+ protected void orderManagerBind(CallbackContext callbackContext) {
345
+ this.orderManager.bind(this.mContext, new ServiceBindListener() {
346
+ @Override
347
+ public void onServiceBoundError(Throwable throwable) {
348
+ orderManagerServiceBinded = false;
349
+ callbackContext.error(String.format("orderManagerBind: onServiceBoundError: Erro fazendo bind do serviço de ordem -> %s",
350
+ throwable.getMessage()));
351
+ }
352
+
353
+ @Override
354
+ public void onServiceBound() {
355
+ orderManagerServiceBinded = true;
356
+ callbackContext.success("orderManagerBind: onServiceBound: Success");
357
+ // orderManager.createDraftOrder("REFERENCIA DA ORDEM");
358
+ // Toast.makeText(mContext,String.format("configSDK: onServiceBound"), Toast.LENGTH_LONG).show();
359
+ }
360
+
361
+ @Override
362
+ public void onServiceUnbound() {
363
+ orderManagerServiceBinded = false;
364
+ callbackContext.success("orderManagerBind: onServiceUnbound: Success");
365
+ // Toast.makeText(mContext,String.format("configSDK: onServiceUnbound"), Toast.LENGTH_LONG).show();
366
+ }
367
+ });
368
+ }
369
+
370
+ protected boolean createDraftOrder(String orderReference, CallbackContext callbackContext) {
371
+ if (!orderManagerServiceBinded) {
372
+ callbackContext.error("createDraftOrder: onServiceBoundError: No binded order manager");
373
+ return false;
374
+ }
375
+ order = orderManager.createDraftOrder(orderReference);
376
+ if (order != null) {
377
+ callbackContext.success(this.parseObjToJsonSrtring(order));
378
+ return true;
379
+ }
380
+ return false;
381
+ }
382
+
383
+ protected boolean addOrderItem(String sku,
384
+ String name,
385
+ int unitPrice,
386
+ int quantity,
387
+ String unityOfMeasure,
388
+ CallbackContext callbackContext) {
389
+ if (!orderManagerServiceBinded) {
390
+ callbackContext.error("createDraftOrder: onServiceBoundError: No binded order manager");
391
+ return false;
392
+ }
393
+ order.addItem(sku, name, unitPrice, quantity, unityOfMeasure);
394
+ callbackContext.success(this.parseObjToJsonSrtring(order));
395
+ return true;
396
+ }
397
+
398
+ protected boolean makePayment(String orderReference,
399
+ String orderId,
400
+ long amount,
401
+ String ec,
402
+ int installments,
403
+ String email,
404
+ String paymentCodeStr,
405
+ CallbackContext callbackContext) {
406
+ if (!orderManagerServiceBinded) {
407
+ callbackContext.error("makePayment error: No binded order manager");
408
+ return false;
409
+ }
410
+ if (order == null) {
411
+ callbackContext.error("makePayment error: No order found");
412
+ return false;
413
+ } else {
414
+ if (!orderReference.equals(order.getReference())) {
415
+ callbackContext.error("makePayment error: The order reference is not the same as the current order (Reference: " + orderReference + ") - (Current order Reference: " + order.getReference() + ")");
416
+ return false;
417
+ }
418
+ }
419
+ cielo.sdk.order.payment.PaymentCode paymentCode = GetPaymentCodeFromName(paymentCodeStr);
420
+ if (paymentCode == null) {
421
+ callbackContext.error("makePayment error: Invalid paymentCode (" + paymentCodeStr + ")");
422
+ return false;
423
+ }
424
+ orderManager.placeOrder(order);
425
+ try
426
+ {
427
+ CheckoutRequest.Builder requestBuilder = new CheckoutRequest.Builder()
428
+ .orderId(orderId)
429
+ // .orderId(order.getId())
430
+ .amount(amount)
431
+ .paymentCode(paymentCode)
432
+ .installments(installments);
433
+
434
+ if (!ec.equals(""))
435
+ requestBuilder.ec(ec);
436
+ if (!email.equals(""))
437
+ requestBuilder.email(email);
438
+
439
+ CheckoutRequest request = requestBuilder.build();
440
+ orderManager.checkoutOrder(request, new PaymentListener() {
441
+ @Override
442
+ public void onStart() {
443
+ }
444
+
445
+ @Override
446
+ public void onPayment(Order paidOrder) {
447
+ order = paidOrder;
448
+ order.markAsPaid();
449
+ orderManager.updateOrder(order);
450
+ callbackContext.success(parseObjToJsonSrtring(order));
451
+ resetState();
452
+ }
453
+
454
+ @Override
455
+ public void onCancel() {
456
+ callbackContext.error("{Result - Cielo - LioLocal MakePayment: checkoutOrder - onCancel");
457
+ resetState();
104
458
  }
459
+
460
+ @Override
461
+ public void onError(@NonNull PaymentError paymentError) {
462
+ callbackContext.error("Result - Cielo - LioLocal MakePayment: checkoutOrder - onError");
463
+ resetState();
464
+ }
465
+
466
+ });
467
+ } catch (Exception error1) {
468
+ callbackContext.error("makePayment " + "- Error Detail: " + error1);
469
+ throw error1;
105
470
  }
106
- else if (action.equals("ListarPagamentos")) {
107
- try {
108
- Credentials credentials = new Credentials("M2vcq2fr0oWKbKd5bvpDoGZvHXQ8IneDLBJEulDjxNA59MOA2D/ EMOfYfErX7Y537JZgJvlgG0r805v5jYTxCgNiPtxm500bBUSxh", "NMgpwK4N5dcLCWnOr2kYbDIFcQdLPEn5M2ObKUTULEOdhxzFZu");
109
- orderManager = new OrderManager(credentials, mContext);
471
+ return true;
472
+ }
110
473
 
111
- orderManager.bind(mContext, new ServiceBindListener() {
474
+
475
+
476
+
477
+ protected boolean listOrders(int pageSize, int page, CallbackContext callbackContext) {
478
+ if (!orderManagerServiceBinded) {
479
+ callbackContext.error("listOrders: onServiceBoundError: No binded order manager");
480
+ return false;
481
+ }
482
+ try {
483
+ ResultOrders resultOrders = orderManager.retrieveOrders(pageSize, page);
484
+ if (resultOrders != null) {
485
+ String resultOrdersStr = parseObjToJsonSrtring(resultOrders);
486
+ callbackContext.success(resultOrdersStr);
487
+ } else {
488
+ callbackContext.success("null");
489
+ }
490
+ return true;
491
+ } catch (Exception error1) {
492
+ callbackContext.error("Result - Cielo - LioLocal - listOrders: " + "Error Detail: " + error1);
493
+ }
494
+ return false;
495
+ }
496
+
497
+ protected boolean cancelPayment(JSONObject orderObj, CallbackContext callbackContext) {
498
+ if (!orderManagerServiceBinded) {
499
+ callbackContext.error("cancelPayment: onServiceBoundError: No binded order manager");
500
+ return false;
501
+ }
502
+ try {
503
+ String jsonStr = orderObj.toString();
504
+ Gson gson = new Gson();
505
+ Order cancelOrder = gson.fromJson(jsonStr, Order.class);
506
+
507
+ List<Payment> paymentList = cancelOrder.getPayments();
508
+ payment = paymentList.get(0);
509
+
510
+
511
+ if (cancelOrder != null && cancelOrder.getPayments().size() > 0) {
512
+ CancellationRequest request = new CancellationRequest.Builder()
513
+ .orderId(cancelOrder.getId())
514
+ .authCode(payment.getAuthCode())
515
+ .cieloCode(payment.getCieloCode())
516
+ .value(payment.getAmount())
517
+ //.ec("0000000000000003")
518
+ .build();
519
+
520
+ orderManager.cancelOrder(request, new CancellationListener() {
112
521
 
113
522
  @Override
114
- public void onServiceBoundError(Throwable throwable) {
115
- orderManagerServiceBinded = false;
116
-
117
- callbackContext.success("Result - ListarPagamentos: " + "Error Detail: " + throwable.getMessage());
118
- // Toast.makeText(getApplicationContext(),
119
- // String.format("Erro fazendo bind do serviço de ordem -> %s",
120
- // throwable.getMessage()), Toast.LENGTH_LONG).show();
121
- // return false;
523
+ public void onSuccess(Order cancelledOrder) {
524
+ cancelledOrder.cancel();
525
+ orderManager.updateOrder(cancelledOrder);
526
+ order = cancelledOrder;
527
+ callbackContext.success(parseObjToJsonSrtring(order));
122
528
  }
123
529
 
124
530
  @Override
125
- public void onServiceBound() {
126
- orderManagerServiceBinded = true;
127
- orderManager.createDraftOrder("REFERENCIA DA ORDEM");
128
- // callbackContext.success("Result - ListarPagamentos: " + "REFERENCIA DA ORDEM => listOrders");
129
-
130
- ResultOrders resultOrders = orderManager.retrieveOrders(200, 0);
131
- final List<Order> orderList = resultOrders.getResults();
132
- String ordersList = "";
133
- for (Order or : orderList) {
134
- if (!or.getItems().isEmpty()) {
135
- ordersList += or.getReference() + " - Price: " + or.getPrice() + "\n";
136
- }
137
- // Log.i("Order: ", or.getNumber() + " - " + or.getPrice());
138
- }
139
- if (ordersList != "") {
140
- // txtEmptyValue.setText(ordersList);
141
- callbackContext.success("Result - ListarPagamentos: " + "REFERENCIA DA ORDEM => listOrders \n" + ordersList);
142
- }
143
- // callbackContext.success("Service Bound");
144
- // listOrders();
145
- // return true;
531
+ public void onCancel() {
532
+ callbackContext.success("cancelPayment - onCancel");
146
533
  }
147
534
 
148
535
  @Override
149
- public void onServiceUnbound() {
150
- orderManagerServiceBinded = false;
536
+ public void onError(PaymentError paymentError) {
537
+ callbackContext.success("cancelPayment - onError");
151
538
  }
152
539
  });
153
- return true;
154
- } catch (Exception error1) {
155
- // alertarMensagem(resutText, error1);
156
- callbackContext.success("Result - ListarPagamentos: " + "Error Detail: " + error1);
540
+ }
541
+ return true;
542
+ } catch (Exception error1) {
543
+ callbackContext.error("Result - Cielo - LioLocal - cancelPayment: " + "Error Detail: " + error1);
544
+ }
545
+ return false;
546
+ }
547
+
548
+
549
+ protected boolean terminalInformation(String informatitonType, CallbackContext callbackContext) {
550
+ try {
551
+ infoManager = new InfoManager();
552
+ Settings settings = infoManager.getSettings(this.mActivity);
553
+
554
+ String logicNumber = settings.getLogicNumber();
555
+ Float batteryLevel = infoManager.getBatteryLevel(this.mActivity);
556
+ DeviceModel deviceModel = infoManager.getDeviceModel();
557
+
558
+
559
+ JSONObject json = new JSONObject();
560
+ json.put("logicNumber", logicNumber);
561
+ json.put("batteryLevel", batteryLevel);
562
+ json.put("deviceModel", deviceModel);
563
+
564
+
565
+
566
+ json.put("serial", Build.SERIAL);
567
+ json.put("model", Build.MODEL);
568
+ json.put("id", Build.ID);
569
+ json.put("manufacture", Build.MANUFACTURER);
570
+ json.put("brand", Build.BRAND);
571
+ json.put("type", Build.TYPE);
572
+ json.put("user", Build.USER);
573
+ json.put("base", Build.VERSION_CODES.BASE);
574
+ json.put("device", Build.DEVICE);
575
+ json.put("incremental", Build.VERSION.INCREMENTAL);
576
+ json.put("sdk", Build.VERSION.SDK);
577
+ json.put("board", Build.BOARD);
578
+ json.put("brand", Build.BRAND);
579
+ json.put("host", Build.HOST);
580
+ json.put("fingerprint", Build.FINGERPRINT);
581
+ json.put("versionCode", Build.VERSION.RELEASE);
582
+ json.put("hardware", Build.HARDWARE);
583
+ callbackContext.success(json.toString());
584
+ return true;
585
+ } catch (Exception error1) {
586
+ callbackContext.error("Result - Cielo - LioLocal - terminalInformation: " + "Error Detail: " + error1);
587
+ }
588
+ return false;
589
+ }
590
+
591
+
592
+
593
+
594
+
595
+
596
+
597
+
598
+
599
+
600
+ protected boolean print_initialize() {
601
+ setStyles();
602
+ printerManager = new PrinterManager(this.mContext);
603
+ printerListener = new PrinterListener() {
604
+ @Override
605
+ public void onWithoutPaper() {
606
+ //Log.d("PrintSampleActivity", "printer without paper");
607
+ }
608
+
609
+ @Override
610
+ public void onPrintSuccess() {
611
+ //Log.d("PrintSampleActivity", "print success!");
157
612
  }
158
- // callbackContext.success("Result - ListarPagamentos: Ok " + action);
159
- // return true;
613
+
614
+ @Override
615
+ public void onError(Throwable throwable) {
616
+ //Log.d("PrintSampleActivity",String.format("printer error -> %s", throwable.getMessage()));
617
+ }
618
+ };
619
+ return true;
620
+ }
621
+
622
+ protected boolean print_SimpleText(String textToPrint,
623
+ int textAlign,
624
+ int textSize,
625
+ int textTypeFace,
626
+
627
+ int textMarginLeft,
628
+ int textMarginRight,
629
+ int textMarginTop,
630
+ int textMarginBotton,
631
+
632
+ int textLineSpace,
633
+ int textWeight,
634
+
635
+ CallbackContext callbackContext) {
636
+ try {
637
+ print_initialize();
638
+ HashMap<String, Integer> printStyle = new HashMap<>();
639
+
640
+ // Alinhamento da impressão
641
+ switch (textAlign) {
642
+ case 1: // Left
643
+ printStyle.put(PrinterAttributes.KEY_ALIGN, PrinterAttributes.VAL_ALIGN_LEFT);
644
+ break;
645
+ case 2: // Center
646
+ printStyle.put(PrinterAttributes.KEY_ALIGN, PrinterAttributes.VAL_ALIGN_CENTER);
647
+ break;
648
+ case 3: // Right
649
+ printStyle.put(PrinterAttributes.KEY_ALIGN, PrinterAttributes.VAL_ALIGN_RIGHT);
650
+ break;
651
+ default:
652
+ printStyle.put(PrinterAttributes.KEY_ALIGN, PrinterAttributes.VAL_ALIGN_LEFT);
653
+ break;
654
+ }
655
+
656
+ // Tamanho do texto
657
+ printStyle.put(PrinterAttributes.KEY_TEXT_SIZE, textSize);
658
+
659
+ // Fonte do texto
660
+ printStyle.put(PrinterAttributes.KEY_TYPEFACE, textTypeFace);
661
+
662
+ // Margem
663
+ // printStyle.put(PrinterAttributes.KEY_MARGINLEFT, textMarginLeft);
664
+ // printStyle.put(PrinterAttributes.KEY_MARGINRIGHT, textMarginRight);
665
+ // printStyle.put(PrinterAttributes.KEY_MARGINTOP, textMarginTop);
666
+ // printStyle.put(PrinterAttributes.KEY_MARGINBOTTOM, textMarginBotton);
667
+
668
+ // LineSpace
669
+ // printStyle.put(PrinterAttributes.KEY_LINESPACE, textLineSpace);
670
+
671
+ // Varíavel utilizada quando se trbaalho com impressão de múltiplas colunas, para escolher o peso de cada coluna
672
+ // printStyle.put(PrinterAttributes.KEY_WEIGHT, textWeight);
673
+
674
+ printerManager.printText(textToPrint, printStyle, printerListener);
675
+ callbackContext.success("Result - Cielo - LioLocal - print_SimpleText: OK");
676
+ return true;
677
+ } catch (Exception error1) {
678
+ callbackContext.error("Result - Cielo - LioLocal - print_SimpleText: " + "Error Detail: " + error1);
679
+ }
680
+ return false;
681
+ }
682
+
683
+ protected boolean print_QrCode(String textToPrint,
684
+ int textAlign,
685
+ int size,
686
+ CallbackContext callbackContext) {
687
+ try {
688
+ print_initialize();
689
+
690
+ // Alinhamento da impressão
691
+ switch (textAlign) {
692
+ case 1: // Left
693
+ printerManager.printQrCode(textToPrint, PrinterAttributes.VAL_ALIGN_LEFT, size, printerListener);
694
+ break;
695
+ case 2: // Center
696
+ printerManager.printQrCode(textToPrint, PrinterAttributes.VAL_ALIGN_CENTER, size, printerListener);
697
+ break;
698
+ case 3: // Right
699
+ printerManager.printQrCode(textToPrint, PrinterAttributes.VAL_ALIGN_RIGHT, size, printerListener);
700
+ break;
701
+ default:
702
+ printerManager.printQrCode(textToPrint, PrinterAttributes.VAL_ALIGN_LEFT, size, printerListener);
703
+ break;
704
+ }
705
+ callbackContext.success("Result - Cielo - LioLocal - print_QrCode: OK");
706
+ return true;
707
+ } catch (Exception error1) {
708
+ callbackContext.error("Result - Cielo - LioLocal - print_QrCode: " + "Error Detail: " + error1);
160
709
  }
161
710
  return false;
162
711
  }
163
712
 
713
+ protected boolean print_BarCode(String textToPrint,
714
+ int textAlign,
715
+ int barcodeWidth,
716
+ int barcodeHeight,
717
+ CallbackContext callbackContext) {
718
+ try {
719
+ print_initialize();
720
+
721
+ // Alinhamento da impressão
722
+ switch (textAlign) {
723
+ case 1: // Left
724
+ printerManager.printBarCode(textToPrint, PrinterAttributes.VAL_ALIGN_LEFT, barcodeWidth, barcodeHeight, false, printerListener);
725
+ break;
726
+ case 2: // Center
727
+ printerManager.printBarCode(textToPrint, PrinterAttributes.VAL_ALIGN_CENTER, barcodeWidth, barcodeHeight, false, printerListener);
728
+ break;
729
+ case 3: // Right
730
+ printerManager.printBarCode(textToPrint, PrinterAttributes.VAL_ALIGN_RIGHT, barcodeWidth, barcodeHeight, false, printerListener);
731
+ break;
732
+ default:
733
+ printerManager.printBarCode(textToPrint, PrinterAttributes.VAL_ALIGN_LEFT, barcodeWidth, barcodeHeight, false, printerListener);
734
+ break;
735
+ }
736
+ callbackContext.success("Result - Cielo - LioLocal - print_BarCode: OK");
737
+ return true;
738
+ } catch (Exception error1) {
739
+ callbackContext.error("Result - Cielo - LioLocal - print_BarCode: " + "Error Detail: " + error1);
740
+ }
741
+ return false;
742
+ }
164
743
 
744
+ private void setStyles() {
745
+ // alignLeft.put(PrinterAttributes.KEY_ALIGN, PrinterAttributes.VAL_ALIGN_LEFT);
746
+ // alignLeft.put(PrinterAttributes.KEY_TYPEFACE, 0);
747
+ // alignLeft.put(PrinterAttributes.KEY_TEXT_SIZE, 30);
165
748
 
749
+ // alignCenter.put(PrinterAttributes.KEY_ALIGN, PrinterAttributes.VAL_ALIGN_CENTER);
750
+ // alignCenter.put(PrinterAttributes.KEY_TYPEFACE, 1);
751
+ // alignCenter.put(PrinterAttributes.KEY_TEXT_SIZE, 20);
166
752
 
167
- // Cielo Functions
168
- protected void configSDKListarPagamentos() {
169
- Credentials credentials = new Credentials("M2vcq2fr0oWKbKd5bvpDoGZvHXQ8IneDLBJEulDjxNA59MOA2D/ EMOfYfErX7Y537JZgJvlgG0r805v5jYTxCgNiPtxm500bBUSxh", "NMgpwK4N5dcLCWnOr2kYbDIFcQdLPEn5M2ObKUTULEOdhxzFZu");
170
- // orderManager = new OrderManager(credentials, this);
171
- // orderManager.bind(this, new ServiceBindListener() {
172
-
173
- // @Override
174
- // public void onServiceBoundError(Throwable throwable) {
175
- // orderManagerServiceBinded = false;
176
-
177
- // Toast.makeText(getApplicationContext(),
178
- // String.format("Erro fazendo bind do serviço de ordem -> %s",
179
- // throwable.getMessage()), Toast.LENGTH_LONG).show();
180
- // }
181
-
182
- // @Override
183
- // public void onServiceBound() {
184
- // orderManagerServiceBinded = true;
185
- // orderManager.createDraftOrder("REFERENCIA DA ORDEM");
186
- // listOrders();
187
- // }
188
-
189
- // @Override
190
- // public void onServiceUnbound() {
191
- // orderManagerServiceBinded = false;
192
- // }
193
- // });
753
+ // alignRight.put(PrinterAttributes.KEY_ALIGN, PrinterAttributes.VAL_ALIGN_RIGHT);
754
+ // alignRight.put(PrinterAttributes.KEY_TYPEFACE, 2);
755
+ // alignRight.put(PrinterAttributes.KEY_TEXT_SIZE, 10);
756
+ }
757
+
758
+
759
+ // Cielo Global
760
+ protected String parseObjToJsonSrtring(Object obj) {
761
+ Gson gson = new Gson();
762
+ String result = gson.toJson(obj);
763
+ return result;
764
+ }
765
+
766
+ protected void resetState() {
767
+ order = null;
194
768
  }
195
769
 
196
770
  }
@@ -60,20 +60,7 @@ public class ElginM10Terminal {
60
60
  }
61
61
 
62
62
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
63
-
64
- if (action.equals("Teste")) {
65
- int arg1 = args.getInt(0);
66
- if (arg1 == 0) {
67
- callbackContext.success("Result - ElginClass: ok " + action);
68
- return false;
69
- }
70
- else {
71
- callbackContext.success("Result - ElginClass: noOk " + action);
72
- return false;
73
- }
74
- }
75
-
76
- else if(action.equals("AbreConexaoImpressora")){
63
+ if(action.equals("AbreConexaoImpressora")){
77
64
  try{
78
65
  JSONObject params = args.getJSONObject(0);
79
66
 
@@ -88,45 +75,48 @@ public class ElginM10Terminal {
88
75
  }catch (Exception e){
89
76
  callbackContext.error("AbreConexaoImpressora error: " + e.toString());
90
77
  }
78
+ return true;
91
79
  }
92
80
 
93
- // else if(action.equals("FechaConexaoImpressora")){
94
- // try{
95
- // int result = Termica.FechaConexaoImpressora();
96
-
97
- // callbackContext.success(result);
98
- // } catch (Exception e){
99
- // callbackContext.error("FechaConexaoImpressora error: " + e.toString());
100
- // }
101
- // }
81
+ else if(action.equals("FechaConexaoImpressora")){
82
+ try{
83
+ int result = Termica.FechaConexaoImpressora();
84
+ callbackContext.success(result);
85
+ } catch (Exception e){
86
+ callbackContext.error("FechaConexaoImpressora error: " + e.toString());
87
+ }
88
+ return true;
89
+ }
102
90
 
103
- // else if(action.equals("AvancaPapel")){
104
- // try{
105
- // JSONObject params = args.getJSONObject(0);
91
+ else if(action.equals("AvancaPapel")){
92
+ try{
93
+ JSONObject params = args.getJSONObject(0);
106
94
 
107
- // int linhas = params.getInt("linhas");
95
+ int linhas = params.getInt("linhas");
108
96
 
109
- // int result = Termica.AvancaPapel(linhas);
97
+ int result = Termica.AvancaPapel(linhas);
110
98
 
111
- // callbackContext.success(result);
112
- // }catch (Exception e){
113
- // callbackContext.error("AvancaPapel error: " + e.toString());
114
- // }
115
- // }
99
+ callbackContext.success(result);
100
+ }catch (Exception e){
101
+ callbackContext.error("AvancaPapel error: " + e.toString());
102
+ }
103
+ return true;
104
+ }
116
105
 
117
- // else if(action.equals("Corte")){
118
- // try{
119
- // JSONObject params = args.getJSONObject(0);
106
+ else if(action.equals("Corte")){
107
+ try{
108
+ JSONObject params = args.getJSONObject(0);
120
109
 
121
- // int avanco = params.getInt("avanco");
110
+ int avanco = params.getInt("avanco");
122
111
 
123
- // int result = Termica.Corte(avanco);
112
+ int result = Termica.Corte(avanco);
124
113
 
125
- // callbackContext.success(result);
126
- // }catch (Exception e){
127
- // callbackContext.error("Corte error: " + e.toString());
128
- // }
129
- // }
114
+ callbackContext.success(result);
115
+ }catch (Exception e){
116
+ callbackContext.error("Corte error: " + e.toString());
117
+ }
118
+ return true;
119
+ }
130
120
 
131
121
  else if(action.equals("ImpressaoTexto")){
132
122
  try{
@@ -146,137 +136,138 @@ public class ElginM10Terminal {
146
136
  return true;
147
137
  }
148
138
 
149
- // else if(action.equals("ImpressaoCodigoBarras")){
150
- // try{
151
- // JSONObject params = args.getJSONObject(0);
139
+ else if(action.equals("ImpressaoCodigoBarras")){
140
+ try{
141
+ JSONObject params = args.getJSONObject(0);
152
142
 
153
- // int tipo = params.getInt("tipo");
154
- // String dados = params.getString("dados");
155
- // int altura = params.getInt("altura");
156
- // int largura = params.getInt("largura");
157
- // int HRI = params.getInt("HRI");
143
+ int tipo = params.getInt("tipo");
144
+ String dados = params.getString("dados");
145
+ int altura = params.getInt("altura");
146
+ int largura = params.getInt("largura");
147
+ int HRI = params.getInt("HRI");
158
148
 
159
- // int result = Termica.ImpressaoCodigoBarras(tipo, dados, altura, largura, HRI);
149
+ int result = Termica.ImpressaoCodigoBarras(tipo, dados, altura, largura, HRI);
160
150
 
161
- // callbackContext.success(result);
162
- // }catch (Exception e){
163
- // callbackContext.error("ImpressaoCodigoBarras error: " + e.toString());
164
- // }
165
- // return true;
166
- // }
151
+ callbackContext.success(result);
152
+ }catch (Exception e){
153
+ callbackContext.error("ImpressaoCodigoBarras error: " + e.toString());
154
+ }
155
+ return true;
156
+ }
167
157
 
168
- // else if (action.equals("DefinePosicao")){
169
- // try{
170
- // JSONObject params = args.getJSONObject(0);
158
+ else if (action.equals("DefinePosicao")){
159
+ try{
160
+ JSONObject params = args.getJSONObject(0);
171
161
 
172
- // int posicao = params.getInt("posicao");
162
+ int posicao = params.getInt("posicao");
173
163
 
174
- // int result = Termica.DefinePosicao(posicao);
164
+ int result = Termica.DefinePosicao(posicao);
175
165
 
176
- // callbackContext.success(result);
177
- // }catch (Exception e){
178
- // callbackContext.error("DefinePosicao error: " + e.toString());
179
- // }
180
- // return true;
181
- // }
166
+ callbackContext.success(result);
167
+ }catch (Exception e){
168
+ callbackContext.error("DefinePosicao error: " + e.toString());
169
+ }
170
+ return true;
171
+ }
182
172
 
183
- // else if(action.equals("ImpressaoQRCode")){
184
- // try{
185
- // JSONObject params = args.getJSONObject(0);
173
+ else if(action.equals("ImpressaoQRCode")){
174
+ try{
175
+ JSONObject params = args.getJSONObject(0);
186
176
 
187
- // String dados = params.getString("dados");
188
- // int tamanho = params.getInt("tamanho");
189
- // int nivelCorrecao = params.getInt("nivelCorrecao");
177
+ String dados = params.getString("dados");
178
+ int tamanho = params.getInt("tamanho");
179
+ int nivelCorrecao = params.getInt("nivelCorrecao");
190
180
 
191
- // int result = Termica.ImpressaoQRCode(dados, tamanho, nivelCorrecao);
181
+ int result = Termica.ImpressaoQRCode(dados, tamanho, nivelCorrecao);
192
182
 
193
- // callbackContext.success(result) ;
194
- // }catch (Exception e){
195
- // callbackContext.error("ImpressaoQRCode error: " + e.toString());
196
- // }
197
- // return true;
198
- // }
183
+ callbackContext.success(result) ;
184
+ }catch (Exception e){
185
+ callbackContext.error("ImpressaoQRCode error: " + e.toString());
186
+ }
187
+ return true;
188
+ }
199
189
 
200
- // else if(action.equals("ImprimeXMLNFCe")){
201
- // try{
202
- // JSONObject params = args.getJSONObject(0);
190
+ else if(action.equals("ImprimeXMLNFCe")){
191
+ try{
192
+ JSONObject params = args.getJSONObject(0);
203
193
 
204
- // String dados = params.getString("dados");
205
- // int indexcsc = params.getInt("indexcsc");
206
- // String csc = params.getString("csc");
207
- // int param = params.getInt("param");
194
+ String dados = params.getString("dados");
195
+ int indexcsc = params.getInt("indexcsc");
196
+ String csc = params.getString("csc");
197
+ int param = params.getInt("param");
208
198
 
209
- // int result = Termica.ImprimeXMLNFCe(dados, indexcsc, csc, param);
199
+ int result = Termica.ImprimeXMLNFCe(dados, indexcsc, csc, param);
210
200
 
211
- // callbackContext.success(result);
212
- // }catch (Exception e){
213
- // callbackContext.error("ImprimeXMLNFCe error: " + e.toString());
214
- // }
215
- // return true;
216
- // }
201
+ callbackContext.success(result);
202
+ }catch (Exception e){
203
+ callbackContext.error("ImprimeXMLNFCe error: " + e.toString());
204
+ }
205
+ return true;
206
+ }
217
207
 
218
- // else if(action.equals("ImprimeXMLSAT")){
219
- // try{
220
- // JSONObject params = args.getJSONObject(0);
208
+ else if(action.equals("ImprimeXMLSAT")){
209
+ try{
210
+ JSONObject params = args.getJSONObject(0);
221
211
 
222
- // String dados = params.getString("dados");
223
- // int param = params.getInt("param");
212
+ String dados = params.getString("dados");
213
+ int param = params.getInt("param");
224
214
 
225
- // int result = Termica.ImprimeXMLSAT(dados, param);
215
+ int result = Termica.ImprimeXMLSAT(dados, param);
226
216
 
227
- // callbackContext.success(result);
217
+ callbackContext.success(result);
228
218
 
229
- // }catch (Exception e){
230
- // callbackContext.error("ImprimeXMLSAT error: " + e.toString());
231
- // }
232
- // return true;
233
- // }
219
+ }catch (Exception e){
220
+ callbackContext.error("ImprimeXMLSAT error: " + e.toString());
221
+ }
222
+ return true;
223
+ }
234
224
 
235
- // else if(action.equals("AbreGavetaElgin")){
236
- // try{
237
- // int result = Termica.AbreGavetaElgin();
225
+ else if(action.equals("AbreGavetaElgin")){
226
+ try{
227
+ int result = Termica.AbreGavetaElgin();
238
228
 
239
- // callbackContext.success(result);
240
- // } catch (Exception e){
241
- // callbackContext.error("AbreGavetaElgin error: " + e.toString());
242
- // }
243
- // }
229
+ callbackContext.success(result);
230
+ } catch (Exception e){
231
+ callbackContext.error("AbreGavetaElgin error: " + e.toString());
232
+ }
233
+ return true;
234
+ }
244
235
 
245
- // else if(action.equals("StatusImpressora")){
246
- // try{
247
- // JSONObject params = args.getJSONObject(0);
236
+ else if(action.equals("StatusImpressora")){
237
+ try{
238
+ JSONObject params = args.getJSONObject(0);
248
239
 
249
- // int param = params.getInt("param");
240
+ int param = params.getInt("param");
250
241
 
251
- // int result = Termica.StatusImpressora(param);
242
+ int result = Termica.StatusImpressora(param);
252
243
 
253
- // callbackContext.success(result);
254
- // }catch (Exception e){
255
- // callbackContext.error("StatusImpressora error: " + e.toString());
256
- // }
257
- // return true;
258
- // }
244
+ callbackContext.success(result);
245
+ }catch (Exception e){
246
+ callbackContext.error("StatusImpressora error: " + e.toString());
247
+ }
248
+ return true;
249
+ }
259
250
 
260
- // else if(action.equals("ImprimeImagem")){
261
- // try{
262
- // JSONObject params = args.getJSONObject(0);
251
+ // else if(action.equals("ImprimeImagem")){
252
+ // try{
253
+ // JSONObject params = args.getJSONObject(0);
263
254
 
264
- // if(params.getBoolean("cutPaper")) this.cutPaper = true;
265
- // else this.cutPaper = false;
255
+ // if(params.getBoolean("cutPaper")) this.cutPaper = true;
256
+ // else this.cutPaper = false;
266
257
 
267
- // Intent intent = new Intent((Intent.ACTION_PICK));
268
- // intent.setType("image/*");
258
+ // Intent intent = new Intent((Intent.ACTION_PICK));
259
+ // intent.setType("image/*");
269
260
 
270
- // this.selecionarImagemCallbackContext = callbackContext;
261
+ // // this.selecionarImagemCallbackContext = callbackContext;
271
262
 
272
- // this.cordova.setActivityResultCallback(this);
273
- // this.cordova.getActivity().startActivityForResult(intent, REQ_CODE_SELECAOIMAGEM);
263
+ // // this.cordova.setActivityResultCallback(this);
264
+ // // this.cordova.getActivity().startActivityForResult(intent, REQ_CODE_SELECAOIMAGEM);
274
265
 
275
- // }catch (Exception e){
276
- // callbackContext.error("ImprimirImagem error: " + e.toString());
277
- // }
278
- // return true;
279
- // }
266
+ // }catch (Exception e){
267
+ // callbackContext.error("ImprimirImagem error: " + e.toString());
268
+ // }
269
+ // return true;
270
+ // }
280
271
  return false;
281
272
  }
282
273
  }
package/src/build.gradle CHANGED
@@ -25,4 +25,6 @@ dependencies {
25
25
  //Em alguns frameworks (como o Ionic), pode ser necessário a definição de alguns atributos de cor utilizado por algumas das libs já incluidas, para evitar qualquer inconsistência nesse sentido
26
26
  //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.
27
27
  implementation 'com.android.support:design:28.0.0'
28
+
29
+ implementation 'com.google.code.gson:gson:2.8.9'
28
30
  }
@@ -6,8 +6,76 @@ exports.Teste = function (params, success, error) {
6
6
  exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.Teste', [params]);
7
7
  }
8
8
 
9
- exports.ListarPagamentos = function (params, success, error) {
10
- exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.ListarPagamentos', [params]);
9
+ exports.ConfigureSdk = function (params, success, error) {
10
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.ConfigureSdk', [params]);
11
11
  }
12
12
 
13
+ exports.OrderManagerBind = function (success, error) {
14
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.OrderManagerBind');
15
+ }
16
+
17
+ exports.OrderManagerUnbind = function (success, error) {
18
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.OrderManagerUnbind');
19
+ }
20
+
21
+
22
+
23
+
24
+ exports.CreateDraftOrder = function (params, success, error) {
25
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.CreateDraftOrder', [params]);
26
+ }
27
+
28
+ exports.AddOrderItem = function (params, success, error) {
29
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.AddOrderItem', [params]);
30
+ }
31
+
32
+ exports.MakePayment = function (params, success, error) {
33
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.MakePayment', [params]);
34
+ }
35
+
36
+
37
+
38
+
39
+ exports.ListOrders = function (params, success, error) {
40
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.ListOrders', [params]);
41
+ }
42
+
43
+
44
+
45
+ exports.CancelPayment = function (param, success, error) {
46
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.CancelPayment', [param]);
47
+ }
48
+
49
+ exports.PrintSimpleText = function (params, success, error) {
50
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.PrintSimpleText', [params]);
51
+ }
52
+
53
+ exports.PrintQrCode = function (params, success, error) {
54
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.PrintQrCode', [params]);
55
+ }
56
+
57
+ exports.PrintBarCode = function (params, success, error) {
58
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.PrintBarCode', [params]);
59
+ }
60
+
61
+ // exports.PlaceOrder = function (params, success, error) {
62
+ // exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.PlaceOrder', [params]);
63
+ // }
64
+
65
+
66
+
67
+
68
+ exports.TerminalInformation = function (params, success, error) {
69
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.TerminalInformation', [params]);
70
+ }
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
13
81
 
@@ -2,10 +2,6 @@ var exec = require('cordova/exec');
2
2
 
3
3
  //Printer Functions
4
4
 
5
- exports.Teste = function (params, success, error) {
6
- exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.Teste', [params]);
7
- }
8
-
9
5
  exports.AbreConexaoImpressora = function (params, success, error) {
10
6
  exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.AbreConexaoImpressora', [params]);
11
7
  }
@@ -55,10 +51,10 @@ exports.StatusImpressora = function (params, success, error) {
55
51
  }
56
52
 
57
53
 
58
- //CUSTOM METHOD
59
- exports.imprimeImagem = function (params, success, error) {
60
- exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.ImprimeImagem', [params]);
61
- }
54
+ // //CUSTOM METHOD
55
+ // exports.imprimeImagem = function (params, success, error) {
56
+ // exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.ImprimeImagem', [params]);
57
+ // }
62
58
 
63
59
 
64
60