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,196 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'http'
|
|
4
|
+
require 'base64'
|
|
5
|
+
require 'json'
|
|
6
|
+
|
|
7
|
+
module Bootpay
|
|
8
|
+
module Commerce
|
|
9
|
+
class CommerceResource
|
|
10
|
+
API_ENTRYPOINTS = {
|
|
11
|
+
'development' => 'https://dev-api.bootapi.com/v1',
|
|
12
|
+
'stage' => 'https://stage-api.bootapi.com/v1',
|
|
13
|
+
'production' => 'https://api.bootapi.com/v1'
|
|
14
|
+
}.freeze
|
|
15
|
+
|
|
16
|
+
API_VERSION = '1.0.0'
|
|
17
|
+
SDK_VERSION = '1.0.0'
|
|
18
|
+
SDK_TYPE = '305' # Ruby
|
|
19
|
+
|
|
20
|
+
attr_reader :client_key, :secret_key, :mode
|
|
21
|
+
|
|
22
|
+
def initialize
|
|
23
|
+
@mode = 'production'
|
|
24
|
+
@token = nil
|
|
25
|
+
@role = 'user'
|
|
26
|
+
@client_key = nil
|
|
27
|
+
@secret_key = nil
|
|
28
|
+
@timeout = 60
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def set_configuration(client_key:, secret_key:, mode: 'production')
|
|
32
|
+
@client_key = client_key
|
|
33
|
+
@secret_key = secret_key
|
|
34
|
+
@mode = mode || 'production'
|
|
35
|
+
raise ArgumentError, "mode는 development, stage, production 중에서 선택이 가능합니다." unless API_ENTRYPOINTS.key?(@mode)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def set_token(token)
|
|
39
|
+
@token = token
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def get_token
|
|
43
|
+
@token
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def set_role(role)
|
|
47
|
+
@role = role
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def get_role
|
|
51
|
+
@role || 'user'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# GET request
|
|
55
|
+
def get(url, params = nil)
|
|
56
|
+
full_url = entrypoint(url)
|
|
57
|
+
response = HTTP.headers(default_headers)
|
|
58
|
+
.timeout(@timeout)
|
|
59
|
+
.get(full_url, params: params)
|
|
60
|
+
parse_response(response)
|
|
61
|
+
rescue StandardError => e
|
|
62
|
+
error_response(e)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# POST request with JSON body
|
|
66
|
+
def post(url, data = nil)
|
|
67
|
+
full_url = entrypoint(url)
|
|
68
|
+
response = HTTP.headers(default_headers)
|
|
69
|
+
.timeout(@timeout)
|
|
70
|
+
.post(full_url, json: data || {})
|
|
71
|
+
parse_response(response)
|
|
72
|
+
rescue StandardError => e
|
|
73
|
+
error_response(e)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# POST with Basic Auth (for token endpoint)
|
|
77
|
+
def post_with_basic_auth(url, data = nil)
|
|
78
|
+
headers = default_headers(include_auth: false)
|
|
79
|
+
headers['Authorization'] = basic_auth_header
|
|
80
|
+
full_url = entrypoint(url)
|
|
81
|
+
response = HTTP.headers(headers)
|
|
82
|
+
.timeout(@timeout)
|
|
83
|
+
.post(full_url, json: data || {})
|
|
84
|
+
parse_response(response)
|
|
85
|
+
rescue StandardError => e
|
|
86
|
+
error_response(e)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# POST multipart/form-data (for product images)
|
|
90
|
+
def post_multipart(url, data = {}, image_paths = nil)
|
|
91
|
+
headers = multipart_headers
|
|
92
|
+
full_url = entrypoint(url)
|
|
93
|
+
|
|
94
|
+
form_data = {}
|
|
95
|
+
data.each do |key, value|
|
|
96
|
+
next if value.nil?
|
|
97
|
+
if value.is_a?(Hash) || value.is_a?(Array)
|
|
98
|
+
form_data[key.to_s] = JSON.generate(value)
|
|
99
|
+
else
|
|
100
|
+
form_data[key.to_s] = value.to_s
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
if image_paths && !image_paths.empty?
|
|
105
|
+
files = image_paths.map do |path|
|
|
106
|
+
HTTP::FormData::File.new(path)
|
|
107
|
+
end
|
|
108
|
+
form_data['images'] = files.length == 1 ? files.first : files
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
form = HTTP::FormData::Multipart.new(form_data)
|
|
112
|
+
response = HTTP.headers(headers)
|
|
113
|
+
.timeout(@timeout)
|
|
114
|
+
.post(full_url, form: form)
|
|
115
|
+
parse_response(response)
|
|
116
|
+
rescue StandardError => e
|
|
117
|
+
error_response(e)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# PUT request
|
|
121
|
+
def put(url, data = nil)
|
|
122
|
+
full_url = entrypoint(url)
|
|
123
|
+
response = HTTP.headers(default_headers)
|
|
124
|
+
.timeout(@timeout)
|
|
125
|
+
.put(full_url, json: data || {})
|
|
126
|
+
parse_response(response)
|
|
127
|
+
rescue StandardError => e
|
|
128
|
+
error_response(e)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# DELETE request
|
|
132
|
+
def delete(url, params = nil)
|
|
133
|
+
full_url = entrypoint(url)
|
|
134
|
+
response = HTTP.headers(default_headers)
|
|
135
|
+
.timeout(@timeout)
|
|
136
|
+
.delete(full_url, params: params)
|
|
137
|
+
parse_response(response)
|
|
138
|
+
rescue StandardError => e
|
|
139
|
+
error_response(e)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
private
|
|
143
|
+
|
|
144
|
+
def entrypoint(url)
|
|
145
|
+
"#{API_ENTRYPOINTS[@mode]}/#{url}"
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def basic_auth_header
|
|
149
|
+
return '' unless @client_key && @secret_key
|
|
150
|
+
credentials = Base64.strict_encode64("#{@client_key}:#{@secret_key}")
|
|
151
|
+
"Basic #{credentials}"
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def default_headers(include_auth: true)
|
|
155
|
+
headers = {
|
|
156
|
+
'Content-Type' => 'application/json',
|
|
157
|
+
'Accept' => 'application/json',
|
|
158
|
+
'Accept-Charset' => 'utf-8',
|
|
159
|
+
'BOOTPAY-SDK-VERSION' => SDK_VERSION,
|
|
160
|
+
'BOOTPAY-API-VERSION' => API_VERSION,
|
|
161
|
+
'BOOTPAY-SDK-TYPE' => SDK_TYPE,
|
|
162
|
+
'BOOTPAY-ROLE' => @role || 'user'
|
|
163
|
+
}
|
|
164
|
+
if include_auth
|
|
165
|
+
basic = basic_auth_header
|
|
166
|
+
headers['Authorization'] = basic unless basic.empty?
|
|
167
|
+
end
|
|
168
|
+
headers
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def multipart_headers
|
|
172
|
+
headers = {
|
|
173
|
+
'Accept' => 'application/json',
|
|
174
|
+
'Accept-Charset' => 'utf-8',
|
|
175
|
+
'BOOTPAY-SDK-VERSION' => SDK_VERSION,
|
|
176
|
+
'BOOTPAY-API-VERSION' => API_VERSION,
|
|
177
|
+
'BOOTPAY-SDK-TYPE' => SDK_TYPE,
|
|
178
|
+
'BOOTPAY-ROLE' => @role || 'user'
|
|
179
|
+
}
|
|
180
|
+
basic = basic_auth_header
|
|
181
|
+
headers['Authorization'] = basic unless basic.empty?
|
|
182
|
+
headers
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def parse_response(response)
|
|
186
|
+
JSON.parse(response.body.to_s, symbolize_names: true)
|
|
187
|
+
rescue JSON::ParserError
|
|
188
|
+
{ success: false, message: 'Invalid JSON response' }
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def error_response(error)
|
|
192
|
+
{ success: false, message: "Commerce API 서버와의 통신이 실패하였습니다. 오류: #{error.message}" }
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module Bootpay
|
|
6
|
+
module Commerce
|
|
7
|
+
class CouponModule
|
|
8
|
+
def initialize(bootpay)
|
|
9
|
+
@bootpay = bootpay
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# 사용자 보유 쿠폰 목록
|
|
13
|
+
def list(params = {})
|
|
14
|
+
query_params = {}
|
|
15
|
+
query_params[:status] = params[:status] if params[:status]
|
|
16
|
+
query_params[:page] = params[:page] unless params[:page].nil?
|
|
17
|
+
query_params[:limit] = params[:limit] unless params[:limit].nil?
|
|
18
|
+
|
|
19
|
+
query = build_query(query_params)
|
|
20
|
+
@bootpay.get("coupon#{query}")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# 다운로드 가능한 쿠폰 목록
|
|
24
|
+
def available
|
|
25
|
+
@bootpay.get('coupon/available')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# 쿠폰 다운로드 (issue_from_template)
|
|
29
|
+
def download(params)
|
|
30
|
+
@bootpay.post('coupon/download', params)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def build_query(params)
|
|
36
|
+
return '' if params.empty?
|
|
37
|
+
"?#{URI.encode_www_form(params)}"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module Bootpay
|
|
6
|
+
module Commerce
|
|
7
|
+
class InvoiceModule
|
|
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
|
+
|
|
19
|
+
query = build_query(query_params)
|
|
20
|
+
@bootpay.get("invoices#{query}")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# 청구서 생성
|
|
24
|
+
def create(invoice)
|
|
25
|
+
@bootpay.post('invoices', invoice)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# 청구서 알림 발송
|
|
29
|
+
def notify(invoice_id, send_types)
|
|
30
|
+
@bootpay.post("invoices/#{invoice_id}/notify", { send_types: send_types })
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# 청구서 상세 조회
|
|
34
|
+
def detail(invoice_id)
|
|
35
|
+
@bootpay.get("invoices/#{invoice_id}")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def build_query(params)
|
|
41
|
+
return '' if params.empty?
|
|
42
|
+
"?#{URI.encode_www_form(params)}"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module Bootpay
|
|
6
|
+
module Commerce
|
|
7
|
+
class OrderModule
|
|
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[:user_id] = params[:user_id] if params[:user_id]
|
|
19
|
+
query_params[:user_group_id] = params[:user_group_id] if params[:user_group_id]
|
|
20
|
+
query_params[:cs_type] = params[:cs_type] if params[:cs_type]
|
|
21
|
+
query_params[:css_at] = params[:css_at] if params[:css_at]
|
|
22
|
+
query_params[:cse_at] = params[:cse_at] if params[:cse_at]
|
|
23
|
+
query_params[:subscription_billing_type] = params[:subscription_billing_type] unless params[:subscription_billing_type].nil?
|
|
24
|
+
|
|
25
|
+
if params[:status].is_a?(Array) && !params[:status].empty?
|
|
26
|
+
query_params[:status] = params[:status].map(&:to_s).join(',')
|
|
27
|
+
end
|
|
28
|
+
if params[:payment_status].is_a?(Array) && !params[:payment_status].empty?
|
|
29
|
+
query_params[:payment_status] = params[:payment_status].map(&:to_s).join(',')
|
|
30
|
+
end
|
|
31
|
+
if params[:order_subscription_ids].is_a?(Array) && !params[:order_subscription_ids].empty?
|
|
32
|
+
query_params[:order_subscription_ids] = params[:order_subscription_ids].join(',')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
query = build_query(query_params)
|
|
36
|
+
@bootpay.get("orders#{query}")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# 주문 상세 조회
|
|
40
|
+
def detail(order_id)
|
|
41
|
+
@bootpay.get("orders/#{order_id}")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# 월별 주문 조회
|
|
45
|
+
def month(user_group_id, search_date)
|
|
46
|
+
query_params = {
|
|
47
|
+
user_group_id: user_group_id,
|
|
48
|
+
search_date: search_date
|
|
49
|
+
}
|
|
50
|
+
@bootpay.get("orders/month?#{URI.encode_www_form(query_params)}")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def build_query(params)
|
|
56
|
+
return '' if params.empty?
|
|
57
|
+
"?#{URI.encode_www_form(params)}"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module Bootpay
|
|
6
|
+
module Commerce
|
|
7
|
+
class OrderCancelModule
|
|
8
|
+
def initialize(bootpay)
|
|
9
|
+
@bootpay = bootpay
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# 취소 요청 목록 조회
|
|
13
|
+
def list(params = {})
|
|
14
|
+
query_params = {}
|
|
15
|
+
query_params[:order_id] = params[:order_id] if params[:order_id]
|
|
16
|
+
query_params[:order_number] = params[:order_number] if params[:order_number]
|
|
17
|
+
|
|
18
|
+
query = build_query(query_params)
|
|
19
|
+
@bootpay.get("order/cancel#{query}")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# 취소 요청
|
|
23
|
+
def request(params)
|
|
24
|
+
@bootpay.post('order/cancel', params)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# 취소 요청 철회
|
|
28
|
+
def withdraw(order_cancel_request_history_id)
|
|
29
|
+
@bootpay.put("order/cancel/#{order_cancel_request_history_id}/withdraw", {})
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# 취소 승인
|
|
33
|
+
def approve(params)
|
|
34
|
+
raise ArgumentError, 'order_cancel_request_history_id is required' unless params[:order_cancel_request_history_id]
|
|
35
|
+
@bootpay.put("order/cancel/#{params[:order_cancel_request_history_id]}/approve", params)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# 취소 거절
|
|
39
|
+
def reject(params)
|
|
40
|
+
raise ArgumentError, 'order_cancel_request_history_id is required' unless params[:order_cancel_request_history_id]
|
|
41
|
+
@bootpay.put("order/cancel/#{params[:order_cancel_request_history_id]}/reject", params)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def build_query(params)
|
|
47
|
+
return '' if params.empty?
|
|
48
|
+
"?#{URI.encode_www_form(params)}"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module Bootpay
|
|
6
|
+
module Commerce
|
|
7
|
+
# 정기구독 진행 중 요청 모듈
|
|
8
|
+
class OrderSubscriptionRequestIngModule
|
|
9
|
+
def initialize(bootpay)
|
|
10
|
+
@bootpay = bootpay
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# 정기구독 일시정지
|
|
14
|
+
def pause(params)
|
|
15
|
+
@bootpay.post('order_subscriptions/requests/ing/pause', params)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# 정기구독 재개
|
|
19
|
+
def resume(params)
|
|
20
|
+
@bootpay.put('order_subscriptions/requests/ing/resume', params)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# 해지 수수료 계산
|
|
24
|
+
def calculate_termination_fee(order_subscription_id: nil, order_number: nil)
|
|
25
|
+
raise ArgumentError, 'order_subscription_id or order_number is required' if order_subscription_id.nil? && order_number.nil?
|
|
26
|
+
|
|
27
|
+
query_params = {}
|
|
28
|
+
if order_subscription_id
|
|
29
|
+
query_params[:order_subscription_id] = order_subscription_id
|
|
30
|
+
elsif order_number
|
|
31
|
+
query_params[:order_number] = order_number
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
@bootpay.get("order_subscriptions/requests/ing/calculate_termination_fee?#{URI.encode_www_form(query_params)}")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# 주문번호로 해지 수수료 계산
|
|
38
|
+
def calculate_termination_fee_by_order_number(order_number)
|
|
39
|
+
calculate_termination_fee(order_number: order_number)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# 정기구독 해지
|
|
43
|
+
def termination(params)
|
|
44
|
+
@bootpay.post('order_subscriptions/requests/ing/termination', params)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# 정기구독 모듈
|
|
49
|
+
class OrderSubscriptionModule
|
|
50
|
+
attr_reader :request_ing
|
|
51
|
+
|
|
52
|
+
def initialize(bootpay)
|
|
53
|
+
@bootpay = bootpay
|
|
54
|
+
@request_ing = OrderSubscriptionRequestIngModule.new(bootpay)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# 정기구독 목록 조회
|
|
58
|
+
def list(params = {})
|
|
59
|
+
query_params = {}
|
|
60
|
+
query_params[:page] = params[:page] unless params[:page].nil?
|
|
61
|
+
query_params[:limit] = params[:limit] unless params[:limit].nil?
|
|
62
|
+
query_params[:keyword] = params[:keyword] if params[:keyword]
|
|
63
|
+
query_params[:s_at] = params[:s_at] if params[:s_at]
|
|
64
|
+
query_params[:e_at] = params[:e_at] if params[:e_at]
|
|
65
|
+
query_params[:request_type] = params[:request_type] if params[:request_type]
|
|
66
|
+
query_params[:user_group_id] = params[:user_group_id] if params[:user_group_id]
|
|
67
|
+
query_params[:user_id] = params[:user_id] if params[:user_id]
|
|
68
|
+
|
|
69
|
+
query = build_query(query_params)
|
|
70
|
+
@bootpay.get("order_subscriptions#{query}")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# 정기구독 상세 조회
|
|
74
|
+
def detail(order_subscription_id)
|
|
75
|
+
@bootpay.get("order_subscriptions/#{order_subscription_id}")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# 정기구독 수정
|
|
79
|
+
def update(params)
|
|
80
|
+
raise ArgumentError, 'order_subscription_id is required' unless params[:order_subscription_id]
|
|
81
|
+
@bootpay.put("order_subscriptions/#{params[:order_subscription_id]}", params)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Supervisor: 정기구독 승인
|
|
85
|
+
def supervisor_approve(order_subscription_id, params = {})
|
|
86
|
+
@bootpay.put("order_subscriptions/#{order_subscription_id}/approve", params)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Supervisor: 정기구독 거절
|
|
90
|
+
def supervisor_reject(order_subscription_id, params = {})
|
|
91
|
+
@bootpay.put("order_subscriptions/#{order_subscription_id}/reject", params)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Supervisor: 정기구독 해지
|
|
95
|
+
def supervisor_terminate(order_subscription_id, params = {})
|
|
96
|
+
@bootpay.put("order_subscriptions/#{order_subscription_id}/terminate", params)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Supervisor: 정기구독 일시정지
|
|
100
|
+
def supervisor_pause(order_subscription_id, params)
|
|
101
|
+
@bootpay.put("order_subscriptions/#{order_subscription_id}/pause", params)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Supervisor: 정기구독 재개
|
|
105
|
+
def supervisor_resume(order_subscription_id, params = {})
|
|
106
|
+
@bootpay.put("order_subscriptions/#{order_subscription_id}/resume", params)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
private
|
|
110
|
+
|
|
111
|
+
def build_query(params)
|
|
112
|
+
return '' if params.empty?
|
|
113
|
+
"?#{URI.encode_www_form(params)}"
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bootpay
|
|
4
|
+
module Commerce
|
|
5
|
+
class OrderSubscriptionAdjustmentModule
|
|
6
|
+
def initialize(bootpay)
|
|
7
|
+
@bootpay = bootpay
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# 정기구독 조정 생성
|
|
11
|
+
def create(order_subscription_id, adjustment)
|
|
12
|
+
@bootpay.post("order_subscriptions/#{order_subscription_id}/adjustments", adjustment)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# 정기구독 조정 수정
|
|
16
|
+
def update(params)
|
|
17
|
+
raise ArgumentError, 'order_subscription_id is required' unless params[:order_subscription_id]
|
|
18
|
+
@bootpay.put("order_subscriptions/#{params[:order_subscription_id]}/adjustments", params)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# 정기구독 조정 삭제
|
|
22
|
+
def delete(order_subscription_id, order_subscription_adjustment_id)
|
|
23
|
+
@bootpay.delete(
|
|
24
|
+
"order_subscriptions/#{order_subscription_id}/adjustments?order_subscription_adjustment_id=#{order_subscription_adjustment_id}"
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module Bootpay
|
|
6
|
+
module Commerce
|
|
7
|
+
class OrderSubscriptionBillModule
|
|
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[:order_subscription_id] = params[:order_subscription_id] if params[:order_subscription_id]
|
|
19
|
+
|
|
20
|
+
if params[:status].is_a?(Array) && !params[:status].empty?
|
|
21
|
+
query_params[:status] = params[:status].map(&:to_s).join(',')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
query = build_query(query_params)
|
|
25
|
+
@bootpay.get("order_subscription_bills#{query}")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# 정기구독 청구 상세 조회
|
|
29
|
+
def detail(order_subscription_bill_id)
|
|
30
|
+
@bootpay.get("order_subscription_bills/#{order_subscription_bill_id}")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# 정기구독 청구 수정
|
|
34
|
+
def update(order_subscription_bill)
|
|
35
|
+
raise ArgumentError, 'order_subscription_bill_id is required' unless order_subscription_bill[:order_subscription_bill_id]
|
|
36
|
+
@bootpay.put(
|
|
37
|
+
"order_subscription_bills/#{order_subscription_bill[:order_subscription_bill_id]}",
|
|
38
|
+
order_subscription_bill
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def build_query(params)
|
|
45
|
+
return '' if params.empty?
|
|
46
|
+
"?#{URI.encode_www_form(params)}"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module Bootpay
|
|
6
|
+
module Commerce
|
|
7
|
+
# V1 OrderSubscription Request 조회/승인 모듈
|
|
8
|
+
#
|
|
9
|
+
# 본인 모드 (user role): project_id 없이 호출 → 본인 요청 목록/단건
|
|
10
|
+
# 슈퍼바이저 모드 (supervisor role): project_id 포함 → 프로젝트 전체 + update (승인/거절)
|
|
11
|
+
#
|
|
12
|
+
# 구매자측 요청 생성 (pause/resume/termination 등) 은
|
|
13
|
+
# `commerce.order_subscription.request_ing.*` 모듈을 사용한다.
|
|
14
|
+
class OrderSubscriptionRequestModule
|
|
15
|
+
def initialize(bootpay)
|
|
16
|
+
@bootpay = bootpay
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# 요청 목록 조회 (user / supervisor 공용)
|
|
20
|
+
def list(params = {})
|
|
21
|
+
query_params = {}
|
|
22
|
+
query_params[:project_id] = params[:project_id] if params[:project_id]
|
|
23
|
+
query_params[:page] = params[:page] unless params[:page].nil?
|
|
24
|
+
query_params[:limit] = params[:limit] unless params[:limit].nil?
|
|
25
|
+
query_params[:request_type] = params[:request_type] unless params[:request_type].nil?
|
|
26
|
+
query_params[:status] = params[:status] unless params[:status].nil?
|
|
27
|
+
query_params[:s_at] = params[:s_at] if params[:s_at]
|
|
28
|
+
query_params[:e_at] = params[:e_at] if params[:e_at]
|
|
29
|
+
query_params[:keyword] = params[:keyword] if params[:keyword]
|
|
30
|
+
|
|
31
|
+
query = build_query(query_params)
|
|
32
|
+
@bootpay.get("order-subscription-requests#{query}")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# 요청 단건 조회 (user / supervisor 공용)
|
|
36
|
+
def detail(order_subscription_request_history_id, project_id: nil)
|
|
37
|
+
query_params = {}
|
|
38
|
+
query_params[:project_id] = project_id if project_id
|
|
39
|
+
|
|
40
|
+
query = build_query(query_params)
|
|
41
|
+
@bootpay.get("order-subscription-requests/#{order_subscription_request_history_id}#{query}")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# 요청 승인/거절 (supervisor 전용)
|
|
45
|
+
def update(params)
|
|
46
|
+
raise ArgumentError, 'order_subscription_request_history_id is required' unless params[:order_subscription_request_history_id]
|
|
47
|
+
history_id = params[:order_subscription_request_history_id]
|
|
48
|
+
body = params.reject { |k, _| k == :order_subscription_request_history_id }
|
|
49
|
+
@bootpay.put("order-subscription-requests/#{history_id}", body)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
def build_query(params)
|
|
55
|
+
return '' if params.empty?
|
|
56
|
+
"?#{URI.encode_www_form(params)}"
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module Bootpay
|
|
6
|
+
module Commerce
|
|
7
|
+
class PointModule
|
|
8
|
+
def initialize(bootpay)
|
|
9
|
+
@bootpay = bootpay
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# 적립금 잔액 조회
|
|
13
|
+
def balance
|
|
14
|
+
@bootpay.get('point/balance')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# 적립금 내역 조회
|
|
18
|
+
def transactions(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[:transaction_type] = params[:transaction_type] unless params[:transaction_type].nil?
|
|
23
|
+
|
|
24
|
+
query = build_query(query_params)
|
|
25
|
+
@bootpay.get("point/transactions#{query}")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def build_query(params)
|
|
31
|
+
return '' if params.empty?
|
|
32
|
+
"?#{URI.encode_www_form(params)}"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|