-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 결제 시크릿 프로퍼티 추가 * chore: openfeign 의존성 추가 * chore: openfeign 세팅 * feat: 결제 승인 클라이언트 임시 구현 * chore: 환경변수 이름 수정 * feat: 토스페이먼츠 헤더 설정 추가 * feat: 주문 완료하기 API 추가 * refactor: feign 패키지 아래로 이동 * feat: feign 로그 설정 * style: 개행 제거 * fix: mysql 예약어 order로 인해 테이블 생성되지 않는 문제 해결 * feat: 시간 관련 포매팅 설정 * feat: ZonedDateTime으로 변경 * refactor: COMPLETED로 변경 * feat: 주문 완료하기 임시 구현 * fix: orders 테이블명으로 인한 불일치 수정 * docs: 투두 주석 추가
- Loading branch information
Showing
15 changed files
with
228 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
public enum OrderStatus { | ||
PENDING, | ||
COMPLETE, | ||
COMPLETED, | ||
CANCELED, | ||
; | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/gdschongik/gdsc/domain/order/dto/request/OrderCompleteRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.gdschongik.gdsc.domain.order.dto.request; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Positive; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public record OrderCompleteRequest( | ||
@NotBlank String paymentKey, @NotBlank @Size(min = 21, max = 21) String orderNanoId, @Positive Long amount) {} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/gdschongik/gdsc/global/config/FeignConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.gdschongik.gdsc.global.config; | ||
|
||
import feign.Logger; | ||
import org.springframework.cloud.openfeign.EnableFeignClients; | ||
import org.springframework.cloud.openfeign.FeignFormatterRegistrar; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar; | ||
|
||
@Configuration | ||
@EnableFeignClients("com.gdschongik.gdsc.infra") | ||
public class FeignConfig { | ||
|
||
@Bean | ||
Logger.Level feignLoggerLevel() { | ||
return Logger.Level.FULL; | ||
} | ||
|
||
@Bean | ||
public FeignFormatterRegistrar dateTimeFormatterRegistrar() { | ||
return registry -> { | ||
var registrar = new DateTimeFormatterRegistrar(); | ||
registrar.setUseIsoFormat(true); | ||
registrar.registerFormatters(registry); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/com/gdschongik/gdsc/global/property/PaymentProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.gdschongik.gdsc.global.property; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@ConfigurationProperties(prefix = "toss") | ||
public class PaymentProperty { | ||
private final String secretKey; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/gdschongik/gdsc/infra/feign/payment/client/PaymentClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.gdschongik.gdsc.infra.feign.payment.client; | ||
|
||
import com.gdschongik.gdsc.infra.feign.payment.config.BasicAuthConfig; | ||
import com.gdschongik.gdsc.infra.feign.payment.dto.request.PaymentConfirmRequest; | ||
import com.gdschongik.gdsc.infra.feign.payment.dto.response.PaymentResponse; | ||
import jakarta.validation.Valid; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
|
||
@FeignClient(name = "paymentClient", url = "https://api.tosspayments.com", configuration = BasicAuthConfig.class) | ||
public interface PaymentClient { | ||
|
||
@PostMapping("/v1/payments/confirm") | ||
PaymentResponse confirm(@Valid @RequestBody PaymentConfirmRequest request); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/gdschongik/gdsc/infra/feign/payment/config/BasicAuthConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.gdschongik.gdsc.infra.feign.payment.config; | ||
|
||
import com.gdschongik.gdsc.global.property.PaymentProperty; | ||
import feign.auth.BasicAuthRequestInterceptor; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
@RequiredArgsConstructor | ||
public class BasicAuthConfig { | ||
|
||
private final PaymentProperty paymentProperty; | ||
|
||
@Bean | ||
public BasicAuthRequestInterceptor basicAuthRequestInterceptor() { | ||
return new BasicAuthRequestInterceptor(paymentProperty.getSecretKey(), ""); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/gdschongik/gdsc/infra/feign/payment/dto/request/PaymentConfirmRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.gdschongik.gdsc.infra.feign.payment.dto.request; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Positive; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public record PaymentConfirmRequest( | ||
@NotBlank String paymentKey, @NotBlank @Size(min = 21, max = 21) String orderId, @Positive Long amount) {} |
100 changes: 100 additions & 0 deletions
100
src/main/java/com/gdschongik/gdsc/infra/feign/payment/dto/response/PaymentResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package com.gdschongik.gdsc.infra.feign.payment.dto.response; | ||
|
||
import jakarta.annotation.Nullable; | ||
import java.time.ZonedDateTime; | ||
import java.util.List; | ||
|
||
public record PaymentResponse( | ||
String version, | ||
String paymentKey, | ||
String type, | ||
String orderId, | ||
String orderName, | ||
String mId, | ||
String currency, | ||
String method, | ||
Long totalAmount, | ||
Long balanceAmount, | ||
String status, | ||
ZonedDateTime requestedAt, | ||
ZonedDateTime approvedAt, | ||
Boolean useEscrow, | ||
@Nullable String lastTransactionKey, | ||
Long suppliedAmount, | ||
Long vat, | ||
Boolean cultureExpense, | ||
Long taxFreeAmount, | ||
Long taxExemtionAmount, | ||
@Nullable List<PaymentCancelDto> cancels, | ||
Boolean isPartialCancelable, | ||
@Nullable CardDto card, | ||
@Nullable TransferDto transfer, | ||
@Nullable ReceiptDto receipt, | ||
@Nullable CheckoutDto checkout, | ||
@Nullable EasyPayDto easyPay, | ||
String country, | ||
@Nullable FailureDto failure, | ||
@Nullable CashReceiptDto cashReceipt, | ||
@Nullable List<CashReceiptsDto> cashReceipts) { | ||
// TODO: enum 관련 매핑 여부 검토 | ||
public record PaymentCancelDto( | ||
Long cancelAmount, | ||
String cancelReason, | ||
Long taxFreeAmount, | ||
Long refundableAmount, | ||
Long easyPayDiscountAmount, | ||
ZonedDateTime canceledAt, | ||
String transactionKey, | ||
@Nullable String receiptKey, | ||
String cancelStatus, | ||
@Nullable String cancelRequestId) {} | ||
|
||
public record CardDto( | ||
Long amount, | ||
String issuerCode, | ||
@Nullable String acquirerCode, | ||
String number, | ||
Integer installmentPlanMonths, | ||
String approveNo, | ||
Boolean useCardPoint, | ||
String cardType, | ||
String ownerType, | ||
String acquireStatus, | ||
Boolean isInterestFree, | ||
@Nullable String interestPayer) {} | ||
|
||
public record TransferDto(String bankCode, String settlementStatus) {} | ||
|
||
public record ReceiptDto(String url) {} | ||
|
||
public record CheckoutDto(String url) {} | ||
|
||
public record EasyPayDto(String provider, Long amount, Long discountAmount) {} | ||
|
||
public record FailureDto(String code, String message) {} | ||
|
||
public record CashReceiptDto( | ||
String type, | ||
String receiptKey, | ||
String issueNumber, | ||
String receiptUrl, | ||
Long amount, | ||
Long taxFreeAmount, | ||
Long taxExemptionAmount) {} | ||
|
||
public record CashReceiptsDto( | ||
String receiptKey, | ||
String orderId, | ||
String orderName, | ||
String type, | ||
String issueNumber, | ||
String receiptUrl, | ||
String businessNumber, | ||
String transactionType, | ||
Integer amount, | ||
Integer taxFreeAmount, | ||
String issueStatus, | ||
Object failure, | ||
String customerIdentityNumber, | ||
ZonedDateTime requestedAt) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
toss: | ||
secret-key: ${PAYMENT_TOSS_SECRET_KEY:} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters