@bootpay/client-js 5.0.0-beta.9 → 5.0.0-rc.1

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,369 +0,0 @@
1
- const pgs = {
2
- KRW: [
3
- '이니시스', '다날', '케이씨피', '나이스페이', '토스', '페이레터', '페이앱', '이지페이', '페이코', '카카오', '세틀뱅크', '티페이',
4
- '웰컴페이먼츠', '스마트로'
5
- ],
6
- USD: [
7
- '페이팔', '스트라이프'
8
- ]
9
- }
10
-
11
- const LEGACY_MAPPER_PG = {
12
- '이니시스': 'inicis',
13
- '다날': 'danal',
14
- '케이씨피': 'kcp',
15
- '나이스페이': 'nicepay',
16
- '토스': 'toss',
17
- '페이레터': 'payletter',
18
- '페이앱': 'payapp',
19
- '이지페이': 'easypay',
20
- '페이코': 'payco',
21
- '카카오': 'kakao',
22
- '세틀뱅크': 'settlebank',
23
- '티페이': 'tpay',
24
- '웰컴페이먼츠': 'welcome',
25
- '스마트로': 'smartro'
26
- }
27
-
28
- const LEGACY_MAPPER_METHOD = {
29
- '카드': 'card',
30
- '휴대폰': 'phone',
31
- '계좌이체': 'bank',
32
- '가상계좌': 'vbank',
33
- '카카오페이': 'kakaopay',
34
- '네이버페이': 'npay',
35
- '페이코': 'payco',
36
- '간편': 'easy',
37
- '카드자동': 'card_rebill',
38
- '간편자동': 'easy_rebill',
39
- '본인인증': 'auth',
40
- '카드수기': 'card_auth',
41
- '디지털카드': 'digital_card',
42
- '디지털카드자동': 'digital_card_rebill'
43
- }
44
-
45
- let Bootpay = window.Bootpay
46
- let BootpayWidget = window.BootpayWidget
47
-
48
- document.addEventListener('DOMContentLoaded', function () {
49
- setSaveData()
50
- getUserToken()
51
- Bootpay.setVersion('1.0.0-test.1', 'TEST SDK')
52
- Bootpay.setLogLevel(1)
53
- // Bootpay.setLocale('en')
54
- // Bootpay.setEnvironmentMode(document.getElementsByName('env')[0].value, 'dev-api.bootpay.co.kr/v3')
55
- Bootpay.setEnvironmentMode(document.getElementsByName('env')[0].value)
56
- Bootpay.setApplicationId(document.getElementsByName('applicationId')[0].value)
57
- Bootpay.login({
58
- id: 'gosomi'
59
- }).then(
60
- function () {
61
- Bootpay.send()
62
- }
63
- )
64
- setTimeout(() => {
65
- BootpayWidget.setEnvironmentMode(document.getElementsByName('env')[0].value)
66
- BootpayWidget.render('#widget', {
67
- application_id: document.getElementsByName('applicationId')[0].value,
68
- user_token: document.getElementsByName('userToken')[0].value,
69
- price: document.getElementsByName('amount')[0].value,
70
- tax_free: document.getElementsByName('taxFreeAmount')[0].value,
71
- sandbox: document.getElementsByName('sandbox')[0].value === '1',
72
- external_terms: [
73
- {
74
- pk: 'external-test-1',
75
- title: '부트페이 외부 약관1',
76
- required: 'required',
77
- url: 'https://naver.com'
78
- }
79
- ],
80
- extra: {
81
- card_quota: [0, 2, 3, 4, 5, 6]
82
- },
83
- // use_terms: false
84
- })
85
- }, 1000)
86
- // document.getElementsByName('pg')[0].value = '나이스페이'
87
- // document.getElementsByName('method')[0].value = '네이버페이'
88
- })
89
-
90
- document.addEventListener('bootpayclose', function (e) {
91
- console.log(e)
92
- console.log("결제창 닫힘")
93
- })
94
-
95
- document.addEventListener('bootpayallagreeterms', function (e) {
96
- console.log(e.detail)
97
- console.log("약관 모두 동의 버튼")
98
- })
99
-
100
- function getCacheMode() {
101
- try {
102
- const mode = window.localStorage.getItem('__mode')
103
- return mode === undefined || mode === null ? 'development' : mode
104
- } catch (e) {
105
- return 'development'
106
- }
107
- }
108
-
109
- function saveData() {
110
- let data = getCache()
111
- const unit = document.getElementsByName('unit')[0].value
112
- if (data.unit !== unit) {
113
- document.getElementsByName('applicationId')[0].value = data.application_id[unit]
114
- }
115
- data.unit = unit
116
- // data.pg_krw = document.getElementsByName('pg_krw')[0].value
117
- // data.pg_usd = document.getElementsByName('pg_usd')[0].value
118
- // data.method = document.getElementsByName('method')[0].value
119
- data.price = document.getElementsByName('amount')[0].value
120
- data.tax_free = document.getElementsByName('taxFreeAmount')[0].value
121
- data.env = document.getElementsByName('env')[0].value
122
- data.application_id[data.unit] = document.getElementsByName('applicationId')[0].value
123
- data.open_type = document.getElementsByName('open_type')[0].value
124
- data.escrow = document.getElementsByName('escrow')[0].value
125
- data.test_deposit = document.getElementsByName('test_deposit')[0].value
126
- data.phone = document.getElementsByName('phone')[0].value
127
- data.separately_confirmed = document.getElementsByName('separately_confirmed')[0].value
128
- data.sandbox = document.getElementsByName('sandbox')[0].value
129
- // data.version = document.getElementsByName('version')[0].value
130
-
131
- window.localStorage.setItem('__mode', document.getElementsByName('env')[0].value)
132
- window.localStorage.setItem('__cache_' + document.getElementsByName('env')[0].value, JSON.stringify(data))
133
- // changePG(data['pg_' + data.unit])
134
- }
135
-
136
- function changeMode() {
137
- window.localStorage.setItem('__mode', document.getElementsByName('env')[0].value)
138
- setSaveData()
139
- }
140
-
141
-
142
- function getCache() {
143
- try {
144
- const data = JSON.parse(window.localStorage.getItem('__cache_' + document.getElementsByName('env')[0].value))
145
- return data === undefined || data === null ? {
146
- pg_krw: '나이스페이',
147
- method: '카드',
148
- price: 1000,
149
- tax_free: 0,
150
- application_id: {
151
- krw: getDefaultApplicationId(document.getElementsByName('env')[0].value),
152
- usd: getDefaultApplicationId(document.getElementsByName('env')[0].value),
153
- },
154
- open_type: 'iframe',
155
- unit: 'krw',
156
- escrow: '0',
157
- separately_confirmed: '0',
158
- phone: '01000000000',
159
- test_deposit: '0',
160
- version: 'v2',
161
- sandbox: '1'
162
- } : data
163
- } catch (e) {
164
- return {
165
- pg_krw: '나이스페이',
166
- method: '카드',
167
- price: 1000,
168
- tax_free: 0,
169
- application_id: {
170
- krw: getDefaultApplicationId(document.getElementsByName('env')[0].value),
171
- usd: getDefaultApplicationId(document.getElementsByName('env')[0].value),
172
- },
173
- open_type: 'iframe',
174
- unit: 'krw',
175
- escrow: '0',
176
- phone: '01000000000',
177
- separately_confirmed: '0',
178
- test_deposit: '0',
179
- version: 'v2',
180
- sandbox: '1'
181
- }
182
- }
183
- }
184
-
185
- function getUserToken() {
186
- if (document.getElementsByName('env')[0].value === 'development' &&
187
- document.getElementsByName('applicationId')[0].value === '59a568d3e13f3336c21bf707') {
188
- $.ajax({
189
- type: 'POST',
190
- url: 'https://admin-dev.bootpay.co.kr/test/user_token',
191
- dataType: 'json',
192
- success: function (data) {
193
- document.getElementsByName('userToken')[0].value = data.user_token
194
- },
195
- error: function (data) {
196
-
197
- }
198
- })
199
- }
200
- }
201
-
202
- function getDefaultApplicationId(env) {
203
- switch (env) {
204
- case 'stage':
205
- case 'production':
206
- return '59a7a368396fa64fc5d4a7db'
207
- default:
208
- return '59a568d3e13f3336c21bf707'
209
- }
210
- }
211
-
212
- function setSaveData() {
213
- document.getElementsByName('env')[0].value = getCacheMode()
214
- const cache = getCache()
215
- document.getElementsByName('unit')[0].value = cache.unit
216
- document.getElementsByName('amount')[0].value = cache.price
217
- document.getElementsByName('taxFreeAmount')[0].value = cache.tax_free
218
- document.getElementsByName('applicationId')[0].value = cache.application_id[cache.unit]
219
- document.getElementsByName('escrow')[0].value = cache.escrow
220
- document.getElementsByName('test_deposit')[0].value = cache.test_deposit
221
- document.getElementsByName('phone')[0].value = cache.phone
222
- document.getElementsByName('separately_confirmed')[0].value = cache.separately_confirmed
223
- document.getElementsByName('sandbox')[0].value = cache.sandbox
224
- }
225
-
226
- function updatePrice() {
227
- BootpayWidget.update({
228
- price: document.getElementsByName('amount')[0].value,
229
- tax_free: document.getElementsByName('taxFreeAmount')[0].value
230
- })
231
- // BootpayWidget.rerender()
232
- saveData()
233
- }
234
-
235
- function rerender() {
236
- BootpayWidget.update({
237
- application_id: document.getElementsByName('applicationId')[0].value,
238
- user_token: document.getElementsByName('userToken')[0].value,
239
- price: document.getElementsByName('amount')[0].value,
240
- tax_free: document.getElementsByName('taxFreeAmount')[0].value,
241
- sandbox: document.getElementsByName('sandbox')[0].value === '1',
242
- extra: {
243
- card_quota: [0, 2, 3, 4, 5, 6]
244
- },
245
- // use_terms: true
246
- })
247
- saveData()
248
- }
249
-
250
- function requestPayment() {
251
- BootpayWidget.requestPayment({
252
- order_name: '(테스트)결제상태 체크 봇',
253
- user_token: document.getElementsByName('userToken')[0].value,
254
- order_id: String((new Date()).getTime()),
255
- metadata: {
256
- test: 1
257
- },
258
- user: {
259
- id: 'bootpay',
260
- username: '부트페이',
261
- phone: document.getElementsByName('phone')[0].value,
262
- email: 'test@bootpay.co.kr'
263
- },
264
- items: [
265
- {
266
- id: 'test',
267
- name: '아이템1',
268
- qty: 2,
269
- price: parseFloat(document.getElementsByName('amount')[0].value) / 2
270
- }
271
- ],
272
- extra: {
273
- show_close_button: true,
274
- // use_compound_tax: true,
275
- open_type: document.getElementsByName('open_type')[0].value,
276
- // identity_no: '3292000492',
277
- // easy_payment_method: '포인트',
278
- // show_close_button: true,
279
- // enable_easy_payments: ['페이코', '카카오페이'],
280
- // except_card_companies: ['국민', '신한'],
281
- // enable_card_companies: ['하나'],
282
- // browser_open_type: [
283
- // {
284
- // browser: 'instagram',
285
- // open_type: 'redirect'
286
- // },
287
- // {
288
- // browser: 'mobile_chrome',
289
- // open_type: 'popup'
290
- // },
291
- // {
292
- // browser: 'mobile_safari',
293
- // open_type: 'iframe'
294
- // }
295
- // ],
296
- // popup: true,
297
- // use_order_id: false,
298
- // redirect_url: 'https://admin-dev.bootpay.co.kr/test/confirm',
299
- // minimum_price_limit: false,
300
- // escrow: true,
301
- // offer_period: '20210401-20210501',
302
- display_cash_receipt: false,
303
- separately_confirmed: document.getElementsByName('separately_confirmed')[0].value === '1',
304
- // card_quota: '0,2,3,4,5,6',
305
- display_success_result: true,
306
- // use_easypay_point: true,
307
- display_error_result: true,
308
- escrow: document.getElementsByName('escrow')[0].value === '1',
309
- card_easy_option: {
310
- title: '부트페이 카드웰렛'
311
- },
312
- select_phone_carrier: 'SKT',
313
- // automatic_tax: true,
314
- // timeout: 1,
315
- // app_scheme: 'bootpay',
316
- // common_event_webhook: true,
317
- // confirm_only_rest_api: true,
318
- // popup: true
319
- // confirm_message: '승인중이지롱'
320
- // theme: '#000000',
321
- locale: 'en',
322
- test_deposit: document.getElementsByName('test_deposit')[0].value === '1',
323
- // deposit_expiration: '2023-05-30 01:25:00'
324
- }
325
- }).then(function (response) {
326
- console.log(response)
327
- if (response.event === 'confirm') {
328
- if (window.confirm('승인할까요?')) {
329
- Bootpay.confirm().then(
330
- function (response) {
331
- console.log(response)
332
- if (response.event === 'issued') {
333
- alert('가상계좌가 발급되었습니다.')
334
- // console.log('가상계좌 발급 끝')
335
- } else {
336
- alert('승인 분리 결제가 완료되었습니다.')
337
- }
338
- }, function (error) {
339
- switch (error.event) {
340
- case 'error':
341
- console.log(error)
342
- alert("에러: " + error.message)
343
- break
344
- case 'cancel':
345
- console.log(error)
346
- alert("닫힘: " + error.message)
347
- break
348
- default:
349
- throw error
350
- // alert(error.message)
351
- }
352
- }
353
- )
354
- } else {
355
-
356
- }
357
- } else {
358
- if (response.event === 'issued') {
359
- alert('가상계좌가 발급되었습니다.')
360
- // console.log('가상계좌 발급 끝')
361
- } else {
362
- alert('결제가 완료되었습니다.')
363
- }
364
- }
365
- }, function (e) {
366
- console.log(e)
367
- alert(e.message)
368
- })
369
- }
@@ -1,164 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>결제 테스트 페이지 (개발서버)</title>
5
- <meta charset="utf-8"/>
6
- <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"/>
7
- <meta name="apple-mobile-web-app-capable" content="yes"/>
8
- <meta name="apple-mobile-web-app-status-bar-style" content="none"/>
9
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
10
- integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
11
- <link rel="stylesheet" media="all" href="./css/style.css"/>
12
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
13
- <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
14
- integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
15
- crossorigin="anonymous"></script>
16
- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
17
- integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
18
- crossorigin="anonymous"></script>
19
- <script src="../../bootpay.js" type="application/javascript"></script>
20
- <script src="../../bootpay-sdk.js" type="application/javascript"></script>
21
- <script src="../../bootpay-widget.js" type="application/javascript"></script>
22
- <script src="https://d-cdn.bootapi.com/bootpay-latest.js" type="application/javascript"></script>
23
- <!-- <script src="https://cdn.bootpay.co.kr/js/bootpay-3.3.6.min.js" type="application/javascript"></script>-->
24
- <script src="./js/widget.js" type="application/javascript"></script>
25
- <meta content="width=device-width, initial-scale=1, user-scalable=no" name="viewport">
26
- <!-- Google Tag Manager -->
27
- <script>(function (w, d, s, l, i) {
28
- w[l] = w[l] || []
29
- w[l].push({
30
- 'gtm.start':
31
- new Date().getTime(), event: 'gtm.js'
32
- })
33
- var f = d.getElementsByTagName(s)[0],
34
- j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''
35
- j.async = true
36
- j.src =
37
- 'https://www.googletagmanager.com/gtm.js?id=' + i + dl
38
- f.parentNode.insertBefore(j, f)
39
- })(window, document, 'script', 'dataLayer', 'GTM-NQKMWJD')</script>
40
- <!-- End Google Tag Manager -->
41
- </head>
42
- <body>
43
- <div class="flex-container widget-background">
44
- <div class="widget-left">
45
- <div class="widget-container">
46
- <div id="widget"></div>
47
- </div>
48
- <div class="mt-4">
49
- <button class="btn btn-primary block w-100 btn-lg" onClick="requestPayment()">결제하기</button>
50
- </div>
51
- </div>
52
- <div class="widget-right">
53
- <div class="card">
54
- <div class="card-header">
55
- <h5 class="card-title">부트페이 위젯 테스트 결제 페이지입니다</h5>
56
- <h6 class="card-subtitle mb-2 text-muted">테스트 서버로 결제 요청을 할 수 있습니다.</h6>
57
- </div>
58
- <div class="card-body">
59
- <div class="form-group">
60
- <label>모드</label>
61
- <select class="form-control" name="env" onChange="changeMode()">
62
- <option value="development">개발모드</option>
63
- <option value="stage">스테이지모드</option>
64
- <option value="production">실서버모드</option>
65
- </select>
66
- </div>
67
- <div class="form-group">
68
- <label>통화(Currency)</label>
69
- <select class="form-control" name="unit" onChange="saveData()">
70
- <option value="krw">원화</option>
71
- <option value="usd">달러</option>
72
- </select>
73
- </div>
74
- <div class="form-group">
75
- <label>Application ID</label>
76
- <input class="form-control" value="" name="applicationId"/>
77
- </div>
78
- <div class="form-group">
79
- <label>결제할 금액</label>
80
- <input class="form-control" value="1000" name="amount" onChange="updatePrice()"/>
81
- </div>
82
- <div class="form-group">
83
- <label>면세로 설정할 금액</label>
84
- <input class="form-control" value="0" name="taxFreeAmount" onChange="updatePrice()"/>
85
- </div>
86
- <div class="form-group">
87
- <label>에스크로</label>
88
- <select class="form-control" name="escrow" onChange="saveData()">
89
- <option value="0">일반</option>
90
- <option value="1">에스크로</option>
91
- </select>
92
- </div>
93
- <div class="form-group">
94
- <label>가상계좌모의통지</label>
95
- <select class="form-control" name="test_deposit" onChange="saveData()">
96
- <option value="0">통지안함</option>
97
- <option value="1">통지함</option>
98
- </select>
99
- </div>
100
- <div class="form-group">
101
- <label>샌드박스모드</label>
102
- <select class="form-control" name="sandbox" onChange="saveData()">
103
- <option value="0">라이브</option>
104
- <option value="1">샌드박스</option>
105
- </select>
106
- </div>
107
- <div class="form-group">
108
- <label>결제진행방법</label>
109
- <select class="form-control" name="open_type" onChange="saveData()">
110
- <option value="iframe">iFrame</option>
111
- <option value="popup">팝업</option>
112
- <option value="redirect">Redirect</option>
113
- </select>
114
- </div>
115
- <div class="form-group">
116
- <label>승인분리</label>
117
- <select class="form-control" name="separately_confirmed" onChange="saveData()">
118
- <option value="0">승인후리턴</option>
119
- <option value="1">승인분리</option>
120
- </select>
121
- </div>
122
- <div class="form-group">
123
- <label>구매자 전화번호</label>
124
- <input class="form-control" value="" name="phone"/>
125
- </div>
126
- <div class="form-group">
127
- <label>User Token</label>
128
- <div class="row">
129
- <div class="col-9">
130
- <input class="form-control" value="" name="userToken"/>
131
- </div>
132
- <div class="col-3">
133
- <button class="btn btn-primary" onClick="getUserToken()">GetToken</button>
134
- </div>
135
- </div>
136
- </div>
137
- <div class="accordion" id="accordionButton">
138
- <div class="card">
139
- <div class="card-header" id="collapsePayment">
140
- <h2 class="mb-0">
141
- <button class="btn btn-link btn-block text-left" data-toggle="collapse"
142
- data-target="paymentOne" aria-expanded="true" aria-controls="collapsePayment">
143
- 결제하기 Section
144
- </button>
145
- </h2>
146
- </div>
147
- <div id="paymentOne" class="collapse show" aria-labelledby="collapsePayment"
148
- data-parent="#accordionButton">
149
- <div class="card-body">
150
- <div class="group mt-3">
151
- <button class="btn btn-primary" onclick="rerender()">
152
- 부트페이 위젯정보 갱신하기
153
- </button>
154
- </div>
155
- </div>
156
- </div>
157
- </div>
158
- </div>
159
- </div>
160
- </div>
161
- </div>
162
- </div>
163
- </body>
164
- </html>
File without changes