λΆνΈνμ΄ κ³΅μ 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();
}μ μ©ν μν νλ‘μ νΈμ μ°Έμ‘°ν΄μ£ΌμΈμ
λΆνΈνμ΄ κ°λ°λ§€λ΄μΌμ μ°Έμ‘°ν΄μ£ΌμΈμ
λΆνΈνμ΄ ννμ΄μ§ μ°μΈ‘ νλ¨ μ±ν μ ν΅ν΄ κΈ°μ λ¬Έμ μ£ΌμΈμ!