bootpay 1.2.0 → 3.1.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/.gitignore +8 -9
- data/.rspec +2 -0
- data/CHANGELOG.md +107 -21
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile +1 -3
- data/LICENSE.txt +1 -1
- data/README.md +309 -196
- data/Rakefile +3 -3
- data/bin/console +1 -1
- data/bootpay.gemspec +22 -20
- data/lib/bootpay/bootpay-rest-client.rb +51 -0
- data/lib/bootpay/concern/authenticate.rb +69 -0
- data/lib/bootpay/concern/cash_receipt.rb +83 -0
- data/lib/bootpay/concern/easy.rb +18 -0
- data/lib/bootpay/concern/escrow.rb +25 -0
- data/lib/bootpay/concern/payment.rb +126 -0
- data/lib/bootpay/concern/reseller.rb +97 -0
- data/lib/bootpay/concern/rest.rb +56 -0
- data/lib/bootpay/concern/sdk.rb +52 -0
- data/lib/bootpay/concern/seller.rb +15 -0
- data/lib/bootpay/concern/service.rb +15 -0
- data/lib/bootpay/concern/subscription.rb +211 -0
- data/lib/bootpay/concern/token.rb +33 -0
- data/lib/bootpay/concern/user_token.rb +23 -0
- data/lib/bootpay/concern/wallet.rb +20 -0
- data/lib/bootpay/concern/webhook.rb +18 -0
- data/lib/bootpay/concern.rb +35 -0
- data/lib/bootpay-backend-ruby.rb +6 -0
- data/lib/bootpay.rb +10 -66
- data/lib/bootpay_storage/bootpay-storage-rest-client.rb +46 -0
- data/lib/bootpay_storage/concern/csv.rb +18 -0
- data/lib/bootpay_storage/concern/image.rb +30 -0
- data/lib/bootpay_storage/concern/rest.rb +176 -0
- data/lib/bootpay_storage/concern/token.rb +9 -0
- data/lib/bootpay_storage/concern.rb +12 -0
- data/lib/bootpay_storage/response.rb +14 -0
- data/lib/bootpay_store/bootpay-store-rest-client.rb +62 -0
- data/lib/bootpay_store/concern/alimtalk_message.rb +67 -0
- data/lib/bootpay_store/concern/alimtalk_official.rb +63 -0
- data/lib/bootpay_store/concern/alimtalk_optout.rb +72 -0
- data/lib/bootpay_store/concern/alimtalk_send.rb +92 -0
- data/lib/bootpay_store/concern/alimtalk_sender.rb +105 -0
- data/lib/bootpay_store/concern/alimtalk_template.rb +215 -0
- data/lib/bootpay_store/concern/alimtalk_webhook.rb +84 -0
- data/lib/bootpay_store/concern/faq.rb +97 -0
- data/lib/bootpay_store/concern/inquiry.rb +138 -0
- data/lib/bootpay_store/concern/invoice.rb +102 -0
- data/lib/bootpay_store/concern/mall_setting.rb +385 -0
- data/lib/bootpay_store/concern/notice.rb +100 -0
- data/lib/bootpay_store/concern/order.rb +74 -0
- data/lib/bootpay_store/concern/order_subscription.rb +391 -0
- data/lib/bootpay_store/concern/payment.rb +119 -0
- data/lib/bootpay_store/concern/product.rb +175 -0
- data/lib/bootpay_store/concern/product_qna.rb +149 -0
- data/lib/bootpay_store/concern/product_review.rb +145 -0
- data/lib/bootpay_store/concern/rest.rb +139 -0
- data/lib/bootpay_store/concern/store.rb +31 -0
- data/lib/bootpay_store/concern/supervisor.rb +211 -0
- data/lib/bootpay_store/concern/token.rb +24 -0
- data/lib/bootpay_store/concern/user.rb +325 -0
- data/lib/bootpay_store/concern/user_group.rb +221 -0
- data/lib/bootpay_store/concern/webhook.rb +17 -0
- data/lib/bootpay_store/concern.rb +55 -0
- data/lib/bootpay_store/response.rb +14 -0
- data/lib/version.rb +9 -0
- metadata +82 -49
- data/.DS_Store +0 -0
- data/.env.example +0 -23
- data/lib/.DS_Store +0 -0
- data/lib/bootpay/.DS_Store +0 -0
- data/lib/bootpay/authentication.rb +0 -61
- data/lib/bootpay/automatic_transfer.rb +0 -56
- data/lib/bootpay/billing.rb +0 -157
- data/lib/bootpay/cancel.rb +0 -29
- data/lib/bootpay/cash_receipt.rb +0 -77
- data/lib/bootpay/commerce/cart.rb +0 -20
- data/lib/bootpay/commerce/category.rb +0 -39
- data/lib/bootpay/commerce/commerce_resource.rb +0 -196
- data/lib/bootpay/commerce/coupon.rb +0 -41
- data/lib/bootpay/commerce/invoice.rb +0 -46
- data/lib/bootpay/commerce/order.rb +0 -61
- data/lib/bootpay/commerce/order_cancel.rb +0 -52
- data/lib/bootpay/commerce/order_subscription.rb +0 -117
- data/lib/bootpay/commerce/order_subscription_adjustment.rb +0 -29
- data/lib/bootpay/commerce/order_subscription_bill.rb +0 -50
- data/lib/bootpay/commerce/order_subscription_request.rb +0 -60
- data/lib/bootpay/commerce/point.rb +0 -36
- data/lib/bootpay/commerce/product.rb +0 -63
- data/lib/bootpay/commerce/store.rb +0 -21
- data/lib/bootpay/commerce/user.rb +0 -75
- data/lib/bootpay/commerce/user_group.rb +0 -70
- data/lib/bootpay/easy.rb +0 -25
- data/lib/bootpay/escrow.rb +0 -24
- data/lib/bootpay/link.rb +0 -60
- data/lib/bootpay/naverpay.rb +0 -17
- data/lib/bootpay/payment_resource.rb +0 -31
- data/lib/bootpay/reseller.rb +0 -12
- data/lib/bootpay/rest.rb +0 -46
- data/lib/bootpay/submit.rb +0 -20
- data/lib/bootpay/token.rb +0 -33
- data/lib/bootpay/verification.rb +0 -55
- data/lib/bootpay/version.rb +0 -25
- data/lib/bootpay/wallet.rb +0 -56
- data/lib/bootpay_commerce.rb +0 -152
- /data/lib/{response.rb → bootpay/response.rb} +0 -0
data/lib/bootpay/link.rb
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Comment by ehowlsla
|
|
3
|
-
# Date: 2021-08-31
|
|
4
|
-
# @return [Hash]
|
|
5
|
-
module Bootpay::Link
|
|
6
|
-
extend ActiveSupport::Concern
|
|
7
|
-
|
|
8
|
-
included do
|
|
9
|
-
# item 모델 설명
|
|
10
|
-
# {
|
|
11
|
-
# item_name: '', # 상품명
|
|
12
|
-
# qty: 1, # 수량
|
|
13
|
-
# unique: '', # 상품 고유키
|
|
14
|
-
# price: 1000, # 상품단가
|
|
15
|
-
# cat1: '', # 카테고리 상
|
|
16
|
-
# cat2: '', # 카테고리 중
|
|
17
|
-
# cat3: '' # 카테고리 하
|
|
18
|
-
# }
|
|
19
|
-
def request_link(pg: nil, method: nil, methods: nil, price: nil, order_id: nil, params: nil, tax_free: nil, name: nil,
|
|
20
|
-
user_info: {
|
|
21
|
-
id: nil, # 개발사에서 관리하는 회원 고유 id
|
|
22
|
-
username: nil, # 구매자 이름
|
|
23
|
-
email: nil, # 구매자 email
|
|
24
|
-
phone: nil, # 01012341234
|
|
25
|
-
gender: nil, # 0:여자, 1:남자
|
|
26
|
-
area: nil, # 서울|인천|대구|광주|부산|울산|경기|강원|충청북도|충북|충청남도|충남|전라북도|전북|전라남도|전남|경상북도|경북|경상남도|경남|제주|세종|대전 중 택 1
|
|
27
|
-
birth: nil # 생일 901004
|
|
28
|
-
},
|
|
29
|
-
items: nil, # item array
|
|
30
|
-
extra: {
|
|
31
|
-
escrow: nil, # 에스크로 연동 시 true, 기본값 false
|
|
32
|
-
quota: nil, #List<int> 형태, 결제금액이 5만원 이상시 할부개월 허용범위를 설정할 수 있음, ex) "0,2,3" 지정시 - [0(일시불), 2개월, 3개월] 허용, 미설정시 PG사별 기본값 적용, 1 지정시 에러가 발생할 수 있음
|
|
33
|
-
disp_cash_result: nil, # 현금영수증 노출할지 말지 (가상계좌 이용시)
|
|
34
|
-
offer_period: nil, # 통합결제창, PG 정기결제창에서 표시되는 '월 자동결제'에 해당하는 문구를 지정한 값으로 변경, 지원하는 PG사만 적용 가능
|
|
35
|
-
theme: nil, # 통합결제창 테마, [ red, purple(기본), custom ] 중 택 1
|
|
36
|
-
custom_background: nil, # 통합결제창 배경색, ex) "#00a086" theme가 custom 일 때 background 색상 지정 가능
|
|
37
|
-
custom_font_color: nil # 통합결제창 글자색, ex) "#ffffff" theme가 custom 일 때 font color 색상 지정 가능
|
|
38
|
-
}
|
|
39
|
-
)
|
|
40
|
-
request(
|
|
41
|
-
uri: 'request/payment',
|
|
42
|
-
payload:
|
|
43
|
-
{
|
|
44
|
-
pg: pg, # [PG 결제] 사용하고자 하는 PG사의 Alias를 입력. ex) danal, kcp, inicis등, 미 지정시 통합결제창이 오픈
|
|
45
|
-
method: method, # card:카드, phone: 휴대폰, bank: 실시간 계좌이체, vbank: 가상계좌, auth: 본인인증, card_rebill: 정기결제, easy: 카카오,페이코,네이버페이 등의 간편결제, 미지정시 통합결제창 오픈
|
|
46
|
-
methods: methods, # 통합결제시 사용할 method 배열 형태
|
|
47
|
-
price: price, # 결제금액
|
|
48
|
-
order_id: order_id, # 개발사에서 관리하는 고유결제번호
|
|
49
|
-
params: params, # string 형태로 전달 할 값, 결제 후 똑같이 리턴해드림
|
|
50
|
-
tax_free: tax_free, # 비과세 금액
|
|
51
|
-
name: name, # 결제할 상품명
|
|
52
|
-
user_info: user_info, # 구매자 정보
|
|
53
|
-
items: items, # 상품정보
|
|
54
|
-
# return_url: return_url, # 결제후 이동할 페이지 url, 아직 사용하지 않음
|
|
55
|
-
extra: extra.values.any? {|v|v != nil} ? extra : nil # 기타 옵션
|
|
56
|
-
}.compact
|
|
57
|
-
)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
data/lib/bootpay/naverpay.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# bootpay dev api
|
|
3
|
-
# Comment by Gosomi
|
|
4
|
-
# Date: 2020-06-18
|
|
5
|
-
# @return [Hash]
|
|
6
|
-
module Bootpay::Naverpay
|
|
7
|
-
extend ActiveSupport::Concern
|
|
8
|
-
|
|
9
|
-
included do
|
|
10
|
-
def naverpay_item_response(data)
|
|
11
|
-
request(
|
|
12
|
-
uri: 'npay/product',
|
|
13
|
-
payload: data
|
|
14
|
-
)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# bootpay dev api
|
|
2
|
-
# Comment by Gosomi
|
|
3
|
-
# Date: 2020-06-18
|
|
4
|
-
# @return [Hash]
|
|
5
|
-
module Bootpay::PaymentResource
|
|
6
|
-
extend ActiveSupport::Concern
|
|
7
|
-
|
|
8
|
-
included do
|
|
9
|
-
def update_pg_resource(data)
|
|
10
|
-
request(
|
|
11
|
-
uri: 'project/payment',
|
|
12
|
-
payload: data
|
|
13
|
-
)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
#----------------------------------------------------------
|
|
17
|
-
# 새로운 웹훅을 실행한다
|
|
18
|
-
# Comment by Gosomi
|
|
19
|
-
# Date: 2021-12-21
|
|
20
|
-
#----------------------------------------------------------
|
|
21
|
-
def create_webhook(receipt_id:, webhook_url:)
|
|
22
|
-
request(
|
|
23
|
-
uri: 'webhook',
|
|
24
|
-
payload: {
|
|
25
|
-
receipt_id: receipt_id,
|
|
26
|
-
webhook_url: webhook_url
|
|
27
|
-
}
|
|
28
|
-
)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
data/lib/bootpay/reseller.rb
DELETED
data/lib/bootpay/rest.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
module Bootpay::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 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
|
-
|
|
23
|
-
response = HTTP.headers(
|
|
24
|
-
{
|
|
25
|
-
Authorization: authorization_header,
|
|
26
|
-
content_type: 'application/json',
|
|
27
|
-
accept: 'application/json'
|
|
28
|
-
}.merge!(headers).compact
|
|
29
|
-
).send(
|
|
30
|
-
method.to_sym,
|
|
31
|
-
[Bootpay::Api::API[@mode.to_sym], uri].join('/'),
|
|
32
|
-
**http_options
|
|
33
|
-
)
|
|
34
|
-
Bootpay::Response.new(
|
|
35
|
-
response.status.success?,
|
|
36
|
-
JSON.parse(response.body.to_s, symbolize_names: true)
|
|
37
|
-
)
|
|
38
|
-
rescue Exception => e
|
|
39
|
-
Bootpay::Response.new(
|
|
40
|
-
false,
|
|
41
|
-
message: "부트페이 API 서버와의 통신이 실패하였습니다. 오류 메세지: #{e.message}",
|
|
42
|
-
backtrace: e.backtrace.join("\n")
|
|
43
|
-
)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
data/lib/bootpay/submit.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Comment by ehowlsla
|
|
3
|
-
# Date: 2021-08-31
|
|
4
|
-
# @return [Hash]
|
|
5
|
-
module Bootpay::Submit
|
|
6
|
-
extend ActiveSupport::Concern
|
|
7
|
-
|
|
8
|
-
included do
|
|
9
|
-
def server_submit(receipt_id)
|
|
10
|
-
raise 'receipt_id 값을 입력해주세요.' if receipt_id.blank?
|
|
11
|
-
|
|
12
|
-
request(
|
|
13
|
-
uri: 'submit',
|
|
14
|
-
payload: {
|
|
15
|
-
receipt_id: receipt_id
|
|
16
|
-
}
|
|
17
|
-
)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
data/lib/bootpay/token.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
module Bootpay::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
|
-
# 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
|
-
|
|
16
|
-
response = request(
|
|
17
|
-
uri: 'request/token',
|
|
18
|
-
payload: {
|
|
19
|
-
application_id: @application_id,
|
|
20
|
-
private_key: @private_key
|
|
21
|
-
}
|
|
22
|
-
)
|
|
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
|
|
30
|
-
response
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
data/lib/bootpay/verification.rb
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
module Bootpay::Verification
|
|
2
|
-
extend ActiveSupport::Concern
|
|
3
|
-
|
|
4
|
-
included do
|
|
5
|
-
|
|
6
|
-
# 결제 검증하기
|
|
7
|
-
# Comment by ehowlsla
|
|
8
|
-
# Date: 2021-08-31
|
|
9
|
-
def verify(receipt_id)
|
|
10
|
-
raise 'receipt_id 값을 입력해주세요' if receipt_id.nil?
|
|
11
|
-
request(
|
|
12
|
-
method: :get,
|
|
13
|
-
uri: "receipt/#{receipt_id}"
|
|
14
|
-
)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# bootpay dev api
|
|
18
|
-
# Comment by ehowlsla
|
|
19
|
-
# Date: 2021-08-31
|
|
20
|
-
def subscribe_verify(receipt_id)
|
|
21
|
-
raise 'receipt_id 값을 입력해주세요' if receipt_id.nil?
|
|
22
|
-
request(
|
|
23
|
-
method: :get,
|
|
24
|
-
uri: "subscribe/billing/#{receipt_id}"
|
|
25
|
-
)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# 서버 승인하기
|
|
29
|
-
# Comment by ehowlsla
|
|
30
|
-
# Date: 2021-08-31
|
|
31
|
-
def confirm(receipt_id)
|
|
32
|
-
raise 'receipt_id 값을 입력해주세요' if receipt_id.nil?
|
|
33
|
-
request(
|
|
34
|
-
uri: "submit",
|
|
35
|
-
payload: {
|
|
36
|
-
receipt_id: receipt_id
|
|
37
|
-
}.compact
|
|
38
|
-
)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# 본인인증 검증하기
|
|
42
|
-
# Comment by ehowlsla
|
|
43
|
-
# Date: 2021-08-31
|
|
44
|
-
def certificate(receipt_id)
|
|
45
|
-
raise 'receipt_id 값을 입력해주세요' if receipt_id.nil?
|
|
46
|
-
request(
|
|
47
|
-
method: :get,
|
|
48
|
-
uri: "certificate/#{receipt_id}",
|
|
49
|
-
payload: {
|
|
50
|
-
receipt_id: receipt_id
|
|
51
|
-
}.compact
|
|
52
|
-
)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
data/lib/bootpay/version.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Bootpay
|
|
4
|
-
VERSION = "1.2.0"
|
|
5
|
-
BANKCODE = {
|
|
6
|
-
"한국은행" => "001",
|
|
7
|
-
"기업은행" => "003",
|
|
8
|
-
"국민은행" => "004",
|
|
9
|
-
"외환은행" => "005",
|
|
10
|
-
"수협은행" => "007",
|
|
11
|
-
"농협은행" => "011",
|
|
12
|
-
"우리은행" => "020",
|
|
13
|
-
"SC은행" => "023",
|
|
14
|
-
"대구은행" => "031",
|
|
15
|
-
"부산은행" => "032",
|
|
16
|
-
"광주은행" => "034",
|
|
17
|
-
"경남은행" => "039",
|
|
18
|
-
"우체국" => "071",
|
|
19
|
-
"KEB하나은행" => "081",
|
|
20
|
-
"신한은행" => "088",
|
|
21
|
-
"케이뱅크" => "089",
|
|
22
|
-
"카카오뱅크" => "090",
|
|
23
|
-
}
|
|
24
|
-
end
|
|
25
|
-
|
data/lib/bootpay/wallet.rb
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
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_commerce.rb
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
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
|
|
File without changes
|