generated from pricelees/issue-pr-template
[#35] 결제 스키마 재정의 & 예약 조회 페이지 개선 #36
@ -0,0 +1,54 @@
|
|||||||
|
package roomescape.payment.infrastructure.client.v2
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
import com.fasterxml.jackson.core.JsonParser
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext
|
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
||||||
|
import roomescape.payment.infrastructure.common.PaymentStatus
|
||||||
|
import java.time.OffsetDateTime
|
||||||
|
|
||||||
|
data class PaymentCancelRequestV2(
|
||||||
|
val paymentKey: String,
|
||||||
|
val amount: Long,
|
||||||
|
val cancelReason: String
|
||||||
|
)
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
data class PaymentCancelResponseV2(
|
||||||
|
val status: PaymentStatus,
|
||||||
|
@JsonDeserialize(using = CancelDetailDeserializer::class)
|
||||||
|
val cancels: CancelDetail,
|
||||||
|
)
|
||||||
|
|
||||||
|
data class CancelDetail(
|
||||||
|
val cancelAmount: Int,
|
||||||
|
val cardDiscountAmount: Int,
|
||||||
|
val transferDiscountAmount: Int,
|
||||||
|
val easyPayDiscountAmount: Int,
|
||||||
|
val canceledAt: OffsetDateTime,
|
||||||
|
)
|
||||||
|
|
||||||
|
class CancelDetailDeserializer : JsonDeserializer<CancelDetail>() {
|
||||||
|
override fun deserialize(
|
||||||
|
p: JsonParser,
|
||||||
|
ctxt: DeserializationContext
|
||||||
|
): CancelDetail? {
|
||||||
|
val node: JsonNode = p.codec.readTree(p) ?: return null
|
||||||
|
|
||||||
|
val targetNode = when {
|
||||||
|
node.isArray && !node.isEmpty -> node[0]
|
||||||
|
node.isObject -> node
|
||||||
|
else -> return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return CancelDetail(
|
||||||
|
cancelAmount = targetNode.get("cancelAmount").asInt(),
|
||||||
|
cardDiscountAmount = targetNode.get("cardDiscountAmount").asInt(),
|
||||||
|
transferDiscountAmount = targetNode.get("transferDiscountAmount").asInt(),
|
||||||
|
easyPayDiscountAmount = targetNode.get("easyPayDiscountAmount").asInt(),
|
||||||
|
canceledAt = OffsetDateTime.parse(targetNode.get("canceledAt").asText())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
package roomescape.payment.infrastructure.client.v2
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
import roomescape.payment.infrastructure.common.*
|
||||||
|
import java.time.OffsetDateTime
|
||||||
|
|
||||||
|
data class PaymentConfirmRequest(
|
||||||
|
val paymentKey: String,
|
||||||
|
val orderId: String,
|
||||||
|
val amount: Long,
|
||||||
|
val paymentType: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
data class PaymentConfirmResponse(
|
||||||
|
val paymentKey: String,
|
||||||
|
val orderId: String,
|
||||||
|
val totalAmount: Int,
|
||||||
|
val method: PaymentMethod,
|
||||||
|
val card: CardDetail?,
|
||||||
|
val easyPay: EasyPayDetail?,
|
||||||
|
val transfer: TransferDetail?,
|
||||||
|
val requestedAt: OffsetDateTime,
|
||||||
|
val approvedAt: OffsetDateTime,
|
||||||
|
)
|
||||||
|
|
||||||
|
data class CardDetail(
|
||||||
|
val issuerCode: CardIssuerCode,
|
||||||
|
val number: String,
|
||||||
|
val amount: Int,
|
||||||
|
val cardType: CardType,
|
||||||
|
val ownerType: CardOwnerType,
|
||||||
|
val isInterestFree: Boolean,
|
||||||
|
val approveNo: String,
|
||||||
|
val installmentPlanMonths: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
data class EasyPayDetail(
|
||||||
|
val provider: EasyPayCompanyCode,
|
||||||
|
val amount: Int,
|
||||||
|
val discountAmount: Int,
|
||||||
|
)
|
||||||
|
|
||||||
|
data class TransferDetail(
|
||||||
|
val bankCode: BankCode,
|
||||||
|
val settlementStatus: String,
|
||||||
|
)
|
||||||
Loading…
x
Reference in New Issue
Block a user