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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(payment_attempt_v2): add payment attempt v2 domain and diesel models (#6027)
Narayan Bhatc7bb9ccda3ce
diff --git a/crates/api_models/Cargo.toml b/crates/api_models/Cargo.tomlindex c16b1d9a41..e8668aab50 100644--- a/crates/api_models/Cargo.toml+++ b/crates/api_models/Cargo.toml@@ -19,7 +19,6 @@ recon = []v1 = ["common_utils/v1"]v2 = ["common_utils/v2", "customer_v2"]customer_v2 = ["common_utils/customer_v2"]-payment_v2 = []payment_methods_v2 = ["common_utils/payment_methods_v2"][dependencies]diff --git a/crates/diesel_models/Cargo.toml b/crates/diesel_models/Cargo.tomlindex 6b28889977..02d917f3b1 100644--- a/crates/diesel_models/Cargo.toml+++ b/crates/diesel_models/Cargo.toml@@ -13,7 +13,6 @@ kv_store = []v1 = []v2 = []customer_v2 = []-payment_v2 = []payment_methods_v2 = [][dependencies]diff --git a/crates/diesel_models/src/kv.rs b/crates/diesel_models/src/kv.rsindex 1cf7fc9d81..d91e57a2b5 100644--- a/crates/diesel_models/src/kv.rs+++ b/crates/diesel_models/src/kv.rs@@ -1,7 +1,7 @@use error_stack::ResultExt;use serde::{Deserialize, Serialize};-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]use crate::payment_attempt::PaymentAttemptUpdateInternal;use crate::{address::{Address, AddressNew, AddressUpdateInternal},@@ -111,11 +111,11 @@ impl DBOperation {Updateable::PaymentIntentUpdate(a) => {DBResult::PaymentIntent(Box::new(a.orig.update(conn, a.update_data).await?))}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]Updateable::PaymentAttemptUpdate(a) => DBResult::PaymentAttempt(Box::new(a.orig.update_with_attempt_id(conn, a.update_data).await?,)),- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]Updateable::PaymentAttemptUpdate(a) => DBResult::PaymentAttempt(Box::new(a.orig.update_with_attempt_id(diff --git a/crates/diesel_models/src/payment_attempt.rs b/crates/diesel_models/src/payment_attempt.rsindex 63ce905f65..75a9aeda2b 100644--- a/crates/diesel_models/src/payment_attempt.rs+++ b/crates/diesel_models/src/payment_attempt.rs@@ -4,35 +4,24 @@ use serde::{Deserialize, Serialize};use time::PrimitiveDateTime;use crate::enums::{self as storage_enums};-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]use crate::schema::payment_attempt;-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]use crate::schema_v2::payment_attempt;-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]#[derive(Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Serialize, Deserialize, Selectable,)]-#[diesel(table_name = payment_attempt, primary_key(attempt_id, merchant_id), check_for_backend(diesel::pg::Pg))]+#[diesel(table_name = payment_attempt, primary_key(id), check_for_backend(diesel::pg::Pg))]pub struct PaymentAttempt {- pub payment_id: id_type::PaymentId,+ pub payment_id: id_type::GlobalPaymentId,pub merchant_id: id_type::MerchantId,- pub attempt_id: String,pub status: storage_enums::AttemptStatus,- pub amount: MinorUnit,- pub currency: Option<storage_enums::Currency>,- pub save_to_locker: Option<bool>,pub connector: Option<String>,pub error_message: Option<String>,- pub offer_amount: Option<MinorUnit>,pub surcharge_amount: Option<MinorUnit>,- pub tax_amount: Option<MinorUnit>,pub payment_method_id: Option<String>,- pub payment_method: Option<storage_enums::PaymentMethod>,- pub connector_transaction_id: Option<String>,- pub capture_method: Option<storage_enums::CaptureMethod>,- #[serde(default, with = "common_utils::custom_serde::iso8601::option")]- pub capture_on: Option<PrimitiveDateTime>,pub confirm: bool,pub authentication_type: Option<storage_enums::AuthenticationType>,#[serde(with = "common_utils::custom_serde::iso8601")]@@ -43,22 +32,15 @@ pub struct PaymentAttempt {pub last_synced: Option<PrimitiveDateTime>,pub cancellation_reason: Option<String>,pub amount_to_capture: Option<MinorUnit>,- pub mandate_id: Option<String>,pub browser_info: Option<serde_json::Value>,pub error_code: Option<String>,pub payment_token: Option<String>,pub connector_metadata: Option<serde_json::Value>,pub payment_experience: Option<storage_enums::PaymentExperience>,- pub payment_method_type: Option<storage_enums::PaymentMethodType>,pub payment_method_data: Option<serde_json::Value>,- pub business_sub_label: Option<String>,- pub straight_through_algorithm: Option<serde_json::Value>,pub preprocessing_step_id: Option<String>,- // providing a location to store mandate details intermediately for transaction- pub mandate_details: Option<storage_enums::MandateDataType>,pub error_reason: Option<String>,pub multiple_capture_count: Option<i16>,- // reference to the payment at connector sidepub connector_response_reference_id: Option<String>,pub amount_capturable: MinorUnit,pub updated_by: String,@@ -71,7 +53,6 @@ pub struct PaymentAttempt {pub external_three_ds_authentication_attempted: Option<bool>,pub authentication_connector: Option<String>,pub authentication_id: Option<String>,- pub mandate_data: Option<storage_enums::MandateDetails>,pub fingerprint_id: Option<String>,pub payment_method_billing_address_id: Option<String>,pub charge_id: Option<String>,@@ -81,11 +62,19 @@ pub struct PaymentAttempt {pub profile_id: id_type::ProfileId,pub organization_id: id_type::OrganizationId,pub card_network: Option<String>,+ pub payment_method_type_v2: Option<storage_enums::PaymentMethod>,+ pub connector_payment_id: Option<String>,+ pub payment_method_subtype: Option<storage_enums::PaymentMethodType>,+ pub routing_result: Option<serde_json::Value>,+ pub authentication_applied: Option<common_enums::AuthenticationType>,+ pub external_reference_id: Option<String>,+ pub tax_on_surcharge: Option<MinorUnit>,+ pub id: String,pub shipping_cost: Option<MinorUnit>,pub order_tax_amount: Option<MinorUnit>,}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[derive(Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Serialize, Deserialize, Selectable,)]@@ -161,6 +150,7 @@ pub struct PaymentAttempt {pub order_tax_amount: Option<MinorUnit>,}+#[cfg(feature = "v1")]impl PaymentAttempt {pub fn get_or_calculate_net_amount(&self) -> MinorUnit {self.net_amount.unwrap_or(@@ -181,6 +171,62 @@ pub struct PaymentListFilters {pub payment_method: Vec<storage_enums::PaymentMethod>,}+#[cfg(feature = "v2")]+#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay, Serialize, Deserialize)]+#[diesel(table_name = payment_attempt)]+pub struct PaymentAttemptNew {+ pub payment_id: id_type::GlobalPaymentId,+ pub merchant_id: id_type::MerchantId,+ pub status: storage_enums::AttemptStatus,+ pub error_message: Option<String>,+ pub surcharge_amount: Option<MinorUnit>,+ pub tax_on_surcharge: Option<MinorUnit>,+ pub payment_method_id: Option<String>,+ pub confirm: bool,+ pub authentication_type: Option<storage_enums::AuthenticationType>,+ #[serde(with = "common_utils::custom_serde::iso8601")]+ pub created_at: PrimitiveDateTime,+ #[serde(with = "common_utils::custom_serde::iso8601")]+ pub modified_at: PrimitiveDateTime,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ pub last_synced: Option<PrimitiveDateTime>,+ pub cancellation_reason: Option<String>,+ pub amount_to_capture: Option<MinorUnit>,+ pub browser_info: Option<serde_json::Value>,+ pub payment_token: Option<String>,+ pub error_code: Option<String>,+ pub connector_metadata: Option<serde_json::Value>,+ pub payment_experience: Option<storage_enums::PaymentExperience>,+ pub payment_method_data: Option<serde_json::Value>,+ pub preprocessing_step_id: Option<String>,+ pub error_reason: Option<String>,+ pub connector_response_reference_id: Option<String>,+ pub multiple_capture_count: Option<i16>,+ pub amount_capturable: MinorUnit,+ pub updated_by: String,+ pub merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,+ pub authentication_data: Option<serde_json::Value>,+ pub encoded_data: Option<String>,+ pub unified_code: Option<String>,+ pub unified_message: Option<String>,+ pub net_amount: Option<MinorUnit>,+ pub external_three_ds_authentication_attempted: Option<bool>,+ pub authentication_connector: Option<String>,+ pub authentication_id: Option<String>,+ pub fingerprint_id: Option<String>,+ pub payment_method_billing_address_id: Option<String>,+ pub charge_id: Option<String>,+ pub client_source: Option<String>,+ pub client_version: Option<String>,+ pub customer_acceptance: Option<pii::SecretSerdeValue>,+ pub profile_id: id_type::ProfileId,+ pub organization_id: id_type::OrganizationId,+ pub card_network: Option<String>,+ pub shipping_cost: Option<MinorUnit>,+ pub order_tax_amount: Option<MinorUnit>,+}++#[cfg(feature = "v1")]#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay, Serialize, Deserialize)]#[diesel(table_name = payment_attempt)]pub struct PaymentAttemptNew {@@ -252,6 +298,7 @@ pub struct PaymentAttemptNew {pub order_tax_amount: Option<MinorUnit>,}+#[cfg(feature = "v1")]impl PaymentAttemptNew {/// returns amount + surcharge_amount + tax_amount (surcharge) + shipping_cost + order_tax_amountpub fn calculate_net_amount(&self) -> MinorUnit {@@ -273,6 +320,26 @@ impl PaymentAttemptNew {}}+#[cfg(feature = "v2")]+impl PaymentAttemptNew {+ /// returns amount + surcharge_amount + tax_amount+ pub fn calculate_net_amount(&self) -> MinorUnit {+ todo!();+ }++ pub fn get_or_calculate_net_amount(&self) -> MinorUnit {+ self.net_amount+ .unwrap_or_else(|| self.calculate_net_amount())+ }++ pub fn populate_derived_fields(self) -> Self {+ let mut payment_attempt_new = self;+ payment_attempt_new.net_amount = Some(payment_attempt_new.calculate_net_amount());+ payment_attempt_new+ }+}++#[cfg(feature = "v1")]#[derive(Debug, Clone, Serialize, Deserialize)]pub enum PaymentAttemptUpdate {Update {@@ -464,6 +531,239 @@ pub enum PaymentAttemptUpdate {},}+#[cfg(feature = "v2")]+#[derive(Debug, Clone, Serialize, Deserialize)]+pub enum PaymentAttemptUpdate {+ // Update {+ // amount: MinorUnit,+ // currency: storage_enums::Currency,+ // status: storage_enums::AttemptStatus,+ // authentication_type: Option<storage_enums::AuthenticationType>,+ // payment_method: Option<storage_enums::PaymentMethod>,+ // payment_token: Option<String>,+ // payment_method_data: Option<serde_json::Value>,+ // payment_method_type: Option<storage_enums::PaymentMethodType>,+ // payment_experience: Option<storage_enums::PaymentExperience>,+ // business_sub_label: Option<String>,+ // amount_to_capture: Option<MinorUnit>,+ // capture_method: Option<storage_enums::CaptureMethod>,+ // surcharge_amount: Option<MinorUnit>,+ // tax_amount: Option<MinorUnit>,+ // fingerprint_id: Option<String>,+ // payment_method_billing_address_id: Option<String>,+ // updated_by: String,+ // },+ // UpdateTrackers {+ // payment_token: Option<String>,+ // connector: Option<String>,+ // straight_through_algorithm: Option<serde_json::Value>,+ // amount_capturable: Option<MinorUnit>,+ // surcharge_amount: Option<MinorUnit>,+ // tax_amount: Option<MinorUnit>,+ // updated_by: String,+ // merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,+ // },+ // AuthenticationTypeUpdate {+ // authentication_type: storage_enums::AuthenticationType,+ // updated_by: String,+ // },+ // ConfirmUpdate {+ // amount: MinorUnit,+ // currency: storage_enums::Currency,+ // status: storage_enums::AttemptStatus,+ // authentication_type: Option<storage_enums::AuthenticationType>,+ // capture_method: Option<storage_enums::CaptureMethod>,+ // payment_method: Option<storage_enums::PaymentMethod>,+ // browser_info: Option<serde_json::Value>,+ // connector: Option<String>,+ // payment_token: Option<String>,+ // payment_method_data: Option<serde_json::Value>,+ // payment_method_type: Option<storage_enums::PaymentMethodType>,+ // payment_experience: Option<storage_enums::PaymentExperience>,+ // business_sub_label: Option<String>,+ // straight_through_algorithm: Option<serde_json::Value>,+ // error_code: Option<Option<String>>,+ // error_message: Option<Option<String>>,+ // amount_capturable: Option<MinorUnit>,+ // surcharge_amount: Option<MinorUnit>,+ // tax_amount: Option<MinorUnit>,+ // fingerprint_id: Option<String>,+ // updated_by: String,+ // merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,+ // payment_method_id: Option<String>,+ // external_three_ds_authentication_attempted: Option<bool>,+ // authentication_connector: Option<String>,+ // authentication_id: Option<String>,+ // payment_method_billing_address_id: Option<String>,+ // client_source: Option<String>,+ // client_version: Option<String>,+ // customer_acceptance: Option<pii::SecretSerdeValue>,+ // },+ // VoidUpdate {+ // status: storage_enums::AttemptStatus,+ // cancellation_reason: Option<String>,+ // updated_by: String,+ // },+ // PaymentMethodDetailsUpdate {+ // payment_method_id: Option<String>,+ // updated_by: String,+ // },+ // BlocklistUpdate {+ // status: storage_enums::AttemptStatus,+ // error_code: Option<Option<String>>,+ // error_message: Option<Option<String>>,+ // updated_by: String,+ // },+ // RejectUpdate {+ // status: storage_enums::AttemptStatus,+ // error_code: Option<Option<String>>,+ // error_message: Option<Option<String>>,+ // updated_by: String,+ // },+ // ResponseUpdate {+ // status: storage_enums::AttemptStatus,+ // connector: Option<String>,+ // connector_transaction_id: Option<String>,+ // authentication_type: Option<storage_enums::AuthenticationType>,+ // payment_method_id: Option<String>,+ // mandate_id: Option<String>,+ // connector_metadata: Option<serde_json::Value>,+ // payment_token: Option<String>,+ // error_code: Option<Option<String>>,+ // error_message: Option<Option<String>>,+ // error_reason: Option<Option<String>>,+ // connector_response_reference_id: Option<String>,+ // amount_capturable: Option<MinorUnit>,+ // updated_by: String,+ // authentication_data: Option<serde_json::Value>,+ // encoded_data: Option<String>,+ // unified_code: Option<Option<String>>,+ // unified_message: Option<Option<String>>,+ // payment_method_data: Option<serde_json::Value>,+ // charge_id: Option<String>,+ // },+ // UnresolvedResponseUpdate {+ // status: storage_enums::AttemptStatus,+ // connector: Option<String>,+ // connector_transaction_id: Option<String>,+ // payment_method_id: Option<String>,+ // error_code: Option<Option<String>>,+ // error_message: Option<Option<String>>,+ // error_reason: Option<Option<String>>,+ // connector_response_reference_id: Option<String>,+ // updated_by: String,+ // },+ // StatusUpdate {+ // status: storage_enums::AttemptStatus,+ // updated_by: String,+ // },+ // ErrorUpdate {+ // connector: Option<String>,+ // status: storage_enums::AttemptStatus,+ // error_code: Option<Option<String>>,+ // error_message: Option<Option<String>>,+ // error_reason: Option<Option<String>>,+ // amount_capturable: Option<MinorUnit>,+ // updated_by: String,+ // unified_code: Option<Option<String>>,+ // unified_message: Option<Option<String>>,+ // connector_transaction_id: Option<String>,+ // payment_method_data: Option<serde_json::Value>,+ // authentication_type: Option<storage_enums::AuthenticationType>,+ // },+ // CaptureUpdate {+ // amount_to_capture: Option<MinorUnit>,+ // multiple_capture_count: Option<MinorUnit>,+ // updated_by: String,+ // },+ // AmountToCaptureUpdate {+ // status: storage_enums::AttemptStatus,+ // amount_capturable: MinorUnit,+ // updated_by: String,+ // },+ // PreprocessingUpdate {+ // status: storage_enums::AttemptStatus,+ // payment_method_id: Option<String>,+ // connector_metadata: Option<serde_json::Value>,+ // preprocessing_step_id: Option<String>,+ // connector_transaction_id: Option<String>,+ // connector_response_reference_id: Option<String>,+ // updated_by: String,+ // },+ // ConnectorResponse {+ // authentication_data: Option<serde_json::Value>,+ // encoded_data: Option<String>,+ // connector_transaction_id: Option<String>,+ // connector: Option<String>,+ // charge_id: Option<String>,+ // updated_by: String,+ // },+ // IncrementalAuthorizationAmountUpdate {+ // amount: MinorUnit,+ // amount_capturable: MinorUnit,+ // },+ // AuthenticationUpdate {+ // status: storage_enums::AttemptStatus,+ // external_three_ds_authentication_attempted: Option<bool>,+ // authentication_connector: Option<String>,+ // authentication_id: Option<String>,+ // updated_by: String,+ // },+ // ManualUpdate {+ // status: Option<storage_enums::AttemptStatus>,+ // error_code: Option<String>,+ // error_message: Option<String>,+ // error_reason: Option<String>,+ // updated_by: String,+ // unified_code: Option<String>,+ // unified_message: Option<String>,+ // connector_transaction_id: Option<String>,+ // },+}++#[cfg(feature = "v2")]+#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]+#[diesel(table_name = payment_attempt)]+pub struct PaymentAttemptUpdateInternal {+ net_amount: Option<i64>,+ status: Option<storage_enums::AttemptStatus>,+ authentication_type: Option<storage_enums::AuthenticationType>,+ error_message: Option<Option<String>>,+ payment_method_id: Option<String>,+ cancellation_reason: Option<String>,+ modified_at: PrimitiveDateTime,+ browser_info: Option<serde_json::Value>,+ payment_token: Option<String>,+ error_code: Option<Option<String>>,+ connector_metadata: Option<serde_json::Value>,+ payment_method_data: Option<serde_json::Value>,+ payment_experience: Option<storage_enums::PaymentExperience>,+ preprocessing_step_id: Option<String>,+ error_reason: Option<Option<String>>,+ connector_response_reference_id: Option<String>,+ multiple_capture_count: Option<i16>,+ surcharge_amount: Option<i64>,+ tax_on_surcharge: Option<i64>,+ amount_capturable: Option<i64>,+ updated_by: String,+ merchant_connector_id: Option<Option<id_type::MerchantConnectorAccountId>>,+ authentication_data: Option<serde_json::Value>,+ encoded_data: Option<String>,+ unified_code: Option<Option<String>>,+ unified_message: Option<Option<String>>,+ external_three_ds_authentication_attempted: Option<bool>,+ authentication_connector: Option<String>,+ authentication_id: Option<String>,+ fingerprint_id: Option<String>,+ payment_method_billing_address_id: Option<String>,+ charge_id: Option<String>,+ client_source: Option<String>,+ client_version: Option<String>,+ customer_acceptance: Option<pii::SecretSerdeValue>,+ card_network: Option<String>,+}++#[cfg(feature = "v1")]#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]#[diesel(table_name = payment_attempt)]pub struct PaymentAttemptUpdateInternal {@@ -518,6 +818,14 @@ pub struct PaymentAttemptUpdateInternal {pub order_tax_amount: Option<MinorUnit>,}+#[cfg(feature = "v2")]+impl PaymentAttemptUpdateInternal {+ pub fn populate_derived_fields(self, source: &PaymentAttempt) -> Self {+ todo!();+ }+}++#[cfg(feature = "v1")]impl PaymentAttemptUpdateInternal {pub fn populate_derived_fields(self, source: &PaymentAttempt) -> Self {let mut update_internal = self;@@ -553,6 +861,97 @@ impl PaymentAttemptUpdateInternal {}}+#[cfg(feature = "v2")]+impl PaymentAttemptUpdate {+ pub fn apply_changeset(self, source: PaymentAttempt) -> PaymentAttempt {+ todo!()+ // let PaymentAttemptUpdateInternal {+ // net_amount,+ // status,+ // authentication_type,+ // error_message,+ // payment_method_id,+ // cancellation_reason,+ // modified_at: _,+ // browser_info,+ // payment_token,+ // error_code,+ // connector_metadata,+ // payment_method_data,+ // payment_experience,+ // straight_through_algorithm,+ // preprocessing_step_id,+ // error_reason,+ // connector_response_reference_id,+ // multiple_capture_count,+ // surcharge_amount,+ // tax_amount,+ // amount_capturable,+ // updated_by,+ // merchant_connector_id,+ // authentication_data,+ // encoded_data,+ // unified_code,+ // unified_message,+ // external_three_ds_authentication_attempted,+ // authentication_connector,+ // authentication_id,+ // payment_method_billing_address_id,+ // fingerprint_id,+ // charge_id,+ // client_source,+ // client_version,+ // customer_acceptance,+ // card_network,+ // } = PaymentAttemptUpdateInternal::from(self).populate_derived_fields(&source);+ // PaymentAttempt {+ // net_amount: net_amount.or(source.net_amount),+ // status: status.unwrap_or(source.status),+ // authentication_type: authentication_type.or(source.authentication_type),+ // error_message: error_message.unwrap_or(source.error_message),+ // payment_method_id: payment_method_id.or(source.payment_method_id),+ // cancellation_reason: cancellation_reason.or(source.cancellation_reason),+ // modified_at: common_utils::date_time::now(),+ // browser_info: browser_info.or(source.browser_info),+ // payment_token: payment_token.or(source.payment_token),+ // error_code: error_code.unwrap_or(source.error_code),+ // connector_metadata: connector_metadata.or(source.connector_metadata),+ // payment_method_data: payment_method_data.or(source.payment_method_data),+ // payment_experience: payment_experience.or(source.payment_experience),+ // straight_through_algorithm: straight_through_algorithm+ // .or(source.straight_through_algorithm),+ // preprocessing_step_id: preprocessing_step_id.or(source.preprocessing_step_id),+ // error_reason: error_reason.unwrap_or(source.error_reason),+ // connector_response_reference_id: connector_response_reference_id+ // .or(source.connector_response_reference_id),+ // multiple_capture_count: multiple_capture_count.or(source.multiple_capture_count),+ // surcharge_amount: surcharge_amount.or(source.surcharge_amount),+ // tax_amount: tax_amount.or(source.tax_amount),+ // amount_capturable: amount_capturable.unwrap_or(source.amount_capturable),+ // updated_by,+ // merchant_connector_id: merchant_connector_id.unwrap_or(source.merchant_connector_id),+ // authentication_data: authentication_data.or(source.authentication_data),+ // encoded_data: encoded_data.or(source.encoded_data),+ // unified_code: unified_code.unwrap_or(source.unified_code),+ // unified_message: unified_message.unwrap_or(source.unified_message),+ // external_three_ds_authentication_attempted: external_three_ds_authentication_attempted+ // .or(source.external_three_ds_authentication_attempted),+ // authentication_connector: authentication_connector.or(source.authentication_connector),+ // authentication_id: authentication_id.or(source.authentication_id),+ // payment_method_billing_address_id: payment_method_billing_address_id+ // .or(source.payment_method_billing_address_id),+ // fingerprint_id: fingerprint_id.or(source.fingerprint_id),+ // charge_id: charge_id.or(source.charge_id),+ // client_source: client_source.or(source.client_source),+ // client_version: client_version.or(source.client_version),+ // customer_acceptance: customer_acceptance.or(source.customer_acceptance),+ // card_network: card_network.or(source.card_network),+ // ..source+ // }+ }+}++#[cfg(feature = "v1")]impl PaymentAttemptUpdate {pub fn apply_changeset(self, source: PaymentAttempt) -> PaymentAttempt {let PaymentAttemptUpdateInternal {@@ -665,6 +1064,922 @@ impl PaymentAttemptUpdate {}}+#[cfg(feature = "v2")]+impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {+ fn from(payment_attempt_update: PaymentAttemptUpdate) -> Self {+ todo!()+ // match payment_attempt_update {+ // PaymentAttemptUpdate::Update {+ // amount,+ // currency,+ // status,+ // // connector_transaction_id,+ // authentication_type,+ // payment_method,+ // payment_token,+ // payment_method_data,+ // payment_method_type,+ // payment_experience,+ // business_sub_label,+ // amount_to_capture,+ // capture_method,+ // surcharge_amount,+ // tax_amount,+ // fingerprint_id,+ // updated_by,+ // payment_method_billing_address_id,+ // } => Self {+ // status: Some(status),+ // // connector_transaction_id,+ // authentication_type,+ // payment_token,+ // modified_at: common_utils::date_time::now(),+ // payment_method_data,+ // payment_experience,+ // surcharge_amount,+ // tax_amount,+ // fingerprint_id,+ // payment_method_billing_address_id,+ // updated_by,+ // net_amount: None,+ // error_message: None,+ // payment_method_id: None,+ // cancellation_reason: None,+ // browser_info: None,+ // error_code: None,+ // connector_metadata: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // amount_capturable: None,+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::AuthenticationTypeUpdate {+ // authentication_type,+ // updated_by,+ // } => Self {+ // authentication_type: Some(authentication_type),+ // modified_at: common_utils::date_time::now(),+ // updated_by,+ // net_amount: None,+ // status: None,+ // error_message: None,+ // payment_method_id: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // error_code: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // amount_capturable: None,+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::ConfirmUpdate {+ // amount,+ // currency,+ // authentication_type,+ // capture_method,+ // status,+ // payment_method,+ // browser_info,+ // connector,+ // payment_token,+ // payment_method_data,+ // payment_method_type,+ // payment_experience,+ // business_sub_label,+ // straight_through_algorithm,+ // error_code,+ // error_message,+ // amount_capturable,+ // updated_by,+ // merchant_connector_id,+ // surcharge_amount,+ // tax_amount,+ // external_three_ds_authentication_attempted,+ // authentication_connector,+ // authentication_id,+ // payment_method_billing_address_id,+ // fingerprint_id,+ // payment_method_id,+ // client_source,+ // client_version,+ // customer_acceptance,+ // } => Self {+ // authentication_type,+ // status: Some(status),+ // modified_at: common_utils::date_time::now(),+ // browser_info,+ // payment_token,+ // payment_method_data,+ // payment_experience,+ // straight_through_algorithm,+ // error_code,+ // error_message,+ // amount_capturable,+ // updated_by,+ // merchant_connector_id: merchant_connector_id.map(Some),+ // surcharge_amount,+ // tax_amount,+ // external_three_ds_authentication_attempted,+ // authentication_connector,+ // authentication_id,+ // payment_method_billing_address_id,+ // fingerprint_id,+ // payment_method_id,+ // client_source,+ // client_version,+ // customer_acceptance,+ // net_amount: None,+ // cancellation_reason: None,+ // connector_metadata: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // charge_id: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::VoidUpdate {+ // status,+ // cancellation_reason,+ // updated_by,+ // } => Self {+ // status: Some(status),+ // cancellation_reason,+ // modified_at: common_utils::date_time::now(),+ // updated_by,+ // net_amount: None,+ // authentication_type: None,+ // error_message: None,+ // payment_method_id: None,+ // browser_info: None,+ // payment_token: None,+ // error_code: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // amount_capturable: None,+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::RejectUpdate {+ // status,+ // error_code,+ // error_message,+ // updated_by,+ // } => Self {+ // status: Some(status),+ // modified_at: common_utils::date_time::now(),+ // error_code,+ // error_message,+ // updated_by,+ // net_amount: None,+ // authentication_type: None,+ // payment_method_id: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // amount_capturable: None,+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::BlocklistUpdate {+ // status,+ // error_code,+ // error_message,+ // updated_by,+ // } => Self {+ // status: Some(status),+ // modified_at: common_utils::date_time::now(),+ // error_code,+ // error_message,+ // updated_by,+ // merchant_connector_id: Some(None),+ // net_amount: None,+ // authentication_type: None,+ // payment_method_id: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // amount_capturable: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::PaymentMethodDetailsUpdate {+ // payment_method_id,+ // updated_by,+ // } => Self {+ // payment_method_id,+ // modified_at: common_utils::date_time::now(),+ // updated_by,+ // net_amount: None,+ // status: None,+ // authentication_type: None,+ // error_message: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // error_code: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // amount_capturable: None,+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::ResponseUpdate {+ // status,+ // connector,+ // connector_transaction_id,+ // authentication_type,+ // payment_method_id,+ // mandate_id,+ // connector_metadata,+ // payment_token,+ // error_code,+ // error_message,+ // error_reason,+ // connector_response_reference_id,+ // amount_capturable,+ // updated_by,+ // authentication_data,+ // encoded_data,+ // unified_code,+ // unified_message,+ // payment_method_data,+ // charge_id,+ // } => Self {+ // status: Some(status),+ // authentication_type,+ // payment_method_id,+ // modified_at: common_utils::date_time::now(),+ // connector_metadata,+ // error_code,+ // error_message,+ // payment_token,+ // error_reason,+ // connector_response_reference_id,+ // amount_capturable,+ // updated_by,+ // authentication_data,+ // encoded_data,+ // unified_code,+ // unified_message,+ // payment_method_data,+ // charge_id,+ // net_amount: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // merchant_connector_id: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::ErrorUpdate {+ // connector,+ // status,+ // error_code,+ // error_message,+ // error_reason,+ // amount_capturable,+ // updated_by,+ // unified_code,+ // unified_message,+ // connector_transaction_id,+ // payment_method_data,+ // authentication_type,+ // } => Self {+ // status: Some(status),+ // error_message,+ // error_code,+ // modified_at: common_utils::date_time::now(),+ // error_reason,+ // amount_capturable,+ // updated_by,+ // unified_code,+ // unified_message,+ // payment_method_data,+ // authentication_type,+ // net_amount: None,+ // payment_method_id: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // connector_metadata: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::StatusUpdate { status, updated_by } => Self {+ // status: Some(status),+ // modified_at: common_utils::date_time::now(),+ // updated_by,+ // net_amount: None,+ // authentication_type: None,+ // error_message: None,+ // payment_method_id: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // error_code: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // amount_capturable: None,+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::UpdateTrackers {+ // payment_token,+ // connector,+ // straight_through_algorithm,+ // amount_capturable,+ // surcharge_amount,+ // tax_amount,+ // updated_by,+ // merchant_connector_id,+ // } => Self {+ // payment_token,+ // modified_at: common_utils::date_time::now(),+ // straight_through_algorithm,+ // amount_capturable,+ // surcharge_amount,+ // tax_amount,+ // updated_by,+ // merchant_connector_id: merchant_connector_id.map(Some),+ // net_amount: None,+ // status: None,+ // authentication_type: None,+ // error_message: None,+ // payment_method_id: None,+ // cancellation_reason: None,+ // browser_info: None,+ // error_code: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::UnresolvedResponseUpdate {+ // status,+ // connector,+ // connector_transaction_id,+ // payment_method_id,+ // error_code,+ // error_message,+ // error_reason,+ // connector_response_reference_id,+ // updated_by,+ // } => Self {+ // status: Some(status),+ // payment_method_id,+ // modified_at: common_utils::date_time::now(),+ // error_code,+ // error_message,+ // error_reason,+ // connector_response_reference_id,+ // updated_by,+ // net_amount: None,+ // authentication_type: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // amount_capturable: None,+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::PreprocessingUpdate {+ // status,+ // payment_method_id,+ // connector_metadata,+ // preprocessing_step_id,+ // connector_transaction_id,+ // connector_response_reference_id,+ // updated_by,+ // } => Self {+ // status: Some(status),+ // payment_method_id,+ // modified_at: common_utils::date_time::now(),+ // connector_metadata,+ // preprocessing_step_id,+ // connector_response_reference_id,+ // updated_by,+ // net_amount: None,+ // authentication_type: None,+ // error_message: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // error_code: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // error_reason: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // amount_capturable: None,+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::CaptureUpdate {+ // multiple_capture_count,+ // updated_by,+ // amount_to_capture,+ // } => Self {+ // multiple_capture_count,+ // modified_at: common_utils::date_time::now(),+ // updated_by,+ // net_amount: None,+ // status: None,+ // authentication_type: None,+ // error_message: None,+ // payment_method_id: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // error_code: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // amount_capturable: None,+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::AmountToCaptureUpdate {+ // status,+ // amount_capturable,+ // updated_by,+ // } => Self {+ // status: Some(status),+ // modified_at: common_utils::date_time::now(),+ // amount_capturable: Some(amount_capturable),+ // updated_by,+ // net_amount: None,+ // authentication_type: None,+ // error_message: None,+ // payment_method_id: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // error_code: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::ConnectorResponse {+ // authentication_data,+ // encoded_data,+ // connector_transaction_id,+ // connector,+ // updated_by,+ // charge_id,+ // } => Self {+ // authentication_data,+ // encoded_data,+ // modified_at: common_utils::date_time::now(),+ // updated_by,+ // charge_id,+ // net_amount: None,+ // status: None,+ // authentication_type: None,+ // error_message: None,+ // payment_method_id: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // error_code: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // amount_capturable: None,+ // merchant_connector_id: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::IncrementalAuthorizationAmountUpdate {+ // amount,+ // amount_capturable,+ // } => Self {+ // modified_at: common_utils::date_time::now(),+ // amount_capturable: Some(amount_capturable),+ // net_amount: None,+ // status: None,+ // authentication_type: None,+ // error_message: None,+ // payment_method_id: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // error_code: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // updated_by: String::default(),+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::AuthenticationUpdate {+ // status,+ // external_three_ds_authentication_attempted,+ // authentication_connector,+ // authentication_id,+ // updated_by,+ // } => Self {+ // status: Some(status),+ // modified_at: common_utils::date_time::now(),+ // external_three_ds_authentication_attempted,+ // authentication_connector,+ // authentication_id,+ // updated_by,+ // net_amount: None,+ // authentication_type: None,+ // error_message: None,+ // payment_method_id: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // error_code: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // error_reason: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // amount_capturable: None,+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // unified_code: None,+ // unified_message: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // PaymentAttemptUpdate::ManualUpdate {+ // status,+ // error_code,+ // error_message,+ // error_reason,+ // updated_by,+ // unified_code,+ // unified_message,+ // connector_transaction_id,+ // } => Self {+ // status,+ // error_code: error_code.map(Some),+ // modified_at: common_utils::date_time::now(),+ // error_message: error_message.map(Some),+ // error_reason: error_reason.map(Some),+ // updated_by,+ // unified_code: unified_code.map(Some),+ // unified_message: unified_message.map(Some),+ // net_amount: None,+ // authentication_type: None,+ // payment_method_id: None,+ // cancellation_reason: None,+ // browser_info: None,+ // payment_token: None,+ // connector_metadata: None,+ // payment_method_data: None,+ // payment_experience: None,+ // straight_through_algorithm: None,+ // preprocessing_step_id: None,+ // connector_response_reference_id: None,+ // multiple_capture_count: None,+ // surcharge_amount: None,+ // tax_amount: None,+ // amount_capturable: None,+ // merchant_connector_id: None,+ // authentication_data: None,+ // encoded_data: None,+ // external_three_ds_authentication_attempted: None,+ // authentication_connector: None,+ // authentication_id: None,+ // fingerprint_id: None,+ // payment_method_billing_address_id: None,+ // charge_id: None,+ // client_source: None,+ // client_version: None,+ // customer_acceptance: None,+ // card_network: None,+ // },+ // }+ }+}++#[cfg(feature = "v1")]impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {fn from(payment_attempt_update: PaymentAttemptUpdate) -> Self {match payment_attempt_update {diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rsindex c6ebbe671e..23d1a0f1ac 100644--- a/crates/diesel_models/src/payment_intent.rs+++ b/crates/diesel_models/src/payment_intent.rs@@ -5,12 +5,12 @@ use serde::{Deserialize, Serialize};use time::PrimitiveDateTime;use crate::enums as storage_enums;-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]use crate::schema::payment_intent;-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]use crate::schema_v2::payment_intent;-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]#[derive(Clone, Debug, PartialEq, Identifiable, Queryable, Serialize, Deserialize, Selectable)]#[diesel(table_name = payment_intent, primary_key(id), check_for_backend(diesel::pg::Pg))]pub struct PaymentIntent {@@ -72,7 +72,7 @@ pub struct PaymentIntent {pub id: common_utils::id_type::GlobalPaymentId,}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[derive(Clone, Debug, PartialEq, Identifiable, Queryable, Serialize, Deserialize, Selectable)]#[diesel(table_name = payment_intent, primary_key(payment_id, merchant_id), check_for_backend(diesel::pg::Pg))]pub struct PaymentIntent {@@ -205,7 +205,7 @@ pub struct DefaultTax {pub order_tax_amount: MinorUnit,}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]#[derive(Clone, Debug, PartialEq, Insertable, router_derive::DebugAsDisplay, Serialize, Deserialize,)]@@ -265,7 +265,7 @@ pub struct PaymentIntentNew {pub id: common_utils::id_type::GlobalPaymentId,}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[derive(Clone, Debug, PartialEq, Insertable, router_derive::DebugAsDisplay, Serialize, Deserialize,)]@@ -330,7 +330,7 @@ pub struct PaymentIntentNew {pub skip_external_tax_calculation: Option<bool>,}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]#[derive(Debug, Clone, Serialize, Deserialize)]pub enum PaymentIntentUpdate {ResponseUpdate {@@ -409,7 +409,7 @@ pub enum PaymentIntentUpdate {},}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[derive(Debug, Clone, Serialize, Deserialize)]pub enum PaymentIntentUpdate {ResponseUpdate {@@ -491,7 +491,7 @@ pub enum PaymentIntentUpdate {},}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]#[derive(Debug, Clone, Serialize, Deserialize)]pub struct PaymentIntentUpdateFields {pub amount: MinorUnit,@@ -516,7 +516,7 @@ pub struct PaymentIntentUpdateFields {pub is_payment_processor_token_flow: Option<bool>,}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[derive(Debug, Clone, Serialize, Deserialize)]pub struct PaymentIntentUpdateFields {pub amount: MinorUnit,@@ -548,7 +548,7 @@ pub struct PaymentIntentUpdateFields {pub tax_details: Option<TaxDetails>,}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]#[diesel(table_name = payment_intent)]pub struct PaymentIntentUpdateInternal {@@ -579,7 +579,7 @@ pub struct PaymentIntentUpdateInternal {pub frm_merchant_decision: Option<String>,}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]#[diesel(table_name = payment_intent)]pub struct PaymentIntentUpdateInternal {@@ -622,7 +622,7 @@ pub struct PaymentIntentUpdateInternal {pub tax_details: Option<TaxDetails>,}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]impl PaymentIntentUpdate {pub fn apply_changeset(self, source: PaymentIntent) -> PaymentIntent {todo!()@@ -693,7 +693,7 @@ impl PaymentIntentUpdate {}}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]impl PaymentIntentUpdate {pub fn apply_changeset(self, source: PaymentIntent) -> PaymentIntent {let PaymentIntentUpdateInternal {@@ -783,7 +783,7 @@ impl PaymentIntentUpdate {}}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {fn from(payment_intent_update: PaymentIntentUpdate) -> Self {todo!()@@ -1292,7 +1292,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {}}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {fn from(payment_intent_update: PaymentIntentUpdate) -> Self {match payment_intent_update {diff --git a/crates/diesel_models/src/query/payment_attempt.rs b/crates/diesel_models/src/query/payment_attempt.rsindex 48941330ec..e07d716fb6 100644--- a/crates/diesel_models/src/query/payment_attempt.rs+++ b/crates/diesel_models/src/query/payment_attempt.rs@@ -8,9 +8,9 @@ use diesel::{use error_stack::{report, ResultExt};use super::generics;-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]use crate::schema::payment_attempt::dsl;-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]use crate::schema_v2::payment_attempt::dsl;use crate::{enums::{self, IntentStatus},@@ -29,7 +29,7 @@ impl PaymentAttemptNew {}impl PaymentAttempt {- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]pub async fn update_with_attempt_id(self,conn: &PgPooledConn,@@ -57,7 +57,7 @@ impl PaymentAttempt {}}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]pub async fn update_with_attempt_id(self,conn: &PgPooledConn,@@ -70,9 +70,7 @@ impl PaymentAttempt {_,>(conn,- dsl::attempt_id- .eq(self.attempt_id.to_owned())- .and(dsl::merchant_id.eq(self.merchant_id.to_owned())),+ dsl::id.eq(self.id.to_owned()),payment_attempt.populate_derived_fields(&self),).await@@ -85,6 +83,7 @@ impl PaymentAttempt {}}+ #[cfg(feature = "v1")]pub async fn find_optional_by_payment_id_merchant_id(conn: &PgPooledConn,payment_id: &common_utils::id_type::PaymentId,@@ -99,6 +98,7 @@ impl PaymentAttempt {.await}+ #[cfg(feature = "v1")]pub async fn find_by_connector_transaction_id_payment_id_merchant_id(conn: &PgPooledConn,connector_transaction_id: &str,@@ -115,6 +115,7 @@ impl PaymentAttempt {.await}+ #[cfg(feature = "v1")]pub async fn find_last_successful_attempt_by_payment_id_merchant_id(conn: &PgPooledConn,payment_id: &common_utils::id_type::PaymentId,@@ -137,6 +138,7 @@ impl PaymentAttempt {.ok_or(report!(DatabaseError::NotFound))}+ #[cfg(feature = "v1")]pub async fn find_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(conn: &PgPooledConn,payment_id: &common_utils::id_type::PaymentId,@@ -163,6 +165,7 @@ impl PaymentAttempt {.ok_or(report!(DatabaseError::NotFound))}+ #[cfg(feature = "v1")]pub async fn find_by_merchant_id_connector_txn_id(conn: &PgPooledConn,merchant_id: &common_utils::id_type::MerchantId,@@ -177,6 +180,7 @@ impl PaymentAttempt {.await}+ #[cfg(feature = "v1")]pub async fn find_by_merchant_id_attempt_id(conn: &PgPooledConn,merchant_id: &common_utils::id_type::MerchantId,@@ -191,6 +195,16 @@ impl PaymentAttempt {.await}+ #[cfg(feature = "v2")]+ pub async fn find_by_id(conn: &PgPooledConn, id: &str) -> StorageResult<Self> {+ generics::generic_find_one::<<Self as HasTable>::Table, _, _>(+ conn,+ dsl::id.eq(id.to_owned()),+ )+ .await+ }++ #[cfg(feature = "v1")]pub async fn find_by_merchant_id_preprocessing_id(conn: &PgPooledConn,merchant_id: &common_utils::id_type::MerchantId,@@ -205,6 +219,7 @@ impl PaymentAttempt {.await}+ #[cfg(feature = "v1")]pub async fn find_by_payment_id_merchant_id_attempt_id(conn: &PgPooledConn,payment_id: &common_utils::id_type::PaymentId,@@ -222,6 +237,7 @@ impl PaymentAttempt {.await}+ #[cfg(feature = "v1")]pub async fn find_by_merchant_id_payment_id(conn: &PgPooledConn,merchant_id: &common_utils::id_type::MerchantId,@@ -244,6 +260,7 @@ impl PaymentAttempt {.await}+ #[cfg(feature = "v1")]pub async fn get_filters_for_payments(conn: &PgPooledConn,pi: &[PaymentIntent],@@ -342,6 +359,7 @@ impl PaymentAttempt {))}+ #[cfg(feature = "v1")]#[allow(clippy::too_many_arguments)]pub async fn get_total_count_of_attempts(conn: &PgPooledConn,diff --git a/crates/diesel_models/src/query/payment_intent.rs b/crates/diesel_models/src/query/payment_intent.rsindex e148c76686..fb23fc6010 100644--- a/crates/diesel_models/src/query/payment_intent.rs+++ b/crates/diesel_models/src/query/payment_intent.rs@@ -1,9 +1,9 @@use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};use super::generics;-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]use crate::schema::payment_intent::dsl;-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]use crate::schema_v2::payment_intent::dsl;use crate::{errors,@@ -20,7 +20,7 @@ impl PaymentIntentNew {}impl PaymentIntent {- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]pub async fn update(self,conn: &PgPooledConn,@@ -41,7 +41,7 @@ impl PaymentIntent {}}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]pub async fn find_by_global_id(conn: &PgPooledConn,id: &common_utils::id_type::GlobalPaymentId,@@ -49,7 +49,7 @@ impl PaymentIntent {generics::generic_find_by_id::<<Self as HasTable>::Table, _, _>(conn, id.to_owned()).await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]pub async fn update(self,conn: &PgPooledConn,@@ -74,7 +74,7 @@ impl PaymentIntent {}}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]pub async fn find_by_merchant_reference_id_merchant_id(conn: &PgPooledConn,merchant_reference_id: &str,@@ -89,7 +89,7 @@ impl PaymentIntent {.await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]pub async fn find_by_payment_id_merchant_id(conn: &PgPooledConn,payment_id: &common_utils::id_type::PaymentId,@@ -104,7 +104,7 @@ impl PaymentIntent {.await}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]pub async fn find_optional_by_merchant_reference_id_merchant_id(conn: &PgPooledConn,merchant_reference_id: &str,@@ -119,7 +119,7 @@ impl PaymentIntent {.await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]pub async fn find_optional_by_payment_id_merchant_id(conn: &PgPooledConn,payment_id: &common_utils::id_type::PaymentId,diff --git a/crates/diesel_models/src/query/user/sample_data.rs b/crates/diesel_models/src/query/user/sample_data.rsindex 3890ee2cd0..b5400f570a 100644--- a/crates/diesel_models/src/query/user/sample_data.rs+++ b/crates/diesel_models/src/query/user/sample_data.rs@@ -3,11 +3,11 @@ use diesel::{associations::HasTable, debug_query, ExpressionMethods, TextExpressuse error_stack::ResultExt;use router_env::logger;-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]use crate::schema::{payment_attempt::dsl as payment_attempt_dsl, payment_intent::dsl as payment_intent_dsl,};-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]use crate::schema_v2::{payment_attempt::dsl as payment_attempt_dsl, payment_intent::dsl as payment_intent_dsl,};@@ -61,7 +61,7 @@ pub async fn insert_refunds(.attach_printable("Error while inserting refunds")}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]pub async fn delete_payment_intents(conn: &PgPooledConn,merchant_id: &common_utils::id_type::MerchantId,@@ -88,7 +88,7 @@ pub async fn delete_payment_intents(})}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]pub async fn delete_payment_intents(conn: &PgPooledConn,merchant_id: &common_utils::id_type::MerchantId,diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rsindex 4c44bb18b7..1c81b402f7 100644--- a/crates/diesel_models/src/schema_v2.rs+++ b/crates/diesel_models/src/schema_v2.rs@@ -733,30 +733,18 @@ diesel::table! {use diesel::sql_types::*;use crate::enums::diesel_exports::*;- payment_attempt (attempt_id, merchant_id) {+ payment_attempt (id) {#[max_length = 64]payment_id -> Varchar,#[max_length = 64]merchant_id -> Varchar,- #[max_length = 64]- attempt_id -> Varchar,status -> AttemptStatus,- amount -> Int8,- currency -> Nullable<Currency>,- save_to_locker -> Nullable<Bool>,#[max_length = 64]connector -> Nullable<Varchar>,error_message -> Nullable<Text>,- offer_amount -> Nullable<Int8>,surcharge_amount -> Nullable<Int8>,- tax_amount -> Nullable<Int8>,#[max_length = 64]payment_method_id -> Nullable<Varchar>,- payment_method -> Nullable<Varchar>,- #[max_length = 128]- connector_transaction_id -> Nullable<Varchar>,- capture_method -> Nullable<CaptureMethod>,- capture_on -> Nullable<Timestamp>,confirm -> Bool,authentication_type -> Nullable<AuthenticationType>,created_at -> Timestamp,@@ -765,8 +753,6 @@ diesel::table! {#[max_length = 255]cancellation_reason -> Nullable<Varchar>,amount_to_capture -> Nullable<Int8>,- #[max_length = 64]- mandate_id -> Nullable<Varchar>,browser_info -> Nullable<Jsonb>,#[max_length = 255]error_code -> Nullable<Varchar>,@@ -775,14 +761,8 @@ diesel::table! {connector_metadata -> Nullable<Jsonb>,#[max_length = 50]payment_experience -> Nullable<Varchar>,- #[max_length = 64]- payment_method_type -> Nullable<Varchar>,payment_method_data -> Nullable<Jsonb>,- #[max_length = 64]- business_sub_label -> Nullable<Varchar>,- straight_through_algorithm -> Nullable<Jsonb>,preprocessing_step_id -> Nullable<Varchar>,- mandate_details -> Nullable<Jsonb>,error_reason -> Nullable<Text>,multiple_capture_count -> Nullable<Int2>,#[max_length = 128]@@ -804,7 +784,6 @@ diesel::table! {authentication_connector -> Nullable<Varchar>,#[max_length = 64]authentication_id -> Nullable<Varchar>,- mandate_data -> Nullable<Jsonb>,#[max_length = 64]fingerprint_id -> Nullable<Varchar>,#[max_length = 64]@@ -822,6 +801,18 @@ diesel::table! {organization_id -> Varchar,#[max_length = 32]card_network -> Nullable<Varchar>,+ payment_method_type_v2 -> Nullable<Varchar>,+ #[max_length = 128]+ connector_payment_id -> Nullable<Varchar>,+ #[max_length = 64]+ payment_method_subtype -> Nullable<Varchar>,+ routing_result -> Nullable<Jsonb>,+ authentication_applied -> Nullable<AuthenticationType>,+ #[max_length = 128]+ external_reference_id -> Nullable<Varchar>,+ tax_on_surcharge -> Nullable<Int8>,+ #[max_length = 64]+ id -> Varchar,shipping_cost -> Nullable<Int8>,order_tax_amount -> Nullable<Int8>,}diff --git a/crates/diesel_models/src/user/sample_data.rs b/crates/diesel_models/src/user/sample_data.rsindex ddcf6352c5..a354e4a02a 100644--- a/crates/diesel_models/src/user/sample_data.rs+++ b/crates/diesel_models/src/user/sample_data.rs@@ -6,15 +6,133 @@ use common_utils::types::MinorUnit;use serde::{Deserialize, Serialize};use time::PrimitiveDateTime;-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]use crate::schema::payment_attempt;-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]use crate::schema_v2::payment_attempt;use crate::{enums::{MandateDataType, MandateDetails},PaymentAttemptNew,};+#[cfg(feature = "v2")]+#[derive(+ Clone, Debug, diesel::Insertable, router_derive::DebugAsDisplay, Serialize, Deserialize,+)]+#[diesel(table_name = payment_attempt)]+pub struct PaymentAttemptBatchNew {+ pub payment_id: common_utils::id_type::PaymentId,+ pub merchant_id: common_utils::id_type::MerchantId,+ pub status: AttemptStatus,+ pub error_message: Option<String>,+ pub surcharge_amount: Option<i64>,+ pub tax_on_surcharge: Option<i64>,+ pub payment_method_id: Option<String>,+ pub confirm: bool,+ pub authentication_type: Option<AuthenticationType>,+ #[serde(with = "common_utils::custom_serde::iso8601")]+ pub created_at: PrimitiveDateTime,+ #[serde(with = "common_utils::custom_serde::iso8601")]+ pub modified_at: PrimitiveDateTime,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ pub last_synced: Option<PrimitiveDateTime>,+ pub cancellation_reason: Option<String>,+ pub browser_info: Option<serde_json::Value>,+ pub payment_token: Option<String>,+ pub error_code: Option<String>,+ pub connector_metadata: Option<serde_json::Value>,+ pub payment_experience: Option<PaymentExperience>,+ pub payment_method_data: Option<serde_json::Value>,+ pub preprocessing_step_id: Option<String>,+ pub error_reason: Option<String>,+ pub connector_response_reference_id: Option<String>,+ pub multiple_capture_count: Option<i16>,+ pub amount_capturable: i64,+ pub updated_by: String,+ pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,+ pub authentication_data: Option<serde_json::Value>,+ pub encoded_data: Option<String>,+ pub unified_code: Option<String>,+ pub unified_message: Option<String>,+ pub net_amount: Option<i64>,+ pub external_three_ds_authentication_attempted: Option<bool>,+ pub authentication_connector: Option<String>,+ pub authentication_id: Option<String>,+ pub payment_method_billing_address_id: Option<String>,+ pub fingerprint_id: Option<String>,+ pub charge_id: Option<String>,+ pub client_source: Option<String>,+ pub client_version: Option<String>,+ pub customer_acceptance: Option<common_utils::pii::SecretSerdeValue>,+ pub profile_id: common_utils::id_type::ProfileId,+ pub organization_id: common_utils::id_type::OrganizationId,+}++#[cfg(feature = "v2")]+#[allow(dead_code)]+impl PaymentAttemptBatchNew {+ // Used to verify compatibility with PaymentAttemptTable+ fn convert_into_normal_attempt_insert(self) -> PaymentAttemptNew {+ // PaymentAttemptNew {+ // payment_id: self.payment_id,+ // merchant_id: self.merchant_id,+ // status: self.status,+ // error_message: self.error_message,+ // surcharge_amount: self.surcharge_amount,+ // tax_amount: self.tax_amount,+ // payment_method_id: self.payment_method_id,+ // confirm: self.confirm,+ // authentication_type: self.authentication_type,+ // created_at: self.created_at,+ // modified_at: self.modified_at,+ // last_synced: self.last_synced,+ // cancellation_reason: self.cancellation_reason,+ // browser_info: self.browser_info,+ // payment_token: self.payment_token,+ // error_code: self.error_code,+ // connector_metadata: self.connector_metadata,+ // payment_experience: self.payment_experience,+ // card_network: self+ // .payment_method_data+ // .as_ref()+ // .and_then(|data| data.as_object())+ // .and_then(|card| card.get("card"))+ // .and_then(|v| v.as_object())+ // .and_then(|v| v.get("card_network"))+ // .and_then(|network| network.as_str())+ // .map(|network| network.to_string()),+ // payment_method_data: self.payment_method_data,+ // straight_through_algorithm: self.straight_through_algorithm,+ // preprocessing_step_id: self.preprocessing_step_id,+ // error_reason: self.error_reason,+ // multiple_capture_count: self.multiple_capture_count,+ // connector_response_reference_id: self.connector_response_reference_id,+ // amount_capturable: self.amount_capturable,+ // updated_by: self.updated_by,+ // merchant_connector_id: self.merchant_connector_id,+ // authentication_data: self.authentication_data,+ // encoded_data: self.encoded_data,+ // unified_code: self.unified_code,+ // unified_message: self.unified_message,+ // net_amount: self.net_amount,+ // external_three_ds_authentication_attempted: self+ // .external_three_ds_authentication_attempted,+ // authentication_connector: self.authentication_connector,+ // authentication_id: self.authentication_id,+ // payment_method_billing_address_id: self.payment_method_billing_address_id,+ // fingerprint_id: self.fingerprint_id,+ // charge_id: self.charge_id,+ // client_source: self.client_source,+ // client_version: self.client_version,+ // customer_acceptance: self.customer_acceptance,+ // profile_id: self.profile_id,+ // organization_id: self.organization_id,+ // }+ todo!()+ }+}++#[cfg(feature = "v1")]#[derive(Clone, Debug, diesel::Insertable, router_derive::DebugAsDisplay, Serialize, Deserialize,)]@@ -87,6 +205,7 @@ pub struct PaymentAttemptBatchNew {pub order_tax_amount: Option<MinorUnit>,}+#[cfg(feature = "v1")]#[allow(dead_code)]impl PaymentAttemptBatchNew {// Used to verify compatibility with PaymentAttemptTablediff --git a/crates/hyperswitch_domain_models/Cargo.toml b/crates/hyperswitch_domain_models/Cargo.tomlindex e2ae011c82..3a0d4b402b 100644--- a/crates/hyperswitch_domain_models/Cargo.toml+++ b/crates/hyperswitch_domain_models/Cargo.toml@@ -16,7 +16,6 @@ frm = ["api_models/frm"]v2 = ["api_models/v2", "diesel_models/v2"]v1 = ["api_models/v1", "diesel_models/v1"]customer_v2 = ["api_models/customer_v2", "diesel_models/customer_v2"]-payment_v2 = ["api_models/payment_v2", "diesel_models/payment_v2"]payment_methods_v2 = ["api_models/payment_methods_v2", "diesel_models/payment_methods_v2"][dependencies]diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rsindex f25ce7cad2..2d7d49e81c 100644--- a/crates/hyperswitch_domain_models/src/payments.rs+++ b/crates/hyperswitch_domain_models/src/payments.rs@@ -14,7 +14,7 @@ use common_enums as storage_enums;use self::payment_attempt::PaymentAttempt;use crate::RemoteStorageObject;-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[derive(Clone, Debug, PartialEq, serde::Serialize)]pub struct PaymentIntent {pub payment_id: id_type::PaymentId,@@ -79,12 +79,12 @@ pub struct PaymentIntent {}impl PaymentIntent {- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2"),))]+ #[cfg(feature = "v1")]pub fn get_id(&self) -> &id_type::PaymentId {&self.payment_id}- #[cfg(all(feature = "v2", feature = "payment_v2",))]+ #[cfg(feature = "v2")]pub fn get_id(&self) -> &id_type::GlobalPaymentId {&self.id}@@ -168,7 +168,7 @@ impl AmountDetails {}}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]#[derive(Clone, Debug, PartialEq, serde::Serialize)]pub struct PaymentIntent {/// The global identifier for the payment intent. This is generated by the system.diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rsindex 003509b203..5f0894566a 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs@@ -1,3 +1,4 @@+#[cfg(all(feature = "v1", feature = "olap"))]use api_models::enums::Connector;use common_enums as storage_enums;use common_utils::{@@ -16,8 +17,9 @@ use masking::Secret;use serde::{Deserialize, Serialize};use time::PrimitiveDateTime;+#[cfg(all(feature = "v1", feature = "olap"))]use super::PaymentIntent;-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]use crate::merchant_key_store::MerchantKeyStore;use crate::{behaviour, errors,@@ -27,14 +29,14 @@ use crate::{#[async_trait::async_trait]pub trait PaymentAttemptInterface {- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn insert_payment_attempt(&self,payment_attempt: PaymentAttemptNew,storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]async fn insert_payment_attempt(&self,key_manager_state: &KeyManagerState,@@ -43,7 +45,7 @@ pub trait PaymentAttemptInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn update_payment_attempt_with_attempt_id(&self,this: PaymentAttempt,@@ -51,7 +53,7 @@ pub trait PaymentAttemptInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]async fn update_payment_attempt_with_attempt_id(&self,key_manager_state: &KeyManagerState,@@ -61,7 +63,7 @@ pub trait PaymentAttemptInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(&self,connector_transaction_id: &str,@@ -70,7 +72,7 @@ pub trait PaymentAttemptInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(&self,payment_id: &id_type::PaymentId,@@ -78,7 +80,7 @@ pub trait PaymentAttemptInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(&self,payment_id: &id_type::PaymentId,@@ -86,7 +88,7 @@ pub trait PaymentAttemptInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_merchant_id_connector_txn_id(&self,merchant_id: &id_type::MerchantId,@@ -94,7 +96,7 @@ pub trait PaymentAttemptInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(&self,payment_id: &id_type::PaymentId,@@ -103,7 +105,7 @@ pub trait PaymentAttemptInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_attempt_id_merchant_id(&self,attempt_id: &str,@@ -111,17 +113,16 @@ pub trait PaymentAttemptInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;- #[cfg(all(feature = "v2", feature = "payment_v2"))]- async fn find_payment_attempt_by_attempt_id_merchant_id(+ #[cfg(feature = "v2")]+ async fn find_payment_attempt_by_id(&self,key_manager_state: &KeyManagerState,merchant_key_store: &MerchantKeyStore,attempt_id: &str,- merchant_id: &id_type::MerchantId,storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_preprocessing_id_merchant_id(&self,preprocessing_id: &str,@@ -129,7 +130,7 @@ pub trait PaymentAttemptInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_attempts_by_merchant_id_payment_id(&self,merchant_id: &id_type::MerchantId,@@ -137,7 +138,7 @@ pub trait PaymentAttemptInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<PaymentAttempt>, errors::StorageError>;- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn get_filters_for_payments(&self,pi: &[PaymentIntent],@@ -145,7 +146,7 @@ pub trait PaymentAttemptInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentListFilters, errors::StorageError>;- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(all(feature = "v1", feature = "olap"))]#[allow(clippy::too_many_arguments)]async fn get_total_count_of_filtered_payment_attempts(&self,@@ -162,6 +163,111 @@ pub trait PaymentAttemptInterface {) -> error_stack::Result<i64, errors::StorageError>;}+#[cfg(feature = "v2")]+#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]+pub struct PaymentAttempt {+ pub payment_id: id_type::GlobalPaymentId,+ pub merchant_id: id_type::MerchantId,+ pub status: storage_enums::AttemptStatus,+ pub net_amount: MinorUnit,+ pub connector: Option<String>,+ pub amount_to_capture: Option<MinorUnit>,+ pub error_message: Option<String>,+ pub surcharge_amount: Option<MinorUnit>,+ pub tax_on_surcharge: Option<MinorUnit>,+ pub confirm: bool,+ pub authentication_type: Option<storage_enums::AuthenticationType>,+ #[serde(with = "common_utils::custom_serde::iso8601")]+ pub created_at: PrimitiveDateTime,+ #[serde(with = "common_utils::custom_serde::iso8601")]+ pub modified_at: PrimitiveDateTime,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ pub last_synced: Option<PrimitiveDateTime>,+ pub cancellation_reason: Option<String>,+ pub browser_info: Option<serde_json::Value>,+ pub error_code: Option<String>,+ pub payment_token: Option<String>,+ pub connector_metadata: Option<serde_json::Value>,+ pub payment_experience: Option<storage_enums::PaymentExperience>,+ pub payment_method_data: Option<serde_json::Value>,+ pub routing_result: Option<serde_json::Value>,+ pub preprocessing_step_id: Option<String>,+ pub error_reason: Option<String>,+ pub multiple_capture_count: Option<i16>,+ // reference to the payment at connector side+ pub connector_response_reference_id: Option<String>,+ pub amount_capturable: MinorUnit,+ pub updated_by: String,+ pub authentication_data: Option<serde_json::Value>,+ pub encoded_data: Option<String>,+ pub merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,+ pub unified_code: Option<String>,+ pub unified_message: Option<String>,+ pub external_three_ds_authentication_attempted: Option<bool>,+ pub authentication_connector: Option<String>,+ pub authentication_id: Option<String>,+ pub payment_method_billing_address_id: Option<String>,+ pub fingerprint_id: Option<String>,+ pub charge_id: Option<String>,+ pub client_source: Option<String>,+ pub client_version: Option<String>,+ pub customer_acceptance: Option<pii::SecretSerdeValue>,+ pub profile_id: id_type::ProfileId,+ pub organization_id: id_type::OrganizationId,+ pub payment_method_type: Option<storage_enums::PaymentMethod>,+ pub payment_method_id: Option<String>,+ pub connector_payment_id: Option<String>,+ pub payment_method_subtype: Option<storage_enums::PaymentMethodType>,+ pub authentication_applied: Option<common_enums::AuthenticationType>,+ pub external_reference_id: Option<String>,+ pub shipping_cost: Option<MinorUnit>,+ pub order_tax_amount: Option<MinorUnit>,+ pub id: String,+}++impl PaymentAttempt {+ #[cfg(feature = "v1")]+ pub fn get_payment_method(&self) -> Option<storage_enums::PaymentMethod> {+ self.payment_method+ }++ #[cfg(feature = "v2")]+ pub fn get_payment_method(&self) -> Option<storage_enums::PaymentMethod> {+ self.payment_method_type+ }++ #[cfg(feature = "v1")]+ pub fn get_payment_method_type(&self) -> Option<storage_enums::PaymentMethodType> {+ self.payment_method_type+ }++ #[cfg(feature = "v2")]+ pub fn get_payment_method_type(&self) -> Option<storage_enums::PaymentMethodType> {+ self.payment_method_subtype+ }++ #[cfg(feature = "v1")]+ pub fn get_id(&self) -> &str {+ &self.attempt_id+ }++ #[cfg(feature = "v2")]+ pub fn get_id(&self) -> &str {+ &self.id+ }++ #[cfg(feature = "v1")]+ pub fn get_connector_payment_id(&self) -> Option<&str> {+ self.connector_transaction_id.as_deref()+ }++ #[cfg(feature = "v2")]+ pub fn get_connector_payment_id(&self) -> Option<&str> {+ self.connector_payment_id.as_deref()+ }+}++#[cfg(feature = "v1")]#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]pub struct PaymentAttempt {pub payment_id: id_type::PaymentId,@@ -233,6 +339,18 @@ pub struct PaymentAttempt {pub order_tax_amount: Option<MinorUnit>,}+#[cfg(feature = "v2")]+impl PaymentAttempt {+ pub fn get_total_amount(&self) -> MinorUnit {+ todo!();+ }++ pub fn get_total_surcharge_amount(&self) -> Option<MinorUnit> {+ todo!();+ }+}++#[cfg(feature = "v1")]impl PaymentAttempt {pub fn get_total_amount(&self) -> MinorUnit {self.amount@@ -256,6 +374,56 @@ pub struct PaymentListFilters {pub authentication_type: Vec<storage_enums::AuthenticationType>,}+#[cfg(feature = "v2")]+#[derive(Clone, Debug, Serialize, Deserialize)]+pub struct PaymentAttemptNew {+ pub payment_id: id_type::PaymentId,+ pub merchant_id: id_type::MerchantId,+ pub status: storage_enums::AttemptStatus,+ pub error_message: Option<String>,+ pub surcharge_amount: Option<MinorUnit>,+ pub tax_amount: Option<MinorUnit>,+ pub payment_method_id: Option<String>,+ pub confirm: bool,+ pub authentication_type: Option<storage_enums::AuthenticationType>,+ pub created_at: PrimitiveDateTime,+ pub modified_at: PrimitiveDateTime,+ pub last_synced: Option<PrimitiveDateTime>,+ pub cancellation_reason: Option<String>,+ pub browser_info: Option<serde_json::Value>,+ pub payment_token: Option<String>,+ pub error_code: Option<String>,+ pub connector_metadata: Option<serde_json::Value>,+ pub payment_experience: Option<storage_enums::PaymentExperience>,+ pub payment_method_data: Option<serde_json::Value>,+ pub straight_through_algorithm: Option<serde_json::Value>,+ pub preprocessing_step_id: Option<String>,+ pub error_reason: Option<String>,+ pub connector_response_reference_id: Option<String>,+ pub multiple_capture_count: Option<i16>,+ pub amount_capturable: MinorUnit,+ pub updated_by: String,+ pub merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,+ pub authentication_data: Option<serde_json::Value>,+ pub encoded_data: Option<String>,+ pub unified_code: Option<String>,+ pub unified_message: Option<String>,+ pub net_amount: Option<MinorUnit>,+ pub external_three_ds_authentication_attempted: Option<bool>,+ pub authentication_connector: Option<String>,+ pub authentication_id: Option<String>,+ pub fingerprint_id: Option<String>,+ pub payment_method_billing_address_id: Option<String>,+ pub charge_id: Option<String>,+ pub client_source: Option<String>,+ pub client_version: Option<String>,+ pub customer_acceptance: Option<pii::SecretSerdeValue>,+ pub profile_id: id_type::ProfileId,+ pub organization_id: id_type::OrganizationId,+ pub card_network: Option<String>,+}++#[cfg(feature = "v1")]#[derive(Clone, Debug, Serialize, Deserialize)]pub struct PaymentAttemptNew {pub payment_id: id_type::PaymentId,@@ -327,6 +495,19 @@ pub struct PaymentAttemptNew {pub order_tax_amount: Option<MinorUnit>,}+#[cfg(feature = "v2")]+impl PaymentAttemptNew {+ /// returns amount + surcharge_amount + tax_amount+ pub fn calculate_net_amount(&self) -> MinorUnit {+ todo!();+ }++ pub fn populate_derived_fields(self) -> Self {+ todo!()+ }+}++#[cfg(feature = "v1")]impl PaymentAttemptNew {/// returns amount + surcharge_amount + tax_amountpub fn calculate_net_amount(&self) -> MinorUnit {@@ -344,6 +525,7 @@ impl PaymentAttemptNew {}}+#[cfg(feature = "v1")]#[derive(Debug, Clone, Serialize, Deserialize)]pub enum PaymentAttemptUpdate {Update {@@ -535,1155 +717,26 @@ pub enum PaymentAttemptUpdate {},}-#[cfg(all(feature = "v2", feature = "payment_v2"))]-impl From<PaymentAttemptUpdate> for diesel_models::PaymentAttemptUpdateInternal {- fn from(payment_attempt_update: PaymentAttemptUpdate) -> Self {- match payment_attempt_update {- PaymentAttemptUpdate::Update {- amount,- currency,- status,- authentication_type,- payment_method,- payment_token,- payment_method_data,- payment_method_type,- payment_experience,- business_sub_label,- amount_to_capture,- capture_method,- surcharge_amount,- tax_amount,- fingerprint_id,- updated_by,- payment_method_billing_address_id,- } => Self {- amount: Some(amount),- currency: Some(currency),- status: Some(status),- authentication_type,- payment_method,- payment_token,- modified_at: common_utils::date_time::now(),- payment_method_data,- payment_method_type,- payment_experience,- business_sub_label,- amount_to_capture,- capture_method,- surcharge_amount,- tax_amount,- fingerprint_id,- payment_method_billing_address_id,- updated_by,- net_amount: None,- connector_transaction_id: None,- connector: None,- error_message: None,- payment_method_id: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- error_code: None,- connector_metadata: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- error_reason: None,- connector_response_reference_id: None,- multiple_capture_count: None,- amount_capturable: None,- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::AuthenticationTypeUpdate {- authentication_type,- updated_by,- } => Self {- authentication_type: Some(authentication_type),- modified_at: common_utils::date_time::now(),- updated_by,- amount: None,- net_amount: None,- currency: None,- status: None,- connector_transaction_id: None,- amount_to_capture: None,- connector: None,- payment_method: None,- error_message: None,- payment_method_id: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- error_code: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- error_reason: None,- capture_method: None,- connector_response_reference_id: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- amount_capturable: None,- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::ConfirmUpdate {- amount,- currency,- authentication_type,- capture_method,- status,- payment_method,- browser_info,- connector,- payment_token,- payment_method_data,- payment_method_type,- payment_experience,- business_sub_label,- straight_through_algorithm,- error_code,- error_message,- amount_capturable,- updated_by,- merchant_connector_id,- surcharge_amount,- tax_amount,- external_three_ds_authentication_attempted,- authentication_connector,- authentication_id,- payment_method_billing_address_id,- fingerprint_id,- payment_method_id,- client_source,- client_version,- customer_acceptance,- shipping_cost,- order_tax_amount,- } => Self {- amount: Some(amount),- currency: Some(currency),- authentication_type,- status: Some(status),- payment_method,- modified_at: common_utils::date_time::now(),- browser_info,- connector: connector.map(Some),- payment_token,- payment_method_data,- payment_method_type,- payment_experience,- business_sub_label,- straight_through_algorithm,- error_code,- error_message,- amount_capturable,- updated_by,- merchant_connector_id: merchant_connector_id.map(Some),- surcharge_amount,- tax_amount,- external_three_ds_authentication_attempted,- authentication_connector,- authentication_id,- payment_method_billing_address_id,- fingerprint_id,- payment_method_id,- capture_method,- client_source,- client_version,- customer_acceptance,- net_amount: None,- connector_transaction_id: None,- amount_to_capture: None,- cancellation_reason: None,- mandate_id: None,- connector_metadata: None,- preprocessing_step_id: None,- error_reason: None,- connector_response_reference_id: None,- multiple_capture_count: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- charge_id: None,- card_network: None,- shipping_cost,- order_tax_amount,- },- PaymentAttemptUpdate::VoidUpdate {- status,- cancellation_reason,- updated_by,- } => Self {- status: Some(status),- cancellation_reason,- modified_at: common_utils::date_time::now(),- updated_by,- amount: None,- net_amount: None,- currency: None,- connector_transaction_id: None,- amount_to_capture: None,- connector: None,- authentication_type: None,- payment_method: None,- error_message: None,- payment_method_id: None,- mandate_id: None,- browser_info: None,- payment_token: None,- error_code: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- error_reason: None,- capture_method: None,- connector_response_reference_id: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- amount_capturable: None,- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::RejectUpdate {- status,- error_code,- error_message,- updated_by,- } => Self {- status: Some(status),- modified_at: common_utils::date_time::now(),- error_code,- error_message,- updated_by,- amount: None,- net_amount: None,- currency: None,- connector_transaction_id: None,- amount_to_capture: None,- connector: None,- authentication_type: None,- payment_method: None,- payment_method_id: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- error_reason: None,- capture_method: None,- connector_response_reference_id: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- amount_capturable: None,- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::BlocklistUpdate {- status,- error_code,- error_message,- updated_by,- } => Self {- status: Some(status),- modified_at: common_utils::date_time::now(),- error_code,- connector: Some(None),- error_message,- updated_by,- merchant_connector_id: Some(None),- amount: None,- net_amount: None,- currency: None,- connector_transaction_id: None,- amount_to_capture: None,- authentication_type: None,- payment_method: None,- payment_method_id: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- error_reason: None,- capture_method: None,- connector_response_reference_id: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- amount_capturable: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::PaymentMethodDetailsUpdate {- payment_method_id,- updated_by,- } => Self {- payment_method_id,- modified_at: common_utils::date_time::now(),- updated_by,- amount: None,- net_amount: None,- currency: None,- status: None,- connector_transaction_id: None,- amount_to_capture: None,- connector: None,- authentication_type: None,- payment_method: None,- error_message: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- error_code: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- error_reason: None,- capture_method: None,- connector_response_reference_id: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- amount_capturable: None,- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::ResponseUpdate {- status,- connector,- connector_transaction_id,- authentication_type,- payment_method_id,- mandate_id,- connector_metadata,- payment_token,- error_code,- error_message,- error_reason,- connector_response_reference_id,- amount_capturable,- updated_by,- authentication_data,- encoded_data,- unified_code,- unified_message,- payment_method_data,- charge_id,- } => Self {- status: Some(status),- connector: connector.map(Some),- connector_transaction_id,- authentication_type,- payment_method_id,- modified_at: common_utils::date_time::now(),- mandate_id,- connector_metadata,- error_code,- error_message,- payment_token,- error_reason,- connector_response_reference_id,- amount_capturable,- updated_by,- authentication_data,- encoded_data,- unified_code,- unified_message,- payment_method_data,- charge_id,- amount: None,- net_amount: None,- currency: None,- amount_to_capture: None,- payment_method: None,- cancellation_reason: None,- browser_info: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- capture_method: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- merchant_connector_id: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::ErrorUpdate {- connector,- status,- error_code,- error_message,- error_reason,- amount_capturable,- updated_by,- unified_code,- unified_message,- connector_transaction_id,- payment_method_data,- authentication_type,- } => Self {- connector: connector.map(Some),- status: Some(status),- error_message,- error_code,- modified_at: common_utils::date_time::now(),- error_reason,- amount_capturable,- updated_by,- unified_code,- unified_message,- connector_transaction_id,- payment_method_data,- authentication_type,- amount: None,- net_amount: None,- currency: None,- amount_to_capture: None,- payment_method: None,- payment_method_id: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- connector_metadata: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- capture_method: None,- connector_response_reference_id: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::StatusUpdate { status, updated_by } => Self {- status: Some(status),- modified_at: common_utils::date_time::now(),- updated_by,- amount: None,- net_amount: None,- currency: None,- connector_transaction_id: None,- amount_to_capture: None,- connector: None,- authentication_type: None,- payment_method: None,- error_message: None,- payment_method_id: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- error_code: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- error_reason: None,- capture_method: None,- connector_response_reference_id: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- amount_capturable: None,- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::UpdateTrackers {- payment_token,- connector,- straight_through_algorithm,- amount_capturable,- surcharge_amount,- tax_amount,- updated_by,- merchant_connector_id,- } => Self {- payment_token,- modified_at: common_utils::date_time::now(),- connector: connector.map(Some),- straight_through_algorithm,- amount_capturable,- surcharge_amount,- tax_amount,- updated_by,- merchant_connector_id: merchant_connector_id.map(Some),- amount: None,- net_amount: None,- currency: None,- status: None,- connector_transaction_id: None,- amount_to_capture: None,- authentication_type: None,- payment_method: None,- error_message: None,- payment_method_id: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- error_code: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- preprocessing_step_id: None,- error_reason: None,- capture_method: None,- connector_response_reference_id: None,- multiple_capture_count: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::UnresolvedResponseUpdate {- status,- connector,- connector_transaction_id,- payment_method_id,- error_code,- error_message,- error_reason,- connector_response_reference_id,- updated_by,- } => Self {- status: Some(status),- connector: connector.map(Some),- connector_transaction_id,- payment_method_id,- modified_at: common_utils::date_time::now(),- error_code,- error_message,- error_reason,- connector_response_reference_id,- updated_by,- amount: None,- net_amount: None,- currency: None,- amount_to_capture: None,- authentication_type: None,- payment_method: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- capture_method: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- amount_capturable: None,- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::PreprocessingUpdate {- status,- payment_method_id,- connector_metadata,- preprocessing_step_id,- connector_transaction_id,- connector_response_reference_id,- updated_by,- } => Self {- status: Some(status),- payment_method_id,- modified_at: common_utils::date_time::now(),- connector_metadata,- preprocessing_step_id,- connector_transaction_id,- connector_response_reference_id,- updated_by,- amount: None,- net_amount: None,- currency: None,- amount_to_capture: None,- connector: None,- authentication_type: None,- payment_method: None,- error_message: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- error_code: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- error_reason: None,- capture_method: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- amount_capturable: None,- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::CaptureUpdate {- multiple_capture_count,- updated_by,- amount_to_capture,- } => Self {- multiple_capture_count,- modified_at: common_utils::date_time::now(),- updated_by,- amount_to_capture,- amount: None,- net_amount: None,- currency: None,- status: None,- connector_transaction_id: None,- connector: None,- authentication_type: None,- payment_method: None,- error_message: None,- payment_method_id: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- error_code: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- error_reason: None,- capture_method: None,- connector_response_reference_id: None,- surcharge_amount: None,- tax_amount: None,- amount_capturable: None,- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::AmountToCaptureUpdate {- status,- amount_capturable,- updated_by,- } => Self {- status: Some(status),- modified_at: common_utils::date_time::now(),- amount_capturable: Some(amount_capturable),- updated_by,- amount: None,- net_amount: None,- currency: None,- connector_transaction_id: None,- amount_to_capture: None,- connector: None,- authentication_type: None,- payment_method: None,- error_message: None,- payment_method_id: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- error_code: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- error_reason: None,- capture_method: None,- connector_response_reference_id: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::ConnectorResponse {- authentication_data,- encoded_data,- connector_transaction_id,- connector,- updated_by,- charge_id,- } => Self {- authentication_data,- encoded_data,- connector_transaction_id,- connector: connector.map(Some),- modified_at: common_utils::date_time::now(),- updated_by,- charge_id,- amount: None,- net_amount: None,- currency: None,- status: None,- amount_to_capture: None,- authentication_type: None,- payment_method: None,- error_message: None,- payment_method_id: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- error_code: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- error_reason: None,- capture_method: None,- connector_response_reference_id: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- amount_capturable: None,- merchant_connector_id: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::IncrementalAuthorizationAmountUpdate {- amount,- amount_capturable,- } => Self {- amount: Some(amount),- modified_at: common_utils::date_time::now(),- amount_capturable: Some(amount_capturable),- net_amount: None,- currency: None,- status: None,- connector_transaction_id: None,- amount_to_capture: None,- connector: None,- authentication_type: None,- payment_method: None,- error_message: None,- payment_method_id: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- error_code: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- error_reason: None,- capture_method: None,- connector_response_reference_id: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- updated_by: String::default(),- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::AuthenticationUpdate {- status,- external_three_ds_authentication_attempted,- authentication_connector,- authentication_id,- updated_by,- } => Self {- status: Some(status),- modified_at: common_utils::date_time::now(),- external_three_ds_authentication_attempted,- authentication_connector,- authentication_id,- updated_by,- amount: None,- net_amount: None,- currency: None,- connector_transaction_id: None,- amount_to_capture: None,- connector: None,- authentication_type: None,- payment_method: None,- error_message: None,- payment_method_id: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- error_code: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- error_reason: None,- capture_method: None,- connector_response_reference_id: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- amount_capturable: None,- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- unified_code: None,- unified_message: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- PaymentAttemptUpdate::ManualUpdate {- status,- error_code,- error_message,- error_reason,- updated_by,- unified_code,- unified_message,- connector_transaction_id,- } => Self {- status,- error_code: error_code.map(Some),- modified_at: common_utils::date_time::now(),- error_message: error_message.map(Some),- error_reason: error_reason.map(Some),- updated_by,- unified_code: unified_code.map(Some),- unified_message: unified_message.map(Some),- amount: None,- net_amount: None,- currency: None,- connector_transaction_id,- amount_to_capture: None,- connector: None,- authentication_type: None,- payment_method: None,- payment_method_id: None,- cancellation_reason: None,- mandate_id: None,- browser_info: None,- payment_token: None,- connector_metadata: None,- payment_method_data: None,- payment_method_type: None,- payment_experience: None,- business_sub_label: None,- straight_through_algorithm: None,- preprocessing_step_id: None,- capture_method: None,- connector_response_reference_id: None,- multiple_capture_count: None,- surcharge_amount: None,- tax_amount: None,- amount_capturable: None,- merchant_connector_id: None,- authentication_data: None,- encoded_data: None,- external_three_ds_authentication_attempted: None,- authentication_connector: None,- authentication_id: None,- fingerprint_id: None,- payment_method_billing_address_id: None,- charge_id: None,- client_source: None,- client_version: None,- customer_acceptance: None,- card_network: None,- shipping_cost: None,- order_tax_amount: None,- },- }+// TODO: Add fields as necessary+#[cfg(feature = "v2")]+#[derive(Debug, Clone, Serialize, Deserialize)]+pub enum PaymentAttemptUpdate {}++#[cfg(feature = "v2")]+impl ForeignIDRef for PaymentAttempt {+ fn foreign_id(&self) -> String {+ todo!()}}+#[cfg(feature = "v1")]impl ForeignIDRef for PaymentAttempt {fn foreign_id(&self) -> String {self.attempt_id.clone()}}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[async_trait::async_trait]impl behaviour::Conversion for PaymentAttempt {type DstType = DieselPaymentAttempt;@@ -1925,7 +978,7 @@ impl behaviour::Conversion for PaymentAttempt {}}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]#[async_trait::async_trait]impl behaviour::Conversion for PaymentAttempt {type DstType = DieselPaymentAttempt;@@ -1941,70 +994,118 @@ impl behaviour::Conversion for PaymentAttempt {.and_then(|card| card.get("card_network")).and_then(|network| network.as_str()).map(|network| network.to_string());++ let Self {+ payment_id,+ merchant_id,+ status,+ net_amount,+ error_message,+ surcharge_amount,+ tax_on_surcharge,+ confirm,+ authentication_type,+ created_at,+ modified_at,+ last_synced,+ cancellation_reason,+ browser_info,+ error_code,+ payment_token,+ connector_metadata,+ payment_experience,+ payment_method_data,+ routing_result,+ preprocessing_step_id,+ error_reason,+ multiple_capture_count,+ connector_response_reference_id,+ amount_capturable,+ updated_by,+ authentication_data,+ encoded_data,+ merchant_connector_id,+ unified_code,+ unified_message,+ external_three_ds_authentication_attempted,+ authentication_connector,+ authentication_id,+ payment_method_billing_address_id,+ fingerprint_id,+ charge_id,+ client_source,+ client_version,+ customer_acceptance,+ profile_id,+ organization_id,+ payment_method_type,+ connector_payment_id,+ payment_method_subtype,+ authentication_applied,+ external_reference_id,+ id,+ amount_to_capture,+ payment_method_id,+ shipping_cost,+ order_tax_amount,+ connector,+ } = self;+Ok(DieselPaymentAttempt {- payment_id: self.payment_id,- merchant_id: self.merchant_id,- attempt_id: self.attempt_id,- status: self.status,- amount: self.amount,- currency: self.currency,- save_to_locker: self.save_to_locker,- connector: self.connector,- error_message: self.error_message,- offer_amount: self.offer_amount,- surcharge_amount: self.surcharge_amount,- tax_amount: self.tax_amount,- payment_method_id: self.payment_method_id,- payment_method: self.payment_method,- connector_transaction_id: self.connector_transaction_id,- capture_method: self.capture_method,- capture_on: self.capture_on,- confirm: self.confirm,- authentication_type: self.authentication_type,- created_at: self.created_at,- modified_at: self.modified_at,- last_synced: self.last_synced,- cancellation_reason: self.cancellation_reason,- amount_to_capture: self.amount_to_capture,- mandate_id: self.mandate_id,- browser_info: self.browser_info,- error_code: self.error_code,- payment_token: self.payment_token,- connector_metadata: self.connector_metadata,- payment_experience: self.payment_experience,- payment_method_type: self.payment_method_type,- payment_method_data: self.payment_method_data,- business_sub_label: self.business_sub_label,- straight_through_algorithm: self.straight_through_algorithm,- preprocessing_step_id: self.preprocessing_step_id,- mandate_details: self.mandate_details.map(Into::into),- error_reason: self.error_reason,- multiple_capture_count: self.multiple_capture_count,- connector_response_reference_id: self.connector_response_reference_id,- amount_capturable: self.amount_capturable,- updated_by: self.updated_by,- merchant_connector_id: self.merchant_connector_id,- authentication_data: self.authentication_data,- encoded_data: self.encoded_data,- unified_code: self.unified_code,- unified_message: self.unified_message,- net_amount: Some(self.net_amount),- external_three_ds_authentication_attempted: self- .external_three_ds_authentication_attempted,- authentication_connector: self.authentication_connector,- authentication_id: self.authentication_id,- mandate_data: self.mandate_data.map(Into::into),- fingerprint_id: self.fingerprint_id,- payment_method_billing_address_id: self.payment_method_billing_address_id,- charge_id: self.charge_id,- client_source: self.client_source,- client_version: self.client_version,- customer_acceptance: self.customer_acceptance,- profile_id: self.profile_id,- organization_id: self.organization_id,+ payment_id,+ merchant_id,+ id,+ status,+ error_message,+ surcharge_amount,+ tax_on_surcharge,+ payment_method_id,+ payment_method_type_v2: payment_method_type,+ connector_payment_id,+ confirm,+ authentication_type,+ created_at,+ modified_at,+ last_synced,+ cancellation_reason,+ amount_to_capture,+ browser_info,+ error_code,+ payment_token,+ connector_metadata,+ payment_experience,+ payment_method_subtype,+ payment_method_data,+ preprocessing_step_id,+ error_reason,+ multiple_capture_count,+ connector_response_reference_id,+ amount_capturable,+ updated_by,+ merchant_connector_id,+ authentication_data,+ encoded_data,+ unified_code,+ unified_message,+ net_amount: Some(net_amount),+ external_three_ds_authentication_attempted,+ authentication_connector,+ authentication_id,+ fingerprint_id,+ payment_method_billing_address_id,+ charge_id,+ client_source,+ client_version,+ customer_acceptance,+ profile_id,+ organization_id,card_network,- order_tax_amount: self.order_tax_amount,- shipping_cost: self.shipping_cost,+ order_tax_amount,+ shipping_cost,+ routing_result,+ authentication_applied,+ external_reference_id,+ connector,})}@@ -2018,26 +1119,18 @@ impl behaviour::Conversion for PaymentAttempt {Self: Sized,{async {- let net_amount = storage_model.get_or_calculate_net_amount();Ok::<Self, error_stack::Report<common_utils::errors::CryptoError>>(Self {payment_id: storage_model.payment_id,merchant_id: storage_model.merchant_id,- attempt_id: storage_model.attempt_id,+ id: storage_model.id,status: storage_model.status,- amount: storage_model.amount,- net_amount,- currency: storage_model.currency,- save_to_locker: storage_model.save_to_locker,- connector: storage_model.connector,+ net_amount: storage_model.net_amount.unwrap_or(MinorUnit::new(0)),+ tax_on_surcharge: storage_model.tax_on_surcharge,error_message: storage_model.error_message,- offer_amount: storage_model.offer_amount,surcharge_amount: storage_model.surcharge_amount,- tax_amount: storage_model.tax_amount,payment_method_id: storage_model.payment_method_id,- payment_method: storage_model.payment_method,- connector_transaction_id: storage_model.connector_transaction_id,- capture_method: storage_model.capture_method,- capture_on: storage_model.capture_on,+ payment_method_type: storage_model.payment_method_type_v2,+ connector_payment_id: storage_model.connector_payment_id,confirm: storage_model.confirm,authentication_type: storage_model.authentication_type,created_at: storage_model.created_at,@@ -2045,18 +1138,14 @@ impl behaviour::Conversion for PaymentAttempt {last_synced: storage_model.last_synced,cancellation_reason: storage_model.cancellation_reason,amount_to_capture: storage_model.amount_to_capture,- mandate_id: storage_model.mandate_id,browser_info: storage_model.browser_info,error_code: storage_model.error_code,payment_token: storage_model.payment_token,connector_metadata: storage_model.connector_metadata,payment_experience: storage_model.payment_experience,- payment_method_type: storage_model.payment_method_type,payment_method_data: storage_model.payment_method_data,- business_sub_label: storage_model.business_sub_label,- straight_through_algorithm: storage_model.straight_through_algorithm,+ routing_result: storage_model.routing_result,preprocessing_step_id: storage_model.preprocessing_step_id,- mandate_details: storage_model.mandate_details.map(Into::into),error_reason: storage_model.error_reason,multiple_capture_count: storage_model.multiple_capture_count,connector_response_reference_id: storage_model.connector_response_reference_id,@@ -2071,7 +1160,6 @@ impl behaviour::Conversion for PaymentAttempt {.external_three_ds_authentication_attempted,authentication_connector: storage_model.authentication_connector,authentication_id: storage_model.authentication_id,- mandate_data: storage_model.mandate_data.map(Into::into),payment_method_billing_address_id: storage_model.payment_method_billing_address_id,fingerprint_id: storage_model.fingerprint_id,charge_id: storage_model.charge_id,@@ -2082,6 +1170,10 @@ impl behaviour::Conversion for PaymentAttempt {organization_id: storage_model.organization_id,order_tax_amount: storage_model.order_tax_amount,shipping_cost: storage_model.shipping_cost,+ payment_method_subtype: storage_model.payment_method_subtype,+ authentication_applied: storage_model.authentication_applied,+ external_reference_id: storage_model.external_reference_id,+ connector: storage_model.connector,})}.await@@ -2100,42 +1192,28 @@ impl behaviour::Conversion for PaymentAttempt {.and_then(|card| card.get("card_network")).and_then(|network| network.as_str()).map(|network| network.to_string());+Ok(DieselPaymentAttemptNew {payment_id: self.payment_id,merchant_id: self.merchant_id,- attempt_id: self.attempt_id,status: self.status,- amount: self.amount,- currency: self.currency,- save_to_locker: self.save_to_locker,- connector: self.connector,error_message: self.error_message,- offer_amount: self.offer_amount,surcharge_amount: self.surcharge_amount,- tax_amount: self.tax_amount,+ tax_on_surcharge: self.tax_on_surcharge,payment_method_id: self.payment_method_id,- payment_method: self.payment_method,- capture_method: self.capture_method,- capture_on: self.capture_on,confirm: self.confirm,authentication_type: self.authentication_type,created_at: self.created_at,modified_at: self.modified_at,last_synced: self.last_synced,cancellation_reason: self.cancellation_reason,- amount_to_capture: self.amount_to_capture,- mandate_id: self.mandate_id,browser_info: self.browser_info,payment_token: self.payment_token,error_code: self.error_code,connector_metadata: self.connector_metadata,payment_experience: self.payment_experience,- payment_method_type: self.payment_method_type,payment_method_data: self.payment_method_data,- business_sub_label: self.business_sub_label,- straight_through_algorithm: self.straight_through_algorithm,preprocessing_step_id: self.preprocessing_step_id,- mandate_details: self.mandate_details.map(Into::into),error_reason: self.error_reason,connector_response_reference_id: self.connector_response_reference_id,multiple_capture_count: self.multiple_capture_count,@@ -2151,7 +1229,6 @@ impl behaviour::Conversion for PaymentAttempt {.external_three_ds_authentication_attempted,authentication_connector: self.authentication_connector,authentication_id: self.authentication_id,- mandate_data: self.mandate_data.map(Into::into),fingerprint_id: self.fingerprint_id,payment_method_billing_address_id: self.payment_method_billing_address_id,charge_id: self.charge_id,@@ -2163,6 +1240,14 @@ impl behaviour::Conversion for PaymentAttempt {card_network,order_tax_amount: self.order_tax_amount,shipping_cost: self.shipping_cost,+ amount_to_capture: self.amount_to_capture,})}}++#[cfg(feature = "v2")]+impl From<PaymentAttemptUpdate> for diesel_models::PaymentAttemptUpdateInternal {+ fn from(update: PaymentAttemptUpdate) -> Self {+ todo!()+ }+}diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rsindex 381a84ce82..bd4707243c 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs@@ -20,7 +20,9 @@ use masking::{Deserialize, PeekInterface, Secret};use serde::Serialize;use time::PrimitiveDateTime;-use super::{payment_attempt::PaymentAttempt, PaymentIntent};+#[cfg(all(feature = "v1", feature = "olap"))]+use super::payment_attempt::PaymentAttempt;+use super::PaymentIntent;use crate::{behaviour, errors,merchant_key_store::MerchantKeyStore,@@ -46,7 +48,7 @@ pub trait PaymentIntentInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentIntent, errors::StorageError>;- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_intent_by_payment_id_merchant_id(&self,state: &KeyManagerState,@@ -56,7 +58,7 @@ pub trait PaymentIntentInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentIntent, errors::StorageError>;- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]async fn find_payment_intent_by_id(&self,state: &KeyManagerState,@@ -65,17 +67,7 @@ pub trait PaymentIntentInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentIntent, errors::StorageError>;- async fn get_active_payment_attempt(- &self,- payment: &mut PaymentIntent,- storage_scheme: storage_enums::MerchantStorageScheme,- ) -> error_stack::Result<PaymentAttempt, errors::StorageError>;-- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn filter_payment_intent_by_constraints(&self,state: &KeyManagerState,@@ -85,11 +77,7 @@ pub trait PaymentIntentInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<PaymentIntent>, errors::StorageError>;- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn filter_payment_intents_by_time_range_constraints(&self,state: &KeyManagerState,@@ -99,11 +87,7 @@ pub trait PaymentIntentInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<PaymentIntent>, errors::StorageError>;- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn get_intent_status_with_count(&self,merchant_id: &id_type::MerchantId,@@ -111,11 +95,7 @@ pub trait PaymentIntentInterface {constraints: &common_utils::types::TimeRange,) -> error_stack::Result<Vec<(common_enums::IntentStatus, i64)>, errors::StorageError>;- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn get_filtered_payment_intents_attempt(&self,state: &KeyManagerState,@@ -125,11 +105,7 @@ pub trait PaymentIntentInterface {storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<(PaymentIntent, PaymentAttempt)>, errors::StorageError>;- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn get_filtered_active_attempt_ids_for_total_count(&self,merchant_id: &id_type::MerchantId,@@ -146,7 +122,7 @@ pub struct CustomerData {pub phone_country_code: Option<String>,}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]#[derive(Debug, Clone, Serialize)]pub struct PaymentIntentUpdateFields {pub amount: Option<MinorUnit>,@@ -171,7 +147,7 @@ pub struct PaymentIntentUpdateFields {pub is_payment_processor_token_flow: Option<bool>,}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[derive(Debug, Clone, Serialize)]pub struct PaymentIntentUpdateFields {pub amount: MinorUnit,@@ -203,7 +179,7 @@ pub struct PaymentIntentUpdateFields {pub tax_details: Option<diesel_models::TaxDetails>,}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[derive(Debug, Clone, Serialize)]pub enum PaymentIntentUpdate {ResponseUpdate {@@ -286,7 +262,7 @@ pub enum PaymentIntentUpdate {}// TODO: remove all enum variants and create new variants that should be used for v2-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]#[derive(Debug, Clone, Serialize)]pub enum PaymentIntentUpdate {ResponseUpdate {@@ -359,7 +335,7 @@ pub enum PaymentIntentUpdate {},}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]#[derive(Clone, Debug, Default)]pub struct PaymentIntentUpdateInternal {pub amount: Option<MinorUnit>,@@ -392,7 +368,7 @@ pub struct PaymentIntentUpdateInternal {pub is_payment_processor_token_flow: Option<bool>,}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[derive(Clone, Debug, Default)]pub struct PaymentIntentUpdateInternal {pub amount: Option<MinorUnit>,@@ -436,7 +412,7 @@ pub struct PaymentIntentUpdateInternal {pub tax_details: Option<diesel_models::TaxDetails>,}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {fn from(payment_intent_update: PaymentIntentUpdate) -> Self {todo!()@@ -614,7 +590,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {}}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {fn from(payment_intent_update: PaymentIntentUpdate) -> Self {match payment_intent_update {@@ -815,7 +791,7 @@ use diesel_models::{PaymentIntentUpdate as DieselPaymentIntentUpdate,PaymentIntentUpdateFields as DieselPaymentIntentUpdateFields,};-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {fn from(value: PaymentIntentUpdate) -> Self {todo!()@@ -959,7 +935,7 @@ impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {}}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {fn from(value: PaymentIntentUpdate) -> Self {match value {@@ -1131,7 +1107,7 @@ impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {}// TODO: evaluate if we will be using the same update struct for v2 as well, uncomment this and make necessary changes if necessary-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInternal {fn from(value: PaymentIntentUpdateInternal) -> Self {todo!()@@ -1199,7 +1175,7 @@ impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInt}}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInternal {fn from(value: PaymentIntentUpdateInternal) -> Self {let modified_at = common_utils::date_time::now();@@ -1474,7 +1450,7 @@ where}}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]#[async_trait::async_trait]impl behaviour::Conversion for PaymentIntent {type DstType = DieselPaymentIntent;@@ -1747,7 +1723,7 @@ impl behaviour::Conversion for PaymentIntent {}}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[async_trait::async_trait]impl behaviour::Conversion for PaymentIntent {type DstType = DieselPaymentIntent;diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rsindex 2146b97d6e..5a0d599dcb 100644--- a/crates/hyperswitch_domain_models/src/router_request_types.rs+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs@@ -527,6 +527,7 @@ impl SurchargeDetails {}}+#[cfg(feature = "v1")]implFrom<(&RequestSurchargeDetails,@@ -554,6 +555,23 @@ impl}}+#[cfg(feature = "v2")]+impl+ From<(+ &RequestSurchargeDetails,+ &payments::payment_attempt::PaymentAttempt,+ )> for SurchargeDetails+{+ fn from(+ (request_surcharge_details, payment_attempt): (+ &RequestSurchargeDetails,+ &payments::payment_attempt::PaymentAttempt,+ ),+ ) -> Self {+ todo!()+ }+}+#[derive(Debug, Clone)]pub struct AuthenticationData {pub eci: Option<String>,diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.tomlindex 7159f34e4b..69c23730b9 100644--- a/crates/router/Cargo.toml+++ b/crates/router/Cargo.toml@@ -33,10 +33,9 @@ payouts = ["api_models/payouts", "common_enums/payouts", "hyperswitch_connectorspayout_retry = ["payouts"]recon = ["email", "api_models/recon"]retry = []-v2 = ["customer_v2", "payment_methods_v2", "payment_v2", "common_default", "api_models/v2", "diesel_models/v2", "hyperswitch_domain_models/v2", "storage_impl/v2", "kgraph_utils/v2", "common_utils/v2"]+v2 = ["customer_v2", "payment_methods_v2", "common_default", "api_models/v2", "diesel_models/v2", "hyperswitch_domain_models/v2", "storage_impl/v2", "kgraph_utils/v2", "common_utils/v2"]v1 = ["common_default", "api_models/v1", "diesel_models/v1", "hyperswitch_domain_models/v1", "storage_impl/v1", "hyperswitch_interfaces/v1", "kgraph_utils/v1"]customer_v2 = ["api_models/customer_v2", "diesel_models/customer_v2", "hyperswitch_domain_models/customer_v2", "storage_impl/customer_v2"]-payment_v2 = ["api_models/payment_v2", "diesel_models/payment_v2", "hyperswitch_domain_models/payment_v2", "storage_impl/payment_v2"]payment_methods_v2 = ["api_models/payment_methods_v2", "diesel_models/payment_methods_v2", "hyperswitch_domain_models/payment_methods_v2", "storage_impl/payment_methods_v2", "common_utils/payment_methods_v2"]dynamic_routing = ["external_services/dynamic_routing", "storage_impl/dynamic_routing"]@@ -83,7 +82,7 @@ nanoid = "0.4.0"num_cpus = "1.16.0"num-traits = "0.2.19"once_cell = "1.19.0"-openidconnect = "3.5.0" # TODO: remove reqwest+openidconnect = "3.5.0" # TODO: remove reqwestopenssl = "0.10.64"quick-xml = { version = "0.31.0", features = ["serialize"] }rand = "0.8.5"@@ -124,7 +123,7 @@ x509-parser = "0.16.0"# First party cratesanalytics = { version = "0.1.0", path = "../analytics", optional = true, default-features = false }-api_models = { version = "0.1.0", path = "../api_models", features = ["errors"]}+api_models = { version = "0.1.0", path = "../api_models", features = ["errors"] }cards = { version = "0.1.0", path = "../cards" }common_enums = { version = "0.1.0", path = "../common_enums" }common_utils = { version = "0.1.0", path = "../common_utils", features = ["signals", "async_ext", "logs", "metrics", "keymanager", "encryption_service"] }diff --git a/crates/router/src/core/fraud_check.rs b/crates/router/src/core/fraud_check.rsindex 2217de2090..70c35b460e 100644--- a/crates/router/src/core/fraud_check.rs+++ b/crates/router/src/core/fraud_check.rs@@ -763,6 +763,7 @@ pub fn is_operation_allowed<Op: Debug>(operation: &Op) -> bool {.contains(&format!("{operation:?}").as_str())}+#[cfg(feature = "v1")]impl From<PaymentToFrmData> for PaymentDetails {fn from(payment_data: PaymentToFrmData) -> Self {Self {@@ -837,7 +838,7 @@ pub async fn frm_fulfillment_core(}}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[instrument(skip_all)]pub async fn make_fulfillment_api_call(db: &dyn StorageInterface,diff --git a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs b/crates/router/src/core/fraud_check/operation/fraud_check_post.rsindex 65079f633d..8a9a91fb1e 100644--- a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs+++ b/crates/router/src/core/fraud_check/operation/fraud_check_post.rs@@ -588,7 +588,7 @@ whereupdated_by: frm_data.merchant_account.storage_scheme.to_string(),};- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]let payment_attempt = db.update_payment_attempt_with_attempt_id(payment_data.get_payment_attempt().clone(),@@ -598,7 +598,7 @@ where.await.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]let payment_attempt = db.update_payment_attempt_with_attempt_id(key_manager_state,diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex 578655a927..3c09db61a3 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -4735,11 +4735,7 @@ async fn get_pm_list_context(Ok(payment_method_retrieval_context)}-#[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- not(feature = "payment_methods_v2")-))]+#[cfg(feature = "v1")]async fn perform_surcharge_ops(payment_intent: Option<storage::PaymentIntent>,state: &routes::SessionState,@@ -4784,7 +4780,7 @@ async fn perform_surcharge_ops(Ok(())}-#[cfg(all(feature = "v2", feature = "payment_v2", feature = "payment_methods_v2"))]+#[cfg(feature = "v2")]pub async fn perform_surcharge_ops(_payment_intent: Option<storage::PaymentIntent>,_state: &routes::SessionState,diff --git a/crates/router/src/core/payment_methods/surcharge_decision_configs.rs b/crates/router/src/core/payment_methods/surcharge_decision_configs.rsindex eaf100a0cb..982d13b54b 100644--- a/crates/router/src/core/payment_methods/surcharge_decision_configs.rs+++ b/crates/router/src/core/payment_methods/surcharge_decision_configs.rs@@ -101,6 +101,22 @@ impl SurchargeSource {}}+#[cfg(feature = "v2")]+pub async fn perform_surcharge_decision_management_for_payment_method_list(+ _state: &SessionState,+ _algorithm_ref: routing::RoutingAlgorithmRef,+ _payment_attempt: &storage::PaymentAttempt,+ _payment_intent: &storage::PaymentIntent,+ _billing_address: Option<payments::Address>,+ _response_payment_method_types: &mut [api_models::payment_methods::ResponsePaymentMethodsEnabled],+) -> ConditionalConfigResult<(+ types::SurchargeMetadata,+ surcharge_decision_configs::MerchantSurchargeConfigs,+)> {+ todo!()+}++#[cfg(feature = "v1")]pub async fn perform_surcharge_decision_management_for_payment_method_list(state: &SessionState,algorithm_ref: routing::RoutingAlgorithmRef,@@ -220,6 +236,7 @@ pub async fn perform_surcharge_decision_management_for_payment_method_list(Ok((surcharge_metadata, merchant_surcharge_configs))}+#[cfg(feature = "v1")]pub async fn perform_surcharge_decision_management_for_session_flow(state: &SessionState,algorithm_ref: routing::RoutingAlgorithmRef,@@ -358,7 +375,7 @@ pub async fn perform_surcharge_decision_management_for_saved_cards(payment_intent: &storage::PaymentIntent,customer_payment_method_list: &mut [api_models::payment_methods::CustomerPaymentMethod],) -> ConditionalConfigResult<types::SurchargeMetadata> {- let mut surcharge_metadata = types::SurchargeMetadata::new(payment_attempt.attempt_id.clone());+ let mut surcharge_metadata = types::SurchargeMetadata::new(payment_attempt.id.clone());let surcharge_source = match (payment_attempt.get_surcharge_details(),algorithm_ref.surcharge_config_algo_id,@@ -424,6 +441,15 @@ pub async fn perform_surcharge_decision_management_for_saved_cards(Ok(surcharge_metadata)}+#[cfg(feature = "v2")]+fn get_surcharge_details_from_surcharge_output(+ _surcharge_details: surcharge_decision_configs::SurchargeDetailsOutput,+ _payment_attempt: &storage::PaymentAttempt,+) -> ConditionalConfigResult<types::SurchargeDetails> {+ todo!()+}++#[cfg(feature = "v1")]fn get_surcharge_details_from_surcharge_output(surcharge_details: surcharge_decision_configs::SurchargeDetailsOutput,payment_attempt: &storage::PaymentAttempt,diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 4bfca852fb..d00d4b7b25 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -103,6 +103,7 @@ use crate::{types::{api::authentication, BrowserInformation},};+#[cfg(feature = "v1")]#[allow(clippy::too_many_arguments, clippy::type_complexity)]#[instrument(skip_all, fields(payment_id, merchant_id))]pub async fn payments_operation_core<F, Req, Op, FData, D>(@@ -825,6 +826,21 @@ pub fn get_connector_data(.attach_printable("Connector not found in connectors iterator")}+#[cfg(feature = "v2")]+#[instrument(skip_all)]+pub async fn call_surcharge_decision_management_for_session_flow(+ _state: &SessionState,+ _merchant_account: &domain::MerchantAccount,+ _business_profile: &domain::Profile,+ _payment_attempt: &storage::PaymentAttempt,+ _payment_intent: &storage::PaymentIntent,+ _billing_address: Option<api_models::payments::Address>,+ _session_connector_data: &[api::SessionConnectorData],+) -> RouterResult<Option<api::SessionSurchargeDetails>> {+ todo!()+}++#[cfg(feature = "v1")]#[instrument(skip_all)]pub async fn call_surcharge_decision_management_for_session_flow(state: &SessionState,@@ -888,6 +904,8 @@ pub async fn call_surcharge_decision_management_for_session_flow(})}}++#[cfg(feature = "v1")]#[allow(clippy::too_many_arguments)]pub async fn payments_core<F, Res, Req, Op, FData, D>(state: SessionState,@@ -2059,6 +2077,32 @@ whereOk(payment_data)}+#[cfg(feature = "v2")]+pub async fn call_create_connector_customer_if_required<F, Req, D>(+ _state: &SessionState,+ _customer: &Option<domain::Customer>,+ _merchant_account: &domain::MerchantAccount,+ _key_store: &domain::MerchantKeyStore,+ _merchant_connector_account: &helpers::MerchantConnectorAccountType,+ _payment_data: &mut D,+) -> RouterResult<Option<storage::CustomerUpdate>>+where+ F: Send + Clone + Sync,+ Req: Send + Sync,++ // To create connector flow specific interface data+ D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,+ D: ConstructFlowSpecificData<F, Req, router_types::PaymentsResponseData>,+ RouterData<F, Req, router_types::PaymentsResponseData>: Feature<F, Req> + Send,++ // To construct connector flow specific api+ dyn api::Connector:+ services::api::ConnectorIntegration<F, Req, router_types::PaymentsResponseData>,+{+ todo!()+}++#[cfg(feature = "v1")]pub async fn call_create_connector_customer_if_required<F, Req, D>(state: &SessionState,customer: &Option<domain::Customer>,@@ -2305,7 +2349,7 @@ where_ => {// 3DS validation for paypal cards after verification (authorize call)if connector.connector_name == router_types::Connector::Paypal- && payment_data.get_payment_attempt().payment_method+ && payment_data.get_payment_attempt().get_payment_method()== Some(storage_enums::PaymentMethod::Card)&& matches!(format!("{operation:?}").as_str(), "CompleteAuthorize"){@@ -2656,6 +2700,26 @@ pub enum TokenizationAction {TokenizeInConnectorAndApplepayPreDecrypt(payments_api::PaymentProcessingDetails),}+#[cfg(feature = "v2")]+#[allow(clippy::too_many_arguments)]+pub async fn get_connector_tokenization_action_when_confirm_true<F, Req, D>(+ _state: &SessionState,+ _operation: &BoxedOperation<'_, F, Req, D>,+ _payment_data: &mut D,+ _validate_result: &operations::ValidateResult,+ _merchant_connector_account: &helpers::MerchantConnectorAccountType,+ _merchant_key_store: &domain::MerchantKeyStore,+ _customer: &Option<domain::Customer>,+ _business_profile: &domain::Profile,+) -> RouterResult<(D, TokenizationAction)>+where+ F: Send + Clone,+ D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,+{+ todo!()+}++#[cfg(feature = "v1")]#[allow(clippy::too_many_arguments)]pub async fn get_connector_tokenization_action_when_confirm_true<F, Req, D>(state: &SessionState,@@ -3037,7 +3101,7 @@ wherepayment_data.get_payment_intent().status,storage_enums::IntentStatus::Processing) && matches!(- payment_data.get_payment_attempt().capture_method,+ payment_data.get_capture_method(),Some(storage_enums::CaptureMethod::ManualMultiple)))}@@ -3350,7 +3414,7 @@ pub async fn add_process_sync_task(let tracking_data = api::PaymentsRetrieveRequest {force_sync: true,merchant_id: Some(payment_attempt.merchant_id.clone()),- resource_id: api::PaymentIdType::PaymentAttemptId(payment_attempt.attempt_id.clone()),+ resource_id: api::PaymentIdType::PaymentAttemptId(payment_attempt.get_id().to_owned()),..Default::default()};let runner = storage::ProcessTrackerRunner::PaymentsSyncWorkflow;@@ -3359,7 +3423,7 @@ pub async fn add_process_sync_task(let process_tracker_id = pt_utils::get_process_tracker_id(runner,task,- &payment_attempt.attempt_id,+ payment_attempt.get_id(),&payment_attempt.merchant_id,);let process_tracker_entry = storage::ProcessTrackerNew::new(@@ -3386,7 +3450,7 @@ pub async fn reset_process_sync_task(let process_tracker_id = pt_utils::get_process_tracker_id(runner,task,- &payment_attempt.attempt_id,+ payment_attempt.get_id(),&payment_attempt.merchant_id,);let psync_process = db@@ -3399,6 +3463,7 @@ pub async fn reset_process_sync_task(Ok(())}+#[cfg(feature = "v1")]pub fn update_straight_through_routing<F, D>(payment_data: &mut D,request_straight_through: serde_json::Value,@@ -3417,6 +3482,7 @@ whereOk(())}+#[cfg(feature = "v1")]#[allow(clippy::too_many_arguments)]pub async fn get_connector_choice<F, Req, D>(operation: &BoxedOperation<'_, F, Req, D>,@@ -3498,6 +3564,7 @@ whereOk(connector)}+#[cfg(feature = "v1")]#[allow(clippy::too_many_arguments)]pub async fn connector_selection<F, D>(state: &SessionState,@@ -4336,7 +4403,10 @@ pub fn should_add_task_to_process_tracker<F: Clone, D: OperationSessionGetters<Flet connector = payment_data.get_payment_attempt().connector.as_deref();!matches!(- (payment_data.get_payment_attempt().payment_method, connector),+ (+ payment_data.get_payment_attempt().get_payment_method(),+ connector+ ),(Some(storage_enums::PaymentMethod::BankTransfer),Some("stripe")@@ -5035,6 +5105,7 @@ pub trait OperationSessionGetters<F> {fn get_token_data(&self) -> Option<&storage::PaymentTokenData>;fn get_mandate_connector(&self) -> Option<&MandateConnectorDetails>;fn get_force_sync(&self) -> Option<bool>;+ fn get_capture_method(&self) -> Option<enums::CaptureMethod>;}pub trait OperationSessionSetters<F> {@@ -5052,6 +5123,7 @@ pub trait OperationSessionSetters<F> {&mut self,merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,);+ #[cfg(feature = "v1")]fn set_capture_method_in_attempt(&mut self, capture_method: enums::CaptureMethod);fn set_frm_message(&mut self, frm_message: FraudCheck);fn set_payment_intent_status(&mut self, status: storage_enums::IntentStatus);@@ -5069,6 +5141,8 @@ pub trait OperationSessionSetters<F> {&mut self,setup_future_usage: storage_enums::FutureUsage,);++ #[cfg(feature = "v1")]fn set_straight_through_algorithm_in_payment_attempt(&mut self,straight_through_algorithm: serde_json::Value,@@ -5199,6 +5273,16 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentData<F> {fn get_force_sync(&self) -> Option<bool> {self.force_sync}++ #[cfg(feature = "v1")]+ fn get_capture_method(&self) -> Option<enums::CaptureMethod> {+ self.payment_attempt.capture_method+ }++ #[cfg(feature = "v2")]+ fn get_capture_method(&self) -> Option<enums::CaptureMethod> {+ self.payment_intent.capture_method+ }}impl<F: Clone> OperationSessionSetters<F> for PaymentData<F> {@@ -5246,6 +5330,7 @@ impl<F: Clone> OperationSessionSetters<F> for PaymentData<F> {self.payment_attempt.merchant_connector_id = merchant_connector_id;}+ #[cfg(feature = "v1")]fn set_capture_method_in_attempt(&mut self, capture_method: enums::CaptureMethod) {self.payment_attempt.capture_method = Some(capture_method);}@@ -5284,6 +5369,7 @@ impl<F: Clone> OperationSessionSetters<F> for PaymentData<F> {self.payment_intent.setup_future_usage = Some(setup_future_usage);}+ #[cfg(feature = "v1")]fn set_straight_through_algorithm_in_payment_attempt(&mut self,straight_through_algorithm: serde_json::Value,@@ -5414,6 +5500,10 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentIntentData<F> {fn get_force_sync(&self) -> Option<bool> {todo!()}++ fn get_capture_method(&self) -> Option<enums::CaptureMethod> {+ todo!()+ }}#[cfg(feature = "v2")]@@ -5462,10 +5552,6 @@ impl<F: Clone> OperationSessionSetters<F> for PaymentIntentData<F> {todo!()}- fn set_capture_method_in_attempt(&mut self, _capture_method: enums::CaptureMethod) {- todo!()- }-fn set_frm_message(&mut self, _frm_message: FraudCheck) {todo!()}@@ -5500,13 +5586,6 @@ impl<F: Clone> OperationSessionSetters<F> for PaymentIntentData<F> {self.payment_intent.setup_future_usage = Some(setup_future_usage);}- fn set_straight_through_algorithm_in_payment_attempt(- &mut self,- _straight_through_algorithm: serde_json::Value,- ) {- todo!()- }-fn set_connector_in_payment_attempt(&mut self, _connector: Option<String>) {todo!()}diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rsindex 6fbe98b3a4..03b2a3153e 100644--- a/crates/router/src/core/payments/flows/authorize_flow.rs+++ b/crates/router/src/core/payments/flows/authorize_flow.rs@@ -72,7 +72,7 @@ impl) -> RouterResult<Option<types::MerchantRecipientData>> {let payment_method = &self.payment_attempt- .payment_method+ .get_payment_method().get_required_value("PaymentMethod")?;let data = if *payment_method == enums::PaymentMethod::OpenBanking {diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex a2fbb3bae4..3782026835 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -887,6 +887,7 @@ pub fn validate_request_amount_and_amount_to_capture(}}+#[cfg(feature = "v1")]/// if capture method = automatic, amount_to_capture(if provided) must be equal to amount#[instrument(skip_all)]pub fn validate_amount_to_capture_and_capture_method(@@ -2266,7 +2267,7 @@ pub async fn store_in_vault_and_generate_ppmt().await?;let parent_payment_method_token = generate_id(consts::ID_LENGTH, "token");- let key_for_hyperswitch_token = payment_attempt.payment_method.map(|payment_method| {+ let key_for_hyperswitch_token = payment_attempt.get_payment_method().map(|payment_method| {payment_methods_handler::ParentPaymentMethodToken::create_key_for_token((&parent_payment_method_token,payment_method,@@ -3870,7 +3871,7 @@ pub enum AttemptType {}impl AttemptType {- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]// The function creates a new payment_attempt from the previous payment attempt but doesn't populate fields like payment_method, error_code etc.// Logic to override the fields with data provided in the request should be done after this if required.// In case if fields are not overridden by the request then they contain the same data that was in the previous attempt provided it is populated in this function.@@ -3965,7 +3966,7 @@ impl AttemptType {}}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]// The function creates a new payment_attempt from the previous payment attempt but doesn't populate fields like payment_method, error_code etc.// Logic to override the fields with data provided in the request should be done after this if required.// In case if fields are not overridden by the request then they contain the same data that was in the previous attempt provided it is populated in this function.@@ -4007,7 +4008,7 @@ impl AttemptType {storage_scheme,);- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]let new_payment_attempt = db.insert_payment_attempt(new_payment_attempt_to_insert, storage_scheme).await@@ -4015,7 +4016,7 @@ impl AttemptType {payment_id: fetched_payment_intent.get_id().to_owned(),})?;- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]let new_payment_attempt = db.insert_payment_attempt(key_manager_state,@@ -4040,7 +4041,7 @@ impl AttemptType {),Some(true),),- active_attempt_id: new_payment_attempt.attempt_id.clone(),+ active_attempt_id: new_payment_attempt.get_id().to_owned(),attempt_count: new_attempt_count,updated_by: storage_scheme.to_string(),},@@ -4053,7 +4054,7 @@ impl AttemptType {logger::info!("manual_retry payment for {:?} with attempt_id {}",updated_payment_intent.get_id(),- new_payment_attempt.attempt_id+ new_payment_attempt.get_id());Ok((updated_payment_intent, new_payment_attempt))@@ -5655,7 +5656,7 @@ whereif let Some(skip_saving_wallet_at_connector) = skip_saving_wallet_at_connector_optional {if let Some(payment_method_type) =- payment_data.get_payment_attempt().payment_method_type+ payment_data.get_payment_attempt().get_payment_method_type(){if skip_saving_wallet_at_connector.contains(&payment_method_type) {logger::debug!("Override setup_future_usage from off_session to on_session based on the merchant's skip_saving_wallet_at_connector configuration to avoid creating a connector mandate.");diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 5b171aa440..51f2de51f2 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -339,7 +339,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa)?;}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]let payment_attempt = db.insert_payment_attempt(payment_attempt_new, storage_scheme).await@@ -347,7 +347,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Papayment_id: payment_id.clone(),})?;- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]let payment_attempt = db.insert_payment_attempt(key_manager_state,diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rsindex deaa20e3f3..6a5299db8c 100644--- a/crates/router/src/core/payments/operations/payment_response.rs+++ b/crates/router/src/core/payments/operations/payment_response.rs@@ -302,10 +302,7 @@ impl<F: Send + Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsAuthorupdated_by: storage_scheme.clone().to_string(),};- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2")- ))]+ #[cfg(feature = "v1")]let respond = state.store.update_payment_attempt_with_attempt_id(@@ -315,7 +312,7 @@ impl<F: Send + Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsAuthor).await;- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]let respond = state.store.update_payment_attempt_with_attempt_id(@@ -404,7 +401,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsIncrementalAu};//payment_attempt updateif let Some(payment_attempt_update) = option_payment_attempt_update {- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]{payment_data.payment_attempt = state.store@@ -417,7 +414,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsIncrementalAu.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]{payment_data.payment_attempt = state.storediff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rsindex ad643164f1..b69c1ebf91 100644--- a/crates/router/src/core/payments/retry.rs+++ b/crates/router/src/core/payments/retry.rs@@ -336,6 +336,26 @@ whereOk(router_data)}+#[cfg(feature = "v2")]+#[instrument(skip_all)]+pub async fn modify_trackers<F, FData, D>(+ state: &routes::SessionState,+ connector: String,+ payment_data: &mut D,+ key_store: &domain::MerchantKeyStore,+ storage_scheme: storage_enums::MerchantStorageScheme,+ router_data: types::RouterData<F, FData, types::PaymentsResponseData>,+ is_step_up: bool,+) -> RouterResult<()>+where+ F: Clone + Send,+ FData: Send,+ D: payments::OperationSessionGetters<F> + payments::OperationSessionSetters<F> + Send + Sync,+{+ todo!()+}++#[cfg(feature = "v1")]#[instrument(skip_all)]pub async fn modify_trackers<F, FData, D>(state: &routes::SessionState,@@ -426,7 +446,7 @@ wherecharge_id,};- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]db.update_payment_attempt_with_attempt_id(payment_data.get_payment_attempt().clone(),payment_attempt_update,@@ -435,7 +455,7 @@ where.await.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]db.update_payment_attempt_with_attempt_id(key_manager_state,key_store,@@ -475,7 +495,7 @@ whereauthentication_type: auth_update,};- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]db.update_payment_attempt_with_attempt_id(payment_data.get_payment_attempt().clone(),payment_attempt_update,@@ -484,7 +504,7 @@ where.await.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]db.update_payment_attempt_with_attempt_id(key_manager_state,key_store,@@ -497,14 +517,14 @@ where}}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]let payment_attempt = db.insert_payment_attempt(new_payment_attempt, storage_scheme).await.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Error inserting payment attempt")?;- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]let payment_attempt = db.insert_payment_attempt(key_manager_state,@@ -524,7 +544,7 @@ wherekey_manager_state,payment_data.get_payment_intent().clone(),storage::PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {- active_attempt_id: payment_data.get_payment_attempt().attempt_id.clone(),+ active_attempt_id: payment_data.get_payment_attempt().get_id().to_owned(),attempt_count: new_attempt_count,updated_by: storage_scheme.to_string(),},@@ -539,7 +559,7 @@ whereOk(())}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]#[instrument(skip_all)]pub fn make_new_payment_attempt(connector: String,@@ -618,7 +638,7 @@ pub fn make_new_payment_attempt(}}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]#[instrument(skip_all)]pub fn make_new_payment_attempt(_connector: String,diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rsindex 1909fa25fb..04080a4273 100644--- a/crates/router/src/core/payments/routing.rs+++ b/crates/router/src/core/payments/routing.rs@@ -938,7 +938,7 @@ pub async fn perform_session_flow_routing(let session_pm_input = SessionRoutingPmTypeInput {state: session_input.state,key_store: session_input.key_store,- attempt_id: &session_input.payment_attempt.attempt_id,+ attempt_id: session_input.payment_attempt.get_id(),routing_algorithm: &routing_algorithm,backend_input: backend_input.clone(),allowed_connectors,diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex e5cce9ad3a..2c5a88e69b 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -68,26 +68,6 @@ where.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed while parsing value for ConnectorAuthType")?;- let resource_id = match payment_data- .payment_attempt- .connector_transaction_id- .clone()- {- Some(id) => types::ResponseId::ConnectorTransactionId(id),- None => types::ResponseId::NoResponseId,- };-- // [#44]: why should response be filled during request- let response = Ok(types::PaymentsResponseData::TransactionResponse {- resource_id,- redirection_data: None,- mandate_reference: None,- connector_metadata: None,- network_txn_id: None,- connector_response_reference_id: None,- incremental_authorization_allowed: None,- charge_id: None,- });let additional_data = PaymentAdditionalData {router_base_url: state.base_url.clone(),connector_name: connector_id.to_string(),@@ -106,7 +86,7 @@ where.payment_id.get_string_repr().to_owned(),- attempt_id: payment_data.payment_attempt.attempt_id.clone(),+ attempt_id: payment_data.payment_attempt.get_id().to_owned(),status: payment_data.payment_attempt.status,payment_method: diesel_models::enums::PaymentMethod::default(),connector_auth_type: auth_type,@@ -120,7 +100,7 @@ whereconnector_meta_data: None,connector_wallets_details: None,request: T::try_from(additional_data)?,- response,+ response: Err(hyperswitch_domain_models::router_data::ErrorResponse::default()),amount_captured: None,minor_amount_captured: None,access_token: None,@@ -1258,6 +1238,7 @@ whereOk(output)}+#[cfg(feature = "v1")]pub fn third_party_sdk_session_next_action<Op>(payment_attempt: &storage::PaymentAttempt,operation: &Op,@@ -1508,6 +1489,7 @@ impl ForeignFrom<ephemeral_key::EphemeralKey> for api::ephemeral_key::EphemeralK}}+#[cfg(feature = "v1")]pub fn bank_transfer_next_steps_check(payment_attempt: storage::PaymentAttempt,) -> RouterResult<Option<api_models::payments::BankTransferNextStepsData>> {@@ -1538,6 +1520,7 @@ pub fn bank_transfer_next_steps_check(Ok(bank_transfer_next_step)}+#[cfg(feature = "v1")]pub fn voucher_next_steps_check(payment_attempt: storage::PaymentAttempt,) -> RouterResult<Option<api_models::payments::VoucherNextStepData>> {@@ -1792,29 +1775,45 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz}}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v2")]+impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsSyncData {+ type Error = error_stack::Report<errors::ApiErrorResponse>;++ fn try_from(additional_data: PaymentAdditionalData<'_, F>) -> Result<Self, Self::Error> {+ todo!()+ }+}++#[cfg(feature = "v1")]impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsSyncData {type Error = error_stack::Report<errors::ApiErrorResponse>;fn try_from(additional_data: PaymentAdditionalData<'_, F>) -> Result<Self, Self::Error> {let payment_data = additional_data.payment_data;+ let capture_method = payment_data.get_capture_method();let amount = payment_data.surcharge_details.as_ref().map(|surcharge_details| surcharge_details.final_amount).unwrap_or(payment_data.amount.into());++ let payment_method_type = payment_data+ .payment_attempt+ .get_payment_method_type()+ .to_owned();Ok(Self {amount,integrity_object: None,mandate_id: payment_data.mandate_id.clone(),- connector_transaction_id: match payment_data.payment_attempt.connector_transaction_id {+ connector_transaction_id: match payment_data.payment_attempt.get_connector_payment_id()+ {Some(connector_txn_id) => {- types::ResponseId::ConnectorTransactionId(connector_txn_id)+ types::ResponseId::ConnectorTransactionId(connector_txn_id.to_owned())}None => types::ResponseId::NoResponseId,},encoded_data: payment_data.payment_attempt.encoded_data,- capture_method: payment_data.payment_attempt.capture_method,+ capture_method,connector_meta: payment_data.payment_attempt.connector_metadata,sync_type: match payment_data.multiple_capture_data {Some(multiple_capture_data) => types::SyncRequestType::MultipleCaptureSync(@@ -1822,7 +1821,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsSyncData),None => types::SyncRequestType::SinglePaymentSync,},- payment_method_type: payment_data.payment_attempt.payment_method_type,+ payment_method_type,currency: payment_data.currency,charges: payment_data.payment_intent@@ -1842,44 +1841,6 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsSyncData}}-#[cfg(all(feature = "v2", feature = "payment_v2"))]-impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsSyncData {- type Error = error_stack::Report<errors::ApiErrorResponse>;-- fn try_from(additional_data: PaymentAdditionalData<'_, F>) -> Result<Self, Self::Error> {- let payment_data = additional_data.payment_data;- let amount = payment_data- .surcharge_details- .as_ref()- .map(|surcharge_details| surcharge_details.final_amount)- .unwrap_or(payment_data.amount.into());- Ok(Self {- amount,- integrity_object: None,- mandate_id: payment_data.mandate_id.clone(),- connector_transaction_id: match payment_data.payment_attempt.connector_transaction_id {- Some(connector_txn_id) => {- types::ResponseId::ConnectorTransactionId(connector_txn_id)- }- None => types::ResponseId::NoResponseId,- },- encoded_data: payment_data.payment_attempt.encoded_data,- capture_method: payment_data.payment_attempt.capture_method,- connector_meta: payment_data.payment_attempt.connector_metadata,- sync_type: match payment_data.multiple_capture_data {- Some(multiple_capture_data) => types::SyncRequestType::MultipleCaptureSync(- multiple_capture_data.get_pending_connector_capture_ids(),- ),- None => types::SyncRequestType::SinglePaymentSync,- },- payment_method_type: payment_data.payment_attempt.payment_method_type,- currency: payment_data.currency,- charges: None,- payment_experience: payment_data.payment_attempt.payment_experience,- })- }-}-impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>>for types::PaymentsIncrementalAuthorizationData{@@ -1929,12 +1890,14 @@ impl ConnectorTransactionId for Helcim {&self,payment_attempt: storage::PaymentAttempt,) -> Result<Option<String>, errors::ApiErrorResponse> {- if payment_attempt.connector_transaction_id.is_none() {+ if payment_attempt.get_connector_payment_id().is_none() {let metadata =Self::connector_transaction_id(self, &payment_attempt.connector_metadata);metadata.map_err(|_| errors::ApiErrorResponse::ResourceIdNotFound)} else {- Ok(payment_attempt.connector_transaction_id)+ Ok(payment_attempt+ .get_connector_payment_id()+ .map(ToString::to_string))}}}@@ -2349,6 +2312,16 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz}}+#[cfg(feature = "v2")]+impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProcessingData {+ type Error = error_stack::Report<errors::ApiErrorResponse>;++ fn try_from(additional_data: PaymentAdditionalData<'_, F>) -> Result<Self, Self::Error> {+ todo!()+ }+}++#[cfg(feature = "v1")]impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProcessingData {type Error = error_stack::Report<errors::ApiErrorResponse>;diff --git a/crates/router/src/core/payments/types.rs b/crates/router/src/core/payments/types.rsindex 66c3eb91f5..01533cefa5 100644--- a/crates/router/src/core/payments/types.rs+++ b/crates/router/src/core/payments/types.rs@@ -188,6 +188,17 @@ impl MultipleCaptureData {}}+#[cfg(feature = "v2")]+impl ForeignTryFrom<(&SurchargeDetails, &PaymentAttempt)> for SurchargeDetailsResponse {+ type Error = TryFromIntError;+ fn foreign_try_from(+ (surcharge_details, payment_attempt): (&SurchargeDetails, &PaymentAttempt),+ ) -> Result<Self, Self::Error> {+ todo!()+ }+}++#[cfg(feature = "v1")]impl ForeignTryFrom<(&SurchargeDetails, &PaymentAttempt)> for SurchargeDetailsResponse {type Error = TryFromIntError;fn foreign_try_from(diff --git a/crates/router/src/core/user/sample_data.rs b/crates/router/src/core/user/sample_data.rsindex 1851c563d0..5058ad600e 100644--- a/crates/router/src/core/user/sample_data.rs+++ b/crates/router/src/core/user/sample_data.rs@@ -74,6 +74,7 @@ pub async fn generate_sample_data_for_user(Ok(ApplicationResponse::StatusOk)}+#[cfg(feature = "v1")]pub async fn delete_sample_data_for_user(state: SessionState,user_from_token: UserFromToken,diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rsindex 607de45215..ae8b7c15a7 100644--- a/crates/router/src/core/utils.rs+++ b/crates/router/src/core/utils.rs@@ -1224,6 +1224,7 @@ pub fn is_merchant_enabled_for_payment_id_as_connector_request_id(config_map.contains(merchant_id)}+#[cfg(feature = "v1")]pub fn get_connector_request_reference_id(conf: &Settings,merchant_id: &common_utils::id_type::MerchantId,@@ -1235,10 +1236,20 @@ pub fn get_connector_request_reference_id(if is_config_enabled_for_merchant {payment_attempt.payment_id.get_string_repr().to_owned()} else {- payment_attempt.attempt_id.clone()+ payment_attempt.attempt_id.to_owned()}}+// TODO: Based on the connector configuration, the connector_request_reference_id should be generated+#[cfg(feature = "v2")]+pub fn get_connector_request_reference_id(+ conf: &Settings,+ merchant_id: &common_utils::id_type::MerchantId,+ payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,+) -> String {+ todo!()+}+/// Validate whether the profile_id exists and is associated with the merchant_idpub async fn validate_and_get_business_profile(db: &dyn StorageInterface,diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rsindex d14de8c233..73d0552863 100644--- a/crates/router/src/db/kafka_store.rs+++ b/crates/router/src/db/kafka_store.rs@@ -1344,7 +1344,7 @@ impl QueueInterface for KafkaStore {#[async_trait::async_trait]impl PaymentAttemptInterface for KafkaStore {- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn insert_payment_attempt(&self,payment_attempt: storage::PaymentAttemptNew,@@ -1366,7 +1366,7 @@ impl PaymentAttemptInterface for KafkaStore {Ok(attempt)}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]async fn insert_payment_attempt(&self,key_manager_state: &KeyManagerState,@@ -1395,7 +1395,7 @@ impl PaymentAttemptInterface for KafkaStore {Ok(attempt)}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn update_payment_attempt_with_attempt_id(&self,this: storage::PaymentAttempt,@@ -1418,7 +1418,7 @@ impl PaymentAttemptInterface for KafkaStore {Ok(attempt)}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]async fn update_payment_attempt_with_attempt_id(&self,key_manager_state: &KeyManagerState,@@ -1449,7 +1449,7 @@ impl PaymentAttemptInterface for KafkaStore {Ok(attempt)}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(&self,connector_transaction_id: &str,@@ -1467,7 +1467,7 @@ impl PaymentAttemptInterface for KafkaStore {.await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_merchant_id_connector_txn_id(&self,merchant_id: &id_type::MerchantId,@@ -1483,7 +1483,7 @@ impl PaymentAttemptInterface for KafkaStore {.await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(&self,payment_id: &id_type::PaymentId,@@ -1501,7 +1501,7 @@ impl PaymentAttemptInterface for KafkaStore {.await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_attempt_id_merchant_id(&self,attempt_id: &str,@@ -1513,27 +1513,25 @@ impl PaymentAttemptInterface for KafkaStore {.await}- #[cfg(all(feature = "v2", feature = "payment_v2"))]- async fn find_payment_attempt_by_attempt_id_merchant_id(+ #[cfg(feature = "v2")]+ async fn find_payment_attempt_by_id(&self,key_manager_state: &KeyManagerState,merchant_key_store: &domain::MerchantKeyStore,attempt_id: &str,- merchant_id: &id_type::MerchantId,storage_scheme: MerchantStorageScheme,- ) -> CustomResult<storage::PaymentAttempt, errors::DataStorageError> {+ ) -> error_stack::Result<storage::PaymentAttempt, errors::DataStorageError> {self.diesel_store- .find_payment_attempt_by_attempt_id_merchant_id(+ .find_payment_attempt_by_id(key_manager_state,merchant_key_store,attempt_id,- merchant_id,storage_scheme,).await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(&self,payment_id: &id_type::PaymentId,@@ -1549,7 +1547,7 @@ impl PaymentAttemptInterface for KafkaStore {.await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(&self,payment_id: &id_type::PaymentId,@@ -1565,7 +1563,7 @@ impl PaymentAttemptInterface for KafkaStore {.await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_preprocessing_id_merchant_id(&self,preprocessing_id: &str,@@ -1581,7 +1579,7 @@ impl PaymentAttemptInterface for KafkaStore {.await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn get_filters_for_payments(&self,pi: &[hyperswitch_domain_models::payments::PaymentIntent],@@ -1596,7 +1594,7 @@ impl PaymentAttemptInterface for KafkaStore {.await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn get_total_count_of_filtered_payment_attempts(&self,merchant_id: &id_type::MerchantId,@@ -1626,7 +1624,7 @@ impl PaymentAttemptInterface for KafkaStore {.await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_attempts_by_merchant_id_payment_id(&self,merchant_id: &id_type::MerchantId,@@ -1821,16 +1819,6 @@ impl PaymentIntentInterface for KafkaStore {).await}-- async fn get_active_payment_attempt(- &self,- payment: &mut storage::PaymentIntent,- storage_scheme: MerchantStorageScheme,- ) -> error_stack::Result<storage::PaymentAttempt, errors::DataStorageError> {- self.diesel_store- .get_active_payment_attempt(payment, storage_scheme)- .await- }}#[async_trait::async_trait]@@ -3231,6 +3219,7 @@ impl DashboardMetadataInterface for KafkaStore {#[async_trait::async_trait]impl BatchSampleDataInterface for KafkaStore {+ #[cfg(feature = "v1")]async fn insert_payment_intents_batch_for_sample_data(&self,state: &KeyManagerState,@@ -3254,6 +3243,7 @@ impl BatchSampleDataInterface for KafkaStore {Ok(payment_intents_list)}+ #[cfg(feature = "v1")]async fn insert_payment_attempts_batch_for_sample_data(&self,batch: Vec<diesel_models::user::sample_data::PaymentAttemptBatchNew>,@@ -3275,6 +3265,7 @@ impl BatchSampleDataInterface for KafkaStore {Ok(payment_attempts_list)}+ #[cfg(feature = "v1")]async fn insert_refunds_batch_for_sample_data(&self,batch: Vec<diesel_models::RefundNew>,@@ -3294,6 +3285,7 @@ impl BatchSampleDataInterface for KafkaStore {Ok(refunds_list)}+ #[cfg(feature = "v1")]async fn delete_payment_intents_for_sample_data(&self,state: &KeyManagerState,@@ -3317,6 +3309,7 @@ impl BatchSampleDataInterface for KafkaStore {Ok(payment_intents_list)}+ #[cfg(feature = "v1")]async fn delete_payment_attempts_for_sample_data(&self,merchant_id: &id_type::MerchantId,@@ -3339,6 +3332,7 @@ impl BatchSampleDataInterface for KafkaStore {Ok(payment_attempts_list)}+ #[cfg(feature = "v1")]async fn delete_refunds_for_sample_data(&self,merchant_id: &id_type::MerchantId,diff --git a/crates/router/src/db/user/sample_data.rs b/crates/router/src/db/user/sample_data.rsindex 3bcbb624cb..709ff4a358 100644--- a/crates/router/src/db/user/sample_data.rs+++ b/crates/router/src/db/user/sample_data.rs@@ -19,6 +19,7 @@ use crate::{connection::pg_connection_write, core::errors::CustomResult, service#[async_trait::async_trait]pub trait BatchSampleDataInterface {+ #[cfg(feature = "v1")]async fn insert_payment_intents_batch_for_sample_data(&self,state: &KeyManagerState,@@ -26,16 +27,19 @@ pub trait BatchSampleDataInterface {key_store: &MerchantKeyStore,) -> CustomResult<Vec<PaymentIntent>, StorageError>;+ #[cfg(feature = "v1")]async fn insert_payment_attempts_batch_for_sample_data(&self,batch: Vec<PaymentAttemptBatchNew>,) -> CustomResult<Vec<PaymentAttempt>, StorageError>;+ #[cfg(feature = "v1")]async fn insert_refunds_batch_for_sample_data(&self,batch: Vec<RefundNew>,) -> CustomResult<Vec<Refund>, StorageError>;+ #[cfg(feature = "v1")]async fn delete_payment_intents_for_sample_data(&self,state: &KeyManagerState,@@ -43,11 +47,13 @@ pub trait BatchSampleDataInterface {key_store: &MerchantKeyStore,) -> CustomResult<Vec<PaymentIntent>, StorageError>;+ #[cfg(feature = "v1")]async fn delete_payment_attempts_for_sample_data(&self,merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<PaymentAttempt>, StorageError>;+ #[cfg(feature = "v1")]async fn delete_refunds_for_sample_data(&self,merchant_id: &common_utils::id_type::MerchantId,@@ -56,6 +62,7 @@ pub trait BatchSampleDataInterface {#[async_trait::async_trait]impl BatchSampleDataInterface for Store {+ #[cfg(feature = "v1")]async fn insert_payment_intents_batch_for_sample_data(&self,state: &KeyManagerState,@@ -89,6 +96,7 @@ impl BatchSampleDataInterface for Store {.await}+ #[cfg(feature = "v1")]async fn insert_payment_attempts_batch_for_sample_data(&self,batch: Vec<PaymentAttemptBatchNew>,@@ -105,6 +113,8 @@ impl BatchSampleDataInterface for Store {.collect()})}++ #[cfg(feature = "v1")]async fn insert_refunds_batch_for_sample_data(&self,batch: Vec<RefundNew>,@@ -117,6 +127,7 @@ impl BatchSampleDataInterface for Store {.map_err(diesel_error_to_data_error)}+ #[cfg(feature = "v1")]async fn delete_payment_intents_for_sample_data(&self,state: &KeyManagerState,@@ -143,6 +154,7 @@ impl BatchSampleDataInterface for Store {.await}+ #[cfg(feature = "v1")]async fn delete_payment_attempts_for_sample_data(&self,merchant_id: &common_utils::id_type::MerchantId,@@ -159,6 +171,8 @@ impl BatchSampleDataInterface for Store {.collect()})}++ #[cfg(feature = "v1")]async fn delete_refunds_for_sample_data(&self,merchant_id: &common_utils::id_type::MerchantId,@@ -174,6 +188,7 @@ impl BatchSampleDataInterface for Store {#[async_trait::async_trait]impl BatchSampleDataInterface for storage_impl::MockDb {+ #[cfg(feature = "v1")]async fn insert_payment_intents_batch_for_sample_data(&self,_state: &KeyManagerState,@@ -183,6 +198,7 @@ impl BatchSampleDataInterface for storage_impl::MockDb {Err(StorageError::MockDbError)?}+ #[cfg(feature = "v1")]async fn insert_payment_attempts_batch_for_sample_data(&self,_batch: Vec<PaymentAttemptBatchNew>,@@ -190,6 +206,7 @@ impl BatchSampleDataInterface for storage_impl::MockDb {Err(StorageError::MockDbError)?}+ #[cfg(feature = "v1")]async fn insert_refunds_batch_for_sample_data(&self,_batch: Vec<RefundNew>,@@ -197,6 +214,7 @@ impl BatchSampleDataInterface for storage_impl::MockDb {Err(StorageError::MockDbError)?}+ #[cfg(feature = "v1")]async fn delete_payment_intents_for_sample_data(&self,_state: &KeyManagerState,@@ -205,12 +223,16 @@ impl BatchSampleDataInterface for storage_impl::MockDb {) -> CustomResult<Vec<PaymentIntent>, StorageError> {Err(StorageError::MockDbError)?}++ #[cfg(feature = "v1")]async fn delete_payment_attempts_for_sample_data(&self,_merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<PaymentAttempt>, StorageError> {Err(StorageError::MockDbError)?}++ #[cfg(feature = "v1")]async fn delete_refunds_for_sample_data(&self,_merchant_id: &common_utils::id_type::MerchantId,diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rsindex d5f73921a9..dd3471f569 100644--- a/crates/router/src/routes/app.rs+++ b/crates/router/src/routes/app.rs@@ -513,7 +513,6 @@ pub struct Payments;any(feature = "olap", feature = "oltp"),feature = "v2",feature = "payment_methods_v2",- feature = "payment_v2"))]impl Payments {pub fn server(state: AppState) -> Scope {@@ -527,12 +526,7 @@ impl Payments {}}-#[cfg(all(- any(feature = "olap", feature = "oltp"),- any(feature = "v2", feature = "v1"),- not(feature = "payment_methods_v2"),- not(feature = "payment_v2")-))]+#[cfg(feature = "v1")]impl Payments {pub fn server(state: AppState) -> Scope {let mut route = web::scope("/payments").app_data(web::Data::new(state));diff --git a/crates/router/src/routes/user.rs b/crates/router/src/routes/user.rsindex b1fbd2bb6d..fdb7d8592c 100644--- a/crates/router/src/routes/user.rs+++ b/crates/router/src/routes/user.rs@@ -292,7 +292,8 @@ pub async fn generate_sample_data()).await}-#[cfg(feature = "dummy_connector")]++#[cfg(all(feature = "dummy_connector", feature = "v1"))]pub async fn delete_sample_data(state: web::Data<AppState>,http_req: HttpRequest,diff --git a/crates/router/src/services/kafka/payment_attempt.rs b/crates/router/src/services/kafka/payment_attempt.rsindex b3827450a8..7689492843 100644--- a/crates/router/src/services/kafka/payment_attempt.rs+++ b/crates/router/src/services/kafka/payment_attempt.rs@@ -59,6 +59,7 @@ pub struct KafkaPaymentAttempt<'a> {pub card_network: Option<String>,}+#[cfg(feature = "v1")]impl<'a> KafkaPaymentAttempt<'a> {pub fn from_storage(attempt: &'a PaymentAttempt) -> Self {Self {@@ -118,6 +119,67 @@ impl<'a> KafkaPaymentAttempt<'a> {}}+#[cfg(feature = "v2")]+impl<'a> KafkaPaymentAttempt<'a> {+ pub fn from_storage(attempt: &'a PaymentAttempt) -> Self {+ todo!()+ // Self {+ // payment_id: &attempt.payment_id,+ // merchant_id: &attempt.merchant_id,+ // attempt_id: &attempt.attempt_id,+ // status: attempt.status,+ // amount: attempt.amount,+ // currency: attempt.currency,+ // save_to_locker: attempt.save_to_locker,+ // connector: attempt.connector.as_ref(),+ // error_message: attempt.error_message.as_ref(),+ // offer_amount: attempt.offer_amount,+ // surcharge_amount: attempt.surcharge_amount,+ // tax_amount: attempt.tax_amount,+ // payment_method_id: attempt.payment_method_id.as_ref(),+ // payment_method: attempt.payment_method,+ // connector_transaction_id: attempt.connector_transaction_id.as_ref(),+ // capture_method: attempt.capture_method,+ // capture_on: attempt.capture_on.map(|i| i.assume_utc()),+ // confirm: attempt.confirm,+ // authentication_type: attempt.authentication_type,+ // created_at: attempt.created_at.assume_utc(),+ // modified_at: attempt.modified_at.assume_utc(),+ // last_synced: attempt.last_synced.map(|i| i.assume_utc()),+ // cancellation_reason: attempt.cancellation_reason.as_ref(),+ // amount_to_capture: attempt.amount_to_capture,+ // mandate_id: attempt.mandate_id.as_ref(),+ // browser_info: attempt.browser_info.as_ref().map(|v| v.to_string()),+ // error_code: attempt.error_code.as_ref(),+ // connector_metadata: attempt.connector_metadata.as_ref().map(|v| v.to_string()),+ // payment_experience: attempt.payment_experience.as_ref(),+ // payment_method_type: attempt.payment_method_type.as_ref(),+ // payment_method_data: attempt.payment_method_data.as_ref().map(|v| v.to_string()),+ // error_reason: attempt.error_reason.as_ref(),+ // multiple_capture_count: attempt.multiple_capture_count,+ // amount_capturable: attempt.amount_capturable,+ // merchant_connector_id: attempt.merchant_connector_id.as_ref(),+ // net_amount: attempt.net_amount,+ // unified_code: attempt.unified_code.as_ref(),+ // unified_message: attempt.unified_message.as_ref(),+ // mandate_data: attempt.mandate_data.as_ref(),+ // client_source: attempt.client_source.as_ref(),+ // client_version: attempt.client_version.as_ref(),+ // profile_id: &attempt.profile_id,+ // organization_id: &attempt.organization_id,+ // card_network: attempt+ // .payment_method_data+ // .as_ref()+ // .and_then(|data| data.as_object())+ // .and_then(|pm| pm.get("card"))+ // .and_then(|data| data.as_object())+ // .and_then(|card| card.get("card_network"))+ // .and_then(|network| network.as_str())+ // .map(|network| network.to_string()),+ // }+ }+}+impl<'a> super::KafkaMessage for KafkaPaymentAttempt<'a> {fn key(&self) -> String {format!(diff --git a/crates/router/src/services/kafka/payment_attempt_event.rs b/crates/router/src/services/kafka/payment_attempt_event.rsindex 13ab031981..b4d6cd8835 100644--- a/crates/router/src/services/kafka/payment_attempt_event.rs+++ b/crates/router/src/services/kafka/payment_attempt_event.rs@@ -60,6 +60,7 @@ pub struct KafkaPaymentAttemptEvent<'a> {pub card_network: Option<String>,}+#[cfg(feature = "v1")]impl<'a> KafkaPaymentAttemptEvent<'a> {pub fn from_storage(attempt: &'a PaymentAttempt) -> Self {Self {@@ -119,6 +120,67 @@ impl<'a> KafkaPaymentAttemptEvent<'a> {}}+#[cfg(feature = "v2")]+impl<'a> KafkaPaymentAttemptEvent<'a> {+ pub fn from_storage(attempt: &'a PaymentAttempt) -> Self {+ todo!()+ // Self {+ // payment_id: &attempt.payment_id,+ // merchant_id: &attempt.merchant_id,+ // attempt_id: &attempt.attempt_id,+ // status: attempt.status,+ // amount: attempt.amount,+ // currency: attempt.currency,+ // save_to_locker: attempt.save_to_locker,+ // connector: attempt.connector.as_ref(),+ // error_message: attempt.error_message.as_ref(),+ // offer_amount: attempt.offer_amount,+ // surcharge_amount: attempt.surcharge_amount,+ // tax_amount: attempt.tax_amount,+ // payment_method_id: attempt.payment_method_id.as_ref(),+ // payment_method: attempt.payment_method,+ // connector_transaction_id: attempt.connector_transaction_id.as_ref(),+ // capture_method: attempt.capture_method,+ // capture_on: attempt.capture_on.map(|i| i.assume_utc()),+ // confirm: attempt.confirm,+ // authentication_type: attempt.authentication_type,+ // created_at: attempt.created_at.assume_utc(),+ // modified_at: attempt.modified_at.assume_utc(),+ // last_synced: attempt.last_synced.map(|i| i.assume_utc()),+ // cancellation_reason: attempt.cancellation_reason.as_ref(),+ // amount_to_capture: attempt.amount_to_capture,+ // mandate_id: attempt.mandate_id.as_ref(),+ // browser_info: attempt.browser_info.as_ref().map(|v| v.to_string()),+ // error_code: attempt.error_code.as_ref(),+ // connector_metadata: attempt.connector_metadata.as_ref().map(|v| v.to_string()),+ // payment_experience: attempt.payment_experience.as_ref(),+ // payment_method_type: attempt.payment_method_type.as_ref(),+ // payment_method_data: attempt.payment_method_data.as_ref().map(|v| v.to_string()),+ // error_reason: attempt.error_reason.as_ref(),+ // multiple_capture_count: attempt.multiple_capture_count,+ // amount_capturable: attempt.amount_capturable,+ // merchant_connector_id: attempt.merchant_connector_id.as_ref(),+ // net_amount: attempt.net_amount,+ // unified_code: attempt.unified_code.as_ref(),+ // unified_message: attempt.unified_message.as_ref(),+ // mandate_data: attempt.mandate_data.as_ref(),+ // client_source: attempt.client_source.as_ref(),+ // client_version: attempt.client_version.as_ref(),+ // profile_id: &attempt.profile_id,+ // organization_id: &attempt.organization_id,+ // card_network: attempt+ // .payment_method_data+ // .as_ref()+ // .and_then(|data| data.as_object())+ // .and_then(|pm| pm.get("card"))+ // .and_then(|data| data.as_object())+ // .and_then(|card| card.get("card_network"))+ // .and_then(|network| network.as_str())+ // .map(|network| network.to_string()),+ // }+ }+}+impl<'a> super::KafkaMessage for KafkaPaymentAttemptEvent<'a> {fn key(&self) -> String {format!(diff --git a/crates/router/src/types.rs b/crates/router/src/types.rsindex 30bb663068..548d216d6e 100644--- a/crates/router/src/types.rs+++ b/crates/router/src/types.rs@@ -101,7 +101,7 @@ use crate::{consts,core::{errors::{self},- payments::PaymentData,+ payments::{OperationSessionGetters, PaymentData},},services,types::transformers::{ForeignFrom, ForeignTryFrom},@@ -271,10 +271,7 @@ impl Capturable for PaymentsAuthorizeData {whereF: Clone,{- match payment_data- .payment_attempt- .capture_method- .unwrap_or_default()+ match payment_data.get_capture_method().unwrap_or_default(){common_enums::CaptureMethod::Automatic => {let intent_status = common_enums::IntentStatus::foreign_from(attempt_status);@@ -349,8 +346,7 @@ impl Capturable for CompleteAuthorizeData {F: Clone,{match payment_data- .payment_attempt- .capture_method+ .get_capture_method().unwrap_or_default(){common_enums::CaptureMethod::Automatic => {diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rsindex 80ad6da8d2..40ba7cc7cf 100644--- a/crates/router/src/types/api.rs+++ b/crates/router/src/types/api.rs@@ -83,7 +83,9 @@ pub trait ConnectorTransactionId: ConnectorCommon + Sync {&self,payment_attempt: hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,) -> Result<Option<String>, errors::ApiErrorResponse> {- Ok(payment_attempt.connector_transaction_id)+ Ok(payment_attempt+ .get_connector_payment_id()+ .map(ToString::to_string))}}diff --git a/crates/router/src/types/storage/payment_attempt.rs b/crates/router/src/types/storage/payment_attempt.rsindex 18b6e8cc6f..f6caa64fe6 100644--- a/crates/router/src/types/storage/payment_attempt.rs+++ b/crates/router/src/types/storage/payment_attempt.rs@@ -21,6 +21,16 @@ pub trait PaymentAttemptExt {}impl PaymentAttemptExt for PaymentAttempt {+ #[cfg(feature = "v2")]+ fn make_new_capture(+ &self,+ capture_amount: MinorUnit,+ capture_status: enums::CaptureStatus,+ ) -> RouterResult<CaptureNew> {+ todo!()+ }++ #[cfg(feature = "v1")]fn make_new_capture(&self,capture_amount: MinorUnit,@@ -55,10 +65,19 @@ impl PaymentAttemptExt for PaymentAttempt {connector_response_reference_id: None,})}++ #[cfg(feature = "v1")]fn get_next_capture_id(&self) -> String {let next_sequence_number = self.multiple_capture_count.unwrap_or_default() + 1;format!("{}_{}", self.attempt_id.clone(), next_sequence_number)}++ #[cfg(feature = "v2")]+ fn get_next_capture_id(&self) -> String {+ todo!()+ }++ #[cfg(feature = "v1")]fn get_surcharge_details(&self) -> Option<api_models::payments::RequestSurchargeDetails> {self.surcharge_amount.map(|surcharge_amount| {api_models::payments::RequestSurchargeDetails {@@ -67,11 +86,23 @@ impl PaymentAttemptExt for PaymentAttempt {}})}++ #[cfg(feature = "v2")]+ fn get_surcharge_details(&self) -> Option<api_models::payments::RequestSurchargeDetails> {+ todo!()+ }++ #[cfg(feature = "v1")]fn get_total_amount(&self) -> MinorUnit {self.amount+ self.surcharge_amount.unwrap_or_default()+ self.tax_amount.unwrap_or_default()}++ #[cfg(feature = "v2")]+ fn get_total_amount(&self) -> MinorUnit {+ todo!()+ }}pub trait AttemptStatusExt {@@ -86,8 +117,7 @@ impl AttemptStatusExt for enums::AttemptStatus {#[cfg(test)]#[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"), // Ignoring tests for v2 since they aren't actively running+ feature = "v1", // Ignoring tests for v2 since they aren't actively runningfeature = "dummy_connector"))]mod tests {diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rsindex 992816a361..b032906293 100644--- a/crates/router/src/types/transformers.rs+++ b/crates/router/src/types/transformers.rs@@ -1288,6 +1288,7 @@ impl ForeignTryFrom<domain::MerchantConnectorAccount>}}+#[cfg(feature = "v1")]impl ForeignFrom<storage::PaymentAttempt> for payments::PaymentAttemptResponse {fn foreign_from(payment_attempt: storage::PaymentAttempt) -> Self {Self {@@ -1476,6 +1477,7 @@ impl ForeignTryFrom<&HeaderMap> for payments::HeaderPayload {}}+#[cfg(feature = "v1")]implForeignTryFrom<(Option<&storage::PaymentAttempt>,diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rsindex e6f549f4fc..a54c2bc8ad 100644--- a/crates/router/src/utils.rs+++ b/crates/router/src/utils.rs@@ -381,7 +381,7 @@ pub async fn get_mca_from_payment_intent(let db = &*state.store;let key_manager_state: &KeyManagerState = &state.into();- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]let payment_attempt = db.find_payment_attempt_by_attempt_id_merchant_id(&payment_intent.active_attempt.get_id(),@@ -391,7 +391,7 @@ pub async fn get_mca_from_payment_intent(.await.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]let payment_attempt = db.find_payment_attempt_by_attempt_id_merchant_id(key_manager_state,diff --git a/crates/storage_impl/Cargo.toml b/crates/storage_impl/Cargo.tomlindex b3dc6d57c6..0a84d5b25f 100644--- a/crates/storage_impl/Cargo.toml+++ b/crates/storage_impl/Cargo.toml@@ -15,7 +15,6 @@ olap = ["hyperswitch_domain_models/olap"]payouts = ["hyperswitch_domain_models/payouts"]v1 = ["api_models/v1", "diesel_models/v1", "hyperswitch_domain_models/v1"]v2 = ["api_models/v2", "diesel_models/v2", "hyperswitch_domain_models/v2"]-payment_v2 = ["hyperswitch_domain_models/payment_v2", "diesel_models/payment_v2"]customer_v2 = ["api_models/customer_v2", "diesel_models/customer_v2", "hyperswitch_domain_models/customer_v2"]payment_methods_v2 = ["diesel_models/payment_methods_v2", "api_models/payment_methods_v2", "hyperswitch_domain_models/payment_methods_v2"]diff --git a/crates/storage_impl/src/lib.rs b/crates/storage_impl/src/lib.rsindex 974de5be80..5954f4791a 100644--- a/crates/storage_impl/src/lib.rs+++ b/crates/storage_impl/src/lib.rs@@ -329,7 +329,7 @@ impl UniqueConstraints for diesel_models::Address {}}-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]impl UniqueConstraints for diesel_models::PaymentIntent {fn unique_constraints(&self) -> Vec<String> {vec![self.id.get_string_repr().to_owned()]@@ -340,7 +340,7 @@ impl UniqueConstraints for diesel_models::PaymentIntent {}}-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]impl UniqueConstraints for diesel_models::PaymentIntent {#[cfg(feature = "v1")]fn unique_constraints(&self) -> Vec<String> {@@ -361,6 +361,7 @@ impl UniqueConstraints for diesel_models::PaymentIntent {}}+#[cfg(feature = "v1")]impl UniqueConstraints for diesel_models::PaymentAttempt {fn unique_constraints(&self) -> Vec<String> {vec![format!(diff --git a/crates/storage_impl/src/mock_db/payment_attempt.rs b/crates/storage_impl/src/mock_db/payment_attempt.rsindex 7abde14099..44c089932d 100644--- a/crates/storage_impl/src/mock_db/payment_attempt.rs+++ b/crates/storage_impl/src/mock_db/payment_attempt.rs@@ -1,23 +1,23 @@-use api_models::enums::{AuthenticationType, Connector, PaymentMethod, PaymentMethodType};use common_utils::errors::CustomResult;-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]use common_utils::types::keymanager::KeyManagerState;use diesel_models::enums as storage_enums;-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]use hyperswitch_domain_models::merchant_key_store::MerchantKeyStore;+#[cfg(feature = "v1")]+use hyperswitch_domain_models::payments::payment_attempt::PaymentAttemptNew;use hyperswitch_domain_models::{errors::StorageError,- payments::payment_attempt::{- PaymentAttempt, PaymentAttemptInterface, PaymentAttemptNew, PaymentAttemptUpdate,- },+ payments::payment_attempt::{PaymentAttempt, PaymentAttemptInterface, PaymentAttemptUpdate},};use super::MockDb;+#[cfg(feature = "v1")]use crate::DataModelExt;#[async_trait::async_trait]impl PaymentAttemptInterface for MockDb {- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(&self,_payment_id: &common_utils::id_type::PaymentId,@@ -29,7 +29,7 @@ impl PaymentAttemptInterface for MockDb {Err(StorageError::MockDbError)?}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn get_filters_for_payments(&self,_pi: &[hyperswitch_domain_models::payments::PaymentIntent],@@ -42,15 +42,15 @@ impl PaymentAttemptInterface for MockDb {Err(StorageError::MockDbError)?}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn get_total_count_of_filtered_payment_attempts(&self,_merchant_id: &common_utils::id_type::MerchantId,_active_attempt_ids: &[String],- _connector: Option<Vec<Connector>>,- _payment_method: Option<Vec<PaymentMethod>>,- _payment_method_type: Option<Vec<PaymentMethodType>>,- _authentication_type: Option<Vec<AuthenticationType>>,+ _connector: Option<Vec<api_models::enums::Connector>>,+ _payment_method: Option<Vec<common_enums::PaymentMethod>>,+ _payment_method_type: Option<Vec<common_enums::PaymentMethodType>>,+ _authentication_type: Option<Vec<common_enums::AuthenticationType>>,_merchanat_connector_id: Option<Vec<common_utils::id_type::MerchantConnectorAccountId>>,_time_range: Option<common_utils::types::TimeRange>,_profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,@@ -59,7 +59,7 @@ impl PaymentAttemptInterface for MockDb {Err(StorageError::MockDbError)?}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_attempt_id_merchant_id(&self,_attempt_id: &str,@@ -70,20 +70,19 @@ impl PaymentAttemptInterface for MockDb {Err(StorageError::MockDbError)?}- #[cfg(all(feature = "v2", feature = "payment_v2"))]- async fn find_payment_attempt_by_attempt_id_merchant_id(+ #[cfg(feature = "v2")]+ async fn find_payment_attempt_by_id(&self,_key_manager_state: &KeyManagerState,_merchant_key_store: &MerchantKeyStore,_attempt_id: &str,- _merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: storage_enums::MerchantStorageScheme,- ) -> CustomResult<PaymentAttempt, StorageError> {+ ) -> error_stack::Result<PaymentAttempt, StorageError> {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_preprocessing_id_merchant_id(&self,_preprocessing_id: &str,@@ -94,7 +93,7 @@ impl PaymentAttemptInterface for MockDb {Err(StorageError::MockDbError)?}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_merchant_id_connector_txn_id(&self,_merchant_id: &common_utils::id_type::MerchantId,@@ -105,7 +104,7 @@ impl PaymentAttemptInterface for MockDb {Err(StorageError::MockDbError)?}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_attempts_by_merchant_id_payment_id(&self,_merchant_id: &common_utils::id_type::MerchantId,@@ -116,7 +115,7 @@ impl PaymentAttemptInterface for MockDb {Err(StorageError::MockDbError)?}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[allow(clippy::panic)]async fn insert_payment_attempt(&self,@@ -194,7 +193,7 @@ impl PaymentAttemptInterface for MockDb {Ok(payment_attempt)}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]#[allow(clippy::panic)]async fn insert_payment_attempt(&self,@@ -207,7 +206,7 @@ impl PaymentAttemptInterface for MockDb {Err(StorageError::MockDbError)?}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]// safety: only used for testing#[allow(clippy::unwrap_used)]async fn update_payment_attempt_with_attempt_id(@@ -232,7 +231,7 @@ impl PaymentAttemptInterface for MockDb {Ok(item.clone())}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]async fn update_payment_attempt_with_attempt_id(&self,_key_manager_state: &KeyManagerState,@@ -245,7 +244,7 @@ impl PaymentAttemptInterface for MockDb {Err(StorageError::MockDbError)?}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(&self,_connector_transaction_id: &str,@@ -257,7 +256,7 @@ impl PaymentAttemptInterface for MockDb {Err(StorageError::MockDbError)?}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]// safety: only used for testing#[allow(clippy::unwrap_used)]async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(@@ -278,7 +277,7 @@ impl PaymentAttemptInterface for MockDb {.unwrap())}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[allow(clippy::unwrap_used)]async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(&self,diff --git a/crates/storage_impl/src/mock_db/payment_intent.rs b/crates/storage_impl/src/mock_db/payment_intent.rsindex 0f1161f644..22160d901f 100644--- a/crates/storage_impl/src/mock_db/payment_intent.rs+++ b/crates/storage_impl/src/mock_db/payment_intent.rs@@ -6,7 +6,6 @@ use hyperswitch_domain_models::{errors::StorageError,merchant_key_store::MerchantKeyStore,payments::{- payment_attempt::PaymentAttempt,payment_intent::{PaymentIntentInterface, PaymentIntentUpdate},PaymentIntent,},@@ -16,11 +15,7 @@ use super::MockDb;#[async_trait::async_trait]impl PaymentIntentInterface for MockDb {- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn filter_payment_intent_by_constraints(&self,_state: &KeyManagerState,@@ -32,11 +27,8 @@ impl PaymentIntentInterface for MockDb {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?}- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]++ #[cfg(all(feature = "v1", feature = "olap"))]async fn filter_payment_intents_by_time_range_constraints(&self,_state: &KeyManagerState,@@ -48,11 +40,8 @@ impl PaymentIntentInterface for MockDb {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?}- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]++ #[cfg(all(feature = "v1", feature = "olap"))]async fn get_intent_status_with_count(&self,_merchant_id: &common_utils::id_type::MerchantId,@@ -62,11 +51,8 @@ impl PaymentIntentInterface for MockDb {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?}- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]++ #[cfg(all(feature = "v1", feature = "olap"))]async fn get_filtered_active_attempt_ids_for_total_count(&self,_merchant_id: &common_utils::id_type::MerchantId,@@ -76,11 +62,8 @@ impl PaymentIntentInterface for MockDb {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?}- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]++ #[cfg(all(feature = "v1", feature = "olap"))]async fn get_filtered_payment_intents_attempt(&self,_state: &KeyManagerState,@@ -88,7 +71,13 @@ impl PaymentIntentInterface for MockDb {_constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,_key_store: &MerchantKeyStore,_storage_scheme: storage_enums::MerchantStorageScheme,- ) -> error_stack::Result<Vec<(PaymentIntent, PaymentAttempt)>, StorageError> {+ ) -> error_stack::Result<+ Vec<(+ PaymentIntent,+ hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,+ )>,+ StorageError,+ > {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?}@@ -141,7 +130,7 @@ impl PaymentIntentInterface for MockDb {Ok(payment_intent.clone())}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]// safety: only used for testing#[allow(clippy::unwrap_used)]async fn find_payment_intent_by_payment_id_merchant_id(@@ -163,7 +152,7 @@ impl PaymentIntentInterface for MockDb {.unwrap())}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]async fn find_payment_intent_by_id(&self,_state: &KeyManagerState,@@ -181,24 +170,4 @@ impl PaymentIntentInterface for MockDb {Ok(payment_intent.clone())}-- async fn get_active_payment_attempt(- &self,- payment: &mut PaymentIntent,- _storage_scheme: storage_enums::MerchantStorageScheme,- ) -> error_stack::Result<PaymentAttempt, StorageError> {- match payment.active_attempt.clone() {- hyperswitch_domain_models::RemoteStorageObject::ForeignID(id) => {- let attempts = self.payment_attempts.lock().await;- let attempt = attempts- .iter()- .find(|pa| pa.attempt_id == id && pa.merchant_id == payment.merchant_id)- .ok_or(StorageError::ValueNotFound("Attempt not found".to_string()))?;-- payment.active_attempt = attempt.clone().into();- Ok(attempt.clone())- }- hyperswitch_domain_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),- }- }}diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rsindex 9974393e10..6d669437ef 100644--- a/crates/storage_impl/src/payments/payment_attempt.rs+++ b/crates/storage_impl/src/payments/payment_attempt.rs@@ -1,5 +1,4 @@-use api_models::enums::{AuthenticationType, Connector, PaymentMethod, PaymentMethodType};-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "v2")]use common_utils::types::keymanager::KeyManagerState;use common_utils::{errors::CustomResult, fallback_reverse_lookup_not_found};use diesel_models::{@@ -15,21 +14,21 @@ use diesel_models::{reverse_lookup::{ReverseLookup, ReverseLookupNew},};use error_stack::ResultExt;+#[cfg(feature = "v2")]+use hyperswitch_domain_models::{+ behaviour::{Conversion, ReverseConversion},+ merchant_key_store::MerchantKeyStore,+};use hyperswitch_domain_models::{- behaviour::Conversion,errors,mandates::{MandateAmountData, MandateDataType, MandateDetails},- payments::{- payment_attempt::{- PaymentAttempt, PaymentAttemptInterface, PaymentAttemptNew, PaymentAttemptUpdate,- PaymentListFilters,- },- PaymentIntent,+ payments::payment_attempt::{+ PaymentAttempt, PaymentAttemptInterface, PaymentAttemptNew, PaymentAttemptUpdate,},};-#[cfg(all(feature = "v2", feature = "payment_v2"))]+#[cfg(feature = "olap")]use hyperswitch_domain_models::{- behaviour::ReverseConversion, merchant_key_store::MerchantKeyStore,+ payments::payment_attempt::PaymentListFilters, payments::PaymentIntent,};use redis_interface::HsetnxReply;use router_env::{instrument, tracing};@@ -45,7 +44,7 @@ use crate::{#[async_trait::async_trait]impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn insert_payment_attempt(&self,@@ -64,7 +63,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {.map(PaymentAttempt::from_storage_model)}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]#[instrument(skip_all)]async fn insert_payment_attempt(&self,@@ -93,7 +92,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {.change_context(errors::StorageError::DecryptionError)}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn update_payment_attempt_with_attempt_id(&self,@@ -112,7 +111,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {.map(PaymentAttempt::from_storage_model)}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]#[instrument(skip_all)]async fn update_payment_attempt_with_attempt_id(&self,@@ -145,7 +144,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {.change_context(errors::StorageError::DecryptionError)}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(&self,@@ -169,7 +168,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {.map(PaymentAttempt::from_storage_model)}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(&self,@@ -191,7 +190,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {.map(PaymentAttempt::from_storage_model)}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(&self,@@ -213,7 +212,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {.map(PaymentAttempt::from_storage_model)}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_by_merchant_id_connector_txn_id(&self,@@ -235,7 +234,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {.map(PaymentAttempt::from_storage_model)}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(&self,@@ -260,7 +259,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {.map(PaymentAttempt::from_storage_model)}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(all(feature = "v1", feature = "olap"))]#[instrument(skip_all)]async fn get_filters_for_payments(&self,@@ -268,6 +267,8 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: MerchantStorageScheme,) -> CustomResult<PaymentListFilters, errors::StorageError> {+ use hyperswitch_domain_models::behaviour::Conversion;+let conn = pg_connection_read(self).await?;let intents = futures::future::try_join_all(pi.iter().cloned().map(|pi| async {Conversion::convert(pi)@@ -301,7 +302,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {)}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_by_preprocessing_id_merchant_id(&self,@@ -324,7 +325,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {.map(PaymentAttempt::from_storage_model)}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_attempts_by_merchant_id_payment_id(&self,@@ -346,7 +347,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {})}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_by_attempt_id_merchant_id(&self,@@ -365,19 +366,18 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {.map(PaymentAttempt::from_storage_model)}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]#[instrument(skip_all)]- async fn find_payment_attempt_by_attempt_id_merchant_id(+ async fn find_payment_attempt_by_id(&self,key_manager_state: &KeyManagerState,merchant_key_store: &MerchantKeyStore,attempt_id: &str,- merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: MerchantStorageScheme,- ) -> CustomResult<PaymentAttempt, errors::StorageError> {+ ) -> error_stack::Result<PaymentAttempt, errors::StorageError> {let conn = pg_connection_read(self).await?;- DieselPaymentAttempt::find_by_merchant_id_attempt_id(&conn, merchant_id, attempt_id)+ DieselPaymentAttempt::find_by_id(&conn, attempt_id).await.map_err(|er| {let new_err = diesel_error_to_data_error(er.current_context());@@ -392,16 +392,16 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {.change_context(errors::StorageError::DecryptionError)}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(all(feature = "v1", feature = "olap"))]#[instrument(skip_all)]async fn get_total_count_of_filtered_payment_attempts(&self,merchant_id: &common_utils::id_type::MerchantId,active_attempt_ids: &[String],- connector: Option<Vec<Connector>>,- payment_method: Option<Vec<PaymentMethod>>,- payment_method_type: Option<Vec<PaymentMethodType>>,- authentication_type: Option<Vec<AuthenticationType>>,+ connector: Option<Vec<api_models::enums::Connector>>,+ payment_method: Option<Vec<common_enums::PaymentMethod>>,+ payment_method_type: Option<Vec<common_enums::PaymentMethodType>>,+ authentication_type: Option<Vec<common_enums::AuthenticationType>>,merchant_connector_id: Option<Vec<common_utils::id_type::MerchantConnectorAccountId>>,time_range: Option<common_utils::types::TimeRange>,profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,@@ -441,7 +441,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {#[async_trait::async_trait]impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn insert_payment_attempt(&self,@@ -590,7 +590,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {}}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]#[instrument(skip_all)]async fn insert_payment_attempt(&self,@@ -610,7 +610,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {.await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn update_payment_attempt_with_attempt_id(&self,@@ -734,7 +734,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {}}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]#[instrument(skip_all)]async fn update_payment_attempt_with_attempt_id(&self,@@ -756,7 +756,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {.await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(&self,@@ -816,7 +816,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {}}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(&self,@@ -875,7 +875,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {}}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(&self,@@ -937,7 +937,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {}}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_by_merchant_id_connector_txn_id(&self,@@ -1006,7 +1006,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {}}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(&self,@@ -1060,7 +1060,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {}}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_by_attempt_id_merchant_id(&self,@@ -1126,29 +1126,27 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {}}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]#[instrument(skip_all)]- async fn find_payment_attempt_by_attempt_id_merchant_id(+ async fn find_payment_attempt_by_id(&self,key_manager_state: &KeyManagerState,merchant_key_store: &MerchantKeyStore,attempt_id: &str,- merchant_id: &common_utils::id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError> {// Ignoring storage scheme for v2 implementationself.router_store- .find_payment_attempt_by_attempt_id_merchant_id(+ .find_payment_attempt_by_id(key_manager_state,merchant_key_store,attempt_id,- merchant_id,storage_scheme,).await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_attempt_by_preprocessing_id_merchant_id(&self,@@ -1217,7 +1215,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {}}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_attempts_by_merchant_id_payment_id(&self,@@ -1267,7 +1265,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {}}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(all(feature = "v1", feature = "olap"))]#[instrument(skip_all)]async fn get_filters_for_payments(&self,@@ -1280,16 +1278,16 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {.await}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(all(feature = "v1", feature = "olap"))]#[instrument(skip_all)]async fn get_total_count_of_filtered_payment_attempts(&self,merchant_id: &common_utils::id_type::MerchantId,active_attempt_ids: &[String],- connector: Option<Vec<Connector>>,- payment_method: Option<Vec<PaymentMethod>>,- payment_method_type: Option<Vec<PaymentMethodType>>,- authentication_type: Option<Vec<AuthenticationType>>,+ connector: Option<Vec<api_models::enums::Connector>>,+ payment_method: Option<Vec<common_enums::PaymentMethod>>,+ payment_method_type: Option<Vec<common_enums::PaymentMethodType>>,+ authentication_type: Option<Vec<common_enums::AuthenticationType>>,merchant_connector_id: Option<Vec<common_utils::id_type::MerchantConnectorAccountId>>,time_range: Option<common_utils::types::TimeRange>,profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,@@ -1375,159 +1373,7 @@ impl DataModelExt for MandateDataType {}}-#[cfg(all(feature = "v2", feature = "payment_v2"))]-impl DataModelExt for PaymentAttempt {- type StorageModel = DieselPaymentAttempt;-- fn to_storage_model(self) -> Self::StorageModel {- DieselPaymentAttempt {- payment_id: self.payment_id,- merchant_id: self.merchant_id,- attempt_id: self.attempt_id,- status: self.status,- amount: self.amount,- net_amount: Some(self.net_amount),- currency: self.currency,- save_to_locker: self.save_to_locker,- connector: self.connector,- error_message: self.error_message,- offer_amount: self.offer_amount,- surcharge_amount: self.surcharge_amount,- tax_amount: self.tax_amount,- payment_method_id: self.payment_method_id,- payment_method: self.payment_method,- connector_transaction_id: self.connector_transaction_id,- capture_method: self.capture_method,- capture_on: self.capture_on,- confirm: self.confirm,- authentication_type: self.authentication_type,- created_at: self.created_at,- modified_at: self.modified_at,- last_synced: self.last_synced,- cancellation_reason: self.cancellation_reason,- amount_to_capture: self.amount_to_capture,- mandate_id: self.mandate_id,- browser_info: self.browser_info,- error_code: self.error_code,- payment_token: self.payment_token,- connector_metadata: self.connector_metadata,- payment_experience: self.payment_experience,- payment_method_type: self.payment_method_type,- card_network: self- .payment_method_data- .as_ref()- .and_then(|data| data.as_object())- .and_then(|card| card.get("card"))- .and_then(|data| data.as_object())- .and_then(|card| card.get("card_network"))- .and_then(|network| network.as_str())- .map(|network| network.to_string()),- payment_method_data: self.payment_method_data,- business_sub_label: self.business_sub_label,- straight_through_algorithm: self.straight_through_algorithm,- preprocessing_step_id: self.preprocessing_step_id,- mandate_details: self.mandate_details.map(|d| d.to_storage_model()),- error_reason: self.error_reason,- multiple_capture_count: self.multiple_capture_count,- connector_response_reference_id: self.connector_response_reference_id,- amount_capturable: self.amount_capturable,- updated_by: self.updated_by,- authentication_data: self.authentication_data,- encoded_data: self.encoded_data,- merchant_connector_id: self.merchant_connector_id,- unified_code: self.unified_code,- unified_message: self.unified_message,- external_three_ds_authentication_attempted: self- .external_three_ds_authentication_attempted,- authentication_connector: self.authentication_connector,- authentication_id: self.authentication_id,- mandate_data: self.mandate_data.map(|d| d.to_storage_model()),- payment_method_billing_address_id: self.payment_method_billing_address_id,- fingerprint_id: self.fingerprint_id,- charge_id: self.charge_id,- client_source: self.client_source,- client_version: self.client_version,- customer_acceptance: self.customer_acceptance,- organization_id: self.organization_id,- profile_id: self.profile_id,- shipping_cost: self.shipping_cost,- order_tax_amount: self.order_tax_amount,- }- }-- fn from_storage_model(storage_model: Self::StorageModel) -> Self {- Self {- net_amount: storage_model.get_or_calculate_net_amount(),- payment_id: storage_model.payment_id,- merchant_id: storage_model.merchant_id,- attempt_id: storage_model.attempt_id,- status: storage_model.status,- amount: storage_model.amount,- currency: storage_model.currency,- save_to_locker: storage_model.save_to_locker,- connector: storage_model.connector,- error_message: storage_model.error_message,- offer_amount: storage_model.offer_amount,- surcharge_amount: storage_model.surcharge_amount,- tax_amount: storage_model.tax_amount,- payment_method_id: storage_model.payment_method_id,- payment_method: storage_model.payment_method,- connector_transaction_id: storage_model.connector_transaction_id,- capture_method: storage_model.capture_method,- capture_on: storage_model.capture_on,- confirm: storage_model.confirm,- authentication_type: storage_model.authentication_type,- created_at: storage_model.created_at,- modified_at: storage_model.modified_at,- last_synced: storage_model.last_synced,- cancellation_reason: storage_model.cancellation_reason,- amount_to_capture: storage_model.amount_to_capture,- mandate_id: storage_model.mandate_id,- browser_info: storage_model.browser_info,- error_code: storage_model.error_code,- payment_token: storage_model.payment_token,- connector_metadata: storage_model.connector_metadata,- payment_experience: storage_model.payment_experience,- payment_method_type: storage_model.payment_method_type,- payment_method_data: storage_model.payment_method_data,- business_sub_label: storage_model.business_sub_label,- straight_through_algorithm: storage_model.straight_through_algorithm,- preprocessing_step_id: storage_model.preprocessing_step_id,- mandate_details: storage_model- .mandate_details- .map(MandateDataType::from_storage_model),- error_reason: storage_model.error_reason,- multiple_capture_count: storage_model.multiple_capture_count,- connector_response_reference_id: storage_model.connector_response_reference_id,- amount_capturable: storage_model.amount_capturable,- updated_by: storage_model.updated_by,- authentication_data: storage_model.authentication_data,- encoded_data: storage_model.encoded_data,- merchant_connector_id: storage_model.merchant_connector_id,- unified_code: storage_model.unified_code,- unified_message: storage_model.unified_message,- external_three_ds_authentication_attempted: storage_model- .external_three_ds_authentication_attempted,- authentication_connector: storage_model.authentication_connector,- authentication_id: storage_model.authentication_id,- mandate_data: storage_model- .mandate_data- .map(MandateDetails::from_storage_model),- payment_method_billing_address_id: storage_model.payment_method_billing_address_id,- fingerprint_id: storage_model.fingerprint_id,- charge_id: storage_model.charge_id,- client_source: storage_model.client_source,- client_version: storage_model.client_version,- customer_acceptance: storage_model.customer_acceptance,- organization_id: storage_model.organization_id,- profile_id: storage_model.profile_id,- shipping_cost: storage_model.shipping_cost,- order_tax_amount: storage_model.order_tax_amount,- }- }-}--#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+#[cfg(feature = "v1")]impl DataModelExt for PaymentAttempt {type StorageModel = DieselPaymentAttempt;@@ -1679,6 +1525,7 @@ impl DataModelExt for PaymentAttempt {}}+#[cfg(feature = "v1")]impl DataModelExt for PaymentAttemptNew {type StorageModel = DieselPaymentAttemptNew;@@ -1830,6 +1677,7 @@ impl DataModelExt for PaymentAttemptNew {}}+#[cfg(feature = "v1")]impl DataModelExt for PaymentAttemptUpdate {type StorageModel = DieselPaymentAttemptUpdate;diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rsindex 971c5edfcd..4c7232f6f3 100644--- a/crates/storage_impl/src/payments/payment_intent.rs+++ b/crates/storage_impl/src/payments/payment_intent.rs@@ -12,16 +12,12 @@ use common_utils::{use diesel::{associations::HasTable, ExpressionMethods, JoinOnDsl, QueryDsl};#[cfg(feature = "olap")]use diesel_models::query::generics::db_metrics;-#[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"-))]+#[cfg(all(feature = "v1", feature = "olap"))]use diesel_models::schema::{payment_attempt::{self as payment_attempt_schema, dsl as pa_dsl},payment_intent::dsl as pi_dsl,};-#[cfg(all(feature = "v2", feature = "payment_v2", feature = "olap"))]+#[cfg(all(feature = "v2", feature = "olap"))]use diesel_models::schema_v2::{payment_attempt::{self as payment_attempt_schema, dsl as pa_dsl},payment_intent::dsl as pi_dsl,@@ -29,24 +25,23 @@ use diesel_models::schema_v2::{use diesel_models::{enums::MerchantStorageScheme,kv,- payment_attempt::PaymentAttempt as DieselPaymentAttempt,payment_intent::{PaymentIntent as DieselPaymentIntent, PaymentIntentUpdate as DieselPaymentIntentUpdate,},};use error_stack::ResultExt;#[cfg(feature = "olap")]-use hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints;+use hyperswitch_domain_models::payments::{+ payment_attempt::PaymentAttempt, payment_intent::PaymentIntentFetchConstraints,+};use hyperswitch_domain_models::{behaviour::Conversion,errors::StorageError,merchant_key_store::MerchantKeyStore,payments::{- payment_attempt::PaymentAttempt,payment_intent::{PaymentIntentInterface, PaymentIntentUpdate},PaymentIntent,},- RemoteStorageObject,};use redis_interface::HsetnxReply;#[cfg(feature = "olap")]@@ -60,7 +55,7 @@ use crate::{errors::RedisErrorExt,redis::kv_store::{decide_storage_scheme, kv_wrapper, KvOperation, Op, PartitionKey},utils::{self, pg_connection_read, pg_connection_write},- DataModelExt, DatabaseStore, KVRouterStore,+ DatabaseStore, KVRouterStore,};#[async_trait::async_trait]@@ -285,7 +280,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {}}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_intent_by_payment_id_merchant_id(&self,@@ -345,7 +340,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {.change_context(StorageError::DecryptionError)}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]#[instrument(skip_all)]async fn find_payment_intent_by_id(&self,@@ -377,38 +372,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {.change_context(StorageError::DecryptionError)}- async fn get_active_payment_attempt(- &self,- payment: &mut PaymentIntent,- _storage_scheme: MerchantStorageScheme,- ) -> error_stack::Result<PaymentAttempt, StorageError> {- match payment.active_attempt.clone() {- RemoteStorageObject::ForeignID(attempt_id) => {- let conn = pg_connection_read(self).await?;-- let pa = DieselPaymentAttempt::find_by_merchant_id_attempt_id(- &conn,- &payment.merchant_id,- attempt_id.as_str(),- )- .await- .map_err(|er| {- let new_err = diesel_error_to_data_error(er.current_context());- er.change_context(new_err)- })- .map(PaymentAttempt::from_storage_model)?;- payment.active_attempt = RemoteStorageObject::Object(pa.clone());- Ok(pa)- }- RemoteStorageObject::Object(pa) => Ok(pa.clone()),- }- }-- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn filter_payment_intent_by_constraints(&self,state: &KeyManagerState,@@ -428,11 +392,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {.await}- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn filter_payment_intents_by_time_range_constraints(&self,state: &KeyManagerState,@@ -452,11 +412,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {.await}- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn get_intent_status_with_count(&self,merchant_id: &common_utils::id_type::MerchantId,@@ -468,11 +424,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {.await}- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn get_filtered_payment_intents_attempt(&self,state: &KeyManagerState,@@ -492,11 +444,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {.await}- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]async fn get_filtered_active_attempt_ids_for_total_count(&self,merchant_id: &common_utils::id_type::MerchantId,@@ -578,7 +526,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {.change_context(StorageError::DecryptionError)}- #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]+ #[cfg(feature = "v1")]#[instrument(skip_all)]async fn find_payment_intent_by_payment_id_merchant_id(&self,@@ -609,7 +557,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {.await}- #[cfg(all(feature = "v2", feature = "payment_v2"))]+ #[cfg(feature = "v2")]#[instrument(skip_all)]async fn find_payment_intent_by_id(&self,@@ -638,39 +586,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {.change_context(StorageError::DecryptionError)}- #[instrument(skip_all)]- async fn get_active_payment_attempt(- &self,- payment: &mut PaymentIntent,- _storage_scheme: MerchantStorageScheme,- ) -> error_stack::Result<PaymentAttempt, StorageError> {- match &payment.active_attempt {- RemoteStorageObject::ForeignID(attempt_id) => {- let conn = pg_connection_read(self).await?;-- let pa = DieselPaymentAttempt::find_by_merchant_id_attempt_id(- &conn,- &payment.merchant_id,- attempt_id.as_str(),- )- .await- .map_err(|er| {- let new_err = diesel_error_to_data_error(er.current_context());- er.change_context(new_err)- })- .map(PaymentAttempt::from_storage_model)?;- payment.active_attempt = RemoteStorageObject::Object(pa.clone());- Ok(pa)- }- RemoteStorageObject::Object(pa) => Ok(pa.clone()),- }- }-- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]#[instrument(skip_all)]async fn filter_payment_intent_by_constraints(&self,@@ -796,11 +712,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {.await}- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]#[instrument(skip_all)]async fn filter_payment_intents_by_time_range_constraints(&self,@@ -822,11 +734,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {.await}- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]#[instrument(skip_all)]async fn get_intent_status_with_count(&self,@@ -870,11 +778,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {})}- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]#[instrument(skip_all)]async fn get_filtered_payment_intents_attempt(&self,@@ -886,6 +790,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {) -> error_stack::Result<Vec<(PaymentIntent, PaymentAttempt)>, StorageError> {use futures::{future::try_join_all, FutureExt};+ use crate::DataModelExt;+let conn = connection::pg_connection_read(self).await.switch()?;let conn = async_bb8_diesel::Connection::as_async_conn(&conn);let mut query = DieselPaymentIntent::table()@@ -1040,7 +946,10 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {logger::debug!(filter = %diesel::debug_query::<diesel::pg::Pg,_>(&query).to_string());query- .get_results_async::<(DieselPaymentIntent, DieselPaymentAttempt)>(conn)+ .get_results_async::<(+ DieselPaymentIntent,+ diesel_models::payment_attempt::PaymentAttempt,+ )>(conn).await.map(|results| {try_join_all(results.into_iter().map(|(pi, pa)| {@@ -1067,11 +976,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {.await}- #[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "payment_v2"),- feature = "olap"- ))]+ #[cfg(all(feature = "v1", feature = "olap"))]#[instrument(skip_all)]async fn get_filtered_active_attempt_ids_for_total_count(&self,diff --git a/justfile b/justfileindex e1b9c25935..84df776c1b 100644--- a/justfile+++ b/justfile@@ -114,7 +114,7 @@ run *FLAGS:alias r := run-doc_flags := '--all-features --all-targets --exclude-features "v2 payment_v2"'+doc_flags := '--all-features --all-targets --exclude-features "v2"'# Generate documentationdoc *FLAGS:diff --git a/v2_migrations/2024-08-28-081721_add_v2_columns/down.sql b/v2_migrations/2024-08-28-081721_add_v2_columns/down.sqlindex de4886b866..cfc769e70e 100644--- a/v2_migrations/2024-08-28-081721_add_v2_columns/down.sql+++ b/v2_migrations/2024-08-28-081721_add_v2_columns/down.sql@@ -31,3 +31,11 @@ ALTER TABLE payment_intent DROP COLUMN merchant_reference_id,DROP COLUMN customer_present,DROP COLUMN routing_algorithm_id,DROP COLUMN payment_link_config;++ALTER TABLE payment_attempt DROP COLUMN payment_method_type_v2,+ DROP COLUMN connector_payment_id,+ DROP COLUMN payment_method_subtype,+ DROP COLUMN routing_result,+ DROP COLUMN authentication_applied,+ DROP COLUMN external_reference_id,+ DROP COLUMN tax_on_surcharge;diff --git a/v2_migrations/2024-08-28-081721_add_v2_columns/up.sql b/v2_migrations/2024-08-28-081721_add_v2_columns/up.sqlindex b89985ae81..520bbdf6e7 100644--- a/v2_migrations/2024-08-28-081721_add_v2_columns/up.sql+++ b/v2_migrations/2024-08-28-081721_add_v2_columns/up.sql@@ -33,3 +33,12 @@ ADD COLUMN merchant_reference_id VARCHAR(64),ADD COLUMN customer_present BOOLEAN,ADD COLUMN routing_algorithm_id VARCHAR(64),ADD COLUMN payment_link_config JSONB;++ALTER TABLE payment_attempt+ADD COLUMN payment_method_type_v2 VARCHAR,+ ADD COLUMN connector_payment_id VARCHAR(128),+ ADD COLUMN payment_method_subtype VARCHAR(64),+ ADD COLUMN routing_result JSONB,+ ADD COLUMN authentication_applied "AuthenticationType",+ ADD COLUMN external_reference_id VARCHAR(128),+ ADD COLUMN tax_on_surcharge BIGINT;diff --git a/v2_migrations/2024-08-28-081747_recreate_ids_for_v2/up.sql b/v2_migrations/2024-08-28-081747_recreate_ids_for_v2/up.sqlindex 99b9441739..daaf597661 100644--- a/v2_migrations/2024-08-28-081747_recreate_ids_for_v2/up.sql+++ b/v2_migrations/2024-08-28-081747_recreate_ids_for_v2/up.sql@@ -30,3 +30,6 @@ ADD COLUMN IF NOT EXISTS id VARCHAR(64);------------------------ Payment Attempt -----------------------ALTER TABLE payment_attempt DROP COLUMN id;++ALTER TABLE payment_attempt+ADD COLUMN IF NOT EXISTS id VARCHAR(64);diff --git a/v2_migrations/2024-08-28-081838_update_v2_primary_key_constraints/down.sql b/v2_migrations/2024-08-28-081838_update_v2_primary_key_constraints/down.sqlindex 50f0e89da8..33a58538a8 100644--- a/v2_migrations/2024-08-28-081838_update_v2_primary_key_constraints/down.sql+++ b/v2_migrations/2024-08-28-081838_update_v2_primary_key_constraints/down.sql@@ -9,7 +9,7 @@ ALTER TABLE ORGANIZATION DROP CONSTRAINT organization_pkey_id;ALTER TABLE ORGANIZATIONADD CONSTRAINT organization_pkey PRIMARY KEY (org_id);-ALTER TABLE organization DROP CONSTRAINT organization_organization_name_key;+ALTER TABLE ORGANIZATION DROP CONSTRAINT organization_organization_name_key;-- back fillUPDATE ORGANIZATION@@ -83,10 +83,16 @@ ALTER TABLE payment_intentADD PRIMARY KEY (payment_id, merchant_id);ALTER TABLE payment_intent-ALTER COLUMN profile_id DROP NOT NULL;+ALTER COLUMN currency DROP NOT NULL,+ ALTER COLUMN client_secret DROP NOT NULL,+ ALTER COLUMN profile_id DROP NOT NULL;-ALTER TABLE payment_intent-ALTER COLUMN currency DROP NOT NULL;+------------------------ Payment Attempt -----------------------+ALTER TABLE payment_attempt DROP CONSTRAINT payment_attempt_pkey;-ALTER TABLE payment_intent-ALTER COLUMN client_secret DROP NOT NULL;+UPDATE payment_attempt+SET attempt_id = id+WHERE attempt_id IS NULL;++ALTER TABLE payment_attempt+ADD PRIMARY KEY (attempt_id, merchant_id);diff --git a/v2_migrations/2024-08-28-081838_update_v2_primary_key_constraints/up.sql b/v2_migrations/2024-08-28-081838_update_v2_primary_key_constraints/up.sqlindex 8d89e4bc92..33718e2050 100644--- a/v2_migrations/2024-08-28-081838_update_v2_primary_key_constraints/up.sql+++ b/v2_migrations/2024-08-28-081838_update_v2_primary_key_constraints/up.sql@@ -91,6 +91,12 @@ ALTER TABLE payment_intent DROP CONSTRAINT payment_intent_pkey;ALTER TABLE payment_intentADD PRIMARY KEY (id);+------------------------ Payment Attempt -----------------------+ALTER TABLE payment_attempt DROP CONSTRAINT payment_attempt_pkey;++ALTER TABLE payment_attempt+ADD PRIMARY KEY (id);+-- This migration is to make fields mandatory in payment_intent tableALTER TABLE payment_intentALTER COLUMN profile_iddiff --git a/v2_migrations/2024-08-28-081847_drop_v1_columns/down.sql b/v2_migrations/2024-08-28-081847_drop_v1_columns/down.sqlindex 004c46a67d..65e90b126f 100644--- a/v2_migrations/2024-08-28-081847_drop_v1_columns/down.sql+++ b/v2_migrations/2024-08-28-081847_drop_v1_columns/down.sql@@ -58,8 +58,8 @@ ADD COLUMN IF NOT EXISTS payment_id VARCHAR(64) NOT NULL,ADD COLUMN business_country "CountryAlpha2",ADD COLUMN business_label VARCHAR(64),ADD COLUMN incremental_authorization_allowed BOOLEAN,- ADD COLUMN fingerprint_id VARCHAR(64),ADD COLUMN merchant_decision VARCHAR(64),+ ADD COLUMN fingerprint_id VARCHAR(64),ADD COLUMN statement_descriptor_name VARCHAR(255),ADD COLUMN amount_to_capture BIGINT,ADD COLUMN off_session BOOLEAN,@@ -67,3 +67,26 @@ ADD COLUMN IF NOT EXISTS payment_id VARCHAR(64) NOT NULL,ADD COLUMN merchant_order_reference_id VARCHAR(255),ADD COLUMN is_payment_processor_token_flow BOOLEAN,ADD COLUMN charges jsonb;++ALTER TABLE payment_attempt+ADD COLUMN IF NOT EXISTS attempt_id VARCHAR(64) NOT NULL,+ ADD COLUMN amount bigint NOT NULL,+ ADD COLUMN currency "Currency",+ ADD COLUMN save_to_locker BOOLEAN,+ ADD COLUMN offer_amount bigint,+ ADD COLUMN payment_method VARCHAR,+ ADD COLUMN connector_transaction_id VARCHAR(64),+ ADD COLUMN capture_method "CaptureMethod",+ ADD COLUMN capture_on TIMESTAMP,+ ADD COLUMN mandate_id VARCHAR(64),+ ADD COLUMN payment_method_type VARCHAR(64),+ ADD COLUMN business_sub_label VARCHAR(64),+ ADD COLUMN mandate_details JSONB,+ ADD COLUMN mandate_data JSONB,+ ADD COLUMN tax_amount bigint,+ ADD COLUMN straight_through_algorithm JSONB;++-- Create the index which was dropped because of dropping the column+CREATE INDEX payment_attempt_connector_transaction_id_merchant_id_index ON payment_attempt (connector_transaction_id, merchant_id);++CREATE UNIQUE INDEX payment_attempt_payment_id_merchant_id_attempt_id_index ON payment_attempt (payment_id, merchant_id, attempt_id);diff --git a/v2_migrations/2024-08-28-081847_drop_v1_columns/up.sql b/v2_migrations/2024-08-28-081847_drop_v1_columns/up.sqlindex 0d2fcdd61d..55b0b19d0b 100644--- a/v2_migrations/2024-08-28-081847_drop_v1_columns/up.sql+++ b/v2_migrations/2024-08-28-081847_drop_v1_columns/up.sql@@ -65,3 +65,21 @@ ALTER TABLE payment_intent DROP COLUMN payment_id,DROP COLUMN merchant_order_reference_id,DROP COLUMN is_payment_processor_token_flow,DROP COLUMN charges;++-- Run below queries only when V1 is deprecated+ALTER TABLE payment_attempt DROP COLUMN attempt_id,+ DROP COLUMN amount,+ DROP COLUMN currency,+ DROP COLUMN save_to_locker,+ DROP COLUMN offer_amount,+ DROP COLUMN payment_method,+ DROP COLUMN connector_transaction_id,+ DROP COLUMN capture_method,+ DROP COLUMN capture_on,+ DROP COLUMN mandate_id,+ DROP COLUMN payment_method_type,+ DROP COLUMN business_sub_label,+ DROP COLUMN mandate_details,+ DROP COLUMN mandate_data,+ DROP COLUMN tax_amount,+ DROP COLUMN straight_through_algorithm;