mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
refactor(router): move api models into separate crate (#103)
This commit is contained in:
478
crates/api_models/src/enums.rs
Normal file
478
crates/api_models/src/enums.rs
Normal file
@ -0,0 +1,478 @@
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Default,
|
||||
Eq,
|
||||
PartialEq,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum AttemptStatus {
|
||||
Started,
|
||||
AuthenticationFailed,
|
||||
JuspayDeclined,
|
||||
PendingVbv,
|
||||
VbvSuccessful,
|
||||
Authorized,
|
||||
AuthorizationFailed,
|
||||
Charged,
|
||||
Authorizing,
|
||||
CodInitiated,
|
||||
Voided,
|
||||
VoidInitiated,
|
||||
CaptureInitiated,
|
||||
CaptureFailed,
|
||||
VoidFailed,
|
||||
AutoRefunded,
|
||||
PartialCharged,
|
||||
#[default]
|
||||
Pending,
|
||||
Failure,
|
||||
PaymentMethodAwaited,
|
||||
ConfirmationAwaited,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Default,
|
||||
Eq,
|
||||
PartialEq,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum AuthenticationType {
|
||||
#[default]
|
||||
ThreeDs,
|
||||
NoThreeDs,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Default,
|
||||
Eq,
|
||||
PartialEq,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum CaptureMethod {
|
||||
#[default]
|
||||
Automatic,
|
||||
Manual,
|
||||
ManualMultiple,
|
||||
Scheduled,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Eq,
|
||||
PartialEq,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ConnectorType {
|
||||
/// PayFacs, Acquirers, Gateways, BNPL etc
|
||||
PaymentProcessor,
|
||||
/// Fraud, Currency Conversion, Crypto etc
|
||||
PaymentVas,
|
||||
/// Accounting, Billing, Invoicing, Tax etc
|
||||
FinOperations,
|
||||
/// Inventory, ERP, CRM, KYC etc
|
||||
FizOperations,
|
||||
/// Payment Networks like Visa, MasterCard etc
|
||||
Networks,
|
||||
/// All types of banks including corporate / commercial / personal / neo banks
|
||||
BankingEntities,
|
||||
/// All types of non-banking financial institutions including Insurance, Credit / Lending etc
|
||||
NonBankingFinance,
|
||||
}
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Default,
|
||||
Eq,
|
||||
Hash,
|
||||
PartialEq,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
)]
|
||||
pub enum Currency {
|
||||
AED,
|
||||
ALL,
|
||||
AMD,
|
||||
ARS,
|
||||
AUD,
|
||||
AWG,
|
||||
AZN,
|
||||
BBD,
|
||||
BDT,
|
||||
BHD,
|
||||
BMD,
|
||||
BND,
|
||||
BOB,
|
||||
BRL,
|
||||
BSD,
|
||||
BWP,
|
||||
BZD,
|
||||
CAD,
|
||||
CHF,
|
||||
CNY,
|
||||
COP,
|
||||
CRC,
|
||||
CUP,
|
||||
CZK,
|
||||
DKK,
|
||||
DOP,
|
||||
DZD,
|
||||
EGP,
|
||||
ETB,
|
||||
EUR,
|
||||
FJD,
|
||||
GBP,
|
||||
GHS,
|
||||
GIP,
|
||||
GMD,
|
||||
GTQ,
|
||||
GYD,
|
||||
HKD,
|
||||
HNL,
|
||||
HRK,
|
||||
HTG,
|
||||
HUF,
|
||||
IDR,
|
||||
ILS,
|
||||
INR,
|
||||
JMD,
|
||||
JOD,
|
||||
JPY,
|
||||
KES,
|
||||
KGS,
|
||||
KHR,
|
||||
KRW,
|
||||
KWD,
|
||||
KYD,
|
||||
KZT,
|
||||
LAK,
|
||||
LBP,
|
||||
LKR,
|
||||
LRD,
|
||||
LSL,
|
||||
MAD,
|
||||
MDL,
|
||||
MKD,
|
||||
MMK,
|
||||
MNT,
|
||||
MOP,
|
||||
MUR,
|
||||
MVR,
|
||||
MWK,
|
||||
MXN,
|
||||
MYR,
|
||||
NAD,
|
||||
NGN,
|
||||
NIO,
|
||||
NOK,
|
||||
NPR,
|
||||
NZD,
|
||||
OMR,
|
||||
PEN,
|
||||
PGK,
|
||||
PHP,
|
||||
PKR,
|
||||
PLN,
|
||||
QAR,
|
||||
RUB,
|
||||
SAR,
|
||||
SCR,
|
||||
SEK,
|
||||
SGD,
|
||||
SLL,
|
||||
SOS,
|
||||
SSP,
|
||||
SVC,
|
||||
SZL,
|
||||
THB,
|
||||
TTD,
|
||||
TWD,
|
||||
TZS,
|
||||
#[default]
|
||||
USD,
|
||||
UYU,
|
||||
UZS,
|
||||
YER,
|
||||
ZAR,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Eq,
|
||||
PartialEq,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum EventType {
|
||||
PaymentSucceeded,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Default,
|
||||
Eq,
|
||||
PartialEq,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum IntentStatus {
|
||||
Succeeded,
|
||||
Failed,
|
||||
Cancelled,
|
||||
Processing,
|
||||
RequiresCustomerAction,
|
||||
RequiresPaymentMethod,
|
||||
#[default]
|
||||
RequiresConfirmation,
|
||||
RequiresCapture,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Default,
|
||||
Eq,
|
||||
PartialEq,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum FutureUsage {
|
||||
#[default]
|
||||
OffSession,
|
||||
OnSession,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Eq,
|
||||
Hash,
|
||||
PartialEq,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum PaymentMethodIssuerCode {
|
||||
JpHdfc,
|
||||
JpIcici,
|
||||
JpGooglepay,
|
||||
JpApplepay,
|
||||
JpPhonepay,
|
||||
JpWechat,
|
||||
JpSofort,
|
||||
JpGiropay,
|
||||
JpSepa,
|
||||
JpBacs,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Eq,
|
||||
Hash,
|
||||
PartialEq,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum PaymentMethodSubType {
|
||||
Credit,
|
||||
Debit,
|
||||
UpiIntent,
|
||||
UpiCollect,
|
||||
CreditCardInstallments,
|
||||
PayLaterInstallments,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Default,
|
||||
Eq,
|
||||
Hash,
|
||||
PartialEq,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum PaymentMethodType {
|
||||
Card,
|
||||
PaymentContainer,
|
||||
#[default]
|
||||
BankTransfer,
|
||||
BankDebit,
|
||||
PayLater,
|
||||
Netbanking,
|
||||
Upi,
|
||||
OpenBanking,
|
||||
ConsumerFinance,
|
||||
Wallet,
|
||||
Klarna,
|
||||
Paypal,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Eq,
|
||||
Hash,
|
||||
PartialEq,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[strum(serialize_all = "lowercase")]
|
||||
pub enum WalletIssuer {
|
||||
GooglePay,
|
||||
ApplePay,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, strum::Display, strum::EnumString)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum RefundStatus {
|
||||
Failure,
|
||||
ManualReview,
|
||||
#[default]
|
||||
Pending,
|
||||
Success,
|
||||
TransactionFailure,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Eq,
|
||||
PartialEq,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum RoutingAlgorithm {
|
||||
RoundRobin,
|
||||
MaxConversion,
|
||||
MinCost,
|
||||
Custom,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Eq,
|
||||
PartialEq,
|
||||
Default,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum MandateStatus {
|
||||
#[default]
|
||||
Active,
|
||||
Inactive,
|
||||
Pending,
|
||||
Revoked,
|
||||
}
|
||||
|
||||
impl From<AttemptStatus> for IntentStatus {
|
||||
fn from(s: AttemptStatus) -> Self {
|
||||
match s {
|
||||
AttemptStatus::Charged | AttemptStatus::AutoRefunded => IntentStatus::Succeeded,
|
||||
|
||||
AttemptStatus::ConfirmationAwaited => IntentStatus::RequiresConfirmation,
|
||||
AttemptStatus::PaymentMethodAwaited => IntentStatus::RequiresPaymentMethod,
|
||||
|
||||
AttemptStatus::Authorized => IntentStatus::RequiresCapture,
|
||||
AttemptStatus::PendingVbv => IntentStatus::RequiresCustomerAction,
|
||||
|
||||
AttemptStatus::PartialCharged
|
||||
| AttemptStatus::Started
|
||||
| AttemptStatus::VbvSuccessful
|
||||
| AttemptStatus::Authorizing
|
||||
| AttemptStatus::CodInitiated
|
||||
| AttemptStatus::VoidInitiated
|
||||
| AttemptStatus::CaptureInitiated
|
||||
| AttemptStatus::Pending => IntentStatus::Processing,
|
||||
|
||||
AttemptStatus::AuthenticationFailed
|
||||
| AttemptStatus::AuthorizationFailed
|
||||
| AttemptStatus::VoidFailed
|
||||
| AttemptStatus::JuspayDeclined
|
||||
| AttemptStatus::CaptureFailed
|
||||
| AttemptStatus::Failure => IntentStatus::Failed,
|
||||
AttemptStatus::Voided => IntentStatus::Cancelled,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user