cordova-plugin-netcontroll-integration-getnet 1.0.111 → 1.0.112
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
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-getnet" version="1.0.
|
|
2
|
+
<plugin id="cordova-plugin-netcontroll-integration-getnet" version="1.0.112"
|
|
3
3
|
xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
4
4
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
5
5
|
|
|
@@ -13,6 +13,11 @@
|
|
|
13
13
|
<clobbers target="cordova.plugins.NetControllCordovaPluginsIntegrationGetNet.GetNetSumni" />
|
|
14
14
|
</js-module>
|
|
15
15
|
|
|
16
|
+
|
|
17
|
+
<js-module name="UtilsImageStore" src="www/Utils/UtilsImageStore.js">
|
|
18
|
+
<clobbers target="cordova.plugins.NetControllCordovaPluginsIntegrationGetNet.UtilsImageStore" />
|
|
19
|
+
</js-module>
|
|
20
|
+
|
|
16
21
|
<dependency id="cordova-plugin-netcontroll-integration-util" />
|
|
17
22
|
|
|
18
23
|
<dependency id="cordova-plugin-androidx-adapter" version="1.1.3" />
|
|
@@ -27,12 +32,16 @@
|
|
|
27
32
|
</config-file>
|
|
28
33
|
|
|
29
34
|
<config-file parent="/*" target="AndroidManifest.xml">
|
|
30
|
-
<uses-permission android:name="com.getnet.
|
|
35
|
+
<uses-permission android:name="br.com.getnet.getstore.provider.READ_DICTIONARY"/>
|
|
31
36
|
<uses-permission android:name="android.permission.ACCESS_WEBVIEW"/>
|
|
37
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
38
|
+
<uses-permission android:name="com.getnet.posdigital.service.POSDIGITAL" />
|
|
32
39
|
</config-file>
|
|
33
40
|
|
|
34
41
|
<!-- executable source code > -->
|
|
35
42
|
<source-file src="src/android/NetControllCordovaPluginsIntegrationGetNet.java" target-dir="src/cordova-plugin-netcontroll-integration-getnet" />
|
|
43
|
+
|
|
44
|
+
<!-- <source-file src="src/android/Utils/UtilsImageStore.java" target-dir="src/cordova-plugin-netcontroll-integration/Utils" /> --> -->
|
|
36
45
|
<!-- <source-file src="src/android/Utils/NetControllHelpers.java" target-dir="src/cordova-plugin-netcontroll-integration-getnet/Utils" /> -->
|
|
37
46
|
<!-- <source-file src="src/android/Utils/NetControllPrinter.java" target-dir="src/cordova-plugin-netcontroll-integration-getnet/Utils" /> -->
|
|
38
47
|
|
|
@@ -24,6 +24,7 @@ import com.google.gson.Gson;
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
// import androidx.annotation.NonNull;
|
|
27
|
+
import android.annotation.SuppressLint;
|
|
27
28
|
import android.app.Activity;
|
|
28
29
|
import android.content.Context;
|
|
29
30
|
import android.content.Intent;
|
|
@@ -32,6 +33,14 @@ import android.net.Uri;
|
|
|
32
33
|
import android.os.Bundle;
|
|
33
34
|
import android.os.RemoteException;
|
|
34
35
|
|
|
36
|
+
import java.io.BufferedReader;
|
|
37
|
+
import java.io.ByteArrayOutputStream;
|
|
38
|
+
import java.io.InputStream;
|
|
39
|
+
import java.io.InputStreamReader;
|
|
40
|
+
import java.net.HttpURLConnection;
|
|
41
|
+
import java.net.URL;
|
|
42
|
+
import java.util.Base64;
|
|
43
|
+
|
|
35
44
|
//Json Serialize
|
|
36
45
|
|
|
37
46
|
|
|
@@ -98,6 +107,7 @@ public class GetNetSumni {
|
|
|
98
107
|
mCordova = cordova;
|
|
99
108
|
}
|
|
100
109
|
|
|
110
|
+
@SuppressLint("NewApi")
|
|
101
111
|
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException, RemoteException {
|
|
102
112
|
cordova.plugin.netcontroll.integration.util.NetControllHelpers netcontrollHelper = new cordova.plugin.netcontroll.integration.util.NetControllHelpers();
|
|
103
113
|
String callbackContextMessageBase = "Result GetNet Sumni P2 - " + action + ": ";
|
|
@@ -129,6 +139,82 @@ public class GetNetSumni {
|
|
|
129
139
|
callbackContext.error(callbackContextMessageBase + "Error Detail: " + error);
|
|
130
140
|
}
|
|
131
141
|
return false;
|
|
142
|
+
} else if (action.equals("TestarHttp")) {
|
|
143
|
+
JSONObject params = args.getJSONObject(0);
|
|
144
|
+
try {
|
|
145
|
+
String httpMethod = params.getString("httpMethod");
|
|
146
|
+
String httpUrl = params.getString("httpUrl");
|
|
147
|
+
String httpBody = params.getString("httpBody");
|
|
148
|
+
String resultCallBackJs = params.getString("resultCallBackJs");
|
|
149
|
+
|
|
150
|
+
String url = httpUrl; // "http://192.168.0.48:802/?Function=habilitaTerminal&format=JSON&callback=retornachamaHabilitaTerminal&callBackEX=callBackEX&user=NETWEB&key=netweb@xmenu&GuidTerminal=fcdd0cb6-1781-4cc8-900f-818ec38692cd&VersaoPDV=1.3.39.0&terminal=2&codigo=1&senha=1&POSPlugin=0&POSImpressora=0&WidgetIfood=0&&T=%275282024100631%27";
|
|
151
|
+
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
|
152
|
+
connection.setRequestMethod(httpMethod);
|
|
153
|
+
connection.setRequestProperty("Accept", "application/json");
|
|
154
|
+
|
|
155
|
+
if (connection.getResponseCode() == 200) {
|
|
156
|
+
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
|
157
|
+
StringBuilder response = new StringBuilder();
|
|
158
|
+
String line;
|
|
159
|
+
while ((line = reader.readLine()) != null) {
|
|
160
|
+
response.append(line);
|
|
161
|
+
}
|
|
162
|
+
reader.close();
|
|
163
|
+
|
|
164
|
+
String result = response.toString();
|
|
165
|
+
// System.out.println("Resultado da URL em formato de string: " + result);
|
|
166
|
+
executeGlobalJavascript(resultCallBackJs + "('" + result + "')");
|
|
167
|
+
callbackContext.success("Resultado da URL em formato de string: " + result);
|
|
168
|
+
} else {
|
|
169
|
+
callbackContext.error("Erro ao obter dados da URL. Código de resposta: " + connection.getResponseCode());
|
|
170
|
+
// System.err.println("Erro ao obter dados da URL. Código de resposta: " + connection.getResponseCode());
|
|
171
|
+
}
|
|
172
|
+
connection.disconnect();
|
|
173
|
+
return true;
|
|
174
|
+
} catch (Exception error) {
|
|
175
|
+
callbackContext.error(callbackContextMessageBase + "Error Detail: " + error);
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
} else if (action.equals("TestarHttpImg")) {
|
|
179
|
+
JSONObject params = args.getJSONObject(0);
|
|
180
|
+
try {
|
|
181
|
+
String imageUrl = "https://adm.netcontroll.com.br/images/users/profile/userId-65.png";
|
|
182
|
+
URL url = new URL(imageUrl);
|
|
183
|
+
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
184
|
+
connection.setRequestMethod("GET");
|
|
185
|
+
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
|
186
|
+
InputStream inputStream = connection.getInputStream();
|
|
187
|
+
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
188
|
+
|
|
189
|
+
// Leia os bytes da imagem
|
|
190
|
+
byte[] buffer = new byte[4096];
|
|
191
|
+
int bytesRead;
|
|
192
|
+
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
|
193
|
+
outputStream.write(buffer, 0, bytesRead);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Converta os bytes em base64
|
|
197
|
+
byte[] imageBytes = outputStream.toByteArray();
|
|
198
|
+
String base64String = null;
|
|
199
|
+
// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
|
200
|
+
//
|
|
201
|
+
// }
|
|
202
|
+
base64String = Base64.getEncoder().encodeToString(imageBytes);
|
|
203
|
+
// String base64Image = Base64.getEncoder().encodeToString(imageBytes);
|
|
204
|
+
// Bitmap dadosImg = cordova.plugin.netcontroll.integration.util.NetControllPrinter.ConverterBase64ToBitmap(base64String);
|
|
205
|
+
// System.out.println("Imagem em base64: " + base64String);
|
|
206
|
+
callbackContext.success("Imagem em base64: " + base64String);
|
|
207
|
+
} else {
|
|
208
|
+
callbackContext.error("Erro ao obter a imagem. Código de resposta: " + connection.getResponseCode());
|
|
209
|
+
// System.err.println("Erro ao obter a imagem. Código de resposta: " + connection.getResponseCode());
|
|
210
|
+
}
|
|
211
|
+
// callbackContext.success("Deu Certo");
|
|
212
|
+
return true;
|
|
213
|
+
} catch (Exception error) {
|
|
214
|
+
callbackContext.error(callbackContextMessageBase + "Error Detail: " + error);
|
|
215
|
+
}
|
|
216
|
+
return false;
|
|
217
|
+
|
|
132
218
|
} else if (action.equals("IniciarTransacao")) {
|
|
133
219
|
try {
|
|
134
220
|
JSONObject params = args.getJSONObject(0);
|
|
@@ -580,6 +666,14 @@ public class GetNetSumni {
|
|
|
580
666
|
|
|
581
667
|
|
|
582
668
|
// Helpers
|
|
669
|
+
private void executeGlobalJavascript(final String jsString){
|
|
670
|
+
mActivity.runOnUiThread(new Runnable() {
|
|
671
|
+
@Override
|
|
672
|
+
public void run() {
|
|
673
|
+
webView.loadUrl("javascript:" + jsString);
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
}
|
|
583
677
|
private void connectPosDigitalService() {
|
|
584
678
|
PosDigital.register(mContext, bindCallback);
|
|
585
679
|
}
|
|
@@ -13,7 +13,10 @@ import android.content.Context;
|
|
|
13
13
|
|
|
14
14
|
public class NetControllCordovaPluginsIntegrationGetNet extends CordovaPlugin {
|
|
15
15
|
//GetNet
|
|
16
|
-
public GetNetSumni getNetSumni;
|
|
16
|
+
public cordova.plugin.netcontroll.integration.getnet.GetNetSumni getNetSumni;
|
|
17
|
+
|
|
18
|
+
//Utils
|
|
19
|
+
public cordova.plugin.netcontroll.integration.util.UtilsImageStore utilsImageStore;
|
|
17
20
|
|
|
18
21
|
//Cordova/Java Params
|
|
19
22
|
private Activity mActivity;
|
|
@@ -33,11 +36,18 @@ public class NetControllCordovaPluginsIntegrationGetNet extends CordovaPlugin {
|
|
|
33
36
|
|
|
34
37
|
private void initializeGetNetSumni() {
|
|
35
38
|
if (this.getNetSumni == null) {
|
|
36
|
-
this.getNetSumni = new GetNetSumni();
|
|
39
|
+
this.getNetSumni = new cordova.plugin.netcontroll.integration.getnet.GetNetSumni();
|
|
37
40
|
this.getNetSumni.initialize(this.cordova, this.webView);
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
43
|
|
|
44
|
+
private void initializeUtilsImageStore() {
|
|
45
|
+
if (this.utilsImageStore == null) {
|
|
46
|
+
this.utilsImageStore = new cordova.plugin.netcontroll.integration.util.UtilsImageStore();
|
|
47
|
+
this.utilsImageStore.initialize(this.cordova, this.webView);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
@Override
|
|
42
52
|
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
|
43
53
|
try {
|
|
@@ -57,6 +67,17 @@ public class NetControllCordovaPluginsIntegrationGetNet extends CordovaPlugin {
|
|
|
57
67
|
default:
|
|
58
68
|
break;
|
|
59
69
|
}
|
|
70
|
+
case "utils":
|
|
71
|
+
String utilsProduct = actionProviderList[1];
|
|
72
|
+
switch (utilsProduct.toLowerCase()) {
|
|
73
|
+
case "utilsimagestore":
|
|
74
|
+
this.initializeUtilsImageStore();
|
|
75
|
+
String utilsimagestoreAction = actionProviderList[2];
|
|
76
|
+
boolean resultUtilsImageStoreExecute = this.utilsImageStore.execute(utilsimagestoreAction, args, callbackContext);
|
|
77
|
+
return resultUtilsImageStoreExecute;
|
|
78
|
+
default:
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
60
81
|
default:
|
|
61
82
|
break;
|
|
62
83
|
}
|
package/www/GetNet/Sumni.js
CHANGED
|
@@ -4,6 +4,14 @@ exports.InitializeSdk = function (params, success, error) {
|
|
|
4
4
|
exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'GetNet.Sumni.InitializeSdk', [params]);
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
exports.TestarHttp = function (params, success, error) {
|
|
8
|
+
exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'GetNet.Sumni.TestarHttp', [params]);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports.TestarHttpImg = function (params, success, error) {
|
|
12
|
+
exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'GetNet.Sumni.TestarHttpImg', [params]);
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
|
|
8
16
|
exports.IniciarTransacao = function (params, success, error) {
|
|
9
17
|
exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'GetNet.Sumni.IniciarTransacao', [params]);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var exec = require('cordova/exec');
|
|
2
|
+
|
|
3
|
+
// exports.CancelarTransacao = function (params, success, error) {
|
|
4
|
+
// exec(success, error, 'NetControllCordovaPluginsIntegration', 'Safra.SafraPayIngenico.CancelarTransacao', [params]);
|
|
5
|
+
// }
|
|
6
|
+
|
|
7
|
+
exports.Testar = function (params, success, error) {
|
|
8
|
+
exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'Utils.UtilsImageStore.Testar', [params]);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports.Initialize = function (params, success, error) {
|
|
12
|
+
exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'Utils.UtilsImageStore.Initialize', [params]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.SaveImageFromUrl = function (params, success, error) {
|
|
16
|
+
exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'Utils.UtilsImageStore.SaveImageFromUrl', [params]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.GetAbsolutePath = function (success, error) {
|
|
20
|
+
exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'Utils.UtilsImageStore.GetAbsolutePath');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.ListStoragedImagesFromDirectory = function (params, success, error) {
|
|
24
|
+
exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'Utils.UtilsImageStore.ListStoragedImagesFromDirectory', [params]);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.LoadStoradImageByFullName = function (params, success, error) {
|
|
28
|
+
exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'Utils.UtilsImageStore.LoadStoradImageByFullName', [params]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|