omnipay-reactnative-sdk 1.0.0 → 1.0.1
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.
|
@@ -46,16 +46,16 @@ public class OmnipayActivityModule extends ReactContextBaseJavaModule {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
@Override
|
|
49
|
-
public Map<String, Object> getConstants() {
|
|
50
|
-
final Map<String, Object> constants = new HashMap
|
|
49
|
+
public Map < String, Object > getConstants() {
|
|
50
|
+
final Map < String, Object > constants = new HashMap < > ();
|
|
51
51
|
constants.put("ERROR", ERROR);
|
|
52
52
|
constants.put("ACTIVITY_DOES_NOT_EXIST", ACTIVITY_DOES_NOT_EXIST);
|
|
53
53
|
return constants;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
private void sendEvent(ReactContext reactContext,
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
String eventName,
|
|
58
|
+
WritableMap params) {
|
|
59
59
|
reactContext
|
|
60
60
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
61
61
|
.emit(eventName, params);
|
|
@@ -79,18 +79,17 @@ public class OmnipayActivityModule extends ReactContextBaseJavaModule {
|
|
|
79
79
|
// Remove upstream listeners, stop unnecessary background tasks
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
|
|
84
84
|
@ReactMethod
|
|
85
85
|
public void isPackageInstalled(String packageName, Promise promise) {
|
|
86
86
|
try {
|
|
87
87
|
iPromise = promise;
|
|
88
88
|
Intent intent = this.reactContext.getPackageManager().getLaunchIntentForPackage(packageName);
|
|
89
|
-
if(intent != null) {
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
iPromise.resolve(false);
|
|
89
|
+
if (intent != null) {
|
|
90
|
+
iPromise.resolve(true);
|
|
91
|
+
} else {
|
|
92
|
+
iPromise.resolve(false);
|
|
94
93
|
}
|
|
95
94
|
iPromise = null;
|
|
96
95
|
} catch (Exception e) {
|
|
@@ -100,33 +99,32 @@ public class OmnipayActivityModule extends ReactContextBaseJavaModule {
|
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
@ReactMethod
|
|
103
|
-
|
|
102
|
+
public void initiateHorizonTransaction(double amt, String tranType, String colour, boolean print, String rrn, String stan, Promise promise) {
|
|
104
103
|
try {
|
|
105
104
|
mPromise = promise;
|
|
106
105
|
Activity currentActivity = getCurrentActivity();
|
|
107
|
-
|
|
106
|
+
|
|
108
107
|
String purchase = "{" +
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
"\"transType\": \"" + tranType + "\",\n" +
|
|
109
|
+
"\"amount\": \"" + amt + "\",\n" +
|
|
110
|
+
"\"colour\": \"" + "234567" + "\",\n" +
|
|
111
|
+
"\"TID\": \"" + "2ANLIIQ3" + "\",\n" +
|
|
112
|
+
"\"rrn\": \"" + rrn + "\",\n" +
|
|
113
|
+
"\"stan\": \"" + stan + "\",\n" +
|
|
114
|
+
"\"print\": \"" + print + "\"\n" +
|
|
115
|
+
"}";
|
|
117
116
|
|
|
118
117
|
Intent fmIntent = this.reactContext.getPackageManager().getLaunchIntentForPackage("com.horizonpay.sample");
|
|
119
118
|
fmIntent.setFlags(0);
|
|
120
119
|
|
|
121
120
|
fmIntent.putExtra("requestData", purchase);
|
|
122
|
-
|
|
123
|
-
if(tranType == "PURCHASE") {
|
|
121
|
+
|
|
122
|
+
if (tranType == "PURCHASE") {
|
|
124
123
|
currentActivity.startActivityForResult(fmIntent, RC_PURCHASE);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
124
|
+
} else {
|
|
127
125
|
currentActivity.startActivityForResult(fmIntent, RC_KEY_EXCHANGE);
|
|
128
126
|
}
|
|
129
|
-
|
|
127
|
+
|
|
130
128
|
} catch (Exception ex) {
|
|
131
129
|
ex.printStackTrace();
|
|
132
130
|
}
|
|
@@ -137,32 +135,37 @@ public class OmnipayActivityModule extends ReactContextBaseJavaModule {
|
|
|
137
135
|
private final ActivityEventListener mActivityEventListener = new BaseActivityEventListener() {
|
|
138
136
|
@Override
|
|
139
137
|
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
138
|
+
try {
|
|
139
|
+
if (data != null) {
|
|
140
|
+
String statusMessage = data.getStringExtra("statusMessage");
|
|
141
|
+
String status = data.getStringExtra("status");
|
|
142
|
+
String datax = data.getStringExtra("data");
|
|
143
|
+
String result = "-status-" + status + "-data-" + datax + "-message-" + statusMessage;
|
|
144
|
+
|
|
145
|
+
try {
|
|
146
|
+
WritableMap params = Arguments.createMap();
|
|
147
|
+
params.putString("data", datax);
|
|
148
|
+
sendEvent(reactContext, "OmnipayEvent", params);
|
|
149
|
+
} catch (Exception ex) {
|
|
150
|
+
ex.printStackTrace();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// String returnValue = data.getStringExtra(returnKey);
|
|
154
|
+
if (mPromise != null) {
|
|
155
|
+
mPromise.resolve(result);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
mPromise = null;
|
|
159
|
+
} else {
|
|
160
|
+
if(mPromise != null) {
|
|
161
|
+
mPromise.resolve("no data");
|
|
162
|
+
}
|
|
163
|
+
mPromise = null;
|
|
150
164
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// String returnValue = data.getStringExtra(returnKey);
|
|
156
|
-
if(mPromise != null) {
|
|
157
|
-
mPromise.resolve(result);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
mPromise = null;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
mPromise.resolve("no data");
|
|
164
|
-
mPromise = null;
|
|
165
|
+
} catch (Exception ex) {
|
|
166
|
+
ex.printStackTrace();
|
|
165
167
|
}
|
|
168
|
+
|
|
166
169
|
}
|
|
167
170
|
};
|
|
168
171
|
}
|