Skip to content

bootpay/backend-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

143 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Bootpay Java Server Side Library

λΆ€νŠΈνŽ˜μ΄ 곡식 Java 라이브러리 μž…λ‹ˆλ‹€ (μ„œλ²„μ‚¬μ΄λ“œ 용)

javaμ–Έμ–΄λ‘œ μž‘μ„±λœ μ–΄ν”Œλ¦¬μΌ€μ΄μ…˜, ν”„λ ˆμž„μ›Œν¬ λ“±μ—μ„œ μ‚¬μš©κ°€λŠ₯ν•©λ‹ˆλ‹€.

  • PG 결제창 연동은 ν΄λΌμ΄μ–ΈνŠΈ λΌμ΄λΈŒλŸ¬λ¦¬μ—μ„œ μˆ˜ν–‰λ©λ‹ˆλ‹€. (Javascript, Android, iOS, React Native, Flutter λ“±)
  • 결제 검증 및 μ·¨μ†Œ, λΉŒλ§ν‚€ λ°œκΈ‰, 본인인증 λ“±μ˜ μˆ˜ν–‰μ€ μ„œλ²„μ‚¬μ΄λ“œμ—μ„œ μ§„ν–‰λ©λ‹ˆλ‹€. (Java, PHP, Python, Ruby, Node.js, Go, ASP.NET λ“±)

λͺ©μ°¨

Gradle둜 μ„€μΉ˜ν•˜κΈ°

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();
        }
    }
}

ν•¨μˆ˜ λ‹¨μœ„μ˜ μƒ˜ν”Œ μ½”λ“œλŠ” 이곳을 μ°Έμ‘°ν•˜μ„Έμš”.

1. 토큰 λ°œκΈ‰

λΆ€νŠΈνŽ˜μ΄μ™€ μ„œλ²„κ°„ 톡신을 ν•˜κΈ° μœ„ν•΄μ„œλŠ” λΆ€νŠΈνŽ˜μ΄ μ„œλ²„λ‘œλΆ€ν„° 토큰을 λ°œκΈ‰λ°›μ•„μ•Ό ν•©λ‹ˆλ‹€.
λ°œκΈ‰λœ 토큰은 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();
}

2. 결제 단건 쑰회

결제창 및 μ •κΈ°κ²°μ œμ—μ„œ 승인/μ·¨μ†Œλœ κ²°μ œκ±΄μ— λŒ€ν•˜μ—¬ μ˜¬λ°”λ₯Έ κ²°μ œκ±΄μΈμ§€ μ„œλ²„κ°„ ν†΅μ‹ μœΌλ‘œ κ²°μ œκ²€μ¦μ„ ν•©λ‹ˆλ‹€.

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();
}

3. 결제 μ·¨μ†Œ (μ „μ•‘ μ·¨μ†Œ / λΆ€λΆ„ μ·¨μ†Œ)

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();
}

4. μžλ™/빌링/μ •κΈ° 결제

4-1. μΉ΄λ“œ λΉŒλ§ν‚€ λ°œκΈ‰

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();
}

4-2. κ³„μ’Œ λΉŒλ§ν‚€ λ°œκΈ‰

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();
     }
 }

4-3. 결제 μš”μ²­ν•˜κΈ°

λ°œκΈ‰λœ λΉŒλ§ν‚€λ‘œ μ›ν•˜λŠ” μ‹œμ μ— μ›ν•˜λŠ” κΈˆμ•‘μœΌλ‘œ 결제 승인 μš”μ²­μ„ ν•  수 μžˆμŠ΅λ‹ˆλ‹€. μž”μ•‘μ΄ λΆ€μ‘±ν•˜κ±°λ‚˜ λ„λ‚œ μΉ΄λ“œ λ“±μ˜ νŠΉλ³„ν•œ 건이 μ•„λ‹ˆλ©΄ 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-4. 결제 μ˜ˆμ•½ν•˜κΈ°

μ›ν•˜λŠ” μ‹œμ μ— 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();
}

4-5. μ˜ˆμ•½ μ‘°νšŒν•˜κΈ°

μ˜ˆμ•½μ‹œ 응닡받은 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();
}

4-6. μ˜ˆμ•½ μ·¨μ†Œν•˜κΈ°

μ˜ˆμ•½μ‹œ 응닡받은 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();
}

4-7. λΉŒλ§ν‚€ μ‚­μ œν•˜κΈ°

λ°œκΈ‰λœ λΉŒλ§ν‚€λ₯Ό μ‚­μ œν•©λ‹ˆλ‹€. μ‚­μ œν•˜λ”λΌλ„ μ˜ˆμ•½λœ κ²°μ œκ±΄μ€ μ·¨μ†Œλ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. μ˜ˆμ•½λœ 결제건 μ·¨μ†Œλ₯Ό μ›ν•˜μ‹œλ©΄ μ˜ˆμ•½ μ·¨μ†Œν•˜κΈ°λ₯Ό μš”μ²­ν•˜μ…”μ•Ό ν•©λ‹ˆλ‹€.

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();
}

4-8. λΉŒλ§ν‚€ μ‘°νšŒν•˜κΈ°

ν΄λΌμ΄μ–ΈνŠΈμ—μ„œ λΉŒλ§ν‚€ λ°œκΈ‰μ‹œ, λ³΄μ•ˆμƒ ν΄λΌμ΄μ–ΈνŠΈ μ΄λ²€νŠΈμ— λΉŒλ§ν‚€λ₯Ό 전달해주지 μ•ŠμŠ΅λ‹ˆλ‹€. κ·ΈλŸ¬λ―€λ‘œ 이 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();
}

5. νšŒμ› 토큰 λ°œκΈ‰μš”μ²­

γ…‡γ…‡νŽ˜μ΄ μ‚¬μš©μ„ μœ„ν•΄ 가맹점 νšŒμ›μ˜ 토큰을 λ°œκΈ‰ν•©λ‹ˆλ‹€. 가맹점은 νšŒμ›μ˜ 고유번호λ₯Ό κ΄€λ¦¬ν•΄μ•Όν•©λ‹ˆλ‹€. 이 토큰값을 기반으둜 ν΄λΌμ΄μ–ΈνŠΈμ—μ„œ κ²°μ œμš”μ²­(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();
}

6. μ„œλ²„ 승인 μš”μ²­

결제승인 방식은 ν΄λΌμ΄μ–ΈνŠΈ 승인 방식과, μ„œλ²„ 승인 λ°©μ‹μœΌλ‘œ 총 2κ°€μ§€κ°€ μžˆμŠ΅λ‹ˆλ‹€.

ν΄λΌμ΄μ–ΈνŠΈ 승인 방식은 javascriptλ‚˜ native λ“±μ—μ„œ confirm ν•¨μˆ˜μ—μ„œ μ§„ν–‰ν•˜λŠ” 일반적인 λ°©λ²•μž…λ‹ˆλ‹€λ§Œ, κ²½μš°μ— 따라 μ„œλ²„ 승인 방식이 ν•„μš”ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

ν•„μš”ν•œ 이유

  1. 100% μ•ˆμ •μ μΈ 결제 ν›„ 고객 μ•ˆλ‚΄λ₯Ό μœ„ν•΄ - ν΄λΌμ΄μ–ΈνŠΈμ—μ„œ PG결제 μ§„ν–‰ ν›„ 승인 μ™„λ£Œλ  λ•Œ onDone이 μˆ˜ν–‰λ˜μ§€ μ•Šμ•„ (인터넷 ν™˜κ²½ λ“±), 결제 이후 κ³ κ°μ—κ²Œ μ•ˆλ‚΄ν•˜μ§€ λͺ»ν•  수 μžˆμŠ΅λ‹ˆλ‹€
  2. 단일 νŠΈλžœμž­μ…˜μ˜ κ°œλ…μ΄ ν•„μš”ν•  경우 - μž¬κ³ νŒŒμ•…μ΄ μ€‘μš”ν•œ 컀머슀λ₯Ό μš΄μ˜ν•  경우 νŠΈλžœμž­μ…˜ κ°œλ…μ΄ ν•„μš”ν•  수 있겠으며, 이λ₯Ό μœ„ν•΄μ„œλŠ” μ„œλ²„ μŠΉμΈμ„ μ‚¬μš©ν•΄μ•Ό ν•©λ‹ˆλ‹€.
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();
}

7. 본인 인증 결과 쑰회

λ‹€λ‚  본인인증 ν›„ 결과값을 μ‘°νšŒν•©λ‹ˆλ‹€. λ‹€λ‚  λ³ΈμΈμΈμ¦μ—μ„œ 톡신사, 외ꡭ인여뢀, μ „ν™”λ²ˆν˜Έ 이 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();
}
  1. (μ—μŠ€ν¬λ‘œ μ΄μš©μ‹œ) 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();
}

9-1. ν˜„κΈˆμ˜μˆ˜μ¦ λ°œν–‰ν•˜κΈ°

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-2. ν˜„κΈˆμ˜μˆ˜μ¦ λ°œν–‰ μ·¨μ†Œ

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();
}

9-3. (별건) ν˜„κΈˆμ˜μˆ˜μ¦ λ°œν–‰

λΆ€νŠΈνŽ˜μ΄ κ²°μ œμ™€ 상관없이 κΈˆμ•‘, μƒν’ˆλͺ…, ν˜„κΈˆμ˜μˆ˜μ¦ λ°œν–‰μ •λ³΄ 등을 보내 ν˜„κΈˆμ˜μˆ˜μ¦μ„ λ°œν–‰ν•˜λŠ” 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-4. (별건) ν˜„κΈˆμ˜μˆ˜μ¦ λ°œν–‰ μ·¨μ†Œ

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();
}

Example ν”„λ‘œμ νŠΈ

μ μš©ν•œ μƒ˜ν”Œ ν”„λ‘œμ νŠΈμ„ μ°Έμ‘°ν•΄μ£Όμ„Έμš”

Documentation

λΆ€νŠΈνŽ˜μ΄ κ°œλ°œλ§€λ‰΄μ–Όμ„ μ°Έμ‘°ν•΄μ£Όμ„Έμš”

기술문의

λΆ€νŠΈνŽ˜μ΄ ν™ˆνŽ˜μ΄μ§€ 우츑 ν•˜λ‹¨ μ±„νŒ…μ„ 톡해 기술문의 μ£Όμ„Έμš”!

License

MIT License.

About

bootpay server side plugin for java

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors