pub use common_enums::*; use utoipa::ToSchema; #[derive( Clone, Copy, Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, )] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum AttemptStatus { Started, AuthenticationFailed, RouterDeclined, AuthenticationPending, AuthenticationSuccessful, Authorized, AuthorizationFailed, Charged, Authorizing, CodInitiated, Voided, VoidInitiated, CaptureInitiated, CaptureFailed, VoidFailed, AutoRefunded, PartialCharged, Unresolved, #[default] Pending, Failure, PaymentMethodAwaited, ConfirmationAwaited, DeviceDataCollectionPending, } #[derive( Clone, Copy, Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, ToSchema, )] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum AuthenticationType { /// If the card is enrolled for 3DS authentication, the 3DS based authentication will be activated. The liability of chargeback shift to the issuer #[default] ThreeDs, /// 3DS based authentication will not be activated. The liability of chargeback stays with the merchant. NoThreeDs, } #[derive( Clone, Copy, Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, ToSchema, )] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum CaptureMethod { /// Post the payment authorization, the capture will be executed on the full amount immediately #[default] Automatic, /// The capture will happen only if the merchant triggers a Capture API request Manual, /// The capture will happen only if the merchant triggers a Capture API request ManualMultiple, /// The capture can be scheduled to automatically get triggered at a specific date & time Scheduled, } #[derive( Clone, Copy, Debug, Eq, PartialEq, strum::Display, strum::EnumString, serde::Deserialize, serde::Serialize, frunk::LabelledGeneric, ToSchema, )] #[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, strum::EnumIter, ToSchema, frunk::LabelledGeneric, )] pub enum Currency { AED, ALL, AMD, ANG, 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, frunk::LabelledGeneric, )] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum EventType { PaymentSucceeded, PaymentProcessing, ActionRequired, RefundSucceeded, RefundFailed, DisputeOpened, DisputeExpired, DisputeAccepted, DisputeCancelled, DisputeChallenged, DisputeWon, DisputeLost, } #[derive( Clone, Copy, Debug, Default, Eq, PartialEq, ToSchema, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, )] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum IntentStatus { Succeeded, Failed, Cancelled, Processing, RequiresCustomerAction, RequiresMerchantAction, RequiresPaymentMethod, #[default] RequiresConfirmation, RequiresCapture, } #[derive( Clone, Copy, Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, ToSchema, )] #[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, frunk::LabelledGeneric, ToSchema, )] #[strum(serialize_all = "snake_case")] #[serde(rename_all = "snake_case")] pub enum PaymentMethodIssuerCode { JpHdfc, JpIcici, JpGooglepay, JpApplepay, JpPhonepay, JpWechat, JpSofort, JpGiropay, JpSepa, JpBacs, } #[derive( Eq, PartialEq, Hash, Copy, Clone, Debug, serde::Serialize, serde::Deserialize, strum::Display, ToSchema, Default, frunk::LabelledGeneric, )] #[serde(rename_all = "snake_case")] pub enum PaymentExperience { /// The URL to which the customer needs to be redirected for completing the payment. #[default] RedirectToUrl, /// Contains the data for invoking the sdk client for completing the payment. InvokeSdkClient, /// The QR code data to be displayed to the customer. DisplayQrCode, /// Contains data to finish one click payment. OneClick, /// Redirect customer to link wallet LinkWallet, /// Contains the data for invoking the sdk client for completing the payment. InvokePaymentApp, } #[derive( Clone, Copy, Debug, Eq, Hash, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, ToSchema, frunk::LabelledGeneric, )] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum PaymentMethodType { Ach, Affirm, AfterpayClearpay, AliPay, ApplePay, Bacs, BancontactCard, Becs, Blik, Credit, CryptoCurrency, Debit, Eps, Giropay, GooglePay, Ideal, Klarna, MbWay, MobilePay, OnlineBankingCzechRepublic, OnlineBankingFinland, OnlineBankingPoland, OnlineBankingSlovakia, PayBright, Paypal, Przelewy24, Sepa, Sofort, Swish, Trustly, Walley, WeChatPay, } #[derive( Clone, Copy, Debug, Default, Eq, Hash, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, ToSchema, frunk::LabelledGeneric, )] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum PaymentMethod { #[default] Card, PayLater, Wallet, BankRedirect, Crypto, BankDebit, } #[derive( Clone, Copy, Debug, Eq, Hash, PartialEq, ToSchema, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, )] #[serde(rename_all = "lowercase")] #[strum(serialize_all = "lowercase")] pub enum WalletIssuer { GooglePay, ApplePay, Paypal, } #[derive( Clone, Copy, Debug, Default, Eq, PartialEq, strum::Display, strum::EnumString, frunk::LabelledGeneric, )] #[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, ToSchema, frunk::LabelledGeneric, )] /// The routing algorithm to be used to process the incoming request from merchant to outgoing payment processor or payment method. The default is 'Custom' #[schema(example = "custom")] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum RoutingAlgorithm { RoundRobin, MaxConversion, MinCost, Custom, } /// The status of the mandate, which indicates whether it can be used to initiate a payment #[derive( Clone, Copy, Debug, Eq, PartialEq, Default, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, ToSchema, )] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum MandateStatus { #[default] Active, Inactive, Pending, Revoked, } #[derive( Clone, Copy, Debug, Default, Eq, PartialEq, ToSchema, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, Hash, )] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum Connector { Aci, Adyen, Airwallex, Applepay, Authorizedotnet, Bluesnap, Braintree, Checkout, Coinbase, Cybersource, #[default] Dummy, Opennode, Bambora, Dlocal, Fiserv, Forte, Globalpay, Klarna, Mollie, Multisafepay, Nexinets, Nuvei, // Payeezy, As psync and rsync are not supported by this connector, it is added as template code for future usage Paypal, Payu, Rapyd, Shift4, Stripe, Trustpay, Worldline, Worldpay, Zen, } impl Connector { pub fn supports_access_token(&self, payment_method: PaymentMethod) -> bool { matches!( (self, payment_method), (Self::Airwallex, _) | (Self::Globalpay, _) | (Self::Paypal, _) | (Self::Payu, _) | (Self::Trustpay, PaymentMethod::BankRedirect) ) } pub fn supports_file_storage_module(&self) -> bool { matches!(self, Self::Stripe | Self::Checkout) } pub fn requires_defend_dispute(&self) -> bool { matches!(self, Self::Checkout) } } #[derive( Clone, Copy, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, )] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum RoutableConnectors { Aci, Adyen, Airwallex, Authorizedotnet, Bambora, Bluesnap, Braintree, Checkout, Coinbase, Cybersource, Dlocal, Fiserv, Forte, Globalpay, Klarna, Mollie, Multisafepay, Nexinets, Nuvei, Opennode, // Payeezy, As psync and rsync are not supported by this connector, it is added as template code for future usage Paypal, Payu, Rapyd, Shift4, Stripe, Trustpay, Worldline, Worldpay, Zen, } /// Name of banks supported by Hyperswitch #[derive( Clone, Copy, Debug, Eq, Hash, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, ToSchema, )] #[strum(serialize_all = "snake_case")] #[serde(rename_all = "snake_case")] pub enum BankNames { AmericanExpress, BankOfAmerica, Barclays, #[serde(rename = "BLIK - PSP")] BlikPSP, CapitalOne, Chase, Citi, Discover, NavyFederalCreditUnion, PentagonFederalCreditUnion, SynchronyBank, WellsFargo, AbnAmro, AsnBank, Bunq, Handelsbanken, Ing, Knab, Moneyou, Rabobank, Regiobank, Revolut, SnsBank, TriodosBank, VanLanschot, ArzteUndApothekerBank, AustrianAnadiBankAg, BankAustria, Bank99Ag, BankhausCarlSpangler, BankhausSchelhammerUndSchatteraAg, #[serde(rename = "Bank Millennium")] BankMillennium, #[serde(rename = "Bank PEKAO S.A.")] BankPEKAOSA, BawagPskAg, BksBankAg, BrullKallmusBankAg, BtvVierLanderBank, CapitalBankGraweGruppeAg, #[serde(rename = "Česká spořitelna")] CeskaSporitelna, Dolomitenbank, EasybankAg, #[serde(rename = "ePlatby VÚB")] EPlatbyVUB, ErsteBankUndSparkassen, HypoAlpeadriabankInternationalAg, HypoNoeLbFurNiederosterreichUWien, HypoOberosterreichSalzburgSteiermark, HypoTirolBankAg, HypoVorarlbergBankAg, HypoBankBurgenlandAktiengesellschaft, #[serde(rename = "Komercní banka")] KomercniBanka, #[serde(rename = "mBank - mTransfer")] MBank, MarchfelderBank, OberbankAg, OsterreichischeArzteUndApothekerbank, #[serde(rename = "Pay with ING")] PayWithING, #[serde(rename = "Płacę z iPKO")] PlaceZIPKO, #[serde(rename = "Płatność online kartą płatniczą")] PlatnoscOnlineKartaPlatnicza, PosojilnicaBankEGen, #[serde(rename = "Poštová banka")] PostovaBanka, RaiffeisenBankengruppeOsterreich, SchelhammerCapitalBankAg, SchoellerbankAg, SpardaBankWien, SporoPay, #[serde(rename = "Santander-Przelew24")] SantanderPrzelew24, TatraPay, Viamo, VolksbankGruppe, VolkskreditbankAg, VrBankBraunau, #[serde(rename = "Pay with Alior Bank")] PayWithAliorBank, #[serde(rename = "Banki Spółdzielcze")] BankiSpoldzielcze, #[serde(rename = "Pay with Inteligo")] PayWithInteligo, #[serde(rename = "BNP Paribas Poland")] BNPParibasPoland, #[serde(rename = "Bank Nowy S.A.")] BankNowySA, #[serde(rename = "Credit Agricole")] CreditAgricole, #[serde(rename = "Pay with BOŚ")] PayWithBOS, #[serde(rename = "Pay with CitiHandlowy")] PayWithCitiHandlowy, #[serde(rename = "Pay with Plus Bank")] PayWithPlusBank, #[serde(rename = "Toyota Bank")] ToyotaBank, VeloBank, #[serde(rename = "e-transfer Pocztowy24")] ETransferPocztowy24, } #[derive( Clone, Debug, Eq, Hash, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, ToSchema, )] pub enum CardNetwork { Visa, Mastercard, AmericanExpress, JCB, DinersClub, Discover, CartesBancaires, UnionPay, Interac, RuPay, Maestro, } impl From for IntentStatus { fn from(s: AttemptStatus) -> Self { match s { AttemptStatus::Charged | AttemptStatus::AutoRefunded => Self::Succeeded, AttemptStatus::ConfirmationAwaited => Self::RequiresConfirmation, AttemptStatus::PaymentMethodAwaited => Self::RequiresPaymentMethod, AttemptStatus::Authorized => Self::RequiresCapture, AttemptStatus::AuthenticationPending | AttemptStatus::DeviceDataCollectionPending => { Self::RequiresCustomerAction } AttemptStatus::Unresolved => Self::RequiresMerchantAction, AttemptStatus::PartialCharged | AttemptStatus::Started | AttemptStatus::AuthenticationSuccessful | AttemptStatus::Authorizing | AttemptStatus::CodInitiated | AttemptStatus::VoidInitiated | AttemptStatus::CaptureInitiated | AttemptStatus::Pending => Self::Processing, AttemptStatus::AuthenticationFailed | AttemptStatus::AuthorizationFailed | AttemptStatus::VoidFailed | AttemptStatus::RouterDeclined | AttemptStatus::CaptureFailed | AttemptStatus::Failure => Self::Failed, AttemptStatus::Voided => Self::Cancelled, } } } #[derive( Clone, Default, Debug, Eq, Hash, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, ToSchema, )] #[serde(rename_all = "snake_case")] pub enum DisputeStage { PreDispute, #[default] Dispute, PreArbitration, } #[derive( Clone, Debug, Default, Eq, Hash, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, ToSchema, )] #[serde(rename_all = "snake_case")] pub enum DisputeStatus { #[default] DisputeOpened, DisputeExpired, DisputeAccepted, DisputeCancelled, DisputeChallenged, // dispute has been successfully challenged by the merchant DisputeWon, // dispute has been unsuccessfully challenged DisputeLost, } #[derive( Clone, Debug, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, ToSchema, )] #[strum(serialize_all = "snake_case")] #[serde(rename_all = "snake_case")] pub enum FrmAction { CancelTxn, AutoRefund, ManualReview, } #[derive( Clone, Debug, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, frunk::LabelledGeneric, ToSchema, )] #[strum(serialize_all = "snake_case")] #[serde(rename_all = "snake_case")] pub enum FrmPreferredFlowTypes { Pre, Post, } #[derive(Debug, Eq, PartialEq, Clone, serde::Serialize, serde::Deserialize)] pub struct UnresolvedResponseReason { pub code: String, /// A message to merchant to give hint on next action he/she should do to resolve pub message: String, }