react-native-bootpay-api 1.5.2 → 4.0.0-beta.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 +1 -1
- package/src/BootpayWebView.js +75 -34
- package/CHANGELOG.md +0 -29
- package/lib/commonjs/BootpayAnalytics.js +0 -131
- package/lib/commonjs/BootpayAnalytics.js.map +0 -1
- package/lib/commonjs/BootpayWebView.js +0 -281
- package/lib/commonjs/BootpayWebView.js.map +0 -1
- package/lib/commonjs/UserInfo.js +0 -94
- package/lib/commonjs/UserInfo.js.map +0 -1
- package/lib/commonjs/index.d.js +0 -28
- package/lib/commonjs/index.d.js.map +0 -1
- package/lib/commonjs/index.js +0 -28
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/useBootpay.js +0 -44
- package/lib/commonjs/useBootpay.js.map +0 -1
- package/lib/module/BootpayAnalytics.js +0 -115
- package/lib/module/BootpayAnalytics.js.map +0 -1
- package/lib/module/BootpayWebView.js +0 -259
- package/lib/module/BootpayWebView.js.map +0 -1
- package/lib/module/UserInfo.js +0 -79
- package/lib/module/UserInfo.js.map +0 -1
- package/lib/module/index.d.js +0 -28
- package/lib/module/index.d.js.map +0 -1
- package/lib/module/index.js +0 -21
- package/lib/module/index.js.map +0 -1
- package/lib/module/useBootpay.js +0 -43
- package/lib/module/useBootpay.js.map +0 -1
- package/lib/typescript/UserInfo.d.ts +0 -15
- package/lib/typescript/UserInfo.d.ts.map +0 -1
- package/src/useBootpay.js +0 -51
package/package.json
CHANGED
package/src/BootpayWebView.js
CHANGED
|
@@ -6,6 +6,8 @@ import WebView from 'react-native-webview-bootpay';
|
|
|
6
6
|
import UserInfo from './UserInfo'
|
|
7
7
|
|
|
8
8
|
export class BootpayWebView extends Component {
|
|
9
|
+
|
|
10
|
+
|
|
9
11
|
webView = useRef<WebView>(null);
|
|
10
12
|
|
|
11
13
|
|
|
@@ -79,7 +81,7 @@ export class BootpayWebView extends Component {
|
|
|
79
81
|
useWebKit={true}
|
|
80
82
|
originWhitelist={['*']}
|
|
81
83
|
source={{
|
|
82
|
-
uri: 'https://
|
|
84
|
+
uri: 'https://webview.bootpay.co.kr/4.0.0/'
|
|
83
85
|
}}
|
|
84
86
|
onRequestClose={()=> {
|
|
85
87
|
console.log('onRequestClose');
|
|
@@ -97,22 +99,24 @@ export class BootpayWebView extends Component {
|
|
|
97
99
|
</Modal>
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
requestPayment = async (payload, items, user, extra) => {
|
|
103
|
+
this.bootpayRequest(payload, items, user, extra, "requestPayment");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
requestSubscription = async (payload, items, user, extra) => {
|
|
107
|
+
this.bootpayRequest(payload, items, user, extra, "requestSubscription");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
requestAuthentication = async (payload, items, user, extra) => {
|
|
111
|
+
this.bootpayRequest(payload, items, user, extra, "requestAuthentication");
|
|
112
|
+
}
|
|
101
113
|
|
|
114
|
+
bootpayRequest = async (payload, items, user, extra, requestMethod) => {
|
|
102
115
|
payload.application_id = Platform.OS == 'ios' ? this.props.ios_application_id : this.props.android_application_id;
|
|
103
116
|
payload.items = items;
|
|
104
117
|
payload.user_info = user;
|
|
105
118
|
payload.extra = extra;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
var quickPopup = '';
|
|
109
|
-
|
|
110
|
-
if(extra != undefined && extra.quick_popup != undefined) {
|
|
111
|
-
if(extra.quick_popup == 1) {
|
|
112
|
-
quickPopup = 'BootPay.startQuickPopup();';
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
119
|
+
|
|
116
120
|
|
|
117
121
|
//visibility가 true가 되면 webview onLoaded가 실행됨
|
|
118
122
|
this.setState(
|
|
@@ -121,15 +125,17 @@ export class BootpayWebView extends Component {
|
|
|
121
125
|
script: `
|
|
122
126
|
${await this.getMountJavascript()}
|
|
123
127
|
${quickPopup}
|
|
124
|
-
${this.generateScript(payload)}
|
|
128
|
+
${this.generateScript(payload, requestMethod)}
|
|
125
129
|
`,
|
|
126
130
|
firstLoad: false,
|
|
127
131
|
showCloseButton: extra.show_close_button || false
|
|
128
132
|
}
|
|
129
133
|
)
|
|
130
134
|
|
|
131
|
-
UserInfo.updateInfo();
|
|
135
|
+
UserInfo.updateInfo();
|
|
132
136
|
}
|
|
137
|
+
|
|
138
|
+
|
|
133
139
|
|
|
134
140
|
dismiss = () => {
|
|
135
141
|
this.setState(
|
|
@@ -149,15 +155,21 @@ export class BootpayWebView extends Component {
|
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
|
|
152
|
-
generateScript= (payload) => {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
generateScript= (payload, requestMethod) => {
|
|
159
|
+
var requestMethod = "requestPayment";
|
|
160
|
+
|
|
161
|
+
const script = "Bootpay." + requestMethod +
|
|
162
|
+
`(${JSON.stringify(payload)})` +
|
|
163
|
+
".then( function (res) {" +
|
|
164
|
+
confirm() +
|
|
165
|
+
issued() +
|
|
166
|
+
done() +
|
|
167
|
+
"}, function (res) {" +
|
|
168
|
+
error() +
|
|
169
|
+
cancel() +
|
|
170
|
+
"})";
|
|
159
171
|
|
|
160
|
-
|
|
172
|
+
this.callJavaScript(script);
|
|
161
173
|
}
|
|
162
174
|
|
|
163
175
|
onMessage = ({ nativeEvent }) => {
|
|
@@ -215,9 +227,9 @@ export class BootpayWebView extends Component {
|
|
|
215
227
|
|
|
216
228
|
getBootpayPlatform = () => {
|
|
217
229
|
if(Platform.OS == 'ios') {
|
|
218
|
-
return "
|
|
230
|
+
return "Bootpay.setDevice('IOS');";
|
|
219
231
|
} else if(Platform.OS == 'android'){
|
|
220
|
-
return "
|
|
232
|
+
return "Bootpay.setDevice('ANDROID');";
|
|
221
233
|
}
|
|
222
234
|
}
|
|
223
235
|
|
|
@@ -230,18 +242,23 @@ export class BootpayWebView extends Component {
|
|
|
230
242
|
// }
|
|
231
243
|
// }
|
|
232
244
|
|
|
233
|
-
transactionConfirm = (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
245
|
+
transactionConfirm = () => {
|
|
246
|
+
const script = "Bootpay.confirm()" +
|
|
247
|
+
".then( function (res) {" +
|
|
248
|
+
confirm() +
|
|
249
|
+
issued() +
|
|
250
|
+
done() +
|
|
251
|
+
"}, function (res) {" +
|
|
252
|
+
error() +
|
|
253
|
+
cancel() +
|
|
254
|
+
"})";
|
|
255
|
+
|
|
256
|
+
this.callJavaScript(script);
|
|
240
257
|
}
|
|
241
258
|
|
|
242
259
|
removePaymentWindow = () => {
|
|
243
260
|
this.callJavaScript(`
|
|
244
|
-
|
|
261
|
+
Bootpay.removePaymentWindow();
|
|
245
262
|
`);
|
|
246
263
|
}
|
|
247
264
|
|
|
@@ -258,14 +275,38 @@ export class BootpayWebView extends Component {
|
|
|
258
275
|
|
|
259
276
|
getAnalyticsData = async () => {
|
|
260
277
|
const uuid = await UserInfo.getBootpayUUID();
|
|
261
|
-
const bootpaySK = await UserInfo.getBootpaySK();
|
|
278
|
+
// const bootpaySK = await UserInfo.getBootpaySK();
|
|
262
279
|
const bootLastTime = await UserInfo.getBootpayLastTime();
|
|
263
280
|
|
|
264
281
|
|
|
265
282
|
const elaspedTime = Date.now() - bootLastTime;
|
|
266
|
-
return `window.
|
|
283
|
+
return `window.Bootpay.$analytics.setAnalyticsData({uuid:'${uuid}', time:${elaspedTime}});`;
|
|
267
284
|
// this.callJavaScript(`window.BootPay.setAnalyticsData({uuid:'${uuid}',sk:'${bootpaySK}',sk_time:${bootLastTime},time:${elaspedTime}});`);
|
|
268
285
|
}
|
|
286
|
+
|
|
287
|
+
confirm = () => {
|
|
288
|
+
return "if (res.event === 'confirm') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
done = () => {
|
|
292
|
+
return "else if (res.event === 'done') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
issued = () => {
|
|
296
|
+
return "else if (res.event === 'issued') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
error = () => {
|
|
300
|
+
return "if (res.event === 'error') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
cancel = () => {
|
|
304
|
+
return "else if (res.event === 'cancel') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
close = () => {
|
|
308
|
+
return "document.addEventListener('bootpayclose', function (e) { window.BootpayRNWebView.postMessage('close'); });";
|
|
309
|
+
}
|
|
269
310
|
}
|
|
270
311
|
|
|
271
312
|
|
package/CHANGELOG.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
### 1.5.2
|
|
2
|
-
- webview version update
|
|
3
|
-
|
|
4
|
-
### 1.5.1
|
|
5
|
-
- 안드로이드 팝업 일 경우 백버튼 클릭시 닫히도록 수정
|
|
6
|
-
|
|
7
|
-
### 1.5.0
|
|
8
|
-
- webview update, android manifest 외부앱 패키지명 update
|
|
9
|
-
|
|
10
|
-
### 1.4.4
|
|
11
|
-
- 사용하지 않은 패키지 제거
|
|
12
|
-
|
|
13
|
-
### 1.4.3
|
|
14
|
-
- bootpay anlaytics api 추가
|
|
15
|
-
|
|
16
|
-
### 1.0.4
|
|
17
|
-
- typescript declare 적용
|
|
18
|
-
|
|
19
|
-
### 1.0.3
|
|
20
|
-
- close button 클릭시 onCancel, onClose 이벤트 호출
|
|
21
|
-
|
|
22
|
-
### 1.0.2
|
|
23
|
-
- callJavascript 버그 수정
|
|
24
|
-
|
|
25
|
-
### 1.0.1
|
|
26
|
-
- close.png 못찾는 버그 수정
|
|
27
|
-
|
|
28
|
-
### 1.0.0
|
|
29
|
-
- first release
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.pageTrace = exports.userTrace = void 0;
|
|
7
|
-
|
|
8
|
-
var _reactNativeBase = _interopRequireDefault(require("react-native-base64"));
|
|
9
|
-
|
|
10
|
-
var _reactNativeDeviceInfo = _interopRequireDefault(require("react-native-device-info"));
|
|
11
|
-
|
|
12
|
-
var _reactNative = require("react-native");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
// import CryptoJS from 'crypto-js';
|
|
17
|
-
var Aes = _reactNative.NativeModules.Aes;
|
|
18
|
-
|
|
19
|
-
const userTrace = async (applicationId, userId, phone, email, gender, birth, area) => {
|
|
20
|
-
try {
|
|
21
|
-
const payload = {
|
|
22
|
-
"id": userId,
|
|
23
|
-
"ver": _reactNativeDeviceInfo.default.getVersion(),
|
|
24
|
-
"application_id": applicationId,
|
|
25
|
-
"phone": phone,
|
|
26
|
-
"email": email,
|
|
27
|
-
"gender": gender,
|
|
28
|
-
"birth": birth,
|
|
29
|
-
"area": area
|
|
30
|
-
};
|
|
31
|
-
var key = getRandomKey(32);
|
|
32
|
-
var iv = getRandomKey(16);
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
const data = await Aes.encrypt(JSON.stringify(payload), stringToHex(key), stringToHex(iv)).then(cipher => cipher);
|
|
36
|
-
const response = await fetch('https://analytics.bootpay.co.kr/login', {
|
|
37
|
-
method: 'POST',
|
|
38
|
-
headers: {
|
|
39
|
-
Accept: 'application/json',
|
|
40
|
-
'Content-Type': 'application/json'
|
|
41
|
-
},
|
|
42
|
-
body: JSON.stringify({
|
|
43
|
-
data: data,
|
|
44
|
-
session_key: await getSessionKey(key, iv)
|
|
45
|
-
})
|
|
46
|
-
});
|
|
47
|
-
const json = await response.json();
|
|
48
|
-
return json;
|
|
49
|
-
} catch (e) {
|
|
50
|
-
console.log(e);
|
|
51
|
-
}
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.error(error);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
exports.userTrace = userTrace;
|
|
58
|
-
|
|
59
|
-
const pageTrace = async (applicationId, url, pageType, items) => {
|
|
60
|
-
try {
|
|
61
|
-
const payload = {
|
|
62
|
-
"application_id": applicationId,
|
|
63
|
-
"url": url,
|
|
64
|
-
"page_type": pageType,
|
|
65
|
-
"items": items,
|
|
66
|
-
"referer": ''
|
|
67
|
-
};
|
|
68
|
-
var key = getRandomKey(32);
|
|
69
|
-
var iv = getRandomKey(16);
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
const data = await Aes.encrypt(JSON.stringify(payload), stringToHex(key), stringToHex(iv)).then(cipher => cipher);
|
|
73
|
-
const response = await fetch('https://analytics.bootpay.co.kr/call', {
|
|
74
|
-
method: 'POST',
|
|
75
|
-
headers: {
|
|
76
|
-
Accept: 'application/json',
|
|
77
|
-
'Content-Type': 'application/json'
|
|
78
|
-
},
|
|
79
|
-
body: JSON.stringify({
|
|
80
|
-
data: data,
|
|
81
|
-
session_key: await getSessionKey(key, iv)
|
|
82
|
-
})
|
|
83
|
-
});
|
|
84
|
-
const json = await response.json();
|
|
85
|
-
return json;
|
|
86
|
-
} catch (e) {
|
|
87
|
-
console.log(e);
|
|
88
|
-
}
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.error(error);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
exports.pageTrace = pageTrace;
|
|
95
|
-
|
|
96
|
-
const stringToHex = str => {
|
|
97
|
-
var hex = '';
|
|
98
|
-
|
|
99
|
-
for (var i = 0, l = str.length; i < l; i++) {
|
|
100
|
-
hex += str.charCodeAt(i).toString(16);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return hex;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const getRandomKey = length => {
|
|
107
|
-
var text = '';
|
|
108
|
-
var keys = 'abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
109
|
-
|
|
110
|
-
for (var i = 0; i < length; i++) text += keys.charAt(Math.floor(Math.random() * keys.length));
|
|
111
|
-
|
|
112
|
-
return text;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const getSessionKey = async (key, iv) => {
|
|
116
|
-
const keyValue = _reactNativeBase.default.encode(key);
|
|
117
|
-
|
|
118
|
-
const ivValue = _reactNativeBase.default.encode(iv);
|
|
119
|
-
|
|
120
|
-
return `${keyValue}##${ivValue}`;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const strEncode = async (str, key, iv) => {
|
|
124
|
-
return await Aes.encrypt(str, key, iv).then(cipher => {
|
|
125
|
-
Aes.hmac256(cipher, key).then(hash => {
|
|
126
|
-
console.log('HMAC', hash);
|
|
127
|
-
return hash;
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
//# sourceMappingURL=BootpayAnalytics.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["BootpayAnalytics.js"],"names":["Aes","NativeModules","userTrace","applicationId","userId","phone","email","gender","birth","area","payload","DeviceInfo","getVersion","key","getRandomKey","iv","data","encrypt","JSON","stringify","stringToHex","then","cipher","response","fetch","method","headers","Accept","body","session_key","getSessionKey","json","e","console","log","error","pageTrace","url","pageType","items","str","hex","i","l","length","charCodeAt","toString","text","keys","charAt","Math","floor","random","keyValue","base64","encode","ivValue","strEncode","hmac256","hash"],"mappings":";;;;;;;AAEA;;AACA;;AAGA;;;;AADA;AAEA,IAAIA,GAAG,GAAGC,2BAAcD,GAAxB;;AAGA,MAAME,SAAS,GAAG,OAAOC,aAAP,EAAsBC,MA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B,CAA8BsC,IAAI,IAAI;AAClC1B,MAAAA,OAAO,CAACC,GAAR,CAAY,MAAZ,EAAoByB,IAApB;AACA,aAAOA,IAAP;AACH,KAHD;AAIH,GALY,CAAb;AAOH,CARD","sourcesContent":["\n \nimport base64 from 'react-native-base64'\nimport DeviceInfo from 'react-native-device-info';\n\n// import CryptoJS from 'crypto-js'; \nimport { NativeModules } from 'react-native'\nvar Aes = NativeModules.Aes\n\n\nconst userTrace = async (applicationId, userId, phone, email, gender, birth, area) => { \n try { \n const payload = {\n \"id\": userId, \n \"ver\": DeviceInfo.getVersion(),\n \"application_id\": applicationId, \n \"phone\": phone,\n \"email\": email,\n \"gender\": gender,\n \"birth\": birth,\n \"area\": area\n };\n\n var key = getRandomKey(32);\n var iv = getRandomKey(16);\n \n try { \n const data = await Aes.encrypt(JSON.stringify(payload), stringToHex(key), stringToHex(iv)).then(cipher => cipher);\n\n const response = await fetch(\n 'https://analytics.bootpay.co.kr/login',\n {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n data: data,\n session_key: await getSessionKey(key, iv)\n })\n }\n );\n const json = await response.json();\n return json;\n } catch (e) {\n console.log(e);\n } \n } catch (error) {\n console.error(error);\n }\n}\n\nconst pageTrace = async (applicationId, url, pageType, items) => { \n try { \n const payload = {\n \"application_id\": applicationId, \n \"url\": url, \n \"page_type\": pageType,\n \"items\": items,\n \"referer\": ''\n }; \n\n var key = getRandomKey(32);\n var iv = getRandomKey(16);\n \n try { \n const data = await Aes.encrypt(JSON.stringify(payload), stringToHex(key), stringToHex(iv)).then(cipher => cipher);\n\n const response = await fetch(\n 'https://analytics.bootpay.co.kr/call',\n {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n data: data,\n session_key: await getSessionKey(key, iv)\n })\n }\n );\n const json = await response.json();\n return json;\n } catch (e) {\n console.log(e);\n } \n } catch (error) {\n console.error(error);\n }\n}\n\nconst stringToHex = (str) => {\n var hex = ''\n for (var i = 0, l = str.length; i < l; i++) {\n hex += str.charCodeAt(i).toString(16)\n }\n return hex\n}\n\nconst getRandomKey = (length) => {\n var text = '';\n var keys = 'abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n\n for (var i = 0; i < length; i++)\n text += keys.charAt(Math.floor(Math.random() * keys.length));\n\n return text;\n}\n\n\nconst getSessionKey = async (key, iv) => {\n const keyValue = base64.encode(key);\n const ivValue = base64.encode(iv);\n\n return `${keyValue}##${ivValue}`;\n}\n\nconst strEncode = async (str, key, iv) => {\n return await Aes.encrypt(str, key, iv).then(cipher => {\n Aes.hmac256(cipher, key).then(hash => {\n console.log('HMAC', hash)\n return hash;\n })\n })\n\n}\n\nexport { userTrace, pageTrace }\n"]}
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.BootpayWebView = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
var _reactNative = require("react-native");
|
|
11
|
-
|
|
12
|
-
var _reactNativeWebviewBootpay = _interopRequireDefault(require("react-native-webview-bootpay"));
|
|
13
|
-
|
|
14
|
-
var _UserInfo = _interopRequireDefault(require("./UserInfo"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
22
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
-
|
|
24
|
-
class BootpayWebView extends _react.Component {
|
|
25
|
-
constructor(...args) {
|
|
26
|
-
super(...args);
|
|
27
|
-
|
|
28
|
-
_defineProperty(this, "webView", _react.useRef < _reactNativeWebviewBootpay.default > null);
|
|
29
|
-
|
|
30
|
-
_defineProperty(this, "state", {
|
|
31
|
-
visibility: false,
|
|
32
|
-
script: '',
|
|
33
|
-
firstLoad: false
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
_defineProperty(this, "request", async (payload, items, user, extra) => {
|
|
37
|
-
payload.application_id = _reactNative.Platform.OS == 'ios' ? this.props.ios_application_id : this.props.android_application_id;
|
|
38
|
-
payload.items = items;
|
|
39
|
-
payload.user_info = user;
|
|
40
|
-
payload.extra = extra;
|
|
41
|
-
var quickPopup = '';
|
|
42
|
-
|
|
43
|
-
if (extra != undefined && extra.quick_popup != undefined) {
|
|
44
|
-
if (extra.quick_popup == 1) {
|
|
45
|
-
quickPopup = 'BootPay.startQuickPopup();';
|
|
46
|
-
}
|
|
47
|
-
} //visibility가 true가 되면 webview onLoaded가 실행됨
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.setState({
|
|
51
|
-
visibility: true,
|
|
52
|
-
script: `
|
|
53
|
-
${await this.getMountJavascript()}
|
|
54
|
-
${quickPopup}
|
|
55
|
-
${this.generateScript(payload)}
|
|
56
|
-
`,
|
|
57
|
-
firstLoad: false,
|
|
58
|
-
showCloseButton: extra.show_close_button || false
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
_UserInfo.default.updateInfo();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
_defineProperty(this, "dismiss", () => {
|
|
65
|
-
this.setState(({
|
|
66
|
-
visibility
|
|
67
|
-
}) => ({
|
|
68
|
-
visibility: false
|
|
69
|
-
}));
|
|
70
|
-
this.removePaymentWindow();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
_defineProperty(this, "getMountJavascript", async () => {
|
|
74
|
-
return `
|
|
75
|
-
${this.getBootpayPlatform()}
|
|
76
|
-
${await this.getAnalyticsData()}
|
|
77
|
-
`;
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
_defineProperty(this, "generateScript", payload => {
|
|
81
|
-
const onError = '.error(function(data){ window.BootpayRNWebView.postMessage( JSON.stringify(data) ); })';
|
|
82
|
-
const onCancel = '.cancel(function(data){ window.BootpayRNWebView.postMessage( JSON.stringify(data) ); })';
|
|
83
|
-
const onReady = '.ready(function(data){ window.BootpayRNWebView.postMessage( JSON.stringify(data) ); })';
|
|
84
|
-
const onConfirm = '.confirm(function(data){ window.BootpayRNWebView.postMessage( JSON.stringify(data) ); })';
|
|
85
|
-
const onClose = '.close(function(data){ window.BootpayRNWebView.postMessage("close"); })';
|
|
86
|
-
const onDone = '.done(function(data){ window.BootpayRNWebView.postMessage( JSON.stringify(data) ); })';
|
|
87
|
-
return `BootPay.request(${JSON.stringify(payload)})` + onError + onCancel + onReady + onConfirm + onClose + onDone + '; void(0);';
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
_defineProperty(this, "onMessage", ({
|
|
91
|
-
nativeEvent
|
|
92
|
-
}) => {
|
|
93
|
-
if (nativeEvent == undefined || nativeEvent.data == undefined) return;
|
|
94
|
-
|
|
95
|
-
if (nativeEvent.data == 'close') {
|
|
96
|
-
if (this.props.onClose == undefined) return;
|
|
97
|
-
var json = {
|
|
98
|
-
action: 'BootpayClose',
|
|
99
|
-
message: '결제창이 닫혔습니다'
|
|
100
|
-
};
|
|
101
|
-
this.props.onClose(json);
|
|
102
|
-
this.dismiss();
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const data = JSON.parse(nativeEvent.data);
|
|
107
|
-
|
|
108
|
-
switch (data.action) {
|
|
109
|
-
case 'BootpayCancel':
|
|
110
|
-
if (this.props.onCancel != undefined) this.props.onCancel(data);
|
|
111
|
-
this.setState({
|
|
112
|
-
visibility: false
|
|
113
|
-
});
|
|
114
|
-
break;
|
|
115
|
-
|
|
116
|
-
case 'BootpayError':
|
|
117
|
-
if (this.props.onError != undefined) this.props.onError(data);
|
|
118
|
-
this.setState({
|
|
119
|
-
visibility: false
|
|
120
|
-
});
|
|
121
|
-
break;
|
|
122
|
-
|
|
123
|
-
case 'BootpayBankReady':
|
|
124
|
-
if (this.props.onReady != undefined) this.props.onReady(data);
|
|
125
|
-
break;
|
|
126
|
-
|
|
127
|
-
case 'BootpayConfirm':
|
|
128
|
-
if (this.props.onConfirm != undefined) this.props.onConfirm(data);
|
|
129
|
-
break;
|
|
130
|
-
|
|
131
|
-
case 'BootpayDone':
|
|
132
|
-
if (this.props.onDone != undefined) this.props.onDone(data);
|
|
133
|
-
this.setState({
|
|
134
|
-
visibility: false
|
|
135
|
-
});
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
_defineProperty(this, "onShouldStartLoadWithRequest", url => {
|
|
141
|
-
return true;
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
_defineProperty(this, "getBootpayPlatform", () => {
|
|
145
|
-
if (_reactNative.Platform.OS == 'ios') {
|
|
146
|
-
return "BootPay.setDevice('IOS');";
|
|
147
|
-
} else if (_reactNative.Platform.OS == 'android') {
|
|
148
|
-
return "BootPay.setDevice('ANDROID');";
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
_defineProperty(this, "transactionConfirm", data => {
|
|
153
|
-
// console.log('transactionConfirm: ' + data);
|
|
154
|
-
var json = JSON.stringify(data);
|
|
155
|
-
this.callJavaScript(`
|
|
156
|
-
BootPay.transactionConfirm(${json});
|
|
157
|
-
`);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
_defineProperty(this, "removePaymentWindow", () => {
|
|
161
|
-
this.callJavaScript(`
|
|
162
|
-
BootPay.removePaymentWindow();
|
|
163
|
-
`);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
_defineProperty(this, "callJavaScript", script => {
|
|
167
|
-
if (this.webView == null || this.webView == undefined) return; // console.log('callJavascript: ' + script);
|
|
168
|
-
|
|
169
|
-
this.webView.injectJavaScript(`
|
|
170
|
-
javascript:(function(){${script} })()
|
|
171
|
-
`); // this.webView.evalu
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
_defineProperty(this, "getAnalyticsData", async () => {
|
|
175
|
-
const uuid = await _UserInfo.default.getBootpayUUID();
|
|
176
|
-
const bootpaySK = await _UserInfo.default.getBootpaySK();
|
|
177
|
-
const bootLastTime = await _UserInfo.default.getBootpayLastTime();
|
|
178
|
-
const elaspedTime = Date.now() - bootLastTime;
|
|
179
|
-
return `window.BootPay.setAnalyticsData({uuid:'${uuid}',sk:'${bootpaySK}',sk_time:${bootLastTime},time:${elaspedTime}});`; // this.callJavaScript(`window.BootPay.setAnalyticsData({uuid:'${uuid}',sk:'${bootpaySK}',sk_time:${bootLastTime},time:${elaspedTime}});`);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// canGoBack() {
|
|
184
|
-
// console.log('canGoBack');
|
|
185
|
-
// if(this.webView.current) {
|
|
186
|
-
// return this.webView.current.canGoBack();
|
|
187
|
-
// }
|
|
188
|
-
// return false;
|
|
189
|
-
// }
|
|
190
|
-
// goBack() {
|
|
191
|
-
// console.log('GoBack');
|
|
192
|
-
// if(this.webView.goBack) {
|
|
193
|
-
// this.webView.current.goBack();
|
|
194
|
-
// }
|
|
195
|
-
// }
|
|
196
|
-
async componentWillUnmount() {
|
|
197
|
-
this.setState({
|
|
198
|
-
visibility: false,
|
|
199
|
-
firstLoad: false,
|
|
200
|
-
showCloseButton: false
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
_UserInfo.default.setBootpayLastTime(Date.now());
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
render() {
|
|
207
|
-
return /*#__PURE__*/_react.default.createElement(_reactNative.Modal, {
|
|
208
|
-
animationType: 'slide',
|
|
209
|
-
transparent: false // shouldCloseOnOverlayClick={true}
|
|
210
|
-
,
|
|
211
|
-
onRequestClose: () => {
|
|
212
|
-
console.log('onRequestClose');
|
|
213
|
-
this.dismiss();
|
|
214
|
-
},
|
|
215
|
-
visible: this.state.visibility
|
|
216
|
-
}, /*#__PURE__*/_react.default.createElement(_reactNative.SafeAreaView, {
|
|
217
|
-
style: {
|
|
218
|
-
flex: 1
|
|
219
|
-
}
|
|
220
|
-
}, this.state.showCloseButton && /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
|
|
221
|
-
onPress: () => {
|
|
222
|
-
var cancelData = {
|
|
223
|
-
action: 'BootpayCancel',
|
|
224
|
-
message: '사용자에 의해 취소되었습니다'
|
|
225
|
-
};
|
|
226
|
-
var closeData = {
|
|
227
|
-
action: 'BootpayClose',
|
|
228
|
-
message: '결제창이 닫혔습니다'
|
|
229
|
-
};
|
|
230
|
-
if (this.props.onCancel != undefined) this.props.onCancel(cancelData);
|
|
231
|
-
if (this.props.onClose != undefined) this.props.onClose(closeData);
|
|
232
|
-
this.setState({
|
|
233
|
-
visibility: false
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
}, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
|
|
237
|
-
style: [styles.overlay],
|
|
238
|
-
source: require('../images/close.png')
|
|
239
|
-
})), /*#__PURE__*/_react.default.createElement(_reactNativeWebviewBootpay.default, {
|
|
240
|
-
ref: wv => this.webView = wv // ref={btWebView}
|
|
241
|
-
,
|
|
242
|
-
useWebKit: true,
|
|
243
|
-
originWhitelist: ['*'],
|
|
244
|
-
source: {
|
|
245
|
-
uri: 'https://inapp.bootpay.co.kr/3.3.3/production.html'
|
|
246
|
-
},
|
|
247
|
-
injectedJavaScript: this.state.script,
|
|
248
|
-
javaScriptEnabled: true,
|
|
249
|
-
javaScriptCanOpenWindowsAutomatically: true // scalesPageToFit={true}
|
|
250
|
-
,
|
|
251
|
-
onMessage: this.onMessage,
|
|
252
|
-
onShouldStartLoadWithRequest: this.onShouldStartLoadWithRequest
|
|
253
|
-
})));
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
exports.BootpayWebView = BootpayWebView;
|
|
259
|
-
|
|
260
|
-
var styles = _reactNative.StyleSheet.create({
|
|
261
|
-
container: {
|
|
262
|
-
flex: 1,
|
|
263
|
-
justifyContent: 'center',
|
|
264
|
-
alignItems: 'center',
|
|
265
|
-
backgroundColor: '#F5FCFF'
|
|
266
|
-
},
|
|
267
|
-
welcome: {
|
|
268
|
-
fontSize: 20,
|
|
269
|
-
textAlign: 'center',
|
|
270
|
-
margin: 10
|
|
271
|
-
},
|
|
272
|
-
// Flex to fill, position absolute,
|
|
273
|
-
// Fixed left/top, and the width set to the window width
|
|
274
|
-
overlay: {
|
|
275
|
-
width: 25,
|
|
276
|
-
height: 25,
|
|
277
|
-
right: 5,
|
|
278
|
-
alignSelf: 'flex-end'
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
//# sourceMappingURL=BootpayWebView.js.map
|