react-native-bootpay-api 1.5.2 → 4.0.0-beta.2

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": "1.5.2",
3
+ "version": "4.0.0-beta.2",
4
4
  "description": "React Native를 위한 bootpay 라이브러리 입니다.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -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://inapp.bootpay.co.kr/3.3.3/production.html'
84
+ uri: 'https://webview.bootpay.co.kr/4.0.0/'
83
85
  }}
84
86
  onRequestClose={()=> {
85
87
  console.log('onRequestClose');
@@ -97,39 +99,42 @@ export class BootpayWebView extends Component {
97
99
  </Modal>
98
100
  }
99
101
 
100
- request = async (payload, items, user, extra) => {
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(
119
123
  {
120
124
  visibility: true,
121
125
  script: `
122
- ${await this.getMountJavascript()}
123
- ${quickPopup}
124
- ${this.generateScript(payload)}
126
+ ${await this.getMountJavascript()}
127
+ ${this.generateScript(payload, requestMethod)}
125
128
  `,
126
129
  firstLoad: false,
127
130
  showCloseButton: extra.show_close_button || false
128
131
  }
129
132
  )
130
133
 
131
- UserInfo.updateInfo();
134
+ UserInfo.updateInfo();
132
135
  }
136
+
137
+
133
138
 
134
139
  dismiss = () => {
135
140
  this.setState(
@@ -149,15 +154,19 @@ export class BootpayWebView extends Component {
149
154
  }
150
155
 
151
156
 
152
- generateScript= (payload) => {
153
- const onError = '.error(function(data){ window.BootpayRNWebView.postMessage( JSON.stringify(data) ); })';
154
- const onCancel = '.cancel(function(data){ window.BootpayRNWebView.postMessage( JSON.stringify(data) ); })';
155
- const onReady = '.ready(function(data){ window.BootpayRNWebView.postMessage( JSON.stringify(data) ); })';
156
- const onConfirm = '.confirm(function(data){ window.BootpayRNWebView.postMessage( JSON.stringify(data) ); })';
157
- const onClose = '.close(function(data){ window.BootpayRNWebView.postMessage("close"); })';
158
- const onDone = '.done(function(data){ window.BootpayRNWebView.postMessage( JSON.stringify(data) ); })';
157
+ generateScript= (payload, requestMethod) => {
158
+ const script = "Bootpay." + requestMethod +
159
+ `(${JSON.stringify(payload)})` +
160
+ ".then( function (res) {" +
161
+ this.confirm() +
162
+ this.issued() +
163
+ this.done() +
164
+ "}, function (res) {" +
165
+ this.error() +
166
+ this.cancel() +
167
+ "})";
159
168
 
160
- return `BootPay.request(${JSON.stringify(payload)})` + onError + onCancel + onReady + onConfirm + onClose + onDone + '; void(0);';
169
+ this.callJavaScript(script);
161
170
  }
162
171
 
163
172
  onMessage = ({ nativeEvent }) => {
@@ -169,42 +178,47 @@ export class BootpayWebView extends Component {
169
178
  action: 'BootpayClose',
170
179
  message: '결제창이 닫혔습니다'
171
180
  }
181
+ this.setState(
182
+ {
183
+ visibility: false
184
+ }
185
+ )
172
186
  this.props.onClose(json);
173
187
  this.dismiss();
174
188
  return;
175
189
  }
176
190
 
177
191
  const data = JSON.parse(nativeEvent.data);
178
- switch (data.action) {
179
- case 'BootpayCancel':
192
+ switch (data.event) {
193
+ case 'cancel':
180
194
  if(this.props.onCancel != undefined) this.props.onCancel(data);
181
- this.setState(
182
- {
183
- visibility: false
184
- }
185
- )
195
+ // this.setState(
196
+ // {
197
+ // visibility: false
198
+ // }
199
+ // )
186
200
  break;
187
- case 'BootpayError':
201
+ case 'error':
188
202
  if(this.props.onError != undefined) this.props.onError(data);
189
- this.setState(
190
- {
191
- visibility: false
192
- }
193
- )
203
+ // this.setState(
204
+ // {
205
+ // visibility: false
206
+ // }
207
+ // )
194
208
  break;
195
- case 'BootpayBankReady':
209
+ case 'issued':
196
210
  if(this.props.onReady != undefined) this.props.onReady(data);
197
211
  break;
198
- case 'BootpayConfirm':
212
+ case 'confirm':
199
213
  if(this.props.onConfirm != undefined) this.props.onConfirm(data);
200
214
  break;
201
- case 'BootpayDone':
215
+ case 'done':
202
216
  if(this.props.onDone != undefined) this.props.onDone(data);
203
- this.setState(
204
- {
205
- visibility: false
206
- }
207
- )
217
+ // this.setState(
218
+ // {
219
+ // visibility: false
220
+ // }
221
+ // )
208
222
  break;
209
223
  }
210
224
  }
@@ -215,9 +229,9 @@ export class BootpayWebView extends Component {
215
229
 
216
230
  getBootpayPlatform = () => {
217
231
  if(Platform.OS == 'ios') {
218
- return "BootPay.setDevice('IOS');";
232
+ return "Bootpay.setDevice('IOS');";
219
233
  } else if(Platform.OS == 'android'){
220
- return "BootPay.setDevice('ANDROID');";
234
+ return "Bootpay.setDevice('ANDROID');";
221
235
  }
222
236
  }
223
237
 
@@ -230,18 +244,23 @@ export class BootpayWebView extends Component {
230
244
  // }
231
245
  // }
232
246
 
233
- transactionConfirm = (data) => {
234
- // console.log('transactionConfirm: ' + data);
235
-
236
- var json = JSON.stringify(data)
237
- this.callJavaScript(`
238
- BootPay.transactionConfirm(${json});
239
- `);
247
+ transactionConfirm = () => {
248
+ const script = "Bootpay.confirm()" +
249
+ ".then( function (res) {" +
250
+ this.confirm() +
251
+ this.issued() +
252
+ this.done() +
253
+ "}, function (res) {" +
254
+ this.error() +
255
+ this.cancel() +
256
+ "})";
257
+
258
+ this.callJavaScript(script);
240
259
  }
241
260
 
242
261
  removePaymentWindow = () => {
243
262
  this.callJavaScript(`
244
- BootPay.removePaymentWindow();
263
+ Bootpay.removePaymentWindow();
245
264
  `);
246
265
  }
247
266
 
@@ -258,14 +277,38 @@ export class BootpayWebView extends Component {
258
277
 
259
278
  getAnalyticsData = async () => {
260
279
  const uuid = await UserInfo.getBootpayUUID();
261
- const bootpaySK = await UserInfo.getBootpaySK();
280
+ // const bootpaySK = await UserInfo.getBootpaySK();
262
281
  const bootLastTime = await UserInfo.getBootpayLastTime();
263
282
 
264
283
 
265
284
  const elaspedTime = Date.now() - bootLastTime;
266
- return `window.BootPay.setAnalyticsData({uuid:'${uuid}',sk:'${bootpaySK}',sk_time:${bootLastTime},time:${elaspedTime}});`;
285
+ return `window.Bootpay.$analytics.setAnalyticsData({uuid:'${uuid}', time:${elaspedTime}});`;
267
286
  // this.callJavaScript(`window.BootPay.setAnalyticsData({uuid:'${uuid}',sk:'${bootpaySK}',sk_time:${bootLastTime},time:${elaspedTime}});`);
268
287
  }
288
+
289
+ confirm = () => {
290
+ return "if (res.event === 'confirm') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
291
+ }
292
+
293
+ done = () => {
294
+ return "else if (res.event === 'done') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
295
+ }
296
+
297
+ issued = () => {
298
+ return "else if (res.event === 'issued') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
299
+ }
300
+
301
+ error = () => {
302
+ return "if (res.event === 'error') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
303
+ }
304
+
305
+ cancel = () => {
306
+ return "else if (res.event === 'cancel') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
307
+ }
308
+
309
+ close = () => {
310
+ return "document.addEventListener('bootpayclose', function (e) { window.BootpayRNWebView.postMessage('close'); });";
311
+ }
269
312
  }
270
313
 
271
314
 
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,MAAtB,EAA8BC,KAA9B,EAAqCC,KAArC,EAA4CC,MAA5C,EAAoDC,KAApD,EAA2DC,IAA3D,KAAoE;AAClF,MAAI;AACA,UAAMC,OAAO,GAAG;AACZ,YAAMN,MADM;AAEZ,aAAOO,+BAAWC,UAAX,EAFK;AAGZ,wBAAkBT,aAHN;AAIZ,eAASE,KAJG;AAKZ,eAASC,KALG;AAMZ,gBAAUC,MANE;AAOZ,eAASC,KAPG;AAQZ,cAAQC;AARI,KAAhB;AAWA,QAAII,GAAG,GAAGC,YAAY,CAAC,EAAD,CAAtB;AACA,QAAIC,EAAE,GAAGD,YAAY,CAAC,EAAD,CAArB;;AAEA,QAAI;AACA,YAAME,IAAI,GAAG,MAA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;;AAEA,OAAK,IAAIN,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGE,MAApB,EAA4BF,CAAC,EAA7B,EACIK,IAAI,IAAIC,IAAI,CAACC,MAAL,CAAYC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,MAAL,KAAgBJ,IAAI,CAACJ,MAAhC,CAAZ,CAAR;;AAEJ,SAAOG,IAAP;AACH,CARD;;AAWA,MAAMjB,aAAa,GAAG,OAAOjB,GAAP,EAAYE,EAAZ,KAAmB;AACrC,QAAMsC,QAAQ,GAAGC,yBAAOC,MAAP,CAAc1C,GAAd,CAAjB;;AACA,QAAM2C,OAAO,GAAGF,yBAAOC,MAAP,CAAcxC,EAAd,CAAhB;;AAEA,SAAQ,GAAEsC,QAAS,KAAIG,OAAQ,EAA/B;AACH,CALD;;AAOA,MAAMC,SAAS,GAAG,OAAOjB,GAAP,EAAY3B,GAAZ,EAAiBE,EAAjB,KAAwB;AACtC,SAAO,MAAMf,GAAG,CAACiB,OAAJ,CAAYuB,GAAZ,EAAiB3B,GAAjB,EAAsBE,EAAtB,EAA0BM,IAA1B,CAA+BC,MAAM,IAAI;AAClDtB,IAAAA,GAAG,CAAC0D,OAAJ,CAAYpC,MAAZ,EAAoBT,GAApB,EAAyBQ,IAAzB,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"]}