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/billing.rb
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
module Bootpay::Billing
|
|
2
|
-
extend ActiveSupport::Concern
|
|
3
|
-
|
|
4
|
-
included do
|
|
5
|
-
# 빌링키 가져오기
|
|
6
|
-
# Comment by ehowlsla
|
|
7
|
-
# Date: 2021-08-30
|
|
8
|
-
def get_billing_key(order_id: nil, pg: nil, item_name: nil, card_no: nil, card_pw: nil, expire_year: nil, expire_month: nil, identify_number: nil,
|
|
9
|
-
user_info: { # 구매자 정보
|
|
10
|
-
id: nil, # 개발사에서 관리하는 회원 고유 id
|
|
11
|
-
username: nil, # 구매자 이름
|
|
12
|
-
email: nil, # 구매자 email
|
|
13
|
-
phone: nil, # 01012341234
|
|
14
|
-
gender: nil, # 0:여자, 1:남자
|
|
15
|
-
area: nil, # 서울|인천|대구|광주|부산|울산|경기|강원|충청북도|충북|충청남도|충남|전라북도|전북|전라남도|전남|경상북도|경북|경상남도|경남|제주|세종|대전 중 택 1
|
|
16
|
-
birth: nil # 생일 901004
|
|
17
|
-
},
|
|
18
|
-
extra: { # 기타 설정
|
|
19
|
-
subscribe_test_payment: nil, # subscribe_test_payment:100원 결제 후 결제가 되면 billing key를 발행, 결제가 실패하면 에러
|
|
20
|
-
raw_data: nil # raw_data: PG 오류 코드 및 메세지까지 리턴
|
|
21
|
-
})
|
|
22
|
-
request(
|
|
23
|
-
uri: 'request/card_rebill',
|
|
24
|
-
payload:
|
|
25
|
-
{
|
|
26
|
-
order_id: order_id, # 개발사에서 관리하는 고유 주문 번호
|
|
27
|
-
pg: pg, # PG사의 Alias ex) danal, kcp, inicis 등
|
|
28
|
-
item_name: item_name, # 상품명
|
|
29
|
-
card_no: card_no, # 카드 일련번호
|
|
30
|
-
card_pw: card_pw, # 카드 비밀번호 앞 2자리
|
|
31
|
-
expire_year: expire_year, # 카드 유효기간 년
|
|
32
|
-
expire_month: expire_month, # 카드 유효기간 월
|
|
33
|
-
identify_number: identify_number, # 주민등록번호 또는 사업자번호
|
|
34
|
-
user_info: user_info, # 구매자 정보
|
|
35
|
-
extra: extra.values.any? {|v|v != nil} ? extra : nil
|
|
36
|
-
}.compact
|
|
37
|
-
)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# 빌링키 삭제하기
|
|
41
|
-
# Comment by ehowlsla
|
|
42
|
-
# Date: 2021-08-30
|
|
43
|
-
def destroy_billing_key(billing_key)
|
|
44
|
-
request(
|
|
45
|
-
method: :delete,
|
|
46
|
-
uri: "subscribe/billing/#{billing_key}"
|
|
47
|
-
)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# 빌링키로 결제 요청하기
|
|
51
|
-
# Comment by ehowlsla
|
|
52
|
-
# Date: 2021-08-30
|
|
53
|
-
def subscribe_billing(billing_key: nil, item_name: nil, price: 0, tax_free: 0, order_id: nil, quota: nil, interest: nil,
|
|
54
|
-
user_info: { # 구매자 정보
|
|
55
|
-
id: nil, # 개발사에서 관리하는 회원 고유 id
|
|
56
|
-
username: nil, # 구매자 이름
|
|
57
|
-
email: nil, # 구매자 email
|
|
58
|
-
phone: nil, # 01012341234
|
|
59
|
-
gender: nil, # 0:여자, 1:남자
|
|
60
|
-
area: nil, # 서울|인천|대구|광주|부산|울산|경기|강원|충청북도|충북|충청남도|충남|전라북도|전북|전라남도|전남|경상북도|경북|경상남도|경남|제주|세종|대전 중 택 1
|
|
61
|
-
birth: nil # 생일 901004
|
|
62
|
-
},
|
|
63
|
-
items: nil, # 상품 정보 배열
|
|
64
|
-
feedback_url: nil, feedback_content_type: nil,
|
|
65
|
-
extra: { # 기타 설정
|
|
66
|
-
subscribe_test_payment: nil, # subscribe_test_payment:100원 결제 후 결제가 되면 billing key를 발행, 결제가 실패하면 에러
|
|
67
|
-
raw_data: nil # raw_data: PG 오류 코드 및 메세지까지 리턴
|
|
68
|
-
})
|
|
69
|
-
raise 'billing_key 값을 입력해주세요.' if billing_key.blank?
|
|
70
|
-
raise 'item_name 값을 입력해주세요.' if item_name.blank?
|
|
71
|
-
raise 'price 금액을 설정을 해주세요.' if price.blank?
|
|
72
|
-
raise 'order_id 주문번호를 설정해주세요.' if order_id.blank?
|
|
73
|
-
request(
|
|
74
|
-
uri: 'subscribe/billing',
|
|
75
|
-
payload: {
|
|
76
|
-
billing_key: billing_key, # 발급받은 빌링키
|
|
77
|
-
item_name: item_name, # 결제할 상품명, 결제창에 노출됨
|
|
78
|
-
price: price, # 결제할 상품금액
|
|
79
|
-
tax_free: tax_free, # 면세 상품일 경우 해당만큼의 금액을 설정
|
|
80
|
-
order_id: order_id, # 개발사에서 지정하는 고유주문번호
|
|
81
|
-
quota: quota, # 5만원 이상 결제건에 적용하는 할부개월수. 0-일시불, 1은 지정시 에러 발생함, 2-2개월, 3-3개월... 12까지 지정가능
|
|
82
|
-
interest: interest, # 웰컴페이먼츠 전용, 무이자여부를 보내는 파라미터가 있다
|
|
83
|
-
user_info: user_info.values.any? {|v|v != nil} ? user_info : nil,
|
|
84
|
-
items: items, # 상품 정보 배열
|
|
85
|
-
feedback_url: feedback_url, # webhook 통지시 받으실 url 주소 (localhost 사용 불가)
|
|
86
|
-
feedback_content_type: feedback_content_type.presence || 'urlencoded', # webhook 통지시 받으실 데이터 타입 (json 또는 urlencoded, 기본값 urlencoded)
|
|
87
|
-
extra: extra.values.any? {|v|v != nil} ? extra : nil # subscribe_test_payment:100원 결제 후 결제가 되면 billing key를 발행, 결제가 실패하면 에러, raw_data: PG 오류 코드 및 메세지까지 리턴
|
|
88
|
-
}.compact,
|
|
89
|
-
)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# 빌링키로 결제 예약하기
|
|
93
|
-
# Comment by ehowlsla
|
|
94
|
-
# Date: 2021-08-30
|
|
95
|
-
def subscribe_reserve_billing(billing_key: nil, item_name: nil, price: 0, tax_free: 0, order_id: nil, quota: 12, interest: 0,
|
|
96
|
-
user_info: {id: nil, username: nil, email: nil, phone: nil, gender: nil, area: nil, birth: nil},
|
|
97
|
-
items: nil, # 상품 정보 배열
|
|
98
|
-
feedback_url: nil, feedback_content_type: nil,
|
|
99
|
-
extra: {subscribe_test_payment: 0, raw_data: 0},
|
|
100
|
-
execute_at: nil)
|
|
101
|
-
raise 'billing_key 값을 입력해주세요.' if billing_key.blank?
|
|
102
|
-
raise 'item_name 값을 입력해주세요.' if item_name.blank?
|
|
103
|
-
raise 'price 금액을 설정을 해주세요.' if price.blank?
|
|
104
|
-
raise 'order_id 주문번호를 설정해주세요.' if order_id.blank?
|
|
105
|
-
request(
|
|
106
|
-
uri: 'subscribe/billing/reserve',
|
|
107
|
-
payload: {
|
|
108
|
-
billing_key: billing_key, # 발급받은 빌링키
|
|
109
|
-
item_name: item_name, # 결제할 상품명, 결제창에 노출됨
|
|
110
|
-
price: price, # 결제할 상품금액
|
|
111
|
-
tax_free: tax_free, # 면세 상품일 경우 해당만큼의 금액을 설정
|
|
112
|
-
order_id: order_id, # 개발사에서 지정하는 고유주문번호
|
|
113
|
-
quota: quota, # 5만원 이상 결제건에 적용하는 할부개월수. 0-일시불, 1은 지정시 에러 발생함, 2-2개월, 3-3개월... 12까지 지정가능
|
|
114
|
-
interest: interest, # 웰컴페이먼츠 전용, 무이자여부를 보내는 파라미터가 있다
|
|
115
|
-
user_info: user_info.values.any? {|v|v != nil} ? user_info : nil,
|
|
116
|
-
items: items, # 상품 정보 배열
|
|
117
|
-
feedback_url: feedback_url, # webhook 통지시 받으실 url 주소 (localhost 사용 불가)
|
|
118
|
-
feedback_content_type: feedback_content_type.presence || 'urlencoded', # webhook 통지시 받으실 데이터 타입 (json 또는 urlencoded, 기본값 urlencoded)
|
|
119
|
-
extra: extra.values.any? {|v|v != nil} ? extra : nil, # subscribe_test_payment:100원 결제 후 결제가 되면 billing key를 발행, 결제가 실패하면 에러, raw_data: PG 오류 코드 및 메세지까지 리턴
|
|
120
|
-
scheduler_type: 'oneshot',
|
|
121
|
-
execute_at: execute_at.presence || (Time.now + 10.seconds).to_i # 예약 실행시간, 미지정 시 10초뒤 실행
|
|
122
|
-
}.compact,
|
|
123
|
-
)
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
# 결제 예약 취소하기
|
|
127
|
-
# Comment by ehowlsla
|
|
128
|
-
# Date: 2021-08-30
|
|
129
|
-
def subscribe_reserve_cancel(reserve_id)
|
|
130
|
-
raise 'reserve_id를 입력해주세요.' if reserve_id.blank?
|
|
131
|
-
request(
|
|
132
|
-
method: :delete,
|
|
133
|
-
uri: "subscribe/billing/reserve/#{reserve_id}"
|
|
134
|
-
)
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# 빌링키 단일 조회
|
|
138
|
-
# NodeJS: GET billing_key/{billingKey}
|
|
139
|
-
def lookup_billing_key(billing_key)
|
|
140
|
-
raise 'billing_key 값을 입력해주세요.' if billing_key.blank?
|
|
141
|
-
request(
|
|
142
|
-
method: :get,
|
|
143
|
-
uri: "billing_key/#{billing_key}"
|
|
144
|
-
)
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
# 예약 결제 단일 조회
|
|
148
|
-
# NodeJS: GET subscribe/payment/reserve/{reserveId}
|
|
149
|
-
def subscribe_payment_reserve_lookup(reserve_id)
|
|
150
|
-
raise 'reserve_id 값을 입력해주세요.' if reserve_id.blank?
|
|
151
|
-
request(
|
|
152
|
-
method: :get,
|
|
153
|
-
uri: "subscribe/payment/reserve/#{reserve_id}"
|
|
154
|
-
)
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|
data/lib/bootpay/cancel.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
module Bootpay::Cancel
|
|
2
|
-
extend ActiveSupport::Concern
|
|
3
|
-
|
|
4
|
-
included do
|
|
5
|
-
# 결제 취소 요청
|
|
6
|
-
# Comment by Gosomi
|
|
7
|
-
# Date: 2021-05-21
|
|
8
|
-
def cancel_payment(cancel_id: nil, receipt_id:, cancel_price: nil, cancel_tax_free: 0, cancel_username: '시스템', cancel_message: '결제취소',
|
|
9
|
-
refund: { # (선택사항) 가상계좌 환불요청시, 전제조건으로 PG사와 CMS 특약이 체결되어 있을 경우에만 환불요청 가능, 기본적으로 가상계좌는 결제취소가 안됨
|
|
10
|
-
account: nil, # 환불받을 계좌번호 - 675601***1234
|
|
11
|
-
accountholder: nil, # 환불받을 계좌주 - 홍길동
|
|
12
|
-
bankcode: nil # 은행 코드
|
|
13
|
-
})
|
|
14
|
-
request(
|
|
15
|
-
uri: 'cancel',
|
|
16
|
-
payload:
|
|
17
|
-
{
|
|
18
|
-
cancel_id: cancel_id.presence || SecureRandom.uuid, # (선택사항) 부분취소 요청시 중복 요청을 방지하기 위한 고유값
|
|
19
|
-
receipt_id: receipt_id, # 부트페이에서 발급한 영수증 id
|
|
20
|
-
price: cancel_price, # (선택사항) 부분취소 요청시 금액을 지정, 미지정시 전액 취소 (부분취소가 가능한 PG사, 결제수단에 한해 적용됨)
|
|
21
|
-
tax_free: cancel_tax_free, # 취소할 비과세 금액
|
|
22
|
-
name: cancel_username, # 취소 요청자 이름
|
|
23
|
-
reason: cancel_message, # 취소 요청 사유
|
|
24
|
-
refund: refund.values.any? {|v|v != nil} ? refund : nil # (선택사항) 가상계좌 환불요청시, 전제조건으로 PG사와 CMS 특약이 체결되어 있을 경우에만 환불요청 가능, 기본적으로 가상계좌는 결제취소가 안됨
|
|
25
|
-
}.compact
|
|
26
|
-
)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
data/lib/bootpay/cash_receipt.rb
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
module Bootpay::CashReceipt
|
|
2
|
-
extend ActiveSupport::Concern
|
|
3
|
-
|
|
4
|
-
included do
|
|
5
|
-
# 결제 건에 현금영수증 발급 요청
|
|
6
|
-
# NodeJS: POST request/receipt/cash/publish
|
|
7
|
-
def cash_receipt_publish_on_receipt(receipt_id: nil, identity_no: nil,
|
|
8
|
-
cash_receipt_type: nil, username: nil,
|
|
9
|
-
email: nil, phone: nil, currency: nil)
|
|
10
|
-
raise 'receipt_id 값을 입력해주세요.' if receipt_id.blank?
|
|
11
|
-
raise 'identity_no 값을 입력해주세요.' if identity_no.blank?
|
|
12
|
-
raise 'cash_receipt_type 값을 입력해주세요.' if cash_receipt_type.blank?
|
|
13
|
-
request(
|
|
14
|
-
uri: 'request/receipt/cash/publish',
|
|
15
|
-
payload: {
|
|
16
|
-
receipt_id: receipt_id,
|
|
17
|
-
identity_no: identity_no,
|
|
18
|
-
cash_receipt_type: cash_receipt_type, # 소득공제 | 지출증빙
|
|
19
|
-
username: username,
|
|
20
|
-
email: email,
|
|
21
|
-
phone: phone,
|
|
22
|
-
currency: currency
|
|
23
|
-
}.compact
|
|
24
|
-
)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# 결제 건에 발급된 현금영수증 취소
|
|
28
|
-
# NodeJS: DELETE request/receipt/cash/cancel/{receiptId}
|
|
29
|
-
def cash_receipt_cancel_on_receipt(receipt_id, cancel_username: nil, cancel_message: nil)
|
|
30
|
-
raise 'receipt_id 값을 입력해주세요.' if receipt_id.blank?
|
|
31
|
-
request(
|
|
32
|
-
method: :delete,
|
|
33
|
-
uri: "request/receipt/cash/cancel/#{receipt_id}",
|
|
34
|
-
params: { cancel_username: cancel_username, cancel_message: cancel_message }.compact
|
|
35
|
-
)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# 단독 현금영수증 발급
|
|
39
|
-
# NodeJS: POST request/cash/receipt
|
|
40
|
-
def request_cash_receipt(pg: nil, price: nil, order_name: nil, cash_receipt_type: nil,
|
|
41
|
-
identity_no: nil, order_id: nil, tax_free: nil,
|
|
42
|
-
purchased_at: nil, user: nil, extra: nil)
|
|
43
|
-
raise 'pg 값을 입력해주세요.' if pg.blank?
|
|
44
|
-
raise 'price 값을 입력해주세요.' if price.blank?
|
|
45
|
-
raise 'order_name 값을 입력해주세요.' if order_name.blank?
|
|
46
|
-
raise 'cash_receipt_type 값을 입력해주세요.' if cash_receipt_type.blank?
|
|
47
|
-
raise 'identity_no 값을 입력해주세요.' if identity_no.blank?
|
|
48
|
-
raise 'order_id 값을 입력해주세요.' if order_id.blank?
|
|
49
|
-
request(
|
|
50
|
-
uri: 'request/cash/receipt',
|
|
51
|
-
payload: {
|
|
52
|
-
pg: pg,
|
|
53
|
-
price: price,
|
|
54
|
-
order_name: order_name,
|
|
55
|
-
cash_receipt_type: cash_receipt_type,
|
|
56
|
-
identity_no: identity_no,
|
|
57
|
-
order_id: order_id,
|
|
58
|
-
tax_free: tax_free,
|
|
59
|
-
purchased_at: purchased_at,
|
|
60
|
-
user: user,
|
|
61
|
-
extra: extra
|
|
62
|
-
}.compact
|
|
63
|
-
)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# 단독 현금영수증 취소
|
|
67
|
-
# NodeJS: DELETE request/cash/receipt/{receiptId}
|
|
68
|
-
def cancel_cash_receipt(receipt_id, cancel_username: nil, cancel_message: nil)
|
|
69
|
-
raise 'receipt_id 값을 입력해주세요.' if receipt_id.blank?
|
|
70
|
-
request(
|
|
71
|
-
method: :delete,
|
|
72
|
-
uri: "request/cash/receipt/#{receipt_id}",
|
|
73
|
-
params: { cancel_username: cancel_username, cancel_message: cancel_message }.compact
|
|
74
|
-
)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Bootpay
|
|
4
|
-
module Commerce
|
|
5
|
-
class CartModule
|
|
6
|
-
def initialize(bootpay)
|
|
7
|
-
@bootpay = bootpay
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
# 주문 미리보기 (배송비/할인 권위적 계산)
|
|
11
|
-
# POST /v1/cart/order-preview
|
|
12
|
-
#
|
|
13
|
-
# member_mode='guest' (기본): cart_items 필수
|
|
14
|
-
# member_mode='member': 서버 장바구니 사용 (user 토큰 필요)
|
|
15
|
-
def order_preview(params = {})
|
|
16
|
-
@bootpay.post('cart/order-preview', params)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Bootpay
|
|
4
|
-
module Commerce
|
|
5
|
-
class CategoryModule
|
|
6
|
-
def initialize(bootpay)
|
|
7
|
-
@bootpay = bootpay
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
# 카테고리 트리 조회
|
|
11
|
-
def list
|
|
12
|
-
@bootpay.get('categories')
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# 카테고리 단건 조회
|
|
16
|
-
def detail(category_id)
|
|
17
|
-
@bootpay.get("categories/#{category_id}")
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# 카테고리 생성
|
|
21
|
-
def create(params)
|
|
22
|
-
@bootpay.post('categories', params)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# 카테고리 수정
|
|
26
|
-
def update(params)
|
|
27
|
-
raise ArgumentError, 'category_id is required' unless params[:category_id]
|
|
28
|
-
category_id = params[:category_id]
|
|
29
|
-
body = params.reject { |k, _| k == :category_id }
|
|
30
|
-
@bootpay.put("categories/#{category_id}", body)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# 카테고리 삭제
|
|
34
|
-
def destroy(category_id)
|
|
35
|
-
@bootpay.delete("categories/#{category_id}")
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,196 +0,0 @@
|
|
|
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
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
|
@@ -1,46 +0,0 @@
|
|
|
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
|
|
@@ -1,61 +0,0 @@
|
|
|
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
|