react-native-bootpay-api 4.0.0-beta.1 → 4.0.6

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.1",
3
+ "version": "4.0.6",
4
4
  "description": "React Native를 위한 bootpay 라이브러리 입니다.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -10,27 +10,16 @@ export class BootpayWebView extends Component {
10
10
 
11
11
  webView = useRef<WebView>(null);
12
12
 
13
+ _VERSION = "4.0.6";
14
+ _DEBUG = false;
15
+ _payload = {};
16
+
13
17
 
14
18
  state = {
15
19
  visibility: false,
16
20
  script: '',
17
21
  firstLoad: false
18
- }
19
-
20
- // canGoBack() {
21
- // console.log('canGoBack');
22
- // if(this.webView.current) {
23
- // return this.webView.current.canGoBack();
24
- // }
25
- // return false;
26
- // }
27
-
28
- // goBack() {
29
- // console.log('GoBack');
30
- // if(this.webView.goBack) {
31
- // this.webView.current.goBack();
32
- // }
33
- // }
22
+ }
34
23
 
35
24
  async componentWillUnmount() {
36
25
  this.setState(
@@ -41,8 +30,7 @@ export class BootpayWebView extends Component {
41
30
  }
42
31
  )
43
32
  UserInfo.setBootpayLastTime(Date.now());
44
- }
45
-
33
+ }
46
34
  render() {
47
35
  return <Modal
48
36
  animationType={'slide'}
@@ -76,15 +64,14 @@ export class BootpayWebView extends Component {
76
64
  </TouchableOpacity>
77
65
  }
78
66
  <WebView
79
- ref={(wv) => this.webView = wv}
80
- // ref={btWebView}
67
+ ref={(wv) => this.webView = wv}
81
68
  useWebKit={true}
82
69
  originWhitelist={['*']}
83
70
  source={{
84
- uri: 'https://webview.bootpay.co.kr/4.0.0/'
71
+ uri: 'https://webview.bootpay.co.kr/4.0.6/'
85
72
  }}
86
73
  onRequestClose={()=> {
87
- console.log('onRequestClose');
74
+ // console.log('onRequestClose');
88
75
  this.dismiss();
89
76
  }}
90
77
  injectedJavaScript={this.state.script}
@@ -111,11 +98,41 @@ export class BootpayWebView extends Component {
111
98
  this.bootpayRequest(payload, items, user, extra, "requestAuthentication");
112
99
  }
113
100
 
114
- bootpayRequest = async (payload, items, user, extra, requestMethod) => {
101
+ bootpayRequest = async (payload, items, user, extra, requestMethod) => {
102
+
115
103
  payload.application_id = Platform.OS == 'ios' ? this.props.ios_application_id : this.props.android_application_id;
116
104
  payload.items = items;
117
- payload.user_info = user;
118
- payload.extra = extra;
105
+ payload.user = user;
106
+ payload.extra = {
107
+ card_quota: extra.card_quota ?? "",
108
+ seller_name: extra.seller_name ?? "",
109
+ delivery_day: extra.delivery_day ?? 1, //배송일자
110
+ locale: extra.locale ?? "ko",
111
+ offer_period: extra.offer_period ?? "" , //결제창 제공기간에 해당하는 string 값, 지원하는 PG만 적용됨
112
+ disp_cash_result: extra.disp_cash_result ?? true, // 현금영수증 보일지 말지.. 가상계좌 KCP 옵션
113
+ deposit_expiration: extra.deposit_expiration ?? "", //가상계좌 입금 만료일자 설정, yyyy-MM-dd
114
+ app_scheme: extra.app_scheme ?? "", //ios의 경우 카드사 앱 호출 후 되돌아오기 위한 앱 스키마명
115
+ use_card_point: extra.use_card_point ?? true, //카드 포인트 사용 여부 (토스만 가능)
116
+ direct_card: extra.direct_card ?? "", //해당 카드로 바로 결제창 (토스만 가능)
117
+ use_order_id: extra.use_order_id ?? false, //가맹점 order_id로 PG로 전송
118
+ international_card_only: extra.international_card_only ?? false, //해외 결제카드 선택 여부 (토스만 가능)
119
+ // phone_carrier: 'SKT', // ['SKT', 'KT', 'LGT'] 중 택 1
120
+ direct_app_card: extra.direct_app_card ?? false, //카드사앱으로 direct 호출
121
+ direct_samsungpay: extra.direct_samsungpay ?? false, //삼성페이 바로 띄우기
122
+ test_deposit: extra.test_deposit ?? false, //가상계좌 모의 입금
123
+ enable_error_webhook: extra.enable_error_webhook ?? false, //결제 오류시 Feedback URL로 webhook
124
+ separately_confirmed: extra.separately_confirmed ?? true, // confirm 이벤트를 호출할지 말지, false일 경우 자동승인
125
+ confirm_only_rest_api: extra.confirm_only_rest_api ?? false, // REST API로만 승인 처리
126
+ open_type: extra.open_type ?? 'redirect', // [그대로 지정] 페이지 오픈 type [iframe, popup, redirect] 중 택 1, 앱에서는 redriect가 default
127
+ use_bootpay_inapp_sdk: extra.use_bootpay_inapp_sdk ?? true, // [그대로 지정] native app에서는 redirect를 완성도있게 지원하기 위한 옵션
128
+ redirect_url: extra.redirect_url ?? 'https://api.bootpay.co.kr/v2', // [그대로 지정] open_type이 redirect일 경우 페이지 이동할 URL ( 오류 및 결제 완료 모두 수신 가능 )
129
+ display_success_result: extra.display_success_result ?? false, // 결제 완료되면 부트페이가 제공하는 완료창으로 보여주기 ( open_type이 iframe, popup 일때만 가능 )
130
+ display_error_result: extra.display_error_result ?? true, // 결제가 실패하면 부트페이가 제공하는 실패창으로 보여주기 ( open_type이 iframe, popup 일때만 가능 )
131
+ show_close_button: extra.show_close_button ?? false, // x 닫기 버튼 삽입 (닫기버튼이 없는 PG사를 위한 옵션)
132
+ };
133
+
134
+
135
+ this._payload = payload;
119
136
 
120
137
 
121
138
  //visibility가 true가 되면 webview onLoaded가 실행됨
@@ -142,13 +159,16 @@ export class BootpayWebView extends Component {
142
159
  visibility: false
143
160
  })
144
161
  )
145
- this.removePaymentWindow();
162
+ // this.removePaymentWindow();
146
163
  }
147
164
 
148
165
 
149
166
  getMountJavascript = async () => {
150
167
  return `
168
+ ${this.getSDKVersion()}
169
+ ${this.getEnvironmentMode()}
151
170
  ${this.getBootpayPlatform()}
171
+ ${this.close()}
152
172
  ${await this.getAnalyticsData()}
153
173
  `;
154
174
  }
@@ -158,68 +178,78 @@ export class BootpayWebView extends Component {
158
178
  const script = "Bootpay." + requestMethod +
159
179
  `(${JSON.stringify(payload)})` +
160
180
  ".then( function (res) {" +
161
- confirm() +
162
- issued() +
163
- done() +
181
+ this.confirm() +
182
+ this.issued() +
183
+ this.done() +
164
184
  "}, function (res) {" +
165
- error() +
166
- cancel() +
167
- "})";
185
+ this.error() +
186
+ this.cancel() +
187
+ "}); void(0);";
188
+
189
+ return script;
168
190
 
169
- this.callJavaScript(script);
191
+ // return this.generateScript;
170
192
  }
171
193
 
172
194
  onMessage = ({ nativeEvent }) => {
173
- if (nativeEvent == undefined || nativeEvent.data == undefined) return;
195
+ // console.log(`onMessage: ${nativeEvent}, ${JSON.stringify(nativeEvent)}`);
196
+
197
+ if (nativeEvent == undefined) return;
198
+
199
+ const res = JSON.parse(JSON.stringify(nativeEvent));
200
+
174
201
 
175
- if(nativeEvent.data == 'close') {
202
+ if(res.data == 'close') {
176
203
  if(this.props.onClose == undefined) return;
177
204
  var json = {
178
205
  action: 'BootpayClose',
179
206
  message: '결제창이 닫혔습니다'
180
- }
181
- this.setState(
182
- {
183
- visibility: false
184
- }
185
- )
207
+ }
186
208
  this.props.onClose(json);
187
209
  this.dismiss();
188
210
  return;
189
211
  }
190
212
 
191
- const data = JSON.parse(nativeEvent.data);
213
+
214
+ const data = JSON.parse(res.data);
215
+
192
216
  switch (data.event) {
193
217
  case 'cancel':
194
- if(this.props.onCancel != undefined) this.props.onCancel(data);
195
- // this.setState(
196
- // {
197
- // visibility: false
198
- // }
199
- // )
218
+ if(this.props.onCancel != undefined) this.props.onCancel(data);
200
219
  break;
201
220
  case 'error':
202
- if(this.props.onError != undefined) this.props.onError(data);
203
- // this.setState(
204
- // {
205
- // visibility: false
206
- // }
207
- // )
221
+ if(this.props.onError != undefined) this.props.onError(data);
208
222
  break;
209
223
  case 'issued':
210
- if(this.props.onReady != undefined) this.props.onReady(data);
224
+ if(this.props.onReady != undefined) this.props.onIssued(data);
211
225
  break;
212
226
  case 'confirm':
213
227
  if(this.props.onConfirm != undefined) this.props.onConfirm(data);
214
228
  break;
215
229
  case 'done':
216
- if(this.props.onDone != undefined) this.props.onDone(data);
217
- // this.setState(
218
- // {
219
- // visibility: false
220
- // }
221
- // )
230
+ if(this.props.onDone != undefined) this.props.onDone(data);
222
231
  break;
232
+ case 'close':
233
+ if(this.props.onClose != undefined) this.props.onClose(data);
234
+ this.dismiss();
235
+ break;
236
+ }
237
+
238
+ console.log(`redirect: ${JSON.stringify(data)}`);
239
+
240
+ if(this._payload != undefined && this._payload.extra != undefined && this._payload.extra.open_type == 'redirect') {
241
+
242
+
243
+ if(data.event == 'done' && this._payload.extra.display_success_result != true) {
244
+ if(this.props.onClose != undefined) this.props.onClose(data);
245
+ this.dismiss();
246
+ } else if(data.event == 'error' && this._payload.extra.display_error_result != true ) {
247
+ if(this.props.onClose != undefined) this.props.onClose(data);
248
+ this.dismiss();
249
+ } else if(data.event == 'cancel') {
250
+ if(this.props.onClose != undefined) this.props.onClose(data);
251
+ this.dismiss();
252
+ }
223
253
  }
224
254
  }
225
255
 
@@ -227,6 +257,24 @@ export class BootpayWebView extends Component {
227
257
  return true;
228
258
  }
229
259
 
260
+ getSDKVersion = () => {
261
+ if(Platform.OS == 'ios') {
262
+ return "Bootpay.setVersion('" + this._VERSION + "', 'ios_react_native')";
263
+ // return "Bootpay.setDevice('IOS');";
264
+ } else if(Platform.OS == 'android'){
265
+ return "Bootpay.setVersion('" + this._VERSION + "', 'android_react_native')";
266
+ // return "Bootpay.setDevice('ANDROID');";
267
+ }
268
+ }
269
+
270
+ getEnvironmentMode = () => {
271
+ if(this._DEBUG) {
272
+ return "Bootpay.setEnvironmentMode('development');";
273
+
274
+ }
275
+ return "";
276
+ }
277
+
230
278
  getBootpayPlatform = () => {
231
279
  if(Platform.OS == 'ios') {
232
280
  return "Bootpay.setDevice('IOS');";
@@ -245,27 +293,29 @@ export class BootpayWebView extends Component {
245
293
  // }
246
294
 
247
295
  transactionConfirm = () => {
248
- const script = "Bootpay.confirm()" +
249
- ".then( function (res) {" +
250
- confirm() +
251
- issued() +
252
- done() +
253
- "}, function (res) {" +
254
- error() +
255
- cancel() +
256
- "})";
296
+ const script = "Bootpay.confirm();"
297
+ // +
298
+ // ".then( function (res) {" +
299
+ // this.confirm() +
300
+ // this.issued() +
301
+ // this.done() +
302
+ // "}, function (res) {" +
303
+ // this.error() +
304
+ // this.cancel() +
305
+ // "})";
257
306
 
258
307
  this.callJavaScript(script);
259
308
  }
260
309
 
261
310
  removePaymentWindow = () => {
262
- this.callJavaScript(`
263
- Bootpay.removePaymentWindow();
264
- `);
311
+ this.dismiss();
312
+ // this.callJavaScript(`
313
+ // Bootpay.removePaymentWindow();
314
+ // `);
265
315
  }
266
316
 
267
- callJavaScript = (script) => {
268
- if(this.webView == null || this.webView == undefined) return;
317
+ callJavaScript = (script) => {
318
+ if(this.webView == null || this.webView == undefined || this.webView == false) return;
269
319
 
270
320
  // console.log('callJavascript: ' + script);
271
321
 
package/src/index.d.ts CHANGED
@@ -8,36 +8,4 @@ import { userTrace, pageTrace } from './BootpayAnalytics'
8
8
 
9
9
 
10
10
  export { BootpayWebView, userTrace, pageTrace }
11
-
12
- // interface BootpayWebViewProps {
13
- // ios_application_id: string;
14
- // android_application_id: string;
15
-
16
- // onCancel: (data: string) => void;
17
- // onError: (data: string) => void;
18
- // onReady: (data: string) => void;
19
- // onConfirm: (data: string) => void;
20
- // onDone: (data: string) => void;
21
- // onClose: () => void;
22
- // }
23
-
24
- // export class BootpayWebView extends Component<BootpayWebViewProps> {
25
- // request: (payload: Object, items: Object, user: Object, extra: Object) => Promise<string>;
26
- // dismiss: () => Promise<string>;
27
- // transactionConfirm: (data: string) => Promise<string>;
28
- // }
29
-
30
- // export class BootpayAnalytics {
31
- // static userTrace: () => void;
32
- // static pageTrace: () => void;
33
- // }
34
-
35
- // export const userTrace: () => void;
36
- // export default function pageTrace(): void;
37
- // export const userTrace: () => void;
38
-
39
- // export default function PageTrace() : void;
40
-
41
- // const Bootpay =
42
-
43
- // export { BootpayWebView, userTrace, pageTrace }
11
+
package/src/index.js CHANGED
@@ -3,23 +3,4 @@
3
3
  import { BootpayWebView } from './BootpayWebView'
4
4
  import { userTrace, pageTrace } from './BootpayAnalytics'
5
5
 
6
- export { BootpayWebView, userTrace, pageTrace };
7
- // export { useBootpay };
8
-
9
- // import React, { Component } from 'react';
10
- // import WebView from 'react-native-webview-bootpay';
11
-
12
- // export class BootpayWebView extends Component {
13
- // render() {
14
- // return <WebView
15
- // useWebKit={true}
16
- // originWhitelist={['*']}
17
- // source={{
18
- // uri: 'https://www.google.com'
19
- // }}
20
- // javaScriptEnabled={true}
21
- // javaScriptCanOpenWindowsAutomatically={true}
22
- // scalesPageToFit={true}
23
- // />
24
- // }
25
- // }
6
+ export { BootpayWebView, userTrace, pageTrace };