Skip to content

Commit

Permalink
[JT-80] 결제 내역 조회 API 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
hongdosan authored Sep 27, 2023
2 parents f418e5c + 4b627f4 commit cca735a
Show file tree
Hide file tree
Showing 6 changed files with 323 additions and 10 deletions.
30 changes: 30 additions & 0 deletions module-application/app-api/src/docs/asciidoc/payment.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
== 결제(Payment)

결제에 대한 검증/등록/조회/취소 기능을 제공합니다.

=== 결제 검증 및 생성
Expand All @@ -17,3 +18,32 @@ include::{snippets}/payments/validation/http-request.adoc[]
==== 응답

include::{snippets}/payments/validation/http-response.adoc[]

=== 결제 취소

1) 결제 금액(IamportClient에서 제공)과 취소될 금액(checksum)를 비교해 검증합니다.
2) 검증 후 결제 취소합니다.

[discrete]
==== 요청

include::{snippets}/payments/cancel/http-request.adoc[]

[discrete]
==== 응답

include::{snippets}/payments/cancel/http-response.adoc[]

=== 결제 내역 조회

1) 데이터베이스에 저장된 결제 내역을 조회합니다.

[discrete]
==== 요청

include::{snippets}/payments/search/http-request.adoc[]

[discrete]
==== 응답

include::{snippets}/payments/search/http-response.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ <h4 id="_상태코드httpstatus"><a class="link" href="#_상태코드httpstatus"
<div id="footer">
<div id="footer-text">
Version 0.0.1-SNAPSHOT<br>
Last updated 2023-09-25 16:39:36 +0900
Last updated 2023-09-26 12:44:07 +0900
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/highlight.min.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,100 @@ <h4 id="_응답" class="discrete">응답</h4>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_결제_취소">결제 취소</h3>
<div class="literalblock">
<div class="content">
<pre>1) 결제 금액(IamportClient에서 제공)과 취소될 금액(checksum)를 비교해 검증합니다.
2) 검증 후 결제 취소합니다.</pre>
</div>
</div>
<h4 id="_요청_2" class="discrete">요청</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight nowrap"><code class="language-http" data-lang="http">POST /payments/cancel HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 137
Host: localhost:8080

{
"impUid" : "impUid123",
"merchantUid" : "merchant123",
"reason" : "reason",
"checksum" : 1000,
"refundHolder" : "홍도산"
}</code></pre>
</div>
</div>
<h4 id="_응답_2" class="discrete">응답</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight nowrap"><code class="language-http" data-lang="http">HTTP/1.1 500 Internal Server Error
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Length: 22

{
"message" : null
}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_결제_내역_조회">결제 내역 조회</h3>
<div class="literalblock">
<div class="content">
<pre>1) 데이터베이스에 저장된 결제 내역을 조회합니다.</pre>
</div>
</div>
<h4 id="_요청_3" class="discrete">요청</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight nowrap"><code class="language-http" data-lang="http">POST /payments/search HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 43
Host: localhost:8080

{
"merchantsUid" : [ "empty merchant" ]
}</code></pre>
</div>
</div>
<h4 id="_응답_3" class="discrete">응답</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight nowrap"><code class="language-http" data-lang="http">HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Length: 3

[ ]</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="footer">
<div id="footer-text">
Version 0.0.1-SNAPSHOT<br>
Last updated 2023-09-25 16:39:36 +0900
Last updated 2023-09-27 15:45:23 +0900
</div>
</div>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
import shop.jtoon.entity.Member;
import shop.jtoon.entity.PaymentInfo;
import shop.jtoon.payment.request.CancelReq;
import shop.jtoon.payment.request.ConditionReq;
import shop.jtoon.payment.request.PaymentReq;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class PaymentFactory {

Expand Down Expand Up @@ -56,4 +59,22 @@ public static CancelReq createCancelReq(PaymentReq paymentReq) {
.refundHolder(paymentReq.buyerEmail())
.build();
}

public static CancelReq createCancelReq(String impUid, String merchantUid, String name) {
return CancelReq.builder()
.impUid(impUid)
.merchantUid(merchantUid)
.reason("reason")
.checksum(CookieItem.COOKIE_ONE.getAmount())
.refundHolder(name)
.build();
}

public static ConditionReq createConditionReq(String... merchantUid) {
List<String> merchantsUid = new ArrayList<>(List.of(merchantUid));

return ConditionReq.builder()
.merchantsUid(merchantsUid)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package shop.jtoon.factory;

import org.springframework.restdocs.payload.RequestFieldsSnippet;
import org.springframework.restdocs.payload.ResponseFieldsSnippet;

import static org.springframework.restdocs.payload.JsonFieldType.NUMBER;
import static org.springframework.restdocs.payload.JsonFieldType.STRING;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
import static org.springframework.restdocs.payload.JsonFieldType.*;
import static org.springframework.restdocs.payload.PayloadDocumentation.*;

public class PaymentSnippetFactory {
public static final RequestFieldsSnippet PAYMENT_REQUEST = requestFields(
Expand All @@ -18,4 +17,23 @@ public class PaymentSnippetFactory {
fieldWithPath("buyerName").type(STRING).description("구매자 이름"),
fieldWithPath("buyerPhone").type(STRING).description("구매자 전화번호")
);

public static final RequestFieldsSnippet CANCEL_REQUEST = requestFields(
fieldWithPath("impUid").type(STRING).description("포트원 결제 고유번호"),
fieldWithPath("merchantUid").type(STRING).description("가맹점 주문번호"),
fieldWithPath("reason").type(STRING).description("환불 사유"),
fieldWithPath("checksum").type(NUMBER).description("환불 가능 금액"),
fieldWithPath("refundHolder").type(STRING).description("환불 수령자")
);

public static final RequestFieldsSnippet CONDITION_REQUEST = requestFields(
fieldWithPath("merchantsUid").type(ARRAY).description("가맹점 주문번호 리스트")
);

public static final ResponseFieldsSnippet CONDITION_RESPONSE = responseFields(
fieldWithPath("[].itemName").type(STRING).description("상품명"),
fieldWithPath("[].itemCount").type(NUMBER).description("상품 수량"),
fieldWithPath("[].amount").type(NUMBER).description("결제 금액"),
fieldWithPath("[].createdAt").type(STRING).description("결제 일시")
);
}
Loading

0 comments on commit cca735a

Please sign in to comment.