react-native-bootpay-api 4.0.0 → 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 +1 -1
- package/src/BootpayWebView.js +99 -54
- package/src/index.d.ts +1 -33
- package/src/index.js +1 -20
package/package.json
CHANGED
package/src/BootpayWebView.js
CHANGED
|
@@ -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,19 +30,7 @@ export class BootpayWebView extends Component {
|
|
|
41
30
|
}
|
|
42
31
|
)
|
|
43
32
|
UserInfo.setBootpayLastTime(Date.now());
|
|
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
|
-
// }
|
|
56
|
-
|
|
33
|
+
}
|
|
57
34
|
render() {
|
|
58
35
|
return <Modal
|
|
59
36
|
animationType={'slide'}
|
|
@@ -91,7 +68,7 @@ export class BootpayWebView extends Component {
|
|
|
91
68
|
useWebKit={true}
|
|
92
69
|
originWhitelist={['*']}
|
|
93
70
|
source={{
|
|
94
|
-
uri: 'https://webview.bootpay.co.kr/4.0.
|
|
71
|
+
uri: 'https://webview.bootpay.co.kr/4.0.6/'
|
|
95
72
|
}}
|
|
96
73
|
onRequestClose={()=> {
|
|
97
74
|
// console.log('onRequestClose');
|
|
@@ -121,11 +98,41 @@ export class BootpayWebView extends Component {
|
|
|
121
98
|
this.bootpayRequest(payload, items, user, extra, "requestAuthentication");
|
|
122
99
|
}
|
|
123
100
|
|
|
124
|
-
bootpayRequest = async (payload, items, user, extra, requestMethod) => {
|
|
101
|
+
bootpayRequest = async (payload, items, user, extra, requestMethod) => {
|
|
102
|
+
|
|
125
103
|
payload.application_id = Platform.OS == 'ios' ? this.props.ios_application_id : this.props.android_application_id;
|
|
126
104
|
payload.items = items;
|
|
127
|
-
payload.user = user;
|
|
128
|
-
payload.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;
|
|
129
136
|
|
|
130
137
|
|
|
131
138
|
//visibility가 true가 되면 webview onLoaded가 실행됨
|
|
@@ -158,6 +165,8 @@ export class BootpayWebView extends Component {
|
|
|
158
165
|
|
|
159
166
|
getMountJavascript = async () => {
|
|
160
167
|
return `
|
|
168
|
+
${this.getSDKVersion()}
|
|
169
|
+
${this.getEnvironmentMode()}
|
|
161
170
|
${this.getBootpayPlatform()}
|
|
162
171
|
${this.close()}
|
|
163
172
|
${await this.getAnalyticsData()}
|
|
@@ -183,28 +192,27 @@ export class BootpayWebView extends Component {
|
|
|
183
192
|
}
|
|
184
193
|
|
|
185
194
|
onMessage = ({ nativeEvent }) => {
|
|
186
|
-
|
|
187
|
-
|
|
195
|
+
// console.log(`onMessage: ${nativeEvent}, ${JSON.stringify(nativeEvent)}`);
|
|
196
|
+
|
|
197
|
+
if (nativeEvent == undefined) return;
|
|
188
198
|
|
|
189
|
-
|
|
199
|
+
const res = JSON.parse(JSON.stringify(nativeEvent));
|
|
200
|
+
|
|
190
201
|
|
|
191
|
-
if(
|
|
202
|
+
if(res.data == 'close') {
|
|
192
203
|
if(this.props.onClose == undefined) return;
|
|
193
204
|
var json = {
|
|
194
205
|
action: 'BootpayClose',
|
|
195
206
|
message: '결제창이 닫혔습니다'
|
|
196
|
-
}
|
|
197
|
-
// this.setState(
|
|
198
|
-
// {
|
|
199
|
-
// visibility: false
|
|
200
|
-
// }
|
|
201
|
-
// )
|
|
207
|
+
}
|
|
202
208
|
this.props.onClose(json);
|
|
203
209
|
this.dismiss();
|
|
204
210
|
return;
|
|
205
211
|
}
|
|
206
212
|
|
|
207
|
-
|
|
213
|
+
|
|
214
|
+
const data = JSON.parse(res.data);
|
|
215
|
+
|
|
208
216
|
switch (data.event) {
|
|
209
217
|
case 'cancel':
|
|
210
218
|
if(this.props.onCancel != undefined) this.props.onCancel(data);
|
|
@@ -223,7 +231,25 @@ export class BootpayWebView extends Component {
|
|
|
223
231
|
break;
|
|
224
232
|
case 'close':
|
|
225
233
|
if(this.props.onClose != undefined) this.props.onClose(data);
|
|
226
|
-
|
|
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
|
+
}
|
|
227
253
|
}
|
|
228
254
|
}
|
|
229
255
|
|
|
@@ -231,6 +257,24 @@ export class BootpayWebView extends Component {
|
|
|
231
257
|
return true;
|
|
232
258
|
}
|
|
233
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
|
+
|
|
234
278
|
getBootpayPlatform = () => {
|
|
235
279
|
if(Platform.OS == 'ios') {
|
|
236
280
|
return "Bootpay.setDevice('IOS');";
|
|
@@ -249,15 +293,16 @@ export class BootpayWebView extends Component {
|
|
|
249
293
|
// }
|
|
250
294
|
|
|
251
295
|
transactionConfirm = () => {
|
|
252
|
-
const script = "Bootpay.confirm()"
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
this.
|
|
256
|
-
this.
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
this.
|
|
260
|
-
|
|
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
|
+
// "})";
|
|
261
306
|
|
|
262
307
|
this.callJavaScript(script);
|
|
263
308
|
}
|
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 };
|