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