react-native-bootpay-api 4.0.9 → 4.1.2
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 +3 -2
- package/src/BootpayWebView.js +116 -66
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-bootpay-api",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"description": "React Native를 위한 bootpay 라이브러리 입니다.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -91,7 +91,8 @@
|
|
|
91
91
|
"react-native-device-info": "^8.7.0",
|
|
92
92
|
"react-native-sensitive-info": "^5.5.8",
|
|
93
93
|
"react-native-base64": "^0.2.1",
|
|
94
|
-
"react-native-aes-crypto": "^2.1.0"
|
|
94
|
+
"react-native-aes-crypto": "^2.1.0",
|
|
95
|
+
"lodash": "^4.17.21"
|
|
95
96
|
},
|
|
96
97
|
"peerDependencies": {
|
|
97
98
|
"react": "*",
|
package/src/BootpayWebView.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import React, { Component, useRef, useEffect } from 'react';
|
|
4
4
|
import { SafeAreaView, Modal, Platform, TouchableOpacity, Image, StyleSheet, BackHandler} from 'react-native';
|
|
5
5
|
import WebView from 'react-native-webview-bootpay';
|
|
6
|
+
import {debounce} from 'lodash';
|
|
6
7
|
import UserInfo from './UserInfo'
|
|
7
8
|
|
|
8
9
|
export class BootpayWebView extends Component {
|
|
@@ -10,7 +11,7 @@ export class BootpayWebView extends Component {
|
|
|
10
11
|
|
|
11
12
|
webView = useRef<WebView>(null);
|
|
12
13
|
|
|
13
|
-
_VERSION = "4.
|
|
14
|
+
_VERSION = "4.1.2";
|
|
14
15
|
_DEBUG = false;
|
|
15
16
|
_payload = {};
|
|
16
17
|
|
|
@@ -31,12 +32,20 @@ export class BootpayWebView extends Component {
|
|
|
31
32
|
)
|
|
32
33
|
UserInfo.setBootpayLastTime(Date.now());
|
|
33
34
|
}
|
|
35
|
+
|
|
36
|
+
componentDidMount() {
|
|
37
|
+
this.closeDismiss = debounce(this.closeDismiss, 30);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
34
41
|
render() {
|
|
35
42
|
return <Modal
|
|
36
43
|
animationType={'slide'}
|
|
37
44
|
transparent={false}
|
|
38
45
|
onRequestClose={()=> {
|
|
39
|
-
this.
|
|
46
|
+
this.closeDismiss();
|
|
47
|
+
// console.log(1234);
|
|
48
|
+
// this.dismiss();
|
|
40
49
|
}}
|
|
41
50
|
visible={this.state.visibility}>
|
|
42
51
|
<SafeAreaView style={{ flex: 1 }}>
|
|
@@ -54,7 +63,7 @@ export class BootpayWebView extends Component {
|
|
|
54
63
|
}
|
|
55
64
|
|
|
56
65
|
if(this.props.onCancel != undefined) this.props.onCancel(cancelData);
|
|
57
|
-
if(this.props.onClose != undefined) this.props.onClose(
|
|
66
|
+
if(this.props.onClose != undefined) this.props.onClose();
|
|
58
67
|
|
|
59
68
|
this.setState({visibility: false})
|
|
60
69
|
} }>
|
|
@@ -69,11 +78,7 @@ export class BootpayWebView extends Component {
|
|
|
69
78
|
originWhitelist={['*']}
|
|
70
79
|
source={{
|
|
71
80
|
uri: 'https://webview.bootpay.co.kr/4.0.6/'
|
|
72
|
-
}}
|
|
73
|
-
onRequestClose={()=> {
|
|
74
|
-
// console.log('onRequestClose');
|
|
75
|
-
this.dismiss();
|
|
76
|
-
}}
|
|
81
|
+
}}
|
|
77
82
|
injectedJavaScript={this.state.script}
|
|
78
83
|
javaScriptEnabled={true}
|
|
79
84
|
javaScriptCanOpenWindowsAutomatically={true}
|
|
@@ -152,6 +157,16 @@ export class BootpayWebView extends Component {
|
|
|
152
157
|
UserInfo.updateInfo();
|
|
153
158
|
}
|
|
154
159
|
|
|
160
|
+
// debounceClose = () => {
|
|
161
|
+
// // deboun
|
|
162
|
+
// console.log('debounceClose');
|
|
163
|
+
// _.debounce(this.closeDismiss, 30);
|
|
164
|
+
// }
|
|
165
|
+
|
|
166
|
+
closeDismiss = () => {
|
|
167
|
+
if(this.props.onClose != undefined) this.props.onClose();
|
|
168
|
+
this.dismiss();
|
|
169
|
+
}
|
|
155
170
|
|
|
156
171
|
|
|
157
172
|
dismiss = () => {
|
|
@@ -193,7 +208,7 @@ export class BootpayWebView extends Component {
|
|
|
193
208
|
}
|
|
194
209
|
|
|
195
210
|
onMessage = ({ nativeEvent }) => {
|
|
196
|
-
|
|
211
|
+
console.log(`onMessage: ${nativeEvent}, ${JSON.stringify(nativeEvent)}`);
|
|
197
212
|
|
|
198
213
|
if (nativeEvent == undefined) return;
|
|
199
214
|
|
|
@@ -201,61 +216,90 @@ export class BootpayWebView extends Component {
|
|
|
201
216
|
|
|
202
217
|
|
|
203
218
|
if(res.data == 'close') {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
this.
|
|
219
|
+
this.closeDismiss();
|
|
220
|
+
// if(this.props.onClose == undefined) return;
|
|
221
|
+
// var json = {
|
|
222
|
+
// action: 'BootpayClose',
|
|
223
|
+
// message: '결제창이 닫혔습니다'
|
|
224
|
+
// }
|
|
225
|
+
// this.props.onClose();
|
|
226
|
+
// this.dismiss();
|
|
211
227
|
return;
|
|
212
228
|
}
|
|
213
229
|
|
|
214
230
|
|
|
215
231
|
const data = JSON.parse(res.data);
|
|
216
232
|
// console.log(`redirect: ${JSON.stringify(data)}`);
|
|
217
|
-
|
|
218
|
-
switch (data.event) {
|
|
219
|
-
case 'cancel':
|
|
220
|
-
if(this.props.onCancel != undefined) this.props.onCancel(data);
|
|
221
|
-
break;
|
|
222
|
-
case 'error':
|
|
223
|
-
if(this.props.onError != undefined) this.props.onError(data);
|
|
224
|
-
break;
|
|
225
|
-
case 'issued':
|
|
226
|
-
if(this.props.onIssued != undefined) this.props.onIssued(data);
|
|
227
|
-
break;
|
|
228
|
-
case 'confirm':
|
|
229
|
-
if(this.props.onConfirm != undefined) this.props.onConfirm(data);
|
|
230
|
-
break;
|
|
231
|
-
case 'done':
|
|
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;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
233
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
} else if(data.event == 'error' && this._payload.extra.display_error_result != true ) {
|
|
249
|
-
if(this.props.onClose != undefined) this.props.onClose(data);
|
|
250
|
-
this.dismiss();
|
|
251
|
-
} else if(data.event == 'issued' && this._payload.extra.display_success_result != true ) {
|
|
252
|
-
if(this.props.onClose != undefined) this.props.onClose(data);
|
|
253
|
-
this.dismiss();
|
|
254
|
-
} else if(data.event == 'cancel') {
|
|
255
|
-
if(this.props.onClose != undefined) this.props.onClose(data);
|
|
256
|
-
this.dismiss();
|
|
234
|
+
redirect = false;
|
|
235
|
+
show_success = false;
|
|
236
|
+
show_error = false;
|
|
237
|
+
if(this._payload != undefined && this._payload.extra != undefined) {
|
|
238
|
+
if(this._payload.extra.open_type == 'redirect') {
|
|
239
|
+
redirect = true;
|
|
257
240
|
}
|
|
241
|
+
if(this._payload.extra.display_error_result == true) {
|
|
242
|
+
show_error = true;
|
|
243
|
+
}
|
|
244
|
+
if(this._payload.extra.display_success_result == 'redirect') {
|
|
245
|
+
show_success = true;
|
|
246
|
+
}
|
|
247
|
+
|
|
258
248
|
}
|
|
249
|
+
|
|
250
|
+
if(redirect == true) {
|
|
251
|
+
switch (data.event) {
|
|
252
|
+
case 'cancel':
|
|
253
|
+
if(this.props.onCancel != undefined) this.props.onCancel(data);
|
|
254
|
+
this.closeDismiss();
|
|
255
|
+
break;
|
|
256
|
+
case 'error':
|
|
257
|
+
if(this.props.onError != undefined) this.props.onError(data);
|
|
258
|
+
if(show_error == false) {
|
|
259
|
+
this.closeDismiss();
|
|
260
|
+
}
|
|
261
|
+
break;
|
|
262
|
+
case 'issued':
|
|
263
|
+
if(this.props.onIssued != undefined) this.props.onIssued(data);
|
|
264
|
+
if(show_success == false) {
|
|
265
|
+
this.closeDismiss();
|
|
266
|
+
}
|
|
267
|
+
break;
|
|
268
|
+
case 'confirm':
|
|
269
|
+
if(this.props.onConfirm != undefined) this.props.onConfirm(data);
|
|
270
|
+
break;
|
|
271
|
+
case 'done':
|
|
272
|
+
if(this.props.onDone != undefined) this.props.onDone(data);
|
|
273
|
+
if(show_success == false) {
|
|
274
|
+
this.closeDismiss();
|
|
275
|
+
}
|
|
276
|
+
break;
|
|
277
|
+
case 'close':
|
|
278
|
+
this.closeDismiss();
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
} else {
|
|
282
|
+
switch (data.event) {
|
|
283
|
+
case 'cancel':
|
|
284
|
+
if(this.props.onCancel != undefined) this.props.onCancel(data);
|
|
285
|
+
break;
|
|
286
|
+
case 'error':
|
|
287
|
+
if(this.props.onError != undefined) this.props.onError(data);
|
|
288
|
+
break;
|
|
289
|
+
case 'issued':
|
|
290
|
+
if(this.props.onIssued != undefined) this.props.onIssued(data);
|
|
291
|
+
break;
|
|
292
|
+
case 'confirm':
|
|
293
|
+
if(this.props.onConfirm != undefined) this.props.onConfirm(data);
|
|
294
|
+
break;
|
|
295
|
+
case 'done':
|
|
296
|
+
if(this.props.onDone != undefined) this.props.onDone(data);
|
|
297
|
+
break;
|
|
298
|
+
case 'close':
|
|
299
|
+
this.closeDismiss();
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
259
303
|
}
|
|
260
304
|
|
|
261
305
|
onShouldStartLoadWithRequest = (url) => {
|
|
@@ -298,16 +342,16 @@ export class BootpayWebView extends Component {
|
|
|
298
342
|
// }
|
|
299
343
|
|
|
300
344
|
transactionConfirm = () => {
|
|
301
|
-
const script = "Bootpay.confirm()
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
345
|
+
const script = "Bootpay.confirm()"
|
|
346
|
+
+
|
|
347
|
+
".then( function (res) {" +
|
|
348
|
+
this.confirm() +
|
|
349
|
+
this.issued() +
|
|
350
|
+
this.done() +
|
|
351
|
+
"}, function (res) {" +
|
|
352
|
+
this.error() +
|
|
353
|
+
this.cancel() +
|
|
354
|
+
"})";
|
|
311
355
|
|
|
312
356
|
this.callJavaScript(script);
|
|
313
357
|
}
|
|
@@ -325,8 +369,14 @@ export class BootpayWebView extends Component {
|
|
|
325
369
|
// console.log('callJavascript: ' + script);
|
|
326
370
|
|
|
327
371
|
this.webView.injectJavaScript(`
|
|
328
|
-
|
|
372
|
+
setTimeout(function() { ${script} }, 30);
|
|
329
373
|
`);
|
|
374
|
+
|
|
375
|
+
// this.webView.injectJavaScript(`
|
|
376
|
+
// javascript:(function(){${script} })()
|
|
377
|
+
// `);
|
|
378
|
+
|
|
379
|
+
|
|
330
380
|
// this.webView.evalu
|
|
331
381
|
}
|
|
332
382
|
|