최신글
hyeonga_code
[JAVA/SPRING] 결제취소(가상계좌)_포트원/아임포트 결제 적용 IamportClient<> 이해하기 본문
반응형
2024.02.14
portone에서 제공하는 github의 IamportRestTest.java
직접 실행해보면서 어떻게 돌아가는지 확인해봄
-- cancleVbankPaymentAlreadyCancelledImpUid()
---- 가상계좌를 이용한 결제 취소
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
|
public void testCancelVbankPaymentAlreadyCancelledImpUid() {
System.err.println(">>> testCancelVbankPaymentAlreadyCancelledImpUid");
client = new IamportClient(" [ REST API Key ] ", " [ Rest API Secret ] ");
String test_already_cancelled_imp_uid = "imp_540676469599";
CancelData cancel_data = new CancelData(test_already_cancelled_imp_uid, true, BigDecimal.valueOf(40)); //imp_uid를 통한 500원 부분취소
try {
IamportResponse<Payment> payment_response = client.cancelPaymentByImpUid(cancel_data);
System.err.println(payment_response.getMessage());
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) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
|
@@실행결과
1)
>>> testCancelVbankPaymentAlreadyCancelledImpUid
취소할 결제건이 존재하지 않습니다.
getMessage : 취소할 결제건이 존재하지 않습니다.
getResponse : null
===== Payment =====
2)
>>> testCancelVbankPaymentAlreadyCancelledImpUid
null
getMessage : null
getResponse : com.siot.IamportRestClient.response.Payment@4d4bb2a1
===== 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_540676469599
____getMerchantUid : nobody_1707897675810
____getName : 주문상품이름
____getPayMethod : point
____getPgProvider : kakaopay
____getPgTid : T5cc734c196d5d205938
____getReceiptUrl : https://mockup-pg-web.kakao.com/v1/confirmation/p/T5cc734c196d5d205938/4f792a2b3cae32f69a3b93682ba06fa5e42cb5a473d3cad8937c09bd29df1030
____getStartedAt : 1707897676
____getStatus : cancelled
____getVbankCode : null
____getVbankHolder : null
____getVbankIssuedAt : 0
____getAmount : 100
____getCancelAmount : 40
____getPaidAt : Wed Feb 14 17:01:28 KST 2024
=================
-- cancleVbankPaymentAlreadyCancelledMerchantUid()
---- 가상 계좌를 이용한 결제의 부분 취소
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
|
public void testPartialCancelVbankPaymentAlreadyCancelledMerchantUid() {
System.err.println(">>> testPartialCancelVbankPaymentAlreadyCancelledMerchantUid");
client = new IamportClient(" [ REST API Key ] ", " [ Rest API Secret ] ");
String test_already_cancelled_merchant_uid = "nobody_1707897662174";
CancelData cancel_data = new CancelData(test_already_cancelled_merchant_uid, false, BigDecimal.valueOf(30)); //merchant_uid를 통한 500원 부분취소
try {
IamportResponse<Payment> payment_response = client.cancelPaymentByImpUid(cancel_data);
System.err.println(payment_response.getMessage());
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) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
|
@@실행결과
1)
>>> testPartialCancelVbankPaymentAlreadyCancelledMerchantUid
취소할 결제건이 존재하지 않습니다.
getMessage : 취소할 결제건이 존재하지 않습니다.
getResponse : null
===== Payment =====
2)
>>> testPartialCancelVbankPaymentAlreadyCancelledMerchantUid
null
getMessage : null
getResponse : com.siot.IamportRestClient.response.Payment@4c4db6cf
===== 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
=================
반응형