Skip to content

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

feat(payments_v2): payment intent diesel and domain models changes v2 (#5783)

Narayan Bhat10ac08944986
diff --git a/crates/common_utils/src/id_type/global_id.rs b/crates/common_utils/src/id_type/global_id.rs
index dcfb9998d3..f04bfc3f92 100644
--- a/crates/common_utils/src/id_type/global_id.rs
+++ b/crates/common_utils/src/id_type/global_id.rs
@@ -11,7 +11,7 @@ use crate::{
id_type::{AlphaNumericId, AlphaNumericIdError, LengthId, LengthIdError},
};
-#[derive(Debug, Clone, Hash, PartialEq, Eq)]
+#[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize)]
/// A global id that can be used to identify any entity
/// This id will have information about the entity and cell in a distributed system architecture
pub(crate) struct GlobalId(LengthId<MAX_GLOBAL_ID_LENGTH, MIN_GLOBAL_ID_LENGTH>);
diff --git a/crates/common_utils/src/id_type/payment.rs b/crates/common_utils/src/id_type/payment.rs
index 87e6eff29f..e0269f2bef 100644
--- a/crates/common_utils/src/id_type/payment.rs
+++ b/crates/common_utils/src/id_type/payment.rs
@@ -1,7 +1,7 @@
use crate::{
errors::{CustomResult, ValidationError},
generate_id_with_default_len,
- id_type::{AlphaNumericId, LengthId},
+ id_type::{global_id, AlphaNumericId, LengthId},
};
crate::id_type!(
@@ -18,6 +18,20 @@ crate::impl_try_from_cow_str_id_type!(PaymentId, "payment_id");
crate::impl_queryable_id_type!(PaymentId);
crate::impl_to_sql_from_sql_id_type!(PaymentId);
+/// A global id that can be used to identify a payment
+#[derive(
+ Debug,
+ Clone,
+ Hash,
+ PartialEq,
+ Eq,
+ serde::Serialize,
+ serde::Deserialize,
+ diesel::expression::AsExpression,
+)]
+#[diesel(sql_type = diesel::sql_types::Text)]
+pub struct PaymentGlobalId(global_id::GlobalId);
+
impl PaymentId {
/// Get the hash key to be stored in redis
pub fn get_hash_key_for_kv_store(&self) -> String {
@@ -75,12 +89,3 @@ impl From<PaymentId> for router_env::opentelemetry::Value {
Self::String(router_env::opentelemetry::StringValue::from(string_value))
}
}
-
-// #[cfg(feature = "metrics")]
-// /// This is implemented so that we can use payment id directly as attribute in metrics
-// impl router_env::tracing::Value for PaymentId {
-// fn record(&self, key: &router_env::types::Field, visitor: &mut dyn router_env::types::Visit) {
-// let string_value = self.get_string_repr();
-// visitor.record_str(key, &string_value);
-// }
-// }
diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rs
index b2f314a0fe..42424c9bff 100644
--- a/crates/diesel_models/src/payment_intent.rs
+++ b/crates/diesel_models/src/payment_intent.rs
@@ -12,9 +12,8 @@ use crate::schema_v2::payment_intent;
#[cfg(all(feature = "v2", feature = "payment_v2"))]
#[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))]
+#[diesel(table_name = payment_intent, primary_key(id), check_for_backend(diesel::pg::Pg))]
pub struct PaymentIntent {
- pub payment_id: common_utils::id_type::PaymentId,
pub merchant_id: common_utils::id_type::MerchantId,
pub status: storage_enums::IntentStatus,
pub amount: MinorUnit,
@@ -24,11 +23,7 @@ pub struct PaymentIntent {
pub description: Option<String>,
pub return_url: Option<String>,
pub metadata: Option<serde_json::Value>,
- pub connector_id: Option<String>,
- pub shipping_address_id: Option<String>,
- pub billing_address_id: Option<String>,
pub statement_descriptor_name: Option<String>,
- pub statement_descriptor_suffix: Option<String>,
#[serde(with = "common_utils::custom_serde::iso8601")]
pub created_at: PrimitiveDateTime,
#[serde(with = "common_utils::custom_serde::iso8601")]
@@ -39,8 +34,6 @@ pub struct PaymentIntent {
pub off_session: Option<bool>,
pub client_secret: Option<String>,
pub active_attempt_id: String,
- pub business_country: Option<storage_enums::CountryAlpha2>,
- pub business_label: Option<String>,
#[diesel(deserialize_as = super::OptionalDieselArray<pii::SecretSerdeValue>)]
pub order_details: Option<Vec<pii::SecretSerdeValue>>,
pub allowed_payment_method_types: Option<serde_json::Value>,
@@ -48,31 +41,38 @@ pub struct PaymentIntent {
pub feature_metadata: Option<serde_json::Value>,
pub attempt_count: i16,
pub profile_id: Option<common_utils::id_type::ProfileId>,
- // Denotes the action(approve or reject) taken by merchant in case of manual review.
- // Manual review can occur when the transaction is marked as risky by the frm_processor, payment processor or when there is underpayment/over payment incase of crypto payment
- pub merchant_decision: Option<String>,
pub payment_link_id: Option<String>,
pub payment_confirm_source: Option<storage_enums::PaymentSource>,
pub updated_by: String,
pub surcharge_applicable: Option<bool>,
pub request_incremental_authorization: Option<RequestIncrementalAuthorization>,
- pub incremental_authorization_allowed: Option<bool>,
pub authorization_count: Option<i32>,
pub session_expiry: Option<PrimitiveDateTime>,
- pub fingerprint_id: Option<String>,
pub request_external_three_ds_authentication: Option<bool>,
pub charges: Option<pii::SecretSerdeValue>,
pub frm_metadata: Option<pii::SecretSerdeValue>,
pub customer_details: Option<Encryption>,
- pub billing_details: Option<Encryption>,
pub merchant_order_reference_id: Option<String>,
- pub shipping_details: Option<Encryption>,
pub is_payment_processor_token_flow: Option<bool>,
pub shipping_cost: Option<MinorUnit>,
pub organization_id: common_utils::id_type::OrganizationId,
pub tax_details: Option<TaxDetails>,
pub skip_external_tax_calculation: Option<bool>,
+ pub merchant_reference_id: String,
+ pub billing_address: Option<Encryption>,
+ pub shipping_address: Option<Encryption>,
+ pub capture_method: Option<storage_enums::CaptureMethod>,
+ pub authentication_type: Option<common_enums::AuthenticationType>,
+ pub amount_to_capture: Option<MinorUnit>,
+ pub prerouting_algorithm: Option<serde_json::Value>,
+ pub surcharge_amount: Option<MinorUnit>,
+ pub tax_on_surcharge: Option<MinorUnit>,
+ // Denotes the action(approve or reject) taken by merchant in case of manual review.
+ // Manual review can occur when the transaction is marked as risky by the frm_processor, payment processor or when there is underpayment/over payment incase of crypto payment
+ pub frm_merchant_decision: Option<String>,
+ // TODO: change this to global id
+ pub id: common_utils::id_type::PaymentId,
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
@@ -118,7 +118,6 @@ pub struct PaymentIntent {
pub merchant_decision: Option<String>,
pub payment_link_id: Option<String>,
pub payment_confirm_source: Option<storage_enums::PaymentSource>,
-
pub updated_by: String,
pub surcharge_applicable: Option<bool>,
pub request_incremental_authorization: Option<RequestIncrementalAuthorization>,
@@ -160,6 +159,74 @@ pub struct DefaultTax {
pub order_tax_amount: MinorUnit,
}
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
+#[derive(
+ Clone, Debug, PartialEq, Insertable, router_derive::DebugAsDisplay, Serialize, Deserialize,
+)]
+#[diesel(table_name = payment_intent)]
+pub struct PaymentIntentNew {
+ pub merchant_id: common_utils::id_type::MerchantId,
+ pub status: storage_enums::IntentStatus,
+ pub amount: MinorUnit,
+ pub currency: Option<storage_enums::Currency>,
+ pub amount_captured: Option<MinorUnit>,
+ pub customer_id: Option<common_utils::id_type::CustomerId>,
+ pub description: Option<String>,
+ pub return_url: Option<String>,
+ pub metadata: Option<serde_json::Value>,
+ pub statement_descriptor_name: Option<String>,
+ #[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 setup_future_usage: Option<storage_enums::FutureUsage>,
+ pub off_session: Option<bool>,
+ pub client_secret: Option<String>,
+ pub active_attempt_id: String,
+ #[diesel(deserialize_as = super::OptionalDieselArray<pii::SecretSerdeValue>)]
+ pub order_details: Option<Vec<pii::SecretSerdeValue>>,
+ pub allowed_payment_method_types: Option<serde_json::Value>,
+ pub connector_metadata: Option<serde_json::Value>,
+ pub feature_metadata: Option<serde_json::Value>,
+ pub attempt_count: i16,
+ pub profile_id: Option<common_utils::id_type::ProfileId>,
+ pub payment_link_id: Option<String>,
+ pub payment_confirm_source: Option<storage_enums::PaymentSource>,
+ pub updated_by: String,
+ pub surcharge_applicable: Option<bool>,
+ pub request_incremental_authorization: Option<RequestIncrementalAuthorization>,
+ pub authorization_count: Option<i32>,
+ #[serde(with = "common_utils::custom_serde::iso8601::option")]
+ pub session_expiry: Option<PrimitiveDateTime>,
+ pub request_external_three_ds_authentication: Option<bool>,
+ pub charges: Option<pii::SecretSerdeValue>,
+ pub frm_metadata: Option<pii::SecretSerdeValue>,
+ pub customer_details: Option<Encryption>,
+ pub merchant_order_reference_id: Option<String>,
+ pub is_payment_processor_token_flow: Option<bool>,
+ pub shipping_cost: Option<MinorUnit>,
+ pub organization_id: common_utils::id_type::OrganizationId,
+ pub tax_details: Option<TaxDetails>,
+ pub skip_external_tax_calculation: Option<bool>,
+ pub merchant_reference_id: String,
+ pub billing_address: Option<Encryption>,
+ pub shipping_address: Option<Encryption>,
+ pub capture_method: Option<storage_enums::CaptureMethod>,
+ pub authentication_type: Option<common_enums::AuthenticationType>,
+ pub amount_to_capture: Option<MinorUnit>,
+ pub prerouting_algorithm: Option<serde_json::Value>,
+ pub surcharge_amount: Option<MinorUnit>,
+ pub tax_on_surcharge: Option<MinorUnit>,
+ // Denotes the action(approve or reject) taken by merchant in case of manual review.
+ // Manual review can occur when the transaction is marked as risky by the frm_processor, payment processor or when there is underpayment/over payment incase of crypto payment
+ pub frm_merchant_decision: Option<String>,
+ // TODO: change this to global id
+ pub id: common_utils::id_type::PaymentId,
+}
+
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
#[derive(
Clone, Debug, PartialEq, Insertable, router_derive::DebugAsDisplay, Serialize, Deserialize,
)]
@@ -224,6 +291,86 @@ pub struct PaymentIntentNew {
pub skip_external_tax_calculation: Option<bool>,
}
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub enum PaymentIntentUpdate {
+ ResponseUpdate {
+ status: storage_enums::IntentStatus,
+ amount_captured: Option<MinorUnit>,
+ // Moved to attempt
+ // fingerprint_id: Option<String>,
+ return_url: Option<String>,
+ updated_by: String,
+ // Moved to attempt
+ // incremental_authorization_allowed: Option<bool>,
+ },
+ MetadataUpdate {
+ metadata: serde_json::Value,
+ updated_by: String,
+ },
+ Update(Box<PaymentIntentUpdateFields>),
+ PaymentCreateUpdate {
+ return_url: Option<String>,
+ status: Option<storage_enums::IntentStatus>,
+ customer_id: Option<common_utils::id_type::CustomerId>,
+ shipping_address: Option<Encryption>,
+ billing_address: Option<Encryption>,
+ customer_details: Option<Encryption>,
+ updated_by: String,
+ },
+ MerchantStatusUpdate {
+ status: storage_enums::IntentStatus,
+ shipping_address: Option<Encryption>,
+ billing_address: Option<Encryption>,
+ updated_by: String,
+ },
+ PGStatusUpdate {
+ status: storage_enums::IntentStatus,
+ updated_by: String,
+ // Moved to attempt
+ // incremental_authorization_allowed: Option<bool>,
+ },
+ PaymentAttemptAndAttemptCountUpdate {
+ active_attempt_id: String,
+ attempt_count: i16,
+ updated_by: String,
+ },
+ StatusAndAttemptUpdate {
+ status: storage_enums::IntentStatus,
+ active_attempt_id: String,
+ attempt_count: i16,
+ updated_by: String,
+ },
+ ApproveUpdate {
+ status: storage_enums::IntentStatus,
+ frm_merchant_decision: Option<String>,
+ updated_by: String,
+ },
+ RejectUpdate {
+ status: storage_enums::IntentStatus,
+ frm_merchant_decision: Option<String>,
+ updated_by: String,
+ },
+ SurchargeApplicableUpdate {
+ surcharge_applicable: Option<bool>,
+ updated_by: String,
+ },
+ IncrementalAuthorizationAmountUpdate {
+ amount: MinorUnit,
+ },
+ AuthorizationCountUpdate {
+ authorization_count: i32,
+ },
+ CompleteAuthorizeUpdate {
+ shipping_address: Option<Encryption>,
+ },
+ ManualUpdate {
+ status: Option<storage_enums::IntentStatus>,
+ updated_by: String,
+ },
+}
+
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PaymentIntentUpdate {
ResponseUpdate {
@@ -305,6 +452,32 @@ pub enum PaymentIntentUpdate {
},
}
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct PaymentIntentUpdateFields {
+ pub amount: MinorUnit,
+ pub currency: storage_enums::Currency,
+ pub setup_future_usage: Option<storage_enums::FutureUsage>,
+ pub status: storage_enums::IntentStatus,
+ pub customer_id: Option<common_utils::id_type::CustomerId>,
+ pub shipping_address: Option<Encryption>,
+ pub billing_address: Option<Encryption>,
+ pub return_url: Option<String>,
+ pub description: Option<String>,
+ pub statement_descriptor_name: Option<String>,
+ pub order_details: Option<Vec<pii::SecretSerdeValue>>,
+ pub metadata: Option<serde_json::Value>,
+ pub payment_confirm_source: Option<storage_enums::PaymentSource>,
+ pub updated_by: String,
+ pub session_expiry: Option<PrimitiveDateTime>,
+ pub request_external_three_ds_authentication: Option<bool>,
+ pub frm_metadata: Option<pii::SecretSerdeValue>,
+ pub customer_details: Option<Encryption>,
+ pub merchant_order_reference_id: Option<String>,
+ pub is_payment_processor_token_flow: Option<bool>,
+}
+
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PaymentIntentUpdateFields {
pub amount: MinorUnit,
@@ -336,6 +509,42 @@ pub struct PaymentIntentUpdateFields {
pub tax_details: Option<TaxDetails>,
}
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
+#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]
+#[diesel(table_name = payment_intent)]
+pub struct PaymentIntentUpdateInternal {
+ pub amount: Option<MinorUnit>,
+ pub currency: Option<storage_enums::Currency>,
+ pub status: Option<storage_enums::IntentStatus>,
+ pub amount_captured: Option<MinorUnit>,
+ pub customer_id: Option<common_utils::id_type::CustomerId>,
+ pub return_url: Option<String>,
+ pub setup_future_usage: Option<storage_enums::FutureUsage>,
+ pub off_session: Option<bool>,
+ pub metadata: Option<serde_json::Value>,
+ pub modified_at: PrimitiveDateTime,
+ pub active_attempt_id: Option<String>,
+ pub description: Option<String>,
+ pub statement_descriptor_name: Option<String>,
+ #[diesel(deserialize_as = super::OptionalDieselArray<pii::SecretSerdeValue>)]
+ pub order_details: Option<Vec<pii::SecretSerdeValue>>,
+ pub attempt_count: Option<i16>,
+ pub payment_confirm_source: Option<storage_enums::PaymentSource>,
+ pub updated_by: String,
+ pub surcharge_applicable: Option<bool>,
+ pub authorization_count: Option<i32>,
+ pub session_expiry: Option<PrimitiveDateTime>,
+ pub request_external_three_ds_authentication: Option<bool>,
+ pub frm_metadata: Option<pii::SecretSerdeValue>,
+ pub customer_details: Option<Encryption>,
+ pub billing_address: Option<Encryption>,
+ pub shipping_address: Option<Encryption>,
+ pub merchant_order_reference_id: Option<String>,
+ pub is_payment_processor_token_flow: Option<bool>,
+ pub frm_merchant_decision: Option<String>,
+}
+
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]
#[diesel(table_name = payment_intent)]
pub struct PaymentIntentUpdateInternal {
@@ -378,6 +587,7 @@ pub struct PaymentIntentUpdateInternal {
pub tax_details: Option<TaxDetails>,
}
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
impl PaymentIntentUpdate {
pub fn apply_changeset(self, source: PaymentIntent) -> PaymentIntent {
let PaymentIntentUpdateInternal {
@@ -390,33 +600,25 @@ impl PaymentIntentUpdate {
setup_future_usage,
off_session,
metadata,
- billing_address_id,
- shipping_address_id,
modified_at: _,
active_attempt_id,
- business_country,
- business_label,
description,
statement_descriptor_name,
- statement_descriptor_suffix,
order_details,
attempt_count,
- merchant_decision,
+ frm_merchant_decision,
payment_confirm_source,
updated_by,
surcharge_applicable,
- incremental_authorization_allowed,
authorization_count,
session_expiry,
- fingerprint_id,
request_external_three_ds_authentication,
frm_metadata,
customer_details,
- billing_details,
+ billing_address,
merchant_order_reference_id,
- shipping_details,
+ shipping_address,
is_payment_processor_token_flow,
- tax_details,
} = self.into();
PaymentIntent {
amount: amount.unwrap_or(source.amount),
@@ -428,45 +630,633 @@ impl PaymentIntentUpdate {
setup_future_usage: setup_future_usage.or(source.setup_future_usage),
off_session: off_session.or(source.off_session),
metadata: metadata.or(source.metadata),
- billing_address_id: billing_address_id.or(source.billing_address_id),
- shipping_address_id: shipping_address_id.or(source.shipping_address_id),
modified_at: common_utils::date_time::now(),
active_attempt_id: active_attempt_id.unwrap_or(source.active_attempt_id),
- business_country: business_country.or(source.business_country),
- business_label: business_label.or(source.business_label),
description: description.or(source.description),
statement_descriptor_name: statement_descriptor_name
.or(source.statement_descriptor_name),
- statement_descriptor_suffix: statement_descriptor_suffix
- .or(source.statement_descriptor_suffix),
order_details: order_details.or(source.order_details),
attempt_count: attempt_count.unwrap_or(source.attempt_count),
- merchant_decision: merchant_decision.or(source.merchant_decision),
+ frm_merchant_decision: frm_merchant_decision.or(source.frm_merchant_decision),
payment_confirm_source: payment_confirm_source.or(source.payment_confirm_source),
updated_by,
surcharge_applicable: surcharge_applicable.or(source.surcharge_applicable),
-
- incremental_authorization_allowed: incremental_authorization_allowed
- .or(source.incremental_authorization_allowed),
authorization_count: authorization_count.or(source.authorization_count),
- fingerprint_id: fingerprint_id.or(source.fingerprint_id),
session_expiry: session_expiry.or(source.session_expiry),
request_external_three_ds_authentication: request_external_three_ds_authentication
.or(source.request_external_three_ds_authentication),
frm_metadata: frm_metadata.or(source.frm_metadata),
customer_details: customer_details.or(source.customer_details),
- billing_details: billing_details.or(source.billing_details),
+ billing_address: billing_address.or(source.billing_address),
+ shipping_address: shipping_address.or(source.shipping_address),
merchant_order_reference_id: merchant_order_reference_id
.or(source.merchant_order_reference_id),
- shipping_details: shipping_details.or(source.shipping_details),
is_payment_processor_token_flow: is_payment_processor_token_flow
.or(source.is_payment_processor_token_flow),
- tax_details: tax_details.or(source.tax_details),
..source
}
}
}
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
+impl PaymentIntentUpdate {
+ pub fn apply_changeset(self, source: PaymentIntent) -> PaymentIntent {
+ let PaymentIntentUpdateInternal {
+ amount,
+ currency,
+ status,
+ amount_captured,
+ customer_id,
+ return_url,
+ setup_future_usage,
+ off_session,
+ metadata,
+ billing_address_id,
+ shipping_address_id,
+ modified_at: _,
+ active_attempt_id,
+ business_country,
+ business_label,
+ description,
+ statement_descriptor_name,
+ statement_descriptor_suffix,
+ order_details,
+ attempt_count,
+ merchant_decision,
+ payment_confirm_source,
+ updated_by,
+ surcharge_applicable,
+ incremental_authorization_allowed,
+ authorization_count,
+ session_expiry,
+ fingerprint_id,
+ request_external_three_ds_authentication,
+ frm_metadata,
+ customer_details,
+ billing_details,
+ merchant_order_reference_id,
+ shipping_details,
+ is_payment_processor_token_flow,
+ tax_details,
+ } = self.into();
+ PaymentIntent {
+ amount: amount.unwrap_or(source.amount),
+ currency: currency.or(source.currency),
+ status: status.unwrap_or(source.status),
+ amount_captured: amount_captured.or(source.amount_captured),
+ customer_id: customer_id.or(source.customer_id),
+ return_url: return_url.or(source.return_url),
+ setup_future_usage: setup_future_usage.or(source.setup_future_usage),
+ off_session: off_session.or(source.off_session),
+ metadata: metadata.or(source.metadata),
+ billing_address_id: billing_address_id.or(source.billing_address_id),
+ shipping_address_id: shipping_address_id.or(source.shipping_address_id),
+ modified_at: common_utils::date_time::now(),
+ active_attempt_id: active_attempt_id.unwrap_or(source.active_attempt_id),
+ business_country: business_country.or(source.business_country),
+ business_label: business_label.or(source.business_label),
+ description: description.or(source.description),
+ statement_descriptor_name: statement_descriptor_name
+ .or(source.statement_descriptor_name),
+ statement_descriptor_suffix: statement_descriptor_suffix
+ .or(source.statement_descriptor_suffix),
+ order_details: order_details.or(source.order_details),
+ attempt_count: attempt_count.unwrap_or(source.attempt_count),
+ merchant_decision: merchant_decision.or(source.merchant_decision),
+ payment_confirm_source: payment_confirm_source.or(source.payment_confirm_source),
+ updated_by,
+ surcharge_applicable: surcharge_applicable.or(source.surcharge_applicable),
+
+ incremental_authorization_allowed: incremental_authorization_allowed
+ .or(source.incremental_authorization_allowed),
+ authorization_count: authorization_count.or(source.authorization_count),
+ fingerprint_id: fingerprint_id.or(source.fingerprint_id),
+ session_expiry: session_expiry.or(source.session_expiry),
+ request_external_three_ds_authentication: request_external_three_ds_authentication
+ .or(source.request_external_three_ds_authentication),
+ frm_metadata: frm_metadata.or(source.frm_metadata),
+ customer_details: customer_details.or(source.customer_details),
+ billing_details: billing_details.or(source.billing_details),
+ merchant_order_reference_id: merchant_order_reference_id
+ .or(source.merchant_order_reference_id),
+ shipping_details: shipping_details.or(source.shipping_details),
+ is_payment_processor_token_flow: is_payment_processor_token_flow
+ .or(source.is_payment_processor_token_flow),
+ tax_details: tax_details.or(source.tax_details),
+ ..source
+ }
+ }
+}
+
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
+impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
+ fn from(payment_intent_update: PaymentIntentUpdate) -> Self {
+ match payment_intent_update {
+ PaymentIntentUpdate::MetadataUpdate {
+ metadata,
+ updated_by,
+ } => Self {
+ metadata: Some(metadata),
+ modified_at: common_utils::date_time::now(),
+ updated_by,
+ amount: None,
+ currency: None,
+ status: None,
+ amount_captured: None,
+ customer_id: None,
+ return_url: None,
+ setup_future_usage: None,
+ off_session: None,
+ active_attempt_id: None,
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ attempt_count: None,
+ frm_merchant_decision: None,
+ payment_confirm_source: None,
+ surcharge_applicable: None,
+ authorization_count: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ customer_details: None,
+ billing_address: None,
+ merchant_order_reference_id: None,
+ shipping_address: None,
+ is_payment_processor_token_flow: None,
+ },
+ PaymentIntentUpdate::Update(value) => Self {
+ amount: Some(value.amount),
+ currency: Some(value.currency),
+ setup_future_usage: value.setup_future_usage,
+ status: Some(value.status),
+ customer_id: value.customer_id,
+ shipping_address: value.shipping_address,
+ billing_address: value.billing_address,
+ return_url: value.return_url,
+ description: value.description,
+ statement_descriptor_name: value.statement_descriptor_name,
+ order_details: value.order_details,
+ metadata: value.metadata,
+ payment_confirm_source: value.payment_confirm_source,
+ updated_by: value.updated_by,
+ session_expiry: value.session_expiry,
+ request_external_three_ds_authentication: value
+ .request_external_three_ds_authentication,
+ frm_metadata: value.frm_metadata,
+ customer_details: value.customer_details,
+ merchant_order_reference_id: value.merchant_order_reference_id,
+ amount_captured: None,
+ off_session: None,
+ modified_at: common_utils::date_time::now(),
+ active_attempt_id: None,
+ attempt_count: None,
+ frm_merchant_decision: None,
+ surcharge_applicable: None,
+ authorization_count: None,
+ is_payment_processor_token_flow: value.is_payment_processor_token_flow,
+ },
+ PaymentIntentUpdate::PaymentCreateUpdate {
+ return_url,
+ status,
+ customer_id,
+ shipping_address,
+ billing_address,
+ customer_details,
+ updated_by,
+ } => Self {
+ return_url,
+ status,
+ customer_id,
+ customer_details,
+ modified_at: common_utils::date_time::now(),
+ updated_by,
+ amount: None,
+ currency: None,
+ amount_captured: None,
+ setup_future_usage: None,
+ off_session: None,
+ metadata: None,
+ active_attempt_id: None,
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ attempt_count: None,
+ frm_merchant_decision: None,
+ payment_confirm_source: None,
+ surcharge_applicable: None,
+ authorization_count: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ billing_address,
+ merchant_order_reference_id: None,
+ shipping_address,
+ is_payment_processor_token_flow: None,
+ },
+ PaymentIntentUpdate::PGStatusUpdate { status, updated_by } => Self {
+ status: Some(status),
+ modified_at: common_utils::date_time::now(),
+ updated_by,
+ amount: None,
+ currency: None,
+ amount_captured: None,
+ customer_id: None,
+ return_url: None,
+ setup_future_usage: None,
+ off_session: None,
+ metadata: None,
+ active_attempt_id: None,
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ attempt_count: None,
+ frm_merchant_decision: None,
+ payment_confirm_source: None,
+ surcharge_applicable: None,
+ authorization_count: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ customer_details: None,
+ billing_address: None,
+ merchant_order_reference_id: None,
+ shipping_address: None,
+ is_payment_processor_token_flow: None,
+ },
+ PaymentIntentUpdate::MerchantStatusUpdate {
+ status,
+ billing_address,
+ shipping_address,
+ updated_by,
+ } => Self {
+ status: Some(status),
+ modified_at: common_utils::date_time::now(),
+ updated_by,
+ amount: None,
+ currency: None,
+ amount_captured: None,
+ customer_id: None,
+ return_url: None,
+ setup_future_usage: None,
+ off_session: None,
+ metadata: None,
+ active_attempt_id: None,
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ attempt_count: None,
+ frm_merchant_decision: None,
+ payment_confirm_source: None,
+ surcharge_applicable: None,
+ authorization_count: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ customer_details: None,
+ billing_address,
+ merchant_order_reference_id: None,
+ shipping_address,
+ is_payment_processor_token_flow: None,
+ },
+ PaymentIntentUpdate::ResponseUpdate {
+ // amount,
+ // currency,
+ status,
+ amount_captured,
+ // customer_id,
+ return_url,
+ updated_by,
+ } => Self {
+ // amount,
+ // currency: Some(currency),
+ status: Some(status),
+ amount_captured,
+ // customer_id,
+ return_url,
+ modified_at: common_utils::date_time::now(),
+ updated_by,
+ amount: None,
+ currency: None,
+ customer_id: None,
+ setup_future_usage: None,
+ off_session: None,
+ metadata: None,
+ active_attempt_id: None,
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ attempt_count: None,
+ frm_merchant_decision: None,
+ payment_confirm_source: None,
+ surcharge_applicable: None,
+ authorization_count: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ customer_details: None,
+ billing_address: None,
+ merchant_order_reference_id: None,
+ shipping_address: None,
+ is_payment_processor_token_flow: None,
+ },
+ PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {
+ active_attempt_id,
+ attempt_count,
+ updated_by,
+ } => Self {
+ active_attempt_id: Some(active_attempt_id),
+ attempt_count: Some(attempt_count),
+ updated_by,
+ amount: None,
+ currency: None,
+ status: None,
+ amount_captured: None,
+ customer_id: None,
+ return_url: None,
+ setup_future_usage: None,
+ off_session: None,
+ metadata: None,
+ modified_at: common_utils::date_time::now(),
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ frm_merchant_decision: None,
+ payment_confirm_source: None,
+ surcharge_applicable: None,
+ authorization_count: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ customer_details: None,
+ billing_address: None,
+ merchant_order_reference_id: None,
+ shipping_address: None,
+ is_payment_processor_token_flow: None,
+ },
+ PaymentIntentUpdate::StatusAndAttemptUpdate {
+ status,
+ active_attempt_id,
+ attempt_count,
+ updated_by,
+ } => Self {
+ status: Some(status),
+ active_attempt_id: Some(active_attempt_id),
+ attempt_count: Some(attempt_count),
+ updated_by,
+ amount: None,
+ currency: None,
+ amount_captured: None,
+ customer_id: None,
+ return_url: None,
+ setup_future_usage: None,
+ off_session: None,
+ metadata: None,
+ modified_at: common_utils::date_time::now(),
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ frm_merchant_decision: None,
+ payment_confirm_source: None,
+ surcharge_applicable: None,
+ authorization_count: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ customer_details: None,
+ billing_address: None,
+ merchant_order_reference_id: None,
+ shipping_address: None,
+ is_payment_processor_token_flow: None,
+ },
+ PaymentIntentUpdate::ApproveUpdate {
+ status,
+ frm_merchant_decision,
+ updated_by,
+ } => Self {
+ status: Some(status),
+ frm_merchant_decision,
+ updated_by,
+ amount: None,
+ currency: None,
+ amount_captured: None,
+ customer_id: None,
+ return_url: None,
+ setup_future_usage: None,
+ off_session: None,
+ metadata: None,
+ modified_at: common_utils::date_time::now(),
+ active_attempt_id: None,
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ attempt_count: None,
+ payment_confirm_source: None,
+ surcharge_applicable: None,
+ authorization_count: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ customer_details: None,
+ billing_address: None,
+ merchant_order_reference_id: None,
+ shipping_address: None,
+ is_payment_processor_token_flow: None,
+ },
+ PaymentIntentUpdate::RejectUpdate {
+ status,
+ frm_merchant_decision,
+ updated_by,
+ } => Self {
+ status: Some(status),
+ frm_merchant_decision,
+ updated_by,
+ amount: None,
+ currency: None,
+ amount_captured: None,
+ customer_id: None,
+ return_url: None,
+ setup_future_usage: None,
+ off_session: None,
+ metadata: None,
+ modified_at: common_utils::date_time::now(),
+ active_attempt_id: None,
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ attempt_count: None,
+ payment_confirm_source: None,
+ surcharge_applicable: None,
+ authorization_count: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ customer_details: None,
+ billing_address: None,
+ merchant_order_reference_id: None,
+ shipping_address: None,
+ is_payment_processor_token_flow: None,
+ },
+ PaymentIntentUpdate::SurchargeApplicableUpdate {
+ surcharge_applicable,
+ updated_by,
+ } => Self {
+ surcharge_applicable,
+ updated_by,
+ amount: None,
+ currency: None,
+ status: None,
+ amount_captured: None,
+ customer_id: None,
+ return_url: None,
+ setup_future_usage: None,
+ off_session: None,
+ metadata: None,
+ modified_at: common_utils::date_time::now(),
+ active_attempt_id: None,
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ attempt_count: None,
+ frm_merchant_decision: None,
+ payment_confirm_source: None,
+ authorization_count: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ customer_details: None,
+ billing_address: None,
+ merchant_order_reference_id: None,
+ shipping_address: None,
+ is_payment_processor_token_flow: None,
+ },
+ PaymentIntentUpdate::IncrementalAuthorizationAmountUpdate { amount } => Self {
+ amount: Some(amount),
+ currency: None,
+ status: None,
+ amount_captured: None,
+ customer_id: None,
+ return_url: None,
+ setup_future_usage: None,
+ off_session: None,
+ metadata: None,
+ modified_at: common_utils::date_time::now(),
+ active_attempt_id: None,
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ attempt_count: None,
+ frm_merchant_decision: None,
+ payment_confirm_source: None,
+ updated_by: String::default(),
+ surcharge_applicable: None,
+ authorization_count: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ customer_details: None,
+ billing_address: None,
+ merchant_order_reference_id: None,
+ shipping_address: None,
+ is_payment_processor_token_flow: None,
+ },
+ PaymentIntentUpdate::AuthorizationCountUpdate {
+ authorization_count,
+ } => Self {
+ authorization_count: Some(authorization_count),
+ amount: None,
+ currency: None,
+ status: None,
+ amount_captured: None,
+ customer_id: None,
+ return_url: None,
+ setup_future_usage: None,
+ off_session: None,
+ metadata: None,
+ modified_at: common_utils::date_time::now(),
+ active_attempt_id: None,
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ attempt_count: None,
+ frm_merchant_decision: None,
+ payment_confirm_source: None,
+ updated_by: String::default(),
+ surcharge_applicable: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ customer_details: None,
+ billing_address: None,
+ merchant_order_reference_id: None,
+ shipping_address: None,
+ is_payment_processor_token_flow: None,
+ },
+ PaymentIntentUpdate::CompleteAuthorizeUpdate { shipping_address } => Self {
+ amount: None,
+ currency: None,
+ status: None,
+ amount_captured: None,
+ customer_id: None,
+ return_url: None,
+ setup_future_usage: None,
+ off_session: None,
+ metadata: None,
+ modified_at: common_utils::date_time::now(),
+ active_attempt_id: None,
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ attempt_count: None,
+ frm_merchant_decision: None,
+ payment_confirm_source: None,
+ updated_by: String::default(),
+ surcharge_applicable: None,
+ authorization_count: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ customer_details: None,
+ billing_address: None,
+ merchant_order_reference_id: None,
+ shipping_address,
+ is_payment_processor_token_flow: None,
+ },
+ PaymentIntentUpdate::ManualUpdate { status, updated_by } => Self {
+ status,
+ updated_by,
+ amount: None,
+ currency: None,
+ amount_captured: None,
+ customer_id: None,
+ return_url: None,
+ setup_future_usage: None,
+ off_session: None,
+ metadata: None,
+ modified_at: common_utils::date_time::now(),
+ active_attempt_id: None,
+ description: None,
+ statement_descriptor_name: None,
+ order_details: None,
+ attempt_count: None,
+ frm_merchant_decision: None,
+ payment_confirm_source: None,
+ surcharge_applicable: None,
+ authorization_count: None,
+ session_expiry: None,
+ request_external_three_ds_authentication: None,
+ frm_metadata: None,
+ customer_details: None,
+ billing_address: None,
+ merchant_order_reference_id: None,
+ shipping_address: None,
+ is_payment_processor_token_flow: None,
+ },
+ }
+ }
+}
+
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
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_intent.rs b/crates/diesel_models/src/query/payment_intent.rs
index 86069e1c66..ccf82d2804 100644
--- a/crates/diesel_models/src/query/payment_intent.rs
+++ b/crates/diesel_models/src/query/payment_intent.rs
@@ -20,6 +20,36 @@ impl PaymentIntentNew {
}
impl PaymentIntent {
+ #[cfg(all(feature = "v2", feature = "payment_v2"))]
+ pub async fn update(
+ self,
+ conn: &PgPooledConn,
+ payment_intent: PaymentIntentUpdate,
+ ) -> StorageResult<Self> {
+ match generics::generic_update_by_id::<<Self as HasTable>::Table, _, _, _>(
+ conn,
+ self.id.to_owned(),
+ PaymentIntentUpdateInternal::from(payment_intent),
+ )
+ .await
+ {
+ Err(error) => match error.current_context() {
+ errors::DatabaseError::NoFieldsToUpdate => Ok(self),
+ _ => Err(error),
+ },
+ Ok(payment_intent) => Ok(payment_intent),
+ }
+ }
+
+ #[cfg(all(feature = "v2", feature = "payment_v2"))]
+ pub async fn find_by_global_id(
+ conn: &PgPooledConn,
+ id: &common_utils::id_type::PaymentId,
+ ) -> StorageResult<Self> {
+ 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")))]
pub async fn update(
self,
conn: &PgPooledConn,
@@ -44,6 +74,22 @@ impl PaymentIntent {
}
}
+ #[cfg(all(feature = "v2", feature = "payment_v2"))]
+ pub async fn find_by_merchant_reference_id_merchant_id(
+ conn: &PgPooledConn,
+ merchant_reference_id: &str,
+ merchant_id: &common_utils::id_type::MerchantId,
+ ) -> StorageResult<Self> {
+ generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
+ conn,
+ dsl::merchant_id
+ .eq(merchant_id.to_owned())
+ .and(dsl::merchant_reference_id.eq(merchant_reference_id.to_owned())),
+ )
+ .await
+ }
+
+ #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
pub async fn find_by_payment_id_merchant_id(
conn: &PgPooledConn,
payment_id: &common_utils::id_type::PaymentId,
@@ -58,6 +104,22 @@ impl PaymentIntent {
.await
}
+ #[cfg(all(feature = "v2", feature = "payment_v2"))]
+ pub async fn find_optional_by_merchant_id_merchant_reference_id(
+ conn: &PgPooledConn,
+ merchant_reference_id: &str,
+ merchant_id: &common_utils::id_type::MerchantId,
+ ) -> StorageResult<Option<Self>> {
+ generics::generic_find_one_optional::<<Self as HasTable>::Table, _, _>(
+ conn,
+ dsl::merchant_id
+ .eq(merchant_id.to_owned())
+ .and(dsl::merchant_reference_id.eq(merchant_reference_id.to_owned())),
+ )
+ .await
+ }
+
+ #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
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.rs
index ed88ccf46d..3890ee2cd0 100644
--- a/crates/diesel_models/src/query/user/sample_data.rs
+++ b/crates/diesel_models/src/query/user/sample_data.rs
@@ -61,6 +61,7 @@ pub async fn insert_refunds(
.attach_printable("Error while inserting refunds")
}
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
pub async fn delete_payment_intents(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
@@ -86,6 +87,33 @@ pub async fn delete_payment_intents(
_ => Ok(result),
})
}
+
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
+pub async fn delete_payment_intents(
+ conn: &PgPooledConn,
+ merchant_id: &common_utils::id_type::MerchantId,
+) -> StorageResult<Vec<PaymentIntent>> {
+ let query = diesel::delete(<PaymentIntent>::table())
+ .filter(payment_intent_dsl::merchant_id.eq(merchant_id.to_owned()))
+ .filter(payment_intent_dsl::merchant_reference_id.like("test_%"));
+
+ logger::debug!(query = %debug_query::<diesel::pg::Pg,_>(&query).to_string());
+
+ query
+ .get_results_async(conn)
+ .await
+ .change_context(errors::DatabaseError::Others)
+ .attach_printable("Error while deleting payment intents")
+ .and_then(|result| match result.len() {
+ n if n > 0 => {
+ logger::debug!("{n} records deleted");
+ Ok(result)
+ }
+ 0 => Err(error_stack::report!(errors::DatabaseError::NotFound)
+ .attach_printable("No records deleted")),
+ _ => Ok(result),
+ })
+}
pub async fn delete_payment_attempts(
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.rs
index 95550068f0..bd64c4bb00 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -829,9 +829,7 @@ diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;
- payment_intent (payment_id, merchant_id) {
- #[max_length = 64]
- payment_id -> Varchar,
+ payment_intent (id) {
#[max_length = 64]
merchant_id -> Varchar,
status -> IntentStatus,
@@ -845,16 +843,8 @@ diesel::table! {
#[max_length = 255]
return_url -> Nullable<Varchar>,
metadata -> Nullable<Jsonb>,
- #[max_length = 64]
- connector_id -> Nullable<Varchar>,
- #[max_length = 64]
- shipping_address_id -> Nullable<Varchar>,
- #[max_length = 64]
- billing_address_id -> Nullable<Varchar>,
#[max_length = 255]
statement_descriptor_name -> Nullable<Varchar>,
- #[max_length = 255]
- statement_descriptor_suffix -> Nullable<Varchar>,
created_at -> Timestamp,
modified_at -> Timestamp,
last_synced -> Nullable<Timestamp>,
@@ -864,9 +854,6 @@ diesel::table! {
client_secret -> Nullable<Varchar>,
#[max_length = 64]
active_attempt_id -> Varchar,
- business_country -> Nullable<CountryAlpha2>,
- #[max_length = 64]
- business_label -> Nullable<Varchar>,
order_details -> Nullable<Array<Nullable<Jsonb>>>,
allowed_payment_method_types -> Nullable<Json>,
connector_metadata -> Nullable<Json>,
@@ -874,8 +861,6 @@ diesel::table! {
attempt_count -> Int2,
#[max_length = 64]
profile_id -> Nullable<Varchar>,
- #[max_length = 64]
- merchant_decision -> Nullable<Varchar>,
#[max_length = 255]
payment_link_id -> Nullable<Varchar>,
payment_confirm_source -> Nullable<PaymentSource>,
@@ -883,25 +868,34 @@ diesel::table! {
updated_by -> Varchar,
surcharge_applicable -> Nullable<Bool>,
request_incremental_authorization -> Nullable<RequestIncrementalAuthorization>,
- incremental_authorization_allowed -> Nullable<Bool>,
authorization_count -> Nullable<Int4>,
session_expiry -> Nullable<Timestamp>,
- #[max_length = 64]
- fingerprint_id -> Nullable<Varchar>,
request_external_three_ds_authentication -> Nullable<Bool>,
charges -> Nullable<Jsonb>,
frm_metadata -> Nullable<Jsonb>,
customer_details -> Nullable<Bytea>,
- billing_details -> Nullable<Bytea>,
#[max_length = 255]
merchant_order_reference_id -> Nullable<Varchar>,
- shipping_details -> Nullable<Bytea>,
is_payment_processor_token_flow -> Nullable<Bool>,
shipping_cost -> Nullable<Int8>,
#[max_length = 32]
organization_id -> Varchar,
tax_details -> Nullable<Jsonb>,
skip_external_tax_calculation -> Nullable<Bool>,
+ #[max_length = 64]
+ merchant_reference_id -> Varchar,
+ billing_address -> Nullable<Bytea>,
+ shipping_address -> Nullable<Bytea>,
+ capture_method -> Nullable<CaptureMethod>,
+ authentication_type -> Nullable<AuthenticationType>,
+ amount_to_capture -> Nullable<Int8>,
+ prerouting_algorithm -> Nullable<Jsonb>,
+ surcharge_amount -> Nullable<Int8>,
+ tax_on_surcharge -> Nullable<Int8>,
+ #[max_length = 64]
+ frm_merchant_decision -> Nullable<Varchar>,
+ #[max_length = 64]
+ id -> Varchar,
}
}
diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rs
index 14d7e43450..fee2155e8d 100644
--- a/crates/hyperswitch_domain_models/src/payments.rs
+++ b/crates/hyperswitch_domain_models/src/payments.rs
@@ -11,6 +11,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")))]
#[derive(Clone, Debug, PartialEq, serde::Serialize)]
pub struct PaymentIntent {
pub payment_id: id_type::PaymentId,
@@ -73,3 +74,78 @@ pub struct PaymentIntent {
pub tax_details: Option<TaxDetails>,
pub skip_external_tax_calculation: Option<bool>,
}
+
+impl PaymentIntent {
+ #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2"),))]
+ pub fn get_id(&self) -> &id_type::PaymentId {
+ &self.payment_id
+ }
+
+ #[cfg(all(feature = "v2", feature = "payment_v2",))]
+ pub fn get_id(&self) -> &id_type::PaymentId {
+ &self.id
+ }
+}
+
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
+#[derive(Clone, Debug, PartialEq, serde::Serialize)]
+pub struct PaymentIntent {
+ pub merchant_id: id_type::MerchantId,
+ pub status: storage_enums::IntentStatus,
+ pub amount: MinorUnit,
+ pub currency: Option<storage_enums::Currency>,
+ pub amount_captured: Option<MinorUnit>,
+ pub customer_id: Option<id_type::CustomerId>,
+ pub description: Option<String>,
+ pub return_url: Option<String>,
+ pub metadata: Option<serde_json::Value>,
+ pub statement_descriptor_name: Option<String>,
+ #[serde(with = "common_utils::custom_serde::iso8601")]
+ pub created_at: PrimitiveDateTime,
+ #[serde(with = "common_utils::custom_serde::iso8601")]
+ pub modified_at: PrimitiveDateTime,
+ #[serde(with = "common_utils::custom_serde::iso8601::option")]
+ pub last_synced: Option<PrimitiveDateTime>,
+ pub setup_future_usage: Option<storage_enums::FutureUsage>,
+ pub off_session: Option<bool>,
+ pub client_secret: Option<String>,
+ pub active_attempt: RemoteStorageObject<PaymentAttempt>,
+ pub order_details: Option<Vec<pii::SecretSerdeValue>>,
+ pub allowed_payment_method_types: Option<serde_json::Value>,
+ pub connector_metadata: Option<serde_json::Value>,
+ pub feature_metadata: Option<serde_json::Value>,
+ pub attempt_count: i16,
+ pub profile_id: Option<id_type::ProfileId>,
+ pub payment_link_id: Option<String>,
+ // Denotes the action(approve or reject) taken by merchant in case of manual review.
+ // Manual review can occur when the transaction is marked as risky by the frm_processor, payment processor or when there is underpayment/over payment incase of crypto payment
+ pub frm_merchant_decision: Option<String>,
+ pub payment_confirm_source: Option<storage_enums::PaymentSource>,
+
+ pub updated_by: String,
+ pub surcharge_applicable: Option<bool>,
+ pub request_incremental_authorization: Option<storage_enums::RequestIncrementalAuthorization>,
+ pub authorization_count: Option<i32>,
+ #[serde(with = "common_utils::custom_serde::iso8601::option")]
+ pub session_expiry: Option<PrimitiveDateTime>,
+ pub request_external_three_ds_authentication: Option<bool>,
+ pub charges: Option<pii::SecretSerdeValue>,
+ pub frm_metadata: Option<pii::SecretSerdeValue>,
+ pub customer_details: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub merchant_order_reference_id: Option<String>,
+ pub is_payment_processor_token_flow: Option<bool>,
+ pub shipping_cost: Option<MinorUnit>,
+ pub tax_details: Option<TaxDetails>,
+ pub merchant_reference_id: String,
+ pub billing_address: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub shipping_address: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub capture_method: Option<storage_enums::CaptureMethod>,
+ pub id: id_type::PaymentId,
+ pub authentication_type: Option<common_enums::AuthenticationType>,
+ pub amount_to_capture: Option<MinorUnit>,
+ pub prerouting_algorithm: Option<serde_json::Value>,
+ pub surcharge_amount: Option<MinorUnit>,
+ pub tax_on_surcharge: Option<MinorUnit>,
+ pub organization_id: id_type::OrganizationId,
+ pub skip_external_tax_calculation: Option<bool>,
+}
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
index 1aaf5218af..b9cfba86d4 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
@@ -508,7 +508,6 @@ impl behaviour::Conversion for PaymentIntent {
async fn convert(self) -> CustomResult<Self::DstType, ValidationError> {
Ok(DieselPaymentIntent {
- payment_id: self.payment_id,
merchant_id: self.merchant_id,
status: self.status,
amount: self.amount,
@@ -518,11 +517,7 @@ impl behaviour::Conversion for PaymentIntent {
description: self.description,
return_url: self.return_url,
metadata: self.metadata,
- connector_id: self.connector_id,
- shipping_address_id: self.shipping_address_id,
- billing_address_id: self.billing_address_id,
statement_descriptor_name: self.statement_descriptor_name,
- statement_descriptor_suffix: self.statement_descriptor_suffix,
created_at: self.created_at,
modified_at: self.modified_at,
last_synced: self.last_synced,
@@ -530,32 +525,36 @@ impl behaviour::Conversion for PaymentIntent {
off_session: self.off_session,
client_secret: self.client_secret,
active_attempt_id: self.active_attempt.get_id(),
- business_country: self.business_country,
- business_label: self.business_label,
order_details: self.order_details,
allowed_payment_method_types: self.allowed_payment_method_types,
connector_metadata: self.connector_metadata,
feature_metadata: self.feature_metadata,
attempt_count: self.attempt_count,
profile_id: self.profile_id,
- merchant_decision: self.merchant_decision,
+ frm_merchant_decision: self.frm_merchant_decision,
payment_link_id: self.payment_link_id,
payment_confirm_source: self.payment_confirm_source,
updated_by: self.updated_by,
surcharge_applicable: self.surcharge_applicable,
request_incremental_authorization: self.request_incremental_authorization,
- incremental_authorization_allowed: self.incremental_authorization_allowed,
authorization_count: self.authorization_count,
- fingerprint_id: self.fingerprint_id,
session_expiry: self.session_expiry,
request_external_three_ds_authentication: self.request_external_three_ds_authentication,
charges: self.charges,
frm_metadata: self.frm_metadata,
customer_details: self.customer_details.map(Encryption::from),
- billing_details: self.billing_details.map(Encryption::from),
+ billing_address: self.billing_address.map(Encryption::from),
merchant_order_reference_id: self.merchant_order_reference_id,
- shipping_details: self.shipping_details.map(Encryption::from),
+ shipping_address: self.shipping_address.map(Encryption::from),
is_payment_processor_token_flow: self.is_payment_processor_token_flow,
+ capture_method: self.capture_method,
+ id: self.id,
+ authentication_type: self.authentication_type,
+ amount_to_capture: self.amount_to_capture,
+ prerouting_algorithm: self.prerouting_algorithm,
+ merchant_reference_id: self.merchant_reference_id,
+ surcharge_amount: self.surcharge_amount,
+ tax_on_surcharge: self.tax_on_surcharge,
organization_id: self.organization_id,
shipping_cost: self.shipping_cost,
tax_details: self.tax_details,
@@ -584,7 +583,6 @@ impl behaviour::Conversion for PaymentIntent {
.and_then(|val| val.try_into_optionaloperation())
};
Ok::<Self, error_stack::Report<common_utils::errors::CryptoError>>(Self {
- payment_id: storage_model.payment_id,
merchant_id: storage_model.merchant_id,
status: storage_model.status,
amount: storage_model.amount,
@@ -594,11 +592,7 @@ impl behaviour::Conversion for PaymentIntent {
description: storage_model.description,
return_url: storage_model.return_url,
metadata: storage_model.metadata,
- connector_id: storage_model.connector_id,
- shipping_address_id: storage_model.shipping_address_id,
- billing_address_id: storage_model.billing_address_id,
statement_descriptor_name: storage_model.statement_descriptor_name,
- statement_descriptor_suffix: storage_model.statement_descriptor_suffix,
created_at: storage_model.created_at,
modified_at: storage_model.modified_at,
last_synced: storage_model.last_synced,
@@ -606,23 +600,19 @@ impl behaviour::Conversion for PaymentIntent {
off_session: storage_model.off_session,
client_secret: storage_model.client_secret,
active_attempt: RemoteStorageObject::ForeignID(storage_model.active_attempt_id),
- business_country: storage_model.business_country,
- business_label: storage_model.business_label,
order_details: storage_model.order_details,
allowed_payment_method_types: storage_model.allowed_payment_method_types,
connector_metadata: storage_model.connector_metadata,
feature_metadata: storage_model.feature_metadata,
attempt_count: storage_model.attempt_count,
profile_id: storage_model.profile_id,
- merchant_decision: storage_model.merchant_decision,
+ frm_merchant_decision: storage_model.frm_merchant_decision,
payment_link_id: storage_model.payment_link_id,
payment_confirm_source: storage_model.payment_confirm_source,
updated_by: storage_model.updated_by,
surcharge_applicable: storage_model.surcharge_applicable,
request_incremental_authorization: storage_model.request_incremental_authorization,
- incremental_authorization_allowed: storage_model.incremental_authorization_allowed,
authorization_count: storage_model.authorization_count,
- fingerprint_id: storage_model.fingerprint_id,
session_expiry: storage_model.session_expiry,
request_external_three_ds_authentication: storage_model
.request_external_three_ds_authentication,
@@ -632,17 +622,25 @@ impl behaviour::Conversion for PaymentIntent {
.customer_details
.async_lift(inner_decrypt)
.await?,
- billing_details: storage_model
- .billing_details
+ billing_address: storage_model
+ .billing_address
.async_lift(inner_decrypt)
.await?,
merchant_order_reference_id: storage_model.merchant_order_reference_id,
- shipping_details: storage_model
- .shipping_details
+ shipping_address: storage_model
+ .shipping_address
.async_lift(inner_decrypt)
.await?,
is_payment_processor_token_flow: storage_model.is_payment_processor_token_flow,
+ capture_method: storage_model.capture_method,
+ id: storage_model.id,
+ merchant_reference_id: storage_model.merchant_reference_id,
organization_id: storage_model.organization_id,
+ authentication_type: storage_model.authentication_type,
+ amount_to_capture: storage_model.amount_to_capture,
+ prerouting_algorithm: storage_model.prerouting_algorithm,
+ surcharge_amount: storage_model.surcharge_amount,
+ tax_on_surcharge: storage_model.tax_on_surcharge,
shipping_cost: storage_model.shipping_cost,
tax_details: storage_model.tax_details,
skip_external_tax_calculation: storage_model.skip_external_tax_calculation,
@@ -656,7 +654,6 @@ impl behaviour::Conversion for PaymentIntent {
async fn construct_new(self) -> CustomResult<Self::NewDstType, ValidationError> {
Ok(DieselPaymentIntentNew {
- payment_id: self.payment_id,
merchant_id: self.merchant_id,
status: self.status,
amount: self.amount,
@@ -666,11 +663,7 @@ impl behaviour::Conversion for PaymentIntent {
description: self.description,
return_url: self.return_url,
metadata: self.metadata,
- connector_id: self.connector_id,
- shipping_address_id: self.shipping_address_id,
- billing_address_id: self.billing_address_id,
statement_descriptor_name: self.statement_descriptor_name,
- statement_descriptor_suffix: self.statement_descriptor_suffix,
created_at: self.created_at,
modified_at: self.modified_at,
last_synced: self.last_synced,
@@ -678,32 +671,36 @@ impl behaviour::Conversion for PaymentIntent {
off_session: self.off_session,
client_secret: self.client_secret,
active_attempt_id: self.active_attempt.get_id(),
- business_country: self.business_country,
- business_label: self.business_label,
order_details: self.order_details,
allowed_payment_method_types: self.allowed_payment_method_types,
connector_metadata: self.connector_metadata,
feature_metadata: self.feature_metadata,
attempt_count: self.attempt_count,
profile_id: self.profile_id,
- merchant_decision: self.merchant_decision,
+ frm_merchant_decision: self.frm_merchant_decision,
payment_link_id: self.payment_link_id,
payment_confirm_source: self.payment_confirm_source,
updated_by: self.updated_by,
surcharge_applicable: self.surcharge_applicable,
request_incremental_authorization: self.request_incremental_authorization,
- incremental_authorization_allowed: self.incremental_authorization_allowed,
authorization_count: self.authorization_count,
- fingerprint_id: self.fingerprint_id,
session_expiry: self.session_expiry,
request_external_three_ds_authentication: self.request_external_three_ds_authentication,
charges: self.charges,
frm_metadata: self.frm_metadata,
customer_details: self.customer_details.map(Encryption::from),
- billing_details: self.billing_details.map(Encryption::from),
+ billing_address: self.billing_address.map(Encryption::from),
merchant_order_reference_id: self.merchant_order_reference_id,
- shipping_details: self.shipping_details.map(Encryption::from),
+ shipping_address: self.shipping_address.map(Encryption::from),
is_payment_processor_token_flow: self.is_payment_processor_token_flow,
+ capture_method: self.capture_method,
+ id: self.id,
+ merchant_reference_id: self.merchant_reference_id,
+ authentication_type: self.authentication_type,
+ amount_to_capture: self.amount_to_capture,
+ prerouting_algorithm: self.prerouting_algorithm,
+ surcharge_amount: self.surcharge_amount,
+ tax_on_surcharge: self.tax_on_surcharge,
organization_id: self.organization_id,
shipping_cost: self.shipping_cost,
tax_details: self.tax_details,
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
index 62fb06fd52..c4d19c83a3 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
@@ -32,6 +32,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")))]
async fn find_payment_intent_by_payment_id_merchant_id(
&self,
state: &KeyManagerState,
@@ -41,13 +42,26 @@ pub trait PaymentIntentInterface {
storage_scheme: storage_enums::MerchantStorageScheme,
) -> error_stack::Result<PaymentIntent, errors::StorageError>;
+ #[cfg(all(feature = "v2", feature = "payment_v2"))]
+ async fn find_payment_intent_by_id(
+ &self,
+ state: &KeyManagerState,
+ id: &id_type::PaymentId,
+ merchant_key_store: &MerchantKeyStore,
+ 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(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn filter_payment_intent_by_constraints(
&self,
state: &KeyManagerState,
@@ -57,7 +71,11 @@ pub trait PaymentIntentInterface {
storage_scheme: storage_enums::MerchantStorageScheme,
) -> error_stack::Result<Vec<PaymentIntent>, errors::StorageError>;
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn filter_payment_intents_by_time_range_constraints(
&self,
state: &KeyManagerState,
@@ -67,7 +85,11 @@ pub trait PaymentIntentInterface {
storage_scheme: storage_enums::MerchantStorageScheme,
) -> error_stack::Result<Vec<PaymentIntent>, errors::StorageError>;
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn get_intent_status_with_count(
&self,
merchant_id: &id_type::MerchantId,
@@ -75,7 +97,11 @@ pub trait PaymentIntentInterface {
constraints: &api_models::payments::TimeRange,
) -> error_stack::Result<Vec<(common_enums::IntentStatus, i64)>, errors::StorageError>;
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn get_filtered_payment_intents_attempt(
&self,
state: &KeyManagerState,
@@ -85,7 +111,11 @@ pub trait PaymentIntentInterface {
storage_scheme: storage_enums::MerchantStorageScheme,
) -> error_stack::Result<Vec<(PaymentIntent, PaymentAttempt)>, errors::StorageError>;
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn get_filtered_active_attempt_ids_for_total_count(
&self,
merchant_id: &id_type::MerchantId,
@@ -102,6 +132,7 @@ pub struct CustomerData {
pub phone_country_code: Option<String>,
}
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
#[derive(Clone, Debug, PartialEq)]
pub struct PaymentIntentNew {
pub payment_id: id_type::PaymentId,
@@ -156,6 +187,86 @@ pub struct PaymentIntentNew {
pub skip_external_tax_calculation: Option<bool>,
}
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
+#[derive(Clone, Debug, PartialEq)]
+pub struct PaymentIntentNew {
+ pub payment_id: id_type::PaymentId,
+ pub merchant_id: id_type::MerchantId,
+ pub status: storage_enums::IntentStatus,
+ pub amount: MinorUnit,
+ pub currency: Option<storage_enums::Currency>,
+ pub amount_captured: Option<MinorUnit>,
+ pub customer_id: Option<id_type::CustomerId>,
+ pub description: Option<String>,
+ pub return_url: Option<String>,
+ pub metadata: Option<serde_json::Value>,
+ pub frm_metadata: Option<pii::SecretSerdeValue>,
+ pub connector_id: Option<String>,
+ pub shipping_address_id: Option<String>,
+ pub billing_address_id: Option<String>,
+ pub statement_descriptor_name: Option<String>,
+ pub statement_descriptor_suffix: Option<String>,
+ pub created_at: Option<PrimitiveDateTime>,
+ pub modified_at: Option<PrimitiveDateTime>,
+ pub last_synced: Option<PrimitiveDateTime>,
+ pub setup_future_usage: Option<storage_enums::FutureUsage>,
+ pub off_session: Option<bool>,
+ pub client_secret: Option<String>,
+ pub active_attempt: RemoteStorageObject<PaymentAttempt>,
+ pub business_country: Option<storage_enums::CountryAlpha2>,
+ pub business_label: Option<String>,
+ pub order_details: Option<Vec<pii::SecretSerdeValue>>,
+ pub allowed_payment_method_types: Option<serde_json::Value>,
+ pub connector_metadata: Option<serde_json::Value>,
+ pub feature_metadata: Option<serde_json::Value>,
+ pub attempt_count: i16,
+ pub profile_id: Option<id_type::ProfileId>,
+ pub merchant_decision: Option<String>,
+ pub payment_link_id: Option<String>,
+ pub payment_confirm_source: Option<storage_enums::PaymentSource>,
+
+ pub updated_by: String,
+ pub surcharge_applicable: Option<bool>,
+ pub request_incremental_authorization: Option<storage_enums::RequestIncrementalAuthorization>,
+ pub incremental_authorization_allowed: Option<bool>,
+ pub authorization_count: Option<i32>,
+ pub fingerprint_id: Option<String>,
+ pub session_expiry: Option<PrimitiveDateTime>,
+ pub request_external_three_ds_authentication: Option<bool>,
+ pub charges: Option<pii::SecretSerdeValue>,
+ pub customer_details: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub billing_details: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub shipping_details: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub is_payment_processor_token_flow: Option<bool>,
+ pub organization_id: id_type::OrganizationId,
+}
+
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
+#[derive(Debug, Clone, Serialize)]
+pub struct PaymentIntentUpdateFields {
+ pub amount: MinorUnit,
+ pub currency: storage_enums::Currency,
+ pub setup_future_usage: Option<storage_enums::FutureUsage>,
+ pub status: storage_enums::IntentStatus,
+ pub customer_id: Option<id_type::CustomerId>,
+ pub shipping_address: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub billing_address: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub return_url: Option<String>,
+ pub description: Option<String>,
+ pub statement_descriptor_name: Option<String>,
+ pub order_details: Option<Vec<pii::SecretSerdeValue>>,
+ pub metadata: Option<serde_json::Value>,
+ pub payment_confirm_source: Option<storage_enums::PaymentSource>,
+ pub updated_by: String,
+ pub session_expiry: Option<PrimitiveDateTime>,
+ pub request_external_three_ds_authentication: Option<bool>,
+ pub frm_metadata: Option<pii::SecretSerdeValue>,
+ pub customer_details: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub merchant_order_reference_id: Option<String>,
+ pub is_payment_processor_token_flow: Option<bool>,
+}
+
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
#[derive(Debug, Clone, Serialize)]
pub struct PaymentIntentUpdateFields {
pub amount: MinorUnit,
@@ -187,6 +298,7 @@ pub struct PaymentIntentUpdateFields {
pub tax_details: Option<diesel_models::TaxDetails>,
}
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
#[derive(Debug, Clone, Serialize)]
pub enum PaymentIntentUpdate {
ResponseUpdate {
@@ -268,6 +380,113 @@ pub enum PaymentIntentUpdate {
},
}
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
+#[derive(Debug, Clone, Serialize)]
+pub enum PaymentIntentUpdate {
+ ResponseUpdate {
+ status: storage_enums::IntentStatus,
+ amount_captured: Option<MinorUnit>,
+ return_url: Option<String>,
+ updated_by: String,
+ },
+ MetadataUpdate {
+ metadata: serde_json::Value,
+ updated_by: String,
+ },
+ Update(Box<PaymentIntentUpdateFields>),
+ PaymentCreateUpdate {
+ return_url: Option<String>,
+ status: Option<storage_enums::IntentStatus>,
+ customer_id: Option<id_type::CustomerId>,
+ shipping_address: Option<Encryptable<Secret<serde_json::Value>>>,
+ billing_address: Option<Encryptable<Secret<serde_json::Value>>>,
+ customer_details: Option<Encryptable<Secret<serde_json::Value>>>,
+ updated_by: String,
+ },
+ MerchantStatusUpdate {
+ status: storage_enums::IntentStatus,
+ shipping_address: Option<Encryptable<Secret<serde_json::Value>>>,
+ billing_address: Option<Encryptable<Secret<serde_json::Value>>>,
+ updated_by: String,
+ },
+ PGStatusUpdate {
+ status: storage_enums::IntentStatus,
+ updated_by: String,
+ },
+ PaymentAttemptAndAttemptCountUpdate {
+ active_attempt_id: String,
+ attempt_count: i16,
+ updated_by: String,
+ },
+ StatusAndAttemptUpdate {
+ status: storage_enums::IntentStatus,
+ active_attempt_id: String,
+ attempt_count: i16,
+ updated_by: String,
+ },
+ ApproveUpdate {
+ status: storage_enums::IntentStatus,
+ frm_merchant_decision: Option<String>,
+ updated_by: String,
+ },
+ RejectUpdate {
+ status: storage_enums::IntentStatus,
+ frm_merchant_decision: Option<String>,
+ updated_by: String,
+ },
+ SurchargeApplicableUpdate {
+ surcharge_applicable: bool,
+ updated_by: String,
+ },
+ IncrementalAuthorizationAmountUpdate {
+ amount: MinorUnit,
+ },
+ AuthorizationCountUpdate {
+ authorization_count: i32,
+ },
+ CompleteAuthorizeUpdate {
+ shipping_address: Option<Encryptable<Secret<serde_json::Value>>>,
+ },
+ ManualUpdate {
+ status: Option<storage_enums::IntentStatus>,
+ updated_by: String,
+ },
+}
+
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
+#[derive(Clone, Debug, Default)]
+pub struct PaymentIntentUpdateInternal {
+ pub amount: Option<MinorUnit>,
+ pub currency: Option<storage_enums::Currency>,
+ pub status: Option<storage_enums::IntentStatus>,
+ pub amount_captured: Option<MinorUnit>,
+ pub customer_id: Option<id_type::CustomerId>,
+ pub return_url: Option<String>,
+ pub setup_future_usage: Option<storage_enums::FutureUsage>,
+ pub off_session: Option<bool>,
+ pub metadata: Option<serde_json::Value>,
+ pub modified_at: Option<PrimitiveDateTime>,
+ pub active_attempt_id: Option<String>,
+ pub description: Option<String>,
+ pub statement_descriptor_name: Option<String>,
+ pub order_details: Option<Vec<pii::SecretSerdeValue>>,
+ pub attempt_count: Option<i16>,
+ pub frm_merchant_decision: Option<String>,
+ pub payment_confirm_source: Option<storage_enums::PaymentSource>,
+ pub updated_by: String,
+ pub surcharge_applicable: Option<bool>,
+ pub authorization_count: Option<i32>,
+ pub session_expiry: Option<PrimitiveDateTime>,
+ pub request_external_three_ds_authentication: Option<bool>,
+ pub frm_metadata: Option<pii::SecretSerdeValue>,
+ pub customer_details: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub billing_address: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub shipping_address: Option<Encryptable<Secret<serde_json::Value>>>,
+ pub merchant_order_reference_id: Option<String>,
+ pub is_payment_processor_token_flow: Option<bool>,
+}
+
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
#[derive(Clone, Debug, Default)]
pub struct PaymentIntentUpdateInternal {
pub amount: Option<MinorUnit>,
@@ -311,6 +530,7 @@ pub struct PaymentIntentUpdateInternal {
pub tax_details: Option<diesel_models::TaxDetails>,
}
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
fn from(payment_intent_update: PaymentIntentUpdate) -> Self {
match payment_intent_update {
@@ -329,69 +549,59 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
setup_future_usage: value.setup_future_usage,
status: Some(value.status),
customer_id: value.customer_id,
- shipping_address_id: value.shipping_address_id,
- billing_address_id: value.billing_address_id,
return_url: value.return_url,
- business_country: value.business_country,
- business_label: value.business_label,
description: value.description,
statement_descriptor_name: value.statement_descriptor_name,
- statement_descriptor_suffix: value.statement_descriptor_suffix,
order_details: value.order_details,
metadata: value.metadata,
payment_confirm_source: value.payment_confirm_source,
updated_by: value.updated_by,
session_expiry: value.session_expiry,
- fingerprint_id: value.fingerprint_id,
request_external_three_ds_authentication: value
.request_external_three_ds_authentication,
frm_metadata: value.frm_metadata,
customer_details: value.customer_details,
- billing_details: value.billing_details,
+ billing_address: value.billing_address,
merchant_order_reference_id: value.merchant_order_reference_id,
- shipping_details: value.shipping_details,
+ shipping_address: value.shipping_address,
is_payment_processor_token_flow: value.is_payment_processor_token_flow,
+ modified_at: Some(common_utils::date_time::now()),
..Default::default()
},
PaymentIntentUpdate::PaymentCreateUpdate {
return_url,
status,
customer_id,
- shipping_address_id,
- billing_address_id,
+ shipping_address,
+ billing_address,
customer_details,
updated_by,
} => Self {
return_url,
status,
customer_id,
- shipping_address_id,
- billing_address_id,
+ shipping_address,
+ billing_address,
customer_details,
modified_at: Some(common_utils::date_time::now()),
updated_by,
..Default::default()
},
- PaymentIntentUpdate::PGStatusUpdate {
- status,
- updated_by,
- incremental_authorization_allowed,
- } => Self {
+ PaymentIntentUpdate::PGStatusUpdate { status, updated_by } => Self {
status: Some(status),
modified_at: Some(common_utils::date_time::now()),
updated_by,
- incremental_authorization_allowed,
..Default::default()
},
PaymentIntentUpdate::MerchantStatusUpdate {
status,
- shipping_address_id,
- billing_address_id,
+ shipping_address,
+ billing_address,
updated_by,
} => Self {
status: Some(status),
- shipping_address_id,
- billing_address_id,
+ shipping_address,
+ billing_address,
modified_at: Some(common_utils::date_time::now()),
updated_by,
..Default::default()
@@ -401,22 +611,18 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
// currency,
status,
amount_captured,
- fingerprint_id,
// customer_id,
return_url,
updated_by,
- incremental_authorization_allowed,
} => Self {
// amount,
// currency: Some(currency),
status: Some(status),
amount_captured,
- fingerprint_id,
// customer_id,
return_url,
modified_at: Some(common_utils::date_time::now()),
updated_by,
- incremental_authorization_allowed,
..Default::default()
},
PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {
@@ -427,6 +633,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
active_attempt_id: Some(active_attempt_id),
attempt_count: Some(attempt_count),
updated_by,
+ modified_at: Some(common_utils::date_time::now()),
..Default::default()
},
PaymentIntentUpdate::StatusAndAttemptUpdate {
@@ -439,26 +646,29 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
active_attempt_id: Some(active_attempt_id),
attempt_count: Some(attempt_count),
updated_by,
+ modified_at: Some(common_utils::date_time::now()),
..Default::default()
},
PaymentIntentUpdate::ApproveUpdate {
status,
- merchant_decision,
+ frm_merchant_decision,
updated_by,
} => Self {
status: Some(status),
- merchant_decision,
+ frm_merchant_decision,
updated_by,
+ modified_at: Some(common_utils::date_time::now()),
..Default::default()
},
PaymentIntentUpdate::RejectUpdate {
status,
- merchant_decision,
+ frm_merchant_decision,
updated_by,
} => Self {
status: Some(status),
- merchant_decision,
+ frm_merchant_decision,
updated_by,
+ modified_at: Some(common_utils::date_time::now()),
..Default::default()
},
PaymentIntentUpdate::SurchargeApplicableUpdate {
@@ -466,23 +676,25 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
updated_by,
} => Self {
surcharge_applicable: Some(surcharge_applicable),
+ modified_at: Some(common_utils::date_time::now()),
updated_by,
..Default::default()
},
PaymentIntentUpdate::IncrementalAuthorizationAmountUpdate { amount } => Self {
amount: Some(amount),
+ modified_at: Some(common_utils::date_time::now()),
..Default::default()
},
PaymentIntentUpdate::AuthorizationCountUpdate {
authorization_count,
} => Self {
authorization_count: Some(authorization_count),
+ modified_at: Some(common_utils::date_time::now()),
..Default::default()
},
- PaymentIntentUpdate::CompleteAuthorizeUpdate {
- shipping_address_id,
- } => Self {
- shipping_address_id,
+ PaymentIntentUpdate::CompleteAuthorizeUpdate { shipping_address } => Self {
+ shipping_address,
+ modified_at: Some(common_utils::date_time::now()),
..Default::default()
},
PaymentIntentUpdate::ManualUpdate { status, updated_by } => Self {
@@ -491,45 +703,373 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
updated_by,
..Default::default()
},
- PaymentIntentUpdate::SessionResponseUpdate {
- tax_details,
- shipping_address_id,
- updated_by,
- shipping_details,
- } => Self {
- tax_details: Some(tax_details),
- shipping_address_id,
- updated_by,
- shipping_details,
- ..Default::default()
- },
}
}
}
-use diesel_models::{
- PaymentIntentUpdate as DieselPaymentIntentUpdate,
- PaymentIntentUpdateFields as DieselPaymentIntentUpdateFields,
-};
-
-impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {
- fn from(value: PaymentIntentUpdate) -> Self {
- match value {
- PaymentIntentUpdate::ResponseUpdate {
- status,
- amount_captured,
- fingerprint_id,
- return_url,
- updated_by,
- incremental_authorization_allowed,
- } => Self::ResponseUpdate {
- status,
- amount_captured,
- fingerprint_id,
- return_url,
- updated_by,
- incremental_authorization_allowed,
- },
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
+impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
+ fn from(payment_intent_update: PaymentIntentUpdate) -> Self {
+ match payment_intent_update {
+ PaymentIntentUpdate::MetadataUpdate {
+ metadata,
+ updated_by,
+ } => Self {
+ metadata: Some(metadata),
+ modified_at: Some(common_utils::date_time::now()),
+ updated_by,
+ ..Default::default()
+ },
+ PaymentIntentUpdate::Update(value) => Self {
+ amount: Some(value.amount),
+ currency: Some(value.currency),
+ setup_future_usage: value.setup_future_usage,
+ status: Some(value.status),
+ customer_id: value.customer_id,
+ shipping_address_id: value.shipping_address_id,
+ billing_address_id: value.billing_address_id,
+ return_url: value.return_url,
+ business_country: value.business_country,
+ business_label: value.business_label,
+ description: value.description,
+ statement_descriptor_name: value.statement_descriptor_name,
+ statement_descriptor_suffix: value.statement_descriptor_suffix,
+ order_details: value.order_details,
+ metadata: value.metadata,
+ payment_confirm_source: value.payment_confirm_source,
+ updated_by: value.updated_by,
+ session_expiry: value.session_expiry,
+ fingerprint_id: value.fingerprint_id,
+ request_external_three_ds_authentication: value
+ .request_external_three_ds_authentication,
+ frm_metadata: value.frm_metadata,
+ customer_details: value.customer_details,
+ billing_details: value.billing_details,
+ merchant_order_reference_id: value.merchant_order_reference_id,
+ shipping_details: value.shipping_details,
+ is_payment_processor_token_flow: value.is_payment_processor_token_flow,
+ ..Default::default()
+ },
+ PaymentIntentUpdate::PaymentCreateUpdate {
+ return_url,
+ status,
+ customer_id,
+ shipping_address_id,
+ billing_address_id,
+ customer_details,
+ updated_by,
+ } => Self {
+ return_url,
+ status,
+ customer_id,
+ shipping_address_id,
+ billing_address_id,
+ customer_details,
+ modified_at: Some(common_utils::date_time::now()),
+ updated_by,
+ ..Default::default()
+ },
+ PaymentIntentUpdate::PGStatusUpdate {
+ status,
+ updated_by,
+ incremental_authorization_allowed,
+ } => Self {
+ status: Some(status),
+ modified_at: Some(common_utils::date_time::now()),
+ updated_by,
+ incremental_authorization_allowed,
+ ..Default::default()
+ },
+ PaymentIntentUpdate::MerchantStatusUpdate {
+ status,
+ shipping_address_id,
+ billing_address_id,
+ updated_by,
+ } => Self {
+ status: Some(status),
+ shipping_address_id,
+ billing_address_id,
+ modified_at: Some(common_utils::date_time::now()),
+ updated_by,
+ ..Default::default()
+ },
+ PaymentIntentUpdate::ResponseUpdate {
+ // amount,
+ // currency,
+ status,
+ amount_captured,
+ fingerprint_id,
+ // customer_id,
+ return_url,
+ updated_by,
+ incremental_authorization_allowed,
+ } => Self {
+ // amount,
+ // currency: Some(currency),
+ status: Some(status),
+ amount_captured,
+ fingerprint_id,
+ // customer_id,
+ return_url,
+ modified_at: Some(common_utils::date_time::now()),
+ updated_by,
+ incremental_authorization_allowed,
+ ..Default::default()
+ },
+ PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {
+ active_attempt_id,
+ attempt_count,
+ updated_by,
+ } => Self {
+ active_attempt_id: Some(active_attempt_id),
+ attempt_count: Some(attempt_count),
+ updated_by,
+ ..Default::default()
+ },
+ PaymentIntentUpdate::StatusAndAttemptUpdate {
+ status,
+ active_attempt_id,
+ attempt_count,
+ updated_by,
+ } => Self {
+ status: Some(status),
+ active_attempt_id: Some(active_attempt_id),
+ attempt_count: Some(attempt_count),
+ updated_by,
+ ..Default::default()
+ },
+ PaymentIntentUpdate::ApproveUpdate {
+ status,
+ merchant_decision,
+ updated_by,
+ } => Self {
+ status: Some(status),
+ merchant_decision,
+ updated_by,
+ ..Default::default()
+ },
+ PaymentIntentUpdate::RejectUpdate {
+ status,
+ merchant_decision,
+ updated_by,
+ } => Self {
+ status: Some(status),
+ merchant_decision,
+ updated_by,
+ ..Default::default()
+ },
+ PaymentIntentUpdate::SurchargeApplicableUpdate {
+ surcharge_applicable,
+ updated_by,
+ } => Self {
+ surcharge_applicable: Some(surcharge_applicable),
+ updated_by,
+ ..Default::default()
+ },
+ PaymentIntentUpdate::IncrementalAuthorizationAmountUpdate { amount } => Self {
+ amount: Some(amount),
+ ..Default::default()
+ },
+ PaymentIntentUpdate::AuthorizationCountUpdate {
+ authorization_count,
+ } => Self {
+ authorization_count: Some(authorization_count),
+ ..Default::default()
+ },
+ PaymentIntentUpdate::CompleteAuthorizeUpdate {
+ shipping_address_id,
+ } => Self {
+ shipping_address_id,
+ ..Default::default()
+ },
+ PaymentIntentUpdate::ManualUpdate { status, updated_by } => Self {
+ status,
+ modified_at: Some(common_utils::date_time::now()),
+ updated_by,
+ ..Default::default()
+ },
+ PaymentIntentUpdate::SessionResponseUpdate {
+ tax_details,
+ shipping_address_id,
+ updated_by,
+ shipping_details,
+ } => Self {
+ tax_details: Some(tax_details),
+ shipping_address_id,
+ updated_by,
+ shipping_details,
+ ..Default::default()
+ },
+ }
+ }
+}
+
+use diesel_models::{
+ PaymentIntentUpdate as DieselPaymentIntentUpdate,
+ PaymentIntentUpdateFields as DieselPaymentIntentUpdateFields,
+};
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
+impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {
+ fn from(value: PaymentIntentUpdate) -> Self {
+ match value {
+ PaymentIntentUpdate::ResponseUpdate {
+ status,
+ amount_captured,
+ return_url,
+ updated_by,
+ } => Self::ResponseUpdate {
+ status,
+ amount_captured,
+ return_url,
+ updated_by,
+ },
+ PaymentIntentUpdate::MetadataUpdate {
+ metadata,
+ updated_by,
+ } => Self::MetadataUpdate {
+ metadata,
+ updated_by,
+ },
+ PaymentIntentUpdate::Update(value) => {
+ Self::Update(Box::new(DieselPaymentIntentUpdateFields {
+ amount: value.amount,
+ currency: value.currency,
+ setup_future_usage: value.setup_future_usage,
+ status: value.status,
+ customer_id: value.customer_id,
+ return_url: value.return_url,
+ description: value.description,
+ statement_descriptor_name: value.statement_descriptor_name,
+ order_details: value.order_details,
+ metadata: value.metadata,
+ payment_confirm_source: value.payment_confirm_source,
+ updated_by: value.updated_by,
+ session_expiry: value.session_expiry,
+ request_external_three_ds_authentication: value
+ .request_external_three_ds_authentication,
+ frm_metadata: value.frm_metadata,
+ customer_details: value.customer_details.map(Encryption::from),
+ billing_address: value.billing_address.map(Encryption::from),
+ shipping_address: value.shipping_address.map(Encryption::from),
+ merchant_order_reference_id: value.merchant_order_reference_id,
+ is_payment_processor_token_flow: value.is_payment_processor_token_flow,
+ }))
+ }
+ PaymentIntentUpdate::PaymentCreateUpdate {
+ return_url,
+ status,
+ customer_id,
+ shipping_address,
+ billing_address,
+ customer_details,
+ updated_by,
+ } => Self::PaymentCreateUpdate {
+ return_url,
+ status,
+ customer_id,
+ shipping_address: shipping_address.map(Encryption::from),
+ billing_address: billing_address.map(Encryption::from),
+ customer_details: customer_details.map(Encryption::from),
+ updated_by,
+ },
+ PaymentIntentUpdate::MerchantStatusUpdate {
+ status,
+ shipping_address,
+ billing_address,
+ updated_by,
+ } => Self::MerchantStatusUpdate {
+ status,
+ shipping_address: shipping_address.map(Encryption::from),
+ billing_address: billing_address.map(Encryption::from),
+ updated_by,
+ },
+ PaymentIntentUpdate::PGStatusUpdate { status, updated_by } => {
+ Self::PGStatusUpdate { status, updated_by }
+ }
+ PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {
+ active_attempt_id,
+ attempt_count,
+ updated_by,
+ } => Self::PaymentAttemptAndAttemptCountUpdate {
+ active_attempt_id,
+ attempt_count,
+ updated_by,
+ },
+ PaymentIntentUpdate::StatusAndAttemptUpdate {
+ status,
+ active_attempt_id,
+ attempt_count,
+ updated_by,
+ } => Self::StatusAndAttemptUpdate {
+ status,
+ active_attempt_id,
+ attempt_count,
+ updated_by,
+ },
+ PaymentIntentUpdate::ApproveUpdate {
+ status,
+ frm_merchant_decision,
+ updated_by,
+ } => Self::ApproveUpdate {
+ status,
+ frm_merchant_decision,
+ updated_by,
+ },
+ PaymentIntentUpdate::RejectUpdate {
+ status,
+ frm_merchant_decision,
+ updated_by,
+ } => Self::RejectUpdate {
+ status,
+ frm_merchant_decision,
+ updated_by,
+ },
+ PaymentIntentUpdate::SurchargeApplicableUpdate {
+ surcharge_applicable,
+ updated_by,
+ } => Self::SurchargeApplicableUpdate {
+ surcharge_applicable: Some(surcharge_applicable),
+ updated_by,
+ },
+ PaymentIntentUpdate::IncrementalAuthorizationAmountUpdate { amount } => {
+ Self::IncrementalAuthorizationAmountUpdate { amount }
+ }
+ PaymentIntentUpdate::AuthorizationCountUpdate {
+ authorization_count,
+ } => Self::AuthorizationCountUpdate {
+ authorization_count,
+ },
+ PaymentIntentUpdate::CompleteAuthorizeUpdate { shipping_address } => {
+ Self::CompleteAuthorizeUpdate {
+ shipping_address: shipping_address.map(Encryption::from),
+ }
+ }
+ PaymentIntentUpdate::ManualUpdate { status, updated_by } => {
+ Self::ManualUpdate { status, updated_by }
+ }
+ }
+ }
+}
+
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
+impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {
+ fn from(value: PaymentIntentUpdate) -> Self {
+ match value {
+ PaymentIntentUpdate::ResponseUpdate {
+ status,
+ amount_captured,
+ fingerprint_id,
+ return_url,
+ updated_by,
+ incremental_authorization_allowed,
+ } => Self::ResponseUpdate {
+ status,
+ amount_captured,
+ fingerprint_id,
+ return_url,
+ updated_by,
+ incremental_authorization_allowed,
+ },
PaymentIntentUpdate::MetadataUpdate {
metadata,
updated_by,
@@ -682,10 +1222,77 @@ impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {
}
}
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInternal {
fn from(value: PaymentIntentUpdateInternal) -> Self {
let modified_at = common_utils::date_time::now();
+ let PaymentIntentUpdateInternal {
+ amount,
+ currency,
+ status,
+ amount_captured,
+ customer_id,
+ return_url,
+ setup_future_usage,
+ off_session,
+ metadata,
+ modified_at: _,
+ active_attempt_id,
+ description,
+ statement_descriptor_name,
+ order_details,
+ attempt_count,
+ frm_merchant_decision,
+ payment_confirm_source,
+ updated_by,
+ surcharge_applicable,
+ authorization_count,
+ session_expiry,
+ request_external_three_ds_authentication,
+ frm_metadata,
+ customer_details,
+ billing_address,
+ merchant_order_reference_id,
+ shipping_address,
+ is_payment_processor_token_flow,
+ } = value;
+ Self {
+ amount,
+ currency,
+ status,
+ amount_captured,
+ customer_id,
+ return_url,
+ setup_future_usage,
+ off_session,
+ metadata,
+ modified_at,
+ active_attempt_id,
+ description,
+ statement_descriptor_name,
+ order_details,
+ attempt_count,
+ frm_merchant_decision,
+ payment_confirm_source,
+ updated_by,
+ surcharge_applicable,
+ authorization_count,
+ session_expiry,
+ request_external_three_ds_authentication,
+ frm_metadata,
+ customer_details: customer_details.map(Encryption::from),
+ billing_address: billing_address.map(Encryption::from),
+ merchant_order_reference_id,
+ shipping_address: shipping_address.map(Encryption::from),
+ is_payment_processor_token_flow,
+ }
+ }
+}
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
+impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInternal {
+ fn from(value: PaymentIntentUpdateInternal) -> Self {
+ let modified_at = common_utils::date_time::now();
let PaymentIntentUpdateInternal {
amount,
currency,
@@ -724,7 +1331,6 @@ impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInt
is_payment_processor_token_flow,
tax_details,
} = value;
-
Self {
amount,
currency,
diff --git a/crates/router/src/bin/scheduler.rs b/crates/router/src/bin/scheduler.rs
index e2da76d51d..346d36156e 100644
--- a/crates/router/src/bin/scheduler.rs
+++ b/crates/router/src/bin/scheduler.rs
@@ -251,6 +251,7 @@ pub async fn deep_health_check_func(
#[derive(Debug, Copy, Clone)]
pub struct WorkflowRunner;
+#[cfg(feature = "v1")]
#[async_trait::async_trait]
impl ProcessTrackerWorkflows<routes::SessionState> for WorkflowRunner {
async fn trigger_workflow<'a>(
@@ -358,6 +359,18 @@ impl ProcessTrackerWorkflows<routes::SessionState> for WorkflowRunner {
}
}
+#[cfg(feature = "v2")]
+#[async_trait::async_trait]
+impl ProcessTrackerWorkflows<routes::SessionState> for WorkflowRunner {
+ async fn trigger_workflow<'a>(
+ &'a self,
+ _state: &'a routes::SessionState,
+ _process: storage::ProcessTracker,
+ ) -> CustomResult<(), ProcessTrackerError> {
+ todo!()
+ }
+}
+
async fn start_scheduler(
state: &routes::AppState,
scheduler_flow: scheduler::SchedulerFlow,
diff --git a/crates/router/src/core.rs b/crates/router/src/core.rs
index 39e707cff7..e2ccca4629 100644
--- a/crates/router/src/core.rs
+++ b/crates/router/src/core.rs
@@ -1,8 +1,10 @@
pub mod admin;
pub mod api_keys;
pub mod api_locking;
+#[cfg(feature = "v1")]
pub mod apple_pay_certificates_migration;
pub mod authentication;
+#[cfg(feature = "v1")]
pub mod blocklist;
pub mod cache;
pub mod cards_info;
@@ -21,6 +23,7 @@ pub mod files;
pub mod fraud_check;
pub mod gsm;
pub mod health_check;
+#[cfg(feature = "v1")]
pub mod locker_migration;
pub mod mandate;
pub mod metrics;
@@ -35,6 +38,7 @@ pub mod pm_auth;
pub mod poll;
#[cfg(feature = "recon")]
pub mod recon;
+#[cfg(feature = "v1")]
pub mod refunds;
pub mod routing;
pub mod surcharge_decision_config;
@@ -47,4 +51,5 @@ pub mod utils;
pub mod verification;
#[cfg(feature = "olap")]
pub mod verify_connector;
+#[cfg(feature = "v1")]
pub mod webhooks;
diff --git a/crates/router/src/core/disputes.rs b/crates/router/src/core/disputes.rs
index 24c6c0f8be..8835f5f95a 100644
--- a/crates/router/src/core/disputes.rs
+++ b/crates/router/src/core/disputes.rs
@@ -61,6 +61,19 @@ pub async fn retrieve_disputes_list(
Ok(services::ApplicationResponse::Json(disputes_list))
}
+#[cfg(feature = "v2")]
+#[instrument(skip(state))]
+pub async fn accept_dispute(
+ state: SessionState,
+ merchant_account: domain::MerchantAccount,
+ profile_id: Option<common_utils::id_type::ProfileId>,
+ key_store: domain::MerchantKeyStore,
+ req: disputes::DisputeId,
+) -> RouterResponse<dispute_models::DisputeResponse> {
+ todo!()
+}
+
+#[cfg(feature = "v1")]
#[instrument(skip(state))]
pub async fn accept_dispute(
state: SessionState,
@@ -92,6 +105,7 @@ pub async fn accept_dispute(
})
},
)?;
+
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
&(&state).into(),
@@ -102,6 +116,7 @@ pub async fn accept_dispute(
)
.await
.change_context(errors::ApiErrorResponse::PaymentNotFound)?;
+
let payment_attempt = db
.find_payment_attempt_by_attempt_id_merchant_id(
&dispute.attempt_id,
@@ -165,6 +180,19 @@ pub async fn accept_dispute(
Ok(services::ApplicationResponse::Json(dispute_response))
}
+#[cfg(feature = "v2")]
+#[instrument(skip(state))]
+pub async fn submit_evidence(
+ state: SessionState,
+ merchant_account: domain::MerchantAccount,
+ profile_id: Option<common_utils::id_type::ProfileId>,
+ key_store: domain::MerchantKeyStore,
+ req: dispute_models::SubmitEvidenceRequest,
+) -> RouterResponse<dispute_models::DisputeResponse> {
+ todo!()
+}
+
+#[cfg(feature = "v1")]
#[instrument(skip(state))]
pub async fn submit_evidence(
state: SessionState,
@@ -208,6 +236,7 @@ pub async fn submit_evidence(
&dispute,
)
.await?;
+
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
&(&state).into(),
@@ -218,6 +247,7 @@ pub async fn submit_evidence(
)
.await
.change_context(errors::ApiErrorResponse::PaymentNotFound)?;
+
let payment_attempt = db
.find_payment_attempt_by_attempt_id_merchant_id(
&dispute.attempt_id,
diff --git a/crates/router/src/core/files/helpers.rs b/crates/router/src/core/files/helpers.rs
index bd4fc74975..22dbfd93f5 100644
--- a/crates/router/src/core/files/helpers.rs
+++ b/crates/router/src/core/files/helpers.rs
@@ -234,6 +234,27 @@ pub async fn retrieve_file_and_provider_file_id_from_file_id(
}
}
+#[cfg(feature = "v2")]
+//Upload file to connector if it supports / store it in S3 and return file_upload_provider, provider_file_id accordingly
+pub async fn upload_and_get_provider_provider_file_id_profile_id(
+ state: &SessionState,
+ merchant_account: &domain::MerchantAccount,
+ key_store: &domain::MerchantKeyStore,
+ create_file_request: &api::CreateFileRequest,
+ file_key: String,
+) -> CustomResult<
+ (
+ String,
+ api_models::enums::FileUploadProvider,
+ Option<common_utils::id_type::ProfileId>,
+ Option<common_utils::id_type::MerchantConnectorAccountId>,
+ ),
+ errors::ApiErrorResponse,
+> {
+ todo!()
+}
+
+#[cfg(feature = "v1")]
//Upload file to connector if it supports / store it in S3 and return file_upload_provider, provider_file_id accordingly
pub async fn upload_and_get_provider_provider_file_id_profile_id(
state: &SessionState,
@@ -279,6 +300,7 @@ pub async fn upload_and_get_provider_provider_file_id_profile_id(
)
.await
.change_context(errors::ApiErrorResponse::PaymentNotFound)?;
+
let payment_attempt = state
.store
.find_payment_attempt_by_attempt_id_merchant_id(
diff --git a/crates/router/src/core/fraud_check.rs b/crates/router/src/core/fraud_check.rs
index 4b53a20abd..90c36ba9aa 100644
--- a/crates/router/src/core/fraud_check.rs
+++ b/crates/router/src/core/fraud_check.rs
@@ -724,6 +724,7 @@ impl From<PaymentToFrmData> for PaymentDetails {
}
}
+#[cfg(feature = "v1")]
#[instrument(skip_all)]
pub async fn frm_fulfillment_core(
state: SessionState,
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.rs
index 99352339e6..bfb54c8f4e 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
@@ -99,7 +99,7 @@ impl GetTracker<PaymentToFrmData> for FraudCheckPost {
.ok();
let existing_fraud_check = db
.find_fraud_check_by_payment_id_if_present(
- payment_data.payment_intent.payment_id.clone(),
+ payment_data.payment_intent.get_id().to_owned(),
payment_data.merchant_account.get_id().clone(),
)
.await
@@ -109,7 +109,7 @@ impl GetTracker<PaymentToFrmData> for FraudCheckPost {
_ => {
db.insert_fraud_check_response(FraudCheckNew {
frm_id: utils::generate_id(consts::ID_LENGTH, "frm"),
- payment_id: payment_data.payment_intent.payment_id.clone(),
+ payment_id: payment_data.payment_intent.get_id().to_owned(),
merchant_id: payment_data.merchant_account.get_id().clone(),
attempt_id: payment_data.payment_attempt.attempt_id.clone(),
created_at: common_utils::date_time::now(),
@@ -202,6 +202,25 @@ where
}))
}
+ #[cfg(feature = "v2")]
+ #[instrument(skip_all)]
+ async fn execute_post_tasks(
+ &self,
+ _state: &SessionState,
+ _req_state: ReqState,
+ _frm_data: &mut FrmData,
+ _merchant_account: &domain::MerchantAccount,
+ _frm_configs: FrmConfigsObject,
+ _frm_suggestion: &mut Option<FrmSuggestion>,
+ _key_store: domain::MerchantKeyStore,
+ _payment_data: &mut D,
+ _customer: &Option<domain::Customer>,
+ _should_continue_capture: &mut bool,
+ ) -> RouterResult<Option<FrmData>> {
+ todo!()
+ }
+
+ #[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn execute_post_tasks(
&self,
@@ -225,7 +244,7 @@ where
*frm_suggestion = Some(FrmSuggestion::FrmCancelTransaction);
let cancel_req = api_models::payments::PaymentsCancelRequest {
- payment_id: frm_data.payment_intent.payment_id.clone(),
+ payment_id: frm_data.payment_intent.get_id().to_owned(),
cancellation_reason: frm_data.fraud_check.frm_error.clone(),
merchant_connector_details: None,
};
@@ -278,7 +297,7 @@ where
)
{
let capture_request = api_models::payments::PaymentsCaptureRequest {
- payment_id: frm_data.payment_intent.payment_id.clone(),
+ payment_id: frm_data.payment_intent.get_id().to_owned(),
merchant_id: None,
amount_to_capture: None,
refund_uncaptured_amount: None,
@@ -362,6 +381,20 @@ where
+ Sync
+ Clone,
{
+ #[cfg(feature = "v2")]
+ async fn update_tracker<'b>(
+ &'b self,
+ state: &SessionState,
+ key_store: &domain::MerchantKeyStore,
+ mut frm_data: FrmData,
+ payment_data: &mut D,
+ frm_suggestion: Option<FrmSuggestion>,
+ frm_router_data: FrmRouterData,
+ ) -> RouterResult<FrmData> {
+ todo!()
+ }
+
+ #[cfg(feature = "v1")]
async fn update_tracker<'b>(
&'b self,
state: &SessionState,
diff --git a/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs b/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs
index fe1dd86e8c..666028e5df 100644
--- a/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs
+++ b/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs
@@ -86,7 +86,7 @@ impl GetTracker<PaymentToFrmData> for FraudCheckPre {
let existing_fraud_check = db
.find_fraud_check_by_payment_id_if_present(
- payment_data.payment_intent.payment_id.clone(),
+ payment_data.payment_intent.get_id().to_owned(),
payment_data.merchant_account.get_id().clone(),
)
.await
@@ -97,7 +97,7 @@ impl GetTracker<PaymentToFrmData> for FraudCheckPre {
_ => {
db.insert_fraud_check_response(FraudCheckNew {
frm_id: Uuid::new_v4().simple().to_string(),
- payment_id: payment_data.payment_intent.payment_id.clone(),
+ payment_id: payment_data.payment_intent.get_id().to_owned(),
merchant_id: payment_data.merchant_account.get_id().clone(),
attempt_id: payment_data.payment_attempt.attempt_id.clone(),
created_at: common_utils::date_time::now(),
diff --git a/crates/router/src/core/mandate.rs b/crates/router/src/core/mandate.rs
index 9cc252ffd0..b570797924 100644
--- a/crates/router/src/core/mandate.rs
+++ b/crates/router/src/core/mandate.rs
@@ -58,6 +58,7 @@ pub async fn get_mandate(
))
}
+#[cfg(feature = "v1")]
#[instrument(skip(state))]
pub async fn revoke_mandate(
state: SessionState,
diff --git a/crates/router/src/core/mandate/helpers.rs b/crates/router/src/core/mandate/helpers.rs
index 52afa6e0e5..28ee784f6f 100644
--- a/crates/router/src/core/mandate/helpers.rs
+++ b/crates/router/src/core/mandate/helpers.rs
@@ -11,6 +11,7 @@ use crate::{
types::{api, domain},
};
+#[cfg(feature = "v1")]
pub async fn get_profile_id_for_mandate(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rs
index 7919b991d8..0065e5a32b 100644
--- a/crates/router/src/core/payment_link.rs
+++ b/crates/router/src/core/payment_link.rs
@@ -63,6 +63,19 @@ pub async fn retrieve_payment_link(
Ok(services::ApplicationResponse::Json(response))
}
+#[cfg(feature = "v2")]
+pub async fn form_payment_link_data(
+ state: &SessionState,
+ merchant_account: domain::MerchantAccount,
+ key_store: domain::MerchantKeyStore,
+ merchant_id: common_utils::id_type::MerchantId,
+ payment_id: common_utils::id_type::PaymentId,
+ locale: Option<String>,
+) -> RouterResult<(PaymentLink, PaymentLinkData, PaymentLinkConfig)> {
+ todo!()
+}
+
+#[cfg(feature = "v1")]
pub async fn form_payment_link_data(
state: &SessionState,
merchant_account: domain::MerchantAccount,
@@ -642,6 +655,19 @@ fn check_payment_link_invalid_conditions(
not_allowed_statuses.contains(intent_status)
}
+#[cfg(feature = "v2")]
+pub async fn get_payment_link_status(
+ _state: SessionState,
+ _merchant_account: domain::MerchantAccount,
+ _key_store: domain::MerchantKeyStore,
+ _merchant_id: common_utils::id_type::MerchantId,
+ _payment_id: common_utils::id_type::PaymentId,
+ _request_headers: &header::HeaderMap,
+) -> RouterResponse<services::PaymentLinkFormData> {
+ todo!()
+}
+
+#[cfg(feature = "v1")]
pub async fn get_payment_link_status(
state: SessionState,
merchant_account: domain::MerchantAccount,
diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs
index 88624cfd09..0061eb4fbc 100644
--- a/crates/router/src/core/payment_methods.rs
+++ b/crates/router/src/core/payment_methods.rs
@@ -34,13 +34,15 @@ use masking::PeekInterface;
use router_env::{instrument, tracing};
use time::Duration;
-use super::errors::{RouterResponse, StorageErrorExt};
+use super::{
+ errors::{RouterResponse, StorageErrorExt},
+ pm_auth,
+};
use crate::{
consts,
core::{
errors::{self, RouterResult},
payments::helpers,
- pm_auth as core_pm_auth,
},
routes::{app::StorageInterface, SessionState},
services,
@@ -450,6 +452,21 @@ pub async fn add_payment_method_status_update_task(
Ok(())
}
+#[cfg(feature = "v2")]
+#[instrument(skip_all)]
+pub async fn retrieve_payment_method_with_token(
+ _state: &SessionState,
+ _merchant_key_store: &domain::MerchantKeyStore,
+ _token_data: &storage::PaymentTokenData,
+ _payment_intent: &PaymentIntent,
+ _card_token_data: Option<&domain::CardToken>,
+ _customer: &Option<domain::Customer>,
+ _storage_scheme: common_enums::enums::MerchantStorageScheme,
+) -> RouterResult<storage::PaymentMethodDataWithId> {
+ todo!()
+}
+
+#[cfg(feature = "v1")]
#[instrument(skip_all)]
pub async fn retrieve_payment_method_with_token(
state: &SessionState,
@@ -562,7 +579,7 @@ pub async fn retrieve_payment_method_with_token(
}
storage::PaymentTokenData::AuthBankDebit(auth_token) => {
- core_pm_auth::retrieve_payment_method_from_auth_service(
+ pm_auth::retrieve_payment_method_from_auth_service(
state,
merchant_key_store,
auth_token,
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 8ab3bf5014..ccd64f066d 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -4658,7 +4658,7 @@ async fn perform_surcharge_ops(
state
.store
.find_payment_attempt_by_payment_id_merchant_id_attempt_id(
- &payment_intent.payment_id,
+ payment_intent.get_id(),
merchant_account.get_id(),
&payment_intent.active_attempt.get_id(),
merchant_account.storage_scheme,
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index bf52bad4ed..3ff5e649f2 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -52,16 +52,16 @@ use scheduler::utils as pt_utils;
use strum::IntoEnumIterator;
use time;
+#[cfg(feature = "v1")]
pub use self::operations::{
PaymentApprove, PaymentCancel, PaymentCapture, PaymentConfirm, PaymentCreate,
- PaymentIncrementalAuthorization, PaymentReject, PaymentResponse, PaymentSession,
- PaymentSessionUpdate, PaymentStatus, PaymentUpdate,
+ PaymentIncrementalAuthorization, PaymentReject, PaymentSession, PaymentSessionUpdate,
+ PaymentStatus, PaymentUpdate,
};
use self::{
conditional_configs::perform_decision_management,
flows::{ConstructFlowSpecificData, Feature},
- helpers::get_key_params_for_surcharge_details,
- operations::{payment_complete_authorize, BoxedOperation, Operation},
+ operations::{BoxedOperation, Operation, PaymentResponse},
routing::{self as self_routing, SessionFlowRoutingInput},
};
use super::{
@@ -535,6 +535,7 @@ where
#[cfg(feature = "frm")]
if let Some(fraud_info) = &mut frm_info {
+ #[cfg(feature = "v1")]
Box::pin(frm_core::post_payment_frm_core(
state,
req_state,
@@ -613,7 +614,7 @@ where
.to_domain()?
.store_extended_card_info_temporarily(
state,
- &payment_data.get_payment_intent().payment_id,
+ payment_data.get_payment_intent().get_id(),
&business_profile,
payment_data.get_payment_method_data(),
)
@@ -729,7 +730,7 @@ where
let raw_card_key = payment_data
.payment_method_data
.as_ref()
- .and_then(get_key_params_for_surcharge_details)
+ .and_then(helpers::get_key_params_for_surcharge_details)
.map(|(payment_method, payment_method_type, card_network)| {
types::SurchargeKey::PaymentMethodData(
payment_method,
@@ -1030,6 +1031,7 @@ pub trait PaymentRedirectFlow: Sync {
#[derive(Clone, Debug)]
pub struct PaymentRedirectCompleteAuthorize;
+#[cfg(feature = "v1")]
#[async_trait::async_trait]
impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize {
type PaymentFlowResponse = router_types::RedirectPaymentFlowResponse;
@@ -1073,7 +1075,7 @@ impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize {
merchant_account,
None,
merchant_key_store.clone(),
- payment_complete_authorize::CompleteAuthorize,
+ operations::payment_complete_authorize::CompleteAuthorize,
payment_confirm_req,
services::api::AuthFlow::Merchant,
connector_action,
@@ -1167,6 +1169,7 @@ impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize {
#[derive(Clone, Debug)]
pub struct PaymentRedirectSync;
+#[cfg(feature = "v1")]
#[async_trait::async_trait]
impl PaymentRedirectFlow for PaymentRedirectSync {
type PaymentFlowResponse = router_types::RedirectPaymentFlowResponse;
@@ -1263,6 +1266,7 @@ impl PaymentRedirectFlow for PaymentRedirectSync {
#[derive(Clone, Debug)]
pub struct PaymentAuthenticateCompleteAuthorize;
+#[cfg(feature = "v1")]
#[async_trait::async_trait]
impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize {
type PaymentFlowResponse = router_types::AuthenticatePaymentFlowResponse;
@@ -2043,40 +2047,49 @@ where
merchant_connector_account.get_mca_id(),
)?;
- let connector_label = utils::get_connector_label(
- payment_data.get_payment_intent().business_country,
- payment_data.get_payment_intent().business_label.as_ref(),
- payment_data
- .get_payment_attempt()
- .business_sub_label
- .as_ref(),
- &connector_name,
- );
+ #[cfg(feature = "v1")]
+ let label = {
+ let connector_label = utils::get_connector_label(
+ payment_data.get_payment_intent().business_country,
+ payment_data.get_payment_intent().business_label.as_ref(),
+ payment_data
+ .get_payment_attempt()
+ .business_sub_label
+ .as_ref(),
+ &connector_name,
+ );
- let connector_label = if let Some(connector_label) = merchant_connector_account
- .get_mca_id()
- .map(|mca_id| mca_id.get_string_repr().to_string())
- .or(connector_label)
- {
- connector_label
- } else {
- let profile_id = payment_data
- .get_payment_intent()
- .profile_id
- .as_ref()
- .get_required_value("profile_id")
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("profile_id is not set in payment_intent")?;
+ if let Some(connector_label) = merchant_connector_account
+ .get_mca_id()
+ .map(|mca_id| mca_id.get_string_repr().to_string())
+ .or(connector_label)
+ {
+ connector_label
+ } else {
+ let profile_id = payment_data
+ .get_payment_intent()
+ .profile_id
+ .as_ref()
+ .get_required_value("profile_id")
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("profile_id is not set in payment_intent")?;
- format!("{connector_name}_{}", profile_id.get_string_repr())
+ format!("{connector_name}_{}", profile_id.get_string_repr())
+ }
+ };
+
+ #[cfg(feature = "v2")]
+ let label = {
+ merchant_connector_account
+ .get_mca_id()
+ .get_required_value("merchant_connector_account_id")?
+ .get_string_repr()
+ .to_owned()
};
let (should_call_connector, existing_connector_customer_id) =
customers::should_call_connector_create_customer(
- state,
- &connector,
- customer,
- &connector_label,
+ state, &connector, customer, &label,
);
if should_call_connector {
@@ -2098,7 +2111,7 @@ where
.await?;
let customer_update = customers::update_connector_customer_in_customers(
- &connector_label,
+ &label,
customer.as_ref(),
&connector_customer_id,
)
@@ -2872,6 +2885,7 @@ impl CustomerDetailsExt for CustomerDetails {
}
}
+#[cfg(feature = "v1")]
pub fn if_not_create_change_operation<'a, Op, F>(
status: storage_enums::IntentStatus,
confirm: Option<bool>,
@@ -2896,6 +2910,7 @@ where
}
}
+#[cfg(feature = "v1")]
pub fn is_confirm<'a, F: Clone + Send, R, Op>(
operation: &'a Op,
confirm: Option<bool>,
@@ -2977,7 +2992,7 @@ pub fn is_operation_complete_authorize<Op: Debug>(operation: &Op) -> bool {
matches!(format!("{operation:?}").as_str(), "CompleteAuthorize")
}
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn list_payments(
state: SessionState,
merchant: domain::MerchantAccount,
@@ -3050,7 +3065,8 @@ pub async fn list_payments(
},
))
}
-#[cfg(feature = "olap")]
+
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn apply_filters_on_payments(
state: SessionState,
merchant: domain::MerchantAccount,
@@ -3108,7 +3124,7 @@ pub async fn apply_filters_on_payments(
))
}
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn get_filters_for_payments(
state: SessionState,
merchant: domain::MerchantAccount,
@@ -3149,7 +3165,7 @@ pub async fn get_filters_for_payments(
))
}
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn get_payment_filters(
state: SessionState,
merchant: domain::MerchantAccount,
@@ -3229,7 +3245,7 @@ pub async fn get_payment_filters(
))
}
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn get_aggregates_for_payments(
state: SessionState,
merchant: domain::MerchantAccount,
@@ -4541,7 +4557,7 @@ pub async fn get_extended_card_info(
))
}
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn payments_manual_update(
state: SessionState,
req: api_models::payments::PaymentsManualUpdateRequest,
@@ -4586,6 +4602,7 @@ pub async fn payments_manual_update(
.attach_printable(
"Error while fetching the payment_attempt by payment_id, merchant_id and attempt_id",
)?;
+
let payment_intent = state
.store
.find_payment_intent_by_payment_id_merchant_id(
@@ -4598,6 +4615,7 @@ pub async fn payments_manual_update(
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)
.attach_printable("Error while fetching the payment_intent by payment_id, merchant_id")?;
+
let option_gsm = if let Some(((code, message), connector_name)) = error_code
.as_ref()
.zip(error_message.as_ref())
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 7636801663..5f9c1a7be0 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -688,6 +688,7 @@ pub async fn get_token_pm_type_mandate_details(
})
}
+#[cfg(feature = "v1")]
pub async fn get_token_for_recurring_mandate(
state: &SessionState,
req: &api::PaymentsRequest,
@@ -1147,7 +1148,7 @@ pub fn create_startpay_url(
format!(
"{}/payments/redirect/{}/{}/{}",
base_url,
- payment_intent.payment_id.get_string_repr(),
+ payment_intent.get_id().get_string_repr(),
payment_intent.merchant_id.get_string_repr(),
payment_attempt.attempt_id
)
@@ -2445,7 +2446,7 @@ where
Some(func(option1?, option2?))
}
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub(super) async fn filter_by_constraints(
state: &SessionState,
constraints: &PaymentIntentFetchConstraints,
@@ -2889,6 +2890,7 @@ pub async fn verify_payment_intent_time_and_client_secret(
},
)?;
+ #[cfg(feature = "v1")]
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
&state.into(),
@@ -2900,6 +2902,17 @@ pub async fn verify_payment_intent_time_and_client_secret(
.await
.change_context(errors::ApiErrorResponse::PaymentNotFound)?;
+ #[cfg(feature = "v2")]
+ let payment_intent = db
+ .find_payment_intent_by_id(
+ &state.into(),
+ &payment_id,
+ key_store,
+ merchant_account.storage_scheme,
+ )
+ .await
+ .change_context(errors::ApiErrorResponse::PaymentNotFound)?;
+
authenticate_client_secret(Some(&cs), &payment_intent)?;
Ok(payment_intent)
})
@@ -2948,6 +2961,7 @@ pub(crate) fn get_payment_id_from_client_secret(cs: &str) -> RouterResult<String
Ok(payment_id.to_string())
}
+#[cfg(feature = "v1")]
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
@@ -3715,7 +3729,7 @@ impl AttemptType {
)
.await
.to_duplicate_response(errors::ApiErrorResponse::DuplicatePayment {
- payment_id: fetched_payment_intent.payment_id.to_owned(),
+ payment_id: fetched_payment_intent.get_id().to_owned(),
})?;
let updated_payment_intent = db
@@ -3743,7 +3757,7 @@ impl AttemptType {
logger::info!(
"manual_retry payment for {:?} with attempt_id {}",
- updated_payment_intent.payment_id,
+ updated_payment_intent.get_id(),
new_payment_attempt.attempt_id
);
diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rs
index 841be780e6..e469207591 100644
--- a/crates/router/src/core/payments/operations.rs
+++ b/crates/router/src/core/payments/operations.rs
@@ -1,16 +1,29 @@
+#[cfg(feature = "v1")]
pub mod payment_approve;
+#[cfg(feature = "v1")]
pub mod payment_cancel;
+#[cfg(feature = "v1")]
pub mod payment_capture;
+#[cfg(feature = "v1")]
pub mod payment_complete_authorize;
+#[cfg(feature = "v1")]
pub mod payment_confirm;
+#[cfg(feature = "v1")]
pub mod payment_create;
+#[cfg(feature = "v1")]
pub mod payment_reject;
pub mod payment_response;
+#[cfg(feature = "v1")]
pub mod payment_session;
+#[cfg(feature = "v1")]
pub mod payment_start;
+#[cfg(feature = "v1")]
pub mod payment_status;
+#[cfg(feature = "v1")]
pub mod payment_update;
+#[cfg(feature = "v1")]
pub mod payments_incremental_authorization;
+#[cfg(feature = "v1")]
pub mod tax_calculation;
use api_models::enums::FrmSuggestion;
@@ -18,11 +31,12 @@ use async_trait::async_trait;
use error_stack::{report, ResultExt};
use router_env::{instrument, tracing};
+pub use self::payment_response::PaymentResponse;
+#[cfg(feature = "v1")]
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
- payment_create::PaymentCreate, payment_reject::PaymentReject,
- payment_response::PaymentResponse, payment_session::PaymentSession,
+ payment_create::PaymentCreate, payment_reject::PaymentReject, payment_session::PaymentSession,
payment_start::PaymentStart, payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs
index 548e9b1be8..5471ae355f 100644
--- a/crates/router/src/core/payments/operations/payment_response.rs
+++ b/crates/router/src/core/payments/operations/payment_response.rs
@@ -181,7 +181,7 @@ impl<F: Send + Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsAuthor
payment_method_id.clone(),
merchant_connector_id.clone(),
merchant_account.storage_scheme,
- &payment_data.payment_intent.payment_id,
+ payment_data.payment_intent.get_id(),
)
.await?;
payment_data.payment_attempt.payment_method_id = payment_method_id;
@@ -394,7 +394,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsIncrementalAu
.store
.find_all_authorizations_by_merchant_id_payment_id(
&router_data.merchant_id,
- &payment_data.payment_intent.payment_id,
+ payment_data.payment_intent.get_id(),
)
.await
.to_not_found_response(errors::ApiErrorResponse::InternalServerError)
@@ -782,7 +782,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SetupMandateRequestDa
payment_method_id.clone(),
merchant_connector_id.clone(),
merchant_account.storage_scheme,
- &payment_data.payment_intent.payment_id,
+ payment_data.payment_intent.get_id(),
)
.await?;
payment_data.payment_attempt.payment_method_id = payment_method_id;
@@ -846,6 +846,21 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::CompleteAuthorizeData
}
}
+#[cfg(feature = "v2")]
+#[instrument(skip_all)]
+async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
+ state: &SessionState,
+ _payment_id: &api::PaymentIdType,
+ mut payment_data: PaymentData<F>,
+ router_data: types::RouterData<F, T, types::PaymentsResponseData>,
+ key_store: &domain::MerchantKeyStore,
+ storage_scheme: enums::MerchantStorageScheme,
+ locale: &Option<String>,
+) -> RouterResult<PaymentData<F>> {
+ todo!()
+}
+
+#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
state: &SessionState,
diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rs
index a96fb08e23..75c0fb6d77 100644
--- a/crates/router/src/core/payments/retry.rs
+++ b/crates/router/src/core/payments/retry.rs
@@ -472,7 +472,7 @@ where
.insert_payment_attempt(new_payment_attempt, storage_scheme)
.await
.to_duplicate_response(errors::ApiErrorResponse::DuplicatePayment {
- payment_id: payment_data.get_payment_intent().payment_id.clone(),
+ payment_id: payment_data.get_payment_intent().get_id().to_owned(),
})?;
// update payment_attempt, connector_response and payment_intent in payment_data
diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rs
index 343e2d3a6c..7e703967a5 100644
--- a/crates/router/src/core/payments/routing.rs
+++ b/crates/router/src/core/payments/routing.rs
@@ -158,6 +158,14 @@ pub fn make_dsl_input_for_payouts(
})
}
+#[cfg(feature = "v2")]
+pub fn make_dsl_input(
+ payments_dsl_input: &routing::PaymentsDslInput<'_>,
+) -> RoutingResult<dsl_inputs::BackendInput> {
+ todo!()
+}
+
+#[cfg(feature = "v1")]
pub fn make_dsl_input(
payments_dsl_input: &routing::PaymentsDslInput<'_>,
) -> RoutingResult<dsl_inputs::BackendInput> {
@@ -849,6 +857,7 @@ pub async fn perform_session_flow_routing(
card_network: None,
};
+ #[cfg(feature = "v1")]
let payment_input = dsl_inputs::PaymentInput {
amount: session_input.payment_intent.amount,
currency: session_input
@@ -875,6 +884,30 @@ pub async fn perform_session_flow_routing(
setup_future_usage: session_input.payment_intent.setup_future_usage,
};
+ #[cfg(feature = "v2")]
+ let payment_input = dsl_inputs::PaymentInput {
+ amount: session_input.payment_intent.amount,
+ currency: session_input
+ .payment_intent
+ .currency
+ .get_required_value("Currency")
+ .change_context(errors::RoutingError::DslMissingRequiredField {
+ field_name: "currency".to_string(),
+ })?,
+ authentication_type: session_input.payment_attempt.authentication_type,
+ card_bin: None,
+ capture_method: session_input
+ .payment_attempt
+ .capture_method
+ .and_then(|cm| cm.foreign_into()),
+ business_country: None,
+ business_label: None,
+ billing_country: session_input
+ .country
+ .map(storage_enums::Country::from_alpha2),
+ setup_future_usage: session_input.payment_intent.setup_future_usage,
+ };
+
let metadata = session_input
.payment_intent
.metadata
@@ -1119,6 +1152,17 @@ async fn perform_session_routing_for_pm_type(
Ok(Some(final_selection))
}
}
+
+#[cfg(feature = "v2")]
+pub fn make_dsl_input_for_surcharge(
+ payment_attempt: &oss_storage::PaymentAttempt,
+ payment_intent: &oss_storage::PaymentIntent,
+ billing_address: Option<Address>,
+) -> RoutingResult<dsl_inputs::BackendInput> {
+ todo!()
+}
+
+#[cfg(feature = "v1")]
pub fn make_dsl_input_for_surcharge(
payment_attempt: &oss_storage::PaymentAttempt,
payment_intent: &oss_storage::PaymentIntent,
@@ -1129,6 +1173,7 @@ pub fn make_dsl_input_for_surcharge(
mandate_type: None,
payment_type: None,
};
+
let payment_input = dsl_inputs::PaymentInput {
amount: payment_attempt.amount,
// currency is always populated in payment_attempt during payment create
@@ -1151,6 +1196,7 @@ pub fn make_dsl_input_for_surcharge(
business_label: payment_intent.business_label.clone(),
setup_future_usage: payment_intent.setup_future_usage,
};
+
let metadata = payment_intent
.metadata
.clone()
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 36961f3375..8537063279 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -1282,6 +1282,7 @@ pub fn wait_screen_next_steps_check(
Ok(display_info_with_timer_instructions)
}
+#[cfg(feature = "v1")]
impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::PaymentsResponse {
fn foreign_from((pi, pa): (storage::PaymentIntent, storage::PaymentAttempt)) -> Self {
Self {
@@ -1993,6 +1994,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsSessionD
}
}
+#[cfg(feature = "v1")]
impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequestData {
type Error = error_stack::Report<errors::ApiErrorResponse>;
@@ -2058,6 +2060,15 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
}
}
+#[cfg(feature = "v2")]
+impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequestData {
+ type Error = error_stack::Report<errors::ApiErrorResponse>;
+
+ fn try_from(additional_data: PaymentAdditionalData<'_, F>) -> Result<Self, Self::Error> {
+ todo!()
+ }
+}
+
impl ForeignTryFrom<types::CaptureSyncResponse> for storage::CaptureUpdate {
type Error = error_stack::Report<errors::ApiErrorResponse>;
@@ -2100,6 +2111,7 @@ impl ForeignTryFrom<types::CaptureSyncResponse> for storage::CaptureUpdate {
}
}
+#[cfg(feature = "v1")]
impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthorizeData {
type Error = error_stack::Report<errors::ApiErrorResponse>;
@@ -2158,6 +2170,15 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
}
}
+#[cfg(feature = "v2")]
+impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthorizeData {
+ type Error = error_stack::Report<errors::ApiErrorResponse>;
+
+ fn try_from(additional_data: PaymentAdditionalData<'_, F>) -> Result<Self, Self::Error> {
+ todo!()
+ }
+}
+
impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProcessingData {
type Error = error_stack::Report<errors::ApiErrorResponse>;
diff --git a/crates/router/src/core/pm_auth.rs b/crates/router/src/core/pm_auth.rs
index b95d78c8a0..bb47a54b12 100644
--- a/crates/router/src/core/pm_auth.rs
+++ b/crates/router/src/core/pm_auth.rs
@@ -45,6 +45,7 @@ use crate::{
types::{self, domain, storage, transformers::ForeignTryFrom},
};
+#[cfg(feature = "v1")]
pub async fn create_link_token(
state: SessionState,
merchant_account: domain::MerchantAccount,
@@ -201,6 +202,16 @@ pub async fn create_link_token(
Ok(ApplicationResponse::Json(response))
}
+#[cfg(feature = "v2")]
+pub async fn create_link_token(
+ _state: SessionState,
+ _merchant_account: domain::MerchantAccount,
+ _key_store: domain::MerchantKeyStore,
+ _payload: api_models::pm_auth::LinkTokenCreateRequest,
+) -> RouterResponse<api_models::pm_auth::LinkTokenCreateResponse> {
+ todo!()
+}
+
impl ForeignTryFrom<&types::ConnectorAuthType> for PlaidAuthType {
type Error = errors::ConnectorError;
@@ -289,6 +300,7 @@ pub async fn exchange_token_core(
Ok(ApplicationResponse::StatusOk)
}
+#[cfg(feature = "v1")]
async fn store_bank_details_in_payment_methods(
key_store: domain::MerchantKeyStore,
payload: api_models::pm_auth::ExchangeTokenCreateRequest,
@@ -558,6 +570,19 @@ async fn store_bank_details_in_payment_methods(
Ok(())
}
+#[cfg(feature = "v2")]
+async fn store_bank_details_in_payment_methods(
+ _key_store: domain::MerchantKeyStore,
+ _payload: api_models::pm_auth::ExchangeTokenCreateRequest,
+ _merchant_account: domain::MerchantAccount,
+ _state: SessionState,
+ _bank_account_details_resp: pm_auth_types::BankAccountCredentialsResponse,
+ _connector_details: (&str, Secret<String>),
+ _mca_id: common_utils::id_type::MerchantConnectorAccountId,
+) -> RouterResult<()> {
+ todo!()
+}
+
async fn store_in_db(
state: &SessionState,
key_store: &domain::MerchantKeyStore,
diff --git a/crates/router/src/core/user/sample_data.rs b/crates/router/src/core/user/sample_data.rs
index ce7143338f..1851c563d0 100644
--- a/crates/router/src/core/user/sample_data.rs
+++ b/crates/router/src/core/user/sample_data.rs
@@ -10,16 +10,17 @@ use crate::{
core::errors::sample_data::{SampleDataError, SampleDataResult},
routes::{app::ReqState, SessionState},
services::{authentication::UserFromToken, ApplicationResponse},
- utils::user::sample_data::generate_sample_data,
+ utils,
};
+#[cfg(feature = "v1")]
pub async fn generate_sample_data_for_user(
state: SessionState,
user_from_token: UserFromToken,
req: SampleDataRequest,
_req_state: ReqState,
) -> SampleDataApiResponse<()> {
- let sample_data = generate_sample_data(
+ let sample_data = utils::user::sample_data::generate_sample_data(
&state,
req,
&user_from_token.merchant_id,
diff --git a/crates/router/src/core/verification/utils.rs b/crates/router/src/core/verification/utils.rs
index 404019e809..787220651f 100644
--- a/crates/router/src/core/verification/utils.rs
+++ b/crates/router/src/core/verification/utils.rs
@@ -1,4 +1,3 @@
-use api_models::payments::PaymentIdType;
use common_utils::{errors::CustomResult, id_type::PaymentId};
use error_stack::{Report, ResultExt};
@@ -11,7 +10,6 @@ use crate::{
routes::SessionState,
services::authentication::AuthenticationData,
types::{self, storage},
- utils::find_payment_intent_from_payment_id_type,
};
pub async fn check_existence_and_add_domain_to_db(
@@ -137,14 +135,28 @@ pub async fn check_if_profile_id_is_present_in_payment_intent(
state: &SessionState,
auth_data: &AuthenticationData,
) -> CustomResult<(), errors::ApiErrorResponse> {
- let payment_id_type = PaymentIdType::PaymentIntentId(payment_id);
- let payment_intent = find_payment_intent_from_payment_id_type(
- state,
- payment_id_type,
- &auth_data.merchant_account,
- &auth_data.key_store,
- )
- .await
- .change_context(errors::ApiErrorResponse::Unauthorized)?;
+ let db = &*state.store;
+ #[cfg(feature = "v1")]
+ let payment_intent = db
+ .find_payment_intent_by_payment_id_merchant_id(
+ &state.into(),
+ &payment_id,
+ auth_data.merchant_account.get_id(),
+ &auth_data.key_store,
+ auth_data.merchant_account.storage_scheme,
+ )
+ .await
+ .change_context(errors::ApiErrorResponse::Unauthorized)?;
+
+ #[cfg(feature = "v2")]
+ let payment_intent = db
+ .find_payment_intent_by_id(
+ &state.into(),
+ &payment_id,
+ &auth_data.key_store,
+ auth_data.merchant_account.storage_scheme,
+ )
+ .await
+ .change_context(errors::ApiErrorResponse::Unauthorized)?;
utils::validate_profile_id_from_auth_layer(auth_data.profile_id.clone(), &payment_intent)
}
diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rs
index 641b4c8b0e..122e9ee00f 100644
--- a/crates/router/src/db/kafka_store.rs
+++ b/crates/router/src/db/kafka_store.rs
@@ -1577,6 +1577,7 @@ impl PaymentIntentInterface for KafkaStore {
Ok(intent)
}
+ #[cfg(feature = "v1")]
async fn find_payment_intent_by_payment_id_merchant_id(
&self,
state: &KeyManagerState,
@@ -1596,7 +1597,20 @@ impl PaymentIntentInterface for KafkaStore {
.await
}
- #[cfg(feature = "olap")]
+ #[cfg(feature = "v2")]
+ async fn find_payment_intent_by_id(
+ &self,
+ state: &KeyManagerState,
+ payment_id: &id_type::PaymentId,
+ key_store: &domain::MerchantKeyStore,
+ storage_scheme: MerchantStorageScheme,
+ ) -> CustomResult<storage::PaymentIntent, errors::DataStorageError> {
+ self.diesel_store
+ .find_payment_intent_by_id(state, payment_id, key_store, storage_scheme)
+ .await
+ }
+
+ #[cfg(all(feature = "olap", feature = "v1"))]
async fn filter_payment_intent_by_constraints(
&self,
state: &KeyManagerState,
@@ -1616,7 +1630,7 @@ impl PaymentIntentInterface for KafkaStore {
.await
}
- #[cfg(feature = "olap")]
+ #[cfg(all(feature = "olap", feature = "v1"))]
async fn filter_payment_intents_by_time_range_constraints(
&self,
state: &KeyManagerState,
@@ -1636,7 +1650,7 @@ impl PaymentIntentInterface for KafkaStore {
.await
}
- #[cfg(feature = "olap")]
+ #[cfg(all(feature = "olap", feature = "v1"))]
async fn get_intent_status_with_count(
&self,
merchant_id: &id_type::MerchantId,
@@ -1648,7 +1662,7 @@ impl PaymentIntentInterface for KafkaStore {
.await
}
- #[cfg(feature = "olap")]
+ #[cfg(all(feature = "olap", feature = "v1"))]
async fn get_filtered_payment_intents_attempt(
&self,
state: &KeyManagerState,
@@ -1674,7 +1688,7 @@ impl PaymentIntentInterface for KafkaStore {
.await
}
- #[cfg(feature = "olap")]
+ #[cfg(all(feature = "olap", feature = "v1"))]
async fn get_filtered_active_attempt_ids_for_total_count(
&self,
merchant_id: &id_type::MerchantId,
diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rs
index fc838645c8..ac452233e0 100644
--- a/crates/router/src/lib.rs
+++ b/crates/router/src/lib.rs
@@ -1,4 +1,4 @@
-#[cfg(feature = "stripe")]
+#[cfg(all(feature = "stripe", feature = "v1"))]
pub mod compatibility;
pub mod configs;
pub mod connection;
@@ -128,9 +128,14 @@ pub fn mk_app(
.service(routes::Customers::server(state.clone()))
.service(routes::Configs::server(state.clone()))
.service(routes::Forex::server(state.clone()))
- .service(routes::Refunds::server(state.clone()))
- .service(routes::MerchantConnectorAccount::server(state.clone()))
- .service(routes::Mandates::server(state.clone()))
+ .service(routes::MerchantConnectorAccount::server(state.clone()));
+
+ #[cfg(feature = "v1")]
+ {
+ server_app = server_app
+ .service(routes::Refunds::server(state.clone()))
+ .service(routes::Mandates::server(state.clone()));
+ }
}
#[cfg(all(
@@ -152,18 +157,23 @@ pub fn mk_app(
.service(routes::Organization::server(state.clone()))
.service(routes::MerchantAccount::server(state.clone()))
.service(routes::ApiKeys::server(state.clone()))
- .service(routes::Files::server(state.clone()))
- .service(routes::Disputes::server(state.clone()))
.service(routes::Analytics::server(state.clone()))
- .service(routes::Routing::server(state.clone()))
- .service(routes::Blocklist::server(state.clone()))
- .service(routes::Gsm::server(state.clone()))
- .service(routes::ApplePayCertificatesMigration::server(state.clone()))
- .service(routes::PaymentLink::server(state.clone()))
- .service(routes::User::server(state.clone()))
- .service(routes::ConnectorOnboarding::server(state.clone()))
- .service(routes::Verify::server(state.clone()))
- .service(routes::WebhookEvents::server(state.clone()));
+ .service(routes::Routing::server(state.clone()));
+
+ #[cfg(feature = "v1")]
+ {
+ server_app = server_app
+ .service(routes::Files::server(state.clone()))
+ .service(routes::Disputes::server(state.clone()))
+ .service(routes::Blocklist::server(state.clone()))
+ .service(routes::Gsm::server(state.clone()))
+ .service(routes::ApplePayCertificatesMigration::server(state.clone()))
+ .service(routes::PaymentLink::server(state.clone()))
+ .service(routes::User::server(state.clone()))
+ .service(routes::ConnectorOnboarding::server(state.clone()))
+ .service(routes::Verify::server(state.clone()))
+ .service(routes::WebhookEvents::server(state.clone()));
+ }
}
#[cfg(feature = "payouts")]
@@ -182,7 +192,7 @@ pub fn mk_app(
server_app = server_app.service(routes::StripeApis::server(state.clone()));
}
- #[cfg(feature = "recon")]
+ #[cfg(all(feature = "recon", feature = "v1"))]
{
server_app = server_app.service(routes::Recon::server(state.clone()));
}
diff --git a/crates/router/src/routes.rs b/crates/router/src/routes.rs
index cb8edb2405..482b9a1b9c 100644
--- a/crates/router/src/routes.rs
+++ b/crates/router/src/routes.rs
@@ -1,8 +1,9 @@
pub mod admin;
pub mod api_keys;
pub mod app;
+#[cfg(feature = "v1")]
pub mod apple_pay_certificates_migration;
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub mod blocklist;
pub mod cache;
pub mod cards_info;
@@ -22,9 +23,11 @@ pub mod fraud_check;
pub mod gsm;
pub mod health;
pub mod lock_utils;
+#[cfg(feature = "v1")]
pub mod locker_migration;
pub mod mandates;
pub mod metrics;
+#[cfg(feature = "v1")]
pub mod payment_link;
pub mod payment_methods;
pub mod payments;
@@ -37,6 +40,7 @@ pub mod pm_auth;
pub mod poll;
#[cfg(feature = "recon")]
pub mod recon;
+#[cfg(feature = "v1")]
pub mod refunds;
#[cfg(feature = "olap")]
pub mod routing;
@@ -48,15 +52,16 @@ pub mod user_role;
pub mod verification;
#[cfg(feature = "olap")]
pub mod verify_connector;
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub mod webhook_events;
+#[cfg(feature = "v1")]
pub mod webhooks;
#[cfg(feature = "dummy_connector")]
pub use self::app::DummyConnector;
#[cfg(any(feature = "olap", feature = "oltp"))]
pub use self::app::Forex;
-#[cfg(all(feature = "olap", feature = "recon"))]
+#[cfg(all(feature = "olap", feature = "recon", feature = "v1"))]
pub use self::app::Recon;
pub use self::app::{
ApiKeys, AppState, ApplePayCertificatesMigration, BusinessProfile, BusinessProfileNew, Cache,
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index c36bf10b8c..06d2d38f83 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -20,8 +20,6 @@ use storage_impl::{config::TenantConfig, redis::RedisStore, MockDb};
use tokio::sync::oneshot;
use self::settings::Tenant;
-#[cfg(feature = "olap")]
-use super::blocklist;
#[cfg(any(feature = "olap", feature = "oltp"))]
use super::currency;
#[cfg(feature = "dummy_connector")]
@@ -50,16 +48,18 @@ use super::poll::retrieve_poll_status;
use super::routing;
#[cfg(feature = "olap")]
use super::verification::{apple_pay_merchant_registration, retrieve_apple_pay_verified_domains};
-#[cfg(feature = "oltp")]
+#[cfg(all(feature = "oltp", feature = "v1"))]
use super::webhooks::*;
-#[cfg(feature = "olap")]
use super::{
- admin::*, api_keys::*, apple_pay_certificates_migration, connector_onboarding::*, disputes::*,
- files::*, gsm::*, payment_link::*, user::*, user_role::*, webhook_events::*,
+ admin, api_keys, cache::*, connector_onboarding, disputes, files, gsm, health::*, user,
+ user_role,
};
-use super::{cache::*, health::*};
+#[cfg(feature = "v1")]
+use super::{apple_pay_certificates_migration, blocklist, payment_link, webhook_events};
#[cfg(any(feature = "olap", feature = "oltp"))]
-use super::{configs::*, customers::*, mandates::*, payments::*, refunds::*};
+use super::{configs::*, customers::*, payments::*};
+#[cfg(all(any(feature = "olap", feature = "oltp"), feature = "v1"))]
+use super::{mandates::*, refunds::*};
#[cfg(feature = "olap")]
pub use crate::analytics::opensearch::OpenSearchClient;
#[cfg(feature = "olap")]
@@ -983,7 +983,7 @@ impl Customers {
}
pub struct Refunds;
-#[cfg(any(feature = "olap", feature = "oltp"))]
+#[cfg(all(any(feature = "olap", feature = "oltp"), feature = "v1"))]
impl Refunds {
pub fn server(state: AppState) -> Scope {
let mut route = web::scope("/refunds").app_data(web::Data::new(state));
@@ -1126,10 +1126,10 @@ impl PaymentMethods {
}
}
-#[cfg(all(feature = "olap", feature = "recon"))]
+#[cfg(all(feature = "olap", feature = "recon", feature = "v1"))]
pub struct Recon;
-#[cfg(all(feature = "olap", feature = "recon"))]
+#[cfg(all(feature = "olap", feature = "recon", feature = "v1"))]
impl Recon {
pub fn server(state: AppState) -> Scope {
web::scope("/recon")
@@ -1142,14 +1142,14 @@ impl Recon {
.service(
web::resource("/request").route(web::post().to(recon_routes::request_for_recon)),
)
- .service(web::resource("/verify_token").route(web::get().to(verify_recon_token)))
+ .service(web::resource("/verify_token").route(web::get().to(user::verify_recon_token)))
}
}
#[cfg(feature = "olap")]
pub struct Blocklist;
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
impl Blocklist {
pub fn server(state: AppState) -> Scope {
web::scope("/blocklist")
@@ -1174,11 +1174,11 @@ impl Organization {
pub fn server(state: AppState) -> Scope {
web::scope("/organization")
.app_data(web::Data::new(state))
- .service(web::resource("").route(web::post().to(organization_create)))
+ .service(web::resource("").route(web::post().to(admin::organization_create)))
.service(
web::resource("/{id}")
- .route(web::get().to(organization_retrieve))
- .route(web::put().to(organization_update)),
+ .route(web::get().to(admin::organization_retrieve))
+ .route(web::put().to(admin::organization_update)),
)
}
}
@@ -1188,11 +1188,11 @@ impl Organization {
pub fn server(state: AppState) -> Scope {
web::scope("/v2/organization")
.app_data(web::Data::new(state))
- .service(web::resource("").route(web::post().to(organization_create)))
+ .service(web::resource("").route(web::post().to(admin::organization_create)))
.service(
web::resource("/{id}")
- .route(web::get().to(organization_retrieve))
- .route(web::put().to(organization_update)),
+ .route(web::get().to(admin::organization_retrieve))
+ .route(web::put().to(admin::organization_update)),
)
}
}
@@ -1204,11 +1204,11 @@ impl MerchantAccount {
pub fn server(state: AppState) -> Scope {
web::scope("/v2/accounts")
.app_data(web::Data::new(state))
- .service(web::resource("").route(web::post().to(merchant_account_create)))
+ .service(web::resource("").route(web::post().to(admin::merchant_account_create)))
.service(
web::resource("/{id}")
- .route(web::get().to(retrieve_merchant_account))
- .route(web::put().to(update_merchant_account)),
+ .route(web::get().to(admin::retrieve_merchant_account))
+ .route(web::put().to(admin::update_merchant_account)),
)
}
}
@@ -1218,22 +1218,25 @@ impl MerchantAccount {
pub fn server(state: AppState) -> Scope {
web::scope("/accounts")
.app_data(web::Data::new(state))
- .service(web::resource("").route(web::post().to(merchant_account_create)))
- .service(web::resource("/list").route(web::get().to(merchant_account_list)))
+ .service(web::resource("").route(web::post().to(admin::merchant_account_create)))
+ .service(web::resource("/list").route(web::get().to(admin::merchant_account_list)))
.service(
web::resource("/{id}/kv")
- .route(web::post().to(merchant_account_toggle_kv))
- .route(web::get().to(merchant_account_kv_status)),
+ .route(web::post().to(admin::merchant_account_toggle_kv))
+ .route(web::get().to(admin::merchant_account_kv_status)),
)
.service(
- web::resource("/transfer").route(web::post().to(merchant_account_transfer_keys)),
+ web::resource("/transfer")
+ .route(web::post().to(admin::merchant_account_transfer_keys)),
+ )
+ .service(
+ web::resource("/kv").route(web::post().to(admin::merchant_account_toggle_all_kv)),
)
- .service(web::resource("/kv").route(web::post().to(merchant_account_toggle_all_kv)))
.service(
web::resource("/{id}")
- .route(web::get().to(retrieve_merchant_account))
- .route(web::post().to(update_merchant_account))
- .route(web::delete().to(delete_merchant_account)),
+ .route(web::get().to(admin::retrieve_merchant_account))
+ .route(web::post().to(admin::update_merchant_account))
+ .route(web::delete().to(admin::delete_merchant_account)),
)
}
}
@@ -1316,7 +1319,7 @@ impl EphemeralKey {
pub struct Mandates;
-#[cfg(any(feature = "olap", feature = "oltp"))]
+#[cfg(all(any(feature = "olap", feature = "oltp"), feature = "v1"))]
impl Mandates {
pub fn server(state: AppState) -> Scope {
let mut route = web::scope("/mandates").app_data(web::Data::new(state));
@@ -1338,7 +1341,7 @@ impl Mandates {
pub struct Webhooks;
-#[cfg(feature = "oltp")]
+#[cfg(all(feature = "oltp", feature = "v1"))]
impl Webhooks {
pub fn server(config: AppState) -> Scope {
use api_models::webhooks as webhook_type;
@@ -1388,7 +1391,7 @@ impl Configs {
pub struct ApplePayCertificatesMigration;
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
impl ApplePayCertificatesMigration {
pub fn server(state: AppState) -> Scope {
web::scope("/apple_pay_certificates_migration")
@@ -1412,18 +1415,18 @@ impl Poll {
pub struct ApiKeys;
-#[cfg(all(feature = "v2", feature = "olap"))]
+#[cfg(all(feature = "olap", feature = "v2"))]
impl ApiKeys {
pub fn server(state: AppState) -> Scope {
web::scope("/v2/api_keys")
.app_data(web::Data::new(state))
- .service(web::resource("").route(web::post().to(api_key_create)))
- .service(web::resource("/list").route(web::get().to(api_key_list)))
+ .service(web::resource("").route(web::post().to(api_keys::api_key_create)))
+ .service(web::resource("/list").route(web::get().to(api_keys::api_key_list)))
.service(
web::resource("/{key_id}")
- .route(web::get().to(api_key_retrieve))
- .route(web::put().to(api_key_update))
- .route(web::delete().to(api_key_revoke)),
+ .route(web::get().to(api_keys::api_key_retrieve))
+ .route(web::put().to(api_keys::api_key_update))
+ .route(web::delete().to(api_keys::api_key_revoke)),
)
}
}
@@ -1433,40 +1436,46 @@ impl ApiKeys {
pub fn server(state: AppState) -> Scope {
web::scope("/api_keys/{merchant_id}")
.app_data(web::Data::new(state))
- .service(web::resource("").route(web::post().to(api_key_create)))
- .service(web::resource("/list").route(web::get().to(api_key_list)))
+ .service(web::resource("").route(web::post().to(api_keys::api_key_create)))
+ .service(web::resource("/list").route(web::get().to(api_keys::api_key_list)))
.service(
web::resource("/{key_id}")
- .route(web::get().to(api_key_retrieve))
- .route(web::post().to(api_key_update))
- .route(web::delete().to(api_key_revoke)),
+ .route(web::get().to(api_keys::api_key_retrieve))
+ .route(web::post().to(api_keys::api_key_update))
+ .route(web::delete().to(api_keys::api_key_revoke)),
)
}
}
pub struct Disputes;
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
impl Disputes {
pub fn server(state: AppState) -> Scope {
web::scope("/disputes")
.app_data(web::Data::new(state))
- .service(web::resource("/list").route(web::get().to(retrieve_disputes_list)))
+ .service(web::resource("/list").route(web::get().to(disputes::retrieve_disputes_list)))
.service(
- web::resource("/profile/list").route(web::get().to(retrieve_disputes_list_profile)),
+ web::resource("/profile/list")
+ .route(web::get().to(disputes::retrieve_disputes_list_profile)),
+ )
+ .service(
+ web::resource("/accept/{dispute_id}")
+ .route(web::post().to(disputes::accept_dispute)),
)
- .service(web::resource("/accept/{dispute_id}").route(web::post().to(accept_dispute)))
.service(
web::resource("/evidence")
- .route(web::post().to(submit_dispute_evidence))
- .route(web::put().to(attach_dispute_evidence))
- .route(web::delete().to(delete_dispute_evidence)),
+ .route(web::post().to(disputes::submit_dispute_evidence))
+ .route(web::put().to(disputes::attach_dispute_evidence))
+ .route(web::delete().to(disputes::delete_dispute_evidence)),
)
.service(
web::resource("/evidence/{dispute_id}")
- .route(web::get().to(retrieve_dispute_evidence)),
+ .route(web::get().to(disputes::retrieve_dispute_evidence)),
+ )
+ .service(
+ web::resource("/{dispute_id}").route(web::get().to(disputes::retrieve_dispute)),
)
- .service(web::resource("/{dispute_id}").route(web::get().to(retrieve_dispute)))
}
}
@@ -1482,16 +1491,16 @@ impl Cards {
pub struct Files;
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
impl Files {
pub fn server(state: AppState) -> Scope {
web::scope("/files")
.app_data(web::Data::new(state))
- .service(web::resource("").route(web::post().to(files_create)))
+ .service(web::resource("").route(web::post().to(files::files_create)))
.service(
web::resource("/{file_id}")
- .route(web::delete().to(files_delete))
- .route(web::get().to(files_retrieve)),
+ .route(web::delete().to(files::files_delete))
+ .route(web::get().to(files::files_retrieve)),
)
}
}
@@ -1507,26 +1516,28 @@ impl Cache {
}
pub struct PaymentLink;
-#[cfg(feature = "olap")]
+
+#[cfg(all(feature = "olap", feature = "v1"))]
impl PaymentLink {
pub fn server(state: AppState) -> Scope {
web::scope("/payment_link")
.app_data(web::Data::new(state))
- .service(web::resource("/list").route(web::post().to(payments_link_list)))
+ .service(web::resource("/list").route(web::post().to(payment_link::payments_link_list)))
.service(
- web::resource("/{payment_link_id}").route(web::get().to(payment_link_retrieve)),
+ web::resource("/{payment_link_id}")
+ .route(web::get().to(payment_link::payment_link_retrieve)),
)
.service(
web::resource("{merchant_id}/{payment_id}")
- .route(web::get().to(initiate_payment_link)),
+ .route(web::get().to(payment_link::initiate_payment_link)),
)
.service(
web::resource("s/{merchant_id}/{payment_id}")
- .route(web::get().to(initiate_secure_payment_link)),
+ .route(web::get().to(payment_link::initiate_secure_payment_link)),
)
.service(
web::resource("status/{merchant_id}/{payment_id}")
- .route(web::get().to(payment_link_status)),
+ .route(web::get().to(payment_link::payment_link_status)),
)
}
}
@@ -1551,13 +1562,13 @@ impl BusinessProfile {
pub fn server(state: AppState) -> Scope {
web::scope("/v2/profiles")
.app_data(web::Data::new(state))
- .service(web::resource("").route(web::post().to(business_profile_create)))
+ .service(web::resource("").route(web::post().to(super::admin::business_profile_create)))
.service(
web::scope("/{profile_id}")
.service(
web::resource("")
- .route(web::get().to(business_profile_retrieve))
- .route(web::put().to(business_profile_update)),
+ .route(web::get().to(super::admin::business_profile_retrieve))
+ .route(web::put().to(super::admin::business_profile_update)),
)
.service(
web::resource("/fallback_routing")
@@ -1610,24 +1621,24 @@ impl BusinessProfile {
.app_data(web::Data::new(state))
.service(
web::resource("")
- .route(web::post().to(business_profile_create))
- .route(web::get().to(business_profiles_list)),
+ .route(web::post().to(admin::business_profile_create))
+ .route(web::get().to(admin::business_profiles_list)),
)
.service(
web::scope("/{profile_id}")
.service(
web::resource("")
- .route(web::get().to(business_profile_retrieve))
- .route(web::post().to(business_profile_update))
- .route(web::delete().to(business_profile_delete)),
+ .route(web::get().to(admin::business_profile_retrieve))
+ .route(web::post().to(admin::business_profile_update))
+ .route(web::delete().to(admin::business_profile_delete)),
)
.service(
web::resource("/toggle_extended_card_info")
- .route(web::post().to(toggle_extended_card_info)),
+ .route(web::post().to(admin::toggle_extended_card_info)),
)
.service(
web::resource("/toggle_connector_agnostic_mit")
- .route(web::post().to(toggle_connector_agnostic_mit)),
+ .route(web::post().to(admin::toggle_connector_agnostic_mit)),
),
)
}
@@ -1641,32 +1652,34 @@ impl BusinessProfileNew {
web::scope("/account/{account_id}/profile")
.app_data(web::Data::new(state))
.service(
- web::resource("").route(web::get().to(business_profiles_list_at_profile_level)),
+ web::resource("")
+ .route(web::get().to(admin::business_profiles_list_at_profile_level)),
)
.service(
- web::resource("/connectors").route(web::get().to(payment_connector_list_profile)),
+ web::resource("/connectors")
+ .route(web::get().to(admin::payment_connector_list_profile)),
)
}
}
pub struct Gsm;
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
impl Gsm {
pub fn server(state: AppState) -> Scope {
web::scope("/gsm")
.app_data(web::Data::new(state))
- .service(web::resource("").route(web::post().to(create_gsm_rule)))
- .service(web::resource("/get").route(web::post().to(get_gsm_rule)))
- .service(web::resource("/update").route(web::post().to(update_gsm_rule)))
- .service(web::resource("/delete").route(web::post().to(delete_gsm_rule)))
+ .service(web::resource("").route(web::post().to(gsm::create_gsm_rule)))
+ .service(web::resource("/get").route(web::post().to(gsm::get_gsm_rule)))
+ .service(web::resource("/update").route(web::post().to(gsm::update_gsm_rule)))
+ .service(web::resource("/delete").route(web::post().to(gsm::delete_gsm_rule)))
}
}
#[cfg(feature = "olap")]
pub struct Verify;
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
impl Verify {
pub fn server(state: AppState) -> Scope {
web::scope("/verify")
@@ -1684,102 +1697,122 @@ impl Verify {
pub struct User;
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
impl User {
pub fn server(state: AppState) -> Scope {
let mut route = web::scope("/user").app_data(web::Data::new(state));
route = route
- .service(web::resource("").route(web::get().to(get_user_details)))
- .service(web::resource("/signin").route(web::post().to(user_signin)))
- .service(web::resource("/v2/signin").route(web::post().to(user_signin)))
+ .service(web::resource("").route(web::get().to(user::get_user_details)))
+ .service(web::resource("/signin").route(web::post().to(user::user_signin)))
+ .service(web::resource("/v2/signin").route(web::post().to(user::user_signin)))
// signin/signup with sso using openidconnect
- .service(web::resource("/oidc").route(web::post().to(sso_sign)))
- .service(web::resource("/signout").route(web::post().to(signout)))
- .service(web::resource("/rotate_password").route(web::post().to(rotate_password)))
- .service(web::resource("/change_password").route(web::post().to(change_password)))
- .service(web::resource("/internal_signup").route(web::post().to(internal_user_signup)))
- .service(web::resource("/switch_merchant").route(web::post().to(switch_merchant_id)))
+ .service(web::resource("/oidc").route(web::post().to(user::sso_sign)))
+ .service(web::resource("/signout").route(web::post().to(user::signout)))
+ .service(web::resource("/rotate_password").route(web::post().to(user::rotate_password)))
+ .service(web::resource("/change_password").route(web::post().to(user::change_password)))
+ .service(
+ web::resource("/internal_signup").route(web::post().to(user::internal_user_signup)),
+ )
+ .service(
+ web::resource("/switch_merchant").route(web::post().to(user::switch_merchant_id)),
+ )
.service(
web::resource("/create_merchant")
- .route(web::post().to(user_merchant_account_create)),
+ .route(web::post().to(user::user_merchant_account_create)),
)
// TODO: Remove this endpoint once migration to /merchants/list is done
- .service(web::resource("/switch/list").route(web::get().to(list_merchants_for_user)))
- .service(web::resource("/merchants/list").route(web::get().to(list_merchants_for_user)))
+ .service(
+ web::resource("/switch/list").route(web::get().to(user::list_merchants_for_user)),
+ )
+ .service(
+ web::resource("/merchants/list")
+ .route(web::get().to(user::list_merchants_for_user)),
+ )
// The route is utilized to select an invitation from a list of merchants in an intermediate state
.service(
web::resource("/merchants_select/list")
- .route(web::get().to(list_merchants_for_user)),
+ .route(web::get().to(user::list_merchants_for_user)),
+ )
+ .service(
+ web::resource("/permission_info")
+ .route(web::get().to(user_role::get_authorization_info)),
+ )
+ .service(
+ web::resource("/module/list").route(web::get().to(user_role::get_role_information)),
+ )
+ .service(
+ web::resource("/update").route(web::post().to(user::update_user_account_details)),
)
- .service(web::resource("/permission_info").route(web::get().to(get_authorization_info)))
- .service(web::resource("/module/list").route(web::get().to(get_role_information)))
- .service(web::resource("/update").route(web::post().to(update_user_account_details)))
.service(
web::resource("/data")
- .route(web::get().to(get_multiple_dashboard_metadata))
- .route(web::post().to(set_dashboard_metadata)),
+ .route(web::get().to(user::get_multiple_dashboard_metadata))
+ .route(web::post().to(user::set_dashboard_metadata)),
);
- route = route.service(
- web::scope("/key")
- .service(web::resource("/transfer").route(web::post().to(transfer_user_key))),
- );
+ route = route
+ .service(web::scope("/key").service(
+ web::resource("/transfer").route(web::post().to(user::transfer_user_key)),
+ ));
route = route.service(
web::scope("/list")
- .service(web::resource("/org").route(web::get().to(list_orgs_for_user)))
+ .service(web::resource("/org").route(web::get().to(user::list_orgs_for_user)))
.service(
- web::resource("/merchant").route(web::get().to(list_merchants_for_user_in_org)),
+ web::resource("/merchant")
+ .route(web::get().to(user::list_merchants_for_user_in_org)),
)
.service(
web::resource("/profile")
- .route(web::get().to(list_profiles_for_user_in_org_and_merchant)),
+ .route(web::get().to(user::list_profiles_for_user_in_org_and_merchant)),
)
.service(
- web::resource("/invitation").route(web::get().to(list_invitations_for_user)),
+ web::resource("/invitation")
+ .route(web::get().to(user_role::list_invitations_for_user)),
),
);
route = route.service(
web::scope("/switch")
- .service(web::resource("/org").route(web::post().to(switch_org_for_user)))
+ .service(web::resource("/org").route(web::post().to(user::switch_org_for_user)))
.service(
web::resource("/merchant")
- .route(web::post().to(switch_merchant_for_user_in_org)),
+ .route(web::post().to(user::switch_merchant_for_user_in_org)),
)
.service(
web::resource("/profile")
- .route(web::post().to(switch_profile_for_user_in_org_and_merchant)),
+ .route(web::post().to(user::switch_profile_for_user_in_org_and_merchant)),
),
);
// Two factor auth routes
route = route.service(
web::scope("/2fa")
- .service(web::resource("").route(web::get().to(check_two_factor_auth_status)))
+ .service(web::resource("").route(web::get().to(user::check_two_factor_auth_status)))
.service(
web::scope("/totp")
- .service(web::resource("/begin").route(web::get().to(totp_begin)))
- .service(web::resource("/reset").route(web::get().to(totp_reset)))
+ .service(web::resource("/begin").route(web::get().to(user::totp_begin)))
+ .service(web::resource("/reset").route(web::get().to(user::totp_reset)))
.service(
web::resource("/verify")
- .route(web::post().to(totp_verify))
- .route(web::put().to(totp_update)),
+ .route(web::post().to(user::totp_verify))
+ .route(web::put().to(user::totp_update)),
),
)
.service(
web::scope("/recovery_code")
.service(
- web::resource("/verify").route(web::post().to(verify_recovery_code)),
+ web::resource("/verify")
+ .route(web::post().to(user::verify_recovery_code)),
)
.service(
web::resource("/generate")
- .route(web::get().to(generate_recovery_codes)),
+ .route(web::get().to(user::generate_recovery_codes)),
),
)
.service(
- web::resource("/terminate").route(web::get().to(terminate_two_factor_auth)),
+ web::resource("/terminate")
+ .route(web::get().to(user::terminate_two_factor_auth)),
),
);
@@ -1787,78 +1820,102 @@ impl User {
web::scope("/auth")
.service(
web::resource("")
- .route(web::post().to(create_user_authentication_method))
- .route(web::put().to(update_user_authentication_method)),
+ .route(web::post().to(user::create_user_authentication_method))
+ .route(web::put().to(user::update_user_authentication_method)),
)
.service(
- web::resource("/list").route(web::get().to(list_user_authentication_methods)),
+ web::resource("/list")
+ .route(web::get().to(user::list_user_authentication_methods)),
)
- .service(web::resource("/url").route(web::get().to(get_sso_auth_url)))
- .service(web::resource("/select").route(web::post().to(terminate_auth_select))),
+ .service(web::resource("/url").route(web::get().to(user::get_sso_auth_url)))
+ .service(
+ web::resource("/select").route(web::post().to(user::terminate_auth_select)),
+ ),
);
#[cfg(feature = "email")]
{
route = route
- .service(web::resource("/from_email").route(web::post().to(user_from_email)))
+ .service(web::resource("/from_email").route(web::post().to(user::user_from_email)))
+ .service(
+ web::resource("/connect_account")
+ .route(web::post().to(user::user_connect_account)),
+ )
+ .service(
+ web::resource("/forgot_password").route(web::post().to(user::forgot_password)),
+ )
.service(
- web::resource("/connect_account").route(web::post().to(user_connect_account)),
+ web::resource("/reset_password").route(web::post().to(user::reset_password)),
)
- .service(web::resource("/forgot_password").route(web::post().to(forgot_password)))
- .service(web::resource("/reset_password").route(web::post().to(reset_password)))
.service(
web::resource("/signup_with_merchant_id")
- .route(web::post().to(user_signup_with_merchant_id)),
+ .route(web::post().to(user::user_signup_with_merchant_id)),
+ )
+ .service(web::resource("/verify_email").route(web::post().to(user::verify_email)))
+ .service(
+ web::resource("/v2/verify_email").route(web::post().to(user::verify_email)),
)
- .service(web::resource("/verify_email").route(web::post().to(verify_email)))
- .service(web::resource("/v2/verify_email").route(web::post().to(verify_email)))
.service(
web::resource("/verify_email_request")
- .route(web::post().to(verify_email_request)),
+ .route(web::post().to(user::verify_email_request)),
+ )
+ .service(
+ web::resource("/user/resend_invite").route(web::post().to(user::resend_invite)),
)
- .service(web::resource("/user/resend_invite").route(web::post().to(resend_invite)))
.service(
web::resource("/accept_invite_from_email")
- .route(web::post().to(accept_invite_from_email)),
+ .route(web::post().to(user::accept_invite_from_email)),
);
}
#[cfg(not(feature = "email"))]
{
- route = route.service(web::resource("/signup").route(web::post().to(user_signup)))
+ route = route.service(web::resource("/signup").route(web::post().to(user::user_signup)))
}
// User management
route = route.service(
web::scope("/user")
- .service(web::resource("").route(web::get().to(get_user_role_details)))
- .service(web::resource("/v2").route(web::post().to(list_user_roles_details)))
+ .service(web::resource("").route(web::get().to(user::get_user_role_details)))
+ .service(web::resource("/v2").route(web::post().to(user::list_user_roles_details)))
.service(
- web::resource("/list").route(web::get().to(list_users_for_merchant_account)),
+ web::resource("/list")
+ .route(web::get().to(user::list_users_for_merchant_account)),
)
- .service(web::resource("/v2/list").route(web::get().to(list_users_in_lineage)))
.service(
- web::resource("/invite_multiple").route(web::post().to(invite_multiple_user)),
+ web::resource("/v2/list")
+ .route(web::get().to(user_role::list_users_in_lineage)),
+ )
+ .service(
+ web::resource("/invite_multiple")
+ .route(web::post().to(user::invite_multiple_user)),
)
.service(
web::scope("/invite/accept")
.service(
web::resource("")
- .route(web::post().to(merchant_select))
- .route(web::put().to(accept_invitation)),
+ .route(web::post().to(user_role::merchant_select))
+ .route(web::put().to(user_role::accept_invitation)),
)
.service(
web::scope("/v2")
.service(
- web::resource("").route(web::post().to(accept_invitations_v2)),
+ web::resource("")
+ .route(web::post().to(user_role::accept_invitations_v2)),
)
.service(
- web::resource("/pre_auth")
- .route(web::post().to(accept_invitations_pre_auth)),
+ web::resource("/pre_auth").route(
+ web::post().to(user_role::accept_invitations_pre_auth),
+ ),
),
),
)
- .service(web::resource("/update_role").route(web::post().to(update_user_role)))
- .service(web::resource("/delete").route(web::delete().to(delete_user_role))),
+ .service(
+ web::resource("/update_role")
+ .route(web::post().to(user_role::update_user_role)),
+ )
+ .service(
+ web::resource("/delete").route(web::delete().to(user_role::delete_user_role)),
+ ),
);
// Role information
@@ -1866,26 +1923,30 @@ impl User {
web::scope("/role")
.service(
web::resource("")
- .route(web::get().to(get_role_from_token))
- .route(web::post().to(create_role)),
+ .route(web::get().to(user_role::get_role_from_token))
+ .route(web::post().to(user_role::create_role)),
+ )
+ .service(
+ web::resource("/v2/list").route(web::get().to(user_role::list_roles_with_info)),
)
- .service(web::resource("/v2/list").route(web::get().to(list_roles_with_info)))
.service(
web::scope("/list")
- .service(web::resource("").route(web::get().to(list_all_roles)))
+ .service(web::resource("").route(web::get().to(user_role::list_all_roles)))
.service(
- web::resource("/invite")
- .route(web::get().to(list_invitable_roles_at_entity_level)),
+ web::resource("/invite").route(
+ web::get().to(user_role::list_invitable_roles_at_entity_level),
+ ),
)
.service(
- web::resource("/update")
- .route(web::get().to(list_updatable_roles_at_entity_level)),
+ web::resource("/update").route(
+ web::get().to(user_role::list_updatable_roles_at_entity_level),
+ ),
),
)
.service(
web::resource("/{role_id}")
- .route(web::get().to(get_role))
- .route(web::put().to(update_role)),
+ .route(web::get().to(user_role::get_role))
+ .route(web::put().to(user_role::update_role)),
),
);
@@ -1893,8 +1954,8 @@ impl User {
{
route = route.service(
web::resource("/sample_data")
- .route(web::post().to(generate_sample_data))
- .route(web::delete().to(delete_sample_data)),
+ .route(web::post().to(user::generate_sample_data))
+ .route(web::delete().to(user::delete_sample_data)),
)
}
route
@@ -1903,35 +1964,47 @@ impl User {
pub struct ConnectorOnboarding;
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
impl ConnectorOnboarding {
pub fn server(state: AppState) -> Scope {
web::scope("/connector_onboarding")
.app_data(web::Data::new(state))
- .service(web::resource("/action_url").route(web::post().to(get_action_url)))
- .service(web::resource("/sync").route(web::post().to(sync_onboarding_status)))
- .service(web::resource("/reset_tracking_id").route(web::post().to(reset_tracking_id)))
+ .service(
+ web::resource("/action_url")
+ .route(web::post().to(connector_onboarding::get_action_url)),
+ )
+ .service(
+ web::resource("/sync")
+ .route(web::post().to(connector_onboarding::sync_onboarding_status)),
+ )
+ .service(
+ web::resource("/reset_tracking_id")
+ .route(web::post().to(connector_onboarding::reset_tracking_id)),
+ )
}
}
#[cfg(feature = "olap")]
pub struct WebhookEvents;
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
impl WebhookEvents {
pub fn server(config: AppState) -> Scope {
web::scope("/events/{merchant_id}")
.app_data(web::Data::new(config))
- .service(web::resource("").route(web::get().to(list_initial_webhook_delivery_attempts)))
+ .service(
+ web::resource("")
+ .route(web::get().to(webhook_events::list_initial_webhook_delivery_attempts)),
+ )
.service(
web::scope("/{event_id}")
.service(
web::resource("attempts")
- .route(web::get().to(list_webhook_delivery_attempts)),
+ .route(web::get().to(webhook_events::list_webhook_delivery_attempts)),
)
.service(
web::resource("retry")
- .route(web::post().to(retry_webhook_delivery_attempt)),
+ .route(web::post().to(webhook_events::retry_webhook_delivery_attempt)),
),
)
}
diff --git a/crates/router/src/routes/fraud_check.rs b/crates/router/src/routes/fraud_check.rs
index 20609502c1..f51becf251 100644
--- a/crates/router/src/routes/fraud_check.rs
+++ b/crates/router/src/routes/fraud_check.rs
@@ -7,6 +7,7 @@ use crate::{
AppState,
};
+#[cfg(feature = "v1")]
pub async fn frm_fulfillment(
state: web::Data<AppState>,
req: HttpRequest,
diff --git a/crates/router/src/routes/mandates.rs b/crates/router/src/routes/mandates.rs
index 70b36f8798..4435c59b42 100644
--- a/crates/router/src/routes/mandates.rs
+++ b/crates/router/src/routes/mandates.rs
@@ -50,25 +50,9 @@ pub async fn get_mandate(
))
.await
}
-/// Mandates - Revoke Mandate
-///
-/// Revokes a mandate created using the Payments/Create API
-#[utoipa::path(
- post,
- path = "/mandates/revoke/{mandate_id}",
- params(
- ("mandate_id" = String, Path, description = "The identifier for a mandate")
- ),
- responses(
- (status = 200, description = "The mandate was revoked successfully", body = MandateRevokedResponse),
- (status = 400, description = "Mandate does not exist in our records")
- ),
- tag = "Mandates",
- operation_id = "Revoke a Mandate",
- security(("api_key" = []))
-)]
+
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::MandatesRevoke))]
-// #[post("/revoke/{id}")]
pub async fn revoke_mandate(
state: web::Data<AppState>,
req: HttpRequest,
diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rs
index 8f3ee3dd4b..82407976c6 100644
--- a/crates/router/src/routes/payments.rs
+++ b/crates/router/src/routes/payments.rs
@@ -30,65 +30,7 @@ use crate::{
},
};
-/// Payments - Create
-///
-/// To process a payment you will have to create a payment, attach a payment method and confirm. Depending on the user journey you wish to achieve, you may opt to all the steps in a single request or in a sequence of API request using following APIs: (i) Payments - Update, (ii) Payments - Confirm, and (iii) Payments - Capture
-#[utoipa::path(
- post,
- path = "/payments",
- request_body(
- content = PaymentsCreateRequest,
- // examples(
- // (
- // "Create a payment with minimul fields" = (
- // value = json!(PAYMENTS_CREATE_MINIMUM_FIELDS)
- // )
- // ),
- // (
- // "Create a manual capture payment" = (
- // value = json!(PAYMENTS_CREATE_WITH_MANUAL_CAPTURE)
- // )
- // ),
- // (
- // "Create a payment with address" = (
- // value = json!(PAYMENTS_CREATE_WITH_ADDRESS)
- // )
- // ),
- // (
- // "Create a payment with customer details" = (
- // value = json!(PAYMENTS_CREATE_WITH_CUSTOMER_DATA)
- // )
- // ),
- // (
- // "Create a 3DS payment" = (
- // value = json!(PAYMENTS_CREATE_WITH_FORCED_3DS)
- // )
- // ),
- // (
- // "Create a payment" = (
- // value = json!(PAYMENTS_CREATE)
- // )
- // ),
- // (
- // "Create a payment with order details" = (
- // value = json!(PAYMENTS_CREATE_WITH_ORDER_DETAILS)
- // )
- // ),
- // (
- // "Create a payment with order category for noon" = (
- // value = json!(PAYMENTS_CREATE_WITH_NOON_ORDER_CATETORY)
- // )
- // ),
- // )
- ),
- responses(
- (status = 200, description = "Payment created", body = PaymentsResponse),
- (status = 400, description = "Missing Mandatory fields")
- ),
- tag = "Payments",
- operation_id = "Create a Payment",
- security(("api_key" = [])),
-)]
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsCreate, payment_id))]
pub async fn payments_create(
state: web::Data<app::AppState>,
@@ -161,24 +103,8 @@ pub async fn payments_create(
))
.await
}
-// /// Payments - Redirect
-// ///
-// /// For a payment which involves the redirection flow. This redirects the user to the authentication page
-// #[utoipa::path(
-// get,
-// path = "/payments/redirect/{payment_id}/{merchant_id}/{attempt_id}",
-// params(
-// ("payment_id" = String, Path, description = "The identifier for payment"),
-// ("merchant_id" = String, Path, description = "The identifier for merchant"),
-// ("attempt_id" = String, Path, description = "The identifier for transaction")
-// ),
-// responses(
-// (status = 200, description = "Redirects to the authentication page"),
-// (status = 404, description = "No redirection found")
-// ),
-// tag = "Payments",
-// operation_id = "Start a Redirection Payment"
-// )]
+
+#[cfg(feature = "v1")]
#[instrument(skip(state, req), fields(flow = ?Flow::PaymentsStart, payment_id))]
pub async fn payments_start(
state: web::Data<app::AppState>,
@@ -232,26 +158,9 @@ pub async fn payments_start(
))
.await
}
-/// Payments - Retrieve
-///
-/// To retrieve the properties of a Payment. This may be used to get the status of a previously initiated payment or next action for an ongoing payment
-#[utoipa::path(
- get,
- path = "/payments/{payment_id}",
- params(
- ("payment_id" = String, Path, description = "The identifier for payment")
- ),
- request_body=PaymentRetrieveBody,
- responses(
- (status = 200, description = "Gets the payment with final status", body = PaymentsResponse),
- (status = 404, description = "No payment found")
- ),
- tag = "Payments",
- operation_id = "Retrieve a Payment",
- security(("api_key" = []), ("publishable_key" = []))
-)]
+
+#[cfg(feature = "v1")]
#[instrument(skip(state, req), fields(flow, payment_id))]
-// #[get("/{payment_id}")]
pub async fn payments_retrieve(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -330,23 +239,9 @@ pub async fn payments_retrieve(
))
.await
}
-/// Payments - Retrieve with gateway credentials
-///
-/// To retrieve the properties of a Payment. This may be used to get the status of a previously initiated payment or next action for an ongoing payment
-#[utoipa::path(
- post,
- path = "/sync",
- request_body=PaymentRetrieveBodyWithCredentials,
- responses(
- (status = 200, description = "Gets the payment with final status", body = PaymentsResponse),
- (status = 404, description = "No payment found")
- ),
- tag = "Payments",
- operation_id = "Retrieve a Payment",
- security(("api_key" = []))
-)]
+
+#[cfg(feature = "v1")]
#[instrument(skip(state, req), fields(flow, payment_id))]
-// #[post("/sync")]
pub async fn payments_retrieve_with_gateway_creds(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -408,26 +303,9 @@ pub async fn payments_retrieve_with_gateway_creds(
))
.await
}
-/// Payments - Update
-///
-/// To update the properties of a PaymentIntent object. This may include attaching a payment method, or attaching customer object or metadata fields after the Payment is created
-#[utoipa::path(
- post,
- path = "/payments/{payment_id}",
- params(
- ("payment_id" = String, Path, description = "The identifier for payment")
- ),
- request_body=PaymentsRequest,
- responses(
- (status = 200, description = "Payment updated", body = PaymentsResponse),
- (status = 400, description = "Missing mandatory fields")
- ),
- tag = "Payments",
- operation_id = "Update a Payment",
- security(("api_key" = []), ("publishable_key" = []))
-)]
+
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsUpdate, payment_id))]
-// #[post("/{payment_id}")]
pub async fn payments_update(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -477,26 +355,9 @@ pub async fn payments_update(
))
.await
}
-/// Payments - Confirm
-///
-/// This API is to confirm the payment request and forward payment to the payment processor. This API provides more granular control upon when the API is forwarded to the payment processor. Alternatively you can confirm the payment within the Payments Create API
-#[utoipa::path(
- post,
- path = "/payments/{payment_id}/confirm",
- params(
- ("payment_id" = String, Path, description = "The identifier for payment")
- ),
- request_body=PaymentsRequest,
- responses(
- (status = 200, description = "Payment confirmed", body = PaymentsResponse),
- (status = 400, description = "Missing mandatory fields")
- ),
- tag = "Payments",
- operation_id = "Confirm a Payment",
- security(("api_key" = []), ("publishable_key" = []))
-)]
+
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsConfirm, payment_id))]
-// #[post("/{payment_id}/confirm")]
pub async fn payments_confirm(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -556,26 +417,9 @@ pub async fn payments_confirm(
))
.await
}
-/// Payments - Capture
-///
-/// To capture the funds for an uncaptured payment
-#[utoipa::path(
- post,
- path = "/payments/{payment_id}/capture",
- params(
- ("payment_id" = String, Path, description = "The identifier for payment")
- ),
- request_body=PaymentsCaptureRequest,
- responses(
- (status = 200, description = "Payment captured", body = PaymentsResponse),
- (status = 400, description = "Missing mandatory fields")
- ),
- tag = "Payments",
- operation_id = "Capture a Payment",
- security(("api_key" = []))
-)]
+
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsCapture, payment_id))]
-// #[post("/{payment_id}/capture")]
pub async fn payments_capture(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -626,8 +470,7 @@ pub async fn payments_capture(
.await
}
-/// Dynamic Tax Calculation
-
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::SessionUpdateTaxCalculation, payment_id))]
pub async fn payments_dynamic_tax_calculation(
state: web::Data<app::AppState>,
@@ -686,21 +529,7 @@ pub async fn payments_dynamic_tax_calculation(
.await
}
-/// Payments - Session token
-///
-/// To create the session object or to get session token for wallets
-#[utoipa::path(
- post,
- path = "/payments/session_tokens",
- request_body=PaymentsSessionRequest,
- responses(
- (status = 200, description = "Payment session object created or session token was retrieved from wallets", body = PaymentsSessionResponse),
- (status = 400, description = "Missing mandatory fields")
- ),
- tag = "Payments",
- operation_id = "Create Session tokens for a Payment",
- security(("publishable_key" = []))
-)]
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsSessionToken, payment_id))]
pub async fn payments_connector_session(
state: web::Data<app::AppState>,
@@ -757,24 +586,8 @@ pub async fn payments_connector_session(
))
.await
}
-// /// Payments - Redirect response
-// ///
-// /// To get the payment response for redirect flows
-// #[utoipa::path(
-// post,
-// path = "/payments/{payment_id}/{merchant_id}/response/{connector}",
-// params(
-// ("payment_id" = String, Path, description = "The identifier for payment"),
-// ("merchant_id" = String, Path, description = "The identifier for merchant"),
-// ("connector" = String, Path, description = "The name of the connector")
-// ),
-// responses(
-// (status = 302, description = "Received payment redirect response"),
-// (status = 400, description = "Missing mandatory fields")
-// ),
-// tag = "Payments",
-// operation_id = "Get Redirect Response for a Payment"
-// )]
+
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsRedirect, payment_id))]
pub async fn payments_redirect_response(
state: web::Data<app::AppState>,
@@ -824,24 +637,7 @@ pub async fn payments_redirect_response(
.await
}
-// /// Payments - Redirect response with creds_identifier
-// ///
-// /// To get the payment response for redirect flows
-// #[utoipa::path(
-// post,
-// path = "/payments/{payment_id}/{merchant_id}/response/{connector}/{cred_identifier}",
-// params(
-// ("payment_id" = String, Path, description = "The identifier for payment"),
-// ("merchant_id" = String, Path, description = "The identifier for merchant"),
-// ("connector" = String, Path, description = "The name of the connector")
-// ),
-// responses(
-// (status = 302, description = "Received payment redirect response"),
-// (status = 400, description = "Missing mandatory fields")
-// ),
-// tag = "Payments",
-// operation_id = "Get Redirect Response for a Payment"
-// )]
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsRedirect, payment_id))]
pub async fn payments_redirect_response_with_creds_identifier(
state: web::Data<app::AppState>,
@@ -890,6 +686,8 @@ pub async fn payments_redirect_response_with_creds_identifier(
)
.await
}
+
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow =? Flow::PaymentsRedirect, payment_id))]
pub async fn payments_complete_authorize_redirect(
state: web::Data<app::AppState>,
@@ -940,7 +738,7 @@ pub async fn payments_complete_authorize_redirect(
.await
}
-/// Payments - Complete Authorize
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow =? Flow::PaymentsCompleteAuthorize, payment_id))]
pub async fn payments_complete_authorize(
state: web::Data<app::AppState>,
@@ -1005,24 +803,7 @@ pub async fn payments_complete_authorize(
.await
}
-/// Payments - Cancel
-///
-/// A Payment could can be cancelled when it is in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_customer_action
-#[utoipa::path(
- post,
- path = "/payments/{payment_id}/cancel",
- request_body=PaymentsCancelRequest,
- params(
- ("payment_id" = String, Path, description = "The identifier for payment")
- ),
- responses(
- (status = 200, description = "Payment canceled"),
- (status = 400, description = "Missing mandatory fields")
- ),
- tag = "Payments",
- operation_id = "Cancel a Payment",
- security(("api_key" = []))
-)]
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsCancel, payment_id))]
pub async fn payments_cancel(
state: web::Data<app::AppState>,
@@ -1070,33 +851,9 @@ pub async fn payments_cancel(
))
.await
}
-/// Payments - List
-///
-/// To list the payments
-#[utoipa::path(
- get,
- path = "/payments/list",
- params(
- ("customer_id" = String, Query, description = "The identifier for the customer"),
- ("starting_after" = String, Query, description = "A cursor for use in pagination, fetch the next list after some object"),
- ("ending_before" = String, Query, description = "A cursor for use in pagination, fetch the previous list before some object"),
- ("limit" = i64, Query, description = "Limit on the number of objects to return"),
- ("created" = PrimitiveDateTime, Query, description = "The time at which payment is created"),
- ("created_lt" = PrimitiveDateTime, Query, description = "Time less than the payment created time"),
- ("created_gt" = PrimitiveDateTime, Query, description = "Time greater than the payment created time"),
- ("created_lte" = PrimitiveDateTime, Query, description = "Time less than or equals to the payment created time"),
- ("created_gte" = PrimitiveDateTime, Query, description = "Time greater than or equals to the payment created time")
- ),
- responses(
- (status = 200, description = "Received payment list"),
- (status = 404, description = "No payments found")
- ),
- tag = "Payments",
- operation_id = "List all Payments",
- security(("api_key" = []))
-)]
+
#[instrument(skip_all, fields(flow = ?Flow::PaymentsList))]
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn payments_list(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -1124,33 +881,9 @@ pub async fn payments_list(
))
.await
}
-/// Business Profile level Payments - List
-///
-/// To list the payments
-#[utoipa::path(
- get,
- path = "/payments/list",
- params(
- ("customer_id" = String, Query, description = "The identifier for the customer"),
- ("starting_after" = String, Query, description = "A cursor for use in pagination, fetch the next list after some object"),
- ("ending_before" = String, Query, description = "A cursor for use in pagination, fetch the previous list before some object"),
- ("limit" = i64, Query, description = "Limit on the number of objects to return"),
- ("created" = PrimitiveDateTime, Query, description = "The time at which payment is created"),
- ("created_lt" = PrimitiveDateTime, Query, description = "Time less than the payment created time"),
- ("created_gt" = PrimitiveDateTime, Query, description = "Time greater than the payment created time"),
- ("created_lte" = PrimitiveDateTime, Query, description = "Time less than or equals to the payment created time"),
- ("created_gte" = PrimitiveDateTime, Query, description = "Time greater than or equals to the payment created time")
- ),
- responses(
- (status = 200, description = "Received payment list"),
- (status = 404, description = "No payments found")
- ),
- tag = "Payments",
- operation_id = "List all Payments for the Profile",
- security(("api_key" = []))
-)]
+
#[instrument(skip_all, fields(flow = ?Flow::PaymentsList))]
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn profile_payments_list(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -1184,8 +917,9 @@ pub async fn profile_payments_list(
))
.await
}
+
#[instrument(skip_all, fields(flow = ?Flow::PaymentsList))]
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn payments_list_by_filter(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -1217,7 +951,7 @@ pub async fn payments_list_by_filter(
}
#[instrument(skip_all, fields(flow = ?Flow::PaymentsList))]
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn profile_payments_list_by_filter(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -1249,7 +983,7 @@ pub async fn profile_payments_list_by_filter(
}
#[instrument(skip_all, fields(flow = ?Flow::PaymentsList))]
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn get_filters_for_payments(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -1275,7 +1009,7 @@ pub async fn get_filters_for_payments(
}
#[instrument(skip_all, fields(flow = ?Flow::PaymentsFilters))]
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn get_payment_filters(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -1299,7 +1033,7 @@ pub async fn get_payment_filters(
}
#[instrument(skip_all, fields(flow = ?Flow::PaymentsFilters))]
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn get_payment_filters_profile(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -1327,7 +1061,7 @@ pub async fn get_payment_filters_profile(
}
#[instrument(skip_all, fields(flow = ?Flow::PaymentsAggregate))]
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn get_payments_aggregates(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -1352,7 +1086,7 @@ pub async fn get_payments_aggregates(
.await
}
-#[cfg(feature = "oltp")]
+#[cfg(all(feature = "oltp", feature = "v1"))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsApprove, payment_id))]
pub async fn payments_approve(
state: web::Data<app::AppState>,
@@ -1416,9 +1150,8 @@ pub async fn payments_approve(
.await
}
-#[cfg(feature = "oltp")]
+#[cfg(all(feature = "oltp", feature = "v1"))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsReject, payment_id))]
-// #[post("/{payment_id}/reject")]
pub async fn payments_reject(
state: web::Data<app::AppState>,
http_req: actix_web::HttpRequest,
@@ -1482,6 +1215,7 @@ pub async fn payments_reject(
.await
}
+#[cfg(feature = "v1")]
#[allow(clippy::too_many_arguments)]
async fn authorize_verify_select<Op>(
operation: Op,
@@ -1567,24 +1301,7 @@ where
}
}
-/// Payments - Incremental Authorization
-///
-/// Authorized amount for a payment can be incremented if it is in status: requires_capture
-#[utoipa::path(
- post,
- path = "/payments/{payment_id}/incremental_authorization",
- request_body=PaymentsIncrementalAuthorizationRequest,
- params(
- ("payment_id" = String, Path, description = "The identifier for payment")
- ),
- responses(
- (status = 200, description = "Payment authorized amount incremented", body = PaymentsResponse),
- (status = 400, description = "Missing mandatory fields")
- ),
- tag = "Payments",
- operation_id = "Increment authorized amount for a Payment",
- security(("api_key" = []))
-)]
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsIncrementalAuthorization, payment_id))]
pub async fn payments_incremental_authorization(
state: web::Data<app::AppState>,
@@ -1633,24 +1350,7 @@ pub async fn payments_incremental_authorization(
.await
}
-/// Payments - External 3DS Authentication
-///
-/// External 3DS Authentication is performed and returns the AuthenticationResponse
-#[utoipa::path(
- post,
- path = "/payments/{payment_id}/3ds/authentication",
- request_body=PaymentsExternalAuthenticationRequest,
- params(
- ("payment_id" = String, Path, description = "The identifier for payment")
- ),
- responses(
- (status = 200, description = "Authentication created"),
- (status = 400, description = "Missing mandatory fields")
- ),
- tag = "Payments",
- operation_id = "Initiate external authentication for a Payment",
- security(("api_key" = []))
-)]
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsExternalAuthentication, payment_id))]
pub async fn payments_external_authentication(
state: web::Data<app::AppState>,
@@ -1685,21 +1385,7 @@ pub async fn payments_external_authentication(
.await
}
-#[utoipa::path(
- post,
- path = "/payments/{payment_id}/{merchant_id}/authorize/{connector}",
- params(
- ("payment_id" = String, Path, description = "The identifier for payment")
- ),
- request_body=PaymentsRequest,
- responses(
- (status = 200, description = "Payment Authorized", body = PaymentsResponse),
- (status = 400, description = "Missing mandatory fields")
- ),
- tag = "Payments",
- operation_id = "Authorize a Payment",
- security(("api_key" = []), ("publishable_key" = []))
-)]
+#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsAuthorize, payment_id))]
pub async fn post_3ds_payments_authorize(
state: web::Data<app::AppState>,
@@ -1749,7 +1435,7 @@ pub async fn post_3ds_payments_authorize(
.await
}
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn payments_manual_update(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@@ -1778,6 +1464,7 @@ pub async fn payments_manual_update(
.await
}
+#[cfg(feature = "v1")]
/// Retrieve endpoint for merchant to fetch the encrypted customer payment method data
#[instrument(skip_all, fields(flow = ?Flow::GetExtendedCardInfo, payment_id))]
pub async fn retrieve_extended_card_info(
@@ -1806,6 +1493,7 @@ pub async fn retrieve_extended_card_info(
.await
}
+#[cfg(feature = "v1")]
pub fn get_or_generate_payment_id(
payload: &mut payment_types::PaymentsRequest,
) -> errors::RouterResult<()> {
@@ -1828,6 +1516,7 @@ pub fn get_or_generate_payment_id(
Ok(())
}
+#[cfg(feature = "v1")]
impl GetLockingInput for payment_types::PaymentsRequest {
fn get_locking_input<F>(&self, flow: F) -> api_locking::LockAction
where
@@ -1849,6 +1538,7 @@ impl GetLockingInput for payment_types::PaymentsRequest {
}
}
+#[cfg(feature = "v1")]
impl GetLockingInput for payment_types::PaymentsStartRequest {
fn get_locking_input<F>(&self, flow: F) -> api_locking::LockAction
where
@@ -1865,6 +1555,7 @@ impl GetLockingInput for payment_types::PaymentsStartRequest {
}
}
+#[cfg(feature = "v1")]
impl GetLockingInput for payment_types::PaymentsRetrieveRequest {
fn get_locking_input<F>(&self, flow: F) -> api_locking::LockAction
where
@@ -1886,6 +1577,7 @@ impl GetLockingInput for payment_types::PaymentsRetrieveRequest {
}
}
+#[cfg(feature = "v1")]
impl GetLockingInput for payment_types::PaymentsSessionRequest {
fn get_locking_input<F>(&self, flow: F) -> api_locking::LockAction
where
@@ -1902,6 +1594,7 @@ impl GetLockingInput for payment_types::PaymentsSessionRequest {
}
}
+#[cfg(feature = "v1")]
impl GetLockingInput for payment_types::PaymentsDynamicTaxCalculationRequest {
fn get_locking_input<F>(&self, flow: F) -> api_locking::LockAction
where
@@ -1918,6 +1611,7 @@ impl GetLockingInput for payment_types::PaymentsDynamicTaxCalculationRequest {
}
}
+#[cfg(feature = "v1")]
impl GetLockingInput for payments::PaymentsRedirectResponseData {
fn get_locking_input<F>(&self, flow: F) -> api_locking::LockAction
where
@@ -1939,6 +1633,7 @@ impl GetLockingInput for payments::PaymentsRedirectResponseData {
}
}
+#[cfg(feature = "v1")]
impl GetLockingInput for payment_types::PaymentsCompleteAuthorizeRequest {
fn get_locking_input<F>(&self, flow: F) -> api_locking::LockAction
where
@@ -1955,6 +1650,7 @@ impl GetLockingInput for payment_types::PaymentsCompleteAuthorizeRequest {
}
}
+#[cfg(feature = "v1")]
impl GetLockingInput for payment_types::PaymentsCancelRequest {
fn get_locking_input<F>(&self, flow: F) -> api_locking::LockAction
where
@@ -1971,6 +1667,7 @@ impl GetLockingInput for payment_types::PaymentsCancelRequest {
}
}
+#[cfg(feature = "v1")]
impl GetLockingInput for payment_types::PaymentsCaptureRequest {
fn get_locking_input<F>(&self, flow: F) -> api_locking::LockAction
where
@@ -2027,6 +1724,7 @@ impl<'a> GetLockingInput for FPaymentsRejectRequest<'a> {
}
}
+#[cfg(feature = "v1")]
impl GetLockingInput for payment_types::PaymentsIncrementalAuthorizationRequest {
fn get_locking_input<F>(&self, flow: F) -> api_locking::LockAction
where
@@ -2043,6 +1741,7 @@ impl GetLockingInput for payment_types::PaymentsIncrementalAuthorizationRequest
}
}
+#[cfg(feature = "v1")]
impl GetLockingInput for payment_types::PaymentsExternalAuthenticationRequest {
fn get_locking_input<F>(&self, flow: F) -> api_locking::LockAction
where
@@ -2059,6 +1758,7 @@ impl GetLockingInput for payment_types::PaymentsExternalAuthenticationRequest {
}
}
+#[cfg(feature = "v1")]
impl GetLockingInput for payment_types::PaymentsManualUpdateRequest {
fn get_locking_input<F>(&self, flow: F) -> api_locking::LockAction
where
@@ -2076,7 +1776,7 @@ impl GetLockingInput for payment_types::PaymentsManualUpdateRequest {
}
#[instrument(skip_all, fields(flow = ?Flow::PaymentsAggregate))]
-#[cfg(feature = "olap")]
+#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn get_payments_aggregates_profile(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rs
index b183106899..ee0a10a822 100644
--- a/crates/router/src/routes/routing.rs
+++ b/crates/router/src/routes/routing.rs
@@ -136,7 +136,7 @@ pub async fn routing_link_config(
auth::auth_type(
&auth::ApiKeyAuth,
&auth::JWTAuthProfileFromRoute {
- profile_id: routing_payload_wrapper.profile_id,
+ profile_id: wrapper.profile_id,
required_permission: Permission::RoutingWrite,
minimum_entity_level: EntityType::Merchant,
},
@@ -309,6 +309,7 @@ pub async fn routing_unlink_config(
&auth::JWTAuthProfileFromRoute {
profile_id: path,
required_permission: Permission::RoutingWrite,
+ minimum_entity_level: EntityType::Merchant,
},
req.headers(),
),
diff --git a/crates/router/src/routes/user.rs b/crates/router/src/routes/user.rs
index 62af1d4374..a6c8659617 100644
--- a/crates/router/src/routes/user.rs
+++ b/crates/router/src/routes/user.rs
@@ -269,7 +269,7 @@ pub async fn user_merchant_account_create(
.await
}
-#[cfg(feature = "dummy_connector")]
+#[cfg(all(feature = "dummy_connector", feature = "v1"))]
pub async fn generate_sample_data(
state: web::Data<AppState>,
http_req: HttpRequest,
diff --git a/crates/router/src/services/kafka/payment_intent.rs b/crates/router/src/services/kafka/payment_intent.rs
index 6e8e795442..cb5ec9cf2e 100644
--- a/crates/router/src/services/kafka/payment_intent.rs
+++ b/crates/router/src/services/kafka/payment_intent.rs
@@ -5,6 +5,7 @@ use masking::{PeekInterface, Secret};
use serde_json::Value;
use time::OffsetDateTime;
+#[cfg(feature = "v1")]
#[derive(serde::Serialize, Debug)]
pub struct KafkaPaymentIntent<'a> {
pub payment_id: &'a id_type::PaymentId,
@@ -43,6 +44,42 @@ pub struct KafkaPaymentIntent<'a> {
pub organization_id: &'a id_type::OrganizationId,
}
+#[cfg(feature = "v2")]
+#[derive(serde::Serialize, Debug)]
+pub struct KafkaPaymentIntent<'a> {
+ pub id: &'a id_type::PaymentId,
+ pub merchant_id: &'a id_type::MerchantId,
+ pub status: storage_enums::IntentStatus,
+ pub amount: MinorUnit,
+ pub currency: Option<storage_enums::Currency>,
+ pub amount_captured: Option<MinorUnit>,
+ pub customer_id: Option<&'a id_type::CustomerId>,
+ pub description: Option<&'a String>,
+ pub return_url: Option<&'a String>,
+ pub metadata: Option<String>,
+ pub statement_descriptor_name: Option<&'a String>,
+ #[serde(with = "time::serde::timestamp")]
+ pub created_at: OffsetDateTime,
+ #[serde(with = "time::serde::timestamp")]
+ pub modified_at: OffsetDateTime,
+ #[serde(default, with = "time::serde::timestamp::option")]
+ pub last_synced: Option<OffsetDateTime>,
+ pub setup_future_usage: Option<storage_enums::FutureUsage>,
+ pub off_session: Option<bool>,
+ pub client_secret: Option<&'a String>,
+ pub active_attempt_id: String,
+ pub attempt_count: i16,
+ pub profile_id: Option<&'a id_type::ProfileId>,
+ pub payment_confirm_source: Option<storage_enums::PaymentSource>,
+ pub billing_details: Option<Encryptable<Secret<Value>>>,
+ pub shipping_details: Option<Encryptable<Secret<Value>>>,
+ pub customer_email: Option<HashedString<pii::EmailStrategy>>,
+ pub feature_metadata: Option<&'a Value>,
+ pub merchant_order_reference_id: Option<&'a String>,
+ pub organization_id: &'a id_type::OrganizationId,
+}
+
+#[cfg(feature = "v1")]
impl<'a> KafkaPaymentIntent<'a> {
pub fn from_storage(intent: &'a PaymentIntent) -> Self {
Self {
@@ -88,12 +125,66 @@ impl<'a> KafkaPaymentIntent<'a> {
}
}
+#[cfg(feature = "v2")]
+impl<'a> KafkaPaymentIntent<'a> {
+ pub fn from_storage(intent: &'a PaymentIntent) -> Self {
+ Self {
+ id: &intent.id,
+ merchant_id: &intent.merchant_id,
+ status: intent.status,
+ amount: intent.amount,
+ currency: intent.currency,
+ amount_captured: intent.amount_captured,
+ customer_id: intent.customer_id.as_ref(),
+ description: intent.description.as_ref(),
+ return_url: intent.return_url.as_ref(),
+ metadata: intent.metadata.as_ref().map(|x| x.to_string()),
+ statement_descriptor_name: intent.statement_descriptor_name.as_ref(),
+ created_at: intent.created_at.assume_utc(),
+ modified_at: intent.modified_at.assume_utc(),
+ last_synced: intent.last_synced.map(|i| i.assume_utc()),
+ setup_future_usage: intent.setup_future_usage,
+ off_session: intent.off_session,
+ client_secret: intent.client_secret.as_ref(),
+ active_attempt_id: intent.active_attempt.get_id(),
+ attempt_count: intent.attempt_count,
+ profile_id: intent.profile_id.as_ref(),
+ payment_confirm_source: intent.payment_confirm_source,
+ // TODO: use typed information here to avoid PII logging
+ billing_details: None,
+ shipping_details: None,
+ customer_email: intent
+ .customer_details
+ .as_ref()
+ .and_then(|value| value.get_inner().peek().as_object())
+ .and_then(|obj| obj.get("email"))
+ .and_then(|email| email.as_str())
+ .map(|email| HashedString::from(Secret::new(email.to_string()))),
+ feature_metadata: intent.feature_metadata.as_ref(),
+ merchant_order_reference_id: intent.merchant_order_reference_id.as_ref(),
+ organization_id: &intent.organization_id,
+ }
+ }
+}
+
+impl KafkaPaymentIntent<'_> {
+ #[cfg(feature = "v1")]
+ fn get_id(&self) -> &id_type::PaymentId {
+ self.payment_id
+ }
+
+ #[cfg(feature = "v2")]
+ fn get_id(&self) -> &id_type::PaymentId {
+ self.id
+ }
+}
+
impl<'a> super::KafkaMessage for KafkaPaymentIntent<'a> {
fn key(&self) -> String {
format!(
"{}_{}",
self.merchant_id.get_string_repr(),
- self.payment_id.get_string_repr(),
+ self.get_id().get_string_repr(),
)
}
diff --git a/crates/router/src/services/kafka/payment_intent_event.rs b/crates/router/src/services/kafka/payment_intent_event.rs
index 1d450c35cf..321ce55810 100644
--- a/crates/router/src/services/kafka/payment_intent_event.rs
+++ b/crates/router/src/services/kafka/payment_intent_event.rs
@@ -5,6 +5,7 @@ use masking::{PeekInterface, Secret};
use serde_json::Value;
use time::OffsetDateTime;
+#[cfg(feature = "v1")]
#[serde_with::skip_serializing_none]
#[derive(serde::Serialize, Debug)]
pub struct KafkaPaymentIntentEvent<'a> {
@@ -44,6 +45,55 @@ pub struct KafkaPaymentIntentEvent<'a> {
pub organization_id: &'a id_type::OrganizationId,
}
+#[cfg(feature = "v2")]
+#[serde_with::skip_serializing_none]
+#[derive(serde::Serialize, Debug)]
+pub struct KafkaPaymentIntentEvent<'a> {
+ pub id: &'a id_type::PaymentId,
+ pub merchant_id: &'a id_type::MerchantId,
+ pub status: storage_enums::IntentStatus,
+ pub amount: MinorUnit,
+ pub currency: Option<storage_enums::Currency>,
+ pub amount_captured: Option<MinorUnit>,
+ pub customer_id: Option<&'a id_type::CustomerId>,
+ pub description: Option<&'a String>,
+ pub return_url: Option<&'a String>,
+ pub metadata: Option<String>,
+ pub statement_descriptor_name: Option<&'a String>,
+ #[serde(with = "time::serde::timestamp::milliseconds")]
+ pub created_at: OffsetDateTime,
+ #[serde(with = "time::serde::timestamp::milliseconds")]
+ pub modified_at: OffsetDateTime,
+ #[serde(default, with = "time::serde::timestamp::milliseconds::option")]
+ pub last_synced: Option<OffsetDateTime>,
+ pub setup_future_usage: Option<storage_enums::FutureUsage>,
+ pub off_session: Option<bool>,
+ pub client_secret: Option<&'a String>,
+ pub active_attempt_id: String,
+ pub attempt_count: i16,
+ pub profile_id: Option<&'a id_type::ProfileId>,
+ pub payment_confirm_source: Option<storage_enums::PaymentSource>,
+ pub billing_details: Option<Encryptable<Secret<Value>>>,
+ pub shipping_details: Option<Encryptable<Secret<Value>>>,
+ pub customer_email: Option<HashedString<pii::EmailStrategy>>,
+ pub feature_metadata: Option<&'a Value>,
+ pub merchant_order_reference_id: Option<&'a String>,
+ pub organization_id: &'a id_type::OrganizationId,
+}
+
+impl KafkaPaymentIntentEvent<'_> {
+ #[cfg(feature = "v1")]
+ pub fn get_id(&self) -> &id_type::PaymentId {
+ self.payment_id
+ }
+
+ #[cfg(feature = "v2")]
+ pub fn get_id(&self) -> &id_type::PaymentId {
+ self.id
+ }
+}
+
+#[cfg(feature = "v1")]
impl<'a> KafkaPaymentIntentEvent<'a> {
pub fn from_storage(intent: &'a PaymentIntent) -> Self {
Self {
@@ -89,12 +139,54 @@ impl<'a> KafkaPaymentIntentEvent<'a> {
}
}
+#[cfg(feature = "v2")]
+impl<'a> KafkaPaymentIntentEvent<'a> {
+ pub fn from_storage(intent: &'a PaymentIntent) -> Self {
+ Self {
+ id: &intent.id,
+ merchant_id: &intent.merchant_id,
+ status: intent.status,
+ amount: intent.amount,
+ currency: intent.currency,
+ amount_captured: intent.amount_captured,
+ customer_id: intent.customer_id.as_ref(),
+ description: intent.description.as_ref(),
+ return_url: intent.return_url.as_ref(),
+ metadata: intent.metadata.as_ref().map(|x| x.to_string()),
+ statement_descriptor_name: intent.statement_descriptor_name.as_ref(),
+ created_at: intent.created_at.assume_utc(),
+ modified_at: intent.modified_at.assume_utc(),
+ last_synced: intent.last_synced.map(|i| i.assume_utc()),
+ setup_future_usage: intent.setup_future_usage,
+ off_session: intent.off_session,
+ client_secret: intent.client_secret.as_ref(),
+ active_attempt_id: intent.active_attempt.get_id(),
+ attempt_count: intent.attempt_count,
+ profile_id: intent.profile_id.as_ref(),
+ payment_confirm_source: intent.payment_confirm_source,
+ // TODO: use typed information here to avoid PII logging
+ billing_details: None,
+ shipping_details: None,
+ customer_email: intent
+ .customer_details
+ .as_ref()
+ .and_then(|value| value.get_inner().peek().as_object())
+ .and_then(|obj| obj.get("email"))
+ .and_then(|email| email.as_str())
+ .map(|email| HashedString::from(Secret::new(email.to_string()))),
+ feature_metadata: intent.feature_metadata.as_ref(),
+ merchant_order_reference_id: intent.merchant_order_reference_id.as_ref(),
+ organization_id: &intent.organization_id,
+ }
+ }
+}
+
impl<'a> super::KafkaMessage for KafkaPaymentIntentEvent<'a> {
fn key(&self) -> String {
format!(
"{}_{}",
self.merchant_id.get_string_repr(),
- self.payment_id.get_string_repr(),
+ self.get_id().get_string_repr(),
)
}
diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rs
index 5fab106061..12a26cf7c8 100644
--- a/crates/router/src/utils.rs
+++ b/crates/router/src/utils.rs
@@ -46,6 +46,8 @@ use tracing_futures::Instrument;
use uuid::Uuid;
pub use self::ext_traits::{OptionExt, ValidateCall};
+#[cfg(feature = "v1")]
+use crate::core::webhooks as webhooks_core;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use crate::types::storage;
use crate::{
@@ -53,7 +55,7 @@ use crate::{
core::{
authentication::types::ExternalThreeDSConnectorMetadata,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
- payments as payments_core, webhooks as webhooks_core,
+ payments as payments_core,
},
logger,
routes::{metrics, SessionState},
@@ -165,6 +167,7 @@ pub fn get_payout_attempt_id(payout_id: impl std::fmt::Display, attempt_count: i
format!("{payout_id}_{attempt_count}")
}
+#[cfg(feature = "v1")]
pub async fn find_payment_intent_from_payment_id_type(
state: &SessionState,
payment_id_type: payments::PaymentIdType,
@@ -228,6 +231,7 @@ pub async fn find_payment_intent_from_payment_id_type(
}
}
+#[cfg(feature = "v1")]
pub async fn find_payment_intent_from_refund_id_type(
state: &SessionState,
refund_id_type: webhooks::RefundIdType,
@@ -274,6 +278,7 @@ pub async fn find_payment_intent_from_refund_id_type(
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)
}
+#[cfg(feature = "v1")]
pub async fn find_payment_intent_from_mandate_id_type(
state: &SessionState,
mandate_id_type: webhooks::MandateIdType,
@@ -313,6 +318,7 @@ pub async fn find_payment_intent_from_mandate_id_type(
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)
}
+#[cfg(feature = "v1")]
pub async fn find_mca_from_authentication_id_type(
state: &SessionState,
authentication_id_type: webhooks::AuthenticationIdType,
@@ -528,6 +534,7 @@ pub async fn get_mca_from_payout_attempt(
}
}
+#[cfg(feature = "v1")]
pub async fn get_mca_from_object_reference_id(
state: &SessionState,
object_reference_id: webhooks::ObjectReferenceId,
@@ -1051,6 +1058,26 @@ pub fn check_if_pull_mechanism_for_external_3ds_enabled_from_connector_metadata(
.unwrap_or(true)
}
+#[cfg(feature = "v2")]
+#[allow(clippy::too_many_arguments)]
+pub async fn trigger_payments_webhook<F, Op, D>(
+ merchant_account: domain::MerchantAccount,
+ business_profile: domain::BusinessProfile,
+ key_store: &domain::MerchantKeyStore,
+ payment_data: D,
+ customer: Option<domain::Customer>,
+ state: &SessionState,
+ operation: Op,
+) -> RouterResult<()>
+where
+ F: Send + Clone + Sync,
+ Op: Debug,
+ D: payments_core::OperationSessionGetters<F>,
+{
+ todo!()
+}
+
+#[cfg(feature = "v1")]
#[allow(clippy::too_many_arguments)]
pub async fn trigger_payments_webhook<F, Op, D>(
merchant_account: domain::MerchantAccount,
@@ -1067,7 +1094,8 @@ where
D: payments_core::OperationSessionGetters<F>,
{
let status = payment_data.get_payment_intent().status;
- let payment_id = payment_data.get_payment_intent().payment_id.clone();
+ let payment_id = payment_data.get_payment_intent().get_id().to_owned();
+
let captures = payment_data
.get_multiple_capture_data()
.map(|multiple_capture_data| {
diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rs
index 40dd3dad93..7147c5071c 100644
--- a/crates/router/src/utils/user/sample_data.rs
+++ b/crates/router/src/utils/user/sample_data.rs
@@ -15,6 +15,7 @@ use crate::{
SessionState,
};
+#[cfg(feature = "v1")]
#[allow(clippy::type_complexity)]
pub async fn generate_sample_data(
state: &SessionState,
diff --git a/crates/router/src/workflows.rs b/crates/router/src/workflows.rs
index 2f858c5980..e86d49faf6 100644
--- a/crates/router/src/workflows.rs
+++ b/crates/router/src/workflows.rs
@@ -2,8 +2,12 @@
pub mod api_key_expiry;
#[cfg(feature = "payouts")]
pub mod attach_payout_account_workflow;
+#[cfg(feature = "v1")]
pub mod outgoing_webhook_retry;
+#[cfg(feature = "v1")]
pub mod payment_method_status_update;
pub mod payment_sync;
+#[cfg(feature = "v1")]
pub mod refund_router;
+#[cfg(feature = "v1")]
pub mod tokenized_data;
diff --git a/crates/router/src/workflows/payment_sync.rs b/crates/router/src/workflows/payment_sync.rs
index 3f0354ecfe..3701418c8f 100644
--- a/crates/router/src/workflows/payment_sync.rs
+++ b/crates/router/src/workflows/payment_sync.rs
@@ -28,6 +28,16 @@ pub struct PaymentsSyncWorkflow;
#[async_trait::async_trait]
impl ProcessTrackerWorkflow<SessionState> for PaymentsSyncWorkflow {
+ #[cfg(feature = "v2")]
+ async fn execute_workflow<'a>(
+ &'a self,
+ state: &'a SessionState,
+ process: storage::ProcessTracker,
+ ) -> Result<(), sch_errors::ProcessTrackerError> {
+ todo!()
+ }
+
+ #[cfg(feature = "v1")]
async fn execute_workflow<'a>(
&'a self,
state: &'a SessionState,
diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rs
index f5d5e3d1ae..11d7b644c0 100644
--- a/crates/router/tests/payments.rs
+++ b/crates/router/tests/payments.rs
@@ -277,6 +277,7 @@ fn connector_list() {
assert_eq!(true, true);
}
+#[cfg(feature = "v1")]
#[actix_rt::test]
#[ignore] // AWS
async fn payments_create_core() {
@@ -534,6 +535,7 @@ async fn payments_create_core() {
// assert_eq!(expected_response, actual_response);
// }
+#[cfg(feature = "v1")]
#[actix_rt::test]
#[ignore]
async fn payments_create_core_adyen_no_redirect() {
diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rs
index e2c86a9b91..28759f7111 100644
--- a/crates/router/tests/payments2.rs
+++ b/crates/router/tests/payments2.rs
@@ -2,7 +2,8 @@
clippy::expect_used,
clippy::unwrap_in_result,
clippy::unwrap_used,
- clippy::print_stdout
+ clippy::print_stdout,
+ unused_imports
)]
mod utils;
@@ -36,6 +37,7 @@ fn connector_list() {
assert_eq!(true, true);
}
+#[cfg(feature = "v1")]
// FIXME: broken test?
#[ignore]
#[actix_rt::test]
@@ -299,6 +301,7 @@ async fn payments_create_core() {
// assert_eq!(expected_response, actual_response);
// }
+#[cfg(feature = "v1")]
// FIXME: broken test?
#[ignore]
#[actix_rt::test]
diff --git a/crates/storage_impl/src/lib.rs b/crates/storage_impl/src/lib.rs
index c00d2b445f..6a79638677 100644
--- a/crates/storage_impl/src/lib.rs
+++ b/crates/storage_impl/src/lib.rs
@@ -329,6 +329,21 @@ impl UniqueConstraints for diesel_models::Address {
}
}
+#[cfg(all(feature = "v2", feature = "payment_v2"))]
+impl UniqueConstraints for diesel_models::PaymentIntent {
+ fn unique_constraints(&self) -> Vec<String> {
+ vec![format!(
+ "pi_{}_{}",
+ self.merchant_id.get_string_repr(),
+ self.merchant_reference_id
+ )]
+ }
+ fn table_name(&self) -> &str {
+ "PaymentIntent"
+ }
+}
+
+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
impl UniqueConstraints for diesel_models::PaymentIntent {
fn unique_constraints(&self) -> Vec<String> {
vec![format!(
diff --git a/crates/storage_impl/src/mock_db/payment_intent.rs b/crates/storage_impl/src/mock_db/payment_intent.rs
index e296c88b3a..4cf8272650 100644
--- a/crates/storage_impl/src/mock_db/payment_intent.rs
+++ b/crates/storage_impl/src/mock_db/payment_intent.rs
@@ -16,7 +16,11 @@ use super::MockDb;
#[async_trait::async_trait]
impl PaymentIntentInterface for MockDb {
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn filter_payment_intent_by_constraints(
&self,
_state: &KeyManagerState,
@@ -28,7 +32,11 @@ impl PaymentIntentInterface for MockDb {
// [#172]: Implement function for `MockDb`
Err(StorageError::MockDbError)?
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn filter_payment_intents_by_time_range_constraints(
&self,
_state: &KeyManagerState,
@@ -40,7 +48,11 @@ impl PaymentIntentInterface for MockDb {
// [#172]: Implement function for `MockDb`
Err(StorageError::MockDbError)?
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn get_intent_status_with_count(
&self,
_merchant_id: &common_utils::id_type::MerchantId,
@@ -50,7 +62,11 @@ impl PaymentIntentInterface for MockDb {
// [#172]: Implement function for `MockDb`
Err(StorageError::MockDbError)?
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn get_filtered_active_attempt_ids_for_total_count(
&self,
_merchant_id: &common_utils::id_type::MerchantId,
@@ -60,7 +76,11 @@ impl PaymentIntentInterface for MockDb {
// [#172]: Implement function for `MockDb`
Err(StorageError::MockDbError)?
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn get_filtered_payment_intents_attempt(
&self,
_state: &KeyManagerState,
@@ -99,7 +119,7 @@ impl PaymentIntentInterface for MockDb {
let mut payment_intents = self.payment_intents.lock().await;
let payment_intent = payment_intents
.iter_mut()
- .find(|item| item.payment_id == this.payment_id && item.merchant_id == this.merchant_id)
+ .find(|item| item.get_id() == this.get_id() && item.merchant_id == this.merchant_id)
.unwrap();
let diesel_payment_intent_update = diesel_models::PaymentIntentUpdate::from(update);
@@ -121,6 +141,7 @@ impl PaymentIntentInterface for MockDb {
Ok(payment_intent.clone())
}
+ #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
// safety: only used for testing
#[allow(clippy::unwrap_used)]
async fn find_payment_intent_by_payment_id_merchant_id(
@@ -136,13 +157,31 @@ impl PaymentIntentInterface for MockDb {
Ok(payment_intents
.iter()
.find(|payment_intent| {
- payment_intent.payment_id == *payment_id
- && payment_intent.merchant_id.eq(merchant_id)
+ payment_intent.get_id() == payment_id && payment_intent.merchant_id.eq(merchant_id)
})
.cloned()
.unwrap())
}
+ #[cfg(all(feature = "v2", feature = "payment_v2"))]
+ async fn find_payment_intent_by_id(
+ &self,
+ _state: &KeyManagerState,
+ id: &common_utils::id_type::PaymentId,
+ _merchant_key_store: &MerchantKeyStore,
+ _storage_scheme: storage_enums::MerchantStorageScheme,
+ ) -> error_stack::Result<PaymentIntent, StorageError> {
+ let payment_intents = self.payment_intents.lock().await;
+ let payment_intent = payment_intents
+ .iter()
+ .find(|payment_intent| payment_intent.get_id() == id)
+ .ok_or(StorageError::ValueNotFound(
+ "PaymentIntent not found".to_string(),
+ ))?;
+
+ Ok(payment_intent.clone())
+ }
+
async fn get_active_payment_attempt(
&self,
payment: &mut PaymentIntent,
diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rs
index 6a29e41569..cb58eac4b6 100644
--- a/crates/storage_impl/src/payments/payment_intent.rs
+++ b/crates/storage_impl/src/payments/payment_intent.rs
@@ -73,8 +73,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentIntent, StorageError> {
let merchant_id = payment_intent.merchant_id.clone();
- let payment_id = payment_intent.payment_id.clone();
- let field = payment_intent.payment_id.get_hash_key_for_kv_store();
+ let payment_id = payment_intent.get_id().to_owned();
+ let field = payment_intent.get_id().get_hash_key_for_kv_store();
let key = PartitionKey::MerchantIdPaymentId {
merchant_id: &merchant_id,
payment_id: &payment_id,
@@ -152,12 +152,12 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentIntent, StorageError> {
let merchant_id = this.merchant_id.clone();
- let payment_id = this.payment_id.clone();
+ let payment_id = this.get_id().to_owned();
let key = PartitionKey::MerchantIdPaymentId {
merchant_id: &merchant_id,
payment_id: &payment_id,
};
- let field = format!("pi_{}", this.payment_id.get_string_repr());
+ let field = format!("pi_{}", this.get_id().get_string_repr());
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentIntent>(
self,
storage_scheme,
@@ -229,6 +229,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
}
}
+ #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
#[instrument(skip_all)]
async fn find_payment_intent_by_payment_id_merchant_id(
&self,
@@ -288,6 +289,35 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
.change_context(StorageError::DecryptionError)
}
+ #[cfg(all(feature = "v2", feature = "payment_v2"))]
+ #[instrument(skip_all)]
+ async fn find_payment_intent_by_id(
+ &self,
+ state: &KeyManagerState,
+ id: &common_utils::id_type::PaymentId,
+ merchant_key_store: &MerchantKeyStore,
+ _storage_scheme: MerchantStorageScheme,
+ ) -> error_stack::Result<PaymentIntent, StorageError> {
+ let conn = pg_connection_read(self).await?;
+ let diesel_payment_intent = DieselPaymentIntent::find_by_global_id(&conn, id)
+ .await
+ .map_err(|er| {
+ let new_err = diesel_error_to_data_error(er.current_context());
+ er.change_context(new_err)
+ })?;
+
+ let merchant_id = diesel_payment_intent.merchant_id.clone();
+
+ PaymentIntent::convert_back(
+ state,
+ diesel_payment_intent,
+ merchant_key_store.key.get_inner(),
+ merchant_id.to_owned().into(),
+ )
+ .await
+ .change_context(StorageError::DecryptionError)
+ }
+
async fn get_active_payment_attempt(
&self,
payment: &mut PaymentIntent,
@@ -315,7 +345,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
}
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn filter_payment_intent_by_constraints(
&self,
state: &KeyManagerState,
@@ -335,7 +369,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
.await
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn filter_payment_intents_by_time_range_constraints(
&self,
state: &KeyManagerState,
@@ -354,7 +392,12 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
)
.await
}
- #[cfg(feature = "olap")]
+
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn get_intent_status_with_count(
&self,
merchant_id: &common_utils::id_type::MerchantId,
@@ -366,7 +409,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
.await
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn get_filtered_payment_intents_attempt(
&self,
state: &KeyManagerState,
@@ -386,7 +433,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
.await
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
async fn get_filtered_active_attempt_ids_for_total_count(
&self,
merchant_id: &common_utils::id_type::MerchantId,
@@ -468,6 +519,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
.change_context(StorageError::DecryptionError)
}
+ #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
#[instrument(skip_all)]
async fn find_payment_intent_by_payment_id_merchant_id(
&self,
@@ -498,6 +550,35 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
.await
}
+ #[cfg(all(feature = "v2", feature = "payment_v2"))]
+ #[instrument(skip_all)]
+ async fn find_payment_intent_by_id(
+ &self,
+ state: &KeyManagerState,
+ id: &common_utils::id_type::PaymentId,
+ merchant_key_store: &MerchantKeyStore,
+ _storage_scheme: MerchantStorageScheme,
+ ) -> error_stack::Result<PaymentIntent, StorageError> {
+ let conn = pg_connection_read(self).await?;
+ let diesel_payment_intent = DieselPaymentIntent::find_by_global_id(&conn, id)
+ .await
+ .map_err(|er| {
+ let new_err = diesel_error_to_data_error(er.current_context());
+ er.change_context(new_err)
+ })?;
+
+ let merchant_id = diesel_payment_intent.merchant_id.clone();
+
+ PaymentIntent::convert_back(
+ state,
+ diesel_payment_intent,
+ merchant_key_store.key.get_inner(),
+ merchant_id.to_owned().into(),
+ )
+ .await
+ .change_context(StorageError::DecryptionError)
+ }
+
#[instrument(skip_all)]
async fn get_active_payment_attempt(
&self,
@@ -526,7 +607,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
}
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
#[instrument(skip_all)]
async fn filter_payment_intent_by_constraints(
&self,
@@ -652,7 +737,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
.await
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
#[instrument(skip_all)]
async fn filter_payment_intents_by_time_range_constraints(
&self,
@@ -674,7 +763,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
.await
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
#[instrument(skip_all)]
async fn get_intent_status_with_count(
&self,
@@ -718,7 +811,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
})
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
#[instrument(skip_all)]
async fn get_filtered_payment_intents_attempt(
&self,
@@ -911,7 +1008,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
.await
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_v2"),
+ feature = "olap"
+ ))]
#[instrument(skip_all)]
async fn get_filtered_active_attempt_ids_for_total_count(
&self,
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.sql
index cf261b322b..427dbcb4d5 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
@@ -13,3 +13,15 @@ ALTER TABLE business_profile DROP COLUMN routing_algorithm_id,
DROP COLUMN default_fallback_routing;
DROP TYPE "OrderFulfillmentTimeOrigin";
+
+-- Revert renaming of field,
+ALTER TABLE payment_intent DROP COLUMN merchant_reference_id,
+ DROP COLUMN billing_address,
+ DROP COLUMN shipping_address,
+ DROP COLUMN capture_method,
+ DROP COLUMN authentication_type,
+ DROP COLUMN amount_to_capture,
+ DROP COLUMN prerouting_algorithm,
+ DROP COLUMN surcharge_amount,
+ DROP COLUMN tax_on_surcharge,
+ DROP COLUMN frm_merchant_decision;
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.sql
index 194d347f4c..719a8afa30 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
@@ -14,3 +14,16 @@ ADD COLUMN routing_algorithm_id VARCHAR(64) DEFAULT NULL,
ADD COLUMN frm_routing_algorithm_id VARCHAR(64) DEFAULT NULL,
ADD COLUMN payout_routing_algorithm_id VARCHAR(64) DEFAULT NULL,
ADD COLUMN default_fallback_routing JSONB DEFAULT NULL;
+
+ALTER TABLE payment_intent
+ADD COLUMN merchant_reference_id VARCHAR(64) NOT NULL,
+ ADD COLUMN billing_address BYTEA DEFAULT NULL,
+ ADD COLUMN shipping_address BYTEA DEFAULT NULL,
+ ADD COLUMN capture_method "CaptureMethod",
+ ADD COLUMN authentication_type "AuthenticationType",
+ ADD COLUMN amount_to_capture bigint,
+ ADD COLUMN prerouting_algorithm JSONB, -- straight_through_algorithm from payment_attempt
+ ADD COLUMN surcharge_amount bigint,
+ ADD COLUMN tax_on_surcharge bigint, -- tax_amount from payment_attempt
+ ADD COLUMN frm_merchant_decision VARCHAR(64);
+
diff --git a/v2_migrations/2024-08-28-081747_recreate_ids_for_v2/down.sql b/v2_migrations/2024-08-28-081747_recreate_ids_for_v2/down.sql
index 1aa2f1f60e..6315fe7f79 100644
--- a/v2_migrations/2024-08-28-081747_recreate_ids_for_v2/down.sql
+++ b/v2_migrations/2024-08-28-081747_recreate_ids_for_v2/down.sql
@@ -15,8 +15,12 @@ ALTER TABLE customers DROP COLUMN IF EXISTS id;
ALTER TABLE customers
ADD COLUMN IF NOT EXISTS id SERIAL;
+ALTER TABLE payment_intent DROP COLUMN IF EXISTS id;
+
ALTER TABLE payment_intent
ADD id SERIAL;
+ALTER TABLE payment_attempt DROP COLUMN IF EXISTS id;
+
ALTER TABLE payment_attempt
ADD id SERIAL;
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.sql
index 0e98d9792b..99b9441739 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
@@ -1,6 +1,7 @@
-- This file contains queries to re-create the `id` column as a `VARCHAR` column instead of `SERIAL` column for tables that already have it.
-- It must be ensured that the deployed version of the application does not include the `id` column in any of its queries.
-- Drop the id column as this will be used later as the primary key with a different type
+------------------------ Merchant Account -----------------------
ALTER TABLE merchant_account DROP COLUMN IF EXISTS id;
-- Adding a new column called `id` which will be the new primary key for v2
@@ -8,17 +9,24 @@ ALTER TABLE merchant_account DROP COLUMN IF EXISTS id;
ALTER TABLE merchant_account
ADD COLUMN id VARCHAR(64);
+------------------------ Merchant Connector Account -----------------------
-- This migration is to modify the id column in merchant_connector_account table to be a VARCHAR(64) and to set the id column as primary key
ALTER TABLE merchant_connector_account DROP COLUMN IF EXISTS id;
ALTER TABLE merchant_connector_account
ADD COLUMN IF NOT EXISTS id VARCHAR(64);
+------------------------ Customers -----------------------
ALTER TABLE customers DROP COLUMN IF EXISTS id;
ALTER TABLE customers
ADD COLUMN IF NOT EXISTS id VARCHAR(64);
+------------------------ Payment Intent -----------------------
ALTER TABLE payment_intent DROP COLUMN id;
+ALTER TABLE payment_intent
+ADD COLUMN IF NOT EXISTS id VARCHAR(64);
+
+------------------------ Payment Attempt -----------------------
ALTER TABLE payment_attempt DROP COLUMN id;
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.sql
index 5d9f96e15f..99af8b6ded 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
@@ -62,3 +62,12 @@ WHERE customer_id IS NULL;
ALTER TABLE customers
ADD PRIMARY KEY (merchant_id, customer_id);
+
+ALTER TABLE payment_intent DROP CONSTRAINT payment_intent_pkey;
+
+UPDATE payment_intent
+SET payment_id = id
+WHERE payment_id IS NULL;
+
+ALTER TABLE payment_intent
+ADD PRIMARY KEY (payment_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.sql
index 19cf516da1..cde27046bc 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
@@ -1,6 +1,6 @@
-- This file contains queries to update the primary key constraints suitable to the v2 application.
-- This also has queries to update other constraints and indexes on tables where applicable.
--- Backfill for organization table
+------------------------ Organization -----------------------
UPDATE ORGANIZATION
SET id = org_id
WHERE id IS NULL;
@@ -16,6 +16,7 @@ ALTER TABLE ORGANIZATION DROP CONSTRAINT organization_pkey;
ALTER TABLE ORGANIZATION
ADD CONSTRAINT organization_pkey_id PRIMARY KEY (id);
+------------------------ Merchant Account -----------------------
-- The new primary key for v2 merchant account will be `id`
ALTER TABLE merchant_account DROP CONSTRAINT merchant_account_pkey;
@@ -34,6 +35,7 @@ WHERE id IS NULL;
ALTER TABLE merchant_account
ADD PRIMARY KEY (id);
+------------------------ Business Profile -----------------------
-- This migration is to modify the id column in business_profile table to be a VARCHAR(64) and to set the id column as primary key
ALTER TABLE business_profile
ADD COLUMN id VARCHAR(64);
@@ -48,6 +50,7 @@ ALTER TABLE business_profile DROP CONSTRAINT business_profile_pkey;
ALTER TABLE business_profile
ADD PRIMARY KEY (id);
+------------------------ Merchant Connector Account -----------------------
-- Backfill the id column with the merchant_connector_id to prevent null values
UPDATE merchant_connector_account
SET id = merchant_connector_id
@@ -63,6 +66,7 @@ ALTER TABLE merchant_connector_account
ALTER COLUMN profile_id
SET NOT NULL;
+------------------------ Customers -----------------------
-- Run this query only when V1 is deprecated
ALTER TABLE customers DROP CONSTRAINT IF EXISTS customers_pkey;
@@ -75,3 +79,9 @@ WHERE id IS NULL;
ALTER TABLE customers
ADD PRIMARY KEY (id);
+
+------------------------ Payment Intent -----------------------
+ALTER TABLE payment_intent DROP CONSTRAINT payment_intent_pkey;
+
+ALTER TABLE payment_intent
+ADD PRIMARY KEY (id);
diff --git a/v2_migrations/2024-08-28-081847_drop_v1_columns/down.sql b/v2_migrations/2024-08-28-081847_drop_v1_columns/down.sql
index 7ca0e260b4..83b369beac 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
@@ -46,3 +46,17 @@ ADD COLUMN IF NOT EXISTS business_country "CountryAlpha2",
ALTER TABLE customers
ADD COLUMN customer_id VARCHAR(64),
ADD COLUMN address_id VARCHAR(64);
+
+ALTER TABLE payment_intent
+ADD COLUMN IF NOT EXISTS payment_id VARCHAR(64) NOT NULL,
+ ADD COLUMN connector_id VARCHAR(64),
+ ADD COLUMN shipping_address_id VARCHAR(64),
+ ADD COLUMN billing_address_id VARCHAR(64),
+ ADD COLUMN shipping_details VARCHAR(64),
+ ADD COLUMN billing_details VARCHAR(64),
+ ADD COLUMN statement_descriptor_suffix VARCHAR(255),
+ 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);
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.sql
index 72344b8e7d..0879d667f9 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
@@ -44,3 +44,17 @@ ALTER TABLE merchant_connector_account DROP COLUMN IF EXISTS business_country,
-- Run this query only when V1 is deprecated
ALTER TABLE customers DROP COLUMN customer_id,
DROP COLUMN address_id;
+
+-- Run below queries only when V1 is deprecated
+ALTER TABLE payment_intent DROP COLUMN payment_id,
+ DROP COLUMN connector_id,
+ DROP COLUMN shipping_address_id,
+ DROP COLUMN billing_address_id,
+ DROP COLUMN shipping_details,
+ DROP COLUMN billing_details,
+ DROP COLUMN statement_descriptor_suffix,
+ DROP COLUMN business_country,
+ DROP COLUMN business_label,
+ DROP COLUMN incremental_authorization_allowed,
+ DROP COLUMN fingerprint_id,
+ DROP COLUMN merchant_decision;