react-native-bootpay-api 4.0.0-beta.0 → 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.0",
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
 
@@ -123,8 +133,7 @@ export class BootpayWebView extends Component {
123
133
  {
124
134
  visibility: true,
125
135
  script: `
126
- ${await this.getMountJavascript()}
127
- ${quickPopup}
136
+ ${await this.getMountJavascript()}
128
137
  ${this.generateScript(payload, requestMethod)}
129
138
  `,
130
139
  firstLoad: false,
@@ -143,37 +152,41 @@ export class BootpayWebView extends Component {
143
152
  visibility: false
144
153
  })
145
154
  )
146
- this.removePaymentWindow();
155
+ // this.removePaymentWindow();
147
156
  }
148
157
 
149
158
 
150
159
  getMountJavascript = async () => {
151
160
  return `
152
161
  ${this.getBootpayPlatform()}
162
+ ${this.close()}
153
163
  ${await this.getAnalyticsData()}
154
164
  `;
155
165
  }
156
166
 
157
167
 
158
- generateScript= (payload, requestMethod) => {
159
- var requestMethod = "requestPayment";
160
-
168
+ generateScript= (payload, requestMethod) => {
161
169
  const script = "Bootpay." + requestMethod +
162
170
  `(${JSON.stringify(payload)})` +
163
171
  ".then( function (res) {" +
164
- confirm() +
165
- issued() +
166
- done() +
172
+ this.confirm() +
173
+ this.issued() +
174
+ this.done() +
167
175
  "}, function (res) {" +
168
- error() +
169
- cancel() +
170
- "})";
176
+ this.error() +
177
+ this.cancel() +
178
+ "}); void(0);";
179
+
180
+ return script;
171
181
 
172
- this.callJavaScript(script);
182
+ // return this.generateScript;
173
183
  }
174
184
 
175
185
  onMessage = ({ nativeEvent }) => {
176
186
  if (nativeEvent == undefined || nativeEvent.data == undefined) return;
187
+
188
+
189
+ console.log(`onMessage: ${nativeEvent.data}`);
177
190
 
178
191
  if(nativeEvent.data == 'close') {
179
192
  if(this.props.onClose == undefined) return;
@@ -181,42 +194,35 @@ export class BootpayWebView extends Component {
181
194
  action: 'BootpayClose',
182
195
  message: '결제창이 닫혔습니다'
183
196
  }
197
+ // this.setState(
198
+ // {
199
+ // visibility: false
200
+ // }
201
+ // )
184
202
  this.props.onClose(json);
185
203
  this.dismiss();
186
204
  return;
187
205
  }
188
206
 
189
207
  const data = JSON.parse(nativeEvent.data);
190
- switch (data.action) {
191
- case 'BootpayCancel':
192
- if(this.props.onCancel != undefined) this.props.onCancel(data);
193
- this.setState(
194
- {
195
- visibility: false
196
- }
197
- )
208
+ switch (data.event) {
209
+ case 'cancel':
210
+ if(this.props.onCancel != undefined) this.props.onCancel(data);
198
211
  break;
199
- case 'BootpayError':
200
- if(this.props.onError != undefined) this.props.onError(data);
201
- this.setState(
202
- {
203
- visibility: false
204
- }
205
- )
212
+ case 'error':
213
+ if(this.props.onError != undefined) this.props.onError(data);
206
214
  break;
207
- case 'BootpayBankReady':
208
- if(this.props.onReady != undefined) this.props.onReady(data);
215
+ case 'issued':
216
+ if(this.props.onReady != undefined) this.props.onIssued(data);
209
217
  break;
210
- case 'BootpayConfirm':
218
+ case 'confirm':
211
219
  if(this.props.onConfirm != undefined) this.props.onConfirm(data);
212
220
  break;
213
- case 'BootpayDone':
214
- if(this.props.onDone != undefined) this.props.onDone(data);
215
- this.setState(
216
- {
217
- visibility: false
218
- }
219
- )
221
+ case 'done':
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);
220
226
  break;
221
227
  }
222
228
  }
@@ -245,25 +251,26 @@ export class BootpayWebView extends Component {
245
251
  transactionConfirm = () => {
246
252
  const script = "Bootpay.confirm()" +
247
253
  ".then( function (res) {" +
248
- confirm() +
249
- issued() +
250
- done() +
254
+ this.confirm() +
255
+ this.issued() +
256
+ this.done() +
251
257
  "}, function (res) {" +
252
- error() +
253
- cancel() +
258
+ this.error() +
259
+ this.cancel() +
254
260
  "})";
255
261
 
256
262
  this.callJavaScript(script);
257
263
  }
258
264
 
259
265
  removePaymentWindow = () => {
260
- this.callJavaScript(`
261
- Bootpay.removePaymentWindow();
262
- `);
266
+ this.dismiss();
267
+ // this.callJavaScript(`
268
+ // Bootpay.removePaymentWindow();
269
+ // `);
263
270
  }
264
271
 
265
- callJavaScript = (script) => {
266
- if(this.webView == null || this.webView == undefined) return;
272
+ callJavaScript = (script) => {
273
+ if(this.webView == null || this.webView == undefined || this.webView == false) return;
267
274
 
268
275
  // console.log('callJavascript: ' + script);
269
276