cordova-plugin-netcontroll-integration 1.0.92 → 1.0.96
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 +1 -1
- package/package.json +1 -1
- package/plugin.xml +1 -22
- package/src/android/NetControllCordovaPluginsIntegration.java +0 -34
- package/src/android/PagSeguro/PagSeguroPax.java +0 -644
- package/www/PagSeguro/PagSeguroPax.js +0 -21
- package/www/alice.js +0 -4
- package/www/bob.js +0 -10
package/README.md
CHANGED
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.96"
|
|
3
3
|
xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
4
4
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
5
5
|
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
</js-module>
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
18
17
|
<js-module name="ElginM10Terminal" src="www/Elgin/M10Terminal.js">
|
|
19
18
|
<clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration.ElginM10Terminal" />
|
|
20
19
|
</js-module>
|
|
@@ -36,22 +35,6 @@
|
|
|
36
35
|
<clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration.SafraPayIngenico" />
|
|
37
36
|
</js-module>
|
|
38
37
|
|
|
39
|
-
<js-module name="PagSeguroPax" src="www/PagSeguro/PagSeguroPax.js">
|
|
40
|
-
<clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration.PagSeguroPax" />
|
|
41
|
-
</js-module>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<js-module src="www/alice.js" name="alice">
|
|
46
|
-
<clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration.alice" />
|
|
47
|
-
<!-- <runs/> -->
|
|
48
|
-
</js-module>
|
|
49
|
-
<js-module src="www/bob.js" name="bob">
|
|
50
|
-
<clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration.bob" />
|
|
51
|
-
<!-- <runs/> -->
|
|
52
|
-
</js-module>
|
|
53
|
-
|
|
54
|
-
|
|
55
38
|
<dependency id="cordova-plugin-androidx-adapter" version="1.1.3" />
|
|
56
39
|
<platform name="android">
|
|
57
40
|
<config-file parent="/*" target="res/xml/config.xml">
|
|
@@ -110,10 +93,6 @@
|
|
|
110
93
|
|
|
111
94
|
<resource-file src="src/libs/IntegracaoSafra-v2.0.aar" target="libs/IntegracaoSafra-v2.0.aar" />
|
|
112
95
|
|
|
113
|
-
<!--______________________________PagSeguro___________________________-->
|
|
114
|
-
<source-file src="src/android/PagSeguro/PagSeguroPax.java" target-dir="src/cordova-plugin-netcontroll-integration/PagSeguro" />
|
|
115
|
-
|
|
116
|
-
|
|
117
96
|
<!--______________________________Other______________________________-->
|
|
118
97
|
|
|
119
98
|
<!-- BarcodeScanner -->
|
|
@@ -28,9 +28,6 @@ public class NetControllCordovaPluginsIntegration extends CordovaPlugin {
|
|
|
28
28
|
//SafraPay
|
|
29
29
|
public SafraPayIngenico safraPayIngenico;
|
|
30
30
|
|
|
31
|
-
//PagSeguro
|
|
32
|
-
public PagSeguroPax pagSeguroPax;
|
|
33
|
-
|
|
34
31
|
//Cordova/Java Params
|
|
35
32
|
private Activity mActivity;
|
|
36
33
|
private Context mContext;
|
|
@@ -89,13 +86,6 @@ public class NetControllCordovaPluginsIntegration extends CordovaPlugin {
|
|
|
89
86
|
}
|
|
90
87
|
}
|
|
91
88
|
|
|
92
|
-
private void initializePagSeguroPax() {
|
|
93
|
-
if (this.pagSeguroPax == null) {
|
|
94
|
-
this.pagSeguroPax = new PagSeguroPax();
|
|
95
|
-
this.pagSeguroPax.initialize(this.cordova, this.webView);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
89
|
@Override
|
|
100
90
|
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
|
101
91
|
try {
|
|
@@ -103,19 +93,6 @@ public class NetControllCordovaPluginsIntegration extends CordovaPlugin {
|
|
|
103
93
|
String[] actionProviderList = action.split("\\.");
|
|
104
94
|
String provider = actionProviderList[0];
|
|
105
95
|
|
|
106
|
-
// if (action.equals("GerarImagemImpresso")) {
|
|
107
|
-
// JSONObject params = args.getJSONObject(0);
|
|
108
|
-
// String htmlString = params.getString("dados");
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// //String html = "<html><body><p>Hello world!</p><br/>Html bitmap</body><html>";
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// //callbackContext.success("Result GerarImagemImpresso");
|
|
115
|
-
// return true;
|
|
116
|
-
// }
|
|
117
|
-
|
|
118
|
-
|
|
119
96
|
switch (provider.toLowerCase()) {
|
|
120
97
|
case "elgin":
|
|
121
98
|
String elginProduct = actionProviderList[1];
|
|
@@ -177,17 +154,6 @@ public class NetControllCordovaPluginsIntegration extends CordovaPlugin {
|
|
|
177
154
|
default:
|
|
178
155
|
break;
|
|
179
156
|
}
|
|
180
|
-
case "pagseguro":
|
|
181
|
-
String pagSeguroProduct = actionProviderList[1];
|
|
182
|
-
switch (pagSeguroProduct.toLowerCase()) {
|
|
183
|
-
case "pagseguropax":
|
|
184
|
-
this.initializePagSeguroPax();
|
|
185
|
-
String pagSeguroAction = actionProviderList[2];
|
|
186
|
-
boolean resultPagSeguroExecute = this.pagSeguroPax.execute(pagSeguroAction, args, callbackContext);
|
|
187
|
-
return resultPagSeguroExecute;
|
|
188
|
-
default:
|
|
189
|
-
break;
|
|
190
|
-
}
|
|
191
157
|
default:
|
|
192
158
|
break;
|
|
193
159
|
}
|
|
@@ -1,644 +0,0 @@
|
|
|
1
|
-
package cordova.plugin.netcontroll.integration;
|
|
2
|
-
|
|
3
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagCustomPrinterLayout;
|
|
4
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagEventData;
|
|
5
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagVoidData;
|
|
6
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.exception.PlugPagException;
|
|
7
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.listeners.PlugPagPaymentListener;
|
|
8
|
-
import io.reactivex.Observable;
|
|
9
|
-
import io.reactivex.ObservableEmitter;
|
|
10
|
-
|
|
11
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagActivationData;
|
|
12
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagPaymentData;
|
|
13
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagTransactionResult;
|
|
14
|
-
import cordova.plugin.netcontroll.integration.NetControllHelpers;
|
|
15
|
-
import cordova.plugin.netcontroll.integration.NetControllPrinter;
|
|
16
|
-
|
|
17
|
-
import org.apache.cordova.CordovaPlugin;
|
|
18
|
-
import org.apache.cordova.PluginResult;
|
|
19
|
-
import org.apache.cordova.CallbackContext;
|
|
20
|
-
import org.apache.cordova.CordovaInterface;
|
|
21
|
-
import org.apache.cordova.CordovaWebView;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import org.jetbrains.annotations.NotNull;
|
|
25
|
-
import org.json.JSONArray;
|
|
26
|
-
import org.json.JSONException;
|
|
27
|
-
import org.json.JSONObject;
|
|
28
|
-
|
|
29
|
-
import android.annotation.SuppressLint;
|
|
30
|
-
import android.app.Activity;
|
|
31
|
-
import android.content.ContentResolver;
|
|
32
|
-
import android.content.ContentValues;
|
|
33
|
-
import android.content.pm.PackageInfo;
|
|
34
|
-
import android.content.pm.PackageManager;
|
|
35
|
-
import android.graphics.Bitmap;
|
|
36
|
-
import android.content.Context;
|
|
37
|
-
import android.os.Build;
|
|
38
|
-
import android.os.Environment;
|
|
39
|
-
import android.os.Handler;
|
|
40
|
-
import android.os.Looper;
|
|
41
|
-
import android.os.Message;
|
|
42
|
-
import android.util.Log;
|
|
43
|
-
import android.widget.Toast;
|
|
44
|
-
import android.net.Uri;
|
|
45
|
-
import android.content.Intent;
|
|
46
|
-
import android.provider.MediaStore;
|
|
47
|
-
|
|
48
|
-
import android.graphics.Bitmap;
|
|
49
|
-
import android.graphics.BitmapFactory;
|
|
50
|
-
import android.graphics.Matrix;
|
|
51
|
-
|
|
52
|
-
import android.util.Base64;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPag;
|
|
56
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagAppIdentification;
|
|
57
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagActivationData;
|
|
58
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagInitializationResult;
|
|
59
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagPrintResult;
|
|
60
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagPrinterData;
|
|
61
|
-
import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagPrinterListener;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// import br.com.setis.safra.integracaosafra.BuildConfig;
|
|
65
|
-
// import br.com.setis.safra.integracaosafra.Gerenciador;
|
|
66
|
-
// import br.com.setis.safra.integracaosafra.PrinterIntegracao;
|
|
67
|
-
// import br.com.setis.safra.integracaosafra.entidades.DadosAutomacao;
|
|
68
|
-
// import br.com.setis.safra.integracaosafra.entidades.EntradaTransacao;
|
|
69
|
-
// import br.com.setis.safra.integracaosafra.entidades.MifareBlockData;
|
|
70
|
-
// import br.com.setis.safra.integracaosafra.entidades.NFCRequest;
|
|
71
|
-
// import br.com.setis.safra.integracaosafra.entidades.Operacoes;
|
|
72
|
-
// import br.com.setis.safra.integracaosafra.entidades.RequestApi;
|
|
73
|
-
// import br.com.setis.safra.integracaosafra.entidades.SaidaTransacao;
|
|
74
|
-
// import br.com.setis.safra.integracaosafra.listeners.MifareNFCCallback;
|
|
75
|
-
// import br.com.setis.safra.integracaosafra.listeners.PrinterListener;
|
|
76
|
-
// import br.com.setis.safra.integracaosafra.listeners.TransacaoListenerCallback;
|
|
77
|
-
// import br.com.setis.safra.integracaosafra.printer.PrinterStatus;
|
|
78
|
-
// import br.com.setis.safra.integracaosafra.printer.PrinterTextAlignment;
|
|
79
|
-
// import br.com.setis.safra.integracaosafra.printer.PrinterTextSize;
|
|
80
|
-
// import br.com.setis.safra.integracaosafra.printer.PrinterTextStyle;
|
|
81
|
-
// import br.com.setis.safra.integracaosafra.util.ReturnCodes;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
//Json Serialize
|
|
85
|
-
|
|
86
|
-
import stone.application.enums.ReceiptType;
|
|
87
|
-
|
|
88
|
-
import com.google.gson.Gson;
|
|
89
|
-
import com.google.gson.GsonBuilder;
|
|
90
|
-
import com.google.gson.annotations.SerializedName;
|
|
91
|
-
import com.google.zxing.WriterException;
|
|
92
|
-
import com.google.zxing.MultiFormatWriter;
|
|
93
|
-
import com.google.zxing.common.BitMatrix;
|
|
94
|
-
import com.google.zxing.BarcodeFormat;
|
|
95
|
-
|
|
96
|
-
import java.io.File;
|
|
97
|
-
import java.io.FileOutputStream;
|
|
98
|
-
import java.io.IOException;
|
|
99
|
-
import java.io.OutputStream;
|
|
100
|
-
import java.text.SimpleDateFormat;
|
|
101
|
-
import java.util.Date;
|
|
102
|
-
import java.util.List;
|
|
103
|
-
import java.util.HashMap;
|
|
104
|
-
import java.util.Map;
|
|
105
|
-
|
|
106
|
-
import com.google.zxing.EncodeHintType;
|
|
107
|
-
|
|
108
|
-
import android.os.AsyncTask;
|
|
109
|
-
|
|
110
|
-
import androidx.annotation.NonNull;
|
|
111
|
-
import androidx.core.app.ActivityCompat;
|
|
112
|
-
import androidx.core.content.ContextCompat;
|
|
113
|
-
|
|
114
|
-
import java.lang.reflect.Type;
|
|
115
|
-
import java.util.ArrayList;
|
|
116
|
-
|
|
117
|
-
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
|
118
|
-
|
|
119
|
-
import java.util.EnumMap;
|
|
120
|
-
|
|
121
|
-
import com.izettle.html2bitmap.Html2Bitmap;
|
|
122
|
-
import com.izettle.html2bitmap.content.WebViewContent;
|
|
123
|
-
|
|
124
|
-
import java.io.ByteArrayOutputStream;
|
|
125
|
-
|
|
126
|
-
import android.content.pm.PackageInfo;
|
|
127
|
-
import android.content.pm.PackageManager;
|
|
128
|
-
|
|
129
|
-
public class PagSeguroPax {
|
|
130
|
-
private PlugPag plugpag;
|
|
131
|
-
|
|
132
|
-
private static final int PERMISSIONS_REQUEST_CODE = 0x1234;
|
|
133
|
-
private Activity mActivity;
|
|
134
|
-
private Context mContext;
|
|
135
|
-
private CordovaInterface mCordova;
|
|
136
|
-
private CordovaWebView webView;
|
|
137
|
-
|
|
138
|
-
//@Override
|
|
139
|
-
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
|
140
|
-
this.webView = webView;
|
|
141
|
-
mActivity = cordova.getActivity();
|
|
142
|
-
mContext = cordova.getActivity().getApplicationContext();
|
|
143
|
-
mCordova = cordova;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
|
147
|
-
if (action.equals("InitializeSdk")) {
|
|
148
|
-
JSONObject params = args.getJSONObject(0);
|
|
149
|
-
try {
|
|
150
|
-
NetControllPrinter.RequestPermissions(this.mActivity, this.mContext);
|
|
151
|
-
|
|
152
|
-
String appName = params.getString("appName");
|
|
153
|
-
String appVersion = params.getString("appVersion");
|
|
154
|
-
// String activationCode = params.getString("activationCode");
|
|
155
|
-
String activationCode = "403938";
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
PlugPagAppIdentification appIdentification = new PlugPagAppIdentification(appName, appVersion);
|
|
159
|
-
plugpag = new PlugPag(mContext, appIdentification);
|
|
160
|
-
|
|
161
|
-
// PlugPagInitializationResult result = this.plugpag.initializeAndActivatePinpad(new PlugPagActivationData(activationCode));
|
|
162
|
-
// int result = this.plugpag.initializeAndActivatePinpad(new PlugPagActivationData(activationCode)).getResult();
|
|
163
|
-
this.mCordova.getThreadPool().execute(new Runnable() {
|
|
164
|
-
public void run() {
|
|
165
|
-
// plugpag = new PlugPag(mActivity, appIdentification);
|
|
166
|
-
plugpag.initializeAndActivatePinpad(new PlugPagActivationData(activationCode));
|
|
167
|
-
callbackContext.success("InitializeSdk OK"); // Thread-safe.
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
// this.mCordova.getActivity().runOnUiThread(new Runnable() {
|
|
171
|
-
// public void run() {
|
|
172
|
-
// plugpag = new PlugPag(mActivity, appIdentification);
|
|
173
|
-
// plugpag.initializeAndActivatePinpad(new PlugPagActivationData(activationCode));
|
|
174
|
-
// callbackContext.success("asdasd"); // Thread-safe.
|
|
175
|
-
// }
|
|
176
|
-
// });
|
|
177
|
-
|
|
178
|
-
// this.mCordova.getActivity().runOnUiThread(new Runnable() {
|
|
179
|
-
// @Override
|
|
180
|
-
// public void run() {
|
|
181
|
-
// plugpag = new PlugPag(mActivity, appIdentification);
|
|
182
|
-
// int result = plugpag.initializeAndActivatePinpad(new PlugPagActivationData(activationCode)).getResult();
|
|
183
|
-
// if (result == 0) {
|
|
184
|
-
// callbackContext.success("InitializeSdk OK");
|
|
185
|
-
// }
|
|
186
|
-
// }
|
|
187
|
-
// });
|
|
188
|
-
// callbackContext.success("InitializeSdk OK");
|
|
189
|
-
return true;
|
|
190
|
-
} catch (Exception error1) {
|
|
191
|
-
callbackContext.error("Result - PagSeguro - Pax - InitializeSdk: " + "Error Detail: " + error1);
|
|
192
|
-
}
|
|
193
|
-
return false;
|
|
194
|
-
} else if (action.equals("IniciarTransacao")) {
|
|
195
|
-
try {
|
|
196
|
-
JSONObject params = args.getJSONObject(0);
|
|
197
|
-
|
|
198
|
-
int tipoTransacao = params.getInt("tipoTransacao");
|
|
199
|
-
int valor = params.getInt("valor");
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
int tipoParcelamento = params.getInt("tipoParcelamento");
|
|
203
|
-
int numeroParcelas = params.getInt("numeroParcelas");
|
|
204
|
-
|
|
205
|
-
String identificadorAutomacao = params.getString("identificadorAutomacao");
|
|
206
|
-
String statusChangeCallBack = params.getString("statusChangeCallBack");
|
|
207
|
-
|
|
208
|
-
PlugPagPaymentData paymentData =
|
|
209
|
-
new PlugPagPaymentData(
|
|
210
|
-
tipoTransacao,
|
|
211
|
-
valor,
|
|
212
|
-
tipoParcelamento,
|
|
213
|
-
numeroParcelas,
|
|
214
|
-
identificadorAutomacao);
|
|
215
|
-
|
|
216
|
-
this.plugpag.doAsyncPayment(paymentData, new PlugPagPaymentListener() {
|
|
217
|
-
@Override
|
|
218
|
-
public void onSuccess(@NotNull PlugPagTransactionResult plugPagTransactionResult) {
|
|
219
|
-
mActivity.runOnUiThread(new Runnable() {
|
|
220
|
-
@Override
|
|
221
|
-
public void run() {
|
|
222
|
-
String transactionStatus = plugPagTransactionResult.getMessage();
|
|
223
|
-
executeGlobalJavascript(statusChangeCallBack + "('" + transactionStatus + "')");
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
callbackContext.success(NetControllHelpers.parseObjToJsonSrtring(plugPagTransactionResult));
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
@Override
|
|
230
|
-
public void onError(@NotNull PlugPagTransactionResult plugPagTransactionResult) {
|
|
231
|
-
//seu código aqui
|
|
232
|
-
callbackContext.error(plugPagTransactionResult.getErrorCode() + " - " + plugPagTransactionResult.getMessage());
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
@Override
|
|
236
|
-
public void onPaymentProgress(@NotNull PlugPagEventData plugPagEventData) {
|
|
237
|
-
executeGlobalJavascript(statusChangeCallBack + "('" + plugPagEventData.getCustomMessage() + "')");
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
@Override
|
|
241
|
-
public void onPrinterSuccess(@NotNull PlugPagPrintResult plugPagPrintResult) {
|
|
242
|
-
String printerSuccess = "";
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
@Override
|
|
246
|
-
public void onPrinterError(@NotNull PlugPagPrintResult plugPagPrintResult) {
|
|
247
|
-
String printerError = "";
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
return true;
|
|
251
|
-
} catch (Exception ex) {
|
|
252
|
-
String exStr = ex.toString();
|
|
253
|
-
throw ex;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
} else if (action.equals("AbortarTransacao")) {
|
|
257
|
-
try {
|
|
258
|
-
|
|
259
|
-
try {
|
|
260
|
-
this.plugpag.abort();
|
|
261
|
-
callbackContext.success("PagSeguro - Pax - AbortarTransacao - onSuccess");
|
|
262
|
-
} catch (Exception e) {
|
|
263
|
-
callbackContext.error("Result - PagSeguro - Pax - AbortarTransacao: " + "Error Detail: " + e.toString());
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// new Thread(() -> {
|
|
267
|
-
// try {
|
|
268
|
-
// transactionProvider.abortPayment();
|
|
269
|
-
// callbackContext.success("Stone - Sumni - AbortarTransacao - onSuccess");
|
|
270
|
-
// } catch (Exception e) {
|
|
271
|
-
// callbackContext.error("Result - Stone - Sumni - AbortarTransacao: " + "Error Detail: " + e.toString());
|
|
272
|
-
// }
|
|
273
|
-
// }).start();
|
|
274
|
-
return true;
|
|
275
|
-
} catch (Exception error1) {
|
|
276
|
-
callbackContext.error("Result - PagSeguro - Pax - AbortarTransacao: " + "Error Detail: " + error1);
|
|
277
|
-
}
|
|
278
|
-
return false;
|
|
279
|
-
} else if (action.equals("CancelarTransacao")) {
|
|
280
|
-
try {
|
|
281
|
-
JSONObject params = args.getJSONObject(0);
|
|
282
|
-
|
|
283
|
-
String codigoTransacao = params.getString("codigoTransacao");
|
|
284
|
-
String idTransacao = params.getString("idTransacao");
|
|
285
|
-
boolean imprimirRecibo = params.getBoolean("imprimirRecibo");
|
|
286
|
-
|
|
287
|
-
// int tipoTransacao = params.getInt("tipoTransacao");
|
|
288
|
-
// int valor = params.getInt("valor");
|
|
289
|
-
//
|
|
290
|
-
//
|
|
291
|
-
// int tipoParcelamento = params.getInt("tipoParcelamento");
|
|
292
|
-
// int numeroParcelas = params.getInt("numeroParcelas");
|
|
293
|
-
//
|
|
294
|
-
// String identificadorAutomacao = params.getString("identificadorAutomacao");
|
|
295
|
-
String statusChangeCallBack = params.getString("statusChangeCallBack");
|
|
296
|
-
|
|
297
|
-
PlugPagVoidData plugPagVoidData = new PlugPagVoidData(codigoTransacao, idTransacao, imprimirRecibo);
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
// PlugPagPaymentData paymentData =
|
|
301
|
-
// new PlugPagPaymentData(
|
|
302
|
-
// tipoTransacao,
|
|
303
|
-
// valor,
|
|
304
|
-
// tipoParcelamento,
|
|
305
|
-
// numeroParcelas,
|
|
306
|
-
// identificadorAutomacao);
|
|
307
|
-
|
|
308
|
-
this.plugpag.doAsyncVoidPayment(plugPagVoidData, new PlugPagPaymentListener() {
|
|
309
|
-
@Override
|
|
310
|
-
public void onSuccess(@NotNull PlugPagTransactionResult plugPagTransactionResult) {
|
|
311
|
-
String testeSucess = "onSuccess";
|
|
312
|
-
// mActivity.runOnUiThread(new Runnable() {
|
|
313
|
-
// @Override
|
|
314
|
-
// public void run() {
|
|
315
|
-
// String transactionStatus = plugPagTransactionResult.getMessage();
|
|
316
|
-
// executeGlobalJavascript(statusChangeCallBack + "('" + transactionStatus + "')");
|
|
317
|
-
// }
|
|
318
|
-
// });
|
|
319
|
-
// callbackContext.success(NetControllHelpers.parseObjToJsonSrtring(plugPagTransactionResult));
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
@Override
|
|
323
|
-
public void onError(@NotNull PlugPagTransactionResult plugPagTransactionResult) {
|
|
324
|
-
//seu código aqui
|
|
325
|
-
callbackContext.error(plugPagTransactionResult.getErrorCode() + " - " + plugPagTransactionResult.getMessage());
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
@Override
|
|
329
|
-
public void onPaymentProgress(@NotNull PlugPagEventData plugPagEventData) {
|
|
330
|
-
executeGlobalJavascript(statusChangeCallBack + "('" + plugPagEventData.getCustomMessage() + "')");
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
@Override
|
|
334
|
-
public void onPrinterSuccess(@NotNull PlugPagPrintResult plugPagPrintResult) {
|
|
335
|
-
String printerSuccess = "";
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
@Override
|
|
339
|
-
public void onPrinterError(@NotNull PlugPagPrintResult plugPagPrintResult) {
|
|
340
|
-
String printerError = "";
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
return true;
|
|
344
|
-
} catch (Exception ex) {
|
|
345
|
-
String exStr = ex.toString();
|
|
346
|
-
throw ex;
|
|
347
|
-
}
|
|
348
|
-
// try {
|
|
349
|
-
//// JSONObject params = args.getJSONObject(0);
|
|
350
|
-
////
|
|
351
|
-
//// String tipoTransacao = params.getString("tipoTransacao");
|
|
352
|
-
//// Operacoes tipoTransacaoObj = GetOperacaoTypeEnumByName(tipoTransacao);
|
|
353
|
-
////
|
|
354
|
-
//// String nsuTransacao = params.getString("nsuTransacao");
|
|
355
|
-
////
|
|
356
|
-
//// String identificadorAutomacao = params.getString("identificadorAutomacao");
|
|
357
|
-
////
|
|
358
|
-
//// EntradaTransacao entradaTransacaoCancelamento = new EntradaTransacao(nsuTransacao, tipoTransacaoObj, identificadorAutomacao);
|
|
359
|
-
//// RequestApi requestApi = new RequestApi(entradaTransacaoCancelamento);
|
|
360
|
-
////
|
|
361
|
-
//// TransacaoListenerCallback callbackCancelamentoTransacao = new TransacaoListenerCallback() {
|
|
362
|
-
//// @Override
|
|
363
|
-
//// public void transacaoFinalizada(final SaidaTransacao saidaTransacao) {
|
|
364
|
-
//// //1 = aprovada // 3 = estornada
|
|
365
|
-
//// if (saidaTransacao.obtemResultadoTransacao() == ReturnCodes.RESULT_APROVADA || (saidaTransacao.obtemOperacaoRealizada() == Operacoes.CANCELAMENTO || saidaTransacao.obtemOperacaoRealizada() == Operacoes.CANCELAMENTO_VIA_NSU && saidaTransacao.obtemResultadoTransacao() == ReturnCodes.RESULT_ESTORNADA)) {
|
|
366
|
-
//// String viaImpressao = saidaTransacao.obtemComprovanteViaLojista().toString();
|
|
367
|
-
//// callbackContext.success(NetControllHelpers.parseObjToJsonSrtring(saidaTransacao));
|
|
368
|
-
//// } else if (saidaTransacao.obtemOperacaoRealizada() == Operacoes.REIMPRESSAO && saidaTransacao.obtemResultadoTransacao() == ReturnCodes.RESULT_OK) {
|
|
369
|
-
//// callbackContext.success(NetControllHelpers.parseObjToJsonSrtring(saidaTransacao));
|
|
370
|
-
//// // builder.setMessage("Sucesso " + saidaTransacao.obtemOperacaoRealizada().name());
|
|
371
|
-
//// } else {
|
|
372
|
-
//// callbackContext.error("erro ao realizar " + saidaTransacao.obtemOperacaoRealizada().name());
|
|
373
|
-
//// }
|
|
374
|
-
//// }
|
|
375
|
-
////
|
|
376
|
-
//// @Override
|
|
377
|
-
//// public void transacaoException(Exception e) {
|
|
378
|
-
//// callbackContext.error("erro " + e.toString());
|
|
379
|
-
//// }
|
|
380
|
-
//// };
|
|
381
|
-
//// gerenciadorIntegracaoSafra.realizaTransacao(requestApi, callbackCancelamentoTransacao);
|
|
382
|
-
// return true;
|
|
383
|
-
// } catch (Exception e) {
|
|
384
|
-
// callbackContext.error("IniciarTransacao error: " + e.toString());
|
|
385
|
-
// }
|
|
386
|
-
// return false;
|
|
387
|
-
} else if (action.equals("ImpressaoTextoNetPrintImg")) {
|
|
388
|
-
JSONObject params = args.getJSONObject(0);
|
|
389
|
-
try {
|
|
390
|
-
if (plugpag == null) {
|
|
391
|
-
callbackContext.error("ImpressaoTextoNetPrintImg error: Sdk não inicializado");
|
|
392
|
-
return false;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
String dados = params.getString("dados");
|
|
396
|
-
String html = NetControllPrinter.ConverterTextoImpressoToHtml(dados);
|
|
397
|
-
NetControllPrinter.ConverterHtmlToBitmap(html, mContext, bitmapResult -> {
|
|
398
|
-
Bitmap dadosImg = bitmapResult;
|
|
399
|
-
String directoryFileName = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Download/NetControllPrint.bmp";
|
|
400
|
-
try {
|
|
401
|
-
String fileName = NetControllPrinter.SaveImage(dadosImg, directoryFileName);
|
|
402
|
-
if (!fileName.isEmpty()) {
|
|
403
|
-
this.ImprimirArquivo(fileName, callbackContext);
|
|
404
|
-
}
|
|
405
|
-
} catch (IOException e) {
|
|
406
|
-
e.printStackTrace();
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
} catch (Exception e) {
|
|
410
|
-
callbackContext.error("ImpressaoTextoNetPrintImg error: " + e.toString());
|
|
411
|
-
}
|
|
412
|
-
return true;
|
|
413
|
-
}
|
|
414
|
-
return false;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
private boolean ImprimirArquivo(String caminhoArquivo, CallbackContext callbackContext) {
|
|
418
|
-
try {
|
|
419
|
-
if (caminhoArquivo != "") {
|
|
420
|
-
try {
|
|
421
|
-
AsyncTask<Void, Void, Boolean> taskPrinter = new AsyncTask<Void, Void, Boolean>() {
|
|
422
|
-
@Override
|
|
423
|
-
protected Boolean doInBackground(Void... voids) {
|
|
424
|
-
PlugPagPrinterData plugPagPrinterData = new PlugPagPrinterData(
|
|
425
|
-
caminhoArquivo,
|
|
426
|
-
10,
|
|
427
|
-
10 * 12);
|
|
428
|
-
|
|
429
|
-
PlugPagPrinterListener listener = new PlugPagPrinterListener() {
|
|
430
|
-
@Override
|
|
431
|
-
public void onSuccess(@NonNull PlugPagPrintResult plugPagPrintResult) {
|
|
432
|
-
callbackContext.success("Arquivo impresso com sucesso");
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
@Override
|
|
436
|
-
public void onError(@NotNull PlugPagPrintResult plugPagPrintResult) {
|
|
437
|
-
callbackContext.error("Erro ao imprimir: " + plugPagPrintResult.getErrorCode() + " - " + plugPagPrintResult.getMessage());
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
//Seta listener de impressão
|
|
442
|
-
plugpag.setPrinterListener(listener);
|
|
443
|
-
|
|
444
|
-
// Imprime arquivo
|
|
445
|
-
PlugPagPrintResult result = plugpag.printFromFile(plugPagPrinterData);
|
|
446
|
-
|
|
447
|
-
if (result.getResult() == PlugPag.RET_OK) {
|
|
448
|
-
callbackContext.success("Arquivo impresso com sucesso");
|
|
449
|
-
}
|
|
450
|
-
return true;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
@Override
|
|
454
|
-
protected void onPostExecute(Boolean bitmap) {
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
taskPrinter.execute();
|
|
459
|
-
return true;
|
|
460
|
-
} catch (Exception ex) {
|
|
461
|
-
String exStr = ex.toString();
|
|
462
|
-
throw ex;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
} catch (Exception errorPost) {
|
|
466
|
-
callbackContext.error("Result - ImprimirArquivo: " + "Error Detail: " + errorPost);
|
|
467
|
-
return false;
|
|
468
|
-
}
|
|
469
|
-
return false;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
private void executeGlobalJavascript(final String jsString) {
|
|
473
|
-
mActivity.runOnUiThread(new Runnable() {
|
|
474
|
-
@Override
|
|
475
|
-
public void run() {
|
|
476
|
-
webView.loadUrl("javascript:" + jsString);
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
// public Observable<Object> initializeAndActivatePinpad() {
|
|
482
|
-
// return Observable.create(emitter -> {
|
|
483
|
-
// PlugPagInitializationResult result = this.plugpag.initializeAndActivatePinpad(new PlugPagActivationData("403938"));
|
|
484
|
-
// if (result.getResult() == PlugPag.RET_OK) {
|
|
485
|
-
// emitter.onNext(new Object());
|
|
486
|
-
// } else {
|
|
487
|
-
// emitter.onError(new RuntimeException(result.getErrorMessage()));
|
|
488
|
-
// }
|
|
489
|
-
// emitter.onComplete();
|
|
490
|
-
// });
|
|
491
|
-
// }
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
// private PlugPagPaymentData mPlugPagPaymentData = null;
|
|
495
|
-
|
|
496
|
-
// private Observable<PagSeguroPaxActionResult> doPayment(final PlugPagPaymentData paymentData) {
|
|
497
|
-
// mPlugPagPaymentData = paymentData;
|
|
498
|
-
// return Observable.create(emitter -> {
|
|
499
|
-
//// mPlugPag.setPlugPagCustomPrinterLayout(getCustomPrinterDialog());
|
|
500
|
-
// PagSeguroPaxActionResult result = new PagSeguroPaxActionResult();
|
|
501
|
-
// setListener(emitter, result);
|
|
502
|
-
//// setPrintListener(emitter, result);
|
|
503
|
-
// PlugPagTransactionResult plugPagTransactionResult = this.plugpag.doPayment(paymentData);
|
|
504
|
-
// if (plugPagTransactionResult != null) {
|
|
505
|
-
// String teste = "";
|
|
506
|
-
// }
|
|
507
|
-
//// sendResponse(emitter, plugPagTransactionResult, result);
|
|
508
|
-
// });
|
|
509
|
-
// }
|
|
510
|
-
//
|
|
511
|
-
// private void setListener(ObservableEmitter<PagSeguroPaxActionResult> emitter, PagSeguroPaxActionResult result) {
|
|
512
|
-
// this.plugpag.setEventListener(plugPagEventData -> {
|
|
513
|
-
// result.setEventCode(plugPagEventData.getEventCode());
|
|
514
|
-
// result.setMessage(plugPagEventData.getCustomMessage());
|
|
515
|
-
// emitter.onNext(result);
|
|
516
|
-
// });
|
|
517
|
-
// }
|
|
518
|
-
//
|
|
519
|
-
//
|
|
520
|
-
// public void startPayment(Context context) {
|
|
521
|
-
// // Define os dados do pagamento
|
|
522
|
-
// PlugPagPaymentData paymentData =
|
|
523
|
-
// new PlugPagPaymentData(
|
|
524
|
-
// PlugPag.TYPE_CREDITO,
|
|
525
|
-
// 25000,
|
|
526
|
-
// PlugPag.INSTALLMENT_TYPE_A_VISTA,
|
|
527
|
-
// 1,
|
|
528
|
-
// "CODVENDA");
|
|
529
|
-
//
|
|
530
|
-
// // Cria a identificação do aplicativo
|
|
531
|
-
// PlugPagAppIdentification appIdentification =
|
|
532
|
-
// new PlugPagAppIdentification("MeuApp", "1.0.7");
|
|
533
|
-
//
|
|
534
|
-
// // Cria a referência do PlugPag
|
|
535
|
-
// PlugPag plugpag = new PlugPag(context, appIdentification);
|
|
536
|
-
//
|
|
537
|
-
// // Ativa terminal e faz o pagamento
|
|
538
|
-
// int initResult = plugpag.initializeAndActivatePinpad(new
|
|
539
|
-
// PlugPagActivationData("403938")).getResult();
|
|
540
|
-
//
|
|
541
|
-
// if (initResult == PlugPag.RET_OK) {
|
|
542
|
-
// PlugPagTransactionResult result = plugpag.doPayment(paymentData);
|
|
543
|
-
//
|
|
544
|
-
// // Trata o resultado da transação
|
|
545
|
-
//
|
|
546
|
-
// }
|
|
547
|
-
// }
|
|
548
|
-
//
|
|
549
|
-
// private Observable<PagSeguroPaxActionResult> doPayment(final PlugPagPaymentData paymentData) {
|
|
550
|
-
// mPlugPagPaymentData = paymentData;
|
|
551
|
-
// return Observable.create(emitter -> {
|
|
552
|
-
//// plugpag.setPlugPagCustomPrinterLayout(getCustomPrinterDialog());
|
|
553
|
-
// PagSeguroPaxActionResult result = new PagSeguroPaxActionResult();
|
|
554
|
-
// setListener(emitter, result);
|
|
555
|
-
//// setPrintListener(emitter, result);
|
|
556
|
-
// PlugPagTransactionResult plugPagTransactionResult = plugpag.doPayment(paymentData);
|
|
557
|
-
// sendResponse(emitter, plugPagTransactionResult, result);
|
|
558
|
-
// });
|
|
559
|
-
// }
|
|
560
|
-
//
|
|
561
|
-
// private void sendResponse(ObservableEmitter<PagSeguroPaxActionResult> emitter, PlugPagTransactionResult plugPagTransactionResult,
|
|
562
|
-
// PagSeguroPaxActionResult result) {
|
|
563
|
-
// if (plugPagTransactionResult.getResult() != 0) {
|
|
564
|
-
// emitter.onError(new PlugPagException(plugPagTransactionResult.getMessage(), plugPagTransactionResult.getErrorCode()));
|
|
565
|
-
// } else {
|
|
566
|
-
// result.setTransactionCode(plugPagTransactionResult.getTransactionCode());
|
|
567
|
-
// result.setTransactionId(plugPagTransactionResult.getTransactionId());
|
|
568
|
-
// emitter.onNext(result);
|
|
569
|
-
// }
|
|
570
|
-
// emitter.onComplete();
|
|
571
|
-
// }
|
|
572
|
-
//
|
|
573
|
-
//// public PlugPagCustomPrinterLayout getCustomPrinterDialog() {
|
|
574
|
-
//// PlugPagCustomPrinterLayout customDialog = new PlugPagCustomPrinterLayout();
|
|
575
|
-
//// customDialog.setTitle("Teste: Imprimir via do client?");
|
|
576
|
-
//// customDialog.setButtonBackgroundColor("#00ff33");
|
|
577
|
-
//// customDialog.setConfirmText("Yes");
|
|
578
|
-
//// customDialog.setCancelText("No");
|
|
579
|
-
//// return customDialog;
|
|
580
|
-
//// }
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
//class PagSeguroPaxActionResult {
|
|
584
|
-
//
|
|
585
|
-
// String transactionCode;
|
|
586
|
-
//
|
|
587
|
-
// String transactionId;
|
|
588
|
-
//
|
|
589
|
-
// String message;
|
|
590
|
-
//
|
|
591
|
-
// int eventCode;
|
|
592
|
-
//
|
|
593
|
-
// String errorCode;
|
|
594
|
-
//
|
|
595
|
-
// int result = 0;
|
|
596
|
-
//
|
|
597
|
-
// public String getTransactionCode() {
|
|
598
|
-
// return transactionCode;
|
|
599
|
-
// }
|
|
600
|
-
//
|
|
601
|
-
// public void setTransactionCode(String transactionCode) {
|
|
602
|
-
// this.transactionCode = transactionCode;
|
|
603
|
-
// }
|
|
604
|
-
//
|
|
605
|
-
// public String getTransactionId() {
|
|
606
|
-
// return transactionId;
|
|
607
|
-
// }
|
|
608
|
-
//
|
|
609
|
-
// public void setTransactionId(String transactionId) {
|
|
610
|
-
// this.transactionId = transactionId;
|
|
611
|
-
// }
|
|
612
|
-
//
|
|
613
|
-
// public String getMessage() {
|
|
614
|
-
// return message;
|
|
615
|
-
// }
|
|
616
|
-
//
|
|
617
|
-
// public void setMessage(String message) {
|
|
618
|
-
// this.message = message;
|
|
619
|
-
// }
|
|
620
|
-
//
|
|
621
|
-
// public int getEventCode() {
|
|
622
|
-
// return eventCode;
|
|
623
|
-
// }
|
|
624
|
-
//
|
|
625
|
-
// public void setEventCode(int eventCode) {
|
|
626
|
-
// this.eventCode = eventCode;
|
|
627
|
-
// }
|
|
628
|
-
//
|
|
629
|
-
// public String getErrorCode() {
|
|
630
|
-
// return errorCode;
|
|
631
|
-
// }
|
|
632
|
-
//
|
|
633
|
-
// public void setErrorCode(String errorCode) {
|
|
634
|
-
// this.errorCode = errorCode;
|
|
635
|
-
// }
|
|
636
|
-
//
|
|
637
|
-
// public int getResult() {
|
|
638
|
-
// return result;
|
|
639
|
-
// }
|
|
640
|
-
//
|
|
641
|
-
// public void setResult(int result) {
|
|
642
|
-
// this.result = result;
|
|
643
|
-
// }
|
|
644
|
-
//}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
var exec = require('cordova/exec');
|
|
2
|
-
|
|
3
|
-
exports.InitializeSdk = function (params, success, error) {
|
|
4
|
-
exec(success, error, 'NetControllCordovaPluginsIntegration', 'PagSeguro.PagSeguroPax.InitializeSdk', [params]);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
exports.IniciarTransacao = function (params, success, error) {
|
|
8
|
-
exec(success, error, 'NetControllCordovaPluginsIntegration', 'PagSeguro.PagSeguroPax.IniciarTransacao', [params]);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
exports.AbortarTransacao = function (params, success, error) {
|
|
12
|
-
exec(success, error, 'NetControllCordovaPluginsIntegration', 'Stone.PagSeguroPax.AbortarTransacao', [params]);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
exports.CancelarTransacao = function (params, success, error) {
|
|
16
|
-
exec(success, error, 'NetControllCordovaPluginsIntegration', 'PagSeguro.PagSeguroPax.CancelarTransacao', [params]);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
exports.ImpressaoTextoNetPrintImg = function (params, success, error) {
|
|
20
|
-
exec(success, error, 'NetControllCordovaPluginsIntegration', 'PagSeguro.PagSeguroPax.ImpressaoTextoNetPrintImg', [params]);
|
|
21
|
-
}
|
package/www/alice.js
DELETED