react-native-bootpay-api 4.0.0-beta.2 → 4.0.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-bootpay-api",
3
- "version": "4.0.0-beta.2",
3
+ "version": "4.0.0",
4
4
  "description": "React Native를 위한 bootpay 라이브러리 입니다.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -42,6 +42,17 @@ export class BootpayWebView extends Component {
42
42
  )
43
43
  UserInfo.setBootpayLastTime(Date.now());
44
44
  }
45
+
46
+ // componentDidMount() {
47
+ // // if(this.webView == null || this.webView == undefined || this.webView == false) return;
48
+
49
+ // console.log('componentDidMount: ' + this.close());
50
+
51
+ // this.webView.injectJavaScript(`
52
+ // javascript:(function(){${this.close()} })()
53
+ // `);
54
+
55
+ // }
45
56
 
46
57
  render() {
47
58
  return <Modal
@@ -76,15 +87,14 @@ export class BootpayWebView extends Component {
76
87
  </TouchableOpacity>
77
88
  }
78
89
  <WebView
79
- ref={(wv) => this.webView = wv}
80
- // ref={btWebView}
90
+ ref={(wv) => this.webView = wv}
81
91
  useWebKit={true}
82
92
  originWhitelist={['*']}
83
93
  source={{
84
94
  uri: 'https://webview.bootpay.co.kr/4.0.0/'
85
95
  }}
86
96
  onRequestClose={()=> {
87
- console.log('onRequestClose');
97
+ // console.log('onRequestClose');
88
98
  this.dismiss();
89
99
  }}
90
100
  injectedJavaScript={this.state.script}
@@ -114,7 +124,7 @@ export class BootpayWebView extends Component {
114
124
  bootpayRequest = async (payload, items, user, extra, requestMethod) => {
115
125
  payload.application_id = Platform.OS == 'ios' ? this.props.ios_application_id : this.props.android_application_id;
116
126
  payload.items = items;
117
- payload.user_info = user;
127
+ payload.user = user;
118
128
  payload.extra = extra;
119
129
 
120
130
 
@@ -142,13 +152,14 @@ export class BootpayWebView extends Component {
142
152
  visibility: false
143
153
  })
144
154
  )
145
- this.removePaymentWindow();
155
+ // this.removePaymentWindow();
146
156
  }
147
157
 
148
158
 
149
159
  getMountJavascript = async () => {
150
160
  return `
151
161
  ${this.getBootpayPlatform()}
162
+ ${this.close()}
152
163
  ${await this.getAnalyticsData()}
153
164
  `;
154
165
  }
@@ -164,13 +175,18 @@ export class BootpayWebView extends Component {
164
175
  "}, function (res) {" +
165
176
  this.error() +
166
177
  this.cancel() +
167
- "})";
178
+ "}); void(0);";
179
+
180
+ return script;
168
181
 
169
- this.callJavaScript(script);
182
+ // return this.generateScript;
170
183
  }
171
184
 
172
185
  onMessage = ({ nativeEvent }) => {
173
186
  if (nativeEvent == undefined || nativeEvent.data == undefined) return;
187
+
188
+
189
+ console.log(`onMessage: ${nativeEvent.data}`);
174
190
 
175
191
  if(nativeEvent.data == 'close') {
176
192
  if(this.props.onClose == undefined) return;
@@ -178,11 +194,11 @@ export class BootpayWebView extends Component {
178
194
  action: 'BootpayClose',
179
195
  message: '결제창이 닫혔습니다'
180
196
  }
181
- this.setState(
182
- {
183
- visibility: false
184
- }
185
- )
197
+ // this.setState(
198
+ // {
199
+ // visibility: false
200
+ // }
201
+ // )
186
202
  this.props.onClose(json);
187
203
  this.dismiss();
188
204
  return;
@@ -191,34 +207,22 @@ export class BootpayWebView extends Component {
191
207
  const data = JSON.parse(nativeEvent.data);
192
208
  switch (data.event) {
193
209
  case 'cancel':
194
- if(this.props.onCancel != undefined) this.props.onCancel(data);
195
- // this.setState(
196
- // {
197
- // visibility: false
198
- // }
199
- // )
210
+ if(this.props.onCancel != undefined) this.props.onCancel(data);
200
211
  break;
201
212
  case 'error':
202
- if(this.props.onError != undefined) this.props.onError(data);
203
- // this.setState(
204
- // {
205
- // visibility: false
206
- // }
207
- // )
213
+ if(this.props.onError != undefined) this.props.onError(data);
208
214
  break;
209
215
  case 'issued':
210
- if(this.props.onReady != undefined) this.props.onReady(data);
216
+ if(this.props.onReady != undefined) this.props.onIssued(data);
211
217
  break;
212
218
  case 'confirm':
213
219
  if(this.props.onConfirm != undefined) this.props.onConfirm(data);
214
220
  break;
215
221
  case 'done':
216
- if(this.props.onDone != undefined) this.props.onDone(data);
217
- // this.setState(
218
- // {
219
- // visibility: false
220
- // }
221
- // )
222
+ if(this.props.onDone != undefined) this.props.onDone(data);
223
+ break;
224
+ case 'close':
225
+ if(this.props.onClose != undefined) this.props.onClose(data);
222
226
  break;
223
227
  }
224
228
  }
@@ -259,13 +263,14 @@ export class BootpayWebView extends Component {
259
263
  }
260
264
 
261
265
  removePaymentWindow = () => {
262
- this.callJavaScript(`
263
- Bootpay.removePaymentWindow();
264
- `);
266
+ this.dismiss();
267
+ // this.callJavaScript(`
268
+ // Bootpay.removePaymentWindow();
269
+ // `);
265
270
  }
266
271
 
267
- callJavaScript = (script) => {
268
- if(this.webView == null || this.webView == undefined) return;
272
+ callJavaScript = (script) => {
273
+ if(this.webView == null || this.webView == undefined || this.webView == false) return;
269
274
 
270
275
  // console.log('callJavascript: ' + script);
271
276