1use convert_case::{Case, Casing};
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
5#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
6#[non_exhaustive]
7pub enum ErrorCode {
8 AlreadyProcessedPayment,
9 ProviderError,
10 ExceedMaxCardInstallmentPlan,
11 InvalidRequest,
12 NotAllowedPointUse,
13 InvalidApiKey,
14 InvalidRejectCard,
15 BelowMinimumAmount,
16 InvalidCardExpiration,
17 InvalidStoppedCard,
18 ExceedMaxDailyPaymentCount,
19 NotSupportedInstallmentPlanCardOrMerchant,
20 InvalidCardInstallmentPlan,
21 NotSupportedMonthlyInstallmentPlan,
22 ExceedMaxPaymentAmount,
23 NotFoundTerminalId,
24 InvalidAuthorizeAuth,
25 InvalidCardLostOrStolen,
26 RestrictedTransferAccount,
27 InvalidCardNumber,
28 InvalidRegisteredSubmall,
29 NotRegisteredBusiness,
30 ExceedMaxOneDayWithdrawAmount,
31 ExceedMaxOneTimeWithdrawAmount,
32 CardProcessingError,
33 ExceedMaxAmount,
34 InvalidAccountInfoReRegister,
35 NotAvailablePayment,
36 UnapprovedOrderId,
37 UnauthorizedKey,
38 RejectAccountPayment,
39 RejectCardPayment,
40 RejectCardCompany,
41 ForbiddenRequest,
42 RejectTosspayInvalidAccount,
43 ExceedMaxAuthCount,
44 ExceedMaxOneDayAmount,
45 NotAvailableBank,
46 InvalidPassword,
47 IncorrectBasicAuthFormat,
48 FdsError,
49 NotFound,
50 NotFoundBilling,
51 NotFoundPayment,
52 NotFoundPaymentSession,
53 FailedPaymentInternalSystemProcessing,
54 FailedInternalSystemProcessing,
55 UnknownPaymentError,
56 AlreadyCanceledPayment,
57 InvalidRefundAccountInfo,
58 ExceedCancelAmountDiscountAmount,
59 InvalidRefundAccountNumber,
60 InvalidBank,
61 NotMatchesRefundableAmount,
62 RefundRejected,
63 AlreadyRefundPayment,
64 NotCancelableAmount,
65 ForbiddenConsecutiveRequest,
66 NotCancelablePayment,
67 ExceedMaxRefundDue,
68 NotAllowedPartialRefundWaitingDeposit,
69 NotAllowedPartialRefund,
70 NotCancelablePaymentForDormantUser,
71 FailedRefundProcess,
72 FailedMethodHandlingCancel,
73 FailedPartialRefund,
74 CommonError,
75 NotSupportedCardType,
76 InvalidCardPassword,
77 InvalidCardIdentity,
78 InvalidBirthDayFormat,
79 NotRegisteredCardCompany,
80 InvalidEmail,
81 NotSupportedMethod,
82 InvalidBillKeyRequest,
83 DuplicatedOrderId,
84 NotMatchesCustomerKey,
85 FailedDbProcessing,
86 FailedCardCompanyResponse,
87 IdempotentRequestProcessing,
88}
89
90impl std::fmt::Display for ErrorCode {
91 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
92 write!(f, "{}", &format!("{:?}", self).to_case(Case::UpperSnake))
93 }
94}
95
96#[cfg(test)]
97mod tests {
98 use super::*;
99
100 #[test]
101 fn error_code_display() {
102 assert_eq!(format!("{}", ErrorCode::CommonError), "COMMON_ERROR");
103 assert_eq!(
104 format!("{}", ErrorCode::NotSupportedMethod),
105 "NOT_SUPPORTED_METHOD"
106 );
107 }
108}