Kaynağa Gözat

네이버페이 결제형 수정 커밋

card007 4 yıl önce
ebeveyn
işleme
d324d682f2

+ 35 - 12
src/main/java/com/style24/core/biz/service/TscNaverPayService.java

@@ -145,16 +145,29 @@ public class TscNaverPayService {
 		String redirectUrl = protocol + env.getProperty("domain.front") + env.getProperty("naverPay.paymentRedirectUrl");
 
 		// API 파라메터 설정
-		NaverPay naverPay = new NaverPay();
-		naverPay.setModelVersion("2");
-		naverPay.setMerchantUserKey(order.getCustNo());
-		naverPay.setMerchantPayKey(order.getOrdNo());
-		naverPay.setProductName(order.getGoodsNm());
-		naverPay.setProductCount(order.getOrdGoodsQty());
-		naverPay.setTotalPayAmount(order.getPayAmt());
-		naverPay.setTaxScopeAmount(order.getPayAmt());
-		naverPay.setTaxExScopeAmount(0);
-		naverPay.setReturnUrl(redirectUrl);
+		// NaverPay naverPay = new NaverPay();
+		// naverPay.setModelVersion("2");
+		// naverPay.setMerchantUserKey(order.getCustNo());
+		// naverPay.setMerchantPayKey(String.valueOf(order.getOrdNo()));
+		// naverPay.setProductName(order.getGoodsNm());
+		// naverPay.setProductCount(order.getOrdGoodsQty());
+		// naverPay.setTotalPayAmount(order.getPayAmt());
+		// naverPay.setTaxScopeAmount(order.getPayAmt());
+		// naverPay.setTaxExScopeAmount(0);
+		// naverPay.setReturnUrl(redirectUrl);
+		
+		GagaMap naverPay = new GagaMap();
+		naverPay.set("modelVersion", "2");
+		if (order.getCustNo() > 0) {
+			naverPay.set("merchantUserKey", String.valueOf(order.getCustNo()));
+		}
+		naverPay.set("merchantPayKey", String.valueOf(order.getOrdNo()));
+		naverPay.set("productName", order.getGoodsNm());
+		naverPay.set("productCount", order.getOrdGoodsQty());
+		naverPay.set("totalPayAmount", order.getPayAmt());
+		naverPay.set("taxScopeAmount", order.getPayAmt());
+		naverPay.set("taxExScopeAmount", 0);
+		naverPay.set("returnUrl", redirectUrl);
 
 		// 네이버페이 API 전송
 		return naverPayApi.naverPaymentJsonApi(naverPay, paymentReadyUrl);
@@ -252,8 +265,8 @@ public class TscNaverPayService {
 		String paymentOrderUrl = env.getProperty("naverPay.apiUrl") + env.getProperty("naverPay.partnerId") + env.getProperty("naverPay.paymentOrderUrl");
 
 		// API 파라메터 설정
-		NaverPay naverPay = new NaverPay();
-		naverPay.setPaymentId(payment.getPgTid());
+		// NaverPay naverPay = new NaverPay();
+		// naverPay.setPaymentId(payment.getPgTid());
 
 		// 기간별 주문 조회 (31일 이내)
 		// naverPay.setStartTime(order.getStartTime());
@@ -261,6 +274,16 @@ public class TscNaverPayService {
 		// naverPay.setApprovalType(order.getApprovalType());
 		// naverPay.setPageNumber(order.getPageNo());
 		// naverPay.setRowsPerPage(order.getPageSize());
+		
+		GagaMap naverPay = new GagaMap();
+		naverPay.set("paymentId", payment.getPgTid());
+
+		// 기간별 주문 조회 (31일 이내)
+		// naverPay.set("startTime", payment.getStartTime());
+		// naverPay.set("endTime", payment.getEndTime);
+		// naverPay.set("approvalType", payment.getApprovalType());
+		// naverPay.set("pageNumber", payment.getPageNo());
+		// naverPay.set("rowsPerPage", payment.getPageSize());
 
 		// 네이버페이 API 전송
 		return naverPayApi.naverPaymentJsonApi(naverPay, paymentOrderUrl);

+ 2 - 4
src/main/java/com/style24/core/biz/thirdparty/NaverPayApi.java

@@ -2,7 +2,6 @@ package com.style24.core.biz.thirdparty;
 
 import java.net.URI;
 
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.http.HttpEntity;
@@ -17,7 +16,6 @@ import com.gagaframework.web.parameter.GagaMap;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.style24.core.support.message.TscMessageByLocale;
-import com.style24.persistence.domain.KakaoPay;
 import com.style24.persistence.domain.NaverPay;
 
 import lombok.extern.slf4j.Slf4j;
@@ -49,7 +47,7 @@ public class NaverPayApi {
 	 * @author card007
 	 * @since 2021. 03. 07
 	 */
-	public NaverPay naverPaymentJsonApi(NaverPay params, String apiUrl) {
+	public NaverPay naverPaymentJsonApi(GagaMap params, String apiUrl) {
 		NaverPay naverPay;
 		try {
 			HttpHeaders headers = new HttpHeaders();
@@ -57,7 +55,7 @@ public class NaverPayApi {
 			headers.set("X-Naver-Client-Id", env.getProperty("naverPay.clientId"));
 			headers.set("X-Naver-Client-Secret", env.getProperty("naverPay.clientSecret"));
 
-			HttpEntity<NaverPay> request = new HttpEntity<>(params, headers);
+			HttpEntity<GagaMap> request = new HttpEntity<>(params, headers);
 			URI url = URI.create(apiUrl);
 
 			ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, request, String.class);

+ 1 - 2
src/main/java/com/style24/persistence/domain/NaverPay.java

@@ -1,6 +1,5 @@
 package com.style24.persistence.domain;
 
-import java.util.Collection;
 import java.util.List;
 
 import com.style24.persistence.TscBaseDomain;
@@ -19,7 +18,7 @@ public class NaverPay extends TscBaseDomain {
 
 	private String modelVersion;				// 결제 연동 방식
 	private int merchantUserKey;				// 가맹점 주문내역 확인 가능한 가맹점 결제번호 또는 주문번호를 전달해야 합니다
-	private int merchantPayKey;					// 가맹점의 사용자 키(개인 아이디와 같은 개인정보 데이터는 제외하여 전달해야 합니다)
+	private String merchantPayKey;				// 가맹점의 사용자 키(개인 아이디와 같은 개인정보 데이터는 제외하여 전달해야 합니다)
 	private String productName;					// 대표 상품명. 예: 장미의 이름 외 1건(X), 장미의 이름(O)
 	private int productCount;					// 상품 수량 예: A 상품 2개 + B 상품 1개의 경우 productCount 3으로 전달
 	private int totalPayAmount;					// 총 결제 금액. 최소 결제금액은 100원