generated from pricelees/issue-pr-template
56 lines
1.7 KiB
Kotlin
56 lines
1.7 KiB
Kotlin
package roomescape.payment.web
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
|
import roomescape.payment.infrastructure.client.PaymentCancelResponseDeserializer
|
|
import roomescape.payment.infrastructure.persistence.PaymentEntity
|
|
import roomescape.reservation.web.ReservationResponse
|
|
import roomescape.reservation.web.toCreateResponse
|
|
import java.time.OffsetDateTime
|
|
|
|
data class PaymentApproveRequest(
|
|
val paymentKey: String,
|
|
val orderId: String,
|
|
val amount: Long,
|
|
val paymentType: String
|
|
)
|
|
|
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
data class PaymentApproveResponse(
|
|
val paymentKey: String,
|
|
val orderId: String,
|
|
val approvedAt: OffsetDateTime,
|
|
val totalAmount: Long
|
|
)
|
|
|
|
data class PaymentCancelRequest(
|
|
val paymentKey: String,
|
|
val amount: Long,
|
|
val cancelReason: String
|
|
)
|
|
|
|
@JsonDeserialize(using = PaymentCancelResponseDeserializer::class)
|
|
data class PaymentCancelResponse(
|
|
val cancelStatus: String,
|
|
val cancelReason: String,
|
|
val cancelAmount: Long,
|
|
val canceledAt: OffsetDateTime
|
|
)
|
|
|
|
data class ReservationPaymentResponse(
|
|
val id: Long,
|
|
val orderId: String,
|
|
val paymentKey: String,
|
|
val totalAmount: Long,
|
|
val reservation: ReservationResponse,
|
|
val approvedAt: OffsetDateTime
|
|
)
|
|
|
|
fun PaymentEntity.toReservationPaymentResponse(): ReservationPaymentResponse = ReservationPaymentResponse(
|
|
id = this.id!!,
|
|
orderId = this.orderId,
|
|
paymentKey = this.paymentKey,
|
|
totalAmount = this.totalAmount,
|
|
reservation = this.reservation.toCreateResponse(),
|
|
approvedAt = this.approvedAt
|
|
) |