๋ถํธํ์ด ๊ณต์ Java ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ ๋๋ค (์๋ฒ์ฌ์ด๋ ์ฉ)
java์ธ์ด๋ก ์์ฑ๋ ์ดํ๋ฆฌ์ผ์ด์ , ํ๋ ์์ํฌ ๋ฑ์์ ์ฌ์ฉ๊ฐ๋ฅํฉ๋๋ค.
- PG ๊ฒฐ์ ์ฐฝ ์ฐ๋์ ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ์ํ๋ฉ๋๋ค. (Javascript, Android, iOS, React Native, Flutter ๋ฑ)
- ๊ฒฐ์ ๊ฒ์ฆ ๋ฐ ์ทจ์, ๋น๋งํค ๋ฐ๊ธ, ๋ณธ์ธ์ธ์ฆ ๋ฑ์ ์ํ์ ์๋ฒ์ฌ์ด๋์์ ์งํ๋ฉ๋๋ค. (Java, PHP, Python, Ruby, Node.js, Go, ASP.NET ๋ฑ)
- ์ฌ์ฉํ๊ธฐ
- 1. ํ ํฐ ๋ฐ๊ธ
- 2. ๊ฒฐ์ ๋จ๊ฑด ์กฐํ
- 3. ๊ฒฐ์ ์ทจ์ (์ ์ก ์ทจ์ / ๋ถ๋ถ ์ทจ์)
- 4. ์๋/๋น๋ง/์ ๊ธฐ ๊ฒฐ์
- 5. ํ์ ํ ํฐ ๋ฐ๊ธ์์ฒญ
- 6. ์๋ฒ ์น์ธ ์์ฒญ
- 7. ๋ณธ์ธ ์ธ์ฆ ๊ฒฐ๊ณผ ์กฐํ
- 8. ์์คํฌ๋ก ์ด์ฉ์ PG์ฌ๋ก ๋ฐฐ์ก์ ๋ณด ๋ณด๋ด๊ธฐ
- 9-1. ํ๊ธ์์์ฆ ๋ฐํํ๊ธฐ
- 9-2. ํ๊ธ์์์ฆ ๋ฐํ ์ทจ์
- 9-3. ๋ณ๊ฑด ํ๊ธ์์์ฆ ๋ฐํ
- 9-4. ๋ณ๊ฑด ํ๊ธ์์์ฆ ๋ฐํ ์ทจ์
- Example ํ๋ก์ ํธ
- Documentation
- ๊ธฐ์ ๋ฌธ์
- License
build.gradle (project)
dependencies {
implementation 'io.github.bootpay:backend:+' // + ๋ ์ต์ ๋ฒ์ ์ ์๋ฏธ
}
BootpayExample.java
import com.google.gson.Gson;
import kr.co.bootpay.Bootpay;
import kr.co.bootpay.model.BankCode;
import kr.co.bootpay.model.response.ResDefault;
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();
}
public static void goGetToken() {
try {
BootpayStoreResponse res = bootpay.getAccessToken();
if (res.isSuccess()) {
System.out.println("goGetToken success: " + res.getData());
} else {
System.out.println("goGetToken false: " + res.getData());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}ํจ์ ๋จ์์ ์ํ ์ฝ๋๋ ์ด๊ณณ์ ์ฐธ์กฐํ์ธ์.
๋ถํธํ์ด์ ์๋ฒ๊ฐ ํต์ ์ ํ๊ธฐ ์ํด์๋ ๋ถํธํ์ด ์๋ฒ๋ก๋ถํฐ ํ ํฐ์ ๋ฐ๊ธ๋ฐ์์ผ ํฉ๋๋ค.
๋ฐ๊ธ๋ ํ ํฐ์ 30๋ถ๊ฐ ์ ํจํ๋ฉฐ, ์ต์ด ๋ฐ๊ธ์ผ๋ก๋ถํฐ 30๋ถ์ด ์ง๋ ๊ฒฝ์ฐ ํ ํฐ ๋ฐ๊ธ ํจ์๋ฅผ ์ฌํธ์ถ ํด์ฃผ์
์ผ ํฉ๋๋ค.
Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
try {
BootpayStoreResponse res = bootpay.getAccessToken();
if(res.isSuccess()) {
System.out.println("goGetToken success: " + res.getData());
} else {
System.out.println("goGetToken false: " + res.getData());
}
} catch (Exception e) {
e.printStackTrace();
}๊ฒฐ์ ์ฐฝ ๋ฐ ์ ๊ธฐ๊ฒฐ์ ์์ ์น์ธ/์ทจ์๋ ๊ฒฐ์ ๊ฑด์ ๋ํ์ฌ ์ฌ๋ฐ๋ฅธ ๊ฒฐ์ ๊ฑด์ธ์ง ์๋ฒ๊ฐ ํต์ ์ผ๋ก ๊ฒฐ์ ๊ฒ์ฆ์ ํฉ๋๋ค.
Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
bootpay.getAccessToken();
try {
HashMap<String, Object> res = bootpay.getReceipt(receiptId);
if(res.get("error_code") == null) { //success
System.out.println("getReceipt success: " + res);
} else {
System.out.println("getReceipt false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}price๋ฅผ ์ง์ ํ์ง ์์ผ๋ฉด ์ ์ก์ทจ์ ๋ฉ๋๋ค.
- ํด๋ํฐ ๊ฒฐ์ ์ ๊ฒฝ์ฐ ์ด์๋ ๊ฒฝ์ฐ ์ดํต์ฌ ์ ์ฑ ์ ์ทจ์๋์ง ์์ต๋๋ค
- ์ ์ฐ๋ฐ์ผ์ค ๊ธ์ก๋ณด๋ค ์ทจ์๊ธ์ก์ด ํด ๊ฒฝ์ฐ PG์ฌ ์ ์ฑ ์ ์ทจ์๋์ง ์์ ์ ์์ต๋๋ค. ์ด๋ PG์ฌ์ ๋ฌธ์ํ์๋ฉด ๋๊ฒ ์ต๋๋ค.
- ๊ฐ์๊ณ์ข์ ๊ฒฝ์ฐ CMS ํน์ฝ์ด ๋์ด์์ง ์์ผ๋ฉด ์ทจ์๋์ง ์์ต๋๋ค. ๊ทธ๋ฌ๋ฏ๋ก ๊ฒฐ์ ํ ์คํธ์์๋ ๊ฐ์๊ณ์ข๋ก ํ ์คํธ ํ์ง ์๊ธธ ์ถ์ฒํฉ๋๋ค.
๋ถ๋ถ์ทจ๋ ์นด๋๋ก ๊ฒฐ์ ๋ ๊ฑด๋ง ๊ฐ๋ฅํ๋ฉฐ, ์ผ๋ถ PG์ฌ๋ง ์ง์ํฉ๋๋ค. ์์ฒญ์ price์ ๊ธ์ก์ ์ง์ ํ์๋ฉด ๋๊ฒ ์ต๋๋ค.
- (์ง์๊ฐ๋ฅ PG์ฌ: ์ด๋์์ค, kcp, ๋ค๋ , ํ์ด๋ ํฐ, ๋์ด์คํ์ด, ์นด์นด์คํ์ด, ํ์ด์ฝ)
๊ฐํน ๊ฐ๋ฐ์ฌ์์ ์ค์๋ก ์ฌ๋ฌ๋ฒ ๋ถ๋ถ์ทจ์๋ฅผ ๋ณด๋ด์ ์ฌ๋ฌ๋ฒ ์ทจ์๋๋ ๊ฒฝ์ฐ๊ฐ ์๊ธฐ๋๋ฌธ์, ๋ถํธํ์ด์์๋ ๋ถ๋ถ์ทจ์ ์ค๋ณต ์์ฒญ์ ๋ง๊ธฐ ์ํด cancel_id ๋ผ๋ ํ๋๋ฅผ ์ถ๊ฐํ์ต๋๋ค. cancel_id๋ฅผ ์ง์ ํ์๋ฉด, ํด๋น ๊ฑด์ ๋ํด ์ค๋ณต ์์ฒญ๋ฐฉ์ง๊ฐ ๊ฐ๋ฅํฉ๋๋ค.
Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
bootpay.getAccessToken();
Cancel cancel = new Cancel();
cancel.receiptId = "628b2206d01c7e00209b6087";
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 {
HashMap<String, Object> res = bootpay.receiptCancel(cancel);
if(res.get("error_code") == null) { //success
System.out.println("receiptCancel success: " + res);
} else {
System.out.println("receiptCancel false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}REST API ๋ฐฉ์์ผ๋ก ๊ณ ๊ฐ์ผ๋ก๋ถํฐ ์นด๋ ์ ๋ณด๋ฅผ ์ ๋ฌํ์ฌ, PG์ฌ์๊ฒ ๋น๋งํค๋ฅผ ๋ฐ๊ธ๋ฐ์ ์ ์์ต๋๋ค. ๋ฐ๊ธ๋ฐ์ ๋น๋งํค๋ฅผ ์ ์ฅํ๊ณ ์๋ค๊ฐ, ์ํ๋ ์์ , ์ํ๋ ๊ธ์ก์ ๊ฒฐ์ ์น์ธ ์์ฒญํ์ฌ ์ข ๋ ์์ ๋ก์ด ๊ฒฐ์ ์๋๋ฆฌ์ค์ ์ ์ฉ์ด ๊ฐ๋ฅํฉ๋๋ค.
- ๋น์ธ์ฆ ์ ๊ธฐ๊ฒฐ์ (REST API) ๋ฐฉ์์ ์ง์ํ๋ PG์ฌ๋ง ์ฌ์ฉ ๊ฐ๋ฅํฉ๋๋ค.
Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
bootpay.getAccessToken();
Subscribe subscribe = new Subscribe();
subscribe.orderName = "์ ๊ธฐ๊ฒฐ์ ํ
์คํธ ์์ดํ
";
subscribe.subscriptionId = "" + (System.currentTimeMillis() / 1000);
subscribe.pg = "payapp";
subscribe.cardNo = "5570**********1074"; //์ค์ ํ
์คํธ์์๋ *** ๋ง์คํฌ์ฒ๋ฆฌ๊ฐ ์๋ ์ซ์์ฌ์ผ ํจ
subscribe.cardPw = "**"; //์ค์ ํ
์คํธ์์๋ *** ๋ง์คํฌ์ฒ๋ฆฌ๊ฐ ์๋ ์ซ์์ฌ์ผ ํจ
subscribe.cardExpireYear = "**"; //์ค์ ํ
์คํธ์์๋ *** ๋ง์คํฌ์ฒ๋ฆฌ๊ฐ ์๋ ์ซ์์ฌ์ผ ํจ
subscribe.cardExpireMonth = "**"; //์ค์ ํ
์คํธ์์๋ *** ๋ง์คํฌ์ฒ๋ฆฌ๊ฐ ์๋ ์ซ์์ฌ์ผ ํจ
subscribe.cardIdentityNo = ""; //์๋
์์ผ ๋๋ ์ฌ์
์ ๋ฑ๋ก๋ฒํธ (- ์์ด ์
๋ ฅ)
subscribe.user = new User();
subscribe.user.username = "ํ๊ธธ๋";
subscribe.user.phone = "01011112222";
try {
HashMap<String, Object> res = bootpay.getBillingKey(subscribe);
JSONObject json = new JSONObject(res);
System.out.printf( "JSON: %s", json);
if(res.get("error_code") == null) { //success
System.out.println("getBillingKey success: " + res);
} else {
System.out.println("getBillingKey false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}REST API ๋ฐฉ์์ผ๋ก ๊ณ ๊ฐ์ ๊ณ์ข ์ ๋ณด๋ฅผ ์ ๋ฌํ์ฌ, PG์ฌ์๊ฒ ๋น๋งํค ๋ฐ๊ธ์ ์์ฒญํฉ๋๋ค. ์์ฒญ ํ ๋น๋งํค๊ฐ ๋ฐ๋ก ๋ฐ๊ธ๋์ง ์๊ณ , ์ถ๊ธ๋์ ํ์ธ ์ ์ฐจ๊น์ง ์งํํด์ผ ๋น๋งํค๊ฐ ๋ฐ๊ธ๋ฉ๋๋ค. ๋จผ์ ๋น๋งํค๋ฅผ ์์ฒญํฉ๋๋ค.
public static void getBillingKeyTransfer() {
try {
Subscribe subscribe = new Subscribe();
subscribe.orderName = "ํ
์คํธ ๊ฒฐ์ ";
subscribe.pg = "๋์ด์คํ์ด";
subscribe.bankName = "๊ตญ๋ฏผ";
subscribe.bankAccount = "67512341234472";
subscribe.username = "ํ๊ธธ๋";
subscribe.identityNo = "901014";
subscribe.phone = "01012341234";
subscribe.subscriptionId = "" + (System.currentTimeMillis() / 1000);
// subscribe.tax
HashMap<String, Object> res = bootpay.getBillingKeyTransfer(subscribe);
if(res.get("error_code") == null) { //success
System.out.println("success: " + res);
} else {
System.out.println("false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}
}์ดํ ๋น๋งํค ๋ฐ๊ธ ์์ฒญ์ ์๋ต๋ฐ์ receipt_id๋ก, ์ถ๊ธ ๋์ ํ์ธ์ ์์ฒญํฉ๋๋ค.
public static void publishBillingKeyTransfer() {
try {
HashMap<String, Object> res = bootpay.publishBillingKeyTransfer("66541bc4ca4517e69343e24c");
if(res.get("error_code") == null) { //success
System.out.println("success: " + res);
} else {
System.out.println("false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}
}๋ฐ๊ธ๋ ๋น๋งํค๋ก ์ํ๋ ์์ ์ ์ํ๋ ๊ธ์ก์ผ๋ก ๊ฒฐ์ ์น์ธ ์์ฒญ์ ํ ์ ์์ต๋๋ค. ์์ก์ด ๋ถ์กฑํ๊ฑฐ๋ ๋๋ ์นด๋ ๋ฑ์ ํน๋ณํ ๊ฑด์ด ์๋๋ฉด PG์ฌ์์ ๊ฒฐ์ ๋ฅผ ๋ฐ๋ก ์น์ธํฉ๋๋ค.
Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
bootpay.getAccessToken();
SubscribePayload payload = new SubscribePayload();
payload.billingKey = "628b2644d01c7e00209b6092";
payload.orderName = "์์ดํ
01";
payload.price = 1000;
payload.user = new User();
payload.user.phone = "01012345678";
payload.orderId = "" + (System.currentTimeMillis() / 1000);
try {
HashMap<String, Object> res = bootpay.requestSubscribe(payload);
JSONObject json = new JSONObject(res);
System.out.printf( "JSON: %s", json);
if(res.get("error_code") == null) { //success
System.out.println("requestSubscribe success: " + res);
} else {
System.out.println("requestSubscribe false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}์ํ๋ ์์ ์ 4-1๋ก ๊ฒฐ์ ์น์ธ ์์ฒญ์ ๋ณด๋ด๋ ๋์ง๋ง, ๋น๋งํค ๋ฐ๊ธ ์ดํ์ ๋ฐ๋ก ๊ฒฐ์ ์์ฝ ํ ์ ์์ต๋๋ค. (๋น๋งํค๋น ์ต๋ 10๊ฑด)
Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
bootpay.getAccessToken();
SubscribePayload payload = new SubscribePayload();
payload.billingKey = "628b2644d01c7e00209b6092";
payload.orderName = "์์ดํ
01";
payload.price = 1000;
payload.orderId = "" + (System.currentTimeMillis() / 1000);
Date now = new Date();
now.setTime(now.getTime() + 10 * 1000); //10์ด ๋ค ๊ฒฐ์
//
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss XXX");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
payload.reserveExecuteAt = sdf.format(now); // ๊ฒฐ์ ์น์ธ ์์
try {
HashMap<String, Object> res = bootpay.reserveSubscribe(payload);
if(res.get("error_code") == null) { //success
System.out.println("reserveSubscribe success: " + res);
} else {
System.out.println("reserveSubscribe false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}์์ฝ์ ์๋ต๋ฐ์ reserveId๋ก ์์ฝ๋ ๊ฑด์ ์กฐํํฉ๋๋ค.
String reserveId = "6490149ca575b40024f0b70d";
try {
HashMap<String, Object> res = bootpay.reserveSubscribeLookup(reserveId);
JSONObject json = new JSONObject(res);
System.out.printf( "JSON: %s", json);
if(res.get("error_code") == null) { //success
System.out.println("getReceipt success: " + res);
} else {
System.out.println("getReceipt false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}์์ฝ์ ์๋ต๋ฐ์ reserveId๋ก ์์ฝ๋ ๊ฑด์ ์ทจ์ํฉ๋๋ค.
Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
bootpay.getAccessToken();
String reserveId = "628b316cd01c7e00219b6081";
try {
HashMap<String, Object> res = bootpay.reserveCancelSubscribe(reserveId);
if(res.get("error_code") == null) { //success
System.out.println("reserveCancelSubscribe success: " + res);
} else {
System.out.println("reserveCancelSubscribe false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}๋ฐ๊ธ๋ ๋น๋งํค๋ฅผ ์ญ์ ํฉ๋๋ค. ์ญ์ ํ๋๋ผ๋ ์์ฝ๋ ๊ฒฐ์ ๊ฑด์ ์ทจ์๋์ง ์์ต๋๋ค. ์์ฝ๋ ๊ฒฐ์ ๊ฑด ์ทจ์๋ฅผ ์ํ์๋ฉด ์์ฝ ์ทจ์ํ๊ธฐ๋ฅผ ์์ฒญํ์ ์ผ ํฉ๋๋ค.
Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
bootpay.getAccessToken();
String receiptId = "628b2644d01c7e00209b6092";
try {
HashMap<String, Object> res = bootpay.destroyBillingKey(receiptId);
JSONObject json = new JSONObject(res);
System.out.printf( "JSON: %s", json);
if(res.get("error_code") == null) { //success
System.out.println("destroyBillingKey success: " + res);
} else {
System.out.println("destroyBillingKey false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}ํด๋ผ์ด์ธํธ์์ ๋น๋งํค ๋ฐ๊ธ์, ๋ณด์์ ํด๋ผ์ด์ธํธ ์ด๋ฒคํธ์ ๋น๋งํค๋ฅผ ์ ๋ฌํด์ฃผ์ง ์์ต๋๋ค. ๊ทธ๋ฌ๋ฏ๋ก ์ด API๋ฅผ ํตํด ์กฐํํด์ผ ํฉ๋๋ค. ๋ค์์ ๋น๋งํค ๋ฐ๊ธ ์์ฒญํ๋ receiptId ๋ก ๋น๋งํค๋ฅผ ์กฐํํฉ๋๋ค.
Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
bootpay.getAccessToken();
String receiptId = "62c7ccebcf9f6d001b3adcd4";
try {
HashMap<String, Object> res = bootpay.lookupBillingKey(receiptId);
JSONObject json = new JSONObject(res);
System.out.printf( "JSON: %s", json);
if(res.get("error_code") == null) { //success
System.out.println("getReceipt success: " + res);
} else {
System.out.println("getReceipt false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}์๋๋ billingKey๋ก ์กฐํํฉ๋๋ค.
String billingKey = "66542dfb4d18d5fc7b43e1b6";
try {
HashMap<String, Object> res = bootpay.lookupBillingKeyByKey(billingKey);
JSONObject json = new JSONObject(res);
System.out.printf( "JSON: %s", json);
if(res.get("error_code") == null) { //success
System.out.println("success: " + res);
} else {
System.out.println("false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}ใ ใ ํ์ด ์ฌ์ฉ์ ์ํด ๊ฐ๋งน์ ํ์์ ํ ํฐ์ ๋ฐ๊ธํฉ๋๋ค. ๊ฐ๋งน์ ์ ํ์์ ๊ณ ์ ๋ฒํธ๋ฅผ ๊ด๋ฆฌํด์ผํฉ๋๋ค. ์ด ํ ํฐ๊ฐ์ ๊ธฐ๋ฐ์ผ๋ก ํด๋ผ์ด์ธํธ์์ ๊ฒฐ์ ์์ฒญ(payload.user_token) ํ์๋ฉด ๋๊ฒ ์ต๋๋ค.
Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
bootpay.getAccessToken();
UserToken userToken = new UserToken();
userToken.userId = "1234"; // ๊ฐ๋ฐ์ฌ์์ ๊ด๋ฆฌํ๋ ํ์ ๊ณ ์ ๋ฒํธ
try {
HashMap<String, Object> res = bootpay.getUserToken(userToken);
if(res.get("error_code") == null) { //success
System.out.println("getUserToken success: " + res);
} else {
System.out.println("getUserToken false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}๊ฒฐ์ ์น์ธ ๋ฐฉ์์ ํด๋ผ์ด์ธํธ ์น์ธ ๋ฐฉ์๊ณผ, ์๋ฒ ์น์ธ ๋ฐฉ์์ผ๋ก ์ด 2๊ฐ์ง๊ฐ ์์ต๋๋ค.
ํด๋ผ์ด์ธํธ ์น์ธ ๋ฐฉ์์ javascript๋ native ๋ฑ์์ confirm ํจ์์์ ์งํํ๋ ์ผ๋ฐ์ ์ธ ๋ฐฉ๋ฒ์ ๋๋ค๋ง, ๊ฒฝ์ฐ์ ๋ฐ๋ผ ์๋ฒ ์น์ธ ๋ฐฉ์์ด ํ์ํ ์ ์์ต๋๋ค.
ํ์ํ ์ด์
- 100% ์์ ์ ์ธ ๊ฒฐ์ ํ ๊ณ ๊ฐ ์๋ด๋ฅผ ์ํด - ํด๋ผ์ด์ธํธ์์ PG๊ฒฐ์ ์งํ ํ ์น์ธ ์๋ฃ๋ ๋ onDone์ด ์ํ๋์ง ์์ (์ธํฐ๋ท ํ๊ฒฝ ๋ฑ), ๊ฒฐ์ ์ดํ ๊ณ ๊ฐ์๊ฒ ์๋ดํ์ง ๋ชปํ ์ ์์ต๋๋ค
- ๋จ์ผ ํธ๋์ญ์ ์ ๊ฐ๋ ์ด ํ์ํ ๊ฒฝ์ฐ - ์ฌ๊ณ ํ์ ์ด ์ค์ํ ์ปค๋จธ์ค๋ฅผ ์ด์ํ ๊ฒฝ์ฐ ํธ๋์ญ์ ๊ฐ๋ ์ด ํ์ํ ์ ์๊ฒ ์ผ๋ฉฐ, ์ด๋ฅผ ์ํด์๋ ์๋ฒ ์น์ธ์ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
bootpay.getAccessToken();
String receiptId = "62876963d01c7e00209b6028";
try {
HashMap<String, Object> res = bootpay.confirm(receiptId);
if(res.get("error_code") == null) { //success
System.out.println("confirm success: " + res);
} else {
System.out.println("confirm false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}๋ค๋ ๋ณธ์ธ์ธ์ฆ ํ ๊ฒฐ๊ณผ๊ฐ์ ์กฐํํฉ๋๋ค. ๋ค๋ ๋ณธ์ธ์ธ์ฆ์์ ํต์ ์ฌ, ์ธ๊ตญ์ธ์ฌ๋ถ, ์ ํ๋ฒํธ ์ด 3๊ฐ์ง ์ ๋ณด๋ ๋ค๋ ์ ์ถ๊ฐ๋ก ์์ฒญํ์ ์ผ ๋ฐ์ผ์ค ์ ์์ต๋๋ค.
Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
bootpay.getAccessToken();
try {
HashMap<String, Object> res = bootpay.certificate(receiptId);
if(res.get("error_code") == null) { //success
System.out.println("certificate success: " + res);
} else {
System.out.println("certificate false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}- (์์คํฌ๋ก ์ด์ฉ์) PG์ฌ๋ก ๋ฐฐ์ก์ ๋ณด ๋ณด๋ด๊ธฐ ํ๊ธ ๊ฑฐ๋์ ํํด ๊ตฌ๋งค์์ ์์ ๊ฑฐ๋๋ฅผ ๋ณด์ฅํ๋ ๋ฐฉ๋ฒ์ผ๋ก, ํ๋งค์์ ๊ตฌ๋งค์์ ์จ๋ผ์ธ ์ ์์๊ฑฐ๋๊ฐ ์ํํ๊ฒ ์ด๋ฃจ์ด์ง ์ ์๋๋ก ์ค๊ณํด์ฃผ๋ ๋งค๋งค๋ณดํธ์๋น์ค์ ๋๋ค. ๊ตญ๋ด๋ฒ์ ๋ฐ๋ผ ์ ์์๊ฑฐ๋์์ ๋ฐ๋์ ์ ์ฉ์ด ๋์ด ์์ด์ผํฉ๋๋ค. PG์์๋ ์์คํฌ๋ก ๊ฒฐ์ ๋ฅผ ์ง์ํ๋ฉฐ, ์์คํฌ๋ก ๊ฒฐ์ ์ฌ์ฉ์ ์ํ์๋ฉด PG์ฌ ๊ฐ๋งน์์ ์์คํฌ๋ก๊ฒฐ์ ๋ฅผ ๋ฏธ๋ฆฌ ์๊ธฐํ๊ณ ๋์ ์งํ์ ํ์๋ ๊ฒ์ด ์์ํฉ๋๋ค.
PG์ฌ๋ก ๋ฐฐ์ก์ ๋ณด( ์ด๋์์ค, KCP๋ง ์ง์ )๋ฅผ ๋ณด๋ด์ ์์คํฌ๋ก ์ํ๋ฅผ ๋ณ๊ฒฝํ๋ API ์ ๋๋ค.
Bootpay bootpay = new Bootpay("5b8f6a4d396fa665fdc2b5ea", "rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=");
bootpay.getAccessToken();
Shipping shipping = new Shipping();
shipping.receiptId = "628ae7ffd01c7e001e9b6066";
shipping.trackingNumber = "123456";
shipping.deliveryCorp = "CJ๋ํํต์ด";
ShippingUser user = new ShippingUser();
user.username = "ํ๊ธธ๋";
user.phone = "01000000000";
user.address = "์์ธํน๋ณ์ ์ข
๋ก๊ตฌ";
user.zipcode = "08490";
shipping.user = user;
try {
HashMap<String, Object> res = bootpay.shippingStart(shipping);
if(res.get("error_code") == null) { //success
System.out.println("certificate success: " + res);
} else {
System.out.println("certificate false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}bootpay api๋ฅผ ํตํด ๊ฒฐ์ ๋ ๊ฑด์ ๋ํ์ฌ ํ๊ธ์์์ฆ์ ๋ฐํํฉ๋๋ค.
CashReceipt cashReceipt = new CashReceipt();
cashReceipt.receiptId = "62e0f11f1fc192036b1b3c92";
cashReceipt.username = "ํ
์คํธ";
cashReceipt.email = "test@bootpay.co.kr";
cashReceipt.phone = "01000000000";
cashReceipt.identityNo = "01000000000";
cashReceipt.cashReceiptType = "์๋๊ณต์ ";
try {
HashMap<String, Object> res = bootpay.requestCashReceiptByBootpay(cashReceipt);
if(res.get("error_code") == null) { //success
System.out.println("cashReceiptBootpay success: " + res);
} else {
System.out.println("cashReceiptBootpay false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}9-1์ ํตํด ๋ฐํํ ํ๊ธ์์์ฆ์ ์ทจ์ํฉ๋๋ค.
Cancel cancel = new Cancel();
cancel.receiptId = "62e0f11f1fc192036b1b3c92";
cancel.cancelMessage = "ํ
์คํธ ๊ฒฐ์ ";
cancel.cancelUsername = "ํ
์คํธ ๊ด๋ฆฌ
try {
HashMap<String, Object> res = bootpay.requestCashReceiptCancelByBootpay(cancel);
if(res.get("error_code") == null) { //success
System.out.println("cashReceiptBootpayCancel success: " + res);
} else {
System.out.println("cashReceiptBootpayCancel false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}๋ถํธํ์ด ๊ฒฐ์ ์ ์๊ด์์ด ๊ธ์ก, ์ํ๋ช , ํ๊ธ์์์ฆ ๋ฐํ์ ๋ณด ๋ฑ์ ๋ณด๋ด ํ๊ธ์์์ฆ์ ๋ฐํํ๋ API ์ ๋๋ค
CashReceipt cashReceipt = new CashReceipt();
cashReceipt.pg = "ํ ์ค";
cashReceipt.price = 1000;
cashReceipt.orderName = "ํ
์คํธ";
cashReceipt.cashReceiptType = "์๋๊ณต์ ";
cashReceipt.identityNo = "01000000000";
Date now = new Date();
now.setTime(now.getTime()); //10์ด ๋ค ๊ฒฐ์
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss XXX");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
cashReceipt.purchasedAt = sdf.format(now); // ๊ฒฐ์ ์น์ธ ์์
cashReceipt.orderId = String.valueOf(now.getTime());
try {
HashMap<String, Object> res = bootpay.requestCashReceipt(cashReceipt);
if(res.get("error_code") == null) { //success
System.out.println("cashReceipt success: " + res);
} else {
System.out.println("cashReceipt false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}9-3์ ํตํด ๋ฐํํ ํ๊ธ์์์ฆ์ ์ทจ์ํฉ๋๋ค.
Cancel cancel = new Cancel();
cancel.receiptId = "62f48ae41fc192036f9f4b54";
cancel.cancelMessage = "ํ
์คํธ ๊ฒฐ์ ";
cancel.cancelUsername = "ํ
์คํธ ๊ด๋ฆฌ์";
try {
HashMap<String, Object> res = bootpay.requestCashReceiptCancel(cancel);
if(res.get("error_code") == null) { //success
System.out.println("cashReceiptCancel success: " + res);
} else {
System.out.println("cashReceiptCancel false: " + res);
}
} catch (Exception e) {
e.printStackTrace();
}์ ์ฉํ ์ํ ํ๋ก์ ํธ์ ์ฐธ์กฐํด์ฃผ์ธ์
๋ถํธํ์ด ๊ฐ๋ฐ๋งค๋ด์ผ์ ์ฐธ์กฐํด์ฃผ์ธ์
๋ถํธํ์ด ํํ์ด์ง ์ฐ์ธก ํ๋จ ์ฑํ ์ ํตํด ๊ธฐ์ ๋ฌธ์ ์ฃผ์ธ์!