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