react-native-bootpay-api 13.8.43 → 13.13.41

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.
@@ -1,136 +1,120 @@
1
-
2
- import {
3
- ViewProps,
4
- } from 'react-native'
1
+ import { ViewProps } from 'react-native';
5
2
 
6
3
  export interface BootpayTypesProps extends ViewProps {
7
- ref?: any
8
- ios_application_id?: string
9
- android_application_id?: string
10
- onCancel?: (data: Object) => void
11
- onError?: (data: Object) => void
12
- onIssued?: (data: Object) => void
13
- onConfirm?: (data: Object) => boolean
14
- onDone?: (data: Object) => void
15
- onClose?: () => void
4
+ ref?: any;
5
+ ios_application_id?: string;
6
+ android_application_id?: string;
7
+ onCancel?: (data: Object) => void;
8
+ onError?: (data: Object) => void;
9
+ onIssued?: (data: Object) => void;
10
+ onConfirm?: (data: Object) => boolean;
11
+ onDone?: (data: Object) => void;
12
+ onClose?: () => void;
16
13
  }
17
14
 
18
15
  export interface LoadingTypesProps extends ViewProps {
19
- loading?: boolean
16
+ loading?: boolean;
20
17
  }
21
18
 
22
-
23
-
24
-
25
19
  export class User {
26
- constructor() {}
27
-
28
- id?: string
29
- username?: string
30
- email?: string
31
- gender?: number
32
- birth?: string
33
- phone?: string
34
- area?: string
35
- addr?: string
20
+ id?: string;
21
+ username?: string;
22
+ email?: string;
23
+ gender?: number;
24
+ birth?: string;
25
+ phone?: string;
26
+ area?: string;
27
+ addr?: string;
28
+
29
+ constructor() {}
36
30
  }
37
31
 
38
32
  export class Item {
39
- constructor() {}
40
-
41
- name?: string
42
- qty?: number
43
- id?: string
44
- price?: number
45
- cat1?: string
46
- cat2?: string
47
- cat3?: string
33
+ name?: string;
34
+ qty?: number;
35
+ id?: string;
36
+ price?: number;
37
+ cat1?: string;
38
+ cat2?: string;
39
+ cat3?: string;
40
+
41
+ constructor() {}
48
42
  }
49
43
 
50
44
  export class StatItem {
51
- constructor() {}
52
-
53
- item_name?: string
54
- item_img?: string
55
- unique?: string
56
- price?: number
57
- cat1?: string
58
- cat2?: string
59
- cat3?: string
45
+ item_name?: string;
46
+ item_img?: string;
47
+ unique?: string;
48
+ price?: number;
49
+ cat1?: string;
50
+ cat2?: string;
51
+ cat3?: string;
52
+
53
+ constructor() {}
60
54
  }
61
55
 
62
- export class Onestore {
63
- constructor() {}
56
+ export class Onestore {
57
+ ad_id?: string = 'UNKNOWN_ADID';
58
+ sim_operator?: string = 'UNKNOWN_SIM_OPERATOR';
59
+ installer_package_name?: string = 'UNKNOWN_INSTALLER';
64
60
 
65
- ad_id?: string = "UNKNOWN_ADID"
66
- sim_operator?: string = "UNKNOWN_SIM_OPERATOR"
67
- installer_package_name?: string = "UNKNOWN_INSTALLER"
61
+ constructor() {}
68
62
  }
69
63
 
70
-
71
-
72
- // export interface Extra {
73
- // card_quota?: string;
74
- // seller_name?: string;
75
- // delivery_day?: number;
76
-
77
- // }
78
-
79
64
  export class Extra {
80
- constructor() {}
81
-
82
- card_quota?: string // 할부허용 범위 (5만원 이상 구매시)
83
- seller_name?: string //노출되는 판매자명 설정
84
- delivery_day?: number = 1 // 배송일자
85
- locale?: string = 'ko' //결제창 언어지원
86
- offer_period?: string //결제창 제공기간에 해당하는 string 값, 지원하는 PG만 적용됨
87
- display_cash_receipt?: boolean = true // 현금영수증 보일지 말지.. 가상계좌 KCP 옵션
88
- deposit_expiration?: string //가상계좌 입금 만료일자 설정
89
- app_scheme?: string // 모바일 앱에서 결제 완료 후 돌아오는 옵션 ( 아이폰만 적용 )
90
- use_card_point?: boolean = true //카드 포인트 사용 여부 (토스만 가능)
91
- direct_card?: string //해당 카드로 바로 결제창 (토스만 가능)
92
- use_order_id?: boolean = false //가맹점 order_id로 PG로 전송
93
- international_card_only?: boolean = false // 해외 결제카드 선택 여부 (토스만 가능)
94
- phone_carrier?: string = "" //본인인증 시 고정할 통신사명, SKT,KT,LGT 중 1개만 가능
95
- direct_app_card?: boolean = false // 카드사앱으로 direct 호출
96
- direct_samsungpay?: boolean = false // 삼성페이 바로 띄우기
97
- test_deposit?: boolean = false // 가상계좌 모의 입금
98
- enable_error_webhook?: boolean = false //결제 오류시 Feedback URL로 webhook
99
- separately_confirmed?: boolean = true // confirm 이벤트를 호출할지 말지, false일 경우 자동승인
100
- confirmOnlyRestApi?: boolean = false // REST API로만 승인 처리
101
- open_type?: string = 'redirect' // 페이지 오픈 type, [iframe, popup, redirect] 중 택 1
102
- use_bootpay_inapp_sdk?: boolean = true // native app에서는 redirect를 완성도있게 지원하기 위한 옵션
103
- redirect_url?: string = 'https://api.bootpay.co.kr/v2' //open_type이 redirect일 경우 페이지 이동할 URL ( 오류 및 결제 완료 모두 수신 가능 )
104
- display_success_result?: boolean = false // 결제 완료되면 부트페이가 제공하는 완료창으로 보여주기 ( open_type이 iframe, popup 일때만 가능 )
105
- display_error_result?: boolean = true // 결제 실패되면 부트페이가 제공하는 실패창으로 보여주기 ( open_type이 iframe, popup 일때만 가능 )
106
- disposable_cup_deposit?: number = 0 // 배달대행 플랫폼을 위한 컵 보증급 가격
107
- // ExtraCardEasyOption cardEasyOption = ExtraCardEasyOption();
108
- // List<BrowserOpenType>? browserOpenType = [];
109
- use_welcomepayment?: number = 0 //웰컴 재판모듈 진행시 1
110
- first_subscription_comment?: string = '' // 자동결제 price > 0 조건일 때 첫 결제 관련 메세지
111
- except_card_companies?: [string] // 제외할 카드사 리스트 ( enable_card_companies가 우선순위를 갖는다 )
112
- enable_easy_payments?: [string] // 노출될 간편결제 리스트
113
- confirm_grace_seconds?: number = 0 // 결제승인 유예시간 ( 승인 요청을 여러번하더라도 승인 이후 특정 시간동안 계속해서 결제 response_data 를 리턴한다 )
114
- show_close_button: boolean = false // x 닫기 버튼을 보여줄지 말지
65
+ card_quota?: string;
66
+ seller_name?: string;
67
+ delivery_day?: number = 1;
68
+ locale?: string = 'ko';
69
+ offer_period?: string;
70
+ display_cash_receipt?: boolean = true;
71
+ deposit_expiration?: string;
72
+ app_scheme?: string;
73
+ use_card_point?: boolean = true;
74
+ direct_card?: string;
75
+ use_order_id?: boolean = false;
76
+ international_card_only?: boolean = false;
77
+ phone_carrier?: string = '';
78
+ direct_app_card?: boolean = false;
79
+ direct_samsungpay?: boolean = false;
80
+ test_deposit?: boolean = false;
81
+ enable_error_webhook?: boolean = false;
82
+ separately_confirmed?: boolean = true;
83
+ confirmOnlyRestApi?: boolean = false;
84
+ open_type?: string = 'redirect';
85
+ use_bootpay_inapp_sdk?: boolean = true;
86
+ redirect_url?: string = 'https://api.bootpay.co.kr/v2';
87
+ display_success_result?: boolean = false;
88
+ display_error_result?: boolean = true;
89
+ disposable_cup_deposit?: number = 0;
90
+ use_welcomepayment?: number = 0;
91
+ first_subscription_comment?: string = '';
92
+ except_card_companies?: string[];
93
+ enable_easy_payments?: string[];
94
+ confirm_grace_seconds?: number = 0;
95
+ show_close_button?: boolean = false;
96
+
97
+ constructor() {}
115
98
  }
116
99
 
117
- export class Payload {
118
-
119
- application_id?: string
120
- android_application_id?: string
121
- ios_application_id?: string
122
- pg?: string
123
- method?: string
124
- methods?: [string]
125
- order_name?: string
126
- price?: number
127
- tax_free?: number
128
- order_id?: string
129
- subscription_id?: string
130
- authentication_id?: string
131
- metadata?: Object
132
- user_token?: string
133
- extra?: Extra
134
- user?: User
135
- items?: [Item]
136
- }
100
+ export class Payload {
101
+ application_id?: string;
102
+ android_application_id?: string;
103
+ ios_application_id?: string;
104
+ pg?: string;
105
+ method?: string;
106
+ methods?: string[];
107
+ order_name?: string;
108
+ price?: number;
109
+ tax_free?: number;
110
+ order_id?: string;
111
+ subscription_id?: string;
112
+ authentication_id?: string;
113
+ metadata?: Object;
114
+ user_token?: string;
115
+ extra?: Extra;
116
+ user?: User;
117
+ items?: Item[];
118
+
119
+ constructor() {}
120
+ }
package/src/UserInfo.ts CHANGED
@@ -1,79 +1,85 @@
1
- // import { Component } from 'react';
2
1
  import DeviceInfo from 'react-native-device-info';
3
- import SInfo from 'react-native-sensitive-info';
2
+ import * as Keychain from 'react-native-keychain';
4
3
 
5
- // export default class UserInfo extends Component {
6
- export default class UserInfo {
7
- static getBootpayInfo = (key: string, defaultVal: any) => {
8
- return new Promise((resolve, reject) => {
9
- SInfo.getItem(key, {
10
- sharedPreferencesName: 'bootpaySharedPrefs',
11
- keychainService: 'bootpayKeychain'
12
- }).then((res: any) => {
13
- res == undefined ? resolve(defaultVal) : resolve(res);
14
- resolve(res);
15
- }).catch((error: any) => {
16
- reject(error);
17
- });
18
- })
19
- }
4
+ export default class UserInfo {
5
+ static async setBootpayInfo(key: string, val: any): Promise<any> {
6
+ try {
7
+ await Keychain.setGenericPassword(key, String(val), {
8
+ service: key,
9
+ accessible: Keychain.ACCESSIBLE.WHEN_UNLOCKED, // 접근 가능 설정
10
+ });
11
+ return val;
12
+ } catch (error) {
13
+ console.error(`Error setting Bootpay info for key ${key}:`, error);
20
14
 
21
- static setBootpayInfo = (key: string, val: any) => {
22
- return new Promise((resolve, reject) => {
23
- SInfo.setItem(String(key), String(val), {
24
- sharedPreferencesName: 'bootpaySharedPrefs',
25
- keychainService: 'bootpayKeychain'
26
- }).then((res: any) => {
27
- resolve(res);
28
- }).catch((error: any) => {
29
- reject(error);
30
- });
31
- })
32
- }
15
+ // 특정 에러 코드에 따라 처리 (iOS와 Android 모두 고려)
16
+ if (error.message.includes('null is not an object')) {
17
+ console.warn('Keychain configuration or capability might be missing.');
18
+ }
33
19
 
34
- static getBootpayUUID = () => {
35
- let uuid = DeviceInfo.getUniqueId();
36
- return UserInfo.setBootpayInfo('uuid', uuid);
20
+ throw error;
37
21
  }
22
+ }
38
23
 
39
- static getBootpaySK = () => {
40
- return UserInfo.getBootpayInfo('bootpay_sk', '')
24
+ static async getBootpayInfo(key: string, defaultVal: string): Promise<any> {
25
+ try {
26
+ const credentials = await Keychain.getGenericPassword({ service: key });
27
+ if (credentials) {
28
+ return credentials.password;
29
+ } else {
30
+ return defaultVal;
31
+ }
32
+ } catch (error) {
33
+ console.error(`Error getting Bootpay info for key ${key}:`, error);
34
+ return defaultVal;
41
35
  }
36
+ }
42
37
 
43
- static setBootpaySK = (val: string) => {
44
- return UserInfo.setBootpayInfo('bootpay_sk', val)
45
- }
38
+ static async getBootpayUUID(): Promise<string> {
39
+ const uuid = DeviceInfo.getUniqueId();
40
+ await UserInfo.setBootpayInfo('uuid', uuid);
41
+ return uuid;
42
+ }
46
43
 
47
- static newBootpaySK = (uuid: string, time: number) => {
48
- return UserInfo.setBootpaySK(`${uuid}_${time}`);
49
- }
44
+ static async getBootpaySK(): Promise<string> {
45
+ return await UserInfo.getBootpayInfo('bootpay_sk', '');
46
+ }
50
47
 
51
- static getBootpayLastTime = async () => {
52
- return await UserInfo.getBootpayInfo('bootpay_last_time', 0) as number
53
- }
48
+ static async setBootpaySK(val: string): Promise<any> {
49
+ return await UserInfo.setBootpayInfo('bootpay_sk', val);
50
+ }
54
51
 
55
- static setBootpayLastTime(val: number){
56
- return UserInfo.setBootpayInfo('bootpay_last_time', val);
57
- }
52
+ static async newBootpaySK(uuid: string, time: number): Promise<any> {
53
+ return await UserInfo.setBootpaySK(`${uuid}_${time}`);
54
+ }
58
55
 
59
- static getBootpayUserId() {
60
- return UserInfo.getBootpayInfo('bootpay_user_id', '');
61
- }
56
+ static async getBootpayLastTime(): Promise<number> {
57
+ const lastTime = await UserInfo.getBootpayInfo('bootpay_last_time', '0');
58
+ return parseInt(lastTime, 10);
59
+ }
62
60
 
63
- static setBootpayUserId = (val: string) => {
64
- return UserInfo.setBootpayInfo('bootpay_user_id', val);
65
- }
61
+ static async setBootpayLastTime(val: number): Promise<any> {
62
+ return await UserInfo.setBootpayInfo('bootpay_last_time', String(val));
63
+ }
66
64
 
67
- static updateInfo = async () => {
68
- const uuid = await UserInfo.getBootpayUUID() as string;
69
- const bootpaySK = await UserInfo.getBootpaySK() as string;
70
- const lastTime = await UserInfo.getBootpayLastTime();
65
+ static async getBootpayUserId(): Promise<string> {
66
+ return await UserInfo.getBootpayInfo('bootpay_user_id', '');
67
+ }
71
68
 
72
- let current = Date.now();
69
+ static async setBootpayUserId(val: string): Promise<any> {
70
+ return await UserInfo.setBootpayInfo('bootpay_user_id', val);
71
+ }
73
72
 
74
- if(bootpaySK == '') await UserInfo.newBootpaySK(uuid, current);
75
- const isExpired = current - lastTime > 30 * 60 * 1000;
76
- if(isExpired) await UserInfo.newBootpaySK(uuid, current);
77
- await UserInfo.setBootpayLastTime(current);
78
- }
79
- }
73
+ static async updateInfo(): Promise<void> {
74
+ const uuid = await UserInfo.getBootpayUUID();
75
+ const bootpaySK = await UserInfo.getBootpaySK();
76
+ const lastTime = await UserInfo.getBootpayLastTime();
77
+ const current = Date.now();
78
+
79
+ if (!bootpaySK) await UserInfo.newBootpaySK(uuid, current);
80
+ const isExpired = current - lastTime > 30 * 60 * 1000;
81
+ if (isExpired) await UserInfo.newBootpaySK(uuid, current);
82
+
83
+ await UserInfo.setBootpayLastTime(current);
84
+ }
85
+ }
@@ -41,88 +41,192 @@ const stringToHex = (str: string): string => {
41
41
  };
42
42
 
43
43
  // userTrace 함수의 반환 타입을 명시
44
- const userTrace = async (applicationId: string, userId: string, phone: string, email: string, gender: string, birth: string, area: string): Promise<any> => {
44
+ const userTrace = async (
45
+ applicationId: string,
46
+ userId: string,
47
+ phone: string,
48
+ email: string,
49
+ gender: string,
50
+ birth: string,
51
+ area: string
52
+ ): Promise<any> => {
45
53
  try {
46
54
  const payload = {
47
- "id": userId,
48
- "ver": DeviceInfo.getVersion(),
49
- "application_id": applicationId,
50
- "phone": phone,
51
- "email": email,
52
- "gender": gender,
53
- "birth": birth,
54
- "area": area,
55
+ id: userId,
56
+ ver: DeviceInfo.getVersion(),
57
+ application_id: applicationId,
58
+ phone: phone,
59
+ email: email,
60
+ gender: gender,
61
+ birth: birth,
62
+ area: area,
55
63
  };
56
64
 
57
- var key = getRandomKey(32);
58
- var iv = getRandomKey(16);
65
+ const key = getRandomKey(32);
66
+ const iv = getRandomKey(16);
59
67
 
60
68
  try {
61
- const data = await NativeModules.Aes.encrypt(JSON.stringify(payload), stringToHex(key), stringToHex(iv));
62
- const response = await fetch(
63
- 'https://analytics.bootpay.co.kr/login',
64
- {
65
- method: 'POST',
66
- headers: {
67
- Accept: 'application/json',
68
- 'Content-Type': 'application/json'
69
- },
70
- body: JSON.stringify({
71
- data: data,
72
- session_key: await getSessionKey(key, iv)
73
- })
74
- }
69
+ const data = await NativeModules.Aes.encrypt(
70
+ JSON.stringify(payload),
71
+ stringToHex(key),
72
+ stringToHex(iv)
75
73
  );
74
+
75
+ const response = await fetch('https://analytics.bootpay.co.kr/login', {
76
+ method: 'POST',
77
+ headers: {
78
+ 'Accept': 'application/json',
79
+ 'Content-Type': 'application/json',
80
+ },
81
+ body: JSON.stringify({
82
+ data: data,
83
+ session_key: await getSessionKey(key, iv),
84
+ }),
85
+ });
86
+
76
87
  const json = await response.json();
77
88
  return json;
78
89
  } catch (e) {
79
90
  console.log(e);
91
+ throw e;
80
92
  }
81
93
  } catch (error) {
82
94
  console.error(error);
95
+ throw error;
83
96
  }
84
97
  };
85
98
 
99
+ // const userTrace = async (applicationId: string, userId: string, phone: string, email: string, gender: string, birth: string, area: string): Promise<any> => {
100
+ // try {
101
+ // const payload = {
102
+ // id: userId,
103
+ // ver: DeviceInfo.getVersion(),
104
+ // application_id: applicationId,
105
+ // phone: phone,
106
+ // email: email,
107
+ // gender: gender,
108
+ // birth: birth,
109
+ // area: area,
110
+ // };
111
+
112
+ // var key = getRandomKey(32);
113
+ // var iv = getRandomKey(16);
114
+
115
+ // try {
116
+ // const data = await NativeModules.Aes.encrypt(JSON.stringify(payload), stringToHex(key), stringToHex(iv));
117
+ // const response = await fetch(
118
+ // 'https://analytics.bootpay.co.kr/login',
119
+ // {
120
+ // method: 'POST',
121
+ // headers: {
122
+ // Accept: 'application/json',
123
+ // 'Content-Type': 'application/json'
124
+ // },
125
+ // body: JSON.stringify({
126
+ // data: data,
127
+ // session_key: await getSessionKey(key, iv)
128
+ // })
129
+ // }
130
+ // );
131
+ // const json = await response.json();
132
+ // return json;
133
+ // } catch (e) {
134
+ // console.log(e);
135
+ // }
136
+ // } catch (error) {
137
+ // console.error(error);
138
+ // }
139
+ // };
140
+
86
141
  // pageTrace 함수의 반환 타입을 명시
87
- const pageTrace = async (applicationId: string, url: string, pageType: string, items: any): Promise<any> => {
142
+ const pageTrace = async (
143
+ applicationId: string,
144
+ url: string,
145
+ pageType: string,
146
+ items: any
147
+ ): Promise<any> => {
88
148
  try {
89
149
  const payload = {
90
- "application_id": applicationId,
91
- "url": url,
92
- "page_type": pageType,
93
- "items": items,
94
- "referer": '',
150
+ application_id: applicationId,
151
+ url: url,
152
+ page_type: pageType,
153
+ items: items,
154
+ referer: '',
95
155
  };
96
156
 
97
- var key = getRandomKey(32);
98
- var iv = getRandomKey(16);
157
+ const key = getRandomKey(32);
158
+ const iv = getRandomKey(16);
99
159
 
100
160
  try {
101
- const data = await NativeModules.Aes.encrypt(JSON.stringify(payload), stringToHex(key), stringToHex(iv));
102
- const response = await fetch(
103
- 'https://analytics.bootpay.co.kr/call',
104
- {
105
- method: 'POST',
106
- headers: {
107
- Accept: 'application/json',
108
- 'Content-Type': 'application/json'
109
- },
110
- body: JSON.stringify({
111
- data: data,
112
- session_key: await getSessionKey(key, iv)
113
- })
114
- }
161
+ const data = await NativeModules.Aes.encrypt(
162
+ JSON.stringify(payload),
163
+ stringToHex(key),
164
+ stringToHex(iv)
115
165
  );
166
+
167
+ const response = await fetch('https://analytics.bootpay.co.kr/call', {
168
+ method: 'POST',
169
+ headers: {
170
+ 'Accept': 'application/json',
171
+ 'Content-Type': 'application/json',
172
+ },
173
+ body: JSON.stringify({
174
+ data: data,
175
+ session_key: await getSessionKey(key, iv),
176
+ }),
177
+ });
178
+
116
179
  const json = await response.json();
117
180
  return json;
118
181
  } catch (e) {
119
182
  console.log(e);
183
+ throw e;
120
184
  }
121
185
  } catch (error) {
122
186
  console.error(error);
187
+ throw error;
123
188
  }
124
189
  };
125
190
 
191
+ // const pageTrace = async (applicationId: string, url: string, pageType: string, items: any): Promise<any> => {
192
+ // try {
193
+ // const payload = {
194
+ // "application_id": applicationId,
195
+ // "url": url,
196
+ // "page_type": pageType,
197
+ // "items": items,
198
+ // "referer": '',
199
+ // };
200
+
201
+ // var key = getRandomKey(32);
202
+ // var iv = getRandomKey(16);
203
+
204
+ // try {
205
+ // const data = await NativeModules.Aes.encrypt(JSON.stringify(payload), stringToHex(key), stringToHex(iv));
206
+ // const response = await fetch(
207
+ // 'https://analytics.bootpay.co.kr/call',
208
+ // {
209
+ // method: 'POST',
210
+ // headers: {
211
+ // Accept: 'application/json',
212
+ // 'Content-Type': 'application/json'
213
+ // },
214
+ // body: JSON.stringify({
215
+ // data: data,
216
+ // session_key: await getSessionKey(key, iv)
217
+ // })
218
+ // }
219
+ // );
220
+ // const json = await response.json();
221
+ // return json;
222
+ // } catch (e) {
223
+ // console.log(e);
224
+ // }
225
+ // } catch (error) {
226
+ // console.error(error);
227
+ // }
228
+ // };
229
+
126
230
  // strEncode 함수의 반환 타입을 명시
127
231
  // const strEncode = async (str: string, key: string, iv: string): Promise<string> => {
128
232
  // return await NativeModules.Aes.encrypt(str, key, iv).then(cipher => {
package/src/index.tsx CHANGED
@@ -1,9 +1,4 @@
1
- import { Bootpay } from './Bootpay'
2
- import { Payload, Extra, Item, User } from './BootpayTypes'
3
- // import { userTrace, pageTrace } from './BootpayAnalytics'
1
+ import { Bootpay } from './Bootpay';
2
+ import { Payload, Extra, Item, User } from './BootpayTypes';
4
3
 
5
- // import { WebView } from 'react-native-bootpay-api';
6
-
7
- export { Bootpay, Payload, Extra, Item, User };
8
-
9
- // export { BootpayModal, userTrace, pageTrace };
4
+ export { Bootpay, Payload, Extra, Item, User };