generated from pricelees/issue-pr-template
feat: 페이먼츠 API에서 제공하는 타입 정보를 담은 Enum
This commit is contained in:
parent
af81260355
commit
e4611c76b3
@ -0,0 +1,243 @@
|
|||||||
|
package roomescape.payment.infrastructure.common
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator
|
||||||
|
import io.github.oshai.kotlinlogging.KLogger
|
||||||
|
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||||
|
import roomescape.payment.exception.PaymentErrorCode
|
||||||
|
import roomescape.payment.exception.PaymentException
|
||||||
|
|
||||||
|
private val log: KLogger = KotlinLogging.logger {}
|
||||||
|
|
||||||
|
enum class PaymentType(
|
||||||
|
private val koreanName: String
|
||||||
|
) {
|
||||||
|
NORMAL("일반결제"),
|
||||||
|
BILLING("자동결제"),
|
||||||
|
BRANDPAY("브랜드페이"),
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val CACHE: Map<String, PaymentType> = entries.associateBy { it.name }
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||||
|
fun get(code: String): PaymentType {
|
||||||
|
return CACHE[code.uppercase()] ?: run {
|
||||||
|
log.warn { "[PaymentTypes.PaymentType] 결제 타입 조회 실패: type=$code" }
|
||||||
|
throw PaymentException(PaymentErrorCode.TYPE_NOT_FOUND)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class PaymentMethod(
|
||||||
|
val koreanName: String,
|
||||||
|
) {
|
||||||
|
CARD("카드"),
|
||||||
|
EASY_PAY("간편결제"),
|
||||||
|
VIRTUAL_ACCOUNT("가상계좌"),
|
||||||
|
MOBILE_PHONE("휴대폰"),
|
||||||
|
TRANSFER("계좌이체"),
|
||||||
|
CULTURE_GIFT_CERTIFICATE("문화상품권"),
|
||||||
|
BOOK_GIFT_CERTIFICATE("도서문화상품권"),
|
||||||
|
GAME_GIFT_CERTIFICATE("게임문화상품권"),
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val CACHE: Map<String, PaymentMethod> = entries.associateBy { it.koreanName }
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||||
|
fun get(koreanName: String): PaymentMethod {
|
||||||
|
return CACHE[koreanName]
|
||||||
|
?: run {
|
||||||
|
log.warn { "[PaymentTypes.PaymentMethod] 결제 수단 조회 실패: type=$koreanName" }
|
||||||
|
throw PaymentException(PaymentErrorCode.TYPE_NOT_FOUND)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class PaymentStatus {
|
||||||
|
IN_PROGRESS,
|
||||||
|
DONE,
|
||||||
|
CANCELED,
|
||||||
|
ABORTED,
|
||||||
|
EXPIRED,
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val CACHE: Map<String, PaymentStatus> = entries.associateBy { it.name }
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||||
|
fun get(name: String): PaymentStatus {
|
||||||
|
return CACHE[name] ?: run {
|
||||||
|
log.warn { "[PaymentStatus.get] 결제 상태 조회 실패: name=$name" }
|
||||||
|
throw PaymentException(PaymentErrorCode.TYPE_NOT_FOUND)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class CardType(
|
||||||
|
private val koreanName: String
|
||||||
|
) {
|
||||||
|
CREDIT("신용"),
|
||||||
|
CHECK("체크"),
|
||||||
|
GIFT("기프트"),
|
||||||
|
UNKNOWN("미확인"),
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val CACHE: Map<String, CardType> = entries.associateBy { it.koreanName }
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||||
|
fun get(koreanName: String): CardType {
|
||||||
|
return CACHE[koreanName] ?: UNKNOWN.also {
|
||||||
|
log.warn { "[PaymentCode.CardType] 카드 타입 조회 실패: type=$koreanName" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class CardOwnerType(
|
||||||
|
private val koreanName: String
|
||||||
|
) {
|
||||||
|
PERSONAL("개인"),
|
||||||
|
CORPORATE("법인"),
|
||||||
|
UNKNOWN("미확인"),
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val CACHE: Map<String, CardOwnerType> = entries.associateBy { it.koreanName }
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||||
|
fun get(koreanName: String): CardOwnerType {
|
||||||
|
return CACHE[koreanName] ?: UNKNOWN.also {
|
||||||
|
log.warn { "[PaymentCode.CardType] 카드 소유자 타입 조회 실패: type=$koreanName" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class BankCode(
|
||||||
|
val code: String,
|
||||||
|
val koreanName: String,
|
||||||
|
) {
|
||||||
|
KYONGNAM_BANK("039", "경남"),
|
||||||
|
GWANGJU_BANK("034", "광주"),
|
||||||
|
LOCAL_NONGHYEOP("012", "단위농협"),
|
||||||
|
BUSAN_BANK("032", "부산"),
|
||||||
|
SAEMAUL("045", "새마을"),
|
||||||
|
SANLIM("064", "산림"),
|
||||||
|
SHINHAN("088", "신한"),
|
||||||
|
SHINHYEOP("048", "신협"),
|
||||||
|
CITI("027", "씨티"),
|
||||||
|
WOORI("020", "우리"),
|
||||||
|
POST("071", "우체국"),
|
||||||
|
SAVINGBANK("050", "저축"),
|
||||||
|
JEONBUK_BANK("037", "전북"),
|
||||||
|
JEJU_BANK("035", "제주"),
|
||||||
|
KAKAO_BANK("090", "카카오"),
|
||||||
|
K_BANK("089", "케이"),
|
||||||
|
TOSS_BANK("092", "토스"),
|
||||||
|
HANA("081", "하나"),
|
||||||
|
HSBC("054", "홍콩상하이"),
|
||||||
|
IBK("003", "기업"),
|
||||||
|
KOOKMIN("004", "국민"),
|
||||||
|
DAEGU("031", "대구"),
|
||||||
|
KDB_BANK("002", "산업"),
|
||||||
|
NONGHYEOP("011", "농협"),
|
||||||
|
SC("023", "SC제일"),
|
||||||
|
SUHYEOP("007", "수협");
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val CACHE: Map<String, BankCode> = entries.associateBy { it.code }
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||||
|
fun get(code: String): BankCode {
|
||||||
|
val parsedCode = if (code.length == 2) "0$code" else code
|
||||||
|
|
||||||
|
return CACHE[parsedCode] ?: run {
|
||||||
|
log.error { "[PaymentCode.BankCode] 은행 코드 조회 실패: code=$code" }
|
||||||
|
throw PaymentException(PaymentErrorCode.ORGANIZATION_CODE_NOT_FOUND)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class CardIssuerCode(
|
||||||
|
val code: String,
|
||||||
|
val koreanName: String,
|
||||||
|
) {
|
||||||
|
IBK_BC("3K", "기업 BC"),
|
||||||
|
GWANGJU_BANK("46", "광주"),
|
||||||
|
LOTTE("71", "롯데"),
|
||||||
|
KDB_BANK("30", "산업"),
|
||||||
|
BC("31", "BC"),
|
||||||
|
SAMSUNG("51", "삼성"),
|
||||||
|
SAEMAUL("38", "새마을"),
|
||||||
|
SHINHAN("41", "신한"),
|
||||||
|
SHINHYEOP("62", "신협"),
|
||||||
|
CITI("36", "씨티"),
|
||||||
|
WOORI_BC("33", "우리"),
|
||||||
|
WOORI("W1", "우리"),
|
||||||
|
POST("37", "우체국"),
|
||||||
|
SAVINGBANK("39", "저축"),
|
||||||
|
JEONBUK_BANK("35", "전북"),
|
||||||
|
JEJU_BANK("42", "제주"),
|
||||||
|
KAKAO_BANK("15", "카카오뱅크"),
|
||||||
|
K_BANK("3A", "케이뱅크"),
|
||||||
|
TOSS_BANK("24", "토스뱅크"),
|
||||||
|
HANA("21", "하나"),
|
||||||
|
HYUNDAI("61", "현대"),
|
||||||
|
KOOKMIN("11", "국민"),
|
||||||
|
NONGHYEOP("91", "농협"),
|
||||||
|
SUHYEOP("34", "수협"),
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val CACHE: Map<String, CardIssuerCode> = entries.associateBy { it.code }
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||||
|
fun get(code: String): CardIssuerCode {
|
||||||
|
return CACHE[code] ?: run {
|
||||||
|
log.error { "[PaymentCode.CardIssuerCode] 카드사 코드 조회 실패: code=$code" }
|
||||||
|
throw PaymentException(PaymentErrorCode.ORGANIZATION_CODE_NOT_FOUND)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class EasyPayCompanyCode(
|
||||||
|
val koreanName: String
|
||||||
|
) {
|
||||||
|
TOSSPAY("토스페이"),
|
||||||
|
NAVERPAY("네이버페이"),
|
||||||
|
SAMSUNGPAY("삼성페이"),
|
||||||
|
LPAY("엘페이"),
|
||||||
|
KAKAOPAY("카카오페이"),
|
||||||
|
PAYCO("페이코"),
|
||||||
|
SSG("SSG페이"),
|
||||||
|
APPLEPAY("애플페이"),
|
||||||
|
PINPAY("핀페이"),
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val CACHE: Map<String, EasyPayCompanyCode> = entries.associateBy { it.koreanName }
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||||
|
fun get(koreanName: String): EasyPayCompanyCode {
|
||||||
|
return CACHE[koreanName] ?: run {
|
||||||
|
log.error { "[PaymentCode.EasyPayCompanyCode] 간편결제사 코드 조회 실패: name=$koreanName" }
|
||||||
|
throw PaymentException(PaymentErrorCode.ORGANIZATION_CODE_NOT_FOUND)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user