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 +3 -7
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/android/Cielo/CieloLioLocal.java +368 -84
- package/src/android/Elgin/ElginM10Terminal.java +133 -142
- package/src/build.gradle +2 -0
- package/www/Cielo/LioLocal.js +18 -2
- package/www/Elgin/M10Terminal.js +4 -8
package/README.md
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
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.
|
|
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
|
-
//
|
|
31
|
-
import
|
|
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
|
-
|
|
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("
|
|
117
|
+
else if (action.equals("ConfigureSdk")) {
|
|
118
|
+
JSONObject params = args.getJSONObject(0);
|
|
107
119
|
try {
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
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
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
|
150
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
168
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
91
|
+
else if(action.equals("AvancaPapel")){
|
|
92
|
+
try{
|
|
93
|
+
JSONObject params = args.getJSONObject(0);
|
|
106
94
|
|
|
107
|
-
|
|
95
|
+
int linhas = params.getInt("linhas");
|
|
108
96
|
|
|
109
|
-
|
|
97
|
+
int result = Termica.AvancaPapel(linhas);
|
|
110
98
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
106
|
+
else if(action.equals("Corte")){
|
|
107
|
+
try{
|
|
108
|
+
JSONObject params = args.getJSONObject(0);
|
|
120
109
|
|
|
121
|
-
|
|
110
|
+
int avanco = params.getInt("avanco");
|
|
122
111
|
|
|
123
|
-
|
|
112
|
+
int result = Termica.Corte(avanco);
|
|
124
113
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
139
|
+
else if(action.equals("ImpressaoCodigoBarras")){
|
|
140
|
+
try{
|
|
141
|
+
JSONObject params = args.getJSONObject(0);
|
|
152
142
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
149
|
+
int result = Termica.ImpressaoCodigoBarras(tipo, dados, altura, largura, HRI);
|
|
160
150
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
151
|
+
callbackContext.success(result);
|
|
152
|
+
}catch (Exception e){
|
|
153
|
+
callbackContext.error("ImpressaoCodigoBarras error: " + e.toString());
|
|
154
|
+
}
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
167
157
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
158
|
+
else if (action.equals("DefinePosicao")){
|
|
159
|
+
try{
|
|
160
|
+
JSONObject params = args.getJSONObject(0);
|
|
171
161
|
|
|
172
|
-
|
|
162
|
+
int posicao = params.getInt("posicao");
|
|
173
163
|
|
|
174
|
-
|
|
164
|
+
int result = Termica.DefinePosicao(posicao);
|
|
175
165
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
166
|
+
callbackContext.success(result);
|
|
167
|
+
}catch (Exception e){
|
|
168
|
+
callbackContext.error("DefinePosicao error: " + e.toString());
|
|
169
|
+
}
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
182
172
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
173
|
+
else if(action.equals("ImpressaoQRCode")){
|
|
174
|
+
try{
|
|
175
|
+
JSONObject params = args.getJSONObject(0);
|
|
186
176
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
177
|
+
String dados = params.getString("dados");
|
|
178
|
+
int tamanho = params.getInt("tamanho");
|
|
179
|
+
int nivelCorrecao = params.getInt("nivelCorrecao");
|
|
190
180
|
|
|
191
|
-
|
|
181
|
+
int result = Termica.ImpressaoQRCode(dados, tamanho, nivelCorrecao);
|
|
192
182
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
183
|
+
callbackContext.success(result) ;
|
|
184
|
+
}catch (Exception e){
|
|
185
|
+
callbackContext.error("ImpressaoQRCode error: " + e.toString());
|
|
186
|
+
}
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
199
189
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
190
|
+
else if(action.equals("ImprimeXMLNFCe")){
|
|
191
|
+
try{
|
|
192
|
+
JSONObject params = args.getJSONObject(0);
|
|
203
193
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
|
|
199
|
+
int result = Termica.ImprimeXMLNFCe(dados, indexcsc, csc, param);
|
|
210
200
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
201
|
+
callbackContext.success(result);
|
|
202
|
+
}catch (Exception e){
|
|
203
|
+
callbackContext.error("ImprimeXMLNFCe error: " + e.toString());
|
|
204
|
+
}
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
217
207
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
208
|
+
else if(action.equals("ImprimeXMLSAT")){
|
|
209
|
+
try{
|
|
210
|
+
JSONObject params = args.getJSONObject(0);
|
|
221
211
|
|
|
222
|
-
|
|
223
|
-
|
|
212
|
+
String dados = params.getString("dados");
|
|
213
|
+
int param = params.getInt("param");
|
|
224
214
|
|
|
225
|
-
|
|
215
|
+
int result = Termica.ImprimeXMLSAT(dados, param);
|
|
226
216
|
|
|
227
|
-
|
|
217
|
+
callbackContext.success(result);
|
|
228
218
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
219
|
+
}catch (Exception e){
|
|
220
|
+
callbackContext.error("ImprimeXMLSAT error: " + e.toString());
|
|
221
|
+
}
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
234
224
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
225
|
+
else if(action.equals("AbreGavetaElgin")){
|
|
226
|
+
try{
|
|
227
|
+
int result = Termica.AbreGavetaElgin();
|
|
238
228
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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
|
-
|
|
246
|
-
|
|
247
|
-
|
|
236
|
+
else if(action.equals("StatusImpressora")){
|
|
237
|
+
try{
|
|
238
|
+
JSONObject params = args.getJSONObject(0);
|
|
248
239
|
|
|
249
|
-
|
|
240
|
+
int param = params.getInt("param");
|
|
250
241
|
|
|
251
|
-
|
|
242
|
+
int result = Termica.StatusImpressora(param);
|
|
252
243
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
244
|
+
callbackContext.success(result);
|
|
245
|
+
}catch (Exception e){
|
|
246
|
+
callbackContext.error("StatusImpressora error: " + e.toString());
|
|
247
|
+
}
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
259
250
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
251
|
+
// else if(action.equals("ImprimeImagem")){
|
|
252
|
+
// try{
|
|
253
|
+
// JSONObject params = args.getJSONObject(0);
|
|
263
254
|
|
|
264
|
-
|
|
265
|
-
|
|
255
|
+
// if(params.getBoolean("cutPaper")) this.cutPaper = true;
|
|
256
|
+
// else this.cutPaper = false;
|
|
266
257
|
|
|
267
|
-
|
|
268
|
-
|
|
258
|
+
// Intent intent = new Intent((Intent.ACTION_PICK));
|
|
259
|
+
// intent.setType("image/*");
|
|
269
260
|
|
|
270
|
-
|
|
261
|
+
// // this.selecionarImagemCallbackContext = callbackContext;
|
|
271
262
|
|
|
272
|
-
|
|
273
|
-
|
|
263
|
+
// // this.cordova.setActivityResultCallback(this);
|
|
264
|
+
// // this.cordova.getActivity().startActivityForResult(intent, REQ_CODE_SELECAOIMAGEM);
|
|
274
265
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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
|
}
|
package/www/Cielo/LioLocal.js
CHANGED
|
@@ -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.
|
|
10
|
-
exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.
|
|
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
|
|
package/www/Elgin/M10Terminal.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|