Browse Source

이지페이 구매요청 생성

marseyes 2 years ago
parent
commit
0937ff3ccd

+ 35 - 0
src/main/java/com/oqpo/api/service/loanmng/EasypayPaymentService.java

@@ -2,11 +2,15 @@ package com.oqpo.api.service.loanmng;
2 2
 
3 3
 
4 4
 import com.kicc.EasyPayClient;
5
+import com.oqpo.api.entity.oper.UserMngEntity;
5 6
 import com.oqpo.api.exception.GlobalException;
6 7
 import com.oqpo.api.mapper.loanmng.UnpaidMngMapper;
8
+import com.oqpo.api.mapper.oper.UserMngMapper;
7 9
 import com.oqpo.api.service.CommonService;
8 10
 import com.oqpo.api.util.StringUtil;
11
+import com.oqpo.api.web.dto.request.loanmng.EasypayPaymentCreateRequest;
9 12
 import com.oqpo.api.web.dto.request.loanmng.EasypayPaymentRequest;
13
+import com.oqpo.api.web.dto.response.loanmng.EasypayPaymentCreateResponse;
10 14
 import com.oqpo.api.web.dto.response.loanmng.EasypayPaymentResponse;
11 15
 import lombok.extern.slf4j.Slf4j;
12 16
 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,12 +27,43 @@ public class EasypayPaymentService extends CommonService {
23 27
     @Autowired
24 28
     private UnpaidMngMapper unpaidMngMapper;
25 29
 
30
+    private UserMngMapper userMngMapper;
31
+
26 32
     @Value("${kicc.gateway}")
27 33
     private String kiccGatewayUrl;
28 34
     @Value("${kicc.cert_dir}")
29 35
     private String kiccCertFile;
30 36
     @Value("${kicc.log_dir}")
31 37
     private String kiccLogDir;
38
+    @Value("${kicc.javascript_url}")
39
+    private String kiccJavaScriptUrl;
40
+    @Value("${kicc.action.web_url}")
41
+    private String kiccActionWebUrl;
42
+    @Value("${kicc.action.mobile_url}")
43
+    private String kiccActionMobileUrl;
44
+
45
+    /* 결제 생성 */
46
+    @Transactional
47
+    public EasypayPaymentCreateResponse createPayment(String userId, EasypayPaymentCreateRequest easypayPaymentCreateRequest) throws Exception {
48
+        EasypayPaymentCreateResponse response = new EasypayPaymentCreateResponse();
49
+
50
+        // 1. 주문번호 생성
51
+        response.setPoOrdNo(fnGetDealNo(36, ""));
52
+
53
+        // TODO 2. 이지페이 결제요청 데이터 생성
54
+
55
+        // 3. 사용자정보 조회 및 매핑
56
+        UserMngEntity userInfo = userMngMapper.selectUserInfo(userId);
57
+        response.setOrdNm(userInfo.getUserNm()); // 구매자명
58
+        response.setOrdTel(StringUtil.isEmpty(userInfo.getTelNo()) && userInfo.getTelNo().startsWith("010") ? userInfo.getTelNo() : null); // 휴대전화번호
59
+        response.setOrdEmail(userInfo.getEmail()); // 이메일
60
+
61
+        // 4. 이지페이 결제 URL 매핑
62
+        response.setKicc_javascript_url(kiccJavaScriptUrl);
63
+        response.setKicc_action_web_url(kiccActionWebUrl);
64
+        response.setKicc_action_mobile_url(kiccActionMobileUrl);
65
+        return response;
66
+    }
32 67
 
33 68
     /* 결제 요청 */
34 69
     @Transactional

+ 19 - 6
src/main/java/com/oqpo/api/web/controller/loanmng/EasypayPaymentController.java

@@ -3,12 +3,10 @@ package com.oqpo.api.web.controller.loanmng;
3 3
 import com.oqpo.api.enums.SystemMessageCode;
4 4
 import com.oqpo.api.service.loanmng.EasypayPaymentService;
5 5
 import com.oqpo.api.service.loanmng.UnpaidMngService;
6
-import com.oqpo.api.web.dto.request.loanmng.EasypayPaymentRequest;
7
-import com.oqpo.api.web.dto.request.loanmng.ReqDsptRequest;
8
-import com.oqpo.api.web.dto.request.loanmng.StlDtlGridRequest;
9
-import com.oqpo.api.web.dto.request.loanmng.UnpaidMngGridRequest;
6
+import com.oqpo.api.web.dto.request.loanmng.*;
10 7
 import com.oqpo.api.web.dto.response.GridResponse;
11 8
 import com.oqpo.api.web.dto.response.SaveResponse;
9
+import com.oqpo.api.web.dto.response.loanmng.EasypayPaymentCreateResponse;
12 10
 import com.oqpo.api.web.dto.response.loanmng.UnpaidMngInfoResponse;
13 11
 import io.swagger.annotations.Api;
14 12
 import io.swagger.annotations.ApiImplicitParam;
@@ -32,6 +30,23 @@ public class EasypayPaymentController {
32 30
     @Autowired
33 31
     private EasypayPaymentService easypayPaymentService;
34 32
 
33
+    /**
34
+     * 설명 : 이지페이 결제 생성
35
+     *
36
+     * @param userId
37
+     * @param easypayPaymentCreateRequest
38
+     * @return SaveResponse
39
+     * @throws Exception
40
+     */
41
+    @ApiImplicitParams({
42
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
43
+    })
44
+    @ApiOperation(value = "이지페이 결제 생성")
45
+    @PostMapping("/create")
46
+    public ResponseEntity<EasypayPaymentCreateResponse> create(@ApiIgnore String userId, @RequestBody @Valid EasypayPaymentCreateRequest easypayPaymentCreateRequest) throws Exception {
47
+        return ResponseEntity.ok(easypayPaymentService.createPayment(userId, easypayPaymentCreateRequest));
48
+    }
49
+
35 50
     /**
36 51
      * 설명 : 이지페이 결제 요청
37 52
      *
@@ -47,9 +62,7 @@ public class EasypayPaymentController {
47 62
     @PostMapping("/request")
48 63
     public ResponseEntity<SaveResponse> request(@ApiIgnore String userId, HttpServletRequest request,
49 64
                                                 @RequestBody @Valid EasypayPaymentRequest easypayPaymentRequest) throws Exception {
50
-
51 65
         easypayPaymentService.requestPayment(userId, request, easypayPaymentRequest);
52
-
53 66
         return ResponseEntity.ok(SaveResponse.toDTO(SystemMessageCode.SAVE_OK));
54 67
     }
55 68
 

+ 18 - 0
src/main/java/com/oqpo/api/web/dto/request/loanmng/EasypayPaymentCreateRequest.java

@@ -0,0 +1,18 @@
1
+package com.oqpo.api.web.dto.request.loanmng;
2
+
3
+import io.swagger.annotations.ApiModelProperty;
4
+import lombok.Data;
5
+
6
+import javax.validation.constraints.NotEmpty;
7
+
8
+@Data
9
+public class EasypayPaymentCreateRequest {
10
+
11
+    @ApiModelProperty(value = "브랜드아이디")
12
+    @NotEmpty
13
+    private String brandId;
14
+    @ApiModelProperty(value = "매장아이디")
15
+    @NotEmpty
16
+    private String storeId;
17
+
18
+}

+ 31 - 0
src/main/java/com/oqpo/api/web/dto/response/loanmng/EasypayPaymentCreateResponse.java

@@ -0,0 +1,31 @@
1
+package com.oqpo.api.web.dto.response.loanmng;
2
+
3
+import io.swagger.annotations.ApiModelProperty;
4
+import lombok.Data;
5
+
6
+@Data
7
+public class EasypayPaymentCreateResponse {
8
+
9
+    @ApiModelProperty(value = "수발주주문번호")
10
+    private String poOrdNo;
11
+    @ApiModelProperty(value = "거래번호")
12
+    private String tid;
13
+    @ApiModelProperty(value = "가맹점ID")
14
+    private String mid;
15
+    @ApiModelProperty(value = "상품명")
16
+    private String goodsNm;
17
+    @ApiModelProperty(value = "구매자명")
18
+    private String ordNm;
19
+    @ApiModelProperty(value = "구매자Mobile번호")
20
+    private String ordTel;
21
+    @ApiModelProperty(value = "구매자Email")
22
+    private String ordEmail;
23
+
24
+	@ApiModelProperty(value = "KICC JAVASCRIPT URL")
25
+	private String kicc_javascript_url;
26
+	@ApiModelProperty(value = "KICC ACTION WEB URL")
27
+	private String kicc_action_web_url;
28
+	@ApiModelProperty(value = "KICC ACTION MOBILE URL")
29
+	private String kicc_action_mobile_url;
30
+
31
+}