cordova-plugin-netcontroll-integration 1.0.8 → 1.0.9

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.9",
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.9"
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;
@@ -27,33 +29,47 @@ import javax.security.auth.callback.Callback;
27
29
 
28
30
  import java.util.List;
29
31
 
30
- //Cielo Package
31
- import cielo.orders.domain.Credentials;
32
+ //Json Serialize
33
+ import com.google.gson.Gson;
34
+ import com.google.gson.GsonBuilder;
35
+
32
36
 
37
+ //Cielo Package Sdk
38
+
39
+ import cielo.orders.domain.CancellationRequest;
40
+ import cielo.orders.domain.Credentials;
33
41
  import cielo.orders.domain.Item;
34
- import cielo.orders.domain.CheckoutRequest;
35
42
  import cielo.orders.domain.Order;
36
43
  import cielo.orders.domain.product.PrimaryProduct;
37
44
  import cielo.orders.domain.product.SecondaryProduct;
45
+ import cielo.orders.domain.CheckoutRequest;
38
46
  import cielo.orders.domain.ResultOrders;
39
47
 
40
48
  import cielo.sdk.order.OrderManager;
49
+ import cielo.sdk.order.cancellation.CancellationListener;
41
50
  import cielo.sdk.order.ServiceBindListener;
51
+ import cielo.sdk.order.payment.Payment;
42
52
  import cielo.sdk.order.payment.PaymentCode;
43
53
  import cielo.sdk.order.payment.PaymentListener;
44
54
  import cielo.sdk.order.payment.PaymentError;
45
55
 
46
56
 
47
-
48
-
49
-
50
57
  /**
51
58
  * This class echoes a string called from JavaScript.
52
59
  */
53
60
  public class CieloLioLocal {
54
- //Cielo
61
+
62
+ //Cielo Package Sdk
55
63
  public OrderManager orderManager;
64
+
65
+
66
+
67
+ //Cielo Variables
68
+ Credentials _credentials ;
56
69
  public boolean orderManagerServiceBinded = false;
70
+ public Order order;
71
+ public Payment payment;
72
+
57
73
 
58
74
 
59
75
  //Cordova/Java Params
@@ -91,106 +107,374 @@ public class CieloLioLocal {
91
107
  } else {
92
108
  callbackContext.success("Result - CieloLioLocalClass: Tem Credencial " + action + " Token: " + credentials.getAccessToken().toString());
93
109
  return true;
94
-
95
110
  }
96
-
97
-
98
- // callbackContext.success("Result - CieloLioLocalClass: ok " + action);
99
- // return false;
100
111
  }
101
112
  else {
102
113
  callbackContext.success("Result - CieloLioLocalClass: noOk " + action);
103
114
  return false;
104
115
  }
105
116
  }
106
- else if (action.equals("ListarPagamentos")) {
117
+ else if (action.equals("ConfigureSdk")) {
118
+ JSONObject params = args.getJSONObject(0);
107
119
  try {
108
- Credentials credentials = new Credentials("M2vcq2fr0oWKbKd5bvpDoGZvHXQ8IneDLBJEulDjxNA59MOA2D/ EMOfYfErX7Y537JZgJvlgG0r805v5jYTxCgNiPtxm500bBUSxh", "NMgpwK4N5dcLCWnOr2kYbDIFcQdLPEn5M2ObKUTULEOdhxzFZu");
109
- orderManager = new OrderManager(credentials, mContext);
120
+ this.configSDK(params.getString("clientId"),params.getString("accessToken"));
121
+ if (this.orderManager == null) {
122
+ callbackContext.error("Result - Cielo - LioLocal - ConfigureSdk: orderManager is null");
123
+ return false;
124
+ } else {
125
+ callbackContext.success("Result - Cielo - LioLocal - ConfigureSdk: orderManager ok");
126
+ return true;
127
+ }
128
+ } catch (Exception error1) {
129
+ callbackContext.error("Result - Cielo - LioLocal - ConfigureSdk: " + "Error Detail: " + error1);
130
+ }
131
+ return false;
132
+ }
133
+ else if (action.equals("PlaceOrder")) {
134
+ JSONObject params = args.getJSONObject(0);
135
+ try {
136
+ this.placeOrder(params.getString("productName"));
137
+ // callbackContext.success("Result - Cielo - LioLocal PlaceOrder: ok ");
138
+ if (order != null) {
139
+ callbackContext.success("Result - Cielo - LioLocal PlaceOrder - order: ok (" + order.getReference() + ")");
140
+ } else {
141
+ callbackContext.success("Result - Cielo - LioLocal PlaceOrder - order is null: Error ");
142
+ return false;
143
+ }
144
+ return true;
145
+ } catch (Exception error1) {
146
+ callbackContext.error("Result - Cielo - LioLocal PlaceOrder: " + "Error Detail: " + error1);
147
+ }
148
+ return false;
149
+ }
150
+ else if (action.equals("MakePayment")) {
151
+ JSONObject params = args.getJSONObject(0);
152
+ try {
153
+ this.makePayment(
154
+ params.getString("orderId"),
155
+ params.getInt("amount"),
156
+ params.getString("ec"),
157
+ params.getInt("installments"),
158
+ params.getString("email"),
159
+ params.getString("paymentCode"),
160
+ callbackContext
161
+ );
162
+ return true;
163
+ } catch (Exception error1) {
164
+ callbackContext.error("Result - Cielo - LioLocal MakePayment: " + "Error Detail: " + error1);
165
+ }
166
+ return false;
167
+ }
168
+ else if (action.equals("ListOrders")) {
169
+ try {
170
+ this.listOrders(callbackContext);
171
+ return true;
172
+ } catch (Exception error1) {
173
+ callbackContext.error("Result - Cielo - LioLocal ListOrders: " + "Error Detail: " + error1);
174
+ }
175
+ }
176
+ else if (action.equals("CancelPayment")) {
177
+ JSONObject paramsObj = args.getJSONObject(0);
178
+ try {
179
+ // JSONObject jobj = args.getJSONObject(0);
180
+ // JSONObject jobj = new JSONObject(json);
181
+
182
+
183
+ // // JSONObject params = args.getJSONObject(0);
184
+ // // Order cancelOrder =
185
+ // // var testes = args.getJSONObject(0);
186
+ // // JSONObject data = args.getJSONObject(0);
187
+ // // JSONObject data = args.getJSONObject();
188
+ this.cancelPayment(paramsObj, callbackContext);
189
+ // callbackContext.success(paramsObj);
190
+
191
+
192
+ return true;
193
+ } catch (Exception error1) {
194
+ callbackContext.error("Result - Cielo - LioLocal ListOrders: " + "Error Detail: " + error1);
195
+ }
196
+
197
+
198
+ // JSONObject params = args.getJSONObject(0);
199
+ // JSONObject params = args.getJSONObject(0);
200
+ // try {
201
+ // String idCancel = params.getString("id");
202
+ // // Toast.makeText(mContext,String.format("configSDK: onServiceUnbound"), Toast.LENGTH_LONG).show();
203
+
204
+ // this.cancelPayment(params.getString("id"), callbackContext);
205
+ // callbackContext.success("Result - Cielo - LioLocal CancelPayment: ok");
206
+ // return true;
207
+ // } catch (Exception error1) {
208
+ // callbackContext.error("Result - Cielo - LioLocal ListOrders: " + "Error Detail: " + error1);
209
+ // }
210
+ }
211
+ return false;
212
+ }
213
+
214
+
215
+ // Cielo Functions Helpers
216
+ private cielo.sdk.order.payment.PaymentCode GetPaymentCodeFromName(String paymentCodeName) {
217
+ cielo.sdk.order.payment.PaymentCode paymentCode = null;
218
+ switch (paymentCodeName) {
219
+ case "DEBITO_AVISTA":
220
+ paymentCode = PaymentCode.DEBITO_AVISTA;
221
+ break;
222
+ case "DEBITO_PREDATADO":
223
+ paymentCode = PaymentCode.DEBITO_PREDATADO;
224
+ break;
225
+ case "CREDITO_AVISTA":
226
+ paymentCode = PaymentCode.CREDITO_AVISTA;
227
+ break;
228
+ case "CREDITO_PARCELADO_LOJA":
229
+ paymentCode = PaymentCode.CREDITO_PARCELADO_LOJA;
230
+ break;
231
+ case "CREDITO_PARCELADO_ADM":
232
+ paymentCode = PaymentCode.CREDITO_PARCELADO_ADM;
233
+ break;
234
+ case "CREDITO_PARCELADO_BNCO":
235
+ paymentCode = PaymentCode.CREDITO_PARCELADO_BNCO;
236
+ break;
237
+ case "CARTAO_LOJA_AVISTA":
238
+ paymentCode = PaymentCode.CARTAO_LOJA_AVISTA;
239
+ break;
240
+ case "CARTAO_LOJA_PARCELADO_LOJA":
241
+ paymentCode = PaymentCode.CARTAO_LOJA_PARCELADO_LOJA;
242
+ break;
243
+ case "CARTAO_LOJA_PARCELADO":
244
+ paymentCode = PaymentCode.CARTAO_LOJA_PARCELADO;
245
+ break;
246
+ case "PRE_AUTORIZACAO":
247
+ paymentCode = PaymentCode.PRE_AUTORIZACAO;
248
+ break;
249
+ case "VOUCHER_ALIMENTACAO":
250
+ paymentCode = PaymentCode.VOUCHER_ALIMENTACAO;
251
+ break;
252
+ case "VOUCHER_REFEICAO":
253
+ paymentCode = PaymentCode.VOUCHER_REFEICAO;
254
+ break;
255
+ case "VISAVALE_REFEICAO":
256
+ paymentCode = PaymentCode.VISAVALE_REFEICAO;
257
+ break;
258
+ case "VISAVALE_ALIMENTACAO":
259
+ paymentCode = PaymentCode.VISAVALE_ALIMENTACAO;
260
+ break;
261
+ default:
262
+ break;
263
+ }
264
+ return paymentCode;
265
+ }
110
266
 
111
- orderManager.bind(mContext, new ServiceBindListener() {
267
+
268
+ // Cielo Functions
269
+ protected void configSDK(String clientId, String accessToken) {
270
+ this._credentials = new Credentials(clientId, accessToken);
271
+ this.orderManager = new OrderManager(this._credentials, this.mContext);
272
+ this.orderManager.bind(this.mContext, new ServiceBindListener() {
273
+
274
+ @Override
275
+ public void onServiceBoundError(Throwable throwable) {
276
+ orderManagerServiceBinded = false;
277
+
278
+ // Toast.makeText(mContext,
279
+ // String.format("configSDK: onServiceBoundError: Erro fazendo bind do serviço de ordem -> %s",
280
+ // throwable.getMessage()), Toast.LENGTH_LONG).show();
281
+ }
282
+
283
+ @Override
284
+ public void onServiceBound() {
285
+ orderManagerServiceBinded = true;
286
+ // orderManager.createDraftOrder("REFERENCIA DA ORDEM");
287
+ // Toast.makeText(mContext,String.format("configSDK: onServiceBound"), Toast.LENGTH_LONG).show();
288
+ }
289
+
290
+ @Override
291
+ public void onServiceUnbound() {
292
+ orderManagerServiceBinded = false;
293
+ // Toast.makeText(mContext,String.format("configSDK: onServiceUnbound"), Toast.LENGTH_LONG).show();
294
+ }
295
+ });
296
+ }
297
+
298
+ protected void placeOrder(String productName) {
299
+ if (!orderManagerServiceBinded) {
300
+ // Toast.makeText(mContext, "Serviço de ordem ainda não recebeu retorno do método bind().\n"
301
+ // + "Verifique sua internet e tente novamente", Toast.LENGTH_LONG).show();
302
+ return;
303
+ }
304
+
305
+ // placeOrderButton.setEnabled(false);
306
+ order = orderManager.createDraftOrder("REFERENCIA DA ORDEM");
307
+ order.addItem("8989", "PROD LCS", 100, 3, "EACH");
308
+ orderManager.updateOrder(order);
309
+ }
310
+
311
+ protected void makePayment(String orderId,
312
+ long amount,
313
+ String ec,
314
+ int installments,
315
+ String email,
316
+ String paymentCodeStr,
317
+ CallbackContext callbackContext) {
318
+ cielo.sdk.order.payment.PaymentCode paymentCode = GetPaymentCodeFromName(paymentCodeStr);
319
+ if (paymentCode == null) {
320
+ callbackContext.error("Result - Cielo - LioLocal MakePayment: Invalid paymentCode (" + paymentCodeStr + ")");
321
+ return;
322
+ }
323
+
324
+
325
+ if (order != null) {
326
+ orderManager.placeOrder(order);
327
+ try {
328
+ CheckoutRequest.Builder requestBuilder = new CheckoutRequest.Builder()
329
+ .orderId(order.getId())
330
+ .amount(amount)
331
+ .paymentCode(paymentCode)
332
+ .installments(installments);
333
+
334
+ if (!ec.equals(""))
335
+ requestBuilder.ec(ec);
336
+
337
+ if (!email.equals(""))
338
+ requestBuilder.email(email);
339
+
340
+ CheckoutRequest request = requestBuilder.build();
341
+
342
+ orderManager.checkoutOrder(request, new PaymentListener() {
343
+ @Override
344
+ public void onStart() {
345
+ // Toast.makeText(mContext,"Result - Cielo - LioLocal MakePayment: checkoutOrder - onStart", 0).show();
346
+ // callbackContext.success("Result - Cielo - LioLocal MakePayment: checkoutOrder - onStart");
347
+ // Log.d(TAG, "ON START");
348
+ }
349
+
350
+ @Override
351
+ public void onPayment(Order paidOrder) {
352
+ order = paidOrder;
353
+ order.markAsPaid();
354
+ orderManager.updateOrder(order);
355
+ Gson gson = new Gson();
356
+ callbackContext.success(gson.toJson(order));
357
+ resetState();
358
+ }
359
+
360
+ @Override
361
+ public void onCancel() {
362
+ // Toast.makeText(mContext,String.format("Result - Cielo - LioLocal MakePayment: onCancel"), Toast.LENGTH_LONG).show();
363
+ callbackContext.error("Result - Cielo - LioLocal MakePayment: checkoutOrder - onCancel");
364
+ // Log.d(TAG, "ON CANCEL");
365
+ resetState();
366
+ }
367
+
368
+ @Override
369
+ public void onError(@NonNull PaymentError paymentError) {
370
+ // Toast.makeText(mContext,String.format("Result - Cielo - LioLocal MakePayment: onError"), Toast.LENGTH_LONG).show();
371
+ callbackContext.error("Result - Cielo - LioLocal MakePayment: checkoutOrder - onError");
372
+ // Log.d(TAG, "ON ERROR");
373
+ resetState();
374
+ }
375
+
376
+ });
377
+
378
+ } catch (Exception error1) {
379
+ callbackContext.error("makePayment " + "- Error Detail: " + error1);
380
+ throw error1;
381
+ }
382
+
383
+
384
+ // if (!ec.equals(""))
385
+ // requestBuilder.ec(ec);
386
+
387
+ // if (!userEmail.equals(""))
388
+ // requestBuilder.email(userEmail);
389
+
390
+ // CheckoutRequest request = requestBuilder.build();
391
+ }
392
+ }
393
+
394
+ protected void listOrders(CallbackContext callbackContext) {
395
+ try {
396
+ ResultOrders resultOrders = orderManager.retrieveOrders(200, 0);
397
+ if (resultOrders != null) {
398
+ Gson gson = new Gson();
399
+ callbackContext.success(gson.toJson(resultOrders));
400
+ } else {
401
+ callbackContext.success("null");
402
+ }
403
+ } catch (Exception error1) {
404
+ callbackContext.error("Result - Cielo - LioLocal - listOrders: " + "Error Detail: " + error1);
405
+ }
406
+ }
407
+
408
+ protected void cancelPayment(JSONObject orderObj, CallbackContext callbackContext) {
409
+ try {
410
+ String jsonStr = orderObj.toString();
411
+ Gson gson = new Gson();
412
+ //Order objCliente = gson.fromJson(jsonStr, Order.class);
413
+ order = gson.fromJson(jsonStr, Order.class);
414
+
415
+ List<Payment> paymentList = order.getPayments();
416
+ payment = paymentList.get(0);
417
+
418
+
419
+ if (order != null && order.getPayments().size() > 0) {
420
+ CancellationRequest request = new CancellationRequest.Builder()
421
+ .orderId(order.getId())
422
+ .authCode(payment.getAuthCode())
423
+ .cieloCode(payment.getCieloCode())
424
+ .value(payment.getAmount())
425
+ //.ec("0000000000000003")
426
+ .build();
427
+
428
+ orderManager.cancelOrder(request, new CancellationListener() {
112
429
 
113
430
  @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;
431
+ public void onSuccess(Order cancelledOrder) {
432
+ // Log.d(TAG, "ON SUCCESS");
433
+ cancelledOrder.cancel();
434
+ orderManager.updateOrder(cancelledOrder);
435
+ //
436
+ Toast.makeText(mContext, "CANCELAMENTO SUCESSO", Toast.LENGTH_SHORT).show();
437
+ order = cancelledOrder;
438
+ // resetState();
439
+ callbackContext.success(parseObjToJsonSrtring(order));
122
440
  }
123
441
 
124
442
  @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;
443
+ public void onCancel() {
444
+ callbackContext.success("cancelPayment - onCancel");
445
+ // Log.d(TAG, "ON CANCEL");
446
+ //
447
+ // Toast.makeText(CancelPaymentActivity.this, "CANCELADO", Toast.LENGTH_SHORT).show();
448
+ // resetUI();
146
449
  }
147
450
 
148
451
  @Override
149
- public void onServiceUnbound() {
150
- orderManagerServiceBinded = false;
452
+ public void onError(PaymentError paymentError) {
453
+ callbackContext.success("cancelPayment - onError");
454
+ // Log.d(TAG, "ON ERROR");
455
+ //
456
+ // Toast.makeText(CancelPaymentActivity.this, "ERRO", Toast.LENGTH_SHORT).show();
457
+ // resetUI();
151
458
  }
152
459
  });
153
- return true;
154
- } catch (Exception error1) {
155
- // alertarMensagem(resutText, error1);
156
- callbackContext.success("Result - ListarPagamentos: " + "Error Detail: " + error1);
157
- }
158
- // callbackContext.success("Result - ListarPagamentos: Ok " + action);
159
- // return true;
460
+
461
+ // callbackContext.success(jsonStr);
462
+ }
463
+ } catch (Exception error1) {
464
+ callbackContext.error("Result - Cielo - LioLocal - listOrders: " + "Error Detail: " + error1);
160
465
  }
161
- return false;
162
466
  }
163
467
 
468
+ protected String parseObjToJsonSrtring(Object obj) {
469
+ Gson gson = new Gson();
470
+ String result = gson.toJson(obj);
471
+ return result;
472
+ }
164
473
 
165
-
166
-
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
- // });
474
+ protected void resetState() {
475
+ order = null;
476
+ // configUi();
477
+ // updatePaymentButton();
194
478
  }
195
479
 
196
480
  }
@@ -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,24 @@ 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
+ }
12
+
13
+ exports.PlaceOrder = function (params, success, error) {
14
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.PlaceOrder', [params]);
15
+ }
16
+
17
+ exports.MakePayment = function (params, success, error) {
18
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.MakePayment', [params]);
19
+ }
20
+
21
+ exports.ListOrders = function (params, success, error) {
22
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.ListOrders', [params]);
23
+ }
24
+
25
+ exports.CancelPayment = function (param, success, error) {
26
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.CancelPayment', [param]);
11
27
  }
12
28
 
13
29
 
@@ -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