generated from pricelees/issue-pr-template
[#56] 예약 & 결제 프로세스 및 패키지 구조 재정의 #57
@ -34,8 +34,6 @@ class PaymentService(
|
||||
return transactionExecutionUtil.withNewTransaction(isReadOnly = false) {
|
||||
val payment: PaymentEntity = paymentWriter.createPayment(
|
||||
reservationId = reservationId,
|
||||
orderId = request.orderId,
|
||||
paymentType = request.paymentType,
|
||||
paymentClientConfirmResponse = clientConfirmResponse
|
||||
)
|
||||
val detail: PaymentDetailEntity = paymentWriter.createDetail(clientConfirmResponse, payment.id)
|
||||
|
||||
@ -5,7 +5,6 @@ import com.sangdol.roomescape.payment.exception.PaymentErrorCode
|
||||
import com.sangdol.roomescape.payment.exception.PaymentException
|
||||
import com.sangdol.roomescape.payment.infrastructure.client.*
|
||||
import com.sangdol.roomescape.payment.infrastructure.common.PaymentMethod
|
||||
import com.sangdol.roomescape.payment.infrastructure.common.PaymentType
|
||||
import com.sangdol.roomescape.payment.infrastructure.persistence.*
|
||||
import io.github.oshai.kotlinlogging.KLogger
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
@ -24,15 +23,11 @@ class PaymentWriter(
|
||||
|
||||
fun createPayment(
|
||||
reservationId: Long,
|
||||
orderId: String,
|
||||
paymentType: PaymentType,
|
||||
paymentClientConfirmResponse: PaymentClientConfirmResponse
|
||||
): PaymentEntity {
|
||||
log.info { "[PaymentWriterV2.createPayment] 결제 승인 및 결제 정보 저장 시작: reservationId=${reservationId}, paymentKey=${paymentClientConfirmResponse.paymentKey}" }
|
||||
|
||||
return paymentClientConfirmResponse.toEntity(
|
||||
id = idGenerator.create(), reservationId, orderId, paymentType
|
||||
).also {
|
||||
return paymentClientConfirmResponse.toEntity(id = idGenerator.create(), reservationId = reservationId).also {
|
||||
paymentRepository.save(it)
|
||||
log.info { "[PaymentWriterV2.createPayment] 결제 승인 및 결제 정보 저장 완료: reservationId=${reservationId}, payment.id=${it.id}" }
|
||||
}
|
||||
|
||||
@ -11,6 +11,8 @@ import java.time.OffsetDateTime
|
||||
|
||||
data class PaymentClientConfirmResponse(
|
||||
val paymentKey: String,
|
||||
val orderId: String,
|
||||
val type: PaymentType,
|
||||
val status: PaymentStatus,
|
||||
val totalAmount: Int,
|
||||
val vat: Int,
|
||||
@ -26,17 +28,15 @@ data class PaymentClientConfirmResponse(
|
||||
fun PaymentClientConfirmResponse.toEntity(
|
||||
id: Long,
|
||||
reservationId: Long,
|
||||
orderId: String,
|
||||
paymentType: PaymentType
|
||||
) = PaymentEntity(
|
||||
id = id,
|
||||
reservationId = reservationId,
|
||||
paymentKey = this.paymentKey,
|
||||
orderId = orderId,
|
||||
orderId = this.orderId,
|
||||
totalAmount = this.totalAmount,
|
||||
requestedAt = this.requestedAt.toInstant(),
|
||||
approvedAt = this.approvedAt.toInstant(),
|
||||
type = paymentType,
|
||||
type = this.type,
|
||||
method = this.method,
|
||||
status = this.status,
|
||||
)
|
||||
|
||||
@ -12,7 +12,6 @@ data class PaymentConfirmRequest(
|
||||
val paymentKey: String,
|
||||
val orderId: String,
|
||||
val amount: Int,
|
||||
val paymentType: PaymentType
|
||||
)
|
||||
|
||||
data class PaymentCreateResponse(
|
||||
|
||||
@ -180,6 +180,7 @@ class DummyInitializer(
|
||||
|
||||
val clientConfirmResponse = PaymentFixture.confirmResponse(
|
||||
paymentKey = request.paymentKey,
|
||||
orderId = request.orderId,
|
||||
amount = request.amount,
|
||||
method = method,
|
||||
cardDetail = cardDetail,
|
||||
@ -189,8 +190,6 @@ class DummyInitializer(
|
||||
|
||||
val payment = paymentWriter.createPayment(
|
||||
reservationId = reservationId,
|
||||
orderId = request.orderId,
|
||||
paymentType = request.paymentType,
|
||||
paymentClientConfirmResponse = clientConfirmResponse
|
||||
)
|
||||
|
||||
|
||||
@ -241,7 +241,6 @@ object PaymentFixture {
|
||||
paymentKey = "paymentKey",
|
||||
orderId = "orderId",
|
||||
amount = 10000,
|
||||
paymentType = PaymentType.NORMAL
|
||||
)
|
||||
|
||||
val cancelRequest: PaymentCancelRequest = PaymentCancelRequest(
|
||||
@ -286,10 +285,13 @@ object PaymentFixture {
|
||||
method: PaymentMethod,
|
||||
cardDetail: CardDetail?,
|
||||
easyPayDetail: EasyPayDetail?,
|
||||
transferDetail: TransferDetail?
|
||||
transferDetail: TransferDetail?,
|
||||
orderId: String = randomString(25),
|
||||
) = PaymentClientConfirmResponse(
|
||||
paymentKey = paymentKey,
|
||||
status = PaymentStatus.DONE,
|
||||
orderId = orderId,
|
||||
type = PaymentType.NORMAL,
|
||||
totalAmount = amount,
|
||||
vat = (amount * 0.1).toInt(),
|
||||
suppliedAmount = (amount * 0.9).toInt(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user