Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

refactor(enums): move enums from `storage_models` and `api_models` crates to `common_enums` crate (#1265)

Amisha Prabhatc0e1d4d3b014
diff --git a/Cargo.lock b/Cargo.lock
index ee189d1409..e42e38db86 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -385,15 +385,14 @@ dependencies = [
"cards",
"common_enums",
"common_utils",
- "frunk",
- "frunk_core",
+ "error-stack",
"masking",
"mime",
"reqwest",
"router_derive",
"serde",
"serde_json",
- "strum",
+ "strum 0.24.1",
"time 0.3.22",
"url",
"utoipa",
@@ -1361,11 +1360,13 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
name = "common_enums"
version = "0.1.0"
dependencies = [
+ "common_utils",
"diesel",
"router_derive",
"serde",
"serde_json",
- "strum",
+ "strum 0.25.0",
+ "time 0.3.22",
"utoipa",
]
@@ -1741,7 +1742,7 @@ dependencies = [
"router_env",
"serde",
"serde_json",
- "strum",
+ "strum 0.24.1",
"thiserror",
"time 0.3.22",
]
@@ -3975,8 +3976,6 @@ dependencies = [
"encoding_rs",
"error-stack",
"external_services",
- "frunk",
- "frunk_core",
"futures",
"hex",
"http",
@@ -4010,7 +4009,7 @@ dependencies = [
"serial_test",
"signal-hook",
"signal-hook-tokio",
- "strum",
+ "strum 0.24.1",
"test_utils",
"thirtyfour",
"thiserror",
@@ -4035,7 +4034,7 @@ dependencies = [
"quote",
"serde",
"serde_json",
- "strum",
+ "strum 0.24.1",
"syn 1.0.109",
]
@@ -4053,7 +4052,7 @@ dependencies = [
"serde",
"serde_json",
"serde_path_to_error",
- "strum",
+ "strum 0.24.1",
"time 0.3.22",
"tokio",
"tracing",
@@ -4595,7 +4594,16 @@ version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
dependencies = [
- "strum_macros",
+ "strum_macros 0.24.3",
+]
+
+[[package]]
+name = "strum"
+version = "0.25.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125"
+dependencies = [
+ "strum_macros 0.25.1",
]
[[package]]
@@ -4611,6 +4619,19 @@ dependencies = [
"syn 1.0.109",
]
+[[package]]
+name = "strum_macros"
+version = "0.25.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6069ca09d878a33f883cc06aaa9718ede171841d3832450354410b718b097232"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "rustversion",
+ "syn 2.0.18",
+]
+
[[package]]
name = "subtle"
version = "2.4.1"
diff --git a/crates/api_models/Cargo.toml b/crates/api_models/Cargo.toml
index fce4c06584..fc4d56e025 100644
--- a/crates/api_models/Cargo.toml
+++ b/crates/api_models/Cargo.toml
@@ -11,13 +11,12 @@ license.workspace = true
default = []
errors = ["dep:actix-web", "dep:reqwest"]
multiple_mca = []
-dummy_connector = []
+dummy_connector = ["common_enums/dummy_connector"]
detailed_errors = []
[dependencies]
actix-web = { version = "4.3.1", optional = true }
-frunk = "0.4.1"
-frunk_core = "0.4.1"
+error-stack = "0.3.1"
mime = "0.3.17"
reqwest = { version = "0.11.18", optional = true }
serde = { version = "1.0.163", features = ["derive"] }
diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs
index 3dad6e8fc8..5e48e39879 100644
--- a/crates/api_models/src/enums.rs
+++ b/crates/api_models/src/enums.rs
@@ -5,543 +5,14 @@ use utoipa::ToSchema;
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
- ThreeDs,
- /// 3DS based authentication will not be activated. The liability of chargeback stays with the merchant.
- #[default]
- 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,
- RON,
- RUB,
- SAR,
- SCR,
- SEK,
- SGD,
- SLL,
- SOS,
- SSP,
- SVC,
- SZL,
- THB,
- TRY,
- 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,
- PaymentFailed,
- 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,
- AliPayHk,
- ApplePay,
- Bacs,
- BancontactCard,
- Becs,
- Blik,
- #[serde(rename = "classic")]
- ClassicReward,
- Credit,
- CryptoCurrency,
- Debit,
- Eps,
- Evoucher,
- Giropay,
- GooglePay,
- Ideal,
- Interac,
- Klarna,
- MbWay,
- MobilePay,
- Multibanco,
- OnlineBankingCzechRepublic,
- OnlineBankingFinland,
- OnlineBankingPoland,
- OnlineBankingSlovakia,
- PayBright,
- Paypal,
- Przelewy24,
- SamsungPay,
- Sepa,
- Sofort,
- Swish,
- Trustly,
- UpiCollect,
- 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,
- BankTransfer,
- Crypto,
- BankDebit,
- Reward,
- Upi,
-}
-
-#[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,
- Hash,
- PartialEq,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
- serde::Deserialize,
- serde::Serialize,
-)]
-#[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")]
@@ -554,31 +25,6 @@ pub enum RoutingAlgorithm {
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,
@@ -588,9 +34,10 @@ pub enum MandateStatus {
ToSchema,
serde::Deserialize,
serde::Serialize,
+ strum::EnumVariantNames,
+ strum::EnumIter,
strum::Display,
strum::EnumString,
- frunk::LabelledGeneric,
Hash,
)]
#[serde(rename_all = "snake_case")]
@@ -697,7 +144,8 @@ impl Connector {
serde::Deserialize,
strum::Display,
strum::EnumString,
- frunk::LabelledGeneric,
+ strum::EnumIter,
+ strum::EnumVariantNames,
)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
@@ -784,7 +232,6 @@ pub enum RoutableConnectors {
serde::Serialize,
strum::Display,
strum::EnumString,
- frunk::LabelledGeneric,
ToSchema,
)]
#[strum(serialize_all = "snake_case")]
@@ -894,91 +341,7 @@ pub enum BankNames {
}
#[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,
-}
-
-#[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,
+ Clone, Debug, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, ToSchema,
)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
@@ -989,14 +352,7 @@ pub enum FrmAction {
}
#[derive(
- Clone,
- Debug,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
- ToSchema,
+ Clone, Debug, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, ToSchema,
)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 66bc1d9667..2802a7f82f 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -1104,17 +1104,7 @@ impl Default for PaymentIdType {
}
}
-#[derive(
- Default,
- Clone,
- Debug,
- Eq,
- PartialEq,
- ToSchema,
- serde::Deserialize,
- serde::Serialize,
- frunk::LabelledGeneric,
-)]
+#[derive(Default, Clone, Debug, Eq, PartialEq, ToSchema, serde::Deserialize, serde::Serialize)]
#[serde(deny_unknown_fields)]
pub struct Address {
/// Provide the address details
@@ -1124,17 +1114,7 @@ pub struct Address {
}
// used by customers also, could be moved outside
-#[derive(
- Clone,
- Default,
- Debug,
- Eq,
- serde::Deserialize,
- serde::Serialize,
- PartialEq,
- ToSchema,
- frunk::LabelledGeneric,
-)]
+#[derive(Clone, Default, Debug, Eq, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct AddressDetails {
/// The address city
@@ -1174,17 +1154,7 @@ pub struct AddressDetails {
pub last_name: Option<Secret<String>>,
}
-#[derive(
- Debug,
- Clone,
- Default,
- Eq,
- PartialEq,
- ToSchema,
- serde::Deserialize,
- serde::Serialize,
- frunk::LabelledGeneric,
-)]
+#[derive(Debug, Clone, Default, Eq, PartialEq, ToSchema, serde::Deserialize, serde::Serialize)]
pub struct PhoneDetails {
/// The contact number
#[schema(value_type = Option<String>, example = "9999999999")]
diff --git a/crates/common_enums/Cargo.toml b/crates/common_enums/Cargo.toml
index 1358e57158..7b930d073d 100644
--- a/crates/common_enums/Cargo.toml
+++ b/crates/common_enums/Cargo.toml
@@ -7,13 +7,19 @@ rust-version.workspace = true
readme = "README.md"
license.workspace = true
+[features]
+dummy_connector = []
+
[dependencies]
diesel = { version = "2.1.0", features = ["postgres"] }
-serde = { version = "1.0.163", features = ["derive"] }
-strum = { version = "0.24.1", features = ["derive"] }
+serde = { version = "1.0.160", features = [ "derive" ] }
+serde_json = "1.0.96"
+strum = { version = "0.25", features = [ "derive" ] }
+time = { version = "0.3.20", features = ["serde", "serde-well-known", "std"] }
utoipa = { version = "3.3.0", features = ["preserve_order"] }
# First party crates
+common_utils = { version = "0.1.0", path = "../common_utils" }
router_derive = { version = "0.1.0", path = "../router_derive" }
[dev-dependencies]
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 7ab2e2eaef..5bdbd7bbae 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -1,5 +1,759 @@
use router_derive;
use serde::{Deserialize, Serialize};
+use utoipa::ToSchema;
+#[doc(hidden)]
+pub mod diesel_exports {
+ pub use super::{
+ DbAttemptStatus as AttemptStatus, DbAuthenticationType as AuthenticationType,
+ DbCaptureMethod as CaptureMethod, DbConnectorType as ConnectorType,
+ DbCountryAlpha2 as CountryAlpha2, DbCurrency as Currency, DbDisputeStage as DisputeStage,
+ DbDisputeStatus as DisputeStatus, DbEventType as EventType, DbFutureUsage as FutureUsage,
+ DbIntentStatus as IntentStatus, DbMandateStatus as MandateStatus,
+ DbPaymentMethodIssuerCode as PaymentMethodIssuerCode, DbRefundStatus as RefundStatus,
+ };
+}
+
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ Default,
+ Eq,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::EnumString,
+)]
+#[router_derive::diesel_enum(storage_type = "pg_enum")]
+#[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,
+ Hash,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::EnumVariantNames,
+ strum::EnumIter,
+ strum::EnumString,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "pg_enum")]
+#[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
+ ThreeDs,
+ /// 3DS based authentication will not be activated. The liability of chargeback stays with the merchant.
+ #[default]
+ NoThreeDs,
+}
+
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ Default,
+ Eq,
+ Hash,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::EnumVariantNames,
+ strum::EnumIter,
+ strum::EnumString,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "pg_enum")]
+#[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,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "pg_enum")]
+#[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,
+ strum::EnumVariantNames,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "pg_enum")]
+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,
+ RON,
+ RUB,
+ SAR,
+ SCR,
+ SEK,
+ SGD,
+ SLL,
+ SOS,
+ SSP,
+ SVC,
+ SZL,
+ THB,
+ TRY,
+ TTD,
+ TWD,
+ TZS,
+ #[default]
+ USD,
+ UYU,
+ UZS,
+ YER,
+ ZAR,
+}
+
+impl Currency {
+ pub fn iso_4217(&self) -> &'static str {
+ match *self {
+ Self::AED => "784",
+ Self::ALL => "008",
+ Self::AMD => "051",
+ Self::ANG => "532",
+ Self::ARS => "032",
+ Self::AUD => "036",
+ Self::AWG => "533",
+ Self::AZN => "944",
+ Self::BBD => "052",
+ Self::BDT => "050",
+ Self::BHD => "048",
+ Self::BMD => "060",
+ Self::BND => "096",
+ Self::BOB => "068",
+ Self::BRL => "986",
+ Self::BSD => "044",
+ Self::BWP => "072",
+ Self::BZD => "084",
+ Self::CAD => "124",
+ Self::CHF => "756",
+ Self::COP => "170",
+ Self::CRC => "188",
+ Self::CUP => "192",
+ Self::CZK => "203",
+ Self::DKK => "208",
+ Self::DOP => "214",
+ Self::DZD => "012",
+ Self::EGP => "818",
+ Self::ETB => "230",
+ Self::EUR => "978",
+ Self::FJD => "242",
+ Self::GBP => "826",
+ Self::GHS => "936",
+ Self::GIP => "292",
+ Self::GMD => "270",
+ Self::GTQ => "320",
+ Self::GYD => "328",
+ Self::HKD => "344",
+ Self::HNL => "340",
+ Self::HTG => "332",
+ Self::HUF => "348",
+ Self::HRK => "191",
+ Self::IDR => "360",
+ Self::ILS => "376",
+ Self::INR => "356",
+ Self::JMD => "388",
+ Self::JOD => "400",
+ Self::JPY => "392",
+ Self::KES => "404",
+ Self::KGS => "417",
+ Self::KHR => "116",
+ Self::KRW => "410",
+ Self::KWD => "414",
+ Self::KYD => "136",
+ Self::KZT => "398",
+ Self::LAK => "418",
+ Self::LBP => "422",
+ Self::LKR => "144",
+ Self::LRD => "430",
+ Self::LSL => "426",
+ Self::MAD => "504",
+ Self::MDL => "498",
+ Self::MKD => "807",
+ Self::MMK => "104",
+ Self::MNT => "496",
+ Self::MOP => "446",
+ Self::MUR => "480",
+ Self::MVR => "462",
+ Self::MWK => "454",
+ Self::MXN => "484",
+ Self::MYR => "458",
+ Self::NAD => "516",
+ Self::NGN => "566",
+ Self::NIO => "558",
+ Self::NOK => "578",
+ Self::NPR => "524",
+ Self::NZD => "554",
+ Self::OMR => "512",
+ Self::PEN => "604",
+ Self::PGK => "598",
+ Self::PHP => "608",
+ Self::PKR => "586",
+ Self::PLN => "985",
+ Self::QAR => "634",
+ Self::RON => "946",
+ Self::CNY => "156",
+ Self::RUB => "643",
+ Self::SAR => "682",
+ Self::SCR => "690",
+ Self::SEK => "752",
+ Self::SGD => "702",
+ Self::SLL => "694",
+ Self::SOS => "706",
+ Self::SSP => "728",
+ Self::SVC => "222",
+ Self::SZL => "748",
+ Self::THB => "764",
+ Self::TRY => "949",
+ Self::TTD => "780",
+ Self::TWD => "901",
+ Self::TZS => "834",
+ Self::USD => "840",
+ Self::UYU => "858",
+ Self::UZS => "860",
+ Self::YER => "886",
+ Self::ZAR => "710",
+ }
+ }
+}
+
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ Eq,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::EnumString,
+)]
+#[router_derive::diesel_enum(storage_type = "pg_enum")]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+pub enum EventType {
+ PaymentSucceeded,
+ PaymentFailed,
+ PaymentProcessing,
+ ActionRequired,
+ RefundSucceeded,
+ RefundFailed,
+ DisputeOpened,
+ DisputeExpired,
+ DisputeAccepted,
+ DisputeCancelled,
+ DisputeChallenged,
+ DisputeWon,
+ DisputeLost,
+}
+
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ Default,
+ Eq,
+ Hash,
+ PartialEq,
+ ToSchema,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::EnumString,
+)]
+#[router_derive::diesel_enum(storage_type = "pg_enum")]
+#[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,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "pg_enum")]
+#[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,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "pg_enum")]
+#[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,
+ strum::EnumString,
+ PartialEq,
+ Hash,
+ Copy,
+ Clone,
+ Debug,
+ serde::Serialize,
+ serde::Deserialize,
+ strum::Display,
+ ToSchema,
+ Default,
+)]
+#[router_derive::diesel_enum(storage_type = "text")]
+#[strum(serialize_all = "snake_case")]
+#[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::EnumVariantNames,
+ strum::EnumIter,
+ strum::EnumString,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "text")]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+pub enum PaymentMethodType {
+ Ach,
+ Affirm,
+ AfterpayClearpay,
+ AliPay,
+ AliPayHk,
+ ApplePay,
+ Bacs,
+ BancontactCard,
+ Becs,
+ Blik,
+ #[serde(rename = "classic")]
+ ClassicReward,
+ Credit,
+ CryptoCurrency,
+ Debit,
+ Eps,
+ Evoucher,
+ Giropay,
+ GooglePay,
+ Ideal,
+ Interac,
+ Klarna,
+ MbWay,
+ MobilePay,
+ Multibanco,
+ OnlineBankingCzechRepublic,
+ OnlineBankingFinland,
+ OnlineBankingPoland,
+ OnlineBankingSlovakia,
+ PayBright,
+ Paypal,
+ Przelewy24,
+ SamsungPay,
+ Sepa,
+ Sofort,
+ Swish,
+ Trustly,
+ UpiCollect,
+ Walley,
+ WeChatPay,
+}
+
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ Default,
+ Eq,
+ Hash,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::EnumVariantNames,
+ strum::EnumIter,
+ strum::EnumString,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "text")]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+pub enum PaymentMethod {
+ #[default]
+ Card,
+ PayLater,
+ Wallet,
+ BankRedirect,
+ BankTransfer,
+ Crypto,
+ BankDebit,
+ Reward,
+ Upi,
+}
+
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ Default,
+ Eq,
+ Hash,
+ PartialEq,
+ strum::Display,
+ strum::EnumString,
+ serde::Serialize,
+ serde::Deserialize,
+)]
+#[router_derive::diesel_enum(storage_type = "pg_enum")]
+#[strum(serialize_all = "snake_case")]
+pub enum RefundStatus {
+ Failure,
+ ManualReview,
+ #[default]
+ Pending,
+ Success,
+ TransactionFailure,
+}
+
+/// 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,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "pg_enum")]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+pub enum MandateStatus {
+ #[default]
+ Active,
+ Inactive,
+ Pending,
+ Revoked,
+}
+
+#[derive(
+ Clone,
+ Debug,
+ Eq,
+ Hash,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::EnumVariantNames,
+ strum::EnumIter,
+ strum::EnumString,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "text")]
+pub enum CardNetwork {
+ Visa,
+ Mastercard,
+ AmericanExpress,
+ JCB,
+ DinersClub,
+ Discover,
+ CartesBancaires,
+ UnionPay,
+ Interac,
+ RuPay,
+ Maestro,
+}
+
+#[derive(
+ Clone,
+ Copy,
+ Default,
+ Debug,
+ Eq,
+ Hash,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::EnumString,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "pg_enum")]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+pub enum DisputeStage {
+ PreDispute,
+ #[default]
+ Dispute,
+ PreArbitration,
+}
+
+#[derive(
+ Clone,
+ Debug,
+ Copy,
+ Default,
+ Eq,
+ Hash,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::EnumString,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "pg_enum")]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_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,
@@ -61,7 +815,20 @@ pub enum CountryAlpha3 {
VEN, VNM, VGB, VIR, WLF, ESH, YEM, ZMB, ZWE
}
-#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)]
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ PartialEq,
+ Eq,
+ Hash,
+ strum::Display,
+ strum::EnumVariantNames,
+ strum::EnumIter,
+ strum::EnumString,
+ Deserialize,
+ Serialize,
+)]
pub enum Country {
Afghanistan,
AlandIslands,
diff --git a/crates/common_enums/src/transformers.rs b/crates/common_enums/src/transformers.rs
index 3fd487a380..aa502d6138 100644
--- a/crates/common_enums/src/transformers.rs
+++ b/crates/common_enums/src/transformers.rs
@@ -2,7 +2,7 @@ use std::fmt::{Display, Formatter};
use serde::{Deserialize, Serialize};
-use crate::enums::{Country, CountryAlpha2, CountryAlpha3};
+use crate::enums::{Country, CountryAlpha2, CountryAlpha3, PaymentMethod, PaymentMethodType};
impl Display for NumericCountryCodeParseError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
@@ -1532,6 +1532,52 @@ impl Country {
}
}
+impl From<PaymentMethodType> for PaymentMethod {
+ fn from(value: PaymentMethodType) -> Self {
+ match value {
+ PaymentMethodType::Ach => Self::BankDebit,
+ PaymentMethodType::Affirm => Self::PayLater,
+ PaymentMethodType::AfterpayClearpay => Self::PayLater,
+ PaymentMethodType::AliPay => Self::Wallet,
+ PaymentMethodType::AliPayHk => Self::Wallet,
+ PaymentMethodType::ApplePay => Self::Wallet,
+ PaymentMethodType::Bacs => Self::BankDebit,
+ PaymentMethodType::BancontactCard => Self::BankRedirect,
+ PaymentMethodType::Becs => Self::BankDebit,
+ PaymentMethodType::Blik => Self::BankRedirect,
+ PaymentMethodType::ClassicReward => Self::Reward,
+ PaymentMethodType::Credit => Self::Card,
+ PaymentMethodType::CryptoCurrency => Self::Crypto,
+ PaymentMethodType::Debit => Self::Card,
+ PaymentMethodType::Eps => Self::BankRedirect,
+ PaymentMethodType::Evoucher => Self::Reward,
+ PaymentMethodType::Giropay => Self::BankRedirect,
+ PaymentMethodType::GooglePay => Self::Wallet,
+ PaymentMethodType::Ideal => Self::BankRedirect,
+ PaymentMethodType::Klarna => Self::PayLater,
+ PaymentMethodType::MbWay => Self::Wallet,
+ PaymentMethodType::MobilePay => Self::Wallet,
+ PaymentMethodType::Multibanco => Self::BankTransfer,
+ PaymentMethodType::Interac => Self::BankRedirect,
+ PaymentMethodType::OnlineBankingCzechRepublic => Self::BankRedirect,
+ PaymentMethodType::OnlineBankingFinland => Self::BankRedirect,
+ PaymentMethodType::OnlineBankingPoland => Self::BankRedirect,
+ PaymentMethodType::OnlineBankingSlovakia => Self::BankRedirect,
+ PaymentMethodType::PayBright => Self::PayLater,
+ PaymentMethodType::Paypal => Self::Wallet,
+ PaymentMethodType::Przelewy24 => Self::BankRedirect,
+ PaymentMethodType::SamsungPay => Self::Wallet,
+ PaymentMethodType::Sepa => Self::BankDebit,
+ PaymentMethodType::Sofort => Self::BankRedirect,
+ PaymentMethodType::Swish => Self::BankRedirect,
+ PaymentMethodType::Trustly => Self::BankRedirect,
+ PaymentMethodType::UpiCollect => Self::Upi,
+ PaymentMethodType::Walley => Self::PayLater,
+ PaymentMethodType::WeChatPay => Self::Wallet,
+ }
+ }
+}
+
#[derive(Debug)]
pub struct NumericCountryCodeParseError;
#[allow(dead_code)]
diff --git a/crates/diesel_models/src/address.rs b/crates/diesel_models/src/address.rs
index 7b428382c0..71ec7c1b89 100644
--- a/crates/diesel_models/src/address.rs
+++ b/crates/diesel_models/src/address.rs
@@ -24,7 +24,7 @@ pub struct AddressNew {
pub modified_at: PrimitiveDateTime,
}
-#[derive(Clone, Debug, Identifiable, Queryable, frunk::LabelledGeneric)]
+#[derive(Clone, Debug, Identifiable, Queryable)]
#[diesel(table_name = address)]
pub struct Address {
pub id: i32,
diff --git a/crates/diesel_models/src/enums.rs b/crates/diesel_models/src/enums.rs
index 13410dbe5c..bf29c07c91 100644
--- a/crates/diesel_models/src/enums.rs
+++ b/crates/diesel_models/src/enums.rs
@@ -14,372 +14,11 @@ pub mod diesel_exports {
DbRefundType as RefundType,
};
}
-
pub use common_enums::*;
use common_utils::pii;
use diesel::serialize::{Output, ToSql};
use time::PrimitiveDateTime;
-#[derive(
- Clone,
- Copy,
- Debug,
- Default,
- Eq,
- PartialEq,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-#[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,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-#[serde(rename_all = "snake_case")]
-#[strum(serialize_all = "snake_case")]
-pub enum AuthenticationType {
- ThreeDs,
- #[default]
- NoThreeDs,
-}
-
-#[derive(
- Clone,
- Copy,
- Debug,
- Default,
- Eq,
- PartialEq,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-#[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,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-#[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,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-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,
- RON,
- RUB,
- SAR,
- SCR,
- SEK,
- SGD,
- SLL,
- SOS,
- SSP,
- SVC,
- SZL,
- THB,
- TRY,
- TTD,
- TWD,
- TZS,
- #[default]
- USD,
- UYU,
- UZS,
- YER,
- ZAR,
-}
-
-impl Currency {
- pub fn iso_4217(&self) -> &'static str {
- match *self {
- Self::AED => "784",
- Self::ALL => "008",
- Self::AMD => "051",
- Self::ANG => "532",
- Self::ARS => "032",
- Self::AUD => "036",
- Self::AWG => "533",
- Self::AZN => "944",
- Self::BBD => "052",
- Self::BDT => "050",
- Self::BHD => "048",
- Self::BMD => "060",
- Self::BND => "096",
- Self::BOB => "068",
- Self::BRL => "986",
- Self::BSD => "044",
- Self::BWP => "072",
- Self::BZD => "084",
- Self::CAD => "124",
- Self::CHF => "756",
- Self::COP => "170",
- Self::CRC => "188",
- Self::CUP => "192",
- Self::CZK => "203",
- Self::DKK => "208",
- Self::DOP => "214",
- Self::DZD => "012",
- Self::EGP => "818",
- Self::ETB => "230",
- Self::EUR => "978",
- Self::FJD => "242",
- Self::GBP => "826",
- Self::GHS => "936",
- Self::GIP => "292",
- Self::GMD => "270",
- Self::GTQ => "320",
- Self::GYD => "328",
- Self::HKD => "344",
- Self::HNL => "340",
- Self::HTG => "332",
- Self::HUF => "348",
- Self::HRK => "191",
- Self::IDR => "360",
- Self::ILS => "376",
- Self::INR => "356",
- Self::JMD => "388",
- Self::JOD => "400",
- Self::JPY => "392",
- Self::KES => "404",
- Self::KGS => "417",
- Self::KHR => "116",
- Self::KRW => "410",
- Self::KWD => "414",
- Self::KYD => "136",
- Self::KZT => "398",
- Self::LAK => "418",
- Self::LBP => "422",
- Self::LKR => "144",
- Self::LRD => "430",
- Self::LSL => "426",
- Self::MAD => "504",
- Self::MDL => "498",
- Self::MKD => "807",
- Self::MMK => "104",
- Self::MNT => "496",
- Self::MOP => "446",
- Self::MUR => "480",
- Self::MVR => "462",
- Self::MWK => "454",
- Self::MXN => "484",
- Self::MYR => "458",
- Self::NAD => "516",
- Self::NGN => "566",
- Self::NIO => "558",
- Self::NOK => "578",
- Self::NPR => "524",
- Self::NZD => "554",
- Self::OMR => "512",
- Self::PEN => "604",
- Self::PGK => "598",
- Self::PHP => "608",
- Self::PKR => "586",
- Self::PLN => "985",
- Self::QAR => "634",
- Self::RON => "946",
- Self::CNY => "156",
- Self::RUB => "643",
- Self::SAR => "682",
- Self::SCR => "690",
- Self::SEK => "752",
- Self::SGD => "702",
- Self::SLL => "694",
- Self::SOS => "706",
- Self::SSP => "728",
- Self::SVC => "222",
- Self::SZL => "748",
- Self::THB => "764",
- Self::TRY => "949",
- Self::TTD => "780",
- Self::TWD => "901",
- Self::TZS => "834",
- Self::USD => "840",
- Self::UYU => "858",
- Self::UZS => "860",
- Self::YER => "886",
- Self::ZAR => "710",
- }
- }
-}
-
#[derive(
Clone,
Copy,
@@ -420,89 +59,6 @@ pub enum EventObjectType {
DisputeDetails,
}
-#[derive(
- Clone,
- Copy,
- Debug,
- Eq,
- PartialEq,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-#[serde(rename_all = "snake_case")]
-#[strum(serialize_all = "snake_case")]
-pub enum EventType {
- PaymentSucceeded,
- PaymentFailed,
- PaymentProcessing,
- ActionRequired,
- RefundSucceeded,
- RefundFailed,
- DisputeOpened,
- DisputeExpired,
- DisputeAccepted,
- DisputeCancelled,
- DisputeChallenged,
- DisputeWon,
- DisputeLost,
-}
-
-#[derive(
- Clone,
- Copy,
- Debug,
- Default,
- Eq,
- Hash,
- PartialEq,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-#[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,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-#[serde(rename_all = "snake_case")]
-#[strum(serialize_all = "snake_case")]
-pub enum FutureUsage {
- #[default]
- OffSession,
- OnSession,
-}
-
#[derive(
Clone,
Copy,
@@ -524,84 +80,6 @@ pub enum MerchantStorageScheme {
RedisKv,
}
-#[derive(
- Clone,
- Copy,
- Debug,
- Eq,
- Hash,
- PartialEq,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-#[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,
- Default,
- Eq,
- Hash,
- PartialEq,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "text")]
-#[serde(rename_all = "snake_case")]
-#[strum(serialize_all = "snake_case")]
-pub enum PaymentMethod {
- #[default]
- Card,
- PayLater,
- Wallet,
- BankRedirect,
- BankTransfer,
- Crypto,
- BankDebit,
- Reward,
- Upi,
-}
-
-#[derive(
- Clone,
- Copy,
- Debug,
- Eq,
- Hash,
- PartialEq,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-#[serde(rename_all = "lowercase")]
-#[strum(serialize_all = "lowercase")]
-pub enum WalletIssuer {
- GooglePay,
- ApplePay,
-}
-
#[derive(
Clone,
Copy,
@@ -629,31 +107,7 @@ pub enum ProcessTrackerStatus {
Finish,
}
-#[derive(
- Clone,
- Copy,
- Debug,
- Default,
- Eq,
- PartialEq,
- serde::Serialize,
- serde::Deserialize,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-#[strum(serialize_all = "snake_case")]
-#[serde(rename_all = "snake_case")]
-pub enum RefundStatus {
- Failure,
- ManualReview,
- #[default]
- Pending,
- Success,
- TransactionFailure,
-}
-
+// Refund
#[derive(
Clone,
Copy,
@@ -697,7 +151,6 @@ pub enum MandateType {
#[default]
MultiUse,
}
-
use diesel::{
backend::Backend,
deserialize::{FromSql, FromSqlRow},
@@ -751,95 +204,12 @@ pub struct MandateAmountData {
Copy,
Debug,
Eq,
- PartialEq,
- Default,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-#[serde(rename_all = "snake_case")]
-#[strum(serialize_all = "snake_case")]
-pub enum MandateStatus {
- #[default]
- Active,
- Inactive,
- Pending,
- Revoked,
-}
-
-#[derive(
- Clone,
- Debug,
- Eq,
Hash,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "text")]
-#[strum(serialize_all = "snake_case")]
-#[serde(rename_all = "snake_case")]
-pub enum PaymentMethodType {
- Ach,
- Affirm,
- AfterpayClearpay,
- AliPay,
- AliPayHk,
- ApplePay,
- Bacs,
- BancontactCard,
- Becs,
- Blik,
- #[serde(rename = "classic")]
- ClassicReward,
- Credit,
- CryptoCurrency,
- Debit,
- Eps,
- Evoucher,
- Giropay,
- GooglePay,
- Ideal,
- Interac,
- Klarna,
- MbWay,
- MobilePay,
- Multibanco,
- OnlineBankingCzechRepublic,
- OnlineBankingFinland,
- OnlineBankingPoland,
- OnlineBankingSlovakia,
- PayBright,
- Paypal,
- Przelewy24,
- SamsungPay,
- Sepa,
- Sofort,
- Swish,
- Trustly,
- UpiCollect,
- Walley,
- WeChatPay,
-}
-
-#[derive(
- Clone,
- Copy,
- Debug,
- Eq,
- Hash,
- PartialEq,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
)]
#[router_derive::diesel_enum(storage_type = "text")]
#[strum(serialize_all = "snake_case")]
@@ -919,106 +289,3 @@ pub enum BankNames {
AliorBank,
Boz,
}
-
-#[derive(
- Clone,
- Debug,
- Eq,
- Hash,
- PartialEq,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "text")]
-pub enum CardNetwork {
- Visa,
- Mastercard,
- AmericanExpress,
- JCB,
- DinersClub,
- Discover,
- CartesBancaires,
- UnionPay,
- Interac,
- RuPay,
- Maestro,
-}
-
-#[derive(
- Eq,
- PartialEq,
- Hash,
- Clone,
- Debug,
- serde::Serialize,
- serde::Deserialize,
- Default,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "text")]
-#[strum(serialize_all = "snake_case")]
-#[serde(rename_all = "snake_case")]
-pub enum PaymentExperience {
- #[default]
- RedirectToUrl,
- InvokeSdkClient,
- DisplayQrCode,
- OneClick,
- LinkWallet,
- InvokePaymentApp,
-}
-
-#[derive(
- Clone,
- Copy,
- Debug,
- Eq,
- PartialEq,
- Default,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-#[serde(rename_all = "snake_case")]
-#[strum(serialize_all = "snake_case")]
-pub enum DisputeStage {
- PreDispute,
- #[default]
- Dispute,
- PreArbitration,
-}
-
-#[derive(
- Clone,
- Copy,
- Debug,
- Eq,
- PartialEq,
- Default,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
- frunk::LabelledGeneric,
-)]
-#[router_derive::diesel_enum(storage_type = "pg_enum")]
-#[serde(rename_all = "snake_case")]
-#[strum(serialize_all = "snake_case")]
-pub enum DisputeStatus {
- #[default]
- DisputeOpened,
- DisputeExpired,
- DisputeAccepted,
- DisputeCancelled,
- DisputeChallenged,
- DisputeWon,
- DisputeLost,
-}
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index 4507d1e98d..4b2fde7f62 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -49,8 +49,6 @@ diesel = { version = "2.1.0", features = ["postgres"] }
dyn-clone = "1.0.11"
encoding_rs = "0.8.32"
error-stack = "0.3.1"
-frunk = "0.4.1"
-frunk_core = "0.4.1"
futures = "0.3.28"
hex = "0.4.3"
http = "0.2.9"
diff --git a/crates/router/src/connector/bluesnap/transformers.rs b/crates/router/src/connector/bluesnap/transformers.rs
index f462360c85..fae7588fbd 100644
--- a/crates/router/src/connector/bluesnap/transformers.rs
+++ b/crates/router/src/connector/bluesnap/transformers.rs
@@ -17,11 +17,7 @@ use crate::{
consts,
core::errors,
pii::Secret,
- types::{
- self, api,
- storage::enums,
- transformers::{ForeignInto, ForeignTryFrom},
- },
+ types::{self, api, storage::enums, transformers::ForeignTryFrom},
utils::{Encode, OptionExt},
};
@@ -353,7 +349,7 @@ impl TryFrom<types::PaymentsSessionResponseRouterData<BluesnapWalletTokenRespons
),
payment_request_data: Some(api_models::payments::ApplePayPaymentRequest {
country_code: item.data.get_billing_country()?,
- currency_code: item.data.request.currency.foreign_into(),
+ currency_code: item.data.request.currency,
total: api_models::payments::AmountInfo {
label: applepay_metadata.data.payment_request_data.label,
total_type: Some("final".to_string()),
diff --git a/crates/router/src/connector/cashtocode.rs b/crates/router/src/connector/cashtocode.rs
index df9f6bb2c9..a68985b1e7 100644
--- a/crates/router/src/connector/cashtocode.rs
+++ b/crates/router/src/connector/cashtocode.rs
@@ -45,10 +45,7 @@ fn get_auth_cashtocode(
payment_method_type: &Option<storage::enums::PaymentMethodType>,
auth_type: &types::ConnectorAuthType,
) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
- match payment_method_type
- .clone()
- .ok_or_else(conn_utils::missing_field_err("payment_method_type"))
- {
+ match (*payment_method_type).ok_or_else(conn_utils::missing_field_err("payment_method_type")) {
Ok(reward_type) => match reward_type {
storage::enums::PaymentMethodType::ClassicReward => match auth_type {
types::ConnectorAuthType::BodyKey { api_key, .. } => Ok(vec![(
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index 84611ecfc3..666207eabc 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -25,7 +25,6 @@ use crate::{
types::{self as domain_types, AsyncLift},
},
storage,
- transformers::ForeignInto,
},
utils::{self, OptionExt},
};
@@ -503,7 +502,7 @@ pub async fn create_payment_connector(
let merchant_connector_account = domain::MerchantConnectorAccount {
merchant_id: merchant_id.to_string(),
- connector_type: req.connector_type.foreign_into(),
+ connector_type: req.connector_type,
connector_name: req.connector_name.to_string(),
merchant_connector_id: utils::generate_id(consts::ID_LENGTH, "mca"),
connector_account_details: domain_types::encrypt(
@@ -670,7 +669,7 @@ pub async fn update_payment_connector(
let payment_connector = storage::MerchantConnectorAccountUpdate::Update {
merchant_id: None,
- connector_type: Some(req.connector_type.foreign_into()),
+ connector_type: Some(req.connector_type),
connector_name: None,
merchant_connector_id: None,
connector_account_details: req
diff --git a/crates/router/src/core/disputes.rs b/crates/router/src/core/disputes.rs
index 2b23bd541d..f83701ae80 100644
--- a/crates/router/src/core/disputes.rs
+++ b/crates/router/src/core/disputes.rs
@@ -16,7 +16,7 @@ use crate::{
api::{self, disputes},
domain,
storage::enums as storage_enums,
- transformers::{ForeignFrom, ForeignInto},
+ transformers::ForeignFrom,
AcceptDisputeRequestData, AcceptDisputeResponse, DefendDisputeRequestData,
DefendDisputeResponse, SubmitEvidenceRequestData, SubmitEvidenceResponse,
},
@@ -145,10 +145,7 @@ pub async fn accept_dispute(
reason: err.reason,
})?;
let update_dispute = diesel_models::dispute::DisputeUpdate::StatusUpdate {
- dispute_status: accept_dispute_response
- .dispute_status
- .clone()
- .foreign_into(),
+ dispute_status: accept_dispute_response.dispute_status,
connector_status: accept_dispute_response.connector_status.clone(),
};
let updated_dispute = db
@@ -308,7 +305,7 @@ pub async fn submit_evidence(
)
};
let update_dispute = diesel_models::dispute::DisputeUpdate::StatusUpdate {
- dispute_status: dispute_status.foreign_into(),
+ dispute_status,
connector_status,
};
let updated_dispute = db
diff --git a/crates/router/src/core/mandate.rs b/crates/router/src/core/mandate.rs
index 2b707f3f6f..0a11aa9bd4 100644
--- a/crates/router/src/core/mandate.rs
+++ b/crates/router/src/core/mandate.rs
@@ -17,7 +17,7 @@ use crate::{
mandates::{self, MandateResponseExt},
},
domain, storage,
- transformers::{ForeignInto, ForeignTryFrom},
+ transformers::ForeignTryFrom,
},
utils::OptionExt,
};
@@ -58,7 +58,7 @@ pub async fn revoke_mandate(
Ok(services::ApplicationResponse::Json(
mandates::MandateRevokedResponse {
mandate_id: mandate.mandate_id,
- status: mandate.mandate_status.foreign_into(),
+ status: mandate.mandate_status,
},
))
}
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 499b8d2419..8cd7f62881 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -64,8 +64,8 @@ pub async fn create_payment_method(
customer_id: customer_id.to_string(),
merchant_id: merchant_id.to_string(),
payment_method_id: payment_method_id.to_string(),
- payment_method: req.payment_method.foreign_into(),
- payment_method_type: req.payment_method_type.map(ForeignInto::foreign_into),
+ payment_method: req.payment_method,
+ payment_method_type: req.payment_method_type,
payment_method_issuer: req.payment_method_issuer.clone(),
scheme: req.card_network.clone(),
metadata: pm_metadata.map(masking::Secret::new),
@@ -159,10 +159,10 @@ pub async fn update_customer_payment_method(
.await?;
};
let new_pm = api::PaymentMethodCreate {
- payment_method: pm.payment_method.foreign_into(),
- payment_method_type: pm.payment_method_type.map(|x| x.foreign_into()),
+ payment_method: pm.payment_method,
+ payment_method_type: pm.payment_method_type,
payment_method_issuer: pm.payment_method_issuer,
- payment_method_issuer_code: pm.payment_method_issuer_code.map(|x| x.foreign_into()),
+ payment_method_issuer_code: pm.payment_method_issuer_code,
card: req.card,
metadata: req.metadata,
customer_id: Some(pm.customer_id),
@@ -1295,9 +1295,7 @@ pub async fn filter_payment_methods(
payment_attempt,
&mut payment_method_object.card_networks,
&address.and_then(|inner| inner.country),
- payment_attempt
- .and_then(|value| value.currency)
- .map(|value| value.foreign_into()),
+ payment_attempt.and_then(|value| value.currency),
);
let filter6 = filter_pm_based_on_allowed_types(
@@ -1617,8 +1615,8 @@ fn filter_payment_currency_based(
) -> bool {
payment_intent.currency.map_or(true, |currency| {
pm.accepted_currencies.as_ref().map_or(true, |ac| match ac {
- admin::AcceptedCurrencies::EnableOnly(acc) => acc.contains(&currency.foreign_into()),
- admin::AcceptedCurrencies::DisableOnly(den) => !den.contains(&currency.foreign_into()),
+ admin::AcceptedCurrencies::EnableOnly(acc) => acc.contains(&currency),
+ admin::AcceptedCurrencies::DisableOnly(den) => !den.contains(&currency),
admin::AcceptedCurrencies::AllAccepted => true,
})
})
@@ -1686,14 +1684,12 @@ pub async fn list_customer_payment_method(
let pma = api::CustomerPaymentMethod {
payment_token: parent_payment_method_token.to_owned(),
customer_id: pm.customer_id,
- payment_method: pm.payment_method.foreign_into(),
- payment_method_type: pm.payment_method_type.map(ForeignInto::foreign_into),
+ payment_method: pm.payment_method,
+ payment_method_type: pm.payment_method_type,
payment_method_issuer: pm.payment_method_issuer,
card,
metadata: pm.metadata,
- payment_method_issuer_code: pm
- .payment_method_issuer_code
- .map(ForeignInto::foreign_into),
+ payment_method_issuer_code: pm.payment_method_issuer_code,
recurring_enabled: false,
installment_payment_enabled: false,
payment_experience: Some(vec![api_models::enums::PaymentExperience::RedirectToUrl]),
@@ -1981,8 +1977,8 @@ pub async fn retrieve_payment_method(
merchant_id: pm.merchant_id,
customer_id: Some(pm.customer_id),
payment_method_id: pm.payment_method_id,
- payment_method: pm.payment_method.foreign_into(),
- payment_method_type: pm.payment_method_type.map(ForeignInto::foreign_into),
+ payment_method: pm.payment_method,
+ payment_method_type: pm.payment_method_type,
card,
metadata: pm.metadata,
created: Some(pm.created_at),
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 64b8c09f18..60b28f102f 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -887,7 +887,7 @@ fn is_payment_method_type_allowed_for_connector(
current_pm_type: &Option<storage::enums::PaymentMethodType>,
pm_type_filter: Option<PaymentMethodTypeTokenFilter>,
) -> bool {
- match current_pm_type.clone().zip(pm_type_filter) {
+ match (*current_pm_type).zip(pm_type_filter) {
Some((pm_type, type_filter)) => match type_filter {
PaymentMethodTypeTokenFilter::AllAccepted => true,
PaymentMethodTypeTokenFilter::EnableOnly(enabled) => enabled.contains(&pm_type),
diff --git a/crates/router/src/core/payments/access_token.rs b/crates/router/src/core/payments/access_token.rs
index 6bae1067b0..067b6c71ac 100644
--- a/crates/router/src/core/payments/access_token.rs
+++ b/crates/router/src/core/payments/access_token.rs
@@ -10,7 +10,7 @@ use crate::{
},
routes::{metrics, AppState},
services,
- types::{self, api as api_types, domain, transformers::ForeignInto},
+ types::{self, api as api_types, domain},
};
/// After we get the access token, check if there was an error and if the flow should proceed further
@@ -59,7 +59,7 @@ pub async fn add_access_token<
) -> RouterResult<types::AddAccessTokenResult> {
if connector
.connector_name
- .supports_access_token(router_data.payment_method.foreign_into())
+ .supports_access_token(router_data.payment_method)
{
let merchant_id = &merchant_account.merchant_id;
let store = &*state.store;
diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs
index e6369d1f82..60935670e5 100644
--- a/crates/router/src/core/payments/flows/authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/authorize_flow.rs
@@ -86,7 +86,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
resp.to_owned(),
maybe_customer,
merchant_account,
- self.request.payment_method_type.clone(),
+ self.request.payment_method_type,
)
.await?;
diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs
index c5d0e3afa8..3b4528406b 100644
--- a/crates/router/src/core/payments/flows/session_flow.rs
+++ b/crates/router/src/core/payments/flows/session_flow.rs
@@ -13,7 +13,7 @@ use crate::{
headers, logger,
routes::{self, metrics},
services,
- types::{self, api, domain, transformers::ForeignInto},
+ types::{self, api, domain},
utils::{self, OptionExt},
};
@@ -190,7 +190,7 @@ async fn create_applepay_session_token(
.change_context(errors::ApiErrorResponse::MissingRequiredField {
field_name: "country_code",
})?,
- currency_code: router_data.request.currency.foreign_into(),
+ currency_code: router_data.request.currency,
total: amount_info,
merchant_capabilities: applepay_metadata
.data
@@ -322,7 +322,7 @@ fn create_gpay_session_token(
let session_data = router_data.request.clone();
let transaction_info = payment_types::GpayTransactionInfo {
country_code: session_data.country.unwrap_or_default(),
- currency_code: router_data.request.currency.foreign_into(),
+ currency_code: router_data.request.currency,
total_price_status: "Final".to_string(),
total_price: utils::to_currency_base_unit(
router_data.request.amount,
diff --git a/crates/router/src/core/payments/flows/verify_flow.rs b/crates/router/src/core/payments/flows/verify_flow.rs
index 6ff56088a3..5b4bb30a66 100644
--- a/crates/router/src/core/payments/flows/verify_flow.rs
+++ b/crates/router/src/core/payments/flows/verify_flow.rs
@@ -69,7 +69,7 @@ impl Feature<api::Verify, types::VerifyRequestData> for types::VerifyRouterData
resp.to_owned(),
maybe_customer,
merchant_account,
- self.request.payment_method_type.clone(),
+ self.request.payment_method_type,
)
.await?;
@@ -183,7 +183,7 @@ impl types::VerifyRouterData {
.await
.to_verify_failed_response()?;
- let payment_method_type = self.request.payment_method_type.clone();
+ let payment_method_type = self.request.payment_method_type;
let pm_id = tokenization::save_payment_method(
state,
connector,
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 392c5622b0..235e4f65b9 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -37,7 +37,6 @@ use crate::{
types::{self, AsyncLift},
},
storage::{self, enums as storage_enums, ephemeral_key, CustomerUpdate::Update},
- transformers::ForeignInto,
ErrorResponse, RouterData,
},
utils::{
@@ -284,8 +283,8 @@ pub async fn get_token_pm_type_mandate_details(
.get_required_value("mandate_data")?;
Ok((
request.payment_token.to_owned(),
- request.payment_method.map(ForeignInto::foreign_into),
- request.payment_method_type.map(ForeignInto::foreign_into),
+ request.payment_method,
+ request.payment_method_type,
Some(setup_mandate),
None,
))
@@ -296,16 +295,15 @@ pub async fn get_token_pm_type_mandate_details(
Ok((
token_,
payment_method_,
- payment_method_type_
- .or_else(|| request.payment_method_type.map(ForeignInto::foreign_into)),
+ payment_method_type_.or(request.payment_method_type),
None,
mandate_connector,
))
}
None => Ok((
request.payment_token.to_owned(),
- request.payment_method.map(ForeignInto::foreign_into),
- request.payment_method_type.map(ForeignInto::foreign_into),
+ request.payment_method,
+ request.payment_method_type,
request.mandate_data.clone(),
None,
)),
@@ -365,7 +363,7 @@ pub async fn get_token_for_recurring_mandate(
let _ =
cards::get_lookup_key_from_locker(state, &token, &payment_method, &locker_id).await?;
if let Some(payment_method_from_request) = req.payment_method {
- let pm: storage_enums::PaymentMethod = payment_method_from_request.foreign_into();
+ let pm: storage_enums::PaymentMethod = payment_method_from_request;
if pm != payment_method.payment_method {
Err(report!(errors::ApiErrorResponse::PreconditionFailed {
message:
@@ -722,7 +720,7 @@ pub fn verify_mandate_details(
utils::when(
mandate
.mandate_currency
- .map(|mandate_currency| mandate_currency != request_currency.foreign_into())
+ .map(|mandate_currency| mandate_currency != request_currency)
.unwrap_or(false),
|| {
Err(report!(errors::ApiErrorResponse::MandateValidationFailed {
@@ -823,8 +821,8 @@ pub(crate) async fn get_payment_method_create_request(
};
let customer_id = customer.customer_id.clone();
let payment_method_request = api::PaymentMethodCreate {
- payment_method: payment_method.foreign_into(),
- payment_method_type: payment_method_type.map(ForeignInto::foreign_into),
+ payment_method,
+ payment_method_type,
payment_method_issuer: card.card_issuer.clone(),
payment_method_issuer_code: None,
card: Some(card_detail),
@@ -839,8 +837,8 @@ pub(crate) async fn get_payment_method_create_request(
}
_ => {
let payment_method_request = api::PaymentMethodCreate {
- payment_method: payment_method.foreign_into(),
- payment_method_type: payment_method_type.map(ForeignInto::foreign_into),
+ payment_method,
+ payment_method_type,
payment_method_issuer: None,
payment_method_issuer_code: None,
card: None,
@@ -1659,14 +1657,14 @@ pub fn generate_mandate(
match data.mandate_type.get_required_value("mandate_type")? {
api::MandateType::SingleUse(data) => new_mandate
.set_mandate_amount(Some(data.amount))
- .set_mandate_currency(Some(data.currency.foreign_into()))
+ .set_mandate_currency(Some(data.currency))
.set_mandate_type(storage_enums::MandateType::SingleUse)
.to_owned(),
api::MandateType::MultiUse(op_data) => match op_data {
Some(data) => new_mandate
.set_mandate_amount(Some(data.amount))
- .set_mandate_currency(Some(data.currency.foreign_into()))
+ .set_mandate_currency(Some(data.currency))
.set_start_date(data.start_date)
.set_end_date(data.end_date)
.set_metadata(data.metadata),
@@ -2493,10 +2491,7 @@ pub async fn get_additional_payment_data(
.map(
|card_info| api_models::payments::AdditionalPaymentData::Card {
card_issuer: card_info.card_issuer,
- card_network: card_info
- .card_network
- .clone()
- .map(|network| network.foreign_into()),
+ card_network: card_info.card_network.clone(),
bank_code: card_info.bank_code,
card_type: card_info.card_type,
card_issuing_country: card_info.card_issuing_country,
diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
index 7ac70ad522..b0dcafda1f 100644
--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs
+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
@@ -59,7 +59,6 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Co
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
payment_intent.setup_future_usage = request
.setup_future_usage
- .map(ForeignInto::foreign_into)
.or(payment_intent.setup_future_usage);
helpers::validate_payment_status_against_not_allowed_statuses(
@@ -113,9 +112,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Co
payment_attempt.browser_info = browser_info;
payment_attempt.payment_method_type =
payment_method_type.or(payment_attempt.payment_method_type);
- payment_attempt.payment_experience = request
- .payment_experience
- .map(|experience| experience.foreign_into());
+ payment_attempt.payment_experience = request.payment_experience;
currency = payment_attempt.currency.get_required_value("currency")?;
amount = payment_attempt.amount.into();
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 810cf181ed..a578f078c9 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -102,7 +102,6 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
payment_intent.setup_future_usage = request
.setup_future_usage
- .map(ForeignInto::foreign_into)
.or(payment_intent.setup_future_usage);
let (token, payment_method, payment_method_type, setup_mandate, mandate_connector) =
@@ -145,13 +144,9 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
payment_attempt.payment_experience = request
.payment_experience
- .map(|experience| experience.foreign_into())
.or(payment_attempt.payment_experience);
- payment_attempt.capture_method = request
- .capture_method
- .or(payment_attempt.capture_method.map(|cm| cm.foreign_into()))
- .map(|cm| cm.foreign_into());
+ payment_attempt.capture_method = request.capture_method.or(payment_attempt.capture_method);
currency = payment_attempt.currency.get_required_value("currency")?;
amount = payment_attempt.amount.into();
@@ -391,8 +386,8 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
.straight_through_algorithm
.clone();
let payment_token = payment_data.token.clone();
- let payment_method_type = payment_data.payment_attempt.payment_method_type.clone();
- let payment_experience = payment_data.payment_attempt.payment_experience.clone();
+ let payment_method_type = payment_data.payment_attempt.payment_method_type;
+ let payment_experience = payment_data.payment_attempt.payment_experience;
let additional_pm_data = payment_data
.payment_method_data
.as_ref()
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index 53b1c80044..b52b1faca9 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -532,15 +532,15 @@ impl PaymentCreate {
currency,
amount: amount.into(),
payment_method,
- capture_method: request.capture_method.map(ForeignInto::foreign_into),
+ capture_method: request.capture_method,
capture_on: request.capture_on,
confirm: request.confirm.unwrap_or(false),
created_at,
modified_at,
last_synced,
- authentication_type: request.authentication_type.map(ForeignInto::foreign_into),
+ authentication_type: request.authentication_type,
browser_info,
- payment_experience: request.payment_experience.map(ForeignInto::foreign_into),
+ payment_experience: request.payment_experience,
payment_method_type,
payment_method_data: additional_pm_data,
amount_to_capture: request.amount_to_capture,
@@ -609,7 +609,7 @@ impl PaymentCreate {
modified_at,
last_synced,
client_secret: Some(client_secret),
- setup_future_usage: request.setup_future_usage.map(ForeignInto::foreign_into),
+ setup_future_usage: request.setup_future_usage,
off_session: request.off_session,
return_url: request.return_url.as_ref().map(|a| a.to_string()),
shipping_address_id,
@@ -678,10 +678,7 @@ impl PaymentCreate {
pub fn payments_create_request_validation(
req: &api::PaymentsRequest,
) -> RouterResult<(api::Amount, enums::Currency)> {
- let currency = req
- .currency
- .map(ForeignInto::foreign_into)
- .get_required_value("currency")?;
+ let currency = req.currency.get_required_value("currency")?;
let amount = req.amount.get_required_value("amount")?;
Ok((amount, currency))
}
diff --git a/crates/router/src/core/payments/operations/payment_method_validate.rs b/crates/router/src/core/payments/operations/payment_method_validate.rs
index d6f42a4542..4e2a7e0101 100644
--- a/crates/router/src/core/payments/operations/payment_method_validate.rs
+++ b/crates/router/src/core/payments/operations/payment_method_validate.rs
@@ -21,7 +21,6 @@ use crate::{
api::{self, enums as api_enums, PaymentIdTypeExt},
domain,
storage::{self, enums as storage_enums},
- transformers::ForeignInto,
},
utils,
};
@@ -322,7 +321,7 @@ impl PaymentMethodValidate {
amount: 0,
currency: Default::default(),
connector: None,
- payment_method: payment_method.map(ForeignInto::foreign_into),
+ payment_method,
confirm: true,
created_at,
modified_at,
@@ -353,7 +352,7 @@ impl PaymentMethodValidate {
modified_at,
last_synced,
client_secret: Some(client_secret),
- setup_future_usage: request.setup_future_usage.map(ForeignInto::foreign_into),
+ setup_future_usage: request.setup_future_usage,
off_session: request.off_session,
active_attempt_id,
attempt_count: 1,
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs
index 20530a5cc1..d25de0d3f2 100644
--- a/crates/router/src/core/payments/operations/payment_update.rs
+++ b/crates/router/src/core/payments/operations/payment_update.rs
@@ -61,7 +61,6 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
payment_intent.setup_future_usage = request
.setup_future_usage
- .map(ForeignInto::foreign_into)
.or(payment_intent.setup_future_usage);
helpers::validate_card_data(request.payment_method_data.clone())?;
@@ -106,10 +105,10 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
- currency = match request.currency {
- Some(cur) => cur.foreign_into(),
- None => payment_attempt.currency.get_required_value("currency")?,
- };
+ currency = request
+ .currency
+ .or(payment_attempt.currency)
+ .get_required_value("currency")?;
payment_attempt.payment_method = payment_method.or(payment_attempt.payment_method);
payment_attempt.payment_method_type =
@@ -441,8 +440,8 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
let business_sub_label = payment_data.payment_attempt.business_sub_label.clone();
- let payment_method_type = payment_data.payment_attempt.payment_method_type.clone();
- let payment_experience = payment_data.payment_attempt.payment_experience.clone();
+ let payment_method_type = payment_data.payment_attempt.payment_method_type;
+ let payment_experience = payment_data.payment_attempt.payment_experience;
let amount_to_capture = payment_data.payment_attempt.amount_to_capture;
let capture_method = payment_data.payment_attempt.capture_method;
payment_data.payment_attempt = db
@@ -604,22 +603,18 @@ impl PaymentUpdate {
.business_sub_label
.clone()
.map(|bsl| payment_attempt.business_sub_label.replace(bsl));
- request.payment_method_type.map(|pmt| {
- payment_attempt
- .payment_method_type
- .replace(pmt.foreign_into())
- });
- request.payment_experience.map(|experience| {
- payment_attempt
- .payment_experience
- .replace(experience.foreign_into())
- });
+ request
+ .payment_method_type
+ .map(|pmt| payment_attempt.payment_method_type.replace(pmt));
+ request
+ .payment_experience
+ .map(|experience| payment_attempt.payment_experience.replace(experience));
payment_attempt.amount_to_capture = request
.amount_to_capture
.or(payment_attempt.amount_to_capture);
request
.capture_method
- .map(|i| payment_attempt.capture_method.replace(i.foreign_into()));
+ .map(|i| payment_attempt.capture_method.replace(i));
}
fn populate_payment_intent_with_request(
payment_intent: &mut storage::PaymentIntent,
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 04acb811e4..6aabf66deb 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -237,10 +237,7 @@ where
.as_ref()
.and_then(|cus| cus.phone.as_ref().map(|s| s.to_owned())),
mandate_id: data.mandate_id.map(|mandate_ids| mandate_ids.mandate_id),
- payment_method: data
- .payment_attempt
- .payment_method
- .map(ForeignInto::foreign_into),
+ payment_method: data.payment_attempt.payment_method,
payment_method_data: data
.payment_method_data
.map(api::PaymentMethodDataResponse::from),
@@ -382,7 +379,7 @@ where
response
.set_payment_id(Some(payment_attempt.payment_id))
.set_merchant_id(Some(payment_attempt.merchant_id))
- .set_status(payment_intent.status.foreign_into())
+ .set_status(payment_intent.status)
.set_amount(payment_attempt.amount)
.set_amount_capturable(amount_capturable)
.set_amount_received(payment_intent.amount_captured)
@@ -411,9 +408,7 @@ where
.set_refunds(refunds_response) // refunds.iter().map(refund_to_refund_response),
.set_disputes(disputes_response)
.set_payment_method(
- payment_attempt
- .payment_method
- .map(ForeignInto::foreign_into),
+ payment_attempt.payment_method,
auth_flow == services::AuthFlow::Merchant,
)
.set_payment_method_data(
@@ -428,33 +423,13 @@ where
.set_next_action(next_action_response)
.set_return_url(payment_intent.return_url)
.set_cancellation_reason(payment_attempt.cancellation_reason)
- .set_authentication_type(
- payment_attempt
- .authentication_type
- .map(ForeignInto::foreign_into),
- )
+ .set_authentication_type(payment_attempt.authentication_type)
.set_statement_descriptor_name(payment_intent.statement_descriptor_name)
.set_statement_descriptor_suffix(payment_intent.statement_descriptor_suffix)
- .set_setup_future_usage(
- payment_intent
- .setup_future_usage
- .map(ForeignInto::foreign_into),
- )
- .set_capture_method(
- payment_attempt
- .capture_method
- .map(ForeignInto::foreign_into),
- )
- .set_payment_experience(
- payment_attempt
- .payment_experience
- .map(ForeignInto::foreign_into),
- )
- .set_payment_method_type(
- payment_attempt
- .payment_method_type
- .map(ForeignInto::foreign_into),
- )
+ .set_setup_future_usage(payment_intent.setup_future_usage)
+ .set_capture_method(payment_attempt.capture_method)
+ .set_payment_experience(payment_attempt.payment_experience)
+ .set_payment_method_type(payment_attempt.payment_method_type)
.set_metadata(payment_intent.metadata)
.set_order_details(payment_intent.order_details)
.set_connector_label(connector_label)
@@ -480,7 +455,7 @@ where
None => services::ApplicationResponse::Json(api::PaymentsResponse {
payment_id: Some(payment_attempt.payment_id),
merchant_id: Some(payment_attempt.merchant_id),
- status: payment_intent.status.foreign_into(),
+ status: payment_intent.status,
amount: payment_attempt.amount,
amount_capturable: None,
amount_received: payment_intent.amount_captured,
@@ -491,12 +466,8 @@ where
description: payment_intent.description,
refunds: refunds_response,
disputes: disputes_response,
- payment_method: payment_attempt
- .payment_method
- .map(ForeignInto::foreign_into),
- capture_method: payment_attempt
- .capture_method
- .map(ForeignInto::foreign_into),
+ payment_method: payment_attempt.payment_method,
+ capture_method: payment_attempt.capture_method,
error_message: payment_attempt.error_message,
error_code: payment_attempt.error_code,
payment_method_data: payment_method_data.map(api::PaymentMethodDataResponse::from),
@@ -590,7 +561,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
Self {
payment_id: Some(pi.payment_id),
merchant_id: Some(pi.merchant_id),
- status: pi.status.foreign_into(),
+ status: pi.status,
amount: pi.amount,
amount_capturable: pi.amount_captured,
client_secret: pi.client_secret.map(|s| s.into()),
@@ -601,8 +572,8 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
order_details: pi.order_details,
customer_id: pi.customer_id,
connector: pa.connector,
- payment_method: pa.payment_method.map(ForeignInto::foreign_into),
- payment_method_type: pa.payment_method_type.map(ForeignInto::foreign_into),
+ payment_method: pa.payment_method,
+ payment_method_type: pa.payment_method_type,
..Default::default()
}
}
@@ -612,21 +583,9 @@ impl ForeignFrom<PaymentListFilters> for api_models::payments::PaymentListFilter
fn foreign_from(item: PaymentListFilters) -> Self {
Self {
connector: item.connector,
- currency: item
- .currency
- .into_iter()
- .map(ForeignInto::foreign_into)
- .collect(),
- status: item
- .status
- .into_iter()
- .map(ForeignInto::foreign_into)
- .collect(),
- payment_method: item
- .payment_method
- .into_iter()
- .map(ForeignInto::foreign_into)
- .collect(),
+ currency: item.currency,
+ status: item.status,
+ payment_method: item.payment_method,
}
}
}
@@ -960,7 +919,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::VerifyRequestDat
email: payment_data.email,
return_url: payment_data.payment_intent.return_url,
browser_info,
- payment_method_type: attempt.payment_method_type.clone(),
+ payment_method_type: attempt.payment_method_type,
})
}
}
diff --git a/crates/router/src/core/refunds/validator.rs b/crates/router/src/core/refunds/validator.rs
index 9d408aa94d..ec5d138639 100644
--- a/crates/router/src/core/refunds/validator.rs
+++ b/crates/router/src/core/refunds/validator.rs
@@ -157,7 +157,6 @@ pub fn validate_for_valid_refunds(
| diesel_models::enums::PaymentMethod::Wallet => {
let payment_method_type = payment_attempt
.payment_method_type
- .clone()
.get_required_value("payment_method_type")?;
utils::when(
diff --git a/crates/router/src/core/webhooks.rs b/crates/router/src/core/webhooks.rs
index 5d7bc4840b..5f0201fb74 100644
--- a/crates/router/src/core/webhooks.rs
+++ b/crates/router/src/core/webhooks.rs
@@ -266,7 +266,7 @@ pub async fn get_or_update_dispute_object(
dispute_id,
amount: dispute_details.amount,
currency: dispute_details.currency,
- dispute_stage: dispute_details.dispute_stage.foreign_into(),
+ dispute_stage: dispute_details.dispute_stage,
dispute_status: event_type
.foreign_try_into()
.into_report()
@@ -300,15 +300,15 @@ pub async fn get_or_update_dispute_object(
.change_context(errors::ApiErrorResponse::WebhookProcessingFailure)
.attach_printable("event type to dispute state conversion failure")?;
crate::core::utils::validate_dispute_stage_and_dispute_status(
- dispute.dispute_stage.foreign_into(),
- dispute.dispute_status.foreign_into(),
- dispute_details.dispute_stage.clone(),
- dispute_status.foreign_into(),
+ dispute.dispute_stage,
+ dispute.dispute_status,
+ dispute_details.dispute_stage,
+ dispute_status,
)
.change_context(errors::ApiErrorResponse::WebhookProcessingFailure)
.attach_printable("dispute stage and status validation failed")?;
let update_dispute = diesel_models::dispute::DisputeUpdate::Update {
- dispute_stage: dispute_details.dispute_stage.foreign_into(),
+ dispute_stage: dispute_details.dispute_stage,
dispute_status,
connector_status: dispute_details.connector_status,
connector_reason: dispute_details.connector_reason,
@@ -500,7 +500,7 @@ pub async fn create_event_and_trigger_outgoing_webhook<W: api::OutgoingWebhookTy
let outgoing_webhook = api::OutgoingWebhook {
merchant_id: merchant_account.merchant_id.clone(),
event_id: event.event_id,
- event_type: event.event_type.foreign_into(),
+ event_type: event.event_type,
content,
timestamp: event.created_at,
};
diff --git a/crates/router/src/db/dispute.rs b/crates/router/src/db/dispute.rs
index 645cc907bb..17265fe06b 100644
--- a/crates/router/src/db/dispute.rs
+++ b/crates/router/src/db/dispute.rs
@@ -1,14 +1,10 @@
-use api_models::enums::{DisputeStage, DisputeStatus};
use error_stack::IntoReport;
use super::{MockDb, Store};
use crate::{
connection,
core::errors::{self, CustomResult},
- types::{
- storage::{self, DisputeDbExt},
- transformers::ForeignFrom,
- },
+ types::storage::{self, DisputeDbExt},
};
#[async_trait::async_trait]
@@ -226,12 +222,12 @@ impl DisputeInterface for MockDb {
&& dispute_constraints
.dispute_status
.as_ref()
- .map(|status| status == &DisputeStatus::foreign_from(d.dispute_status))
+ .map(|status| status == &d.dispute_status)
.unwrap_or(true)
&& dispute_constraints
.dispute_stage
.as_ref()
- .map(|stage| stage == &DisputeStage::foreign_from(d.dispute_stage))
+ .map(|stage| stage == &d.dispute_stage)
.unwrap_or(true)
&& dispute_constraints
.reason
diff --git a/crates/router/src/db/mandate.rs b/crates/router/src/db/mandate.rs
index bd8f1624b5..02d04a040d 100644
--- a/crates/router/src/db/mandate.rs
+++ b/crates/router/src/db/mandate.rs
@@ -4,10 +4,7 @@ use super::{MockDb, Store};
use crate::{
connection,
core::{errors, errors::CustomResult},
- types::{
- storage::{self, MandateDbExt},
- transformers::ForeignInto,
- },
+ types::storage::{self, MandateDbExt},
};
#[async_trait::async_trait]
@@ -201,9 +198,7 @@ impl MandateInterface for MockDb {
checker &= mandate.connector == *connector;
}
if let Some(mandate_status) = mandate_constraints.mandate_status {
- let storage_mandate_status: diesel_models::enums::MandateStatus =
- mandate_status.foreign_into();
- checker &= mandate.mandate_status == storage_mandate_status;
+ checker &= mandate.mandate_status == mandate_status;
}
checker
});
diff --git a/crates/router/src/db/payment_attempt.rs b/crates/router/src/db/payment_attempt.rs
index cf66c6da30..3cf833fc91 100644
--- a/crates/router/src/db/payment_attempt.rs
+++ b/crates/router/src/db/payment_attempt.rs
@@ -464,8 +464,8 @@ mod storage {
payment_token: payment_attempt.payment_token.clone(),
error_code: payment_attempt.error_code.clone(),
connector_metadata: payment_attempt.connector_metadata.clone(),
- payment_experience: payment_attempt.payment_experience.clone(),
- payment_method_type: payment_attempt.payment_method_type.clone(),
+ payment_experience: payment_attempt.payment_experience,
+ payment_method_type: payment_attempt.payment_method_type,
payment_method_data: payment_attempt.payment_method_data.clone(),
business_sub_label: payment_attempt.business_sub_label.clone(),
straight_through_algorithm: payment_attempt
diff --git a/crates/router/src/db/refund.rs b/crates/router/src/db/refund.rs
index 8e9a778da7..df2b2edf10 100644
--- a/crates/router/src/db/refund.rs
+++ b/crates/router/src/db/refund.rs
@@ -4,8 +4,6 @@ use std::collections::HashSet;
use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal};
use super::MockDb;
-#[cfg(feature = "olap")]
-use crate::types::transformers::ForeignInto;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums},
@@ -865,10 +863,10 @@ impl RefundInterface for MockDb {
for refund in filtered_refunds.into_iter() {
unique_connectors.insert(refund.connector);
- let currency: api_models::enums::Currency = refund.currency.foreign_into();
+ let currency: api_models::enums::Currency = refund.currency;
unique_currencies.insert(currency);
- let status: api_models::enums::RefundStatus = refund.refund_status.foreign_into();
+ let status: api_models::enums::RefundStatus = refund.refund_status;
unique_statuses.insert(status);
}
diff --git a/crates/router/src/types/api/mandates.rs b/crates/router/src/types/api/mandates.rs
index dfd9ba124b..4a56205800 100644
--- a/crates/router/src/types/api/mandates.rs
+++ b/crates/router/src/types/api/mandates.rs
@@ -13,7 +13,6 @@ use crate::{
types::{
api, domain,
storage::{self, enums as storage_enums},
- transformers::ForeignInto,
},
};
@@ -76,7 +75,7 @@ impl MandateResponseExt for MandateResponse {
}),
}),
card,
- status: mandate.mandate_status.foreign_into(),
+ status: mandate.mandate_status,
payment_method: payment_method.payment_method.to_string(),
payment_method_id: mandate.payment_method_id,
})
diff --git a/crates/router/src/types/domain/address.rs b/crates/router/src/types/domain/address.rs
index cb84e4fb8a..d80ac45783 100644
--- a/crates/router/src/types/domain/address.rs
+++ b/crates/router/src/types/domain/address.rs
@@ -129,7 +129,7 @@ impl behaviour::Conversion for Address {
}
}
-#[derive(Debug, frunk::LabelledGeneric)]
+#[derive(Debug)]
pub enum AddressUpdate {
Update {
city: Option<String>,
diff --git a/crates/router/src/types/storage/dispute.rs b/crates/router/src/types/storage/dispute.rs
index d037aa94aa..01b1ea01ca 100644
--- a/crates/router/src/types/storage/dispute.rs
+++ b/crates/router/src/types/storage/dispute.rs
@@ -5,7 +5,7 @@ pub use diesel_models::dispute::{Dispute, DisputeNew, DisputeUpdate};
use diesel_models::{errors, schema::dispute::dsl};
use error_stack::{IntoReport, ResultExt};
-use crate::{connection::PgPooledConn, logger, types::transformers::ForeignInto};
+use crate::{connection::PgPooledConn, logger};
#[async_trait::async_trait]
pub trait DisputeDbExt: Sized {
@@ -50,14 +50,10 @@ impl DisputeDbExt for Dispute {
filter = filter.filter(dsl::connector_reason.eq(reason));
}
if let Some(dispute_stage) = dispute_list_constraints.dispute_stage {
- let storage_dispute_stage: diesel_models::enums::DisputeStage =
- dispute_stage.foreign_into();
- filter = filter.filter(dsl::dispute_stage.eq(storage_dispute_stage));
+ filter = filter.filter(dsl::dispute_stage.eq(dispute_stage));
}
if let Some(dispute_status) = dispute_list_constraints.dispute_status {
- let storage_dispute_status: diesel_models::enums::DisputeStatus =
- dispute_status.foreign_into();
- filter = filter.filter(dsl::dispute_status.eq(storage_dispute_status));
+ filter = filter.filter(dsl::dispute_status.eq(dispute_status));
}
if let Some(limit) = dispute_list_constraints.limit {
filter = filter.limit(limit);
diff --git a/crates/router/src/types/storage/mandate.rs b/crates/router/src/types/storage/mandate.rs
index 4d4199ab53..32c0798e95 100644
--- a/crates/router/src/types/storage/mandate.rs
+++ b/crates/router/src/types/storage/mandate.rs
@@ -7,7 +7,7 @@ pub use diesel_models::mandate::{
use diesel_models::{errors, schema::mandate::dsl};
use error_stack::{IntoReport, ResultExt};
-use crate::{connection::PgPooledConn, logger, types::transformers::ForeignInto};
+use crate::{connection::PgPooledConn, logger};
#[async_trait::async_trait]
pub trait MandateDbExt: Sized {
@@ -49,9 +49,7 @@ impl MandateDbExt for Mandate {
filter = filter.filter(dsl::connector.eq(connector));
}
if let Some(mandate_status) = mandate_list_constraints.mandate_status {
- let storage_mandate_status: diesel_models::enums::MandateStatus =
- mandate_status.foreign_into();
- filter = filter.filter(dsl::mandate_status.eq(storage_mandate_status));
+ filter = filter.filter(dsl::mandate_status.eq(mandate_status));
}
if let Some(limit) = mandate_list_constraints.limit {
filter = filter.limit(limit);
diff --git a/crates/router/src/types/storage/refund.rs b/crates/router/src/types/storage/refund.rs
index d174b07e83..8f3be72342 100644
--- a/crates/router/src/types/storage/refund.rs
+++ b/crates/router/src/types/storage/refund.rs
@@ -11,7 +11,7 @@ use diesel_models::{
};
use error_stack::{IntoReport, ResultExt};
-use crate::{connection::PgPooledConn, logger, types::transformers::ForeignInto};
+use crate::{connection::PgPooledConn, logger};
#[cfg(feature = "kv_store")]
impl crate::utils::storage_partitioning::KvStorePartition for Refund {}
@@ -69,19 +69,11 @@ impl RefundDbExt for Refund {
}
if let Some(filter_currency) = &refund_list_details.currency {
- let currency: Vec<Currency> = filter_currency
- .iter()
- .map(|currency| (*currency).foreign_into())
- .collect();
- filter = filter.filter(dsl::currency.eq_any(currency));
+ filter = filter.filter(dsl::currency.eq_any(filter_currency.clone()));
}
if let Some(filter_refund_status) = &refund_list_details.refund_status {
- let refund_status: Vec<RefundStatus> = filter_refund_status
- .iter()
- .map(|refund_status| (*refund_status).foreign_into())
- .collect();
- filter = filter.filter(dsl::refund_status.eq_any(refund_status));
+ filter = filter.filter(dsl::refund_status.eq_any(filter_refund_status.clone()));
}
logger::debug!(query = %diesel::debug_query::<diesel::pg::Pg, _>(&filter).to_string());
@@ -145,14 +137,8 @@ impl RefundDbExt for Refund {
let meta = api_models::refunds::RefundListMetaData {
connector: filter_connector,
- currency: filter_currency
- .into_iter()
- .map(|curr| curr.foreign_into())
- .collect(),
- status: filter_status
- .into_iter()
- .map(|curr| curr.foreign_into())
- .collect(),
+ currency: filter_currency,
+ status: filter_status,
};
Ok(meta)
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 33f653c3f2..f9a00d1428 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -50,18 +50,6 @@ where
}
}
-impl ForeignFrom<api_enums::ConnectorType> for storage_enums::ConnectorType {
- fn foreign_from(conn: api_enums::ConnectorType) -> Self {
- frunk::labelled_convert_from(conn)
- }
-}
-
-impl ForeignFrom<storage_enums::ConnectorType> for api_enums::ConnectorType {
- fn foreign_from(conn: storage_enums::ConnectorType) -> Self {
- frunk::labelled_convert_from(conn)
- }
-}
-
impl ForeignFrom<api_models::refunds::RefundType> for storage_enums::RefundType {
fn foreign_from(item: api_models::refunds::RefundType) -> Self {
match item {
@@ -71,60 +59,6 @@ impl ForeignFrom<api_models::refunds::RefundType> for storage_enums::RefundType
}
}
-impl ForeignFrom<storage_enums::MandateStatus> for api_enums::MandateStatus {
- fn foreign_from(status: storage_enums::MandateStatus) -> Self {
- frunk::labelled_convert_from(status)
- }
-}
-
-impl ForeignFrom<api_enums::MandateStatus> for storage_enums::MandateStatus {
- fn foreign_from(status: api_enums::MandateStatus) -> Self {
- frunk::labelled_convert_from(status)
- }
-}
-
-impl ForeignFrom<api_enums::PaymentMethod> for storage_enums::PaymentMethod {
- fn foreign_from(pm_type: api_enums::PaymentMethod) -> Self {
- frunk::labelled_convert_from(pm_type)
- }
-}
-
-impl ForeignFrom<storage_enums::PaymentMethod> for api_enums::PaymentMethod {
- fn foreign_from(pm_type: storage_enums::PaymentMethod) -> Self {
- frunk::labelled_convert_from(pm_type)
- }
-}
-
-impl ForeignFrom<storage_enums::PaymentMethodIssuerCode> for api_enums::PaymentMethodIssuerCode {
- fn foreign_from(issuer_code: storage_enums::PaymentMethodIssuerCode) -> Self {
- frunk::labelled_convert_from(issuer_code)
- }
-}
-
-impl ForeignFrom<api_enums::PaymentExperience> for storage_enums::PaymentExperience {
- fn foreign_from(experience: api_enums::PaymentExperience) -> Self {
- frunk::labelled_convert_from(experience)
- }
-}
-
-impl ForeignFrom<storage_enums::PaymentExperience> for api_enums::PaymentExperience {
- fn foreign_from(experience: storage_enums::PaymentExperience) -> Self {
- frunk::labelled_convert_from(experience)
- }
-}
-
-impl ForeignFrom<storage_enums::IntentStatus> for api_enums::IntentStatus {
- fn foreign_from(status: storage_enums::IntentStatus) -> Self {
- frunk::labelled_convert_from(status)
- }
-}
-
-impl ForeignFrom<api_enums::IntentStatus> for storage_enums::IntentStatus {
- fn foreign_from(status: api_enums::IntentStatus) -> Self {
- frunk::labelled_convert_from(status)
- }
-}
-
impl ForeignFrom<storage_enums::AttemptStatus> for storage_enums::IntentStatus {
fn foreign_from(s: storage_enums::AttemptStatus) -> Self {
match s {
@@ -192,7 +126,7 @@ impl ForeignFrom<storage_enums::MandateAmountData> for api_models::payments::Man
fn foreign_from(from: storage_enums::MandateAmountData) -> Self {
Self {
amount: from.amount,
- currency: from.currency.foreign_into(),
+ currency: from.currency,
start_date: from.start_date,
end_date: from.end_date,
metadata: from.metadata,
@@ -204,7 +138,7 @@ impl ForeignFrom<api_models::payments::MandateAmountData> for storage_enums::Man
fn foreign_from(from: api_models::payments::MandateAmountData) -> Self {
Self {
amount: from.amount,
- currency: from.currency.foreign_into(),
+ currency: from.currency,
start_date: from.start_date,
end_date: from.end_date,
metadata: from.metadata,
@@ -322,72 +256,6 @@ impl ForeignTryFrom<api_models::webhooks::IncomingWebhookEvent> for storage_enum
}
}
-impl ForeignFrom<storage_enums::EventType> for api_enums::EventType {
- fn foreign_from(event_type: storage_enums::EventType) -> Self {
- frunk::labelled_convert_from(event_type)
- }
-}
-
-impl ForeignFrom<api_enums::FutureUsage> for storage_enums::FutureUsage {
- fn foreign_from(future_usage: api_enums::FutureUsage) -> Self {
- frunk::labelled_convert_from(future_usage)
- }
-}
-
-impl ForeignFrom<storage_enums::FutureUsage> for api_enums::FutureUsage {
- fn foreign_from(future_usage: storage_enums::FutureUsage) -> Self {
- frunk::labelled_convert_from(future_usage)
- }
-}
-
-impl ForeignFrom<storage_enums::RefundStatus> for api_enums::RefundStatus {
- fn foreign_from(status: storage_enums::RefundStatus) -> Self {
- frunk::labelled_convert_from(status)
- }
-}
-
-impl ForeignFrom<api_enums::RefundStatus> for storage_enums::RefundStatus {
- fn foreign_from(status: api_enums::RefundStatus) -> Self {
- frunk::labelled_convert_from(status)
- }
-}
-
-impl ForeignFrom<api_enums::CaptureMethod> for storage_enums::CaptureMethod {
- fn foreign_from(capture_method: api_enums::CaptureMethod) -> Self {
- frunk::labelled_convert_from(capture_method)
- }
-}
-
-impl ForeignFrom<storage_enums::CaptureMethod> for api_enums::CaptureMethod {
- fn foreign_from(capture_method: storage_enums::CaptureMethod) -> Self {
- frunk::labelled_convert_from(capture_method)
- }
-}
-
-impl ForeignFrom<api_enums::AuthenticationType> for storage_enums::AuthenticationType {
- fn foreign_from(auth_type: api_enums::AuthenticationType) -> Self {
- frunk::labelled_convert_from(auth_type)
- }
-}
-
-impl ForeignFrom<storage_enums::AuthenticationType> for api_enums::AuthenticationType {
- fn foreign_from(auth_type: storage_enums::AuthenticationType) -> Self {
- frunk::labelled_convert_from(auth_type)
- }
-}
-
-impl ForeignFrom<api_enums::Currency> for storage_enums::Currency {
- fn foreign_from(currency: api_enums::Currency) -> Self {
- frunk::labelled_convert_from(currency)
- }
-}
-
-impl ForeignFrom<storage_enums::Currency> for api_enums::Currency {
- fn foreign_from(currency: storage_enums::Currency) -> Self {
- frunk::labelled_convert_from(currency)
- }
-}
-
impl ForeignFrom<storage::Config> for api_types::Config {
fn foreign_from(config: storage::Config) -> Self {
let config = config;
@@ -430,18 +298,6 @@ impl<'a> From<&'a domain::Address> for api_types::Address {
}
}
-impl ForeignFrom<api_models::enums::PaymentMethodType> for diesel_models::enums::PaymentMethodType {
- fn foreign_from(payment_method_type: api_models::enums::PaymentMethodType) -> Self {
- frunk::labelled_convert_from(payment_method_type)
- }
-}
-
-impl ForeignFrom<diesel_models::enums::PaymentMethodType> for api_models::enums::PaymentMethodType {
- fn foreign_from(payment_method_type: diesel_models::enums::PaymentMethodType) -> Self {
- frunk::labelled_convert_from(payment_method_type)
- }
-}
-
impl
ForeignFrom<(
diesel_models::api_keys::ApiKey,
@@ -496,36 +352,6 @@ impl ForeignFrom<api_models::api_keys::UpdateApiKeyRequest>
}
}
-impl ForeignFrom<storage_enums::AttemptStatus> for api_enums::AttemptStatus {
- fn foreign_from(status: storage_enums::AttemptStatus) -> Self {
- frunk::labelled_convert_from(status)
- }
-}
-
-impl ForeignFrom<api_enums::DisputeStage> for storage_enums::DisputeStage {
- fn foreign_from(status: api_enums::DisputeStage) -> Self {
- frunk::labelled_convert_from(status)
- }
-}
-
-impl ForeignFrom<api_enums::DisputeStatus> for storage_enums::DisputeStatus {
- fn foreign_from(status: api_enums::DisputeStatus) -> Self {
- frunk::labelled_convert_from(status)
- }
-}
-
-impl ForeignFrom<storage_enums::DisputeStage> for api_enums::DisputeStage {
- fn foreign_from(status: storage_enums::DisputeStage) -> Self {
- frunk::labelled_convert_from(status)
- }
-}
-
-impl ForeignFrom<storage_enums::DisputeStatus> for api_enums::DisputeStatus {
- fn foreign_from(status: storage_enums::DisputeStatus) -> Self {
- frunk::labelled_convert_from(status)
- }
-}
-
impl ForeignTryFrom<api_models::webhooks::IncomingWebhookEvent> for storage_enums::DisputeStatus {
type Error = errors::ValidationError;
@@ -561,8 +387,8 @@ impl ForeignFrom<storage::Dispute> for api_models::disputes::DisputeResponse {
attempt_id: dispute.attempt_id,
amount: dispute.amount,
currency: dispute.currency,
- dispute_stage: dispute.dispute_stage.foreign_into(),
- dispute_status: dispute.dispute_status.foreign_into(),
+ dispute_stage: dispute.dispute_stage,
+ dispute_status: dispute.dispute_status,
connector: dispute.connector,
connector_status: dispute.connector_status,
connector_dispute_id: dispute.connector_dispute_id,
@@ -580,8 +406,8 @@ impl ForeignFrom<storage::Dispute> for api_models::disputes::DisputeResponsePaym
fn foreign_from(dispute: storage::Dispute) -> Self {
Self {
dispute_id: dispute.dispute_id,
- dispute_stage: dispute.dispute_stage.foreign_into(),
- dispute_status: dispute.dispute_status.foreign_into(),
+ dispute_stage: dispute.dispute_stage,
+ dispute_status: dispute.dispute_status,
connector_status: dispute.connector_status,
connector_dispute_id: dispute.connector_dispute_id,
connector_reason: dispute.connector_reason,
@@ -643,7 +469,7 @@ impl TryFrom<domain::MerchantConnectorAccount> for api_models::admin::MerchantCo
None => None,
};
Ok(Self {
- connector_type: item.connector_type.foreign_into(),
+ connector_type: item.connector_type,
connector_name: item.connector_name,
connector_label: item.connector_label,
merchant_connector_id: item.merchant_connector_id,
@@ -659,9 +485,3 @@ impl TryFrom<domain::MerchantConnectorAccount> for api_models::admin::MerchantCo
})
}
}
-
-impl ForeignFrom<diesel_models::enums::CardNetwork> for api_models::enums::CardNetwork {
- fn foreign_from(source: diesel_models::enums::CardNetwork) -> Self {
- frunk::labelled_convert_from(source)
- }
-}