From 4f792c91996d61fc888124ea6b0d1f3c6e4f5d5f Mon Sep 17 00:00:00 2001 From: bongsh0112 Date: Mon, 18 Sep 2023 01:52:52 +0900 Subject: [PATCH 01/20] =?UTF-8?q?feat:=20=EA=B2=B0=EC=A0=9C=20=EC=97=B0?= =?UTF-8?q?=EB=8F=99=20=EA=B8=B0=EB=8A=A5=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?#29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../picasso/server/api/HomeController.java | 5 ++ Api/src/main/resources/static/js/.keep | 0 Api/src/main/resources/static/js/payment.js | 67 +++++++++++++++++++ Api/src/main/resources/templates/payment.html | 16 +++++ 4 files changed, 88 insertions(+) delete mode 100644 Api/src/main/resources/static/js/.keep create mode 100644 Api/src/main/resources/static/js/payment.js create mode 100644 Api/src/main/resources/templates/payment.html diff --git a/Api/src/main/java/picasso/server/api/HomeController.java b/Api/src/main/java/picasso/server/api/HomeController.java index 2c8dd227..1b9d78f1 100644 --- a/Api/src/main/java/picasso/server/api/HomeController.java +++ b/Api/src/main/java/picasso/server/api/HomeController.java @@ -12,4 +12,9 @@ public class HomeController { public String index() { return "index"; } + + @GetMapping("/payment-test") + public String payment() { + return "payment"; + } } diff --git a/Api/src/main/resources/static/js/.keep b/Api/src/main/resources/static/js/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/Api/src/main/resources/static/js/payment.js b/Api/src/main/resources/static/js/payment.js new file mode 100644 index 00000000..902cf258 --- /dev/null +++ b/Api/src/main/resources/static/js/payment.js @@ -0,0 +1,67 @@ +console.log("html & js connection complete!"); + +var IMP = window.IMP; +IMP.init("imp16618334"); + +function requestKakaoPay() { + IMP.request_pay({ + pg : "kakaopay.TC0ONETIME", + pay_method : 'card', + merchant_uid: "52300234", // 계속 바뀌게 설정해야함 + name : '당근 10kg', + amount : 1004, + buyer_email : 'Iamport@chai.finance', + buyer_name : '아임포트 기술지원팀', + buyer_tel : '010-1234-5678', + buyer_addr : '서울특별시 강남구 삼성동', + buyer_postcode : '123-456' + }, function (rsp) { // callback + if (rsp.success) { + console.log(rsp); + } else { + console.log(rsp); + } + }); +} + +function requestTossPay() { + IMP.request_pay({ + pg : "tosspay.tosstest", + pay_method : 'card', + merchant_uid: "52300234", // 계속 바뀌게 설정해야함 + name : '당근 10kg', + amount : 1004, + buyer_email : 'Iamport@chai.finance', + buyer_name : '아임포트 기술지원팀', + buyer_tel : '010-1234-5678', + buyer_addr : '서울특별시 강남구 삼성동', + buyer_postcode : '123-456' + }, function (rsp) { // callback + if (rsp.success) { + console.log(rsp); + } else { + console.log(rsp); + } + }); +} + +function requestKGInicis() { + IMP.request_pay({ + pg : "html5_inicis.INIBillTst", + pay_method : 'card', + merchant_uid: "52300234", // 계속 바뀌게 설정해야함 + name : '당근 10kg', + amount : 1004, + buyer_email : 'Iamport@chai.finance', + buyer_name : '아임포트 기술지원팀', + buyer_tel : '010-1234-5678', + buyer_addr : '서울특별시 강남구 삼성동', + buyer_postcode : '123-456' + }, function (rsp) { // callback + if (rsp.success) { + console.log(rsp); + } else { + console.log(rsp); + } + }); +} \ No newline at end of file diff --git a/Api/src/main/resources/templates/payment.html b/Api/src/main/resources/templates/payment.html new file mode 100644 index 00000000..68ffb095 --- /dev/null +++ b/Api/src/main/resources/templates/payment.html @@ -0,0 +1,16 @@ + + + + + + + + Sample Payment + + + + + + + + From e7060e83b8eb19579dbb465769d800e6e6f9eb5c Mon Sep 17 00:00:00 2001 From: bongsh0112 Date: Mon, 18 Sep 2023 10:17:07 +0900 Subject: [PATCH 02/20] =?UTF-8?q?feat:=20=EA=B2=B0=EC=A0=9C=20=EC=97=B0?= =?UTF-8?q?=EB=8F=99=20=EA=B5=AC=ED=98=84=EC=97=90=20=EB=A7=9E=EC=B6=98=20?= =?UTF-8?q?dbml=20=EC=88=98=EC=A0=95=20#29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Api/src/main/resources/static/js/payment.js | 23 +++++++-------------- Docs/Picasso.dbml | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Api/src/main/resources/static/js/payment.js b/Api/src/main/resources/static/js/payment.js index 902cf258..42a6a4da 100644 --- a/Api/src/main/resources/static/js/payment.js +++ b/Api/src/main/resources/static/js/payment.js @@ -7,14 +7,11 @@ function requestKakaoPay() { IMP.request_pay({ pg : "kakaopay.TC0ONETIME", pay_method : 'card', - merchant_uid: "52300234", // 계속 바뀌게 설정해야함 + merchant_uid: "09090902", // 계속 바뀌게 설정해야함. 결제에서 가장 중요한 정보 -> 이걸로 결제 하나하나를 식별함 name : '당근 10kg', amount : 1004, buyer_email : 'Iamport@chai.finance', - buyer_name : '아임포트 기술지원팀', - buyer_tel : '010-1234-5678', - buyer_addr : '서울특별시 강남구 삼성동', - buyer_postcode : '123-456' + buyer_name : '아임포트 기술지원팀' }, function (rsp) { // callback if (rsp.success) { console.log(rsp); @@ -28,15 +25,12 @@ function requestTossPay() { IMP.request_pay({ pg : "tosspay.tosstest", pay_method : 'card', - merchant_uid: "52300234", // 계속 바뀌게 설정해야함 + merchant_uid: "1341", name : '당근 10kg', amount : 1004, buyer_email : 'Iamport@chai.finance', - buyer_name : '아임포트 기술지원팀', - buyer_tel : '010-1234-5678', - buyer_addr : '서울특별시 강남구 삼성동', - buyer_postcode : '123-456' - }, function (rsp) { // callback + buyer_name : '아임포트 기술지원팀' + }, function (rsp) { // callback -> rsp에 if (rsp.success) { console.log(rsp); } else { @@ -49,14 +43,11 @@ function requestKGInicis() { IMP.request_pay({ pg : "html5_inicis.INIBillTst", pay_method : 'card', - merchant_uid: "52300234", // 계속 바뀌게 설정해야함 + merchant_uid: "57854673", name : '당근 10kg', amount : 1004, buyer_email : 'Iamport@chai.finance', - buyer_name : '아임포트 기술지원팀', - buyer_tel : '010-1234-5678', - buyer_addr : '서울특별시 강남구 삼성동', - buyer_postcode : '123-456' + buyer_name : '아임포트 기술지원팀' }, function (rsp) { // callback if (rsp.success) { console.log(rsp); diff --git a/Docs/Picasso.dbml b/Docs/Picasso.dbml index 20b1e321..91748d7e 100644 --- a/Docs/Picasso.dbml +++ b/Docs/Picasso.dbml @@ -105,6 +105,27 @@ Table Board.article_amount_history [ created_at datetime [default: 'now()', note: '해당 금액 갱신 시간'] } +Table Payment.payment_info [ + headercolor: #2563eb + note: '결제 히스토리' +] { + id long [pk, increment, note: '결제 정보 하나하나에 대한 ID'] + payment_id long + pg varchar(20) [not null, note: ''' + 결제 플랫폼 + ex) 카카오페이, 토스페이, 이니시스 + ''' + pay_method varchar(20) [not null, default: 'card', note: '결제 방법'] + merchant_uid int [not null, unique, note: '''' + 주문 번호 : 서버에서 고유하게 지정할 예정. + 아마 게시물(경매 물품)의 id를 변형할듯함 + '''] + product_name varchar(100) [not null, note: '상품 이름'] + amount int [not null, note: '결제 가격'] + buyer_id [not null, ref > Auth.user.id, note: '구매자 ID' + buyer_email [not null, note: '구매자 Email'] + buyer_name [not null, note: '구매자 이름'] +} //사용자 정보 관련 그룹 TableGroup User { From b8b38f794386d92b8de2aad102e14480a09b3cc9 Mon Sep 17 00:00:00 2001 From: bongsh0112 Date: Mon, 18 Sep 2023 16:52:28 +0900 Subject: [PATCH 03/20] =?UTF-8?q?feat:=20=EA=B2=B0=EC=A0=9C=20=EC=97=B0?= =?UTF-8?q?=EB=8F=99=20=EA=B5=AC=ED=98=84=20thymeleaf=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=201=ED=8A=B8=20#29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/picasso/server/payment/PGName.java | 14 ++++ Api/src/main/resources/static/js/pay_modal.js | 14 ++++ Api/src/main/resources/static/js/payment.js | 79 +++++++++---------- .../resources/templates/fragment/config.html | 4 + Api/src/main/resources/templates/payment.html | 36 ++++++--- .../src/main/java/picasso/server/infra/.keep | 0 6 files changed, 93 insertions(+), 54 deletions(-) create mode 100644 Api/src/main/java/picasso/server/payment/PGName.java create mode 100644 Api/src/main/resources/static/js/pay_modal.js delete mode 100644 Infra/src/main/java/picasso/server/infra/.keep diff --git a/Api/src/main/java/picasso/server/payment/PGName.java b/Api/src/main/java/picasso/server/payment/PGName.java new file mode 100644 index 00000000..74ade9e1 --- /dev/null +++ b/Api/src/main/java/picasso/server/payment/PGName.java @@ -0,0 +1,14 @@ +package picasso.server.payment; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum PGName { + KAKAO("kakaopay.TC0ONETIME"), + TOSS("tosspay.tosstest"); + + private final String value; +} + diff --git a/Api/src/main/resources/static/js/pay_modal.js b/Api/src/main/resources/static/js/pay_modal.js new file mode 100644 index 00000000..ac9e7694 --- /dev/null +++ b/Api/src/main/resources/static/js/pay_modal.js @@ -0,0 +1,14 @@ +const inputP = document.querySelector('.inputPrice') //결제 개월 수 입력받는 inputhidden +const amount = document.querySelector('.amount'); +const amountV = document.querySelector('.amountValue'); + +//결제 가격 +function inputPrice(e){ + const paynum = (e.value); + inputP.value = e.value; + amount.textContent = "결제 금액 : " + paynum + "원"; + amountV.value = paynum; +} + +var price = inputP.value; +document.getElementById("price_amount").innerHTML = price; \ No newline at end of file diff --git a/Api/src/main/resources/static/js/payment.js b/Api/src/main/resources/static/js/payment.js index 42a6a4da..b0449386 100644 --- a/Api/src/main/resources/static/js/payment.js +++ b/Api/src/main/resources/static/js/payment.js @@ -1,58 +1,51 @@ -console.log("html & js connection complete!"); - var IMP = window.IMP; -IMP.init("imp16618334"); +IMP.init("imp16618334"); // 재발급 받은 뒤 숨겨버릴 예정 -function requestKakaoPay() { - IMP.request_pay({ - pg : "kakaopay.TC0ONETIME", +var requestPayment = pg_name => { + return IMP.request_pay({ + pg : pg_name, pay_method : 'card', - merchant_uid: "09090902", // 계속 바뀌게 설정해야함. 결제에서 가장 중요한 정보 -> 이걸로 결제 하나하나를 식별함 - name : '당근 10kg', + merchant_uid: "picasso_" + new Date().getMilliseconds(), // 계속 바뀌게 설정해야함. 결제에서 가장 중요한 정보 -> 이걸로 결제 하나하나를 식별함 + name : 'asdfasdf', amount : 1004, buyer_email : 'Iamport@chai.finance', buyer_name : '아임포트 기술지원팀' - }, function (rsp) { // callback - if (rsp.success) { - console.log(rsp); - } else { - console.log(rsp); - } }); } -function requestTossPay() { - IMP.request_pay({ - pg : "tosspay.tosstest", - pay_method : 'card', - merchant_uid: "1341", - name : '당근 10kg', - amount : 1004, - buyer_email : 'Iamport@chai.finance', - buyer_name : '아임포트 기술지원팀' - }, function (rsp) { // callback -> rsp에 - if (rsp.success) { - console.log(rsp); +var paymentResult = pg_name => { + return (requestPayment(pg_name), function(response) { + if (response.success) { + var msg = "결제 완료"; + msg += '고유ID : ' + response.imp_uid; + msg += '// 상점 거래ID : ' + response.merchant_uid; + msg += '// 결제 금액 : ' + response.paid_amount; + msg += '// 카드 승인번호 : ' + response.apply_num; + + postPayInfo(true); + console.log(msg); } else { - console.log(rsp); + var msg = "결제 실패" + msg += "에러 내용" + response.error_msg; + postPayInfo(false); + console.log(msg); } }); } -function requestKGInicis() { - IMP.request_pay({ - pg : "html5_inicis.INIBillTst", - pay_method : 'card', - merchant_uid: "57854673", - name : '당근 10kg', - amount : 1004, - buyer_email : 'Iamport@chai.finance', - buyer_name : '아임포트 기술지원팀' - }, function (rsp) { // callback - if (rsp.success) { - console.log(rsp); - } else { - console.log(rsp); - } - }); +function postPayInfo(tof, rsp) { + $.ajax({ + type : 'post', + url : '/pay', + data : { + "pay_result" : tof, + "buyer_name" : rsp.buyer_name, + "buyer_email" : rsp.buyer_email, + "merchant_uid" : rsp.merchant_uid, + "product_name" : rsp.name, + "pg_provider" : rsp.pg_provider, + "amount" : rsp.paid_amount, + "pay_method" : rsp.pay_method + }, + }) } \ No newline at end of file diff --git a/Api/src/main/resources/templates/fragment/config.html b/Api/src/main/resources/templates/fragment/config.html index 3ee1599f..d63234d6 100644 --- a/Api/src/main/resources/templates/fragment/config.html +++ b/Api/src/main/resources/templates/fragment/config.html @@ -18,6 +18,10 @@ + + + + diff --git a/Api/src/main/resources/templates/payment.html b/Api/src/main/resources/templates/payment.html index 68ffb095..255b014b 100644 --- a/Api/src/main/resources/templates/payment.html +++ b/Api/src/main/resources/templates/payment.html @@ -1,16 +1,30 @@ - - - - - - - Sample Payment - + + - - - + + +
+

결제하기

+
+ + + +
+

결제 금액

+ +
+ + diff --git a/Infra/src/main/java/picasso/server/infra/.keep b/Infra/src/main/java/picasso/server/infra/.keep deleted file mode 100644 index e69de29b..00000000 From 9ec5251ef2f122c7d27a9f62a46f529df5b1a646 Mon Sep 17 00:00:00 2001 From: bongsh0112 Date: Mon, 18 Sep 2023 17:27:20 +0900 Subject: [PATCH 04/20] =?UTF-8?q?feat:=20=EA=B2=B0=EC=A0=9C=20=EC=97=B0?= =?UTF-8?q?=EB=8F=99=20=EA=B5=AC=ED=98=84=20thymeleaf=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20=EC=99=84=EB=A3=8C=20#29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Api/src/main/resources/static/js/payment.js | 3 ++- Api/src/main/resources/templates/payment.html | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Api/src/main/resources/static/js/payment.js b/Api/src/main/resources/static/js/payment.js index b0449386..4f581afc 100644 --- a/Api/src/main/resources/static/js/payment.js +++ b/Api/src/main/resources/static/js/payment.js @@ -13,7 +13,8 @@ var requestPayment = pg_name => { }); } -var paymentResult = pg_name => { +var paymentResult = obj => { + var pg_name = obj.value return (requestPayment(pg_name), function(response) { if (response.success) { var msg = "결제 완료"; diff --git a/Api/src/main/resources/templates/payment.html b/Api/src/main/resources/templates/payment.html index 255b014b..ded8bb89 100644 --- a/Api/src/main/resources/templates/payment.html +++ b/Api/src/main/resources/templates/payment.html @@ -12,11 +12,8 @@

결제하기

- - - + +

결제 금액