기본 콘텐츠로 건너뛰기

네이버페이 리뷰 API 연동

네이버 페이 리뷰 API

네이버 측에 문의 하면 sandbox용 인증키를 받습니다.

AccessLicense, SecretKey

그리고 받은 파일의 4. WSDL을 열어 주시고 Naver_Pay_API_MallService41_WSDL(sandbox)_20140925파일 압축 풀어주세요

그럼 파일이 BaseType.xsd, CheckoutAPI.wsdl, MallServiceMessage.xsd 세개의 파일이 나옵니다.

네이버페이 리뷰 리스트 가져오는 메소드는 getPurchaseReviewList입니다.

BaseType.xsd를 켜신 후 MallID로 검색하면 <xs:complexType name="purchaseReview"> 안쪽의 MallID밑에 

<xs:element minOccurs="0" name="PurchaseReviewClassType" type="xs:string"/>

추가해주세요 포토 리뷰를 가져오는 파라미터 값을 보내기 위해서 입니다.

<xs:element minOccurs="0" name="Content" type="xs:string"/>

이값도 필요합니다 이미지 경로를 가져오기 위해서 입니다.



<xs:complexType name="purchaseReview">

    <xs:sequence>

      <xs:element minOccurs="0" name="CreateYmdt" type="xs:dateTime"/>

      <xs:element minOccurs="0" name="MallID" type="xs:string"/>

  <xs:element minOccurs="0" name="PurchaseReviewClassType" type="xs:string"/>

      <xs:element minOccurs="0" name="ModifyYmdt" type="xs:dateTime"/>

      <xs:element minOccurs="0" name="ProductID" type="xs:string"/>

      <xs:element minOccurs="0" name="ProductName" type="xs:string"/>

      <xs:element minOccurs="0" name="ProductOption" type="xs:string"/>

      <xs:element minOccurs="0" name="ProductOrderID" type="xs:string"/>

      <xs:element minOccurs="0" name="PurchaseReviewId" type="xs:long"/>

      <xs:element minOccurs="0" name="PurchaseReviewScore" type="xs:int"/>

      <xs:element minOccurs="0" name="Title" type="xs:string"/>

      <xs:element minOccurs="0" name="WriterId" type="xs:string"/>

  <xs:element minOccurs="0" name="Content" type="xs:string"/>

      <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax"/>

    </xs:sequence>

  </xs:complexType>



MallServiceMessage.xsd파일을 여시고 getPurchaseReviewListRequest로 검색후 MallID써진 곳 밑에
<xs:element minOccurs="0" name="PurchaseReviewClassType" type="xs:string" />
추가해주세요



<xs:complexType name="getPurchaseReviewListRequest">

<xs:complexContent>

<xs:extension base="bs:ListRequestType">

<xs:sequence>

<xs:element minOccurs="0" name="MallID" type="xs:string" />

<xs:element minOccurs="0" name="PurchaseReviewClassType" type="xs:string" />

</xs:sequence>

</xs:extension>

</xs:complexContent>

</xs:complexType>

이제 추가할 내용은 끝이고 wsdl를 java파일로 만들겠습니다.

인텔리제이 File -> new -> Project 화면에서 밑으로 내리면 WebServices Client가 있습니다. 버전은 Apache Axis로 변경 해주시고 Next


저장할곳 저장해줍니다.

지정하면 프로젝트가 열리고 Generate Java Code From Wsdl이 뜹니다.

Web service WSDL URL에 wsdl파일을 연결 시키면 됩니다. 그후 ok

이제 기본 파라미터 값같은게 세팅이 되었고 네이버 암호화 툴을 추가해줍니다.

네이버에서 제공한 폴더의 3.SampleCode -> java -> SimpleCryptLib(Java)_091105안의 SimpleCryptLib-1.1.0.jar, bcprov-jdk16-138.jar파일을 프로젝트 라이브러리에 넣어서 인식 시킵니다.(Add as Library)

 main 패키지 만들고 메인 클래스를 만든후

public class Naverpay {
public static void main(String[] args) throws ServiceException, RemoteException, InterruptedException {
String accessLicense = "첨에 받은 라이센스 키";
String secretKey = "첨에 받은 시크릿키";


String timeStamp;
String serviceName = "MallService41";
String operationName = "GetPurchaseReviewList";
String signature = "";
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

timeStamp = SimpleCryptLib.getTimestamp();
String data = timeStamp + serviceName + operationName;

try {
signature = SimpleCryptLib.generateSign(data, secretKey);
} catch (SignatureException e) {
//서명정보 실패
System.out.println(e.getMessage());
}


AccessCredentialsType accessCredentialsType = new AccessCredentialsType();
accessCredentialsType.setAccessLicense(accessLicense);
accessCredentialsType.setTimestamp(timeStamp);
accessCredentialsType.setSignature(signature);




GetPurchaseReviewListRequest reviewListRequest = new GetPurchaseReviewListRequest();
reviewListRequest.setAccessCredentials(accessCredentialsType);

Calendar from = Calendar.getInstance();
from.add(Calendar.DATE, -1);
int fromYear = from.get(Calendar.YEAR);
int fromMonth = from.get(Calendar.MONTH);
int fromDate = from.get(Calendar.DATE);

Calendar to = Calendar.getInstance();
int toYear = to.get(Calendar.YEAR);
int toMonth = to.get(Calendar.MONTH);
int toDate = to.get(Calendar.DATE);

from.set(fromYear, fromMonth, fromDate, 0, 0, 0);
to.set(toYear, toMonth, toDate, 0, 0, 0);

reviewListRequest.setInquiryTimeFrom(from);
reviewListRequest.setInquiryTimeTo(to);
reviewListRequest.setVersion("4.1");

reviewListRequest.setMallID("계약한 ID");
reviewListRequest.setPurchaseReviewClassType("GENERAL");

GetPurchaseReviewListResponse response = new MallServiceLocator().getMallServiceSOAP11Port().getPurchaseReviewList(reviewListRequest);

System.out.println(response.getResponseType());

//PurchaseReview[] result = response.getPurchaseReviewList();
Thread.sleep(5000);

reviewListRequest.setPurchaseReviewClassType("PREMIUM");
GetPurchaseReviewListResponse response1 = new MallServiceLocator().getMallServiceSOAP11Port().getPurchaseReviewList(reviewListRequest);

System.out.println(response1.getResponseType());

//PurchaseReview[] result1 = response1.getPurchaseReviewList();

//Arrays.asList(result).stream().forEach(r -> System.out.println(r));
}
}

샌드박스 테스트가 끝나면 프로덕션 테스트를 하고 싶다고 네이버 측에 요청하면 라이센스키와 인증키를 새로 보내줍니다.

샌드박스 테스트에서 라이센스와 인증키만 바꾸고 저 코드대로라면 11코드를 사용하니까 MallServiceLocator에서 MallServiceSOAP11Port_address에서 주소만 변경 하면 됩니다.

http://sandbox.api.naver.com/Checkout/MallService41    ->    http://ec.api.naver.com/Checkout/MallService41

그러면 실서버로 테스트 완료~!!



댓글

이 블로그의 인기 게시물

mac 맥 맥북 Brew 완전 삭제

맥북에서 Brew 초기화 Brew를 써서 h2를 쓰려고 하는데 brew install h2가 안되서 이리 저리 알아보다가 완전 삭제 후 다시 설치 하니까 되서 그 방법을 남겨놈 1. 터미널에 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)" 입력후 y랑 뭐 비번.. 2. /usr/local 폴더에서 Homebrew 폴더 삭제 rm -rf Homebrew/ 권한설정으로 잘.....삭제하고 3. 다시 설치 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" 좀 오래걸리니까 기다려야한다는걸 배움... 출처.... https://discourse.brew.sh/t/error-no-formulae-found-in-taps/8331/9

ORA-28000 계정이 잠금되었습니다 계정 잠길때

오라클 계정이 잠길때 해제방법 증상 t he account is locked 오류 발생 원인 Oracle 에서 t he account is locked  에러가 나는 원인은 ● 잘못된 패스워드로 설정횟수만큼 접속 시도시 Lock. ●  30일동안(Default) 해당 계정으로 로그인을 하지 않았을 경우 Lock. 등이 있다. 해결방법 command창에서 * 로컬일경우, sqlplus "/as sysdba"  또는  sqlplus /nolog  conn /as sysdba  * 로컬이 아닐 경우, sqlplus /nolog conn sys/password@<sid> 이름/패스워드@sid로 입력 로 접속 후 SELECT username, account_status, lock_date FROM dba_users; 으로 Lock이 된 사용자를 확인한 후 LOCKED<TIMED> 라고 되있으면, 패스워드 설정횟수 입력 오류로, 아래의 Unlock 명령만, EXPIRED & LOCKED 라고 되있으면, 패스워드 기간만료로, Unlock 후 비밀번호를 지정해줘야 한다. ALTER USER 사용자명 ACCOUNT UNLOCK; 로 Lock된 사용자를 Unl ock 시킨다 방금 말했다시피, 다시 Lock된 사용자 확인했는데,  Open되지 않고 EXPIRED되어 있다면, alter user 사용자명 identified by 바꿀패스워드;  로 패스워드를 변경하거나 또는 SQL*PLUS 를 재시작하여 Lock를 해제한 계정(사용자명/패스워드)로 로그인 하면 패스워드 변경 창이 뜬다. 추가로 패스워드 Lock 횟수 확인하는 방법은 SELECT U.USERNAME,P.PROFILE, P.RESOURCE_NAME, P.LIMIT  FROM D

메이븐으로 라이브러리 인식

 간혹 퍼블릭 jar가 아닌 파일이 있는데 그럴때 쓰면 될듯 <dependency> <groupId> SimpleCryptLib </groupId> <artifactId> SimpleCryptLib </artifactId> <version> 1.1.0 </version> <scope> system </scope> <systemPath> ${basedir}/src/main/webapp/WEB-INF/lib/SimpleCryptLib-1.1.0.jar </systemPath> </dependency> version, scope, systemPath는 꼭 작성해야 한다 groupId, artifactId, version은 암거나 해도 되는거 같음 최근(2021.05.04)스프링 부트    < dependency > < groupId > NiceID </ groupId > < artifactId > NiceID </ artifactId > < version > 1.0 </ version > < scope > system </ scope > < systemPath > ${basedir}/src/main/resources/lib/NiceID.jar </ systemPath > </ dependency > 이걸 추가해주는것도 필요할지도..?? < build > < plugins > < plugin > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-maven-plugi