From e4611c76b3e4ff32abb1a9dbe5f545c025fdea2b Mon Sep 17 00:00:00 2001 From: pricelees Date: Fri, 15 Aug 2025 18:37:03 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=8E=98=EC=9D=B4=EB=A8=BC=EC=B8=A0=20?= =?UTF-8?q?API=EC=97=90=EC=84=9C=20=EC=A0=9C=EA=B3=B5=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EB=8B=B4?= =?UTF-8?q?=EC=9D=80=20Enum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/common/PaymentTypes.kt | 243 ++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 src/main/kotlin/roomescape/payment/infrastructure/common/PaymentTypes.kt diff --git a/src/main/kotlin/roomescape/payment/infrastructure/common/PaymentTypes.kt b/src/main/kotlin/roomescape/payment/infrastructure/common/PaymentTypes.kt new file mode 100644 index 00000000..e94a42b0 --- /dev/null +++ b/src/main/kotlin/roomescape/payment/infrastructure/common/PaymentTypes.kt @@ -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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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) + } + } + } +}