react-native-bootpay-api 4.1.0 → 4.1.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-bootpay-api",
3
- "version": "4.1.0",
3
+ "version": "4.1.3",
4
4
  "description": "React Native를 위한 bootpay 라이브러리 입니다.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -87,11 +87,12 @@
87
87
  "selenium-webdriver": "4.0.0-alpha.7",
88
88
  "semantic-release": "15.13.24",
89
89
  "typescript": "^4.0.0",
90
- "react-native-webview-bootpay": "^11.18.15",
90
+ "react-native-webview-bootpay": "^11.18.16",
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": "*",
@@ -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.1.0";
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.dismiss();
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(closeData);
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 = () => {
@@ -201,13 +216,14 @@ export class BootpayWebView extends Component {
201
216
 
202
217
 
203
218
  if(res.data == 'close') {
204
- if(this.props.onClose == undefined) return;
205
- var json = {
206
- action: 'BootpayClose',
207
- message: '결제창이 닫혔습니다'
208
- }
209
- this.props.onClose(json);
210
- this.dismiss();
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
 
@@ -235,36 +251,31 @@ export class BootpayWebView extends Component {
235
251
  switch (data.event) {
236
252
  case 'cancel':
237
253
  if(this.props.onCancel != undefined) this.props.onCancel(data);
238
- if(this.props.onClose != undefined) this.props.onClose(data);
239
- this.dismiss();
254
+ this.closeDismiss();
240
255
  break;
241
256
  case 'error':
242
257
  if(this.props.onError != undefined) this.props.onError(data);
243
258
  if(show_error == false) {
244
- if(this.props.onClose != undefined) this.props.onClose(data);
245
- this.dismiss();
259
+ this.closeDismiss();
246
260
  }
247
261
  break;
248
262
  case 'issued':
249
- if(this.props.onIssued != undefined) this.props.onIssued(data.data);
263
+ if(this.props.onIssued != undefined) this.props.onIssued(data);
250
264
  if(show_success == false) {
251
- if(this.props.onClose != undefined) this.props.onClose(data.data);
252
- this.dismiss();
265
+ this.closeDismiss();
253
266
  }
254
267
  break;
255
268
  case 'confirm':
256
269
  if(this.props.onConfirm != undefined) this.props.onConfirm(data);
257
270
  break;
258
271
  case 'done':
259
- if(this.props.onDone != undefined) this.props.onDone(data.data);
272
+ if(this.props.onDone != undefined) this.props.onDone(data);
260
273
  if(show_success == false) {
261
- if(this.props.onClose != undefined) this.props.onClose(data.data);
262
- this.dismiss();
274
+ this.closeDismiss();
263
275
  }
264
276
  break;
265
277
  case 'close':
266
- if(this.props.onClose != undefined) this.props.onClose(data);
267
- this.dismiss();
278
+ this.closeDismiss();
268
279
  break;
269
280
  }
270
281
  } else {
@@ -285,28 +296,10 @@ export class BootpayWebView extends Component {
285
296
  if(this.props.onDone != undefined) this.props.onDone(data);
286
297
  break;
287
298
  case 'close':
288
- if(this.props.onClose != undefined) this.props.onClose(data);
289
- this.dismiss();
299
+ this.closeDismiss();
290
300
  break;
291
301
  }
292
- }
293
- // if(this._payload != undefined && this._payload.extra != undefined && this._payload.extra.open_type == 'redirect') {
294
-
295
-
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
- // }
302
+ }
310
303
  }
311
304
 
312
305
  onShouldStartLoadWithRequest = (url) => {
@@ -349,16 +342,16 @@ export class BootpayWebView extends Component {
349
342
  // }
350
343
 
351
344
  transactionConfirm = () => {
352
- const script = "Bootpay.confirm();"
353
- // +
354
- // ".then( function (res) {" +
355
- // this.confirm() +
356
- // this.issued() +
357
- // this.done() +
358
- // "}, function (res) {" +
359
- // this.error() +
360
- // this.cancel() +
361
- // "})";
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
+ "})";
362
355
 
363
356
  this.callJavaScript(script);
364
357
  }
@@ -376,8 +369,14 @@ export class BootpayWebView extends Component {
376
369
  // console.log('callJavascript: ' + script);
377
370
 
378
371
  this.webView.injectJavaScript(`
379
- javascript:(function(){${script} })()
372
+ setTimeout(function() { ${script} }, 30);
380
373
  `);
374
+
375
+ // this.webView.injectJavaScript(`
376
+ // javascript:(function(){${script} })()
377
+ // `);
378
+
379
+
381
380
  // this.webView.evalu
382
381
  }
383
382