bootpay-backend-ruby 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +2 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +319 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/bootpay-backend-ruby.gemspec +29 -0
- data/lib/bootpay/concern/authenticate.rb +15 -0
- data/lib/bootpay/concern/cash_receipt.rb +45 -0
- data/lib/bootpay/concern/easy.rb +18 -0
- data/lib/bootpay/concern/escrow.rb +24 -0
- data/lib/bootpay/concern/payment.rb +48 -0
- data/lib/bootpay/concern/reseller.rb +59 -0
- data/lib/bootpay/concern/rest.rb +34 -0
- data/lib/bootpay/concern/sdk.rb +36 -0
- data/lib/bootpay/concern/subscription.rb +115 -0
- data/lib/bootpay/concern/token.rb +20 -0
- data/lib/bootpay/concern/user_token.rb +23 -0
- data/lib/bootpay/concern/webhook.rb +18 -0
- data/lib/bootpay/concern.rb +29 -0
- data/lib/bootpay/version.rb +4 -0
- data/lib/bootpay-backend-ruby.rb +28 -0
- data/lib/response.rb +14 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 955385f1140fc3523ac4db41237c8d72bdfdcfefd4a26289280070cbd73f75f0
|
4
|
+
data.tar.gz: b509c9c00b861c904e7b5ba3bf779213d1f73c2b6e67ec0b3985e20c0395087e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 84cd62e3488892623d4a8151f05b4ae82bdf252ae1e52c2d1c9c1595f99bdc5dc77bb604908e67d2809af1d6dee123ef2f0f9eff5f8a00e456c7138ddeed788a
|
7
|
+
data.tar.gz: 0622ca14d4ca976d7815a777c79868b81791b7ac06a9927bfb0a1639587cae579edc0a19fa87ed3bd0b02ec83081b64005666f5b7032c638dfa2595401d483a0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at gosomi@udid.co.kr. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 gosomi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,319 @@
|
|
1
|
+
# Bootpay Ruby Server Side Library
|
2
|
+
|
3
|
+
부트페이 공식 Ruby 라이브러리 입니다 (서버사이드 용)
|
4
|
+
|
5
|
+
Ruby 언어로 작성된 어플리케이션, 프레임워크 등에서 사용가능합니다.
|
6
|
+
|
7
|
+
* PG 결제창 연동은 클라이언트 라이브러리에서 수행됩니다. (Javascript, Android, iOS, React Native, Flutter 등)
|
8
|
+
* 결제 검증 및 취소, 빌링키 발급, 본인인증 등의 수행은 서버사이드에서 진행됩니다. (Java, PHP, Python, Ruby, Node.js, Go, ASP.NET 등)
|
9
|
+
|
10
|
+
|
11
|
+
## 기능
|
12
|
+
1. (부트페이 통신을 위한) 토큰 발급
|
13
|
+
2. 결제 단건 조회
|
14
|
+
3. 결제 취소 (전액 취소 / 부분 취소)
|
15
|
+
4. 신용카드 자동결제 (빌링결제)
|
16
|
+
4-1. 빌링키 발급
|
17
|
+
4-2. 발급된 빌링키로 결제 승인 요청
|
18
|
+
4-3. 발급된 빌링키로 결제 예약 요청
|
19
|
+
4-4. 발급된 빌링키로 결제 예약 - 취소 요청
|
20
|
+
4-5. 빌링키 삭제
|
21
|
+
4-6. 해당 결제건의 빌링키 조회 (빌링)
|
22
|
+
5. (생체인증, 비밀번호 결제를 위한) 구매자 토큰 발급
|
23
|
+
6. 서버 승인 요청
|
24
|
+
7. 본인 인증 결과 조회
|
25
|
+
|
26
|
+
## Gem으로 설치하기
|
27
|
+
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
gem 'bootpay-backend-ruby'
|
31
|
+
```
|
32
|
+
|
33
|
+
Gemfile에 위 라인을 추가하고, 아래 라인으로 인스톨 합니다.
|
34
|
+
```ruby
|
35
|
+
$ bundle install
|
36
|
+
```
|
37
|
+
|
38
|
+
|
39
|
+
또는 아래 문장을 통해 바로 설치할 수 있습니다:
|
40
|
+
```ruby
|
41
|
+
$ gem install bootpay-backend-ruby
|
42
|
+
```
|
43
|
+
|
44
|
+
## 사용하기
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
|
48
|
+
require 'bootpay-backend-ruby'
|
49
|
+
|
50
|
+
@api = Bootpay::RestClient.new(
|
51
|
+
application_id: '5b8f6a4d396fa665fdc2b5ea',
|
52
|
+
private_key: 'rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=',
|
53
|
+
)
|
54
|
+
|
55
|
+
response = @api.request_access_token
|
56
|
+
if response.success?
|
57
|
+
puts response.data.to_json
|
58
|
+
end
|
59
|
+
```
|
60
|
+
함수 단위의 샘플 코드는 [이곳](https://github.com/bootpay/backend-ruby/tree/2-x-development/spec/bootpay)을 참조하세요.
|
61
|
+
|
62
|
+
|
63
|
+
## 1. (부트페이 통신을 위한) 토큰 발급
|
64
|
+
|
65
|
+
부트페이와 서버간 통신을 하기 위해서는 부트페이 서버로부터 토큰을 발급받아야 합니다.
|
66
|
+
발급된 토큰은 30분간 유효하며, 최초 발급일로부터 30분이 지날 경우 토큰 발급 함수를 재호출 해주셔야 합니다.
|
67
|
+
```ruby
|
68
|
+
api = Bootpay::RestClient.new(
|
69
|
+
application_id: '59bfc738e13f337dbd6ca48a',
|
70
|
+
private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0='
|
71
|
+
)
|
72
|
+
|
73
|
+
api.request_access_token.success?
|
74
|
+
```
|
75
|
+
|
76
|
+
|
77
|
+
## 2. 결제 단건 조회
|
78
|
+
결제창 및 정기결제에서 승인/취소된 결제건에 대하여 올바른 결제건인지 서버간 통신으로 결제검증을 합니다.
|
79
|
+
```ruby
|
80
|
+
api = Bootpay::RestClient.new(
|
81
|
+
application_id: '59bfc738e13f337dbd6ca48a',
|
82
|
+
private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0='
|
83
|
+
)
|
84
|
+
|
85
|
+
if api.request_access_token.success?
|
86
|
+
response = api.receipt_payment(
|
87
|
+
"62a818cf1fc19203154a8f2e"
|
88
|
+
)
|
89
|
+
puts response.data.to_json
|
90
|
+
end
|
91
|
+
```
|
92
|
+
|
93
|
+
|
94
|
+
## 3. 결제 취소 (전액 취소 / 부분 취소)
|
95
|
+
price를 지정하지 않으면 전액취소 됩니다.
|
96
|
+
* 휴대폰 결제의 경우 이월될 경우 이통사 정책상 취소되지 않습니다
|
97
|
+
* 정산받으실 금액보다 취소금액이 클 경우 PG사 정책상 취소되지 않을 수 있습니다. 이때 PG사에 문의하시면 되겠습니다.
|
98
|
+
* 가상계좌의 경우 CMS 특약이 되어있지 않으면 취소되지 않습니다. 그러므로 결제 테스트시에는 가상계좌로 테스트 하지 않길 추천합니다.
|
99
|
+
|
100
|
+
부분취는 카드로 결제된 건만 가능하며, 일부 PG사만 지원합니다. 요청시 price에 금액을 지정하시면 되겠습니다.
|
101
|
+
* (지원가능 PG사: 이니시스, kcp, 다날, 페이레터, 나이스페이, 카카오페이, 페이코)
|
102
|
+
|
103
|
+
간혹 개발사에서 실수로 여러번 부분취소를 보내서 여러번 취소되는 경우가 있기때문에, 부트페이에서는 부분취소 중복 요청을 막기 위해 cancel_id 라는 필드를 추가했습니다. cancel_id를 지정하시면, 해당 건에 대해 중복 요청방지가 가능합니다.
|
104
|
+
```ruby
|
105
|
+
api = Bootpay::RestClient.new(
|
106
|
+
application_id: '59bfc738e13f337dbd6ca48a',
|
107
|
+
private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0='
|
108
|
+
)
|
109
|
+
if api.request_access_token.success?
|
110
|
+
response = api.cancel_payment(
|
111
|
+
receipt_id: "624a56111fc19202e4746df2",
|
112
|
+
cancel_price: 1000,
|
113
|
+
cancel_username: 'test_user',
|
114
|
+
cancel_message: 'test_message',
|
115
|
+
)
|
116
|
+
puts response.data.to_json
|
117
|
+
end
|
118
|
+
```
|
119
|
+
|
120
|
+
## 4-1. 빌링키 발급
|
121
|
+
REST API 방식으로 고객으로부터 카드 정보를 전달하여, PG사에게 빌링키를 발급받을 수 있습니다.
|
122
|
+
발급받은 빌링키를 저장하고 있다가, 원하는 시점, 원하는 금액에 결제 승인 요청하여 좀 더 자유로운 결제시나리오에 적용이 가능합니다.
|
123
|
+
* 비인증 정기결제(REST API) 방식을 지원하는 PG사만 사용 가능합니다.
|
124
|
+
```ruby
|
125
|
+
api = Bootpay::RestClient.new(
|
126
|
+
application_id: '59bfc738e13f337dbd6ca48a',
|
127
|
+
private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0='
|
128
|
+
)
|
129
|
+
|
130
|
+
if api.request_access_token.success?
|
131
|
+
response = @api.request_subscribe_billing_key(
|
132
|
+
subscription_id: '1234',
|
133
|
+
pg: 'nicepay',
|
134
|
+
order_name: '테스트 결제',
|
135
|
+
card_no: '', # 값 할당 필요, 카드번호
|
136
|
+
card_pw: '', # 값 할당 필요, 카드 비밀번호 2자리
|
137
|
+
card_expire_year: '', # 값 할당 필요, 카드 유효기간 연도 2자리
|
138
|
+
card_expire_month: '', # 값 할당 필요, 카드 유효기간 월 2자리
|
139
|
+
card_identity_no: '' # 값 할당 필요, 카드 소유주 생년월일
|
140
|
+
)
|
141
|
+
puts response.data.to_json
|
142
|
+
end
|
143
|
+
|
144
|
+
```
|
145
|
+
|
146
|
+
## 4-2. 발급된 빌링키로 결제 승인 요청
|
147
|
+
발급된 빌링키로 원하는 시점에 원하는 금액으로 결제 승인 요청을 할 수 있습니다. 잔액이 부족하거나 도난 카드 등의 특별한 건이 아니면 PG사에서 결제를 바로 승인합니다.
|
148
|
+
|
149
|
+
```ruby
|
150
|
+
api = Bootpay::RestClient.new(
|
151
|
+
application_id: '59bfc738e13f337dbd6ca48a',
|
152
|
+
private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0='
|
153
|
+
)
|
154
|
+
if api.request_access_token.success?
|
155
|
+
response = api.request_subscribe_card_payment(
|
156
|
+
billing_key: '6295cd1d1fc19202e4e319b0',
|
157
|
+
order_name: '테스트결제',
|
158
|
+
price: 1000,
|
159
|
+
card_quota: '00',
|
160
|
+
order_id: Time.current.to_i,
|
161
|
+
user: {
|
162
|
+
phone: '01000000000',
|
163
|
+
username: '홍길동',
|
164
|
+
email: 'test@bootpay.co.kr'
|
165
|
+
}
|
166
|
+
)
|
167
|
+
puts response.data.to_json
|
168
|
+
end
|
169
|
+
```
|
170
|
+
## 4-3. 발급된 빌링키로 결제 예약 요청
|
171
|
+
원하는 시점에 4-1로 결제 승인 요청을 보내도 되지만, 빌링키 발급 이후에 바로 결제 예약 할 수 있습니다. (빌링키당 최대 5건)
|
172
|
+
```ruby
|
173
|
+
api = Bootpay::RestClient.new(
|
174
|
+
application_id: '59bfc738e13f337dbd6ca48a',
|
175
|
+
private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0='
|
176
|
+
)
|
177
|
+
if api.request_access_token.success?
|
178
|
+
response = api.subscribe_payment_reserve(
|
179
|
+
billing_key: '628c0d0d1fc19202e5ef2866',
|
180
|
+
order_name: '테스트결제',
|
181
|
+
price: 1000,
|
182
|
+
order_id: Time.current.to_i,
|
183
|
+
user: {
|
184
|
+
phone: '01000000000',
|
185
|
+
username: '홍길동',
|
186
|
+
email: 'test@bootpay.co.kr'
|
187
|
+
},
|
188
|
+
reserve_execute_at: (Time.current + 30.seconds).iso8601
|
189
|
+
)
|
190
|
+
print response.data.to_json
|
191
|
+
end
|
192
|
+
```
|
193
|
+
## 4-4. 발급된 빌링키로 결제 예약 - 취소 요청
|
194
|
+
빌링키로 예약된 결제건을 취소합니다.
|
195
|
+
```ruby
|
196
|
+
api = Bootpay::RestClient.new(
|
197
|
+
application_id: '59bfc738e13f337dbd6ca48a',
|
198
|
+
private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0='
|
199
|
+
)
|
200
|
+
if api.request_access_token.success?
|
201
|
+
response = api.subscribe_payment_reserve(
|
202
|
+
billing_key: '623028630e019e036fe98478',
|
203
|
+
order_name: '테스트결제',
|
204
|
+
price: 1000,
|
205
|
+
order_id: Time.current.to_i,
|
206
|
+
user: {
|
207
|
+
phone: '01000000000',
|
208
|
+
username: '홍길동',
|
209
|
+
email: 'test@bootpay.co.kr'
|
210
|
+
},
|
211
|
+
reserve_execute_at: (Time.current + 5.seconds).iso8601
|
212
|
+
)
|
213
|
+
puts response.data.to_json
|
214
|
+
if response.success?
|
215
|
+
puts "cancel reserve_id: #{response.data[:reserve_id]}"
|
216
|
+
cancel = api.cancel_subscribe_reserve(response.data[:reserve_id])
|
217
|
+
puts cancel.data.to_json
|
218
|
+
end
|
219
|
+
end
|
220
|
+
```
|
221
|
+
## 4-5. 빌링키 삭제
|
222
|
+
발급된 빌링키로 더 이상 사용되지 않도록, 삭제 요청합니다.
|
223
|
+
```ruby
|
224
|
+
api = Bootpay::RestClient.new(
|
225
|
+
application_id: '59bfc738e13f337dbd6ca48a',
|
226
|
+
private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0='
|
227
|
+
)
|
228
|
+
if api.request_access_token.success?
|
229
|
+
response = api.destroy_billing_key(
|
230
|
+
'6257bafb1fc19202e47471f7:'
|
231
|
+
)
|
232
|
+
print response.data.to_json
|
233
|
+
end
|
234
|
+
```
|
235
|
+
|
236
|
+
## 4-6. 해당 결제건의 빌링키 조회 (빌링)
|
237
|
+
```java
|
238
|
+
api = Bootpay::RestClient.new(
|
239
|
+
application_id: '59bfc738e13f337dbd6ca48a',
|
240
|
+
private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0='
|
241
|
+
)
|
242
|
+
if api.request_access_token.success?
|
243
|
+
response = api.lookup_subscribe_billing_key(
|
244
|
+
"624e4f7c1fc19202e4746f91"
|
245
|
+
)
|
246
|
+
print response.data.to_json
|
247
|
+
end
|
248
|
+
```
|
249
|
+
|
250
|
+
## 5. (생체인증, 비밀번호 결제를 위한) 구매자 토큰 발급
|
251
|
+
(부트페이 단독) 부트페이에서 제공하는 간편결제창, 생체인증 기반의 결제 사용을 위해서는 개발사에서 회원 고유번호를 관리해야하며, 해당 회원에 대한 사용자 토큰을 발급합니다.
|
252
|
+
이 토큰값을 기반으로 클라이언트에서 결제요청 하시면 되겠습니다.
|
253
|
+
```ruby
|
254
|
+
api = Bootpay::RestClient.new(
|
255
|
+
application_id: '59bfc738e13f337dbd6ca48a',
|
256
|
+
private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0='
|
257
|
+
)
|
258
|
+
if api.request_access_token.success?
|
259
|
+
response = api.request_user_token(
|
260
|
+
user_id: 'gosomi1',
|
261
|
+
phone: '01012345678'
|
262
|
+
)
|
263
|
+
print response.data.to_json
|
264
|
+
end
|
265
|
+
```
|
266
|
+
|
267
|
+
## 6. 서버 승인 요청
|
268
|
+
결제승인 방식은 클라이언트 승인 방식과, 서버 승인 방식으로 총 2가지가 있습니다.
|
269
|
+
|
270
|
+
클라이언트 승인 방식은 javascript나 native 등에서 confirm 함수에서 진행하는 일반적인 방법입니다만, 경우에 따라 서버 승인 방식이 필요할 수 있습니다.
|
271
|
+
|
272
|
+
필요한 이유
|
273
|
+
1. 100% 안정적인 결제 후 고객 안내를 위해 - 클라이언트에서 PG결제 진행 후 승인 완료될 때 onDone이 수행되지 않아 (인터넷 환경 등), 결제 이후 고객에게 안내하지 못할 수 있습니다
|
274
|
+
2. 단일 트랜잭션의 개념이 필요할 경우 - 재고파악이 중요한 커머스를 운영할 경우 트랜잭션 개념이 필요할 수 있겠으며, 이를 위해서는 서버 승인을 사용해야 합니다.
|
275
|
+
|
276
|
+
```ruby
|
277
|
+
api = Bootpay::RestClient.new(
|
278
|
+
application_id: '59bfc738e13f337dbd6ca48a',
|
279
|
+
private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0='
|
280
|
+
)
|
281
|
+
if api.request_access_token.success?
|
282
|
+
response = api.confirm_payment(
|
283
|
+
"61d3d41b1fc19202e483320b"
|
284
|
+
)
|
285
|
+
print response.data.to_json
|
286
|
+
end
|
287
|
+
```
|
288
|
+
|
289
|
+
## 7. 본인 인증 결과 조회
|
290
|
+
다날 본인인증 후 결과값을 조회합니다.
|
291
|
+
다날 본인인증에서 통신사, 외국인여부, 전화번호 이 3가지 정보는 다날에 추가로 요청하셔야 받으실 수 있습니다.
|
292
|
+
```ruby
|
293
|
+
api = Bootpay::RestClient.new(
|
294
|
+
application_id: '59bfc738e13f337dbd6ca48a',
|
295
|
+
private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0='
|
296
|
+
)
|
297
|
+
if api.request_access_token.success?
|
298
|
+
response = api.certificate(
|
299
|
+
"624d2e531fc19202e4746f40"
|
300
|
+
)
|
301
|
+
print response.data.to_json
|
302
|
+
end
|
303
|
+
```
|
304
|
+
|
305
|
+
## Example 프로젝트
|
306
|
+
|
307
|
+
[적용한 샘플 프로젝트](https://github.com/bootpay/backend-ruby-example)을 참조해주세요
|
308
|
+
|
309
|
+
## Documentation
|
310
|
+
|
311
|
+
[부트페이 개발매뉴얼](https://docs.bootpay.co.kr/next/)을 참조해주세요
|
312
|
+
|
313
|
+
## 기술문의
|
314
|
+
|
315
|
+
[부트페이 홈페이지](https://www.bootpay.co.kr) 우측 하단 채팅을 통해 기술문의 주세요!
|
316
|
+
|
317
|
+
## License
|
318
|
+
|
319
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "bootpay/rest/client"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/bootpay/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "bootpay-backend-ruby"
|
7
|
+
spec.version = Bootpay::V2_VERSION
|
8
|
+
spec.authors = ["gosomi"]
|
9
|
+
spec.email = ["gosomi@bootpay.co.kr"]
|
10
|
+
|
11
|
+
spec.summary = "Bootpay Ruby REST Client"
|
12
|
+
spec.description = "Bootpay REST API / Search One Receipt or Cancel Payment, Subscription Payment on REST API."
|
13
|
+
spec.license = "MIT"
|
14
|
+
# Specify which files should be added to the gem when it is released.
|
15
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
16
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
17
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
# Uncomment to register a new dependency of your gem
|
24
|
+
spec.add_dependency "activesupport"
|
25
|
+
spec.add_dependency "http"
|
26
|
+
|
27
|
+
# For more information and examples about making a new gem, checkout our
|
28
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Bootpay::Concern::Authenticate
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# 본인인증 데이터 가져오기
|
6
|
+
# Comment by Gosomi
|
7
|
+
# Date: 2021-12-08
|
8
|
+
def certificate(receipt_id)
|
9
|
+
request(
|
10
|
+
method: :get,
|
11
|
+
uri: "certificate/#{receipt_id}"
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Bootpay::Concern::CashReceipt
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# 현금 영수증 발행 처리 하기
|
6
|
+
# Comment by Gosomi
|
7
|
+
# Date: 2021-12-15
|
8
|
+
def request_cash_receipt(pg:, order_name:, identity_no:, purchased_at:, cash_receipt_type:, price:, tax_free:, user: {},
|
9
|
+
metadata: {}, extra: {}, order_id:)
|
10
|
+
request(
|
11
|
+
method: :post,
|
12
|
+
uri: 'request/cash/receipt',
|
13
|
+
payload: {
|
14
|
+
pg: pg,
|
15
|
+
order_name: order_name,
|
16
|
+
identity_no: identity_no,
|
17
|
+
purchased_at: purchased_at,
|
18
|
+
cash_receipt_type: cash_receipt_type,
|
19
|
+
price: price,
|
20
|
+
tax_free: tax_free,
|
21
|
+
user: user,
|
22
|
+
metadata: metadata,
|
23
|
+
order_id: order_id,
|
24
|
+
extra: extra
|
25
|
+
}
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
# 현금영수증 발행 취소
|
30
|
+
# Comment by Gosomi
|
31
|
+
# Date: 2021-12-16
|
32
|
+
def cancel_cash_receipt(receipt_id:, cancel_username:, cancel_message:)
|
33
|
+
request(
|
34
|
+
method: :delete,
|
35
|
+
uri: "request/cash/receipt/#{receipt_id}",
|
36
|
+
headers: {
|
37
|
+
params: {
|
38
|
+
cancel_username: cancel_username,
|
39
|
+
cancel_message: cancel_message
|
40
|
+
}
|
41
|
+
}
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Bootpay::Concern::Easy
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# 간편결제 subscribe
|
6
|
+
# Comment by Gosomi
|
7
|
+
# Date: 2022-02-11
|
8
|
+
def subscribe_on_easy(receipt_id:, billing_key:)
|
9
|
+
request(
|
10
|
+
uri: 'subscribe/easy',
|
11
|
+
payload: {
|
12
|
+
receipt_id: receipt_id,
|
13
|
+
billing_key: billing_key
|
14
|
+
}
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Bootpay::Concern::Escrow
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# 배송시작 API
|
6
|
+
# Comment by Gosomi
|
7
|
+
# Date: 2021-12-14
|
8
|
+
def shipping_start(receipt_id:, tracking_number:, delivery_corp:, shipping_prepayment: true,
|
9
|
+
shipping_day: 5, user: nil, company: {})
|
10
|
+
request(
|
11
|
+
method: :put,
|
12
|
+
uri: "escrow/shipping/start/#{receipt_id}",
|
13
|
+
payload: {
|
14
|
+
tracking_number: tracking_number,
|
15
|
+
delivery_corp: delivery_corp,
|
16
|
+
shipping_prepayment: shipping_prepayment,
|
17
|
+
shipping_day: shipping_day,
|
18
|
+
user: user,
|
19
|
+
company: company
|
20
|
+
}
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Bootpay::Concern::Payment
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# 결제 정보 가져오기
|
6
|
+
# Comment by Gosomi
|
7
|
+
# Date: 2021-12-08
|
8
|
+
def receipt_payment(receipt_id)
|
9
|
+
request(
|
10
|
+
method: :get,
|
11
|
+
uri: "receipt/#{receipt_id}"
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
# 결제 승인처리
|
16
|
+
# Comment by Gosomi
|
17
|
+
# Date: 2022-01-04
|
18
|
+
def confirm_payment(receipt_id)
|
19
|
+
request(
|
20
|
+
uri: 'confirm',
|
21
|
+
payload: {
|
22
|
+
receipt_id: receipt_id
|
23
|
+
}
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
# 결제 취소 요청
|
28
|
+
# Comment by Gosomi
|
29
|
+
# Date: 2021-05-21
|
30
|
+
def cancel_payment(cancel_id: nil, receipt_id:, cancel_price: nil, cancel_tax_free: nil, cancel_username: '시스템', cancel_message: '결제취소',
|
31
|
+
refund: { bank_account: nil, bank_username: nil, bank_code: nil }, items: nil)
|
32
|
+
request(
|
33
|
+
uri: 'cancel',
|
34
|
+
payload:
|
35
|
+
{
|
36
|
+
cancel_id: cancel_id.presence || SecureRandom.uuid,
|
37
|
+
receipt_id: receipt_id,
|
38
|
+
cancel_price: cancel_price,
|
39
|
+
cancel_tax_free: cancel_tax_free,
|
40
|
+
cancel_username: cancel_username,
|
41
|
+
cancel_message: cancel_message,
|
42
|
+
refund: refund,
|
43
|
+
items: items
|
44
|
+
}.compact
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Bootpay::Concern::Reseller
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# 가맹점 계정을 생성한다
|
6
|
+
# Comment by Gosomi
|
7
|
+
# Date: 2022-01-05
|
8
|
+
def create_seller(company_alias:, company_name:, email: nil, regist_no: nil, owner_name: nil,
|
9
|
+
phone: nil, zip: nil, address1: nil, address2: nil)
|
10
|
+
request(
|
11
|
+
uri: 'reseller/seller',
|
12
|
+
payload: {
|
13
|
+
company_alias: company_alias,
|
14
|
+
company_name: company_name,
|
15
|
+
email: email,
|
16
|
+
regist_no: regist_no,
|
17
|
+
owner_name: owner_name,
|
18
|
+
phone: phone,
|
19
|
+
zip: zip,
|
20
|
+
address1: address1,
|
21
|
+
address2: address2
|
22
|
+
}
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
# 판매점의 프로젝트 생성하기
|
27
|
+
# Comment by Gosomi
|
28
|
+
# Date: 2022-01-05
|
29
|
+
def create_seller_app(provider_id:, name:, unit: 'KRW', real: '실물', desc: nil, timezone: 'Asia/Seoul')
|
30
|
+
request(
|
31
|
+
uri: 'reseller/seller/app',
|
32
|
+
payload: {
|
33
|
+
provider_id: provider_id,
|
34
|
+
name: name,
|
35
|
+
unit: unit,
|
36
|
+
real: real,
|
37
|
+
desc: desc,
|
38
|
+
timezone: timezone
|
39
|
+
}
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
# 프로젝트/가맹점 초대하기
|
44
|
+
# Comment by Gosomi
|
45
|
+
# Date: 2022-01-13
|
46
|
+
def member_invite(email:, level:, app_id: nil, invite_type:, provider_id: nil)
|
47
|
+
request(
|
48
|
+
uri: 'reseller/invite',
|
49
|
+
payload: {
|
50
|
+
email: email,
|
51
|
+
level: level,
|
52
|
+
app_id: app_id,
|
53
|
+
provider_id: provider_id,
|
54
|
+
invite_type: invite_type
|
55
|
+
}
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Bootpay::Concern::Rest
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
private
|
6
|
+
|
7
|
+
# HTTP Request 기본 Method
|
8
|
+
# Comment by Gosomi
|
9
|
+
# Date: 2021-05-21
|
10
|
+
def request(method: :post, uri:, payload: {}, headers: {})
|
11
|
+
response = HTTP.headers(
|
12
|
+
{
|
13
|
+
Authorization: "Bearer #{@token}",
|
14
|
+
content_type: 'application/json',
|
15
|
+
accept: 'application/json'
|
16
|
+
}.merge!(headers).compact
|
17
|
+
).send(
|
18
|
+
method.to_sym,
|
19
|
+
[Bootpay::RestClient::API[@mode.to_sym], uri].join('/'),
|
20
|
+
json: payload
|
21
|
+
)
|
22
|
+
Bootpay::Response.new(
|
23
|
+
response.status.success?,
|
24
|
+
JSON.parse(response.body.to_s, symbolize_names: true)
|
25
|
+
)
|
26
|
+
rescue Exception => e
|
27
|
+
Bootpay::Response.new(
|
28
|
+
false,
|
29
|
+
message: "부트페이 API 서버와의 통신이 실패하였습니다. 오류 메세지: #{e.message}",
|
30
|
+
backtrace: e.backtrace.join("\n")
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Bootpay::Concern::Sdk
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# 현재 등록된 지갑 정보를 가져온다
|
6
|
+
# Comment by Gosomi
|
7
|
+
# Date: 2022-02-21
|
8
|
+
def wallets(user_token)
|
9
|
+
request(
|
10
|
+
method: :get,
|
11
|
+
uri: "sdk/easy/wallet",
|
12
|
+
headers: {
|
13
|
+
'Bootpay-User-Token': user_token
|
14
|
+
}
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Biometric Authenticate
|
19
|
+
# Comment by Gosomi
|
20
|
+
# Date: 2022-02-21
|
21
|
+
def regist_biometric_authenticate(os:, token:, user_token:, uuid:)
|
22
|
+
request(
|
23
|
+
method: :post,
|
24
|
+
uri: 'sdk/easy/biometric',
|
25
|
+
headers: {
|
26
|
+
'Bootpay-User-Token': user_token,
|
27
|
+
'Bootpay-Device-UUID': uuid
|
28
|
+
},
|
29
|
+
payload: {
|
30
|
+
os: os,
|
31
|
+
token: token
|
32
|
+
}
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
module Bootpay::Concern::Subscription
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# 헤당 결제건의 빌링키 가져오기
|
6
|
+
# Comment by Gosomi
|
7
|
+
# Date: 2021-11-01
|
8
|
+
def lookup_subscribe_billing_key(receipt_id)
|
9
|
+
request(
|
10
|
+
method: :get,
|
11
|
+
uri: "subscribe/billing_key/#{receipt_id}"
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
# 빌링키로 결제 요청하기
|
16
|
+
# Comment by Gosomi
|
17
|
+
# Date: 2021-11-02
|
18
|
+
def request_subscribe_card_payment(billing_key:, order_name:, price:, tax_free: 0, card_quota: '00',
|
19
|
+
card_interest: nil, order_id:, items: [], user: {}, extra: {})
|
20
|
+
request(
|
21
|
+
uri: 'subscribe/payment',
|
22
|
+
payload: {
|
23
|
+
billing_key: billing_key,
|
24
|
+
order_name: order_name,
|
25
|
+
price: price,
|
26
|
+
tax_free: tax_free,
|
27
|
+
card_quota: card_quota,
|
28
|
+
card_interest: card_interest,
|
29
|
+
order_id: order_id,
|
30
|
+
items: items,
|
31
|
+
user: user,
|
32
|
+
extra: extra
|
33
|
+
}
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
# 자동결제 예약
|
38
|
+
# Comment by Gosomi
|
39
|
+
# Date: 2022-04-21
|
40
|
+
def subscribe_payment_reserve(billing_key:, reserve_execute_at:, order_name:, price:, tax_free: 0, items: nil, order_id:,
|
41
|
+
metadata: {}, user: nil, feedback_url: nil, content_type: nil)
|
42
|
+
request(
|
43
|
+
uri: 'subscribe/payment/reserve',
|
44
|
+
payload: {
|
45
|
+
billing_key: billing_key,
|
46
|
+
reserve_execute_at: reserve_execute_at,
|
47
|
+
order_name: order_name,
|
48
|
+
order_id: order_id,
|
49
|
+
metadata: metadata,
|
50
|
+
price: price,
|
51
|
+
tax_free: tax_free,
|
52
|
+
items: items,
|
53
|
+
user: user,
|
54
|
+
feedback_url: feedback_url,
|
55
|
+
content_type: content_type
|
56
|
+
}
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
# 자동결제 예약 취소
|
61
|
+
# Comment by Gosomi
|
62
|
+
# Date: 2022-04-21
|
63
|
+
def cancel_subscribe_reserve(reserve_id)
|
64
|
+
request(
|
65
|
+
method: :delete,
|
66
|
+
uri: "subscribe/payment/reserve/#{reserve_id}"
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
# 빌링키를 강제로 만료한다
|
71
|
+
# Comment by Gosomi
|
72
|
+
# Date: 2021-11-04
|
73
|
+
def destroy_billing_key(billing_key)
|
74
|
+
request(
|
75
|
+
method: :delete,
|
76
|
+
uri: "subscribe/billing_key/#{billing_key}"
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
# 빌링키 발급받기
|
81
|
+
# Comment by Gosomi
|
82
|
+
# Date: 2021-11-04
|
83
|
+
def request_subscribe_billing_key(pg:, order_name:, price: nil, tax_free: nil, subscription_id:, card_no:, card_pw:,
|
84
|
+
card_identity_no:, card_expire_year:, card_expire_month:, extra: {}, user: {}, metadata: {})
|
85
|
+
request(
|
86
|
+
uri: 'request/subscribe',
|
87
|
+
payload: {
|
88
|
+
pg: pg,
|
89
|
+
order_name: order_name,
|
90
|
+
subscription_id: subscription_id,
|
91
|
+
price: price,
|
92
|
+
tax_free: tax_free,
|
93
|
+
card_no: card_no,
|
94
|
+
card_pw: card_pw,
|
95
|
+
card_identity_no: card_identity_no,
|
96
|
+
card_expire_year: card_expire_year,
|
97
|
+
card_expire_month: card_expire_month,
|
98
|
+
extra: extra,
|
99
|
+
user: user,
|
100
|
+
metadata: metadata
|
101
|
+
}
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
# 정기결제를 계속해서 진행한다
|
106
|
+
# Comment by Gosomi
|
107
|
+
# Date: 2022-01-18
|
108
|
+
def request_subscribe_on_continue(receipt_id)
|
109
|
+
request(
|
110
|
+
method: :put,
|
111
|
+
uri: "request/subscribe/#{receipt_id}"
|
112
|
+
)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Bootpay::Concern::Token
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# Access Token을 요청한다
|
6
|
+
# Comment by Gosomi
|
7
|
+
# Date: 2021-05-21
|
8
|
+
def request_access_token
|
9
|
+
response = request(
|
10
|
+
uri: 'request/token',
|
11
|
+
payload: {
|
12
|
+
application_id: @application_id,
|
13
|
+
private_key: @private_key
|
14
|
+
}
|
15
|
+
)
|
16
|
+
@token = response.data[:access_token] if response.success?
|
17
|
+
response
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Bootpay::Concern::UserToken
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# User Token 정보를 가져온다
|
6
|
+
# Comment by Gosomi
|
7
|
+
# Date: 2022-02-03
|
8
|
+
def request_user_token(user_id:, email: nil, username: nil, gender: -1, birth: nil, phone: nil)
|
9
|
+
request(
|
10
|
+
method: :post,
|
11
|
+
uri: 'request/user/token',
|
12
|
+
payload: {
|
13
|
+
user_id: user_id,
|
14
|
+
email: email,
|
15
|
+
username: username,
|
16
|
+
gender: gender,
|
17
|
+
birth: birth,
|
18
|
+
phone: phone
|
19
|
+
}
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Bootpay::Concern::Webhook
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# Access Token을 요청한다
|
6
|
+
# Comment by Gosomi
|
7
|
+
# Date: 2021-05-21
|
8
|
+
def request_webhook(receipt_id:, webhook_url:)
|
9
|
+
request(
|
10
|
+
uri: 'request/webhook',
|
11
|
+
payload: {
|
12
|
+
receipt_id: receipt_id,
|
13
|
+
webhook_url: webhook_url
|
14
|
+
}
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Bootpay
|
2
|
+
module Concern
|
3
|
+
require_relative 'concern/authenticate'
|
4
|
+
require_relative 'concern/cash_receipt'
|
5
|
+
require_relative 'concern/easy'
|
6
|
+
require_relative 'concern/escrow'
|
7
|
+
require_relative 'concern/payment'
|
8
|
+
require_relative 'concern/reseller'
|
9
|
+
require_relative 'concern/rest'
|
10
|
+
require_relative 'concern/sdk'
|
11
|
+
require_relative 'concern/subscription'
|
12
|
+
require_relative 'concern/token'
|
13
|
+
require_relative 'concern/user_token'
|
14
|
+
require_relative 'concern/webhook'
|
15
|
+
|
16
|
+
include Authenticate
|
17
|
+
include CashReceipt
|
18
|
+
include Easy
|
19
|
+
include Escrow
|
20
|
+
include Payment
|
21
|
+
include Reseller
|
22
|
+
include Rest
|
23
|
+
include Sdk
|
24
|
+
include Subscription
|
25
|
+
include Token
|
26
|
+
include UserToken
|
27
|
+
include Webhook
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/all'
|
4
|
+
require 'http'
|
5
|
+
require_relative 'response'
|
6
|
+
require_relative 'bootpay/version'
|
7
|
+
require_relative 'bootpay/concern'
|
8
|
+
|
9
|
+
module Bootpay
|
10
|
+
class RestClient
|
11
|
+
include Concern
|
12
|
+
|
13
|
+
API =
|
14
|
+
{
|
15
|
+
development: 'https://dev-api.bootpay.co.kr/v2',
|
16
|
+
stage: 'https://stage-api.bootpay.co.kr/v2',
|
17
|
+
production: 'https://api.bootpay.co.kr/v2'
|
18
|
+
}.freeze
|
19
|
+
|
20
|
+
def initialize(application_id:, private_key:, mode: 'production')
|
21
|
+
@application_id = application_id
|
22
|
+
@private_key = private_key
|
23
|
+
@mode = mode.presence || 'production'
|
24
|
+
@token = nil
|
25
|
+
raise ArgumentError, "개발환경 mode는 development, stage, production 중에서 선택이 가능합니다." if API[@mode.to_sym].blank?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/response.rb
ADDED
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bootpay-backend-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- gosomi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-06-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: http
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Bootpay REST API / Search One Receipt or Cancel Payment, Subscription
|
42
|
+
Payment on REST API.
|
43
|
+
email:
|
44
|
+
- gosomi@bootpay.co.kr
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- ".rspec"
|
51
|
+
- CHANGELOG.md
|
52
|
+
- CODE_OF_CONDUCT.md
|
53
|
+
- Gemfile
|
54
|
+
- LICENSE.txt
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- bin/console
|
58
|
+
- bin/setup
|
59
|
+
- bootpay-backend-ruby.gemspec
|
60
|
+
- lib/bootpay-backend-ruby.rb
|
61
|
+
- lib/bootpay/concern.rb
|
62
|
+
- lib/bootpay/concern/authenticate.rb
|
63
|
+
- lib/bootpay/concern/cash_receipt.rb
|
64
|
+
- lib/bootpay/concern/easy.rb
|
65
|
+
- lib/bootpay/concern/escrow.rb
|
66
|
+
- lib/bootpay/concern/payment.rb
|
67
|
+
- lib/bootpay/concern/reseller.rb
|
68
|
+
- lib/bootpay/concern/rest.rb
|
69
|
+
- lib/bootpay/concern/sdk.rb
|
70
|
+
- lib/bootpay/concern/subscription.rb
|
71
|
+
- lib/bootpay/concern/token.rb
|
72
|
+
- lib/bootpay/concern/user_token.rb
|
73
|
+
- lib/bootpay/concern/webhook.rb
|
74
|
+
- lib/bootpay/version.rb
|
75
|
+
- lib/response.rb
|
76
|
+
homepage:
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubygems_version: 3.0.3.1
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Bootpay Ruby REST Client
|
99
|
+
test_files: []
|