최신글
hyeonga_code
[JAVA/SPRING] paymentByImpUid() / paymentBalanceByImpUid()_포트원/아임포트 결제 적용 IamportClient<> 이해하기 본문
Spring
[JAVA/SPRING] paymentByImpUid() / paymentBalanceByImpUid()_포트원/아임포트 결제 적용 IamportClient<> 이해하기
hyeonga 2024. 2. 15. 08:09반응형
2024.02.14
portone에서 제공하는 github의 IamportRestTest.java
직접 실행해보면서 어떻게 돌아가는지 확인해봄
-- paymentBalanceByImpUid()
---- imp_uid 결제건의 금액 상세 정보를 가져오는 메소드
---- 결제 금액 상세 정보를 받아와 해당 정보가 null인지 아닌지 확인할 수 있는데 현재는 PAYCO, KCP만 지원하는듯 하다.
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
|
public void testPaymentBalanceByImpUid() {
System.err.println(">>> testPaymentBalanceByImpUid");
client = new IamportClient("[ REST API Key ]", " [ Rest API Secret ] ");
String test_imp_uid = "imp_011115679124";
try {
IamportResponse<PaymentBalance> payment_response = client.paymentBalanceByImpUid(test_imp_uid);
System.err.println("getMessage : " + payment_response.getMessage());
System.err.println("getResponse : " + payment_response.getResponse());
PaymentBalance result = payment_response.getResponse();
System.err.println("___getAmount : " + result.getAmount());
System.err.println("___getCashReceipt : " + result.getCashReceipt());
System.err.println("___getDiscount : " + result.getDiscount());
System.err.println("___getHistories : " + result.getHistories());
System.err.println("___getPrimary : " + result.getPrimary());
System.err.println("___getSecondary : " + result.getSecondary());
} 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();
}
}
|
@@실행결과
>>> testPaymentBalanceByImpUid
(현재는 PAYCO, KCP만 지원됩니다) 결제건에 대한 금액상세정보가 확인되지 않습니다.
결제 상태가 paid 또는 cancelled가 아닌 경우 확인되지 않습니다.
-- paymentByImpUid()
---- 결제건의 상세 정보를 가져오는 메소드
---- 취소된 경우에도 결제정보를 받아오는지 확인
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
41
42
43
44
45
46
47
48
49
50
51 |
public void testPaymentByImpUid() {
System.err.println(">>> testPaymentByImpUid");
client = new IamportClient(" [ REST API Key ] ", " [ Rest API Secret ] ");
String test_imp_uid = "imp_448280090638";
try {
IamportResponse<Payment> payment_response = client.paymentByImpUid(test_imp_uid);
System.err.println("getMessage : " + payment_response.getMessage());
System.err.println("getResponse : " + payment_response.getResponse());
setPayment(payment_response.getResponse());
} catch (IamportResponseException e) {
System.err.println(e.getMessage());
switch (e.getHttpStatusCode()) {
case 401:
//TODO
break;
case 500:
//TODO
break;
}
} catch (IOException e) {
e.printStackTrace();
}
String test_imp_uid_cancelled = "imp_138841716839";
try {
IamportResponse<Payment> cancelled_response = client.paymentByImpUid(test_imp_uid_cancelled);
Payment cancelled = cancelled_response.getResponse();
PaymentCancelDetail[] cancelDetail = cancelled.getCancelHistory();
System.err.println("getMessage : " + cancelled_response.getMessage());
System.err.println("getResponse : " + cancelled_response.getResponse());
setPayment(cancelled_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();
}
} |
@@실행결과
1)
>>> testPaymentByImpUid
존재하지 않는 결제정보입니다.
존재하지 않는 결제정보입니다.
2)
>>> testPaymentByImpUid
getMessage : null
getResponse : com.siot.IamportRestClient.response.Payment@5ecfe258
===== Payment =====
____getApplyNum :
____getBankCode : null
____getBankName : null
____getBuyerAddr : 주소
____getBuyerEmail : email@email.com
____getBuyerName : 이름
____getBuyerPostcode : 우편번호
____getBuyerTel : 전화번호
____getCancelReason : null
____getCardCode : null
____getCardName : null
____getCardNumber : null
____getCardQuota : 0
____getCardType : 0
____getChannel : pc
____getCurrency : KRW
____getCustomData : null
____getCustomerUid : null
____getCustomerUidUsage : null
____getEmbPgProvider : null
____getFailReason : null
____getImpUid : imp_688863851303
____getMerchantUid : nobody_1707901863097
____getName : 주문상품이름
____getPayMethod : point
____getPgProvider : kakaopay
____getPgTid : T5cc83a71c025b0fec7f
____getReceiptUrl : https://mockup-pg-web.kakao.com/v1/confirmation/p/T5cc83a71c025b0fec7f/fb33ec520cf52a3d0b07a007fd4dc4e486231c6f3579047b54b638b533e173a7
____getStartedAt : 1707901863
____getStatus : paid
____getVbankCode : null
____getVbankHolder : null
____getVbankIssuedAt : 0
____getAmount : 100
____getCancelAmount : 0
____getPaidAt : Wed Feb 14 18:11:12 KST 2024
=================
## 취소된 결제건 정보 조회
getMessage : null
getResponse : com.siot.IamportRestClient.response.Payment@3520d42c
===== Payment =====
____getApplyNum :
____getBankCode : null
____getBankName : null
____getBuyerAddr : 주소
____getBuyerEmail : email@email.com
____getBuyerName : 이름
____getBuyerPostcode : 우편번호
____getBuyerTel : 전화번호
____getCancelReason : 취소요청api
____getCardCode : null
____getCardName : null
____getCardNumber : null
____getCardQuota : 0
____getCardType : 0
____getChannel : pc
____getCurrency : KRW
____getCustomData : null
____getCustomerUid : null
____getCustomerUidUsage : null
____getEmbPgProvider : null
____getFailReason : null
____getImpUid : imp_980662878590
____getMerchantUid : nobody_1707897662174
____getName : 주문상품이름
____getPayMethod : point
____getPgProvider : kakaopay
____getPgTid : T5cc733e196d5d205937
____getReceiptUrl : https://mockup-pg-web.kakao.com/v1/confirmation/p/T5cc733e196d5d205937/f89bf5079c7de4405b4d88a0c972c757aff224a9002f13c478879cd02b1b6197
____getStartedAt : 1707897662
____getStatus : cancelled
____getVbankCode : null
____getVbankHolder : null
____getVbankIssuedAt : 0
____getAmount : 100
____getCancelAmount : 30
____getPaidAt : Wed Feb 14 17:01:14 KST 2024
=================
반응형
'Spring' 카테고리의 다른 글
[JAVA/SPRING] 결제취소(전체)canclePayment()_포트원/아임포트 결제 적용 IamportClient<> 이해하기 (0) | 2024.02.15 |
---|---|
[JAVA/SPRING] paymentsByStatus()_포트원/아임포트 결제 적용 IamportClient<> 이해하기 (0) | 2024.02.15 |
[JAVA/SPRING] GetToken()_포트원/아임포트 결제 적용 IamportClient<> 이해하기 (0) | 2024.02.15 |
[JAVA/SPRING] 포트원/아임포트 결제 적용 IamportResponse<Payment> (0) | 2024.02.15 |
@PostConstruct 어노테이션 (0) | 2024.02.15 |