react-native-bootpay-api 4.0.9 → 4.1.0
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/package.json +1 -1
- package/src/BootpayWebView.js +91 -40
package/package.json
CHANGED
package/src/BootpayWebView.js
CHANGED
|
@@ -10,7 +10,7 @@ export class BootpayWebView extends Component {
|
|
|
10
10
|
|
|
11
11
|
webView = useRef<WebView>(null);
|
|
12
12
|
|
|
13
|
-
_VERSION = "4.0
|
|
13
|
+
_VERSION = "4.1.0";
|
|
14
14
|
_DEBUG = false;
|
|
15
15
|
_payload = {};
|
|
16
16
|
|
|
@@ -193,7 +193,7 @@ export class BootpayWebView extends Component {
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
onMessage = ({ nativeEvent }) => {
|
|
196
|
-
|
|
196
|
+
console.log(`onMessage: ${nativeEvent}, ${JSON.stringify(nativeEvent)}`);
|
|
197
197
|
|
|
198
198
|
if (nativeEvent == undefined) return;
|
|
199
199
|
|
|
@@ -214,48 +214,99 @@ export class BootpayWebView extends Component {
|
|
|
214
214
|
|
|
215
215
|
const data = JSON.parse(res.data);
|
|
216
216
|
// console.log(`redirect: ${JSON.stringify(data)}`);
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if(this.props.onDone != undefined) this.props.onDone(data);
|
|
233
|
-
break;
|
|
234
|
-
case 'close':
|
|
235
|
-
if(this.props.onClose != undefined) this.props.onClose(data);
|
|
236
|
-
this.dismiss();
|
|
237
|
-
break;
|
|
217
|
+
|
|
218
|
+
redirect = false;
|
|
219
|
+
show_success = false;
|
|
220
|
+
show_error = false;
|
|
221
|
+
if(this._payload != undefined && this._payload.extra != undefined) {
|
|
222
|
+
if(this._payload.extra.open_type == 'redirect') {
|
|
223
|
+
redirect = true;
|
|
224
|
+
}
|
|
225
|
+
if(this._payload.extra.display_error_result == true) {
|
|
226
|
+
show_error = true;
|
|
227
|
+
}
|
|
228
|
+
if(this._payload.extra.display_success_result == 'redirect') {
|
|
229
|
+
show_success = true;
|
|
230
|
+
}
|
|
231
|
+
|
|
238
232
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
233
|
|
|
242
|
-
if(
|
|
234
|
+
if(redirect == true) {
|
|
235
|
+
switch (data.event) {
|
|
236
|
+
case 'cancel':
|
|
237
|
+
if(this.props.onCancel != undefined) this.props.onCancel(data);
|
|
238
|
+
if(this.props.onClose != undefined) this.props.onClose(data);
|
|
239
|
+
this.dismiss();
|
|
240
|
+
break;
|
|
241
|
+
case 'error':
|
|
242
|
+
if(this.props.onError != undefined) this.props.onError(data);
|
|
243
|
+
if(show_error == false) {
|
|
244
|
+
if(this.props.onClose != undefined) this.props.onClose(data);
|
|
245
|
+
this.dismiss();
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
case 'issued':
|
|
249
|
+
if(this.props.onIssued != undefined) this.props.onIssued(data.data);
|
|
250
|
+
if(show_success == false) {
|
|
251
|
+
if(this.props.onClose != undefined) this.props.onClose(data.data);
|
|
252
|
+
this.dismiss();
|
|
253
|
+
}
|
|
254
|
+
break;
|
|
255
|
+
case 'confirm':
|
|
256
|
+
if(this.props.onConfirm != undefined) this.props.onConfirm(data);
|
|
257
|
+
break;
|
|
258
|
+
case 'done':
|
|
259
|
+
if(this.props.onDone != undefined) this.props.onDone(data.data);
|
|
260
|
+
if(show_success == false) {
|
|
261
|
+
if(this.props.onClose != undefined) this.props.onClose(data.data);
|
|
262
|
+
this.dismiss();
|
|
263
|
+
}
|
|
264
|
+
break;
|
|
265
|
+
case 'close':
|
|
266
|
+
if(this.props.onClose != undefined) this.props.onClose(data);
|
|
267
|
+
this.dismiss();
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
} else {
|
|
271
|
+
switch (data.event) {
|
|
272
|
+
case 'cancel':
|
|
273
|
+
if(this.props.onCancel != undefined) this.props.onCancel(data);
|
|
274
|
+
break;
|
|
275
|
+
case 'error':
|
|
276
|
+
if(this.props.onError != undefined) this.props.onError(data);
|
|
277
|
+
break;
|
|
278
|
+
case 'issued':
|
|
279
|
+
if(this.props.onIssued != undefined) this.props.onIssued(data);
|
|
280
|
+
break;
|
|
281
|
+
case 'confirm':
|
|
282
|
+
if(this.props.onConfirm != undefined) this.props.onConfirm(data);
|
|
283
|
+
break;
|
|
284
|
+
case 'done':
|
|
285
|
+
if(this.props.onDone != undefined) this.props.onDone(data);
|
|
286
|
+
break;
|
|
287
|
+
case 'close':
|
|
288
|
+
if(this.props.onClose != undefined) this.props.onClose(data);
|
|
289
|
+
this.dismiss();
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// if(this._payload != undefined && this._payload.extra != undefined && this._payload.extra.open_type == 'redirect') {
|
|
243
294
|
|
|
244
295
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
296
|
+
// if(data.event == 'done' && this._payload.extra.display_success_result != true) {
|
|
297
|
+
// if(this.props.onClose != undefined) this.props.onClose(data);
|
|
298
|
+
// this.dismiss();
|
|
299
|
+
// } else if(data.event == 'error' && this._payload.extra.display_error_result != true ) {
|
|
300
|
+
// if(this.props.onClose != undefined) this.props.onClose(data);
|
|
301
|
+
// this.dismiss();
|
|
302
|
+
// } else if(data.event == 'issued' && this._payload.extra.display_success_result != true ) {
|
|
303
|
+
// if(this.props.onClose != undefined) this.props.onClose(data);
|
|
304
|
+
// this.dismiss();
|
|
305
|
+
// } else if(data.event == 'cancel') {
|
|
306
|
+
// if(this.props.onClose != undefined) this.props.onClose(data);
|
|
307
|
+
// this.dismiss();
|
|
308
|
+
// }
|
|
309
|
+
// }
|
|
259
310
|
}
|
|
260
311
|
|
|
261
312
|
onShouldStartLoadWithRequest = (url) => {
|