diff --git a/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/application/PaymentFacade.kt b/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/application/PaymentFacade.kt index 0f66511..d7df6c5 100644 --- a/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/application/PaymentFacade.kt +++ b/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/application/PaymentFacade.kt @@ -3,8 +3,6 @@ package com.hanghae.commerce.payment.application import com.hanghae.commerce.order.domain.OrderReader import com.hanghae.commerce.payment.domain.PaymentService import com.hanghae.commerce.payment.domain.command.PaymentCommand -import com.hanghae.commerce.payment.presentation.dto.PaymentRequest -import com.hanghae.commerce.payment.presentation.dto.PaymentResponse import org.springframework.stereotype.Component @Component @@ -12,14 +10,10 @@ class PaymentFacade( private val paymentService: PaymentService, private val orderReader: OrderReader, ) { - fun payment(paymentRequest: PaymentRequest): PaymentResponse { - return PaymentResponse( - paymentService.payment( - PaymentCommand( - order = orderReader.read(paymentRequest.orderId), - bankAccount = paymentRequest.bankAccount, - ), - ), + fun payment(command: PaymentCommand): String { + return paymentService.payment( + command, + orderReader.read(command.orderId), ) } } diff --git a/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/domain/PaymentService.kt b/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/domain/PaymentService.kt index ae7ade8..34211cc 100644 --- a/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/domain/PaymentService.kt +++ b/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/domain/PaymentService.kt @@ -18,8 +18,8 @@ class PaymentService( @CircuitBreaker(name = "payment", fallbackMethod = "circuitBreakerFallback") fun payment( command: PaymentCommand, + order: Order, ): String { - val order = command.order if (!order.isPaymentWait()) { throw IllegalStateException("이미 결제가 완료된 주문입니다.") } diff --git a/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/domain/command/PaymentCommand.kt b/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/domain/command/PaymentCommand.kt index cabda73..a41622c 100644 --- a/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/domain/command/PaymentCommand.kt +++ b/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/domain/command/PaymentCommand.kt @@ -1,9 +1,8 @@ package com.hanghae.commerce.payment.domain.command -import com.hanghae.commerce.order.domain.Order import com.hanghae.commerce.payment.domain.BankAccount data class PaymentCommand( - val order: Order, + val orderId: String, val bankAccount: BankAccount, ) diff --git a/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/presentation/PaymentController.kt b/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/presentation/PaymentController.kt index 5d1252b..8c50a3b 100644 --- a/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/presentation/PaymentController.kt +++ b/commerce-api/src/main/kotlin/com/hanghae/commerce/payment/presentation/PaymentController.kt @@ -1,6 +1,7 @@ package com.hanghae.commerce.payment.presentation import com.hanghae.commerce.payment.application.PaymentFacade +import com.hanghae.commerce.payment.domain.command.PaymentCommand import com.hanghae.commerce.payment.presentation.dto.PaymentRequest import com.hanghae.commerce.payment.presentation.dto.PaymentResponse import jakarta.validation.Valid @@ -22,7 +23,14 @@ class PaymentController( paymentRequest: PaymentRequest, ): ResponseEntity { return ResponseEntity.ok( - paymentFacade.payment(paymentRequest), + PaymentResponse( + paymentFacade.payment( + PaymentCommand( + paymentRequest.orderId, + paymentRequest.bankAccount, + ), + ), + ), ) } } diff --git a/commerce-api/src/test/kotlin/com/hanghae/commerce/claim/domain/OrderCancelServiceTest.kt b/commerce-api/src/test/kotlin/com/hanghae/commerce/claim/domain/OrderCancelServiceTest.kt index 4d6ea96..a89e3d0 100644 --- a/commerce-api/src/test/kotlin/com/hanghae/commerce/claim/domain/OrderCancelServiceTest.kt +++ b/commerce-api/src/test/kotlin/com/hanghae/commerce/claim/domain/OrderCancelServiceTest.kt @@ -30,7 +30,7 @@ class OrderCancelServiceTest { private lateinit var sut: OrderCancelService @Nested - @DisplayName("When: 주문 취소가 성공하면, ") + @DisplayName("When: 주문 취소가 성공하면") inner class Context1 { val testOrderId = "testOrderId" @@ -64,7 +64,7 @@ class OrderCancelServiceTest { } @Test - @DisplayName("Then: 저장소에 저장한다.") + @DisplayName("Then: 변경사항을 저장소에 저장한다.") fun tc3() { // when sut.cancel(command, order) diff --git a/commerce-api/src/test/kotlin/com/hanghae/commerce/claim/domain/OrderCancelValidatorTest.kt b/commerce-api/src/test/kotlin/com/hanghae/commerce/claim/domain/OrderCancelValidatorTest.kt index 30b1a89..138da4a 100644 --- a/commerce-api/src/test/kotlin/com/hanghae/commerce/claim/domain/OrderCancelValidatorTest.kt +++ b/commerce-api/src/test/kotlin/com/hanghae/commerce/claim/domain/OrderCancelValidatorTest.kt @@ -22,7 +22,7 @@ class OrderCancelValidatorTest { private lateinit var sut: OrderCancelValidator @Nested - @DisplayName("When: 환불시 환불 전용 계좌를 입력했다면,") + @DisplayName("When: 환불시 환불 전용 계좌를 입력했을 때") inner class Context1 { @Test @DisplayName("Then: 계좌의 유효성을 검증한다.") diff --git a/commerce-api/src/test/kotlin/com/hanghae/commerce/claim/presentation/ClaimControllerTest.kt b/commerce-api/src/test/kotlin/com/hanghae/commerce/claim/presentation/ClaimControllerTest.kt index 75186d6..3d2f06a 100644 --- a/commerce-api/src/test/kotlin/com/hanghae/commerce/claim/presentation/ClaimControllerTest.kt +++ b/commerce-api/src/test/kotlin/com/hanghae/commerce/claim/presentation/ClaimControllerTest.kt @@ -51,7 +51,7 @@ class ClaimControllerTest { val itemId = "testItemId" val orderId = "testOrderId" val item = persistItem(itemId, "상품1", 10000, 10, "1") - val order = persistOrder(userId, orderId, item) + persistOrder(userId, orderId, item) // when val request = OrderCancelRequest( diff --git a/commerce-api/src/test/kotlin/com/hanghae/commerce/payment/domain/PaymentServiceTest.kt b/commerce-api/src/test/kotlin/com/hanghae/commerce/payment/domain/PaymentServiceTest.kt index e9fdaf0..1f17335 100644 --- a/commerce-api/src/test/kotlin/com/hanghae/commerce/payment/domain/PaymentServiceTest.kt +++ b/commerce-api/src/test/kotlin/com/hanghae/commerce/payment/domain/PaymentServiceTest.kt @@ -76,14 +76,15 @@ class PaymentServiceTest { private fun executePayment(alreadyPayedOrder: Order): String { return sut.payment( - PaymentCommand( - order = alreadyPayedOrder, + command = PaymentCommand( + orderId = alreadyPayedOrder.id, bankAccount = BankAccount( bankName = "국민은행", accountNumber = "1234567890", accountHolder = "홍길동", ), ), + order = alreadyPayedOrder, ) }