Skip to content

Commit 139ea67

Browse files
committed
- shipping api http method change get -> put
1 parent edac228 commit 139ea67

4 files changed

Lines changed: 102 additions & 59 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 2.0.4
2+
- shipping api http method change get -> put
3+
14
### 2.0.3
25
- shipping model field added
36

README.md

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,27 @@
55

66

77
## 기능
8-
1. (부트페이 통신을 위한) 토큰 발급 요청
9-
2. 결제 검증
8+
1. (부트페이 통신을 위한) 토큰 발급
9+
2. 결제 단건 조회
1010
3. 결제 취소 (전액 취소 / 부분 취소)
11-
4. 빌링키 발급
11+
4. 신용카드 자동결제 (빌링결제)
1212

13-
4-1. 발급된 빌링키로 결제 승인 요청
13+
4-1. 빌링키 발급
1414

15-
4-2. 발급된 빌링키로 결제 승인 예약 요청
15+
4-2. 발급된 빌링키로 결제 승인 요청
1616

17-
4-2-1. 발급된 빌링키로 결제 승인 예약 - 취소 요청
17+
4-3. 발급된 빌링키로 결제 예약 요청
1818

19-
4-3. 빌링키 삭제
20-
5. (부트페이 단독) 사용자 토큰 발급
21-
6. (부트페이 단독) 결제 링크 생성
22-
7. 서버 승인 요청
23-
8. 본인 인증 결과 조회
19+
4-4. 발급된 빌링키로 결제 예약 - 취소 요청
20+
21+
4-5. 빌링키 삭제
22+
23+
4-6. 빌링키 조회
24+
25+
5. (생체인증, 비밀번호 결제를 위한) 구매자 토큰 발급
26+
6. 서버 승인 요청
27+
7. 본인 인증 결과 조회
28+
8. (에스크로 이용시) PG사로 배송정보 보내기
2429

2530
## 설치하기
2631

@@ -52,7 +57,7 @@ func GetToken(api *bootpay.Api) {
5257
}
5358
```
5459

55-
## 2. 결제 검증
60+
## 2. 결제 단건 조회
5661
결제창 및 정기결제에서 승인/취소된 결제건에 대하여 올바른 결제건인지 서버간 통신으로 결제검증을 합니다.
5762
```go
5863
func GetReceipt(api *Api) {
@@ -101,7 +106,7 @@ func ReceiptCancel(api *Api) {
101106
}
102107
```
103108

104-
## 4. 빌링키 발급
109+
## 4-1. 빌링키 발급
105110
REST API 방식으로 고객으로부터 카드 정보를 전달하여, PG사에게 빌링키를 발급받을 수 있습니다.
106111
발급받은 빌링키를 저장하고 있다가, 원하는 시점, 원하는 금액에 결제 승인 요청하여 좀 더 자유로운 결제시나리오에 적용이 가능합니다.
107112
* 비인증 정기결제(REST API) 방식을 지원하는 PG사만 사용 가능합니다.
@@ -129,7 +134,7 @@ func GetBillingKey(api *Api) {
129134
}
130135
```
131136

132-
## 4-1. 발급된 빌링키로 결제 승인 요청
137+
## 4-2. 발급된 빌링키로 결제 승인 요청
133138
발급된 빌링키로 원하는 시점에 원하는 금액으로 결제 승인 요청을 할 수 있습니다. 잔액이 부족하거나 도난 카드 등의 특별한 건이 아니면 PG사에서 결제를 바로 승인합니다.
134139
```go
135140
func RequestSubscribe(api *bootpay.Api) {
@@ -148,8 +153,8 @@ func RequestSubscribe(api *bootpay.Api) {
148153
fmt.Println("--------------- RequestSubscribe() End ---------------")
149154
}
150155
```
151-
## 4-2. 발급된 빌링키로 결제 예약 요청
152-
원하는 시점에 4-1로 결제 승인 요청을 보내도 되지만, 빌링키 발급 이후에 바로 결제 예약 할 수 있습니다. (빌링키당 최대 5건)
156+
## 4-3. 발급된 빌링키로 결제 예약 요청
157+
원하는 시점에 4-1로 결제 승인 요청을 보내도 되지만, 빌링키 발급 이후에 바로 결제 예약 할 수 있습니다. (빌링키당 최대 10건)
153158
```go
154159
func ReserveSubscribe(api *Api) {
155160
s10 := time.Now().Add(time.Second * 100).Format("2006-01-02T15:04:05-07:00")
@@ -171,7 +176,7 @@ func ReserveSubscribe(api *Api) {
171176
fmt.Println("--------------- ReserveSubscribe() End ---------------")
172177
}
173178
```
174-
## 4-2-1. 발급된 빌링키로 결제 예약 - 취소 요청
179+
## 4-4. 발급된 빌링키로 결제 예약 - 취소 요청
175180
빌링키로 예약된 결제건을 취소합니다.
176181
```go
177182
func ReserveCancel(api *Api) {
@@ -186,7 +191,7 @@ func ReserveCancel(api *Api) {
186191
fmt.Println("--------------- ReserveCancel() End ---------------")
187192
}
188193
```
189-
## 4-3. 빌링키 삭제
194+
## 4-5. 빌링키 삭제
190195
발급된 빌링키로 더 이상 사용되지 않도록, 삭제 요청합니다.
191196
```go
192197
func DestroyBillingKey(api *Api) {
@@ -224,36 +229,16 @@ func GetUserToken(api *Api) {
224229
}
225230
fmt.Println("--------------- GetUserToken() End ---------------")
226231
}
227-
```
228-
## 6. 결제 링크 생성
229-
(부트페이 단독) 요청 하시면 결제링크가 리턴되며, 해당 url을 고객에게 안내, 결제 유도하여 결제를 진행할 수 있습니다. (v2에서는 아직 지원되지 않습니다)
230-
```go
231-
func RequestLink(api *bootpay.Api) {
232-
payload := bootpay.Payload{
233-
Pg: "kcp",
234-
Method: "card",
235-
Price: 1000,
236-
OrderId: fmt.Sprintf("%+8d", (time.Now().UnixNano() / int64(time.Millisecond))),
237-
Name: "테스트 결제 상품",
238-
}
239-
res, err := api.RequestLink(payload)
240-
241-
fmt.Println(res)
242-
if err != nil {
243-
fmt.Println("get token error: " + err.Error())
244-
}
245-
}
246-
```
232+
```
247233

248-
## 7. 서버 승인 요청
234+
## 6. 서버 승인 요청
249235
결제승인 방식은 클라이언트 승인 방식과, 서버 승인 방식으로 총 2가지가 있습니다.
250236

251-
클라이언트 승인 방식은 javascript나 native 등에서 confirm 함수에서 진행하는 일반적인 방법입니다만, 경우에 따라 서버 승인 방식이 필요할 수 있습니다.
237+
클라이언트 승인 방식은 pythonscript나 native 등에서 confirm 함수에서 진행하는 일반적인 방법입니다만, 경우에 따라 서버 승인 방식이 필요할 수 있습니다.
252238

253239
필요한 이유
254240
1. 100% 안정적인 결제 후 고객 안내를 위해 - 클라이언트에서 PG결제 진행 후 승인 완료될 때 onDone이 수행되지 않아 (인터넷 환경 등), 결제 이후 고객에게 안내하지 못할 수 있습니다
255241
2. 단일 트랜잭션의 개념이 필요할 경우 - 재고파악이 중요한 커머스를 운영할 경우 트랜잭션 개념이 필요할 수 있겠으며, 이를 위해서는 서버 승인을 사용해야 합니다.
256-
257242
```go
258243
func ServerConfirm(api *Api) {
259244
receiptId := "62afda41cf9f6d001f7d105f"
@@ -268,10 +253,10 @@ func ServerConfirm(api *Api) {
268253
}
269254
```
270255

271-
## 8. 본인 인증 결과 조회
256+
## 7. 본인 인증 결과 조회
272257
다날 본인인증 후 결과값을 조회합니다.
273258
다날 본인인증에서 통신사, 외국인여부, 전화번호 이 3가지 정보는 다날에 추가로 요청하셔야 받으실 수 있습니다.
274-
```java
259+
```go
275260
func Certificate(api *Api) {
276261
receiptId := "6285ffa6cf9f6d0022c4346b"
277262
fmt.Println("--------------- Certificate() Start ---------------")
@@ -285,13 +270,43 @@ func Certificate(api *Api) {
285270
}
286271
```
287272

273+
274+
8. (에스크로 이용시) PG사로 배송정보 보내기
275+
현금 거래에 한해 구매자의 안전거래를 보장하는 방법으로, 판매자와 구매자의 온라인 전자상거래가 원활하게 이루어질 수 있도록 중계해주는 매매보호서비스입니다. 국내법에 따라 전자상거래에서 반드시 적용이 되어 있어야합니다. PG에서도 에스크로 결제를 지원하며, 에스크로 결제 사용을 원하시면 PG사 가맹시에 에스크로결제를 미리 얘기하고나서 진행을 하시는 것이 수월합니다.
276+
277+
PG사로 배송정보( 이니시스, KCP만 지원 )를 보내서 에스크로 상태를 변경하는 API 입니다.
278+
```go
279+
func ShoppingStart(api *Api) {
280+
shipping := Shipping{
281+
ReceiptId: "628ae7ffd01c7e001e9b6066",
282+
TrackingNumber: "123456",
283+
DeliveryCorp: "CJ대한통운",
284+
User: ShippingUser{
285+
Username: "홍길동",
286+
Phone: "01000000000",
287+
Address: "서울특별시 종로구",
288+
Zipcode: "08490",
289+
},
290+
}
291+
292+
fmt.Println("--------------- ShoppingStart() Start ---------------")
293+
res, err := api.putShippingStart(shipping)
294+
295+
fmt.Println(res)
296+
if err != nil {
297+
fmt.Println("get token error: " + err.Error())
298+
}
299+
fmt.Println("--------------- ShoppingStart() End ---------------")
300+
}
301+
```
302+
288303
## Example 프로젝트
289304

290305
[적용한 샘플 프로젝트](https://github.com/bootpay/backend-go-example)을 참조해주세요
291306

292307
## Documentation
293308

294-
[부트페이 개발매뉴얼](https://bootpay.gitbook.io/docs/)을 참조해주세요
309+
[부트페이 개발매뉴얼](https://docs.bootpay.co.kr/next/)을 참조해주세요
295310

296311
## 기술문의
297312

bootpay_test.go

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@ import (
99
func TestGetBillingKey(t *testing.T) {
1010
bootpay := Api{}.New("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=", nil, "")
1111
GetToken(bootpay)
12-
ReceiptCancel(bootpay)
13-
GetReceipt(bootpay)
14-
GetBillingKey(bootpay)
15-
RequestSubscribe(bootpay)
16-
LookupBillingKey(bootpay)
17-
ReserveSubscribe(bootpay)
18-
ReserveCancel(bootpay)
19-
DestroyBillingKey(bootpay)
20-
GetUserToken(bootpay)
21-
GetVerify(bootpay)
22-
//RequestLink(bootpay)
23-
ServerConfirm(bootpay)
24-
Certificate(bootpay)
12+
//ReceiptCancel(bootpay)
13+
//GetReceipt(bootpay)
14+
//GetBillingKey(bootpay)
15+
//RequestSubscribe(bootpay)
16+
//LookupBillingKey(bootpay)
17+
//ReserveSubscribe(bootpay)
18+
//ReserveCancel(bootpay)
19+
//DestroyBillingKey(bootpay)
20+
//GetUserToken(bootpay)
21+
//GetVerify(bootpay)
22+
////RequestLink(bootpay)
23+
//ServerConfirm(bootpay)
24+
//Certificate(bootpay)
25+
ShoppingStart(bootpay)
2526
}
2627

2728
func GetToken(api *Api) {
@@ -240,4 +241,27 @@ func Certificate(api *Api) {
240241
fmt.Println("get token error: " + err.Error())
241242
}
242243
fmt.Println("--------------- Certificate() End ---------------")
244+
}
245+
246+
func ShoppingStart(api *Api) {
247+
shipping := Shipping{
248+
ReceiptId: "628ae7ffd01c7e001e9b6066",
249+
TrackingNumber: "123456",
250+
DeliveryCorp: "CJ대한통운",
251+
User: ShippingUser{
252+
Username: "홍길동",
253+
Phone: "01000000000",
254+
Address: "서울특별시 종로구",
255+
Zipcode: "08490",
256+
},
257+
}
258+
259+
fmt.Println("--------------- ShoppingStart() Start ---------------")
260+
res, err := api.putShippingStart(shipping)
261+
262+
fmt.Println(res)
263+
if err != nil {
264+
fmt.Println("get token error: " + err.Error())
265+
}
266+
fmt.Println("--------------- ShoppingStart() End ---------------")
243267
}

escrow.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package bootpay
22

33
import (
4+
"bytes"
45
"encoding/json"
56
"errors"
67
"net/http"
@@ -40,9 +41,9 @@ func (api *Api) putShippingStart(shipping Shipping) (APIResponse, error) {
4041
putBody, _ := json.Marshal(shipping)
4142
body := bytes.NewBuffer(putBody)
4243

43-
req, err := api.NewRequest(http.MethodGet, "/escrow/shipping/start/" + shipping.ReceiptId, body)
44+
req, err := api.NewRequest(http.MethodPut, "/escrow/shipping/start/" + shipping.ReceiptId, body)
4445
if err != nil {
45-
errors.New("bootpay: Verify error: " + err.Error())
46+
errors.New("bootpay: putShippingStart error: " + err.Error())
4647
return APIResponse{}, err
4748
}
4849
res, err := api.client.Do(req)

0 commit comments

Comments
 (0)