키움결제 테스트

This commit is contained in:
이경숙
2026-03-23 16:04:25 +09:00
parent ef4f5f473c
commit b0b9ae46be
6 changed files with 802 additions and 3 deletions

View File

@@ -32,6 +32,7 @@ import org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilder;
import org.bouncycastle.operator.InputDecryptorProvider;
import org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfo;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.json.simple.parser.JSONParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -1468,10 +1469,94 @@ public class BOPayService{
}
/* ============================================================================== */
/* = 여기서 부터 Kiwoom
/* = -------------------------------------------------------------------------- = */
/**
* Kiwoom 결제
* @param BOPayVO
*/
public Map<String, Object> insertKiwoomPay(BOPayVO payVO) throws Exception {
//관련 키값 DB 조회
/*DataMap resultMap = selectPayLink(payVO.getSopmalCd());
String reSetleAmt = StringUtil.isNullToString(selectRlSetleAmt(payVO.getSopmalCd(),payVO.getOrderId()));
reSetleAmt = reSetleAmt.isEmpty()? "10" : reSetleAmt; //0원은 정상거래로 인정되어서 10원으로 지정함*/
log.info("insertKiwoomPay step1 ");
String cpId = f_get_parm( payVO.getCpId());
String payMethod = f_get_parm( payVO.getPayMethod());
String orderNo = f_get_parm( payVO.getOrderId());
String type = f_get_parm( payVO.getType());
String amount = f_get_parm( payVO.getAmount());
JSONObject jsonObj = new JSONObject();
jsonObj.put("CPID", cpId);
jsonObj.put("PAYMETHOD", payMethod);
jsonObj.put("ORDERNO", orderNo);
jsonObj.put("TYPE", type);
jsonObj.put("AMOUNT", amount);
log.info("insertKiwoomPay step2 ::: {}", jsonObj);
//결제등록 요청시 실결제값(good_mny)
/*String payType = getPayMethod(payVO.getPayMethod());
jsonReq.put("ordr_mony", reSetleAmt); // ** 결제금액 유효성 검증 **
jsonReq.put("pay_type", payType); // ** 결제수단 유효성 검증 **
jsonReq.put("ordr_no", payVO.getOrderId()); // ** 주문번호검증 **
*/
String kiwoom_ENC = "";
try {
String url = "https://apitest.kiwoompay.co.kr/pay/hash";
URL goUrl = new URL(url);
HttpURLConnection con = (HttpURLConnection) goUrl.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
con.setUseCaches(false);
con.setDoOutput(true);
con.setDoInput(true);
OutputStream os = con.getOutputStream();
os.write((jsonObj.toString()).getBytes("euc-kr"));
os.flush();
os.close();
int responseCode = con.getResponseCode();
if (responseCode == 200) {
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response1 = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response1.append(inputLine);
}
in.close();
JSONObject jObj = (JSONObject) JSONValue.parse(response1.toString());
kiwoom_ENC = (String) jObj.get("KIWOOM_ENC");
log.info("insertKiwoomPay step3 ::: {}", jObj);
}
con.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
JSONObject resultObj = new JSONObject();
resultObj.put("KIWOOM_ENC", kiwoom_ENC);
log.info("insertKiwoomPay step4 ::: {}", resultObj.get("KIWOOM_ENC"));
return new HashMap<>() {{
put("response", resultObj.toString());
}};
}

View File

@@ -292,6 +292,9 @@ public class BOPayVO extends AbstractVO {
/** 테스트 여부 - 테스트용 */
private String testAt;
/** 키움 - 상점ID */
private String cpId;
// cookie
/** 에이전트 ID */