|
@@ -1,5 +1,7 @@
|
|
|
package com.style24.core.biz.service;
|
|
package com.style24.core.biz.service;
|
|
|
|
|
|
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
|
|
+
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
@@ -8,7 +10,8 @@ import org.springframework.core.env.Environment;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import com.gagaframework.web.parameter.GagaMap;
|
|
import com.gagaframework.web.parameter.GagaMap;
|
|
|
-import com.style24.persistence.domain.Order;
|
|
|
|
|
|
|
+import com.kcp.J_PP_CLI_N;
|
|
|
|
|
+import com.style24.persistence.domain.Payment;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
@@ -18,14 +21,57 @@ public class TscKcpService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private Environment env;
|
|
private Environment env;
|
|
|
|
|
|
|
|
- public GagaMap kcpOrderRequest(Order param, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
|
|
+ public String f_get_parm(String val) {
|
|
|
|
|
+ if ( val == null ) val = "";
|
|
|
|
|
+ return val;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public GagaMap kcpPayRequest(Payment param, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
GagaMap result = new GagaMap();
|
|
GagaMap result = new GagaMap();
|
|
|
// PC pay_method
|
|
// PC pay_method
|
|
|
/* = 신용카드 : 100000000000, 계좌이체 : 010000000000, 가상계좌 : 001000000000 = */
|
|
/* = 신용카드 : 100000000000, 계좌이체 : 010000000000, 가상계좌 : 001000000000 = */
|
|
|
- /* = 포인트 : 000100000000, 휴대폰 : 000010000000, 상품권 : 000000001000 = */
|
|
|
|
|
|
|
+ /* = 포인트 : 000100000000, 휴대폰 : 000010000000, 상품권 : 000000001000 = */
|
|
|
/* = ARS : 000000000010 = */
|
|
/* = ARS : 000000000010 = */
|
|
|
|
|
|
|
|
|
|
+ // 01. characterEncoding EUC-KR 세팅
|
|
|
|
|
+ request.setCharacterEncoding("euc-kr");
|
|
|
|
|
+
|
|
|
|
|
+ log.info("CHECK INFO PARAM >> {}", param.toString());
|
|
|
|
|
+ if (!"POST".equals(request.getMethod())) {
|
|
|
|
|
+ throw new IllegalArgumentException("잘못된 경로로 접속하셨습니다.");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 02. 지불 요청 정보 설정
|
|
|
|
|
+ param.setReqTx(request.getParameter("req_tx"));
|
|
|
|
|
+ param.setTranCd(request.getParameter("tran_cd"));
|
|
|
|
|
+ param.setOrdrIdxx(request.getParameter("ordr_idxx"));
|
|
|
|
|
+
|
|
|
|
|
+ // 03. 인스턴스 생성 및 초기화(변경 불가) (결제에 필요한 인스턴스를 생성하고 초기화 합니다.)
|
|
|
|
|
+ J_PP_CLI_N c_PayPlus = new J_PP_CLI_N();
|
|
|
|
|
+ c_PayPlus.mf_init("", env.getProperty("pg.kcp.gw.url"), env.getProperty("pg.kcp.gw.port"), Integer.parseInt(env.getProperty("pg.kcp.tx.mode")), env.getProperty("pg.kcp.log.dir"));
|
|
|
|
|
+ c_PayPlus.mf_init_set();
|
|
|
|
|
+
|
|
|
|
|
+ // 04-1. 승인 요청 정보 설정
|
|
|
|
|
+ if ("pay".equals(param.getReqTx())){
|
|
|
|
|
+ c_PayPlus.mf_set_enc_data(f_get_parm(request.getParameter("enc_data" )), f_get_parm(request.getParameter("enc_info")));
|
|
|
|
|
+
|
|
|
|
|
+ /* 1원은 실제로 업체에서 결제하셔야 될 원 금액을 넣어주셔야 합니다. 결제금액 유효성 검증 */
|
|
|
|
|
+ int ordr_data_set_no = c_PayPlus.mf_add_set("ordr_data");
|
|
|
|
|
+ c_PayPlus.mf_set_us(ordr_data_set_no, "ordr_mony", request.getParameter("good_mny"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 05. 실행
|
|
|
|
|
+ if (param.getTranCd().length() > 0) {
|
|
|
|
|
+ c_PayPlus.mf_do_tx(env.getProperty("pg.kcp.site.cd"), env.getProperty("pg.kcp.site.key"), param.getTranCd(), "", param.getOrdrIdxx(), env.getProperty("pg.kcp.log.level"), "0");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ c_PayPlus.m_res_cd = "9562";
|
|
|
|
|
+ c_PayPlus.m_res_msg = "연동 오류|tran_cd값이 설정되지 않았습니다.";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ param.setResCd(c_PayPlus.m_res_cd); // 결과 코드
|
|
|
|
|
+ param.setResMsg(c_PayPlus.m_res_msg); // 결과 메시지
|
|
|
|
|
|
|
|
|
|
+ log.info("CHECK RESULT >> " + param.toString());
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|