|
|
@@ -3,6 +3,7 @@ package com.style24.front.biz.service;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.gagaframework.web.parameter.GagaMap;
|
|
|
import com.gagaframework.web.security.GagaPasswordEncoder;
|
|
|
+import com.kcp.J_PP_CLI_N;
|
|
|
import com.style24.core.biz.service.TscCustomerService;
|
|
|
import com.style24.core.support.env.TscConstants;
|
|
|
import com.style24.core.support.session.TscSession;
|
|
|
@@ -18,12 +19,18 @@ import com.style24.persistence.domain.WishList;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.env.Environment;
|
|
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.nio.ByteBuffer;
|
|
|
+import java.nio.CharBuffer;
|
|
|
+import java.nio.charset.Charset;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
@@ -56,6 +63,8 @@ public class TsfCustomerService {
|
|
|
@Autowired
|
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private Environment env;
|
|
|
|
|
|
/**
|
|
|
* 고객아이디 찾기
|
|
|
@@ -776,4 +785,138 @@ public class TsfCustomerService {
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * KCP 계좌인증 처리
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @result GagaMap
|
|
|
+ * @author jsshin
|
|
|
+ * @since 2021. 03. 17
|
|
|
+ */
|
|
|
+ public GagaMap checkAccount(HttpServletRequest request) {
|
|
|
+ try {
|
|
|
+ request.setCharacterEncoding("euc-kr");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.getMessage();
|
|
|
+ }
|
|
|
+ GagaMap resultMap = new GagaMap();
|
|
|
+ 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"), 0, env.getProperty("pg.kcp.log.dir") );
|
|
|
+ c_PayPlus.mf_init( "", "paygw.kcp.co.kr", "8090", 0, env.getProperty("pg.kcp.log.dir") );
|
|
|
+ c_PayPlus.mf_init_set();
|
|
|
+// String siteCd = env.getProperty("pg.kcp.site.cd");
|
|
|
+// String siteKey = env.getProperty("pg.kcp.site.key");
|
|
|
+ String kcpSiteCd = "U3476";
|
|
|
+ String kcpsiteKey = "4aVa--.Xz8Fc78nwYPsrmmY__";
|
|
|
+
|
|
|
+ String custIp = request.getRemoteAddr();
|
|
|
+ String tranCd = "00100000";
|
|
|
+ String ordNo = "0";
|
|
|
+ String bankCode = "04";//map.getString("bankList"); //"04";
|
|
|
+ String accountNo = "27560104388848";//map.getString("accountNumber"); //"27560104388848";
|
|
|
+
|
|
|
+
|
|
|
+ int payx_data_set;
|
|
|
+ int common_data_set;
|
|
|
+
|
|
|
+ payx_data_set = c_PayPlus.mf_add_set("payx_data");
|
|
|
+ common_data_set = c_PayPlus.mf_add_set("common");
|
|
|
+
|
|
|
+ c_PayPlus.mf_set_us(common_data_set, "amount", "0");
|
|
|
+ c_PayPlus.mf_set_us(common_data_set, "cust_ip", custIp);
|
|
|
+ c_PayPlus.mf_set_us(common_data_set, "escw_mod", "N");
|
|
|
+
|
|
|
+ c_PayPlus.mf_add_rs(payx_data_set, common_data_set);
|
|
|
+
|
|
|
+ // 주문 정보
|
|
|
+ int ordr_data_set = c_PayPlus.mf_add_set("ordr_data");
|
|
|
+
|
|
|
+ c_PayPlus.mf_set_us(ordr_data_set, "ordr_idxx", ordNo);
|
|
|
+
|
|
|
+ // 계좌 정보
|
|
|
+ int acnt_data_set = c_PayPlus.mf_add_set("bank");
|
|
|
+ log.info("accountHolder {}" , request.getParameter("accountHolder"));
|
|
|
+ c_PayPlus.mf_set_us(acnt_data_set, "bk_owner_nm", request.getParameter("accountHolder")); // 예금주명
|
|
|
+ c_PayPlus.mf_set_us(acnt_data_set, "bk_txtype", "74200000"); // 지불 타입 (계좌 인증)
|
|
|
+ c_PayPlus.mf_set_us(acnt_data_set, "bk_code", bankCode); // 은행 코드
|
|
|
+ c_PayPlus.mf_set_us(acnt_data_set, "bk_account_no", accountNo); // 발급 계좌
|
|
|
+ c_PayPlus.mf_add_rs(payx_data_set, acnt_data_set);
|
|
|
+
|
|
|
+ c_PayPlus.mf_do_tx(kcpSiteCd, kcpsiteKey, tranCd, custIp, ordNo, "3", "0" );
|
|
|
+
|
|
|
+ log.info("recCd =====> {}", c_PayPlus.m_res_cd);
|
|
|
+ log.info("resMsg =====> {}", c_PayPlus.m_res_msg);
|
|
|
+ try {
|
|
|
+ log.info("resMsg 1. kr =====> {}", euckrToUtf8(c_PayPlus.m_res_msg));
|
|
|
+ log.info("resMsg 2. kr =====> {}", euckrToUtf82(c_PayPlus.m_res_msg));
|
|
|
+ log.info("resMsg 3. kr =====> {}", utf83(c_PayPlus.m_res_msg));
|
|
|
+ log.info("resMsg 4. kr =====> {}", new String(c_PayPlus.m_res_msg.getBytes("utf-8"), "utf-8"));
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("res_en_msg =====> {}", c_PayPlus.getRecvMsgOfKey("res_en_msg"));
|
|
|
+ resultMap.set("ResMsg", c_PayPlus.getRecvMsgOfKey("res_en_msg")); // 결과 메시지
|
|
|
+
|
|
|
+ if ("0000".equals(c_PayPlus.m_res_cd)) {
|
|
|
+ resultMap.setBoolean("isPossible", true);
|
|
|
+ log.info("tno ====> {}", c_PayPlus.mf_get_res("tno")); // KCP 거래 고유 번호
|
|
|
+ log.info("app_time ====> {}", c_PayPlus.mf_get_res("app_time"));
|
|
|
+ } else {
|
|
|
+ resultMap.setBoolean("isPossible", false);
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String euckrToUtf8(String euc_kr_str) throws UnsupportedEncodingException {
|
|
|
+ //euc_kr_str - euc-kr 문자열
|
|
|
+
|
|
|
+ CharBuffer cbuffer = CharBuffer.wrap((new String(euc_kr_str.getBytes(Charset.forName("EUC-KR")), "EUC-KR")).toCharArray());
|
|
|
+
|
|
|
+ Charset utf8charset = StandardCharsets.UTF_8;
|
|
|
+
|
|
|
+ ByteBuffer bbuffer = utf8charset.encode(cbuffer);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //변환된 UTF-8 문자열
|
|
|
+
|
|
|
+ return new String(bbuffer.array());
|
|
|
+ }
|
|
|
+
|
|
|
+ private String utf8ToEuckr(String euc_kr_str) throws UnsupportedEncodingException {
|
|
|
+ //euc_kr_str - euc-kr 문자열
|
|
|
+
|
|
|
+ CharBuffer cbuffer = CharBuffer.wrap((new String(euc_kr_str.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8)).toCharArray());
|
|
|
+
|
|
|
+ Charset utf8charset = Charset.forName("EUC-KR");
|
|
|
+
|
|
|
+ ByteBuffer bbuffer = utf8charset.encode(cbuffer);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //변환된 UTF-8 문자열
|
|
|
+
|
|
|
+ return new String(bbuffer.array());
|
|
|
+ }
|
|
|
+
|
|
|
+ private String utf8ToEuckr2(String value) throws UnsupportedEncodingException {
|
|
|
+ byte[] eucKr = value.getBytes("EUC-KR");
|
|
|
+ return eucKr.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String euckrToUtf82(String value) throws UnsupportedEncodingException {
|
|
|
+ byte[] utf8 = value.getBytes("UTF-8");
|
|
|
+ return utf8.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String utf83(String value) throws UnsupportedEncodingException {
|
|
|
+ CharBuffer cbuffer = CharBuffer.wrap((new String(value.getBytes("EUC-KR"), "EUC-KR")).toCharArray());
|
|
|
+ Charset utf8charset = Charset.forName("UTF-8");
|
|
|
+ ByteBuffer bbuffer = utf8charset.encode(cbuffer);
|
|
|
+ return new String(bbuffer.array());
|
|
|
+ }
|
|
|
}
|