키움결제 테스트
This commit is contained in:
@@ -22,9 +22,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.wb.domainserver.domain.sopmal.ordr.vo.PayVO;
|
||||
@@ -630,4 +628,164 @@ public class PayController {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
/* *********************************************
|
||||
* 키움결제
|
||||
********************************************* */
|
||||
|
||||
/**
|
||||
* 키움 결제 화면
|
||||
* @return PayKiwoomSucsC.jsp
|
||||
* @author 이경숙
|
||||
*/
|
||||
@Policy(AuthPolicy.RESTRICTED)
|
||||
@RequestMapping(value="/selectKiwoomSimple")
|
||||
public String selectKiwoonPay(ModelMap model) throws Exception {
|
||||
log.debug("selectKiwoonPay = {}");
|
||||
return "sopmal/ordr/PayKiwoomPayC";
|
||||
}
|
||||
|
||||
@Policy(AuthPolicy.RESTRICTED)
|
||||
@RequestMapping(value="/selectKiwoomSimple2")
|
||||
public String selectKiwoonPay2(ModelMap model) throws Exception {
|
||||
log.debug("selectKiwoonPay = {}");
|
||||
return "sopmal/ordr/PayKiwoomPay2C";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 키움 결제 연계 전 getEnc 값 받아오기
|
||||
* @return PayKiwoomSucsC.jsp
|
||||
* @author 이경숙
|
||||
*/
|
||||
@Policy(AuthPolicy.RESTRICTED)
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/kiwoomPayGetEnc")
|
||||
public Map<String, Object> selectKiwoomGetEnc(HttpServletRequest request) throws Exception {
|
||||
|
||||
BOPayVO payVO = new BOPayVO();
|
||||
|
||||
log.debug("kiwoomPayGetEnc = {}");
|
||||
|
||||
payVO.setCpId(request.getParameter("CPID"));
|
||||
payVO.setPayMethod(request.getParameter("PAYMETHOD"));
|
||||
payVO.setOrderId(request.getParameter("ORDERNO"));
|
||||
payVO.setType(request.getParameter("TYPE"));
|
||||
payVO.setAmount(request.getParameter("AMOUNT"));
|
||||
|
||||
Map<String, Object> message;
|
||||
String sopmalCd = payVO.getSopmalCd();
|
||||
try {
|
||||
message = service.insertKiwoomPay(payVO);
|
||||
|
||||
} catch (Exception e) {
|
||||
message = new HashMap<>() {{
|
||||
put("response", "결제를 실패하였습니다.\n관리자에게 문의하시기 바랍니다.");
|
||||
}};
|
||||
}
|
||||
|
||||
|
||||
log.info("insertKiwoomPay step5 ::: {}", message.get("KIWOOM_ENC"));
|
||||
|
||||
//model.addAttribute("message", message);
|
||||
//return "sopmal/ordr/PayKiwoomSucsC";
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 키움 결제 연계처리 - 결과통보페이지
|
||||
* @return PayKiwoomSucsC.jsp
|
||||
* @author 이경숙
|
||||
*/
|
||||
@Policy(AuthPolicy.RESTRICTED)
|
||||
@RequestMapping(value="/kiwoomPayWebhook")
|
||||
@ResponseBody
|
||||
public ResponseEntity<String> selectPaymentkiwoomWebhook(HttpServletRequest request) throws Exception {
|
||||
|
||||
String resultCode = request.getParameter("RESULTCODE");
|
||||
String orderNo = request.getParameter("ORDERNO");
|
||||
String amount = request.getParameter("AMOUNT");
|
||||
|
||||
System.out.println("콜백 수신");
|
||||
System.out.println("RESULTCODE = " + resultCode);
|
||||
System.out.println("ORDERNO = " + orderNo);
|
||||
System.out.println("AMOUNT = " + amount);
|
||||
|
||||
/* 실제 처리해야 되는 부분
|
||||
// 1. 주문 조회
|
||||
Order order = orderService.find(orderNo);
|
||||
|
||||
// 2. 중복 방지
|
||||
if ("PAID".equals(order.getStatus())) return "OK";
|
||||
|
||||
// 3. 금액 검증
|
||||
if (!order.getAmount().equals(Integer.parseInt(amount))) {
|
||||
order.setStatus("FAIL");
|
||||
return "OK";
|
||||
}
|
||||
|
||||
// 4. 성공 처리
|
||||
if ("0000".equals(resultCode)) {
|
||||
order.setStatus("PAID");
|
||||
} else {
|
||||
order.setStatus("FAIL");
|
||||
}
|
||||
|
||||
orderService.save(order);
|
||||
*/
|
||||
String response = "<html><body><RESULT>SUCCESS</RESULT></body></html>";
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.TEXT_HTML)
|
||||
.body(response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 키움 결제 연계처리 - 성공결과페이지
|
||||
* @return PayKiwoomSucsC.jsp
|
||||
* @author 이경숙
|
||||
*/
|
||||
@Policy(AuthPolicy.RESTRICTED)
|
||||
@RequestMapping(value="/kiwoomPaySuccss")
|
||||
public String confirmPaymentkiwoom(HttpServletRequest request, ModelMap model) throws Exception {
|
||||
|
||||
BOPayVO payVO = new BOPayVO();
|
||||
|
||||
payVO.setCode(request.getParameter("RESULTCODE"));
|
||||
payVO.setOrderId(request.getParameter("ORDERNO"));
|
||||
payVO.setAmount(request.getParameter("AMOUNT"));
|
||||
payVO.setPayMethod(request.getParameter("PAYMETHOD"));
|
||||
|
||||
Map<String, Object> message = new HashMap<>();
|
||||
/*String sopmalCd = payVO.getSopmalCd();
|
||||
try {
|
||||
message = service.insertKcpPay(payVO);
|
||||
|
||||
} catch (Exception e) {
|
||||
message = new HashMap<>() {{
|
||||
put("response", "결제를 실패하였습니다.\n관리자에게 문의하시기 바랍니다.");
|
||||
}};
|
||||
}*/
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("code", payVO.getCode());
|
||||
jsonObject.put("orderId", payVO.getOrderId());
|
||||
jsonObject.put("amount", payVO.getAmount());
|
||||
jsonObject.put("payMethod", payVO.getPayMethod());
|
||||
message.put("response",jsonObject.toString());
|
||||
|
||||
model.addAttribute("message", message);
|
||||
// responseHandler.handleResponse(
|
||||
// sendToResrc.ofPost(RESRC.GCONEBO, "/gcone/ordr/pay/kcpPayProc", payVO),
|
||||
// model,
|
||||
// "message"
|
||||
// );
|
||||
|
||||
return "sopmal/ordr/PayKiwoomSucsC";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user