-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx.bak
More file actions
319 lines (268 loc) · 11.3 KB
/
App.tsx.bak
File metadata and controls
319 lines (268 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
import React, { useRef, useState } from 'react';
import {
StyleSheet,
View,
Text,
TouchableOpacity
} from 'react-native';
import { Bootpay, Extra, User } from 'react-native-bootpay-api';
import WebView from 'react-native-webview-bootpay';
import StandardWebView from 'react-native-webview';
export default function App() {
const bootpay = useRef<Bootpay>(null);
const [showWebView, setShowWebView] = useState(false);
const [webViewType, setWebViewType] = useState<'standard' | 'bootpay'>('standard');
const goBootpayTest = () => {
const payload = {
pg: '나이스페이', //['kcp', 'danal', 'inicis', 'nicepay', 'lgup', 'toss', 'payapp', 'easypay', 'jtnet', 'tpay', 'mobilians', 'payletter', 'onestore', 'welcome'] 중 택 1
method: '카드 ', // ['카드', '휴대폰', '계좌이체', '가상계좌', '카카오페이', '네이버페이', '페이코', '카드자동'] 중 택 1
order_name: '마스카라', //결제창에 보여질 상품명
order_id: '1234_1234', //개발사에 관리하는 주문번호
// subscription_id: '12345_21345', //개발사에 관리하는 주문번호 (정기결제용)
// authentication_id: '12345_21345', //개발사에 관리하는 주문번호 (본인인증용)
// method: 'card',
// methods: ['card', 'vbank', 'bank', 'phone'], // 통합결제창 진행시 사용하고자 하는 결제수단 지정 가능, method와 함께 적용 불가
price: 1000, //결제금액
// taxFree: 0, //면세금액
}
//결제되는 상품정보들로 통계에 사용되며, price의 합은 결제금액과 동일해야함
const items = [
{
name: '키보드', //통계에 반영될 상품명
qty: 1, //수량
id: 'ITEM_CODE_KEYBOARD', //개발사에서 관리하는 상품고유번호
price: 1000, //상품단가
cat1: '패션', //카테고리 상 , 자유롭게 기술
cat2: '여성상의', //카테고리 중, 자유롭게 기술
cat3: '블라우스', //카테고리 하, 자유롭게 기술
}
]
//구매자 정보로 결제창이 미리 적용될 수 있으며, 통계에도 사용되는 정보
const user = {
id: 'user_id_1234', //개발사에서 관리하는 회원고유번호
username: '홍길동', //구매자명
email: 'user1234@gmail.com', //구매자 이메일
gender: 0, //성별, 1:남자 , 0:여자
birth: '1986-10-14', //생년월일 yyyy-MM-dd
phone: '01012345678', //전화번호, 페이앱 필수
area: '서울', // [서울,인천,대구,광주,부산,울산,경기,강원,충청북도,충북,충청남도,충남,전라북도,전북,전라남도,전남,경상북도,경북,경상남도,경남,제주,세종,대전] 중 택 1
addr: '서울시 동작구 상도로' //주소
}
// let extra1 = new Extra();
// extra1.
// const user = new User();
// user.id = 'user_id_1234';
// user.email = 'tes2t@bootpay.co.kr';
//기타 설정
const extra = {
card_quota: "0,2,3", //결제금액이 5만원 이상시 할부개월 허용범위를 설정할 수 있음, [0(일시불), 2개월, 3개월] 허용, 미설정시 12개월까지 허용
app_scheme: "bootpayrnapi", //ios의 경우 카드사 앱 호출 후 되돌아오기 위한 앱 스키마명
show_close_button: true, // x 닫기 버튼 삽입 (닫기버튼이 없는 PG사를 위한 옵션)
}
// const extra = new Extra();
// extra.app_scheme = "bootpayrnapi2";
if(bootpay != null && bootpay.current != null) bootpay.current.requestPayment(payload, items, user, extra);
}
const goBootpaySubscriptionTest = () => {
const payload = {
pg: '나이스페이', //['kcp', 'danal', 'inicis', 'nicepay', 'lgup', 'toss', 'payapp', 'easypay', 'jtnet', 'tpay', 'mobilians', 'payletter', 'onestore', 'welcome'] 중 택 1
method: '카드자동', // ['카드', '휴대폰', '계좌이체', '가상계좌', '카카오페이', '네이버페이', '페이코', '카드자동'] 중 택 1
order_name: '마스카라', //결제창에 보여질 상품명
// order_id: '1234_1234', //개발사에 관리하는 주문번호
subscription_id: '12345_21345', //개발사에 관리하는 주문번호 (카드자동결제용)
// authentication_id: '12345_21345', //개발사에 관리하는 주문번호 (본인인증용)
// method: 'card',
// methods: ['card', 'vbank', 'bank', 'phone'], // 통합결제창 진행시 사용하고자 하는 결제수단 지정 가능, method와 함께 적용 불가
price: 1000, //결제금액
// taxFree: 0, //면세금액
}
//결제되는 상품정보들로 통계에 사용되며, price의 합은 결제금액과 동일해야함
const items = [
{
name: '키보드2', //통계에 반영될 상품명
qty: 1, //수량
id: 'ITEM_CODE_KEYBOARD', //개발사에서 관리하는 상품고유번호
price: 1000, //상품단가
cat1: '패션', //카테고리 상 , 자유롭게 기술
cat2: '여성상의', //카테고리 중, 자유롭게 기술
cat3: '블라우스', //카테고리 하, 자유롭게 기술
}
]
//구매자 정보로 결제창이 미리 적용될 수 있으며, 통계에도 사용되는 정보
const user = {
id: 'user_id_1234', //개발사에서 관리하는 회원고유번호
username: '홍길동', //구매자명
email: 'user1234@gmail.com', //구매자 이메일
gender: 0, //성별, 1:남자 , 0:여자
birth: '1986-10-14', //생년월일 yyyy-MM-dd
phone: '01012345678', //전화번호, 페이앱 필수
area: '서울', // [서울,인천,대구,광주,부산,울산,경기,강원,충청북도,충북,충청남도,충남,전라북도,전북,전라남도,전남,경상북도,경북,경상남도,경남,제주,세종,대전] 중 택 1
addr: '서울시 동작구 상도로' //주소
}
// use
//기타 설정
const extra = {
card_quota: "0,2,3", //결제금액이 5만원 이상시 할부개월 허용범위를 설정할 수 있음, [0(일시불), 2개월, 3개월] 허용, 미설정시 12개월까지 허용
app_scheme: "bootpayrnapi", //ios의 경우 카드사 앱 호출 후 되돌아오기 위한 앱 스키마명
show_close_button: false, // x 닫기 버튼 삽입 (닫기버튼이 없는 PG사를 위한 옵션)
}
if(bootpay != null && bootpay.current != null) bootpay.current.requestSubscription(payload, items, user, extra);
}
const goBootpayAuthTest = () => {
const payload = {
pg: '다날', //['kcp', 'danal', 'inicis', 'nicepay', 'lgup', 'toss', 'payapp', 'easypay', 'jtnet', 'tpay', 'mobilians', 'payletter', 'onestore', 'welcome'] 중 택 1
method: '본인인증',
order_name: '마스카라', //본인인증 명
// order_id: '1234_1234', //개발사에 관리하는 주문번호
// subscription_id: '12345_21345', //개발사에 관리하는 주문번호 (정기결제용)
authentication_id: '12345_21345', //개발사에 관리하는 주문번호 (본인인증용)
// method: 'card',
// methods: ['card', 'vbank', 'bank', 'phone'], // 통합결제창 진행시 사용하고자 하는 결제수단 지정 가능, method와 함께 적용 불가
// price: 1000, //결제금액
// taxFree: 0, //면세금액
}
//기타 설정
const extra = {
app_scheme: "bootpayrnapi", //ios의 경우 카드사 앱 호출 후 되돌아오기 위한 앱 스키마명
show_close_button: false, // x 닫기 버튼 삽입 (닫기버튼이 없는 PG사를 위한 옵션)
}
// const extra = new Extra();
if(bootpay != null && bootpay.current != null) bootpay.current.requestAuthentication(payload, [], {}, extra);
}
const onCancel = (data: Object) => {
console.log('-- cancel', data);
}
const onError = (data: Object) => {
console.log('-- error', data);
}
const onIssued = (data: Object) => {
console.log('-- issued', data);
}
const onConfirm = (data: Object) => {
console.log('-- confirm', data);
// if(bootpay != null && bootpay.current != null) bootpay.current.transactionConfirm(data); //
return true
}
const onDone = (data: Object) => {
console.log('-- done', data);
}
const onClose = () => {
console.log('-- closed');
}
// WebView 테스트 함수 추가
const showStandardWebView = () => {
setWebViewType('standard');
setShowWebView(true);
}
const showBootpayWebView = () => {
setWebViewType('bootpay');
setShowWebView(true);
}
const hideWebView = () => {
setShowWebView(false);
}
// React.useEffect(() => {
// BootpayApi.multiply(3, 7).then(setResult);
// }, []);
return (
<View style={styles.container}>
<TouchableOpacity
style={styles.button}
onPress={goBootpayTest}
>
<Text>일반결제 결제테스트</Text>
</TouchableOpacity>
<Bootpay
ref={bootpay}
ios_application_id={'5b8f6a4d396fa665fdc2b5e9'}
android_application_id={'5b8f6a4d396fa665fdc2b5e8'}
// ios_application_id={'5b9f51264457636ab9a07cdd'}
// android_application_id={'5b9f51264457636ab9a07cdc'}
onCancel={onCancel}
onError={onError}
onIssued={onIssued}
onConfirm={onConfirm}
onDone={onDone}
onClose={onClose}
/>
<TouchableOpacity
style={styles.button}
onPress={goBootpaySubscriptionTest}
>
<Text>정기결제 테스트</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.button}
onPress={goBootpayAuthTest}
>
<Text>본인인증 테스트</Text>
</TouchableOpacity>
{/* WebView 테스트 버튼 추가 */}
<TouchableOpacity
style={styles.button}
onPress={showStandardWebView}
>
<Text>일반 WebView 테스트</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.button}
onPress={showBootpayWebView}
>
<Text>부트페이 WebView 테스트</Text>
</TouchableOpacity>
{/* WebView 표시 영역 */}
{showWebView && (
<View style={styles.webViewContainer}>
<TouchableOpacity
style={styles.closeButton}
onPress={hideWebView}
>
<Text>WebView 닫기</Text>
</TouchableOpacity>
{webViewType === 'standard' ? (
<StandardWebView
style={styles.webView}
source={{ uri: 'https://bootpay.co.kr' }}
/>
) : (
<WebView
style={styles.webView}
source={{ uri: 'https://bootpay.co.kr' }}
/>
)}
</View>
)}
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
button: {
alignItems: "center",
backgroundColor: "#DDDDDD",
padding: 10,
margin: 10,
},
webViewContainer: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: 'white',
zIndex: 999,
},
webView: {
flex: 1,
},
closeButton: {
alignItems: "center",
backgroundColor: "#FF5555",
padding: 10,
margin: 10,
},
});