bootpay 1.0.9 → 1.2.0
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 +4 -4
- data/.DS_Store +0 -0
- data/.env.example +23 -0
- data/.gitignore +8 -1
- data/.rspec +1 -0
- data/CHANGELOG.md +8 -0
- data/README.md +38 -13
- data/bootpay.gemspec +11 -11
- data/lib/.DS_Store +0 -0
- data/lib/bootpay/.DS_Store +0 -0
- data/lib/bootpay/authentication.rb +61 -0
- data/lib/bootpay/automatic_transfer.rb +56 -0
- data/lib/bootpay/billing.rb +25 -1
- data/lib/bootpay/cash_receipt.rb +77 -0
- data/lib/bootpay/commerce/cart.rb +20 -0
- data/lib/bootpay/commerce/category.rb +39 -0
- data/lib/bootpay/commerce/commerce_resource.rb +196 -0
- data/lib/bootpay/commerce/coupon.rb +41 -0
- data/lib/bootpay/commerce/invoice.rb +46 -0
- data/lib/bootpay/commerce/order.rb +61 -0
- data/lib/bootpay/commerce/order_cancel.rb +52 -0
- data/lib/bootpay/commerce/order_subscription.rb +117 -0
- data/lib/bootpay/commerce/order_subscription_adjustment.rb +29 -0
- data/lib/bootpay/commerce/order_subscription_bill.rb +50 -0
- data/lib/bootpay/commerce/order_subscription_request.rb +60 -0
- data/lib/bootpay/commerce/point.rb +36 -0
- data/lib/bootpay/commerce/product.rb +63 -0
- data/lib/bootpay/commerce/store.rb +21 -0
- data/lib/bootpay/commerce/user.rb +75 -0
- data/lib/bootpay/commerce/user_group.rb +70 -0
- data/lib/bootpay/escrow.rb +1 -1
- data/lib/bootpay/rest.rb +15 -4
- data/lib/bootpay/token.rb +16 -3
- data/lib/bootpay/version.rb +1 -1
- data/lib/bootpay/wallet.rb +56 -0
- data/lib/bootpay.rb +22 -5
- data/lib/bootpay_commerce.rb +152 -0
- metadata +33 -8
- data/lib/bootpay/bootpay.rb +0 -49
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module Bootpay
|
|
6
|
+
module Commerce
|
|
7
|
+
class ProductModule
|
|
8
|
+
def initialize(bootpay)
|
|
9
|
+
@bootpay = bootpay
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# 상품 목록 조회
|
|
13
|
+
def list(params = {})
|
|
14
|
+
query_params = {}
|
|
15
|
+
query_params[:page] = params[:page] unless params[:page].nil?
|
|
16
|
+
query_params[:limit] = params[:limit] unless params[:limit].nil?
|
|
17
|
+
query_params[:keyword] = params[:keyword] if params[:keyword]
|
|
18
|
+
query_params[:type] = params[:type] unless params[:type].nil?
|
|
19
|
+
query_params[:period_type] = params[:period_type] if params[:period_type]
|
|
20
|
+
query_params[:s_at] = params[:s_at] if params[:s_at]
|
|
21
|
+
query_params[:e_at] = params[:e_at] if params[:e_at]
|
|
22
|
+
query_params[:category_code] = params[:category_code] if params[:category_code]
|
|
23
|
+
|
|
24
|
+
query = build_query(query_params)
|
|
25
|
+
@bootpay.get("products#{query}")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# 상품 생성 (이미지 포함)
|
|
29
|
+
def create(product, image_paths = nil)
|
|
30
|
+
@bootpay.post_multipart('products', product, image_paths)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# 상품 상세 조회
|
|
34
|
+
def detail(product_id)
|
|
35
|
+
@bootpay.get("products/#{product_id}")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# 상품 수정
|
|
39
|
+
def update(product)
|
|
40
|
+
raise ArgumentError, 'product_id is required' unless product[:product_id]
|
|
41
|
+
@bootpay.put("products/#{product[:product_id]}", product)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# 상품 상태 변경
|
|
45
|
+
def status(params)
|
|
46
|
+
raise ArgumentError, 'product_id is required' unless params[:product_id]
|
|
47
|
+
@bootpay.put("products/#{params[:product_id]}/status", params)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# 상품 삭제
|
|
51
|
+
def delete(product_id)
|
|
52
|
+
@bootpay.delete("products/#{product_id}")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def build_query(params)
|
|
58
|
+
return '' if params.empty?
|
|
59
|
+
"?#{URI.encode_www_form(params)}"
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bootpay
|
|
4
|
+
module Commerce
|
|
5
|
+
class StoreModule
|
|
6
|
+
def initialize(bootpay)
|
|
7
|
+
@bootpay = bootpay
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# 가맹점 기본 정보 조회
|
|
11
|
+
def info
|
|
12
|
+
@bootpay.get('store')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# 가맹점 상세 정보 조회
|
|
16
|
+
def detail
|
|
17
|
+
@bootpay.get('store/detail')
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module Bootpay
|
|
6
|
+
module Commerce
|
|
7
|
+
class UserModule
|
|
8
|
+
def initialize(bootpay)
|
|
9
|
+
@bootpay = bootpay
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# 사용자 토큰 발급
|
|
13
|
+
def token(user_id)
|
|
14
|
+
@bootpay.post('users/login/token', { user_id: user_id })
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# 회원가입
|
|
18
|
+
def join(user)
|
|
19
|
+
@bootpay.post('users/join', user)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# 중복 체크
|
|
23
|
+
def check_exist(key, value)
|
|
24
|
+
encoded_value = URI.encode_www_form_component(value)
|
|
25
|
+
@bootpay.get("users/join/#{key}?pk=#{encoded_value}")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# 본인인증 데이터 조회
|
|
29
|
+
def authentication_data(stand_id)
|
|
30
|
+
@bootpay.get("users/authenticate/#{stand_id}")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# 로그인
|
|
34
|
+
def login(login_id, login_pw)
|
|
35
|
+
@bootpay.post('users/login', { login_id: login_id, login_pw: login_pw })
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# 사용자 목록 조회
|
|
39
|
+
def list(params = {})
|
|
40
|
+
query_params = {}
|
|
41
|
+
query_params[:page] = params[:page] unless params[:page].nil?
|
|
42
|
+
query_params[:limit] = params[:limit] unless params[:limit].nil?
|
|
43
|
+
query_params[:keyword] = params[:keyword] if params[:keyword]
|
|
44
|
+
query_params[:member_type] = params[:member_type] unless params[:member_type].nil?
|
|
45
|
+
query_params[:type] = params[:type] if params[:type]
|
|
46
|
+
|
|
47
|
+
query = build_query(query_params)
|
|
48
|
+
@bootpay.get("users#{query}")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# 사용자 상세 조회
|
|
52
|
+
def detail(user_id)
|
|
53
|
+
@bootpay.get("users/#{user_id}")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# 사용자 정보 수정
|
|
57
|
+
def update(user)
|
|
58
|
+
raise ArgumentError, 'user_id is required' unless user[:user_id]
|
|
59
|
+
@bootpay.put("users/#{user[:user_id]}", user)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# 사용자 삭제
|
|
63
|
+
def delete(user_id)
|
|
64
|
+
@bootpay.delete("users/#{user_id}")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
private
|
|
68
|
+
|
|
69
|
+
def build_query(params)
|
|
70
|
+
return '' if params.empty?
|
|
71
|
+
"?#{URI.encode_www_form(params)}"
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module Bootpay
|
|
6
|
+
module Commerce
|
|
7
|
+
class UserGroupModule
|
|
8
|
+
def initialize(bootpay)
|
|
9
|
+
@bootpay = bootpay
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# 사용자 그룹 생성
|
|
13
|
+
def create(user_group)
|
|
14
|
+
@bootpay.post('user-groups', user_group)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# 사용자 그룹 목록 조회
|
|
18
|
+
def list(params = {})
|
|
19
|
+
query_params = {}
|
|
20
|
+
query_params[:page] = params[:page] unless params[:page].nil?
|
|
21
|
+
query_params[:limit] = params[:limit] unless params[:limit].nil?
|
|
22
|
+
query_params[:keyword] = params[:keyword] if params[:keyword]
|
|
23
|
+
query_params[:corporate_type] = params[:corporate_type] unless params[:corporate_type].nil?
|
|
24
|
+
|
|
25
|
+
query = build_query(query_params)
|
|
26
|
+
@bootpay.get("user-groups#{query}")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# 사용자 그룹 상세 조회
|
|
30
|
+
def detail(user_group_id)
|
|
31
|
+
@bootpay.get("user-groups/#{user_group_id}")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# 사용자 그룹 수정
|
|
35
|
+
def update(user_group)
|
|
36
|
+
raise ArgumentError, 'user_group_id is required' unless user_group[:user_group_id]
|
|
37
|
+
@bootpay.put("user-groups/#{user_group[:user_group_id]}", user_group)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# 그룹에 사용자 추가
|
|
41
|
+
def user_create(user_group_id, user_id)
|
|
42
|
+
@bootpay.post("user-groups/#{user_group_id}/user", { user_id: user_id })
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# 그룹에서 사용자 제거
|
|
46
|
+
def user_delete(user_group_id, user_id)
|
|
47
|
+
@bootpay.delete("user-groups/#{user_group_id}/user/#{user_id}")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# 그룹 제한 설정
|
|
51
|
+
def limit(params)
|
|
52
|
+
raise ArgumentError, 'user_group_id is required' unless params[:user_group_id]
|
|
53
|
+
@bootpay.put("user-groups/#{params[:user_group_id]}/limit", params)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# 그룹 거래 집계
|
|
57
|
+
def aggregate_transaction(params)
|
|
58
|
+
raise ArgumentError, 'user_group_id is required' unless params[:user_group_id]
|
|
59
|
+
@bootpay.put("user-groups/#{params[:user_group_id]}/aggregate-transaction", params)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def build_query(params)
|
|
65
|
+
return '' if params.empty?
|
|
66
|
+
"?#{URI.encode_www_form(params)}"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
data/lib/bootpay/escrow.rb
CHANGED
data/lib/bootpay/rest.rb
CHANGED
|
@@ -7,18 +7,29 @@ module Bootpay::Rest
|
|
|
7
7
|
# HTTP Request 기본 Method
|
|
8
8
|
# Comment by Gosomi
|
|
9
9
|
# Date: 2021-05-21
|
|
10
|
-
def
|
|
10
|
+
def authorization_header
|
|
11
|
+
if @client_key.present? && @secret_key.present?
|
|
12
|
+
"Basic #{Base64.strict_encode64("#{@client_key}:#{@secret_key}")}"
|
|
13
|
+
elsif @token.present?
|
|
14
|
+
"Bearer #{@token}"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def request(method: :post, uri:, payload: {}, headers: {}, params: nil)
|
|
19
|
+
|
|
20
|
+
http_options = { json: payload }
|
|
21
|
+
http_options[:params] = params if params && !params.empty?
|
|
22
|
+
|
|
11
23
|
response = HTTP.headers(
|
|
12
24
|
{
|
|
13
|
-
|
|
14
|
-
Authorization: "#{@token}",
|
|
25
|
+
Authorization: authorization_header,
|
|
15
26
|
content_type: 'application/json',
|
|
16
27
|
accept: 'application/json'
|
|
17
28
|
}.merge!(headers).compact
|
|
18
29
|
).send(
|
|
19
30
|
method.to_sym,
|
|
20
31
|
[Bootpay::Api::API[@mode.to_sym], uri].join('/'),
|
|
21
|
-
|
|
32
|
+
**http_options
|
|
22
33
|
)
|
|
23
34
|
Bootpay::Response.new(
|
|
24
35
|
response.status.success?,
|
data/lib/bootpay/token.rb
CHANGED
|
@@ -6,6 +6,13 @@ module Bootpay::Token
|
|
|
6
6
|
# Comment by Gosomi
|
|
7
7
|
# Date: 2021-05-21
|
|
8
8
|
def request_access_token
|
|
9
|
+
# client_key/secret_key 인증은 매 요청에 Basic Auth 헤더가 자동 부착된다.
|
|
10
|
+
# request/token 호출이 불필요하므로 합성 응답을 즉시 반환한다.
|
|
11
|
+
if @client_key.present? && @secret_key.present?
|
|
12
|
+
@token = nil
|
|
13
|
+
return Bootpay::Response.new(true, { access_token: '', expire_in: 0 })
|
|
14
|
+
end
|
|
15
|
+
|
|
9
16
|
response = request(
|
|
10
17
|
uri: 'request/token',
|
|
11
18
|
payload: {
|
|
@@ -13,8 +20,14 @@ module Bootpay::Token
|
|
|
13
20
|
private_key: @private_key
|
|
14
21
|
}
|
|
15
22
|
)
|
|
16
|
-
|
|
23
|
+
if response.success?
|
|
24
|
+
# 기존 Ruby PG 응답(data.token)을 우선 유지하되, 다른 SDK/신규 응답(access_token)도
|
|
25
|
+
# 받을 수 있게 확장한다. 기존 응답 구조와 token 값에는 영향을 주지 않는다.
|
|
26
|
+
@token = response.data.dig(:data, :token)
|
|
27
|
+
@token ||= response.data[:access_token]
|
|
28
|
+
@token ||= response.data.dig(:data, :access_token)
|
|
29
|
+
end
|
|
17
30
|
response
|
|
18
|
-
end
|
|
31
|
+
end
|
|
19
32
|
end
|
|
20
|
-
end
|
|
33
|
+
end
|
data/lib/bootpay/version.rb
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module Bootpay::Wallet
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
included do
|
|
5
|
+
# 사용자 월렛 목록 조회
|
|
6
|
+
# Reference: Go SDK GetUserWallets
|
|
7
|
+
#
|
|
8
|
+
# @deprecated 다음 메이저 버전에서 제거 예정. wallet 엔드포인트는 폐기 예정이며,
|
|
9
|
+
# 결제는 Request::PaymentController#create 의 wallet_id + user_token 으로 처리됩니다.
|
|
10
|
+
def get_user_wallets(user_id:, sandbox: false)
|
|
11
|
+
warn '[DEPRECATION] `get_user_wallets` is deprecated and will be removed in a future major version.'
|
|
12
|
+
raise 'user_id 값을 입력해주세요.' if user_id.blank?
|
|
13
|
+
|
|
14
|
+
request(
|
|
15
|
+
method: :get,
|
|
16
|
+
uri: "wallet?user_id=#{user_id}&sandbox=#{sandbox}"
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# 월렛 결제 요청
|
|
21
|
+
# Reference: Go SDK RequestWalletPayment
|
|
22
|
+
#
|
|
23
|
+
# @deprecated 다음 메이저 버전에서 제거 예정. wallet 엔드포인트는 폐기 예정이며,
|
|
24
|
+
# 결제는 wallet_id + user_token 흐름으로 전환하세요.
|
|
25
|
+
def request_wallet_payment(user_id:, order_name:, price:, order_id:, tax_free: 0, sandbox: false,
|
|
26
|
+
webhook_url: nil, content_type: nil,
|
|
27
|
+
items: nil,
|
|
28
|
+
user_info: nil,
|
|
29
|
+
extra: nil,
|
|
30
|
+
metadata: nil)
|
|
31
|
+
warn '[DEPRECATION] `request_wallet_payment` is deprecated and will be removed in a future major version.'
|
|
32
|
+
raise 'user_id 값을 입력해주세요.' if user_id.blank?
|
|
33
|
+
raise 'order_name 값을 입력해주세요.' if order_name.blank?
|
|
34
|
+
raise 'price 금액을 설정해주세요.' if price.blank?
|
|
35
|
+
raise 'order_id 주문번호를 설정해주세요.' if order_id.blank?
|
|
36
|
+
|
|
37
|
+
request(
|
|
38
|
+
uri: 'wallet/payment',
|
|
39
|
+
payload: {
|
|
40
|
+
user_id: user_id,
|
|
41
|
+
order_name: order_name,
|
|
42
|
+
price: price,
|
|
43
|
+
tax_free: tax_free,
|
|
44
|
+
order_id: order_id,
|
|
45
|
+
sandbox: sandbox,
|
|
46
|
+
webhook_url: webhook_url,
|
|
47
|
+
content_type: content_type,
|
|
48
|
+
items: items,
|
|
49
|
+
user: user_info,
|
|
50
|
+
extra: extra,
|
|
51
|
+
metadata: metadata
|
|
52
|
+
}.compact
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
data/lib/bootpay.rb
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
require 'active_support/all'
|
|
2
|
+
require 'base64'
|
|
2
3
|
require 'http'
|
|
3
4
|
require_relative 'response'
|
|
5
|
+
require_relative 'bootpay/authentication'
|
|
6
|
+
require_relative 'bootpay/automatic_transfer'
|
|
4
7
|
require_relative 'bootpay/billing'
|
|
5
8
|
require_relative 'bootpay/cancel'
|
|
9
|
+
require_relative 'bootpay/cash_receipt'
|
|
6
10
|
require_relative 'bootpay/easy'
|
|
7
11
|
require_relative 'bootpay/escrow'
|
|
8
12
|
require_relative 'bootpay/link'
|
|
@@ -14,11 +18,15 @@ require_relative 'bootpay/submit'
|
|
|
14
18
|
require_relative 'bootpay/token'
|
|
15
19
|
require_relative 'bootpay/verification'
|
|
16
20
|
require_relative "bootpay/version"
|
|
21
|
+
require_relative 'bootpay/wallet'
|
|
17
22
|
|
|
18
23
|
module Bootpay
|
|
19
24
|
class Api
|
|
25
|
+
include Authentication
|
|
26
|
+
include AutomaticTransfer
|
|
20
27
|
include Billing
|
|
21
28
|
include Cancel
|
|
29
|
+
include CashReceipt
|
|
22
30
|
include Easy
|
|
23
31
|
include Escrow
|
|
24
32
|
include Link
|
|
@@ -29,21 +37,30 @@ module Bootpay
|
|
|
29
37
|
include Submit
|
|
30
38
|
include Token
|
|
31
39
|
include Verification
|
|
40
|
+
include Wallet
|
|
32
41
|
|
|
33
42
|
API =
|
|
34
43
|
{
|
|
35
|
-
development: 'https://dev-api.bootpay.co.kr/',
|
|
36
|
-
stage: 'https://stage-api.bootpay.co.kr/',
|
|
37
|
-
production: 'https://api.bootpay.co.kr/'
|
|
44
|
+
development: 'https://dev-api.bootpay.co.kr/v2',
|
|
45
|
+
stage: 'https://stage-api.bootpay.co.kr/v2',
|
|
46
|
+
production: 'https://api.bootpay.co.kr/v2',
|
|
47
|
+
ehowlsla: 'https://ehowlsla.bootpay.co.kr/api/v2'
|
|
38
48
|
}.freeze
|
|
39
49
|
|
|
40
|
-
def initialize(application_id
|
|
41
|
-
|
|
50
|
+
def initialize(application_id: nil, private_key: nil, client_key: nil, secret_key: nil, mode: 'production')
|
|
42
51
|
@application_id = application_id
|
|
43
52
|
@private_key = private_key
|
|
53
|
+
@client_key = client_key
|
|
54
|
+
@secret_key = secret_key
|
|
44
55
|
@mode = mode.presence || 'production'
|
|
45
56
|
@token = nil
|
|
57
|
+
|
|
46
58
|
raise ArgumentError, "개발환경 mode는 development, stage, production 중에서 선택이 가능합니다." if API[@mode.to_sym].blank?
|
|
59
|
+
if @client_key.present?
|
|
60
|
+
raise ArgumentError, 'secret_key 값이 비어있습니다.' if @secret_key.blank?
|
|
61
|
+
elsif @application_id.blank? || @private_key.blank?
|
|
62
|
+
raise ArgumentError, 'application_id/private_key 또는 client_key/secret_key를 입력해주세요.'
|
|
63
|
+
end
|
|
47
64
|
end
|
|
48
65
|
end
|
|
49
66
|
end
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'bootpay/commerce/commerce_resource'
|
|
4
|
+
require_relative 'bootpay/commerce/user'
|
|
5
|
+
require_relative 'bootpay/commerce/user_group'
|
|
6
|
+
require_relative 'bootpay/commerce/product'
|
|
7
|
+
require_relative 'bootpay/commerce/invoice'
|
|
8
|
+
require_relative 'bootpay/commerce/order'
|
|
9
|
+
require_relative 'bootpay/commerce/order_cancel'
|
|
10
|
+
require_relative 'bootpay/commerce/order_subscription'
|
|
11
|
+
require_relative 'bootpay/commerce/order_subscription_bill'
|
|
12
|
+
require_relative 'bootpay/commerce/order_subscription_adjustment'
|
|
13
|
+
require_relative 'bootpay/commerce/order_subscription_request'
|
|
14
|
+
require_relative 'bootpay/commerce/store'
|
|
15
|
+
require_relative 'bootpay/commerce/category'
|
|
16
|
+
require_relative 'bootpay/commerce/coupon'
|
|
17
|
+
require_relative 'bootpay/commerce/point'
|
|
18
|
+
require_relative 'bootpay/commerce/cart'
|
|
19
|
+
|
|
20
|
+
module Bootpay
|
|
21
|
+
module Commerce
|
|
22
|
+
# Bootpay Commerce API 클라이언트
|
|
23
|
+
#
|
|
24
|
+
# 사용 예시:
|
|
25
|
+
# commerce = Bootpay::Commerce::Api.new(
|
|
26
|
+
# client_key: 'your_client_key',
|
|
27
|
+
# secret_key: 'your_secret_key',
|
|
28
|
+
# mode: 'production'
|
|
29
|
+
# )
|
|
30
|
+
#
|
|
31
|
+
# # 액세스 토큰 발급
|
|
32
|
+
# token_response = commerce.get_access_token
|
|
33
|
+
#
|
|
34
|
+
# # Role 설정 (메서드 체이닝 지원)
|
|
35
|
+
# commerce.as_manager
|
|
36
|
+
#
|
|
37
|
+
# # 사용자 목록 조회
|
|
38
|
+
# users = commerce.user.list(page: 1, limit: 10)
|
|
39
|
+
#
|
|
40
|
+
# # 상품 생성 (이미지 포함)
|
|
41
|
+
# product = commerce.product.create({ name: '상품명', price: 10000 }, ['/path/to/image.jpg'])
|
|
42
|
+
#
|
|
43
|
+
class Api < CommerceResource
|
|
44
|
+
attr_reader :user, :user_group, :product, :invoice, :order,
|
|
45
|
+
:order_cancel, :order_subscription, :order_subscription_bill,
|
|
46
|
+
:order_subscription_adjustment, :order_subscription_request,
|
|
47
|
+
:store, :category, :coupon, :point, :cart
|
|
48
|
+
|
|
49
|
+
def initialize(client_key: nil, secret_key: nil, mode: 'production')
|
|
50
|
+
super()
|
|
51
|
+
if client_key && secret_key
|
|
52
|
+
set_configuration(client_key: client_key, secret_key: secret_key, mode: mode)
|
|
53
|
+
end
|
|
54
|
+
init_modules
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# 액세스 토큰 발급
|
|
58
|
+
# client_key/secret_key로 Basic Auth 인증
|
|
59
|
+
def get_access_token
|
|
60
|
+
response = post_with_basic_auth('request/token', {
|
|
61
|
+
client_key: @client_key,
|
|
62
|
+
secret_key: @secret_key
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
if response.is_a?(Hash) && response[:access_token]
|
|
66
|
+
set_token(response[:access_token])
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
response
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# 토큰을 발급받아 설정 (메서드 체이닝)
|
|
73
|
+
def with_token
|
|
74
|
+
get_access_token
|
|
75
|
+
self
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# 현재 설정된 토큰 반환
|
|
79
|
+
def current_token
|
|
80
|
+
get_token
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# 토큰이 설정되어 있는지 확인
|
|
84
|
+
def has_token?
|
|
85
|
+
token = get_token
|
|
86
|
+
!token.nil? && !token.empty?
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Role 설정 (메서드 체이닝)
|
|
90
|
+
def with_role(role)
|
|
91
|
+
set_role(role)
|
|
92
|
+
self
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# 일반 사용자 role로 설정
|
|
96
|
+
def as_user
|
|
97
|
+
with_role('user')
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# 매니저 role로 설정
|
|
101
|
+
def as_manager
|
|
102
|
+
with_role('manager')
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# 파트너 role로 설정
|
|
106
|
+
def as_partner
|
|
107
|
+
with_role('partner')
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# 벤더 role로 설정
|
|
111
|
+
def as_vendor
|
|
112
|
+
with_role('vendor')
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# 슈퍼바이저 role로 설정
|
|
116
|
+
def as_supervisor
|
|
117
|
+
with_role('supervisor')
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# 현재 role 반환
|
|
121
|
+
def current_role
|
|
122
|
+
get_role
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# role을 기본값(user)으로 초기화
|
|
126
|
+
def clear_role
|
|
127
|
+
set_role('user')
|
|
128
|
+
self
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
private
|
|
132
|
+
|
|
133
|
+
def init_modules
|
|
134
|
+
@user = UserModule.new(self)
|
|
135
|
+
@user_group = UserGroupModule.new(self)
|
|
136
|
+
@product = ProductModule.new(self)
|
|
137
|
+
@invoice = InvoiceModule.new(self)
|
|
138
|
+
@order = OrderModule.new(self)
|
|
139
|
+
@order_cancel = OrderCancelModule.new(self)
|
|
140
|
+
@order_subscription = OrderSubscriptionModule.new(self)
|
|
141
|
+
@order_subscription_bill = OrderSubscriptionBillModule.new(self)
|
|
142
|
+
@order_subscription_adjustment = OrderSubscriptionAdjustmentModule.new(self)
|
|
143
|
+
@order_subscription_request = OrderSubscriptionRequestModule.new(self)
|
|
144
|
+
@store = StoreModule.new(self)
|
|
145
|
+
@category = CategoryModule.new(self)
|
|
146
|
+
@coupon = CouponModule.new(self)
|
|
147
|
+
@point = PointModule.new(self)
|
|
148
|
+
@cart = CartModule.new(self)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bootpay
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- bootpay
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-05-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: http
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -45,7 +45,10 @@ executables: []
|
|
|
45
45
|
extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
|
47
47
|
files:
|
|
48
|
+
- ".DS_Store"
|
|
49
|
+
- ".env.example"
|
|
48
50
|
- ".gitignore"
|
|
51
|
+
- ".rspec"
|
|
49
52
|
- CHANGELOG.md
|
|
50
53
|
- CODE_OF_CONDUCT.md
|
|
51
54
|
- Gemfile
|
|
@@ -55,10 +58,30 @@ files:
|
|
|
55
58
|
- bin/console
|
|
56
59
|
- bin/setup
|
|
57
60
|
- bootpay.gemspec
|
|
61
|
+
- lib/.DS_Store
|
|
58
62
|
- lib/bootpay.rb
|
|
63
|
+
- lib/bootpay/.DS_Store
|
|
64
|
+
- lib/bootpay/authentication.rb
|
|
65
|
+
- lib/bootpay/automatic_transfer.rb
|
|
59
66
|
- lib/bootpay/billing.rb
|
|
60
|
-
- lib/bootpay/bootpay.rb
|
|
61
67
|
- lib/bootpay/cancel.rb
|
|
68
|
+
- lib/bootpay/cash_receipt.rb
|
|
69
|
+
- lib/bootpay/commerce/cart.rb
|
|
70
|
+
- lib/bootpay/commerce/category.rb
|
|
71
|
+
- lib/bootpay/commerce/commerce_resource.rb
|
|
72
|
+
- lib/bootpay/commerce/coupon.rb
|
|
73
|
+
- lib/bootpay/commerce/invoice.rb
|
|
74
|
+
- lib/bootpay/commerce/order.rb
|
|
75
|
+
- lib/bootpay/commerce/order_cancel.rb
|
|
76
|
+
- lib/bootpay/commerce/order_subscription.rb
|
|
77
|
+
- lib/bootpay/commerce/order_subscription_adjustment.rb
|
|
78
|
+
- lib/bootpay/commerce/order_subscription_bill.rb
|
|
79
|
+
- lib/bootpay/commerce/order_subscription_request.rb
|
|
80
|
+
- lib/bootpay/commerce/point.rb
|
|
81
|
+
- lib/bootpay/commerce/product.rb
|
|
82
|
+
- lib/bootpay/commerce/store.rb
|
|
83
|
+
- lib/bootpay/commerce/user.rb
|
|
84
|
+
- lib/bootpay/commerce/user_group.rb
|
|
62
85
|
- lib/bootpay/easy.rb
|
|
63
86
|
- lib/bootpay/escrow.rb
|
|
64
87
|
- lib/bootpay/link.rb
|
|
@@ -70,6 +93,8 @@ files:
|
|
|
70
93
|
- lib/bootpay/token.rb
|
|
71
94
|
- lib/bootpay/verification.rb
|
|
72
95
|
- lib/bootpay/version.rb
|
|
96
|
+
- lib/bootpay/wallet.rb
|
|
97
|
+
- lib/bootpay_commerce.rb
|
|
73
98
|
- lib/response.rb
|
|
74
99
|
homepage: http://www.bootpay.co.kr
|
|
75
100
|
licenses:
|
|
@@ -91,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
91
116
|
- !ruby/object:Gem::Version
|
|
92
117
|
version: '0'
|
|
93
118
|
requirements: []
|
|
94
|
-
rubygems_version: 3.
|
|
119
|
+
rubygems_version: 3.5.11
|
|
95
120
|
signing_key:
|
|
96
121
|
specification_version: 4
|
|
97
122
|
summary: Bootpay server side plugin for ruby
|