hyeonga_code

[JAVA/SPRING] paymentsByStatus()_포트원/아임포트 결제 적용 IamportClient<> 이해하기 본문

Spring

[JAVA/SPRING] paymentsByStatus()_포트원/아임포트 결제 적용 IamportClient<> 이해하기

hyeonga 2024. 2. 15. 08:19
반응형

2024.02.14

portone에서 제공하는 github의 IamportRestTest.java

https://github.com/iamport/iamport-rest-client-java/blob/master/src/test/java/com/siot/IamportRestClient/IamportRestTest.java

 

직접 실행해보면서 어떻게 돌아가는지 확인해봄

 

-- paymentsByStatus()

---- 주어진 상태에 해당하는 결제 정보를 가지고 옵니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    public void testPaymentsByStatusAll() {
        System.err.println(">>> testPaymentsByStatusAll");
        client = new IamportClient(" [ REST API Key ] "" [ Rest API Secret ] ");
        try {
            IamportResponse<PagedDataList<Payment>> r_response = client.paymentsByStatus("ready");
            IamportResponse<PagedDataList<Payment>> p_response = client.paymentsByStatus("paid");
            IamportResponse<PagedDataList<Payment>> f_response = client.paymentsByStatus("failed");
            IamportResponse<PagedDataList<Payment>> c_response = client.paymentsByStatus("cancelled");
            IamportResponse<PagedDataList<Payment>> all_response = client.paymentsByStatus("all");
            
            System.err.println("R getMessage : " + r_response.getMessage());
            System.err.println("R getResponse : " + r_response.getResponse());
            System.err.println("++++++++++++++++");
            System.err.println("P getMessage : " + p_response.getMessage());
            System.err.println("P getResponse : " + p_response.getResponse());
            System.err.println("++++++++++++++++");
            System.err.println("F getMessage : " + f_response.getMessage());
            System.err.println("F getResponse : " + f_response.getResponse());
            System.err.println("++++++++++++++++");
            System.err.println("C getMessage : " + c_response.getMessage());
            System.err.println("C getResponse : " + c_response.getResponse());
            System.err.println("++++++++++++++++");
            System.err.println("ALL getMessage : " + all_response.getMessage());
            System.err.println("ALL getResponse : " + all_response.getResponse());
        } catch (IamportResponseException e) {
            System.err.println(e.getMessage());
 
            switch (e.getHttpStatusCode()) {
                case 401:
                    //TODO
                    break;
                case 500:
                    //TODO
                    break;
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

 

 

@@실행결과

>>> testPaymentsByStatusAll
R getMessagenull
R getResponsecom.siot.IamportRestClient.response.PagedDataList@6bf5125f
++++++++++++++++
P getMessagenull
P getResponsecom.siot.IamportRestClient.response.PagedDataList@54c55e12
++++++++++++++++
F getMessagenull
F getResponsecom.siot.IamportRestClient.response.PagedDataList@fd6fef3
++++++++++++++++
C getMessagenull
C getResponsecom.siot.IamportRestClient.response.PagedDataList@4c92fcb8
++++++++++++++++
ALL getMessagenull
ALL getResponsecom.siot.IamportRestClient.response.PagedDataList@f36689f

 

 

반응형