bootpay 1.0.0 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 022100bd6bd482b36005a017f48fcb688740eeaedf6379f056c0a34174b328b6
4
- data.tar.gz: 1aee63779b76d0adaa96b6708ed8bbc6cdb5be379cc9824372901a6dc440abd9
3
+ metadata.gz: f93c2b7e68e637cf9ef3e6349179b7635bb513a749c1df031cc34385f8df6252
4
+ data.tar.gz: c71a38014a72b0d4dabc92ddf615d8267302722c79c7d202e42f34d273712f75
5
5
  SHA512:
6
- metadata.gz: 5f3fdc48ca258c10d22c8d413b2dead5e2b31adb5e4ff03a40819f8325b6c6c84b83c7348379e29162cc1fba2b4a97e6f04253816027b501e7ca1c9392717c5e
7
- data.tar.gz: fa9bcf0841dc97fc5106fed67d4c02a747c623421f18d09342d4a9b20f1de53c3d2ad4551f03ad6840f88576fe89b418eebae17a186ddf1c877d1767b3e715b8
6
+ metadata.gz: 1f8e2ecb7afb21f5d44ff93b7348d0706a3a48dbb797891365f67be3030078351bbb2495a431d72c0cf4597e9b730785607567ef56d04c6347719f3a2cd651a2
7
+ data.tar.gz: 15ca7fcd004f83855f90155eead0b97251677a0d5bfd58ead94d093e4eb4e1823298762fbffb1dc9e304cad7472f6a7a7e501af4f4afba4d6f0551f1e3182756
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
- ## [Unreleased]
1
+ ## 1.0.4
2
2
 
3
- ## [0.1.0] - 2021-08-30
3
+ - cancel에 refund 형식 수정
4
4
 
5
- - Initial release
5
+ ## 1.0.3
6
+
7
+ - BankCode 추가
8
+
9
+ ## 1.0.2
10
+ - certificate data type application/json 으로 수정
11
+
12
+ ## 1.0.1
13
+ - namespace 변경
14
+
15
+ ## 1.0.0
16
+
17
+ - 첫 배포
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 ehowlsla
3
+ Copyright (c) 2021 bootpay
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,10 +1,33 @@
1
- # Bootpay Ruby 플러그인
2
1
 
3
- Bootpay Ruby 라이브러리는 Ruby 언어로 작성된 어플리케이션, 프레임워크 등에서 사용가능합니다.
2
+ ## Bootpay Ruby Server Side Library
3
+ 부트페이 공식 Ruby 라이브러리 입니다 (서버사이드 용)
4
4
 
5
- ## Installation
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
+
17
+ 4-1. 발급된 빌링키로 결제 승인 요청
18
+
19
+ 4-2. 발급된 빌링키로 결제 승인 예약 요청
20
+
21
+ 4-2-1. 발급된 빌링키로 결제 승인 예약 - 취소 요청
22
+
23
+ 4-3. 빌링키 삭제
24
+ 5. (부트페이 단독) 사용자 토큰 발급
25
+ 6. (부트페이 단독) 결제 링크 생성
26
+ 7. 서버 승인 요청
27
+ 8. 본인 인증 결과 조회
28
+
29
+ ## Gem으로 설치하기
6
30
 
7
- Gemfile 파일을 이용하여 설치하기
8
31
 
9
32
  ```ruby
10
33
  gem 'bootpay'
@@ -20,25 +43,229 @@ Gemfile에 위 라인을 추가하고, 아래 라인으로 인스톨 합니다.
20
43
 
21
44
  $ gem install backend-ruby
22
45
 
23
- ## Getting Started
46
+ ## 사용하기
24
47
 
25
48
  ```ruby
26
- # 결제 검증하기
27
- receipt_id = '612df0250d681b001de61de6'
28
49
 
29
- api = Bootpay::Api.new(
30
- application_id: '5b8f6a4d396fa665fdc2b5ea',
31
- private_key: 'rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=',
50
+ require 'bootpay'
51
+
52
+ @api = Bootpay::Api.new(
53
+ application_id: '5b8f6a4d396fa665fdc2b5ea',
54
+ private_key: 'rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=',
55
+ )
56
+ response = @api.request_access_token
57
+ if response.success?
58
+ puts response.data.to_json
59
+ end
60
+ ```
61
+ 함수 단위의 샘플 코드는 [이곳](https://github.com/bootpay/backend-ruby/tree/main/spec/bootpay)을 참조하세요.
62
+
63
+
64
+ ## 1. 토큰 발급
65
+
66
+ 부트페이와 서버간 통신을 하기 위해서는 부트페이 서버로부터 토큰을 발급받아야 합니다.
67
+ 발급된 토큰은 30분간 유효하며, 최초 발급일로부터 30분이 지날 경우 토큰 발급 함수를 재호출 해주셔야 합니다.
68
+ ```ruby
69
+ def get_token
70
+ response = @api.request_access_token
71
+ if response.success?
72
+ puts response.data.to_json
73
+ end
74
+ end
75
+ ```
76
+
77
+
78
+ ## 2. 결제 검증
79
+ 결제창 및 정기결제에서 승인/취소된 결제건에 대하여 올바른 결제건인지 서버간 통신으로 결제검증을 합니다.
80
+ ```ruby
81
+ def verification
82
+ receipt_id = '612df0250d681b001de61de6'
83
+ if @api.request_access_token.success?
84
+ response = @api.verify(receipt_id)
85
+ puts response.data.to_json
86
+ end
87
+ end
88
+ ```
89
+
90
+
91
+ ## 3. 결제 취소 (전액 취소 / 부분 취소)
92
+ price를 지정하지 않으면 전액취소 됩니다.
93
+ * 휴대폰 결제의 경우 이월될 경우 이통사 정책상 취소되지 않습니다
94
+ * 정산받으실 금액보다 취소금액이 클 경우 PG사 정책상 취소되지 않을 수 있습니다. 이때 PG사에 문의하시면 되겠습니다.
95
+ * 가상계좌의 경우 CMS 특약이 되어있지 않으면 취소되지 않습니다. 그러므로 결제 테스트시에는 가상계좌로 테스트 하지 않길 추천합니다.
96
+
97
+ 부분취는 카드로 결제된 건만 가능하며, 일부 PG사만 지원합니다. 요청시 price에 금액을 지정하시면 되겠습니다.
98
+ * (지원가능 PG사: 이니시스, kcp, 다날, 페이레터, 나이스페이, 카카오페이, 페이코)
99
+
100
+ 간혹 개발사에서 실수로 여러번 부분취소를 보내서 여러번 취소되는 경우가 있기때문에, 부트페이에서는 부분취소 중복 요청을 막기 위해 cancel_id 라는 필드를 추가했습니다. cancel_id를 지정하시면, 해당 건에 대해 중복 요청방지가 가능합니다.
101
+ ```ruby
102
+ def cancel
103
+ if @api.request_access_token.success?
104
+ response = @api.cancel_payment(
105
+ receipt_id: "612df0250d681b001de61de6",
106
+ cancel_username: 'test',
107
+ cancel_message: 'test',
108
+ cancel_price: 1000, # 부분취소 요청시
109
+ refund: { # 가상계좌 환불 요청시, 단 CMS 특약이 되어있어야만 환불요청이 가능하다.
110
+ account: '675601010124', # 환불계좌
111
+ accountholder: '홍길동', # 환불계좌주
112
+ bankcode: Bootpay::BANKCODE["국민은행"] # 은행코드
113
+ }
32
114
  )
33
- if api.request_access_token.success?
34
- response = api.verify(receipt_id)
35
- print response.data.to_json
36
- end
115
+ puts response.data.to_json
116
+ end
117
+ end
37
118
  ```
38
119
 
120
+ ## 4. 빌링키 발급
121
+ REST API 방식으로 고객으로부터 카드 정보를 전달하여, PG사에게 빌링키를 발급받을 수 있습니다.
122
+ 발급받은 빌링키를 저장하고 있다가, 원하는 시점, 원하는 금액에 결제 승인 요청하여 좀 더 자유로운 결제시나리오에 적용이 가능합니다.
123
+ * 비인증 정기결제(REST API) 방식을 지원하는 PG사만 사용 가능합니다.
124
+ ```ruby
125
+ def get_billing_key
126
+ if @api.request_access_token.success?
127
+ response = @api.get_billing_key(
128
+ order_id: '1234',
129
+ pg: 'nicepay',
130
+ item_name: '테스트 결제',
131
+ card_no: '', # 값 할당 필요
132
+ card_pw: '', # 값 할당 필요
133
+ expire_year: '', # 값 할당 필요
134
+ expire_month: '', # 값 할당 필요
135
+ identify_number: '' # 값 할당 필요
136
+ )
137
+ puts response.data.to_json
138
+ end
139
+ end
140
+ ```
141
+
142
+ ## 4-1. 발급된 빌링키로 결제 승인 요청
143
+ 발급된 빌링키로 원하는 시점에 원하는 금액으로 결제 승인 요청을 할 수 있습니다. 잔액이 부족하거나 도난 카드 등의 특별한 건이 아니면 PG사에서 결제를 바로 승인합니다.
144
+
145
+ ```ruby
146
+ def subscribe_billing
147
+ billing_key = '612deb53019943001fb52312'
148
+ if @api.request_access_token.success?
149
+ response = @api.subscribe_billing(
150
+ billing_key: billing_key,
151
+ item_name: '테스트 결제',
152
+ price: 1000,
153
+ tax_free: 1000,
154
+ order_id: '1234'
155
+ )
156
+ puts response.data.to_json
157
+ end
158
+ end
159
+ ```
160
+ ## 4-2. 발급된 빌링키로 결제 예약 요청
161
+ 원하는 시점에 4-1로 결제 승인 요청을 보내도 되지만, 빌링키 발급 이후에 바로 결제 예약 할 수 있습니다. (빌링키당 최대 5건)
162
+ ```ruby
163
+ def subscribe_reserve_billing
164
+ billing_key = '612deb53019943001fb52312'
165
+ if @api.request_access_token.success?
166
+ response = @api.subscribe_reserve_billing(
167
+ billing_key: billing_key,
168
+ item_name: '테스트 결제',
169
+ price: 1000,
170
+ tax_free: 1000,
171
+ order_id: '1234',
172
+ execute_at: (Time.now + 10.seconds).to_i # 10초 뒤 결제
173
+ )
174
+ puts response.data.to_json
175
+ end
176
+ end
177
+ ```
178
+ ## 4-2-1. 발급된 빌링키로 결제 예약 - 취소 요청
179
+ 빌링키로 예약된 결제건을 취소합니다.
180
+ ```ruby
181
+ def subscribe_reserve_cancel
182
+ reserve_id = '612deb53019943001fb52312'
183
+ if @api.request_access_token.success?
184
+ response = @api.subscribe_reserve_cancel(reserve_id)
185
+ puts response.data.to_json
186
+ end
187
+ end
188
+ ```
189
+ ## 4-3. 빌링키 삭제
190
+ 발급된 빌링키로 더 이상 사용되지 않도록, 삭제 요청합니다.
191
+ ```java
192
+ Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
193
+
194
+ try {
195
+ ResDefault res = bootpay.destroyBillingKey("6100e7ea0d681b001fd4de69");
196
+ System.out.println(res.toJson());
197
+ } catch (Exception e) {
198
+ e.printStackTrace();
199
+ }
200
+ ```
201
+ ## 5. 사용자 토큰 발급
202
+ (부트페이 단독) 부트페이에서 제공하는 간편결제창, 생체인증 기반의 결제 사용을 위해서는 개발사에서 회원 고유번호를 관리해야하며, 해당 회원에 대한 사용자 토큰을 발급합니다.
203
+ 이 토큰값을 기반으로 클라이언트에서 결제요청 하시면 되겠습니다.
204
+ ```ruby
205
+ def destroy_billing_key
206
+ if @api.request_access_token.success?
207
+ billing_key = '612debc70d681b0039e6133d'
208
+ response = @api.destroy_billing_key(billing_key)
209
+ puts response.data.to_json
210
+ end
211
+ end
212
+ ```
213
+ ## 6. 결제 링크 생성
214
+ (부트페이 단독) 요청 하시면 결제링크가 리턴되며, 해당 url을 고객에게 안내, 결제 유도하여 결제를 진행할 수 있습니다.
215
+ ```ruby
216
+ def request_link
217
+ if @api.request_access_token.success?
218
+ response = @api.request_link(
219
+ pg: 'nicepay',
220
+ price: 1000,
221
+ tax_free: 1000,
222
+ order_id: '1234',
223
+ name: '결제테스트'
224
+ )
225
+ puts response.data.to_json
226
+ end
227
+ end
228
+ ```
229
+
230
+ ## 7. 서버 승인 요청
231
+ 결제승인 방식은 클라이언트 승인 방식과, 서버 승인 방식으로 총 2가지가 있습니다.
232
+
233
+ 클라이언트 승인 방식은 javascript나 native 등에서 confirm 함수에서 진행하는 일반적인 방법입니다만, 경우에 따라 서버 승인 방식이 필요할 수 있습니다.
234
+
235
+ 필요한 이유
236
+ 1. 100% 안정적인 결제 후 고객 안내를 위해 - 클라이언트에서 PG결제 진행 후 승인 완료될 때 onDone이 수행되지 않아 (인터넷 환경 등), 결제 이후 고객에게 안내하지 못할 수 있습니다
237
+ 2. 단일 트랜잭션의 개념이 필요할 경우 - 재고파악이 중요한 커머스를 운영할 경우 트랜잭션 개념이 필요할 수 있겠으며, 이를 위해서는 서버 승인을 사용해야 합니다.
238
+
239
+ ```ruby
240
+ def submit
241
+ receipt_id = '612e09260d681b0021e61ab9'
242
+ if @api.request_access_token.success?
243
+ response = @api.server_submit(receipt_id)
244
+ puts response.data.to_json
245
+ end
246
+ end
247
+ ```
248
+
249
+ ## 8. 본인 인증 결과 조회
250
+ 다날 본인인증 후 결과값을 조회합니다.
251
+ 다날 본인인증에서 통신사, 외국인여부, 전화번호 이 3가지 정보는 다날에 추가로 요청하셔야 받으실 수 있습니다.
252
+ ```ruby
253
+ def certificate
254
+ receipt_id = '612e09260d681b0021e61ab9'
255
+ if @api.request_access_token.success?
256
+ response = @api.certificate(receipt_id)
257
+ puts response.data.to_json
258
+ end
259
+ end
260
+ ```
261
+
262
+ ## Example 프로젝트
263
+
264
+ [적용한 샘플 프로젝트](https://github.com/bootpay/backend-ruby-example)을 참조해주세요
265
+
39
266
  ## Documentation
40
267
 
41
- [부트페이 개발매뉴얼](https://app.gitbook.com/@bootpay)을 참조해주세요
268
+ [부트페이 개발매뉴얼](https://bootpay.gitbook.io/docs/)을 참조해주세요
42
269
 
43
270
  ## 기술문의
44
271
 
@@ -46,4 +273,4 @@ Gemfile에 위 라인을 추가하고, 아래 라인으로 인스톨 합니다.
46
273
 
47
274
  ## License
48
275
 
49
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
276
+ [MIT License](https://opensource.org/licenses/MIT).
data/bootpay-1.0.0.gem ADDED
Binary file
data/bootpay-1.0.1.gem ADDED
Binary file
data/bootpay-1.0.2.gem ADDED
Binary file
data/bootpay-1.0.3.gem ADDED
Binary file
@@ -0,0 +1,49 @@
1
+ require 'active_support/all'
2
+ require 'http'
3
+ require_relative 'response'
4
+ require_relative 'bootpay/billing'
5
+ require_relative 'bootpay/cancel'
6
+ require_relative 'bootpay/easy'
7
+ require_relative 'bootpay/escrow'
8
+ require_relative 'bootpay/link'
9
+ require_relative 'bootpay/naverpay'
10
+ require_relative 'bootpay/payment_resource'
11
+ require_relative 'bootpay/reseller'
12
+ require_relative 'bootpay/rest'
13
+ require_relative 'bootpay/submit'
14
+ require_relative 'bootpay/token'
15
+ require_relative 'bootpay/verification'
16
+ require_relative "bootpay/version"
17
+
18
+ module Bootpay
19
+ class Api
20
+ include Billing
21
+ include Cancel
22
+ include Easy
23
+ include Escrow
24
+ include Link
25
+ include Naverpay
26
+ include PaymentResource
27
+ include Reseller
28
+ include Rest
29
+ include Submit
30
+ include Token
31
+ include Verification
32
+
33
+ API =
34
+ {
35
+ development: 'https://dev-api.bootpay.co.kr/',
36
+ stage: 'https://stage-api.bootpay.co.kr/',
37
+ production: 'https://api.bootpay.co.kr/'
38
+ }.freeze
39
+
40
+ def initialize(application_id:, private_key:, mode: 'production')
41
+
42
+ @application_id = application_id
43
+ @private_key = private_key
44
+ @mode = mode.presence || 'production'
45
+ @token = nil
46
+ raise ArgumentError, "개발환경 mode는 development, stage, production 중에서 선택이 가능합니다." if API[@mode.to_sym].blank?
47
+ end
48
+ end
49
+ end
@@ -6,7 +6,7 @@ module Bootpay::Cancel
6
6
  # Comment by Gosomi
7
7
  # Date: 2021-05-21
8
8
  def cancel_payment(cancel_id: nil, receipt_id:, cancel_price: nil, cancel_tax_free: 0, cancel_username: '시스템', cancel_message: '결제취소',
9
- refund: { bank_account: nil, bank_username: nil, bank_code: nil })
9
+ refund: { account: nil, accountholder: nil, bankcode: nil })
10
10
  request(
11
11
  uri: 'cancel',
12
12
  payload:
@@ -1,6 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bootpay
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.4"
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
+ }
5
24
  end
6
25
 
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - bootpay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-03 00:00:00.000000000 Z
11
+ date: 2021-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -56,11 +56,16 @@ files:
56
56
  - Rakefile
57
57
  - bin/console
58
58
  - bin/setup
59
+ - bootpay-1.0.0.gem
60
+ - bootpay-1.0.1.gem
61
+ - bootpay-1.0.2.gem
62
+ - bootpay-1.0.3.gem
59
63
  - bootpay.gemspec
60
64
  - lib/.DS_Store
61
- - lib/api.rb
65
+ - lib/bootpay.rb
62
66
  - lib/bootpay/.DS_Store
63
67
  - lib/bootpay/billing.rb
68
+ - lib/bootpay/bootpay.rb
64
69
  - lib/bootpay/cancel.rb
65
70
  - lib/bootpay/easy.rb
66
71
  - lib/bootpay/escrow.rb