bootpay-backend-ruby 2.0.5 → 3.0.0.pre.alpha.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34d3516ce74a87e2e2f06a2ea4302ad5bd205a8f2d16d71341cb6dbb9f5ad529
4
- data.tar.gz: 677167c71eb134d5e8ab400104993788994cce77b53bd341026d4ffe10d35076
3
+ metadata.gz: 2f99b7d09d3da36d7350f6e11ec9e3992e5518b1e4cf9280577f537b952471ff
4
+ data.tar.gz: a139b2429b80827e4865b5bb1b6d970bb9cb9051b28577a4340a0f88b2e258e1
5
5
  SHA512:
6
- metadata.gz: fb2929d5d6a82d87825ea8af03bb5446653ca90c931648d21e0c33b1f03ddb6ff6454577f299f3245c3fc42dba9b07140b9417471a5f16eb86fd84898b78b7a7
7
- data.tar.gz: 170ab349d9a9e8e374afe4b2cb64eb664748be654f3fe1567c837e152be4e04834a6280871568de481b5cb0632fdca2455ceccadd422302b62734965da51e7c1
6
+ metadata.gz: 4151964b4afe765e3a2dbdd2b36f531ee02e0f21e28a4d2f674917b310018f891c657462a73b3132853529a1ab80e249da1aca01acddf954ab3aa2f60ffa1cdc
7
+ data.tar.gz: 94d3d4875dce4fbf501c10263cff3d221bf2c7ae78b60f4210709ef3811271d77ba47de346dd834e6df108492c496e001293ef2c8b372d3ec803f3e3168981f7
data/.gitignore CHANGED
@@ -13,7 +13,7 @@
13
13
  *.iml
14
14
  *.gem
15
15
  Gemfile.lock
16
- /spec/bootpay/request_rest_billing_key_spec.rb
16
+ /spec/bootpay/card_billing/request_rest_billing_key_spec.rb
17
17
  /spec/bootpay/__stage_test_unit_spec.rb
18
18
  /spec/bootpay/__development_test_unit_spec.rb
19
19
  .DS_Store
data/README.md CHANGED
@@ -8,28 +8,33 @@ Ruby 언어로 작성된 어플리케이션, 프레임워크 등에서 사용가
8
8
  * 결제 검증 및 취소, 빌링키 발급, 본인인증 등의 수행은 서버사이드에서 진행됩니다. (Java, PHP, Python, Ruby, Node.js, Go, ASP.NET 등)
9
9
 
10
10
 
11
- ## 기능
12
- 1. (부트페이 통신을 위한) 토큰 발급
13
- 2. 결제 단건 조회
14
- 3. 결제 취소 (전액 취소 / 부분 취소)
15
- 4. 신용카드 자동결제 (빌링결제)
11
+ ## 목차
12
+ - [사용하기](#사용하기)
13
+ - [1. 토큰 발급](#1-토큰-발급)
14
+ - [2. 결제 단건 조회](#2-결제-단건-조회)
15
+ - [3. 결제 취소 (전액 취소 / 부분 취소)](#3-결제-취소-전액-취소--부분-취소)
16
+ - [4. 자동/빌링/정기 결제](#4-자동빌링정기-결제)
17
+ - [4-1. 카드 빌링키 발급](#4-1-카드-빌링키-발급)
18
+ - [4-2. 계좌 빌링키 발급](#4-2-계좌-빌링키-발급)
19
+ - [4-3. 결제 요청하기](#4-3-결제-요청하기)
20
+ - [4-4. 결제 예약하기](#4-4-결제-예약하기)
21
+ - [4-5. 예약 조회하기](#4-5-예약-조회하기)
22
+ - [4-6. 예약 취소하기](#4-6-예약-취소하기)
23
+ - [4-7. 빌링키 삭제하기](#4-7-빌링키-삭제하기)
24
+ - [4-8. 빌링키 조회하기](#4-8-빌링키-조회하기)
25
+ - [5. 회원 토큰 발급요청](#5-회원-토큰-발급요청)
26
+ - [6. 서버 승인 요청](#6-서버-승인-요청)
27
+ - [7. 본인 인증 결과 조회](#7-본인-인증-결과-조회)
28
+ - [8. 에스크로 이용시 PG사로 배송정보 보내기](#8-에스크로-이용시-pg사로-배송정보-보내기)
29
+ - [9-1. 현금영수증 발행하기](#9-1-현금영수증-발행하기)
30
+ - [9-2. 현금영수증 발행 취소](#9-2-현금영수증-발행-취소)
31
+ - [9-3. 별건 현금영수증 발행](#9-3-별건-현금영수증-발행)
32
+ - [9-4. 별건 현금영수증 발행 취소](#9-4-별건-현금영수증-발행-취소)
33
+ - [Example 프로젝트](#example-프로젝트)
34
+ - [Documentation](#documentation)
35
+ - [기술문의](#기술문의)
36
+ - [License](#license)
16
37
 
17
- 4-1. 빌링키 발급
18
-
19
- 4-2. 발급된 빌링키로 결제 승인 요청
20
-
21
- 4-3. 발급된 빌링키로 결제 예약 요청
22
-
23
- 4-4. 발급된 빌링키로 결제 예약 - 취소 요청
24
-
25
- 4-5. 빌링키 삭제
26
-
27
- 4-6. 빌링키 조회
28
-
29
- 5. (생체인증, 비밀번호 결제를 위한) 구매자 토큰 발급
30
- 6. 서버 승인 요청
31
- 7. 본인 인증 결과 조회
32
- 8. (에스크로 이용시) PG사로 배송정보 보내기
33
38
 
34
39
  ## Gem으로 설치하기
35
40
 
@@ -68,7 +73,7 @@ end
68
73
  함수 단위의 샘플 코드는 [이곳](https://github.com/bootpay/backend-ruby/tree/2-x-development/spec/bootpay)을 참조하세요.
69
74
 
70
75
 
71
- ## 1. (부트페이 통신을 위한) 토큰 발급
76
+ ## 1. 토큰 발급
72
77
 
73
78
  부트페이와 서버간 통신을 하기 위해서는 부트페이 서버로부터 토큰을 발급받아야 합니다.
74
79
  발급된 토큰은 30분간 유효하며, 최초 발급일로부터 30분이 지날 경우 토큰 발급 함수를 재호출 해주셔야 합니다.
@@ -125,7 +130,7 @@ if api.request_access_token.success?
125
130
  end
126
131
  ```
127
132
 
128
- ## 4-1. 빌링키 발급
133
+ ## 4-1. 카드 빌링키 발급
129
134
  REST API 방식으로 고객의 카드 정보를 전달하여, PG사로부터 빌링키를 발급받을 수 있습니다. (부트페이에서는 PG사의 빌링키를 개발사에게 전달하지 않고, 부트페이가 내부적으로 발급한 빌링키를 전달합니다)
130
135
  발급받은 빌링키를 저장하고 있다가, 원하는 시점, 원하는 금액에 결제 승인 요청하여 좀 더 자유로운 결제시나리오에 적용이 가능합니다.
131
136
  * 비인증 정기결제(REST API) 방식을 지원하는 PG사만 사용 가능합니다.
@@ -151,7 +156,40 @@ end
151
156
 
152
157
  ```
153
158
 
154
- ## 4-2. 발급된 빌링키로 결제 승인 요청
159
+
160
+ ## 4-2. 계좌 빌링키 발급
161
+ REST API 방식으로 고객의 계좌 정보를 전달하여, PG사에게 빌링키 발급을 요청합니다. 요청 후 빌링키가 바로 발급되진 않고, 출금동의 확인 절차까지 진행해야 빌링키가 발급됩니다.
162
+ 먼저 빌링키를 요청합니다.
163
+ ```ruby
164
+ res1 = api.request_subscribe_automatic_transfer_billing_key(
165
+ pg: 'nicepay',
166
+ order_name: '테스트 결제',
167
+ price: 100,
168
+ tax_free: 0,
169
+ subscription_id: Time.current.to_i,
170
+ username: '홍길동',
171
+ user: {
172
+ phone: '01012341234',
173
+ username: '홍길동',
174
+ email: 'test@bootpay.co.kr'
175
+ },
176
+ bank_name: '국민',
177
+ bank_account: '675123412342472',
178
+ identity_no: '901014',
179
+ cash_receipt_identity_no: '01012341234',
180
+ phone: '01012341234',
181
+ )
182
+ print res1.data.to_json
183
+ ```
184
+ 이후 빌링키 발급 요청시 응답받은 receipt_id로, 출금 동의 확인을 요청합니다.
185
+
186
+ ```ruby
187
+ res2 = api.publish_automatic_transfer_billing_key(receipt_id: res1.data[:receipt_id])
188
+ print "\n\n" + res2.data.to_json
189
+ ```
190
+
191
+
192
+ ## 4-3. 결제 요청하기
155
193
  발급된 빌링키로 원하는 시점에 원하는 금액으로 결제 승인 요청을 할 수 있습니다. 잔액이 부족하거나 도난 카드 등의 특별한 건이 아니면 PG사에서 결제를 바로 승인합니다.
156
194
 
157
195
  ```ruby
@@ -175,7 +213,7 @@ if api.request_access_token.success?
175
213
  puts response.data.to_json
176
214
  end
177
215
  ```
178
- ## 4-3. 발급된 빌링키로 결제 예약 요청
216
+ ## 4-4. 결제 예약하기
179
217
  원하는 시점에 4-1로 결제 승인 요청을 보내도 되지만, 빌링키 발급 이후에 바로 결제 예약 할 수 있습니다. (빌링키당 최대 10건)
180
218
  ```ruby
181
219
  api = Bootpay::RestClient.new(
@@ -198,8 +236,24 @@ if api.request_access_token.success?
198
236
  print response.data.to_json
199
237
  end
200
238
  ```
201
- ## 4-4. 발급된 빌링키로 결제 예약 - 취소 요청
202
- 빌링키로 예약된 결제건을 취소합니다.
239
+
240
+ ## 4-5. 예약 조회하기
241
+ 예약시 응답받은 reserveId로 예약된 건을 조회합니다.
242
+ ```ruby
243
+ api = Bootpay::RestClient.new(
244
+ application_id: '59bfc738e13f337dbd6ca48a',
245
+ private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0='
246
+ )
247
+ if api.request_access_token.success?
248
+ reserve_id = "628c0d0d1fc19202e5ef2866"
249
+ response = api.subscribe_payment_reserve_lookup(reserve_id)
250
+ print response.data.to_json
251
+ ```
252
+
253
+
254
+
255
+ ## 4-6. 예약 취소하기
256
+ 예약시 응답받은 reserveId로 예약된 건을 취소합니다.
203
257
  ```ruby
204
258
  api = Bootpay::RestClient.new(
205
259
  application_id: '59bfc738e13f337dbd6ca48a',
@@ -226,8 +280,8 @@ if api.request_access_token.success?
226
280
  end
227
281
  end
228
282
  ```
229
- ## 4-5. 빌링키 삭제
230
- 발급된 빌링키가 이상 사용되지 않도록, 삭제 요청합니다.
283
+ ## 4-7. 빌링키 삭제하기
284
+ 발급된 빌링키를 삭제합니다. 삭제하더라도 예약된 결제건은 취소되지 않습니다. 예약된 결제건 취소를 원하시면 예약 취소하기를 요청하셔야 합니다.
231
285
  ```ruby
232
286
  api = Bootpay::RestClient.new(
233
287
  application_id: '59bfc738e13f337dbd6ca48a',
@@ -241,8 +295,9 @@ if api.request_access_token.success?
241
295
  end
242
296
  ```
243
297
 
244
- ## 4-6. 빌링키 조회
245
- (빌링키 발급 완료시 리턴받았던 receipt_id에 한정) 어떤 빌링키였는지 조회합니다.
298
+ ## 4-8. 빌링키 조회하기
299
+ 클라이언트에서 빌링키 발급시, 보안상 클라이언트 이벤트에 빌링키를 전달해주지 않습니다. 그러므로 이 API를 통해 조회해야 합니다.
300
+ 다음은 빌링키 발급 요청했던 receiptId 로 빌링키를 조회합니다.
246
301
  ```ruby
247
302
  api = Bootpay::RestClient.new(
248
303
  application_id: '59bfc738e13f337dbd6ca48a',
@@ -256,9 +311,9 @@ if api.request_access_token.success?
256
311
  end
257
312
  ```
258
313
 
259
- ## 5. (생체인증, 비밀번호 결제를 위한) 구매자 토큰 발급
260
- 부트페이에서 제공하는 간편결제창, 생체인증 기반의 결제 사용을 위해서는 개발사에서 회원 고유번호를 관리해야하며, 해당 회원에 대한 사용자 토큰을 발급합니다.
261
- 이 토큰값을 기반으로 클라이언트에서 결제요청 하시면 되겠습니다.
314
+ ## 5. 회원 토큰 발급요청
315
+ ㅇㅇ페이 사용을 위해 가맹점 회원의 토큰을 발급합니다. 가맹점은 회원의 고유번호를 관리해야합니다.
316
+ 이 토큰값을 기반으로 클라이언트에서 결제요청(payload.user_token) 하시면 되겠습니다.
262
317
  ```ruby
263
318
  api = Bootpay::RestClient.new(
264
319
  application_id: '59bfc738e13f337dbd6ca48a',
@@ -344,7 +399,7 @@ end
344
399
 
345
400
  ## Documentation
346
401
 
347
- [부트페이 개발매뉴얼](https://docs.bootpay.co.kr/next/)을 참조해주세요
402
+ [부트페이 개발매뉴얼](https://developer.bootpay.co.kr/)을 참조해주세요
348
403
 
349
404
  ## 기술문의
350
405
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/bootpay/version"
3
+ require_relative "lib/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "bootpay-backend-ruby"
@@ -3,8 +3,8 @@
3
3
  require 'active_support/all'
4
4
  require 'http'
5
5
  require_relative 'response'
6
- require_relative 'bootpay/version'
7
- require_relative 'bootpay/concern'
6
+ require_relative '../version'
7
+ require_relative 'concern'
8
8
 
9
9
  module Bootpay
10
10
  class RestClient
@@ -17,7 +17,7 @@ module Bootpay
17
17
  production: 'https://api.bootpay.co.kr/v2'
18
18
  }
19
19
 
20
- SDK_VERSION = '4.2.1'
20
+ SDK_VERSION = '5.0.0'
21
21
 
22
22
  def initialize(application_id:, private_key:, mode: 'production')
23
23
  @application_id = application_id
@@ -45,18 +45,21 @@ module Bootpay::Concern::CashReceipt
45
45
  # 결제된 계좌이체/가상계좌 결제건중 누락된 현금영수증을 발행해주는 API
46
46
  # Comment by Gosomi
47
47
  # Date: 2022-07-21
48
- def cash_receipt_publish_on_receipt(receipt_id:, username:, email:, phone:, identity_no:, currency: 'WON', cash_receipt_type: '소득공제')
48
+ def cash_receipt_publish_on_receipt(receipt_id:, username:, email:, phone:, identity_no:, currency: 'WON',
49
+ cash_receipt_type: '소득공제', pg: nil, test_production: false)
49
50
  request(
50
51
  method: :post,
51
52
  uri: "request/receipt/cash/publish",
52
53
  payload: {
54
+ pg: pg,
53
55
  receipt_id: receipt_id,
54
56
  username: username,
55
57
  email: email,
56
58
  phone: phone,
57
59
  identity_no: identity_no,
58
60
  currency: currency,
59
- cash_receipt_type: cash_receipt_type
61
+ cash_receipt_type: cash_receipt_type,
62
+ test_production: test_production
60
63
  }
61
64
  )
62
65
  end
@@ -60,7 +60,8 @@ module Bootpay::Concern::Payment
60
60
  # Comment by Gosomi
61
61
  # Date: 2023-03-28
62
62
  def request_payment(platform_application_id:, pg:, method: nil, price:, tax_free: 0, order_name:, order_id:, user_token: nil, uuid: nil, sk: nil,
63
- ti: 0, tk: nil, items: [], extra: {}, user: {}, agent: nil)
63
+ ti: 0, tk: nil, items: [], extra: {}, user: {}, agent: nil, commission_keys: nil, wallet_id: nil, terms: [], widget_key: nil, widget_sandbox: false,
64
+ redirect_url: nil)
64
65
  rand_uuid = SecureRandom.uuid
65
66
  request(
66
67
  uri: 'request/payment',
@@ -74,6 +75,12 @@ module Bootpay::Concern::Payment
74
75
  order_name: order_name,
75
76
  order_id: order_id,
76
77
  user_token: user_token,
78
+ wallet_id: wallet_id,
79
+ commission_keys: commission_keys,
80
+ terms: terms,
81
+ redirect_url: redirect_url,
82
+ widget_key: widget_key,
83
+ widget_sandbox: widget_sandbox,
77
84
  uuid: uuid.presence || rand_uuid,
78
85
  sk: sk.presence || "#{rand_uuid}-#{Time.current.to_i}",
79
86
  ti: ti,
@@ -28,6 +28,16 @@ module Bootpay::Concern::Reseller
28
28
  )
29
29
  end
30
30
 
31
+ # 가맹점 정보를 조회한다
32
+ # Comment by GOSOMI
33
+ # @date: 2024-07-09
34
+ def lookup_seller(provider_id)
35
+ request(
36
+ method: :get,
37
+ uri: "reseller/seller/#{provider_id}",
38
+ )
39
+ end
40
+
31
41
  # 테스트로 생성한 계정을 모두 삭제한다
32
42
  # Comment by GOSOMI
33
43
  # @date: 2023-10-11
@@ -7,7 +7,7 @@ module Bootpay::Concern::Rest
7
7
  # HTTP Request 기본 Method
8
8
  # Comment by Gosomi
9
9
  # Date: 2021-05-21
10
- def request(method: :post, uri:, payload: {}, headers: {})
10
+ def request(method: :post, uri:, payload: {}, headers: {}, params: nil)
11
11
  response = HTTP.headers(
12
12
  {
13
13
  Authorization: "Bearer #{@token}",
@@ -20,7 +20,8 @@ module Bootpay::Concern::Rest
20
20
  ).send(
21
21
  method.to_sym,
22
22
  [Bootpay::RestClient::API[@mode.to_sym], uri].join('/'),
23
- json: payload
23
+ json: payload,
24
+ params: params
24
25
  )
25
26
  Bootpay::Response.new(
26
27
  response.status.to_i == 200,
@@ -0,0 +1,15 @@
1
+ module Bootpay::Concern::Service
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ # 등록된 Wallet 정보를 가져온다
6
+ # Comment by GOSOMI
7
+ # @date: 2024-06-27
8
+ def lookup_service_wallets
9
+ request(
10
+ uri: 'seller/service/wallet',
11
+ method: :get
12
+ )
13
+ end
14
+ end
15
+ end
@@ -204,6 +204,13 @@ module Bootpay::Concern::Subscription
204
204
  )
205
205
  end
206
206
 
207
+ def request_subscribe_automatic_transfer_on_continue(receipt_id)
208
+ request(
209
+ method: :put,
210
+ uri: "request/subscribe/automatic-transfer/#{receipt_id}"
211
+ )
212
+ end
213
+
207
214
  # 빌링키로 조회하는 기능을 만든다
208
215
  # Comment by GOSOMI
209
216
  # @date: 2023-09-14
@@ -0,0 +1,41 @@
1
+ module Bootpay::Concern::Wallet
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ # 설정된 wallet 기준으로 결제를 진행한다
6
+ def request_wallet_payment(user_id:, order_name:, price:, tax_free: 0, webhook_url: nil, content_type: nil, order_id:,
7
+ items: [], user: {}, extra: {}, metadata: {}, sandbox: false)
8
+ request(
9
+ uri: 'wallet/payment',
10
+ payload: {
11
+ user_id: user_id,
12
+ order_name: order_name,
13
+ price: price,
14
+ tax_free: tax_free,
15
+ webhook_url: webhook_url,
16
+ content_type: content_type,
17
+ order_id: order_id,
18
+ items: items,
19
+ user: user,
20
+ extra: extra,
21
+ metadata: metadata,
22
+ sandbox: sandbox
23
+ }
24
+ )
25
+ end
26
+
27
+ # 등록된 회원의 지갑 정보를 가져온다
28
+ # Comment by GOSOMI
29
+ # @date: 2025-02-13
30
+ def user_wallets(user_id:, sandbox:)
31
+ request(
32
+ uri: 'wallet',
33
+ method: :get,
34
+ params: {
35
+ user_id: user_id,
36
+ sandbox: sandbox
37
+ }
38
+ )
39
+ end
40
+ end
41
+ end
@@ -9,9 +9,11 @@ module Bootpay
9
9
  require_relative 'concern/rest'
10
10
  require_relative 'concern/sdk'
11
11
  require_relative 'concern/seller'
12
+ require_relative 'concern/service'
12
13
  require_relative 'concern/subscription'
13
14
  require_relative 'concern/token'
14
15
  require_relative 'concern/user_token'
16
+ require_relative 'concern/wallet'
15
17
  require_relative 'concern/webhook'
16
18
 
17
19
  include Authenticate
@@ -23,9 +25,11 @@ module Bootpay
23
25
  include Rest
24
26
  include Sdk
25
27
  include Seller
28
+ include Service
26
29
  include Subscription
27
30
  include Token
28
31
  include UserToken
32
+ include Wallet
29
33
  include Webhook
30
34
  end
31
35
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/all'
4
+ require 'http'
5
+ require_relative 'response'
6
+ require_relative '../version'
7
+ require_relative 'concern'
8
+
9
+ module BootpayStorage
10
+ class RestClient
11
+ include Concern
12
+
13
+ API =
14
+ {
15
+ development: 'https://dev-s.bootapi.com/api/v1',
16
+ stage: 'https://stage-s.bootapi.com/api/v1',
17
+ production: 'https://s.bootapi.com/api/v1',
18
+ }
19
+
20
+ SDK_VERSION = '5.0.0'
21
+
22
+ def initialize(server_key:, private_key:, mode: 'production')
23
+ @server_key = server_key
24
+ @private_key = private_key
25
+ @mode = mode.presence || 'production'
26
+ @token = nil
27
+ @api_version = SDK_VERSION
28
+ raise ArgumentError, "개발환경 mode는 development, stage, production 중에서 선택이 가능합니다." if API[@mode.to_sym].blank?
29
+ end
30
+
31
+ # API URL을 변경
32
+ # Comment by GOSOMI
33
+ # @date: 2023-05-26
34
+ def set_api_url(url)
35
+ API[@mode.to_sym] = url
36
+ end
37
+
38
+ # API 버전을 설정한다
39
+ # Comment by Gosomi
40
+ # Date: 2022-07-29
41
+ def set_api_version(version)
42
+ raise ArgumentError, 'API Version은 4.0.0 이상만 설정이 가능합니다.' if version < '4.0.0'
43
+ @api_version = version
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,19 @@
1
+ module BootpayStorage::Concern::Image
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+
6
+
7
+ # REST API로 본인인증 요청하기
8
+ # Comment by Gosomi
9
+ # Date: 2022-11-02
10
+ def image_upload(image_data:, image_name:)
11
+ upload(
12
+ uri: 'images',
13
+ image_data: image_data,
14
+ image_name: image_name
15
+ )
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,88 @@
1
+ module BootpayStorage::Concern::Rest
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ private
6
+
7
+ # HTTP Request 기본 Method
8
+ # Comment by Gosomi
9
+ # Date: 2021-05-21
10
+ def request(method: :post, uri:, payload: {}, headers: {}, params: nil)
11
+ response = HTTP.headers(
12
+ {
13
+ Authorization: "Bearer #{@token}",
14
+ content_type: 'application/json',
15
+ accept: 'application/json',
16
+ bootpay_api_version: @api_version,
17
+ bootpay_sdk_version: Bootpay::V2_VERSION,
18
+ bootpay_sdk_type: '300'
19
+ }.merge!(headers).compact
20
+ ).send(
21
+ method.to_sym,
22
+ [BootpayStorage::RestClient::API[@mode.to_sym], uri].join('/'),
23
+ json: payload,
24
+ params: params
25
+ )
26
+ BootpayStorage::Response.new(
27
+ response.status.to_i == 200,
28
+ JSON.parse(response.body.to_s, symbolize_names: true)
29
+ )
30
+ rescue Exception => e
31
+ BootpayStorage::Response.new(
32
+ false,
33
+ message: "부트페이 API 서버와의 통신이 실패하였습니다. 오류 메세지: #{e.message}",
34
+ backtrace: e.backtrace.join("\n")
35
+ )
36
+ end
37
+
38
+ # Multipart 파일 전송 Method
39
+ # Comment by Gosomi
40
+ # Date: 2025-03-25
41
+ def upload(uri:, image_data:, image_name:, headers: {}, params: nil)
42
+
43
+ # puts [BootpayStorage::RestClient::API[@mode.to_sym], uri].join('/')
44
+
45
+ # 파일 객체 생성
46
+ file = HTTP::FormData::File.new(image_data, filename: image_name)
47
+
48
+ # HTTP 요청
49
+ response = HTTP.headers(
50
+ {
51
+ Authorization: "Bearer #{@token}",
52
+ accept: 'application/json',
53
+ bootpay_api_version: @api_version,
54
+ bootpay_sdk_version: Bootpay::V2_VERSION,
55
+ bootpay_sdk_type: '300'
56
+ }.merge!(headers).compact
57
+ ).post(
58
+ [BootpayStorage::RestClient::API[@mode.to_sym], uri].join('/'),
59
+ form: { images: [file] },
60
+ params: params
61
+ )
62
+
63
+ # 응답 상태와 바디 출력
64
+ puts "Response Status: #{response.status}"
65
+ puts "Response Body: #{response.body.to_s}"
66
+
67
+ # JSON 파싱 시도
68
+ parsed_response = begin
69
+ JSON.parse(response.body.to_s, symbolize_names: true)
70
+ rescue JSON::ParserError => e
71
+ { error: "응답 파싱 실패: #{e.message}", body: response.body.to_s }
72
+ end
73
+
74
+ # 응답 처리
75
+ BootpayStorage::Response.new(
76
+ response.status.to_i == 200,
77
+ parsed_response
78
+ )
79
+ rescue Exception => e
80
+ BootpayStorage::Response.new(
81
+ false,
82
+ message: "파일 업로드 실패: #{e.message}",
83
+ backtrace: e.backtrace.join("\n")
84
+ )
85
+ end
86
+
87
+ end
88
+ end
@@ -0,0 +1,9 @@
1
+ module BootpayStorage::Concern::Token
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ def set_token(token)
6
+ @token = token
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module BootpayStorage
2
+ module Concern
3
+ require_relative 'concern/rest'
4
+ require_relative 'concern/token'
5
+ require_relative 'concern/image'
6
+ include Rest
7
+ include Image
8
+ include Token
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ module BootpayStorage
2
+ class Response
3
+ attr_reader :data
4
+
5
+ def initialize(success = true, data = {})
6
+ @success = success
7
+ @data = data
8
+ end
9
+
10
+ def success?
11
+ @success
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/all'
4
+ require 'http'
5
+ require_relative 'response'
6
+ require_relative '../version'
7
+ require_relative 'concern'
8
+
9
+ module BootpayStore
10
+ class RestClient
11
+ include Concern
12
+
13
+ API =
14
+ {
15
+ development: 'https://dev-api.bootapi.com/v1',
16
+ stage: 'https://stage-api.bootapi.com/v1',
17
+ production: 'https://api.bootapi.com/v1'
18
+ }
19
+
20
+ SDK_VERSION = '5.0.0'
21
+
22
+ def initialize(server_key:, private_key:, mode: 'production')
23
+ @server_key = server_key
24
+ @private_key = private_key
25
+ @mode = mode.presence || 'production'
26
+ @token = nil
27
+ @api_version = SDK_VERSION
28
+ raise ArgumentError, "개발환경 mode는 development, stage, production 중에서 선택이 가능합니다." if API[@mode.to_sym].blank?
29
+ end
30
+
31
+ # API URL을 변경
32
+ # Comment by GOSOMI
33
+ # @date: 2023-05-26
34
+ def set_api_url(url)
35
+ API[@mode.to_sym] = url
36
+ end
37
+
38
+ # API 버전을 설정한다
39
+ # Comment by Gosomi
40
+ # Date: 2022-07-29
41
+ def set_api_version(version)
42
+ raise ArgumentError, 'API Version은 4.0.0 이상만 설정이 가능합니다.' if version < '4.0.0'
43
+ @api_version = version
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,38 @@
1
+ module BootpayStore::Concern::Rest
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ private
6
+
7
+ # HTTP Request 기본 Method
8
+ # Comment by Gosomi
9
+ # Date: 2021-05-21
10
+ def request(method: :post, uri:, payload: {}, headers: {}, params: nil)
11
+ response = HTTP.headers(
12
+ {
13
+ Authorization: "Bearer #{@token}",
14
+ content_type: 'application/json',
15
+ accept: 'application/json',
16
+ bootpay_api_version: @api_version,
17
+ bootpay_sdk_version: Bootpay::V2_VERSION,
18
+ bootpay_sdk_type: '300'
19
+ }.merge!(headers).compact
20
+ ).send(
21
+ method.to_sym,
22
+ [BootpayStore::RestClient::API[@mode.to_sym], uri].join('/'),
23
+ json: payload,
24
+ params: params
25
+ )
26
+ BootpayStore::Response.new(
27
+ response.status.to_i == 200,
28
+ JSON.parse(response.body.to_s, symbolize_names: true)
29
+ )
30
+ rescue Exception => e
31
+ BootpayStore::Response.new(
32
+ false,
33
+ message: "부트페이 API 서버와의 통신이 실패하였습니다. 오류 메세지: #{e.message}",
34
+ backtrace: e.backtrace.join("\n")
35
+ )
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,24 @@
1
+ module BootpayStore::Concern::Token
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ # Access Token을 요청한다
6
+ # Comment by Gosomi
7
+ # Date: 2021-05-21
8
+ def request_access_token
9
+ response = request(
10
+ uri: 'token',
11
+ payload: {
12
+ server_key: @server_key,
13
+ private_key: @private_key
14
+ }
15
+ )
16
+ @token = response.data[:access_token] if response.success?
17
+ response
18
+ end
19
+
20
+ def set_token(token)
21
+ @token = token
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ module BootpayStore
2
+ module Concern
3
+ # require_relative 'concern/authenticate'
4
+ # require_relative 'concern/cash_receipt'
5
+ # require_relative 'concern/easy'
6
+ # require_relative 'concern/escrow'
7
+ # require_relative 'concern/payment'
8
+ # require_relative 'concern/reseller'
9
+ require_relative 'concern/rest'
10
+ # require_relative 'concern/sdk'
11
+ # require_relative 'concern/seller'
12
+ # require_relative 'concern/service'
13
+ # require_relative 'concern/subscription'
14
+ require_relative 'concern/token'
15
+ # require_relative 'concern/user_token'
16
+ # require_relative 'concern/wallet'
17
+ # require_relative 'concern/webhook'
18
+ #
19
+ # include Authenticate
20
+ # include CashReceipt
21
+ # include Easy
22
+ # include Escrow
23
+ # include Payment
24
+ # include Reseller
25
+ include Rest
26
+ # include Sdk
27
+ # include Seller
28
+ # include Service
29
+ # include Subscription
30
+ include Token
31
+ # include UserToken
32
+ # include Wallet
33
+ # include Webhook
34
+ end
35
+ end
@@ -0,0 +1,14 @@
1
+ module BootpayStore
2
+ class Response
3
+ attr_reader :data
4
+
5
+ def initialize(success = true, data = {})
6
+ @success = success
7
+ @data = data
8
+ end
9
+
10
+ def success?
11
+ @success
12
+ end
13
+ end
14
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Bootpay
3
- V2_VERSION = "2.0.5"
3
+ V2_VERSION = "3.0.0-alpha.1"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootpay-backend-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 3.0.0.pre.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - gosomi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-29 00:00:00.000000000 Z
11
+ date: 2025-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -56,7 +56,7 @@ files:
56
56
  - bin/console
57
57
  - bin/setup
58
58
  - bootpay-backend-ruby.gemspec
59
- - lib/bootpay-backend-ruby.rb
59
+ - lib/bootpay/bootpay-rest-client.rb
60
60
  - lib/bootpay/concern.rb
61
61
  - lib/bootpay/concern/authenticate.rb
62
62
  - lib/bootpay/concern/cash_receipt.rb
@@ -67,12 +67,25 @@ files:
67
67
  - lib/bootpay/concern/rest.rb
68
68
  - lib/bootpay/concern/sdk.rb
69
69
  - lib/bootpay/concern/seller.rb
70
+ - lib/bootpay/concern/service.rb
70
71
  - lib/bootpay/concern/subscription.rb
71
72
  - lib/bootpay/concern/token.rb
72
73
  - lib/bootpay/concern/user_token.rb
74
+ - lib/bootpay/concern/wallet.rb
73
75
  - lib/bootpay/concern/webhook.rb
74
- - lib/bootpay/version.rb
75
- - lib/response.rb
76
+ - lib/bootpay/response.rb
77
+ - lib/bootpay_storage/bootpay-storage-rest-client.rb
78
+ - lib/bootpay_storage/concern.rb
79
+ - lib/bootpay_storage/concern/image.rb
80
+ - lib/bootpay_storage/concern/rest.rb
81
+ - lib/bootpay_storage/concern/token.rb
82
+ - lib/bootpay_storage/response.rb
83
+ - lib/bootpay_store/bootpay-store-rest-client.rb
84
+ - lib/bootpay_store/concern.rb
85
+ - lib/bootpay_store/concern/rest.rb
86
+ - lib/bootpay_store/concern/token.rb
87
+ - lib/bootpay_store/response.rb
88
+ - lib/version.rb
76
89
  homepage:
77
90
  licenses:
78
91
  - MIT
@@ -92,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
105
  - !ruby/object:Gem::Version
93
106
  version: '0'
94
107
  requirements: []
95
- rubygems_version: 3.4.10
108
+ rubygems_version: 3.5.11
96
109
  signing_key:
97
110
  specification_version: 4
98
111
  summary: Bootpay Ruby REST Client
File without changes