Skip to content

Commit

Permalink
chore: move the struct to appropriate place
Browse files Browse the repository at this point in the history
  • Loading branch information
Narayanbhat166 committed Jan 9, 2025
1 parent 2901eaf commit c5755cc
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 39 deletions.
11 changes: 1 addition & 10 deletions crates/api_models/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,7 @@ impl<T> ApiEventMetric for DisputesMetricsResponse<T> {
Some(ApiEventsType::Miscellaneous)
}
}
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
impl ApiEventMetric for PaymentMethodIntentConfirmInternal {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::PaymentMethod {
payment_method_id: self.id.clone(),
payment_method_type: Some(self.payment_method_type),
payment_method_subtype: Some(self.payment_method_subtype),
})
}
}


#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
impl ApiEventMetric for PaymentMethodIntentCreate {
Expand Down
22 changes: 0 additions & 22 deletions crates/api_models/src/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,28 +194,6 @@ impl PaymentMethodIntentConfirm {
}
}

/// This struct is used internally only
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
pub struct PaymentMethodIntentConfirmInternal {
pub id: id_type::GlobalPaymentMethodId,
pub payment_method_type: api_enums::PaymentMethod,
pub payment_method_subtype: api_enums::PaymentMethodType,
pub customer_id: Option<id_type::CustomerId>,
pub payment_method_data: PaymentMethodCreateData,
}

#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
impl From<PaymentMethodIntentConfirmInternal> for PaymentMethodIntentConfirm {
fn from(item: PaymentMethodIntentConfirmInternal) -> Self {
Self {
payment_method_type: item.payment_method_type,
payment_method_subtype: item.payment_method_subtype,
customer_id: item.customer_id,
payment_method_data: item.payment_method_data.clone(),
}
}
}
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
/// This struct is only used by and internal api to migrate payment method
pub struct PaymentMethodMigrate {
Expand Down
36 changes: 35 additions & 1 deletion crates/router/src/routes/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,40 @@ pub async fn create_payment_method_intent_api(
.await
}

/// This struct is used internally only
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
pub struct PaymentMethodIntentConfirmInternal {
pub id: id_type::GlobalPaymentMethodId,
pub payment_method_type: common_enums::PaymentMethod,
pub payment_method_subtype: common_enums::PaymentMethodType,
pub customer_id: Option<id_type::CustomerId>,
pub payment_method_data: payment_methods::PaymentMethodCreateData,
}

#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
impl From<PaymentMethodIntentConfirmInternal> for payment_methods::PaymentMethodIntentConfirm {
fn from(item: PaymentMethodIntentConfirmInternal) -> Self {
Self {
payment_method_type: item.payment_method_type,
payment_method_subtype: item.payment_method_subtype,
customer_id: item.customer_id,
payment_method_data: item.payment_method_data.clone(),
}
}
}

#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
impl common_utils::events::ApiEventMetric for PaymentMethodIntentConfirmInternal {
fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> {
Some(common_utils::events::ApiEventsType::PaymentMethod {
payment_method_id: self.id.clone(),
payment_method_type: Some(self.payment_method_type),
payment_method_subtype: Some(self.payment_method_subtype),
})
}
}

#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodsCreate))]
pub async fn confirm_payment_method_intent_api(
Expand All @@ -146,7 +180,7 @@ pub async fn confirm_payment_method_intent_api(
Err(e) => return api::log_and_return_error_response(e),
};

let inner_payload = payment_methods::PaymentMethodIntentConfirmInternal {
let inner_payload = PaymentMethodIntentConfirmInternal {
id: pm_id.to_owned(),
payment_method_type: payload.payment_method_type,
payment_method_subtype: payload.payment_method_subtype,
Expand Down
12 changes: 6 additions & 6 deletions crates/router/src/types/api/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ pub use api_models::payment_methods::{
GetTokenizePayloadResponse, ListCountriesCurrenciesRequest,
PaymentMethodCollectLinkRenderRequest, PaymentMethodCollectLinkRequest, PaymentMethodCreate,
PaymentMethodCreateData, PaymentMethodDeleteResponse, PaymentMethodId,
PaymentMethodIntentConfirm, PaymentMethodIntentConfirmInternal, PaymentMethodIntentCreate,
PaymentMethodListData, PaymentMethodListRequest, PaymentMethodListResponse,
PaymentMethodMigrate, PaymentMethodMigrateResponse, PaymentMethodResponse,
PaymentMethodResponseData, PaymentMethodUpdate, PaymentMethodUpdateData, PaymentMethodsData,
TokenizePayloadEncrypted, TokenizePayloadRequest, TokenizedCardValue1, TokenizedCardValue2,
TokenizedWalletValue1, TokenizedWalletValue2,
PaymentMethodIntentConfirm, PaymentMethodIntentCreate, PaymentMethodListData,
PaymentMethodListRequest, PaymentMethodListResponse, PaymentMethodMigrate,
PaymentMethodMigrateResponse, PaymentMethodResponse, PaymentMethodResponseData,
PaymentMethodUpdate, PaymentMethodUpdateData, PaymentMethodsData, TokenizePayloadEncrypted,
TokenizePayloadRequest, TokenizedCardValue1, TokenizedCardValue2, TokenizedWalletValue1,
TokenizedWalletValue2,
};
#[cfg(all(
any(feature = "v2", feature = "v1"),
Expand Down

0 comments on commit c5755cc

Please sign in to comment.