-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBootpayExample.java
More file actions
208 lines (179 loc) · 7.14 KB
/
Copy pathBootpayExample.java
File metadata and controls
208 lines (179 loc) · 7.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import com.google.gson.Gson;
import kr.co.bootpay.Bootpay;
import kr.co.bootpay.model.BankCode;
import kr.co.bootpay.model.request.*;
import kr.co.bootpay.model.response.ResDefault;
import kr.co.bootpay.model.response.data.*;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import java.util.HashMap;
public class BootpayExample {
static Bootpay bootpay;
public static void main(String[] args) {
bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
goGetToken();
// goVerfity();
// receiptCancel();
// getBillingKey();
// requestSubscribe();
reserveSubscribe();
// reserveCancelSubscribe();
// destroyBillingKey();
// getUserToken();
// requestLink();
// submit();
// certificate();
}
public static void goGetToken() {
try {
ResDefault<HashMap<String, Object>> res = bootpay.getAccessToken();
System.out.println(res.toJson());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void getBillingKey() {
Subscribe subscribe = new Subscribe();
subscribe.itemName = "정기결제 테스트 아이템";
subscribe.orderId = "" + (System.currentTimeMillis() / 1000);
subscribe.pg = "payapp";
subscribe.cardNo = "5570**********1074"; //실제 테스트시에는 *** 마스크처리가 아닌 숫자여야 함
subscribe.cardPw = "**"; //실제 테스트시에는 *** 마스크처리가 아닌 숫자여야 함
subscribe.expireYear = "**"; //실제 테스트시에는 *** 마스크처리가 아닌 숫자여야 함
subscribe.expireMonth = "**"; //실제 테스트시에는 *** 마스크처리가 아닌 숫자여야 함
subscribe.identifyNumber = ""; //주민등록번호 또는 사업자 등록번호 (- 없이 입력)
subscribe.userInfo = new User();
subscribe.userInfo.username = "홍길동";
subscribe.userInfo.phone = "01011112222";
try {
ResDefault<HashMap<String, Object>> res = bootpay.getBillingKey(subscribe);
System.out.println(res.toJson());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void destroyBillingKey() {
String receiptId = "6100e7ea0d681b001fd4de69";
try {
ResDefault res = bootpay.destroyBillingKey(receiptId);
System.out.println(res.toJson());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void requestSubscribe() {
SubscribePayload payload = new SubscribePayload();
payload.billingKey = "618c661d019943003944d5ec";
payload.itemName = "아이템01";
payload.price = 1000;
payload.orderId = "" + (System.currentTimeMillis() / 1000);
try {
ResDefault<HashMap<String, Object>> res = bootpay.requestSubscribe(payload);
System.out.println(res.toJson());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void reserveSubscribe() {
SubscribePayload payload = new SubscribePayload();
payload.billingKey = "619af3fd27018000269761d4";
payload.itemName = "아이템01";
payload.price = 1000;
payload.orderId = "" + (System.currentTimeMillis() / 1000);
payload.executeAt = (System.currentTimeMillis() / 1000) + 10; // 결제 승인 시점
try {
ResDefault<HashMap<String, Object>> res = bootpay.reserveSubscribe(payload);
System.out.println(res.toJson());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void reserveCancelSubscribe() {
String receiptId = "618c66320d681b00445194b5";
try {
ResDefault<HashMap<String, Object>> res = bootpay.reserveCancelSubscribe(receiptId);
System.out.println(res.toJson());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void receiptCancel() {
Cancel cancel = new Cancel();
cancel.receiptId = "6100e77a019943003650f4d5";
cancel.name = "관리자";
cancel.reason = "테스트 결제";
// cancel.price = 1000.0; //부분취소 요청시
// cancel.cancelId = "12342134"; //부분취소 요청시, 중복 부분취소 요청하는 실수를 방지하고자 할때 지정
// RefundData refund = new RefundData(); // 가상계좌 환불 요청시, 단 CMS 특약이 되어있어야만 환불요청이 가능하다.
// refund.account = "675601012341234"; //환불계좌
// refund.accountholder = "홍길동"; //환불계좌주
// refund.bankcode = BankCode.getCode("국민은행");//은행코드
// cancel.refund = refund;
try {
ResDefault<HashMap<String, Object>> res = bootpay.receiptCancel(cancel);
System.out.println(res.toJson());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void getUserToken() {
UserToken userToken = new UserToken();
userToken.userId = "1234"; // 개발사에서 관리하는 회원 고유 번호
try {
ResDefault<HashMap<String, Object>> res = bootpay.getUserToken(userToken);
System.out.println(res.toJson());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void requestLink() {
Payload payload = new Payload();
payload.orderId = "1234";
payload.price = 1000;
payload.name = "테스트 결제";
payload.pg = "payapp";
// payload.method = "vbank";
User user = new User();
user.username = "홍길동";
user.phone = "01012341234";
payload.userInfo = user;
Extra extra = new Extra();
// extra.rawData = 1;
payload.extra = extra;
try {
ResDefault res = bootpay.requestLink(payload);
System.out.println(res.data);
System.out.println(res.toJson());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void submit() {
String receiptId = "6100e8e7019943003850f9b0";
try {
ResDefault<HashMap<String, Object>> res = bootpay.submit(receiptId);
System.out.println(res.toJson());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void goVerfity() {
String receiptId = "6100e77a019943003650f4d5";
try {
ResDefault<HashMap<String, Object>> res = bootpay.verify(receiptId);
System.out.println(res.data.get("receipt_id"));
System.out.println(res.toJson());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void certificate() {
String receiptId = "6184f5310d681b0020511c23";
try {
ResDefault<HashMap<String, Object>> res = bootpay.certificate(receiptId);
System.out.println(res.toJson());
} catch (Exception e) {
e.printStackTrace();
}
}
}