Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
70
351k
source
stringclasses
4 values
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router payment_method_session, Secret::new("CLIENT_SECRET_REDACTED".to_string()), payments_response, ); Ok(services::ApplicationResponse::Json( payment_method_session_response, )) } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] impl pm_types::SavedPMLPaymentsInfo { pub async fn form_payments_info( payment_intent: PaymentIntent, merchant_account: &domain::MerchantAccount, profile: domain::Profile, db: &dyn StorageInterface, key_manager_state: &util_types::keymanager::KeyManagerState, key_store: &domain::MerchantKeyStore, ) -> RouterResult<Self> { let collect_cvv_during_payment = profile.should_collect_cvv_during_payment; let off_session_payment_flag = matches!( payment_intent.setup_future_usage, common_enums::FutureUsage::OffSession pub async fn form_payments_info( payment_intent: PaymentIntent, merchant_account: &domain::MerchantAccount, profile: domain::Profile, db: &dyn StorageInterface, key_manager_state: &util_types::keymanager::KeyManagerState, key_store: &domain::MerchantKeyStore, ) -> RouterResult<Self> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router payment_link_config: None, request_incremental_authorization: None, session_expiry: None, frm_metadata: None, request_external_three_ds_authentication: None, customer_acceptance: None, browser_info: None, force_3ds_challenge: None, }) } #[cfg(feature = "v2")] async fn create_zero_auth_payment( state: SessionState, req_state: routes::app::ReqState, merchant_account: domain::MerchantAccount, profile: domain::Profile, key_store: domain::MerchantKeyStore, request: api_models::payments::PaymentsRequest, ) -> RouterResult<api_models::payments::PaymentsResponse> { let response = Box::pin(payments_core::payments_create_and_confirm_intent( state, req_state, merchant_account, profile, async fn create_zero_auth_payment( state: SessionState, req_state: routes::app::ReqState, merchant_account: domain::MerchantAccount, profile: domain::Profile, key_store: domain::MerchantKeyStore, request: api_models::payments::PaymentsRequest, ) -> RouterResult<api_models::payments::PaymentsResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router message: "payment methods session does not exist or has expired".to_string(), }) .attach_printable("Failed to retrieve payment methods session from db")?; let response = delete_payment_method_core(state, pm_id, key_store, merchant_account) .await .attach_printable("Failed to delete saved payment method")?; Ok(services::ApplicationResponse::Json(response)) } #[cfg(feature = "v2")] fn construct_zero_auth_payments_request( confirm_request: &payment_methods::PaymentMethodSessionConfirmRequest, payment_method_session: &hyperswitch_domain_models::payment_methods::PaymentMethodSession, payment_method: &payment_methods::PaymentMethodResponse, ) -> RouterResult<api_models::payments::PaymentsRequest> { use api_models::payments; Ok(payments::PaymentsRequest { amount_details: payments::AmountDetails::new_for_zero_auth_payment( common_enums::Currency::USD, ), payment_method_data: confirm_request.payment_method_data.clone(), payment_method_type: confirm_request.payment_method_type, fn construct_zero_auth_payments_request( confirm_request: &payment_methods::PaymentMethodSessionConfirmRequest, payment_method_session: &hyperswitch_domain_models::payment_methods::PaymentMethodSession, payment_method: &payment_methods::PaymentMethodResponse, ) -> RouterResult<api_models::payments::PaymentsRequest> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router .attach_printable("Failed to retrieve payment methods session from db")?; let response = transformers::generate_payment_method_session_response( payment_method_session_domain_model, Secret::new("CLIENT_SECRET_REDACTED".to_string()), None, // TODO: send associated payments response based on the expandable param ); Ok(services::ApplicationResponse::Json(response)) } #[cfg(feature = "v2")] pub async fn payment_methods_session_update_payment_method( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, payment_method_session_id: id_type::GlobalPaymentMethodSessionId, request: payment_methods::PaymentMethodSessionUpdateSavedPaymentMethod, ) -> RouterResponse<payment_methods::PaymentMethodResponse> { let db = state.store.as_ref(); let key_manager_state = &(&state).into(); // Validate if the session still exists db.get_payment_methods_session(key_manager_state, &key_store, &payment_method_session_id) .await pub async fn payment_methods_session_update_payment_method( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, payment_method_session_id: id_type::GlobalPaymentMethodSessionId, request: payment_methods::PaymentMethodSessionUpdateSavedPaymentMethod, ) -> RouterResponse<payment_methods::PaymentMethodResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router .attach_printable("Failed to insert payment methods session in db")?; let response = transformers::generate_payment_method_session_response( payment_method_session_domain_model, client_secret.secret, None, ); Ok(services::ApplicationResponse::Json(response)) } #[cfg(feature = "v2")] pub async fn payment_methods_session_update( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, payment_method_session_id: id_type::GlobalPaymentMethodSessionId, request: payment_methods::PaymentMethodsSessionUpdateRequest, ) -> RouterResponse<payment_methods::PaymentMethodSessionResponse> { let db = state.store.as_ref(); let key_manager_state = &(&state).into(); let existing_payment_method_session_state = db .get_payment_methods_session(key_manager_state, &key_store, &payment_method_session_id) .await pub async fn payment_methods_session_update( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, payment_method_session_id: id_type::GlobalPaymentMethodSessionId, request: payment_methods::PaymentMethodsSessionUpdateRequest, ) -> RouterResponse<payment_methods::PaymentMethodSessionResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed while encrypting payment methods session detailss")?; Ok(encrypted_data) } } #[cfg(feature = "v2")] #[async_trait::async_trait] impl EncryptableData for payment_methods::PaymentMethodsSessionUpdateRequest { type Output = hyperswitch_domain_models::payment_methods::DecryptedPaymentMethodSession; async fn encrypt_data( &self, key_manager_state: &common_utils::types::keymanager::KeyManagerState, key_store: &domain::MerchantKeyStore, ) -> RouterResult<Self::Output> { use common_utils::types::keymanager::ToEncryptable; let encrypted_billing_address = self .billing .clone() .map(|address| address.encode_to_value()) .transpose() .change_context(errors::ApiErrorResponse::InternalServerError) async fn encrypt_data( &self, key_manager_state: &common_utils::types::keymanager::KeyManagerState, key_store: &domain::MerchantKeyStore, ) -> RouterResult<Self::Output> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router merchant_account: domain::MerchantAccount, ) -> RouterResponse<api::PaymentMethodDeleteResponse> { let pm_id = id_type::GlobalPaymentMethodId::generate_from_string(pm_id.payment_method_id) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to generate GlobalPaymentMethodId")?; let response = delete_payment_method_core(state, pm_id, key_store, merchant_account).await?; Ok(services::ApplicationResponse::Json(response)) } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] pub async fn delete_payment_method_core( state: SessionState, pm_id: id_type::GlobalPaymentMethodId, key_store: domain::MerchantKeyStore, merchant_account: domain::MerchantAccount, ) -> RouterResult<api::PaymentMethodDeleteResponse> { let db = state.store.as_ref(); let key_manager_state = &(&state).into(); let payment_method = db .find_payment_method( &((&state).into()), &key_store, pub async fn delete_payment_method_core( state: SessionState, pm_id: id_type::GlobalPaymentMethodId, key_store: domain::MerchantKeyStore, merchant_account: domain::MerchantAccount, ) -> RouterResult<api::PaymentMethodDeleteResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router ) .await .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to get total payment method count")?; let response = api::TotalPaymentMethodCountResponse { total_count }; Ok(response) } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] pub async fn retrieve_payment_method( state: SessionState, pm: api::PaymentMethodId, key_store: domain::MerchantKeyStore, merchant_account: domain::MerchantAccount, ) -> RouterResponse<api::PaymentMethodResponse> { let db = state.store.as_ref(); let pm_id = id_type::GlobalPaymentMethodId::generate_from_string(pm.payment_method_id) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to generate GlobalPaymentMethodId")?; let payment_method = db .find_payment_method( pub async fn retrieve_payment_method( state: SessionState, pm: api::PaymentMethodId, key_store: domain::MerchantKeyStore, merchant_account: domain::MerchantAccount, ) -> RouterResponse<api::PaymentMethodResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router consts::ID_LENGTH, "token", )), ), }) } }; Ok(payment_method_retrieval_context) } #[cfg(all(feature = "v2", feature = "olap"))] pub async fn list_customer_payment_method_core( state: &SessionState, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, customer_id: &id_type::GlobalCustomerId, ) -> RouterResult<api::CustomerPaymentMethodsListResponse> { let db = &*state.store; let key_manager_state = &(state).into(); let saved_payment_methods = db .find_payment_method_by_global_customer_id_merchant_id_status( key_manager_state, key_store, pub async fn list_customer_payment_method_core( state: &SessionState, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, customer_id: &id_type::GlobalCustomerId, ) -> RouterResult<api::CustomerPaymentMethodsListResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router .map(|data| data.network_token_requestor_reference_id), network_token_locker_id: nt_data.clone().map(|data| data.network_token_locker_id), network_token_payment_method_data: nt_data.map(|data| data.network_token_pmd.into()), connector_mandate_details: connector_mandate_details_update, locker_fingerprint_id: vault_fingerprint_id, }; Ok(pm_update) } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] pub async fn vault_payment_method( state: &SessionState, pmd: &domain::PaymentMethodVaultingData, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, existing_vault_id: Option<domain::VaultId>, customer_id: &id_type::GlobalCustomerId, ) -> RouterResult<(pm_types::AddVaultResponse, String)> { let db = &*state.store; // get fingerprint_id from vault let fingerprint_id_from_vault = vault::get_fingerprint_id_from_vault(state, pmd, customer_id.get_string_repr().to_owned()) pub async fn vault_payment_method( state: &SessionState, pmd: &domain::PaymentMethodVaultingData, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, existing_vault_id: Option<domain::VaultId>, customer_id: &id_type::GlobalCustomerId, ) -> RouterResult<(pm_types::AddVaultResponse, String)> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router reference_record_hash_map, ); hyperswitch_domain_models::mandates::CommonMandateReference { payments: Some(payments_mandate_reference), payouts: None, } } } } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[allow(clippy::too_many_arguments)] pub async fn create_pm_additional_data_update( pmd: Option<&domain::PaymentMethodVaultingData>, state: &SessionState, key_store: &domain::MerchantKeyStore, vault_id: Option<String>, vault_fingerprint_id: Option<String>, payment_method: &domain::PaymentMethod, connector_token_details: Option<payment_methods::ConnectorTokenDetails>, nt_data: Option<NetworkTokenPaymentMethodDetails>, payment_method_type: Option<common_enums::PaymentMethod>, payment_method_subtype: Option<common_enums::PaymentMethodType>, ) -> RouterResult<storage::PaymentMethodUpdate> { let encrypted_payment_method_data = pmd pub async fn create_pm_additional_data_update( pmd: Option<&domain::PaymentMethodVaultingData>, state: &SessionState, key_store: &domain::MerchantKeyStore, vault_id: Option<String>, vault_fingerprint_id: Option<String>, payment_method: &domain::PaymentMethod, connector_token_details: Option<payment_methods::ConnectorTokenDetails>, nt_data: Option<NetworkTokenPaymentMethodDetails>, payment_method_type: Option<common_enums::PaymentMethod>, payment_method_subtype: Option<common_enums::PaymentMethodType>, ) -> RouterResult<storage::PaymentMethodUpdate> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router storage_scheme, ) .await .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to add payment method in db")?; Ok(response) } #[cfg(feature = "v2")] /// Update the connector_mandate_details of the payment method with /// new token details for the payment fn create_connector_token_details_update( token_details: payment_methods::ConnectorTokenDetails, payment_method: &domain::PaymentMethod, ) -> hyperswitch_domain_models::mandates::CommonMandateReference { let connector_id = token_details.connector_id.clone(); let reference_record = hyperswitch_domain_models::mandates::ConnectorTokenReferenceRecord::foreign_from( token_details, ); let connector_token_details = payment_method.connector_mandate_details.clone(); /// Update the connector_mandate_details of the payment method with /// new token details for the payment fn create_connector_token_details_update( token_details: payment_methods::ConnectorTokenDetails, payment_method: &domain::PaymentMethod, ) -> hyperswitch_domain_models::mandates::CommonMandateReference { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router .collect(); payment_methods::PaymentMethodListResponse { payment_methods_enabled: response_payment_methods, customer_payment_methods, } } } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] #[allow(clippy::too_many_arguments)] pub async fn create_payment_method_for_intent( state: &SessionState, metadata: Option<common_utils::pii::SecretSerdeValue>, customer_id: &id_type::GlobalCustomerId, payment_method_id: id_type::GlobalPaymentMethodId, merchant_id: &id_type::MerchantId, key_store: &domain::MerchantKeyStore, storage_scheme: enums::MerchantStorageScheme, payment_method_billing_address: Option< Encryptable<hyperswitch_domain_models::address::Address>, >, ) -> CustomResult<domain::PaymentMethod, errors::ApiErrorResponse> { let db = &*state.store; pub async fn create_payment_method_for_intent( state: &SessionState, metadata: Option<common_utils::pii::SecretSerdeValue>, customer_id: &id_type::GlobalCustomerId, payment_method_id: id_type::GlobalPaymentMethodId, merchant_id: &id_type::MerchantId, key_store: &domain::MerchantKeyStore, storage_scheme: enums::MerchantStorageScheme, payment_method_billing_address: Option< Encryptable<hyperswitch_domain_models::address::Address>, >, ) -> CustomResult<domain::PaymentMethod, errors::ApiErrorResponse> { let db = &*state.store; let current_time = common_utils::date_time::now(); let response = db .insert_payment_method( &state.into(), key_store, domain::PaymentMethod { customer_id: customer_id.to_owned(), merchant_id: merchant_id.to_owned(), id: payment_method_id, locker_id: None, payment_method_type: None, payment_method_subtype: None, payment_method_data: None, connector_mandate_details: None, customer_acceptance: None, client_secret: None, status: enums::PaymentMethodStatus::AwaitingData, network_transaction_id: None, created_at: current_time, last_modified: current_time, last_used_at: current_time, payment_method_billing_address, updated_by: None, version: common_types::consts::API_VERSION, locker_fingerprint_id: None, network_token_locker_id: None, network_token_payment_method_data: None, network_token_requestor_reference_id: None, }, storage_scheme, ) .await .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to add payment method in db")?; Ok(response) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router use hyperswitch_domain_models::mandates::CommonMandateReference; use crate::{ configs::settings, core::{payment_methods::transformers as pm_transforms, payments as payments_core}, db::errors::ConnectorErrorExt, headers, logger, routes::{self, payment_methods as pm_routes}, services::encryption, types::{ self, api::{self, payment_methods::PaymentMethodCreateExt}, domain::types as domain_types, payment_methods as pm_types, storage::{ephemeral_key, PaymentMethodListContext}, transformers::{ForeignFrom, ForeignTryFrom}, Tokenizable, }, utils::ext_traits::OptionExt, }; use crate::{ consts, core::{ errors::{ProcessTrackerError, RouterResult}, payments::helpers as payment_helpers, }, errors, routes::{app::StorageInterface, SessionState}, services, types::{ domain, storage::{self, enums as storage_enums}, }, }; fn get_required_fields( self, input: RequiredFieldsInput, ) -> RequiredFieldsForEnabledPaymentMethodTypes { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router #[cfg(feature = "v2")] impl PerformFilteringOnEnabledPaymentMethods for hyperswitch_domain_models::merchant_connector_account::FlattenedPaymentMethodsEnabled { fn perform_filtering(self) -> FilteredPaymentMethodsEnabled { FilteredPaymentMethodsEnabled(self.payment_methods_enabled) } } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] pub async fn list_payment_methods_for_session( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, profile: domain::Profile, payment_method_session_id: id_type::GlobalPaymentMethodSessionId, ) -> RouterResponse<api::PaymentMethodListResponse> { let key_manager_state = &(&state).into(); let db = &*state.store; let payment_method_session = db .get_payment_methods_session(key_manager_state, &key_store, &payment_method_session_id) pub async fn list_payment_methods_for_session( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, profile: domain::Profile, payment_method_session_id: id_type::GlobalPaymentMethodSessionId, ) -> RouterResponse<api::PaymentMethodListResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router }), card_cvc: card.card_cvc.clone(), }) } } _ => self.clone(), } } } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] pub async fn payment_method_intent_create( state: &SessionState, req: api::PaymentMethodIntentCreate, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, ) -> RouterResponse<api::PaymentMethodResponse> { let db = &*state.store; let merchant_id = merchant_account.get_id(); let customer_id = req.customer_id.to_owned(); let key_manager_state = &(state).into(); db.find_customer_by_global_id( key_manager_state, pub async fn payment_method_intent_create( state: &SessionState, req: api::PaymentMethodIntentCreate, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, ) -> RouterResponse<api::PaymentMethodResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router pub use api_models::enums as api_enums; use api_models::payment_methods; use crate::{ configs::settings, core::{payment_methods::transformers as pm_transforms, payments as payments_core}, db::errors::ConnectorErrorExt, headers, logger, routes::{self, payment_methods as pm_routes}, services::encryption, types::{ self, api::{self, payment_methods::PaymentMethodCreateExt}, domain::types as domain_types, payment_methods as pm_types, storage::{ephemeral_key, PaymentMethodListContext}, transformers::{ForeignFrom, ForeignTryFrom}, Tokenizable, }, utils::ext_traits::OptionExt, }; use crate::{ consts, core::{ errors::{ProcessTrackerError, RouterResult}, payments::helpers as payment_helpers, }, errors, routes::{app::StorageInterface, SessionState}, services, types::{ domain, storage::{self, enums as storage_enums}, }, }; async fn populate_bin_details_for_payment_method(&self, state: &SessionState) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router pub use api_models::enums as api_enums; pub use api_models::enums::Connector; use api_models::payment_methods; pub use api_models::{enums::PayoutConnectors, payouts as payout_types}; use hyperswitch_domain_models::payment_method_data; use crate::{ configs::settings, core::{payment_methods::transformers as pm_transforms, payments as payments_core}, db::errors::ConnectorErrorExt, headers, logger, routes::{self, payment_methods as pm_routes}, services::encryption, types::{ self, api::{self, payment_methods::PaymentMethodCreateExt}, domain::types as domain_types, payment_methods as pm_types, storage::{ephemeral_key, PaymentMethodListContext}, transformers::{ForeignFrom, ForeignTryFrom}, Tokenizable, }, utils::ext_traits::OptionExt, }; use crate::{ consts, core::{ errors::{ProcessTrackerError, RouterResult}, payments::helpers as payment_helpers, }, errors, routes::{app::StorageInterface, SessionState}, services, types::{ domain, storage::{self, enums as storage_enums}, }, }; pub async fn populate_bin_details_for_payment_method( state: &SessionState, payment_method_data: &domain::PaymentMethodVaultingData, ) -> domain::PaymentMethodVaultingData { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router Ok(response) } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[derive(Clone, Debug)] pub struct NetworkTokenPaymentMethodDetails { network_token_requestor_reference_id: String, network_token_locker_id: String, network_token_pmd: Encryptable<Secret<serde_json::Value>>, } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] pub async fn network_tokenize_and_vault_the_pmd( state: &SessionState, payment_method_data: &domain::PaymentMethodVaultingData, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, network_tokenization: Option<common_types::payment_methods::NetworkTokenization>, network_tokenization_enabled_for_profile: bool, customer_id: &id_type::GlobalCustomerId, ) -> Option<NetworkTokenPaymentMethodDetails> { let network_token_pm_details_result: CustomResult< NetworkTokenPaymentMethodDetails, errors::NetworkTokenizationError, > = async { pub async fn network_tokenize_and_vault_the_pmd( state: &SessionState, payment_method_data: &domain::PaymentMethodVaultingData, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, network_tokenization: Option<common_types::payment_methods::NetworkTokenization>, network_tokenization_enabled_for_profile: bool, customer_id: &id_type::GlobalCustomerId, ) -> Option<NetworkTokenPaymentMethodDetails> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router storage::PaymentTokenData::WalletToken(_) => storage::PaymentMethodDataWithId { payment_method: None, payment_method_data: None, payment_method_id: None, }, }; Ok(token) } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] pub(crate) fn get_payment_method_create_request( payment_method_data: &api_models::payments::PaymentMethodData, payment_method_type: storage_enums::PaymentMethod, payment_method_subtype: storage_enums::PaymentMethodType, customer_id: id_type::GlobalCustomerId, billing_address: Option<&api_models::payments::Address>, payment_method_session: Option<&domain::payment_methods::PaymentMethodSession>, ) -> RouterResult<payment_methods::PaymentMethodCreate> { match payment_method_data { api_models::payments::PaymentMethodData::Card(card) => { let card_detail = payment_methods::CardDetail { card_number: card.card_number.clone(), card_exp_month: card.card_exp_month.clone(), pub(crate) fn get_payment_method_create_request( payment_method_data: &api_models::payments::PaymentMethodData, payment_method_type: storage_enums::PaymentMethod, payment_method_subtype: storage_enums::PaymentMethodType, customer_id: id_type::GlobalCustomerId, billing_address: Option<&api_models::payments::Address>, payment_method_session: Option<&domain::payment_methods::PaymentMethodSession>, ) -> RouterResult<payment_methods::PaymentMethodCreate> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router fn generate_task_id_for_payment_method_status_update_workflow( key_id: &str, runner: storage::ProcessTrackerRunner, task: &str, ) -> String { format!("{runner}_{task}_{key_id}") } #[cfg(all( any(feature = "v1", feature = "v2"), not(feature = "payment_methods_v2") ))] pub async fn add_payment_method_status_update_task( db: &dyn StorageInterface, payment_method: &domain::PaymentMethod, prev_status: enums::PaymentMethodStatus, curr_status: enums::PaymentMethodStatus, merchant_id: &id_type::MerchantId, ) -> Result<(), ProcessTrackerError> { let created_at = payment_method.created_at; let schedule_time = created_at.saturating_add(Duration::seconds(consts::DEFAULT_SESSION_EXPIRY)); let tracking_data = storage::PaymentMethodStatusTrackingData { payment_method_id: payment_method.get_id().clone(), pub async fn add_payment_method_status_update_task( db: &dyn StorageInterface, payment_method: &domain::PaymentMethod, prev_status: enums::PaymentMethodStatus, curr_status: enums::PaymentMethodStatus, merchant_id: &id_type::MerchantId, ) -> Result<(), ProcessTrackerError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable_lazy(|| { format!("Failed to parse the payment method collect link - {}", url) })? .into(), return_url: pm_collect_link.return_url, ui_config: pm_collect_link.link_data.ui_config, enabled_payment_methods: pm_collect_link.link_data.enabled_payment_methods, }; Ok(services::ApplicationResponse::Json(response)) } pub async fn create_pm_collect_db_entry( state: &SessionState, merchant_account: &domain::MerchantAccount, pm_collect_link_data: &PaymentMethodCollectLinkData, return_url: Option<String>, ) -> RouterResult<PaymentMethodCollectLink> { let db: &dyn StorageInterface = &*state.store; let link_data = serde_json::to_value(pm_collect_link_data) .map_err(|_| report!(errors::ApiErrorResponse::InternalServerError)) .attach_printable("Failed to convert PaymentMethodCollectLinkData to Value")?; let pm_collect_link = GenericLinkNew { pub async fn create_pm_collect_db_entry( state: &SessionState, merchant_account: &domain::MerchantAccount, pm_collect_link_data: &PaymentMethodCollectLinkData, return_url: Option<String>, ) -> RouterResult<PaymentMethodCollectLink> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router pm, merchant_key_store, business_profile, ) .await?; Ok((pm_opt.to_owned(), payment_token)) } _ => Ok((None, None)), } } pub async fn initiate_pm_collect_link( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, req: payment_methods::PaymentMethodCollectLinkRequest, ) -> RouterResponse<payment_methods::PaymentMethodCollectLinkResponse> { // Validate request and initiate flow let pm_collect_link_data = validator::validate_request_and_initiate_payment_method_collect_link( &state, &merchant_account, &key_store, &req, pub async fn initiate_pm_collect_link( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, req: payment_methods::PaymentMethodCollectLinkRequest, ) -> RouterResponse<payment_methods::PaymentMethodCollectLinkResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router .collect(); payment_methods::PaymentMethodListResponse { payment_methods_enabled: response_payment_methods, customer_payment_methods, } } } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] #[allow(clippy::too_many_arguments)] pub async fn create_payment_method_for_intent( state: &SessionState, metadata: Option<common_utils::pii::SecretSerdeValue>, customer_id: &id_type::GlobalCustomerId, payment_method_id: id_type::GlobalPaymentMethodId, merchant_id: &id_type::MerchantId, key_store: &domain::MerchantKeyStore, storage_scheme: enums::MerchantStorageScheme, payment_method_billing_address: Option< Encryptable<hyperswitch_domain_models::address::Address>, >, ) -> CustomResult<domain::PaymentMethod, errors::ApiErrorResponse> { let db = &*state.store; pub async fn create_payment_method_for_intent( state: &SessionState, metadata: Option<common_utils::pii::SecretSerdeValue>, customer_id: &id_type::GlobalCustomerId, payment_method_id: id_type::GlobalPaymentMethodId, merchant_id: &id_type::MerchantId, key_store: &domain::MerchantKeyStore, storage_scheme: enums::MerchantStorageScheme, payment_method_billing_address: Option< Encryptable<hyperswitch_domain_models::address::Address>, >, ) -> CustomResult<domain::PaymentMethod, errors::ApiErrorResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router use crate::{ configs::settings, core::{payment_methods::transformers as pm_transforms, payments as payments_core}, db::errors::ConnectorErrorExt, headers, logger, routes::{self, payment_methods as pm_routes}, services::encryption, types::{ self, api::{self, payment_methods::PaymentMethodCreateExt}, domain::types as domain_types, payment_methods as pm_types, storage::{ephemeral_key, PaymentMethodListContext}, transformers::{ForeignFrom, ForeignTryFrom}, Tokenizable, }, utils::ext_traits::OptionExt, }; fn new(required_fields_config: settings::RequiredFields) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router .serialize_and_set_key_with_expiry( &payment_method_data::SingleUseTokenKey::get_store_key(&key).into(), value, consts::DEFAULT_PAYMENT_METHOD_STORE_TTL, ) .await .change_context(errors::StorageError::KVError) .attach_printable("Failed to insert payment method token to redis")?; Ok(()) } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] async fn get_single_use_token_from_store( state: &SessionState, key: payment_method_data::SingleUseTokenKey, ) -> CustomResult<Option<payment_method_data::SingleUsePaymentMethodToken>, errors::StorageError> { let redis_connection = state .store .get_redis_conn() .map_err(Into::<errors::StorageError>::into)?; redis_connection .get_and_deserialize_key::<Option<payment_method_data::SingleUsePaymentMethodToken>>( &payment_method_data::SingleUseTokenKey::get_store_key(&key).into(), "SingleUsePaymentMethodToken", async fn get_single_use_token_from_store( state: &SessionState, key: payment_method_data::SingleUseTokenKey, ) -> CustomResult<Option<payment_method_data::SingleUsePaymentMethodToken>, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router let key = payment_method_data::SingleUseTokenKey::store_key(&payment_method.id); add_single_use_token_to_store(&state, key, value) .await .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to store single use token")?; Ok(()) } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] async fn add_single_use_token_to_store( state: &SessionState, key: payment_method_data::SingleUseTokenKey, value: payment_method_data::SingleUsePaymentMethodToken, ) -> CustomResult<(), errors::StorageError> { let redis_connection = state .store .get_redis_conn() .map_err(Into::<errors::StorageError>::into)?; redis_connection .serialize_and_set_key_with_expiry( &payment_method_data::SingleUseTokenKey::get_store_key(&key).into(), async fn add_single_use_token_to_store( state: &SessionState, key: payment_method_data::SingleUseTokenKey, value: payment_method_data::SingleUsePaymentMethodToken, ) -> CustomResult<(), errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router let is_connector_agnostic_mit_enabled = profile.is_connector_agnostic_mit_enabled.unwrap_or(false); Ok(Self { payment_intent, profile, collect_cvv_during_payment, off_session_payment_flag, is_connector_agnostic_mit_enabled, }) } pub async fn perform_payment_ops( &self, state: &SessionState, parent_payment_method_token: Option<String>, pma: &api::CustomerPaymentMethod, pm_list_context: PaymentMethodListContext, ) -> RouterResult<()> { let token = parent_payment_method_token .as_ref() .get_required_value("parent_payment_method_token")?; let token_data = pm_list_context .get_token_data() .get_required_value("PaymentTokenData")?; pub async fn perform_payment_ops( &self, state: &SessionState, parent_payment_method_token: Option<String>, pma: &api::CustomerPaymentMethod, pm_list_context: PaymentMethodListContext, ) -> RouterResult<()> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router &merchant_account, &key_store, payment_method_update_request, &request.payment_method_id, ) .await .attach_printable("Failed to update saved payment method")?; Ok(services::ApplicationResponse::Json(updated_payment_method)) } #[cfg(feature = "v2")] pub async fn payment_methods_session_delete_payment_method( state: SessionState, key_store: domain::MerchantKeyStore, merchant_account: domain::MerchantAccount, pm_id: id_type::GlobalPaymentMethodId, payment_method_session_id: id_type::GlobalPaymentMethodSessionId, ) -> RouterResponse<api::PaymentMethodDeleteResponse> { let db = state.store.as_ref(); let key_manager_state = &(&state).into(); // Validate if the session still exists db.get_payment_methods_session(key_manager_state, &key_store, &payment_method_session_id) .await pub async fn payment_methods_session_delete_payment_method( state: SessionState, key_store: domain::MerchantKeyStore, merchant_account: domain::MerchantAccount, pm_id: id_type::GlobalPaymentMethodId, payment_method_session_id: id_type::GlobalPaymentMethodSessionId, ) -> RouterResponse<api::PaymentMethodDeleteResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to update payment methods session in db")?; let response = transformers::generate_payment_method_session_response( update_state_change, Secret::new("CLIENT_SECRET_REDACTED".to_string()), None, // TODO: send associated payments response based on the expandable param ); Ok(services::ApplicationResponse::Json(response)) } #[cfg(feature = "v2")] pub async fn payment_methods_session_retrieve( state: SessionState, _merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, payment_method_session_id: id_type::GlobalPaymentMethodSessionId, ) -> RouterResponse<payment_methods::PaymentMethodSessionResponse> { let db = state.store.as_ref(); let key_manager_state = &(&state).into(); let payment_method_session_domain_model = db .get_payment_methods_session(key_manager_state, &key_store, &payment_method_session_id) .await .to_not_found_response(errors::ApiErrorResponse::GenericNotFoundError { pub async fn payment_methods_session_retrieve( state: SessionState, _merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, payment_method_session_id: id_type::GlobalPaymentMethodSessionId, ) -> RouterResponse<payment_methods::PaymentMethodSessionResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to update payment method in db")?; let response = pm_transforms::generate_payment_method_response(&payment_method, &None)?; // Add a PT task to handle payment_method delete from vault Ok(response) } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] pub async fn delete_payment_method( state: SessionState, pm_id: api::PaymentMethodId, key_store: domain::MerchantKeyStore, merchant_account: domain::MerchantAccount, ) -> RouterResponse<api::PaymentMethodDeleteResponse> { let pm_id = id_type::GlobalPaymentMethodId::generate_from_string(pm_id.payment_method_id) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to generate GlobalPaymentMethodId")?; let response = delete_payment_method_core(state, pm_id, key_store, merchant_account).await?; Ok(services::ApplicationResponse::Json(response)) } pub async fn delete_payment_method( state: SessionState, pm_id: api::PaymentMethodId, key_store: domain::MerchantKeyStore, merchant_account: domain::MerchantAccount, ) -> RouterResponse<api::PaymentMethodDeleteResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router &state.clone(), payment_method_data::SingleUseTokenKey::store_key(&pm_id.clone()), ) .await .unwrap_or_default(); transformers::generate_payment_method_response(&payment_method, &single_use_token_in_cache) .map(services::ApplicationResponse::Json) } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] pub async fn update_payment_method( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, req: api::PaymentMethodUpdate, payment_method_id: &id_type::GlobalPaymentMethodId, ) -> RouterResponse<api::PaymentMethodResponse> { let response = update_payment_method_core( &state, &merchant_account, &key_store, req, payment_method_id, pub async fn update_payment_method( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, req: api::PaymentMethodUpdate, payment_method_id: &id_type::GlobalPaymentMethodId, ) -> RouterResponse<api::PaymentMethodResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router .map(ForeignTryFrom::foreign_try_from) .collect::<Result<Vec<api::CustomerPaymentMethod>, _>>() .change_context(errors::ApiErrorResponse::InternalServerError)?; let response = api::CustomerPaymentMethodsListResponse { customer_payment_methods, }; Ok(response) } #[cfg(all(feature = "v2", feature = "olap"))] pub async fn get_total_payment_method_count_core( state: &SessionState, merchant_account: &domain::MerchantAccount, ) -> RouterResult<api::TotalPaymentMethodCountResponse> { let db = &*state.store; let total_count = db .get_payment_method_count_by_merchant_id_status( merchant_account.get_id(), common_enums::PaymentMethodStatus::Active, ) .await .change_context(errors::ApiErrorResponse::InternalServerError) pub async fn get_total_payment_method_count_core( state: &SessionState, merchant_account: &domain::MerchantAccount, ) -> RouterResult<api::TotalPaymentMethodCountResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router use api_models::payment_methods; use crate::{ configs::settings, core::{payment_methods::transformers as pm_transforms, payments as payments_core}, db::errors::ConnectorErrorExt, headers, logger, routes::{self, payment_methods as pm_routes}, services::encryption, types::{ self, api::{self, payment_methods::PaymentMethodCreateExt}, domain::types as domain_types, payment_methods as pm_types, storage::{ephemeral_key, PaymentMethodListContext}, transformers::{ForeignFrom, ForeignTryFrom}, Tokenizable, }, utils::ext_traits::OptionExt, }; use crate::{ consts, core::{ errors::{ProcessTrackerError, RouterResult}, payments::helpers as payment_helpers, }, errors, routes::{app::StorageInterface, SessionState}, services, types::{ domain, storage::{self, enums as storage_enums}, }, }; fn generate_response( self, customer_payment_methods: Vec<payment_methods::CustomerPaymentMethod>, ) -> payment_methods::PaymentMethodListResponse { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router use hyperswitch_domain_models::api::{GenericLinks, GenericLinksData}; use hyperswitch_domain_models::mandates::CommonMandateReference; use hyperswitch_domain_models::payment_method_data; use hyperswitch_domain_models::payments::{ payment_attempt::PaymentAttempt, PaymentIntent, VaultData, }; use crate::{ configs::settings, core::{payment_methods::transformers as pm_transforms, payments as payments_core}, db::errors::ConnectorErrorExt, headers, logger, routes::{self, payment_methods as pm_routes}, services::encryption, types::{ self, api::{self, payment_methods::PaymentMethodCreateExt}, domain::types as domain_types, payment_methods as pm_types, storage::{ephemeral_key, PaymentMethodListContext}, transformers::{ForeignFrom, ForeignTryFrom}, Tokenizable, }, utils::ext_traits::OptionExt, }; use crate::{ consts, core::{ errors::{ProcessTrackerError, RouterResult}, payments::helpers as payment_helpers, }, errors, routes::{app::StorageInterface, SessionState}, services, types::{ domain, storage::{self, enums as storage_enums}, }, }; fn get_required_fields( &self, payment_method_enabled: &hyperswitch_domain_models::merchant_connector_account::PaymentMethodsEnabledForConnector, ) -> Option<&settings::RequiredFieldFinal> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router use crate::{ configs::settings, core::{payment_methods::transformers as pm_transforms, payments as payments_core}, db::errors::ConnectorErrorExt, headers, logger, routes::{self, payment_methods as pm_routes}, services::encryption, types::{ self, api::{self, payment_methods::PaymentMethodCreateExt}, domain::types as domain_types, payment_methods as pm_types, storage::{ephemeral_key, PaymentMethodListContext}, transformers::{ForeignFrom, ForeignTryFrom}, Tokenizable, }, utils::ext_traits::OptionExt, }; fn new(required_fields_config: settings::RequiredFields) -> Self { Self { required_fields_config, } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router ) -> RouterResponse<api::CustomerPaymentMethodsListResponse> { let customer_payment_methods = list_customer_payment_method_core(&state, &merchant_account, &key_store, &customer_id) .await?; Ok(hyperswitch_domain_models::api::ApplicationResponse::Json( customer_payment_methods, )) } #[cfg(all(feature = "v2", feature = "olap"))] #[instrument(skip_all)] pub async fn get_total_saved_payment_methods_for_merchant( state: SessionState, merchant_account: domain::MerchantAccount, ) -> RouterResponse<api::TotalPaymentMethodCountResponse> { let total_payment_method_count = get_total_payment_method_count_core(&state, &merchant_account).await?; Ok(hyperswitch_domain_models::api::ApplicationResponse::Json( total_payment_method_count, )) } #[cfg(feature = "v2")] pub async fn get_total_saved_payment_methods_for_merchant( state: SessionState, merchant_account: domain::MerchantAccount, ) -> RouterResponse<api::TotalPaymentMethodCountResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router hyperswitch_domain_models::merchant_connector_account::FlattenedPaymentMethodsEnabled::from_payment_connectors_list(payment_connector_accounts) .perform_filtering() .get_required_fields(RequiredFieldsInput::new(state.conf.required_fields.clone())) .generate_response(customer_payment_methods.customer_payment_methods); Ok(hyperswitch_domain_models::api::ApplicationResponse::Json( response, )) } #[cfg(all(feature = "v2", feature = "olap"))] #[instrument(skip_all)] pub async fn list_saved_payment_methods_for_customer( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, customer_id: id_type::GlobalCustomerId, ) -> RouterResponse<api::CustomerPaymentMethodsListResponse> { let customer_payment_methods = list_customer_payment_method_core(&state, &merchant_account, &key_store, &customer_id) .await?; Ok(hyperswitch_domain_models::api::ApplicationResponse::Json( customer_payment_methods, )) pub async fn list_saved_payment_methods_for_customer( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, customer_id: id_type::GlobalCustomerId, ) -> RouterResponse<api::CustomerPaymentMethodsListResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router }) .attach_printable("PaymentMethodType Required")), }, None => Err(report!(errors::ApiErrorResponse::MissingRequiredField { field_name: "payment_method_data" }) .attach_printable("PaymentMethodData required Or Card is already saved")), } } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] pub async fn create_payment_method( state: &SessionState, request_state: &routes::app::ReqState, req: api::PaymentMethodCreate, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, profile: &domain::Profile, ) -> RouterResponse<api::PaymentMethodResponse> { let response = create_payment_method_core( state, request_state, req, merchant_account, pub async fn create_payment_method( state: &SessionState, request_state: &routes::app::ReqState, req: api::PaymentMethodCreate, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, profile: &domain::Profile, ) -> RouterResponse<api::PaymentMethodResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router format!( "Failed while inserting PAYMENT_METHOD_STATUS_UPDATE reminder to process_tracker for payment_method_id: {}", payment_method.get_id().clone() ) })?; Ok(()) } #[cfg(feature = "v2")] #[allow(clippy::too_many_arguments)] #[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, _mandate_id: Option<api_models::payments::MandateIds>, _payment_method_info: Option<domain::PaymentMethod>, _business_profile: &domain::Profile, ) -> RouterResult<storage::PaymentMethodDataWithId> { todo!() 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, _mandate_id: Option<api_models::payments::MandateIds>, _payment_method_info: Option<domain::PaymentMethod>, _business_profile: &domain::Profile, ) -> RouterResult<storage::PaymentMethodDataWithId> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router use std::str::FromStr; use crate::{ configs::settings, core::{payment_methods::transformers as pm_transforms, payments as payments_core}, db::errors::ConnectorErrorExt, headers, logger, routes::{self, payment_methods as pm_routes}, services::encryption, types::{ self, api::{self, payment_methods::PaymentMethodCreateExt}, domain::types as domain_types, payment_methods as pm_types, storage::{ephemeral_key, PaymentMethodListContext}, transformers::{ForeignFrom, ForeignTryFrom}, Tokenizable, }, utils::ext_traits::OptionExt, }; use crate::{ consts, core::{ errors::{ProcessTrackerError, RouterResult}, payments::helpers as payment_helpers, }, errors, routes::{app::StorageInterface, SessionState}, services, types::{ domain, storage::{self, enums as storage_enums}, }, }; fn generate_task_id_for_payment_method_status_update_workflow( key_id: &str, runner: storage::ProcessTrackerRunner, task: &str, ) -> String { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router + Duration::seconds(pm_collect_link_data.session_expiry.into()), ..Default::default() }; db.insert_pm_collect_link(pm_collect_link) .await .to_duplicate_response(errors::ApiErrorResponse::GenericDuplicateError { message: "payment method collect link already exists".to_string(), }) } #[cfg(all(feature = "v2", feature = "customer_v2"))] pub async fn render_pm_collect_link( _state: SessionState, _merchant_account: domain::MerchantAccount, _key_store: domain::MerchantKeyStore, _req: payment_methods::PaymentMethodCollectLinkRenderRequest, ) -> RouterResponse<services::GenericLinkFormData> { todo!() } #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] pub async fn render_pm_collect_link( state: SessionState, merchant_account: domain::MerchantAccount, pub async fn render_pm_collect_link( _state: SessionState, _merchant_account: domain::MerchantAccount, _key_store: domain::MerchantKeyStore, _req: payment_methods::PaymentMethodCollectLinkRenderRequest, ) -> RouterResponse<services::GenericLinkFormData> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router .unwrap_or(common_utils::consts::DEFAULT_INTENT_FULFILLMENT_TIME); pm_routes::ParentPaymentMethodToken::create_key_for_token((token, pma.payment_method_type)) .insert(intent_fulfillment_time, token_data, state) .await?; Ok(()) } } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[allow(clippy::too_many_arguments)] async fn create_single_use_tokenization_flow( state: SessionState, req_state: routes::app::ReqState, merchant_account: domain::MerchantAccount, profile: domain::Profile, key_store: domain::MerchantKeyStore, payment_method_create_request: &payment_methods::PaymentMethodCreate, payment_method: &api::PaymentMethodResponse, payment_method_session: &domain::payment_methods::PaymentMethodSession, ) -> RouterResult<()> { let customer_id = payment_method_create_request.customer_id.to_owned(); let connector_id = payment_method_create_request .get_tokenize_connector_id() async fn create_single_use_tokenization_flow( state: SessionState, req_state: routes::app::ReqState, merchant_account: domain::MerchantAccount, profile: domain::Profile, key_store: domain::MerchantKeyStore, payment_method_create_request: &payment_methods::PaymentMethodCreate, payment_method: &api::PaymentMethodResponse, payment_method_session: &domain::payment_methods::PaymentMethodSession, ) -> RouterResult<()> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router )) .await?; logger::info!(associated_payments_response=?response); response .get_json_body() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unexpected response from payments core") } #[cfg(feature = "v2")] pub async fn payment_methods_session_confirm( state: SessionState, req_state: routes::app::ReqState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, profile: domain::Profile, payment_method_session_id: id_type::GlobalPaymentMethodSessionId, request: payment_methods::PaymentMethodSessionConfirmRequest, ) -> RouterResponse<payment_methods::PaymentMethodSessionResponse> { let db: &dyn StorageInterface = state.store.as_ref(); let key_manager_state = &(&state).into(); // Validate if the session still exists pub async fn payment_methods_session_confirm( state: SessionState, req_state: routes::app::ReqState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, profile: domain::Profile, payment_method_session_id: id_type::GlobalPaymentMethodSessionId, request: payment_methods::PaymentMethodSessionConfirmRequest, ) -> RouterResponse<payment_methods::PaymentMethodSessionResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router let encrypted_data = hyperswitch_domain_models::payment_methods::FromRequestEncryptablePaymentMethodSession::from_encryptable( batch_encrypted_data, ) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed while encrypting payment methods session detailss")?; Ok(encrypted_data) } } #[cfg(feature = "v2")] pub async fn payment_methods_session_create( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, request: payment_methods::PaymentMethodSessionRequest, ) -> RouterResponse<payment_methods::PaymentMethodSessionResponse> { let db = state.store.as_ref(); let key_manager_state = &(&state).into(); db.find_customer_by_global_id( key_manager_state, &request.customer_id, merchant_account.get_id(), pub async fn payment_methods_session_create( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, request: payment_methods::PaymentMethodSessionRequest, ) -> RouterResponse<payment_methods::PaymentMethodSessionResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router &merchant_account, &key_store, req, payment_method_id, ) .await?; Ok(services::ApplicationResponse::Json(response)) } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] pub async fn update_payment_method_core( state: &SessionState, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, request: api::PaymentMethodUpdate, payment_method_id: &id_type::GlobalPaymentMethodId, ) -> RouterResult<api::PaymentMethodResponse> { let db = state.store.as_ref(); let payment_method = db .find_payment_method( &((state).into()), key_store, pub async fn update_payment_method_core( state: &SessionState, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, request: api::PaymentMethodUpdate, payment_method_id: &id_type::GlobalPaymentMethodId, ) -> RouterResult<api::PaymentMethodResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router .attach_printable("Failed to add payment method in vault")?; Ok((resp_from_vault, fingerprint_id_from_vault)) } // TODO: check if this function will be used for listing the customer payment methods for payments #[allow(unused)] #[cfg(all( feature = "v2", feature = "payment_methods_v2", feature = "customer_v2" ))] fn get_pm_list_context( payment_method_type: enums::PaymentMethod, payment_method: &domain::PaymentMethod, is_payment_associated: bool, ) -> Result<Option<PaymentMethodListContext>, error_stack::Report<errors::ApiErrorResponse>> { let payment_method_data = payment_method .payment_method_data .clone() .map(|payment_method_data| payment_method_data.into_inner()); let payment_method_retrieval_context = match payment_method_data { Some(payment_methods::PaymentMethodsData::Card(card)) => { Some(PaymentMethodListContext::Card { fn get_pm_list_context( payment_method_type: enums::PaymentMethod, payment_method: &domain::PaymentMethod, is_payment_associated: bool, ) -> Result<Option<PaymentMethodListContext>, error_stack::Report<errors::ApiErrorResponse>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router req, merchant_account, key_store, profile, ) .await?; Ok(services::ApplicationResponse::Json(response)) } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] pub async fn create_payment_method_core( state: &SessionState, _request_state: &routes::app::ReqState, req: api::PaymentMethodCreate, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, profile: &domain::Profile, ) -> RouterResult<api::PaymentMethodResponse> { use common_utils::ext_traits::ValueExt; req.validate()?; let db = &*state.store; pub async fn create_payment_method_core( state: &SessionState, _request_state: &routes::app::ReqState, req: api::PaymentMethodCreate, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, profile: &domain::Profile, ) -> RouterResult<api::PaymentMethodResponse> { { Ok((vaulting_resp, fingerprint_id)) => { let pm_update = create_pm_additional_data_update( Some(&payment_method_data), state, key_store, Some(vaulting_resp.vault_id.get_string_repr().clone()), Some(fingerprint_id), &payment_method, None, network_tokenization_resp, Some(req.payment_method_type), Some(req.payment_method_subtype), ) .await .attach_printable("Unable to create Payment method data")?; let payment_method = db .update_payment_method( &(state.into()), key_store, payment_method, pm_update, merchant_account.storage_scheme, ) .await .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to update payment method in db")?; let resp = pm_transforms::generate_payment_method_response(&payment_method, &None)?; Ok((resp, payment_method)) }<|fim_suffix|> <|fim_middle|> Err(e) => { let pm_update = storage::PaymentMethodUpdate::StatusUpdate { status: Some(enums::PaymentMethodStatus::Inactive), }; db.update_payment_method( &(state.into()), key_store, payment_method, pm_update, merchant_account.storage_scheme, ) .await .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to update payment method in db")?; Err(e) } } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router _ => Err(report!(errors::ApiErrorResponse::UnprocessableEntity { message: "only card payment methods are supported for tokenization".to_string() }) .attach_printable("Payment method data is incorrect")), } } #[cfg(all( any(feature = "v1", feature = "v2"), not(feature = "payment_methods_v2") ))] #[instrument(skip_all)] pub(crate) async fn get_payment_method_create_request( payment_method_data: Option<&domain::PaymentMethodData>, payment_method: Option<storage_enums::PaymentMethod>, payment_method_type: Option<storage_enums::PaymentMethodType>, customer_id: &Option<id_type::CustomerId>, billing_name: Option<Secret<String>>, payment_method_billing_address: Option<&hyperswitch_domain_models::address::Address>, ) -> RouterResult<payment_methods::PaymentMethodCreate> { match payment_method_data { Some(pm_data) => match payment_method { Some(payment_method) => match pm_data { domain::PaymentMethodData::Card(card) => { let card_detail = payment_methods::CardDetail { pub(crate) async fn get_payment_method_create_request( payment_method_data: Option<&domain::PaymentMethodData>, payment_method: Option<storage_enums::PaymentMethod>, payment_method_type: Option<storage_enums::PaymentMethodType>, customer_id: &Option<id_type::CustomerId>, billing_name: Option<Secret<String>>, payment_method_billing_address: Option<&hyperswitch_domain_models::address::Address>, ) -> RouterResult<payment_methods::PaymentMethodCreate> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router routes::{app::StorageInterface, SessionState}, services, types::{ domain, storage::{self, enums as storage_enums}, }, }; const PAYMENT_METHOD_STATUS_UPDATE_TASK: &str = "PAYMENT_METHOD_STATUS_UPDATE"; const PAYMENT_METHOD_STATUS_TAG: &str = "PAYMENT_METHOD_STATUS"; #[instrument(skip_all)] pub async fn retrieve_payment_method_core( pm_data: &Option<domain::PaymentMethodData>, state: &SessionState, payment_intent: &PaymentIntent, payment_attempt: &PaymentAttempt, merchant_key_store: &domain::MerchantKeyStore, business_profile: Option<&domain::Profile>, ) -> RouterResult<(Option<domain::PaymentMethodData>, Option<String>)> { match pm_data { pm_opt @ Some(pm @ domain::PaymentMethodData::Card(_)) => { let payment_token = payment_helpers::store_payment_method_data_in_vault( state, payment_attempt, pub async fn retrieve_payment_method_core( pm_data: &Option<domain::PaymentMethodData>, state: &SessionState, payment_intent: &PaymentIntent, payment_attempt: &PaymentAttempt, merchant_key_store: &domain::MerchantKeyStore, business_profile: Option<&domain::Profile>, ) -> RouterResult<(Option<domain::PaymentMethodData>, Option<String>)> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router _payment_method_info: Option<domain::PaymentMethod>, _business_profile: &domain::Profile, ) -> RouterResult<storage::PaymentMethodDataWithId> { todo!() } #[cfg(all( any(feature = "v1", feature = "v2"), not(feature = "payment_methods_v2") ))] #[instrument(skip_all)] #[allow(clippy::too_many_arguments)] pub async fn retrieve_payment_method_with_token( state: &SessionState, merchant_key_store: &domain::MerchantKeyStore, token_data: &storage::PaymentTokenData, payment_intent: &PaymentIntent, payment_attempt: &PaymentAttempt, card_token_data: Option<&domain::CardToken>, customer: &Option<domain::Customer>, storage_scheme: common_enums::enums::MerchantStorageScheme, mandate_id: Option<api_models::payments::MandateIds>, payment_method_info: Option<domain::PaymentMethod>, business_profile: &domain::Profile, should_retry_with_pan: bool, pub async fn retrieve_payment_method_with_token( state: &SessionState, merchant_key_store: &domain::MerchantKeyStore, token_data: &storage::PaymentTokenData, payment_intent: &PaymentIntent, payment_attempt: &PaymentAttempt, card_token_data: Option<&domain::CardToken>, customer: &Option<domain::Customer>, storage_scheme: common_enums::enums::MerchantStorageScheme, mandate_id: Option<api_models::payments::MandateIds>, payment_method_info: Option<domain::PaymentMethod>, business_profile: &domain::Profile, should_retry_with_pan: bool, vault_data: Option<&VaultData>, ) -> RouterResult<storage::PaymentMethodDataWithId> { { storage::PaymentTokenData::TemporaryGeneric(generic_token) => { payment_helpers::retrieve_payment_method_with_temporary_token( state, &generic_token.token, payment_intent, payment_attempt, merchant_key_store, card_token_data, ) .await? .map( |(payment_method_data, payment_method)| storage::PaymentMethodDataWithId { payment_method_data: Some(payment_method_data), payment_method: Some(payment_method), payment_method_id: None, }, ) .unwrap_or_default() }<|fim_suffix|> <|fim_middle|> storage::PaymentTokenData::WalletToken(_) => storage::PaymentMethodDataWithId { payment_method: None, payment_method_data: None, payment_method_id: None, }, } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_methods.rs | crate: router #[cfg(all(feature = "v2", feature = "customer_v2"))] pub async fn render_pm_collect_link( _state: SessionState, _merchant_account: domain::MerchantAccount, _key_store: domain::MerchantKeyStore, _req: payment_methods::PaymentMethodCollectLinkRenderRequest, ) -> RouterResponse<services::GenericLinkFormData> { todo!() } #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] pub async fn render_pm_collect_link( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, req: payment_methods::PaymentMethodCollectLinkRenderRequest, ) -> RouterResponse<services::GenericLinkFormData> { let db: &dyn StorageInterface = &*state.store; // Fetch pm collect link let pm_collect_link = db .find_pm_collect_link_by_link_id(&req.pm_collect_link_id) .await .to_not_found_response(errors::ApiErrorResponse::GenericNotFoundError { pub async fn render_pm_collect_link( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, req: payment_methods::PaymentMethodCollectLinkRenderRequest, ) -> RouterResponse<services::GenericLinkFormData> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use scheduler::{consumer::types::process_data, utils as process_tracker_utils}; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn get_refund_sync_process_schedule_time( db: &dyn db::StorageInterface, connector: &str, merchant_id: &common_utils::id_type::MerchantId, retry_count: i32, ) -> Result<Option<time::PrimitiveDateTime>, errors::ProcessTrackerError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use diesel_models::process_tracker::business_status; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn add_refund_execute_task( db: &dyn db::StorageInterface, refund: &storage::Refund, runner: storage::ProcessTrackerRunner, ) -> RouterResult<storage::ProcessTracker> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use diesel_models::process_tracker::business_status; use router_env::{instrument, tracing}; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn add_refund_sync_task( db: &dyn db::StorageInterface, refund: &storage::Refund, runner: storage::ProcessTrackerRunner, ) -> RouterResult<storage::ProcessTracker> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use diesel_models::process_tracker::business_status; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn sync_refund_with_gateway_workflow( state: &SessionState, refund_tracker: &storage::ProcessTracker, ) -> Result<(), errors::ProcessTrackerError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use std::collections::HashMap; use api_models::admin::MerchantConnectorInfo; use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use scheduler::{consumer::types::process_data, utils as process_tracker_utils}; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn get_aggregates_for_refunds( state: SessionState, merchant: domain::MerchantAccount, profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>, time_range: common_utils::types::TimeRange, ) -> RouterResponse<api_models::refunds::RefundAggregateResponse> { let db = state.store.as_ref(); let refund_status_with_count = db .get_refund_status_with_count( merchant.get_id(), profile_id_list, &time_range, merchant.storage_scheme, ) .await .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to find status count")?; let mut status_map: HashMap<enums::RefundStatus, i64> = refund_status_with_count.into_iter().collect(); for status in enums::RefundStatus::iter() { status_map.entry(status).or_default(); } Ok(services::ApplicationResponse::Json( api_models::refunds::RefundAggregateResponse { status_with_count: status_map, }, )) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use std::collections::HashMap; use api_models::admin::MerchantConnectorInfo; use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn get_filters_for_refunds( state: SessionState, merchant_account: domain::MerchantAccount, profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>, ) -> RouterResponse<api_models::refunds::RefundListFilters> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use api_models::admin::MerchantConnectorInfo; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn refund_manual_update( state: SessionState, req: api_models::refunds::RefundManualUpdateRequest, ) -> RouterResponse<serde_json::Value> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn refund_retrieve_core_with_refund_id( state: SessionState, merchant_account: domain::MerchantAccount, profile_id: Option<common_utils::id_type::ProfileId>, key_store: domain::MerchantKeyStore, request: refunds::RefundsRetrieveRequest, ) -> RouterResult<storage::Refund> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn refund_retrieve_core_with_internal_reference_id( state: SessionState, merchant_account: domain::MerchantAccount, profile_id: Option<common_utils::id_type::ProfileId>, key_store: domain::MerchantKeyStore, refund_internal_request_id: String, force_sync: Option<bool>, ) -> RouterResult<storage::Refund> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use api_models::admin::MerchantConnectorInfo; use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn refund_list( state: SessionState, merchant_account: domain::MerchantAccount, profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>, req: api_models::refunds::RefundListRequest, ) -> RouterResponse<api_models::refunds::RefundListResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn refund_update_core( state: SessionState, merchant_account: domain::MerchantAccount, req: refunds::RefundUpdateRequest, ) -> RouterResponse<refunds::RefundResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router .insert_process(process_tracker_entry) .await .to_duplicate_response(errors::ApiErrorResponse::DuplicateRefundRequest) .attach_printable_lazy(|| { format!( "Failed while inserting task in process_tracker: refund_id: {}", refund.refund_id ) })?; Ok(response) } pub async fn get_refund_sync_process_schedule_time( db: &dyn db::StorageInterface, connector: &str, merchant_id: &common_utils::id_type::MerchantId, retry_count: i32, ) -> Result<Option<time::PrimitiveDateTime>, errors::ProcessTrackerError> { let redis_mapping: errors::CustomResult<process_data::ConnectorPTMapping, errors::RedisError> = db::get_and_deserialize_key( db, &format!("pt_mapping_refund_sync_{connector}"), "ConnectorPTMapping", ) .await; pub async fn get_refund_sync_process_schedule_time( db: &dyn db::StorageInterface, connector: &str, merchant_id: &common_utils::id_type::MerchantId, retry_count: i32, ) -> Result<Option<time::PrimitiveDateTime>, errors::ProcessTrackerError> { { Ok(x) => x,<|fim_suffix|> <|fim_middle|> Err(err) => { logger::error!("Error: while getting connector mapping: {err:?}"); process_data::ConnectorPTMapping::default() } } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router Ok(services::ApplicationResponse::Json( api_models::refunds::RefundListFilters { connector: connector_map, currency: enums::Currency::iter().collect(), refund_status: enums::RefundStatus::iter().collect(), }, )) } #[instrument(skip_all)] #[cfg(feature = "olap")] pub async fn get_aggregates_for_refunds( state: SessionState, merchant: domain::MerchantAccount, profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>, time_range: common_utils::types::TimeRange, ) -> RouterResponse<api_models::refunds::RefundAggregateResponse> { let db = state.store.as_ref(); let refund_status_with_count = db .get_refund_status_with_count( merchant.get_id(), profile_id_list, &time_range, merchant.storage_scheme, pub async fn get_aggregates_for_refunds( state: SessionState, merchant: domain::MerchantAccount, profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>, time_range: common_utils::types::TimeRange, ) -> RouterResponse<api_models::refunds::RefundAggregateResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub fn refund_to_refund_core_workflow_model( refund: &storage::Refund, ) -> storage::RefundCoreWorkflow { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn start_refund_workflow( state: &SessionState, refund_tracker: &storage::ProcessTracker, ) -> Result<(), errors::ProcessTrackerError> { { Some("EXECUTE_REFUND") => { Box::pin(trigger_refund_execute_workflow(state, refund_tracker)).await }<|fim_suffix|> <|fim_middle|> _ => Err(errors::ProcessTrackerError::JobNotFound), } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; fn foreign_from(refund: storage::Refund) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use api_models::admin::MerchantConnectorInfo; use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use scheduler::{consumer::types::process_data, utils as process_tracker_utils}; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn refund_filter_list( state: SessionState, merchant_account: domain::MerchantAccount, req: common_utils::types::TimeRange, ) -> RouterResponse<api_models::refunds::RefundListMetaData> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use diesel_models::process_tracker::business_status; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; fn should_call_refund(refund: &diesel_models::refund::Refund, force_sync: bool) -> bool { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn refund_response_wrapper<F, Fut, T, Req>( state: SessionState, merchant_account: domain::MerchantAccount, profile_id: Option<common_utils::id_type::ProfileId>, key_store: domain::MerchantKeyStore, request: Req, f: F, ) -> RouterResponse<refunds::RefundResponse> where F: Fn( SessionState, domain::MerchantAccount, Option<common_utils::id_type::ProfileId>, domain::MerchantKeyStore, Req, ) -> Fut, Fut: futures::Future<Output = RouterResult<T>>, T: ForeignInto<refunds::RefundResponse>, { Ok(services::ApplicationResponse::Json( f(state, merchant_account, profile_id, key_store, request) .await? .foreign_into(), )) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use hyperswitch_domain_models::{ router_data::ErrorResponse, router_request_types::SplitRefundsRequest, }; use hyperswitch_interfaces::integrity::{CheckIntegrity, FlowIntegrity, GetIntegrityObject}; use scheduler::{consumer::types::process_data, utils as process_tracker_utils}; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub fn check_refund_integrity<T, Request>( request: &Request, refund_response_data: &Result<types::RefundsResponseData, ErrorResponse>, ) -> Result<(), common_utils::errors::IntegrityCheckError> where T: FlowIntegrity, Request: GetIntegrityObject<T> + CheckIntegrity<Request, T>, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use diesel_models::process_tracker::business_status; use scheduler::{consumer::types::process_data, utils as process_tracker_utils}; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn trigger_refund_execute_workflow( state: &SessionState, refund_tracker: &storage::ProcessTracker, ) -> Result<(), errors::ProcessTrackerError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use api_models::admin::MerchantConnectorInfo; use hyperswitch_domain_models::{ router_data::ErrorResponse, router_request_types::SplitRefundsRequest, }; use scheduler::{consumer::types::process_data, utils as process_tracker_utils}; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn schedule_refund_execution( state: &SessionState, refund: storage::Refund, refund_type: api_models::refunds::RefundType, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, payment_attempt: &storage::PaymentAttempt, payment_intent: &storage::PaymentIntent, creds_identifier: Option<String>, split_refunds: Option<SplitRefundsRequest>, ) -> RouterResult<storage::Refund> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn refund_retrieve_core( state: SessionState, merchant_account: domain::MerchantAccount, profile_id: Option<common_utils::id_type::ProfileId>, key_store: domain::MerchantKeyStore, request: refunds::RefundsRetrieveRequest, refund: storage::Refund, ) -> RouterResult<storage::Refund> { let db = &*state.store; let merchant_id = merchant_account.get_id(); core_utils::validate_profile_id_from_auth_layer(profile_id, &refund)?; let payment_id = &refund.payment_id; let payment_intent = db .find_payment_intent_by_payment_id_merchant_id( &(&state).into(), payment_id, merchant_id, &key_store, merchant_account.storage_scheme, ) .await .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; let payment_attempt = db .find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id( &refund.connector_transaction_id, payment_id, merchant_id, merchant_account.storage_scheme, ) .await .to_not_found_response(errors::ApiErrorResponse::InternalServerError)?; let creds_identifier = request .merchant_connector_details .as_ref() .map(|mcd| mcd.creds_identifier.to_owned()); request .merchant_connector_details .to_owned() .async_map(|mcd| async { helpers::insert_merchant_connector_creds_to_config(db, merchant_id, mcd).await }) .await .transpose()?; let split_refunds_req = core_utils::get_split_refunds(SplitRefundInput { split_payment_request: payment_intent.split_payments.clone(), payment_charges: payment_attempt.charges.clone(), charge_id: payment_attempt.charge_id.clone(), refund_request: refund.split_refunds.clone(), })?; let unified_translated_message = if let (Some(unified_code), Some(unified_message)) = (refund.unified_code.clone(), refund.unified_message.clone()) { helpers::get_unified_translation( &state, unified_code, unified_message.clone(), state.locale.to_string(), ) .await .or(Some(unified_message)) } else { refund.unified_message }; let refund = storage::Refund { unified_message: unified_translated_message, ..refund }; let response = if should_call_refund(&refund, request.force_sync.unwrap_or(false)) { Box::pin(sync_refund_with_gateway( &state, &merchant_account, &key_store, &payment_attempt, &payment_intent, &refund, creds_identifier, split_refunds_req, )) .await } else { Ok(refund) }?; Ok(response) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use error_stack::{report, ResultExt}; use scheduler::{consumer::types::process_data, utils as process_tracker_utils}; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn refund_create_core( state: SessionState, merchant_account: domain::MerchantAccount, _profile_id: Option<common_utils::id_type::ProfileId>, key_store: domain::MerchantKeyStore, req: refunds::RefundRequest, ) -> RouterResponse<refunds::RefundResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use error_stack::{report, ResultExt}; use scheduler::{consumer::types::process_data, utils as process_tracker_utils}; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn validate_and_create_refund( state: &SessionState, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, payment_attempt: &storage::PaymentAttempt, payment_intent: &storage::PaymentIntent, refund_amount: MinorUnit, req: refunds::RefundRequest, creds_identifier: Option<String>, ) -> RouterResult<refunds::RefundResponse> { {let db = &*state.store;<|fim_suffix|> <|fim_middle|> Ok(refund.foreign_into())}}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use hyperswitch_domain_models::{ router_data::ErrorResponse, router_request_types::SplitRefundsRequest, }; use hyperswitch_interfaces::integrity::{CheckIntegrity, FlowIntegrity, GetIntegrityObject}; use router_env::{instrument, tracing}; use scheduler::{consumer::types::process_data, utils as process_tracker_utils}; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn sync_refund_with_gateway( state: &SessionState, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, payment_attempt: &storage::PaymentAttempt, payment_intent: &storage::PaymentIntent, refund: &storage::Refund, creds_identifier: Option<String>, split_refunds: Option<SplitRefundsRequest>, ) -> RouterResult<storage::Refund> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/refunds.rs | crate: router use common_utils::{ ext_traits::AsyncExt, types::{ConnectorTransactionId, MinorUnit}, }; use diesel_models::process_tracker::business_status; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::{ router_data::ErrorResponse, router_request_types::SplitRefundsRequest, }; use hyperswitch_interfaces::integrity::{CheckIntegrity, FlowIntegrity, GetIntegrityObject}; use router_env::{instrument, tracing}; use scheduler::{consumer::types::process_data, utils as process_tracker_utils}; use crate::{ consts, core::{ errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, access_token, helpers}, refunds::transformers::SplitRefundInput, utils as core_utils, }, db, logger, routes::{metrics, SessionState}, services, types::{ self, api::{self, refunds}, domain, storage::{self, enums}, transformers::{ForeignFrom, ForeignInto}, }, utils::{self, OptionExt}, workflows::payment_sync, }; pub async fn trigger_refund_to_gateway( state: &SessionState, refund: &storage::Refund, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, payment_attempt: &storage::PaymentAttempt, payment_intent: &storage::PaymentIntent, creds_identifier: Option<String>, split_refunds: Option<SplitRefundsRequest>, ) -> RouterResult<storage::Refund> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use common_enums::PayoutRetryType; use common_utils::{ consts, ext_traits::{AsyncExt, ValueExt}, id_type::CustomerId, link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus}, types::{MinorUnit, UnifiedCode, UnifiedMessage}, }; use diesel_models::{ enums as storage_enums, generic_link::{GenericLinkNew, PayoutLink}, CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord, }; use error_stack::{report, ResultExt}; use serde_json; use time::Duration; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn create_payout_link_db_entry( state: &SessionState, merchant_id: &common_utils::id_type::MerchantId, payout_link_data: &PayoutLinkData, return_url: Option<String>, ) -> RouterResult<PayoutLink> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use common_utils::{ consts, ext_traits::{AsyncExt, ValueExt}, id_type::CustomerId, link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus}, types::{MinorUnit, UnifiedCode, UnifiedMessage}, }; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; async fn validate_and_get_business_profile( state: &SessionState, merchant_key_store: &domain::MerchantKeyStore, profile_id: &common_utils::id_type::ProfileId, merchant_id: &common_utils::id_type::MerchantId, ) -> RouterResult<domain::Profile> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use common_utils::{ consts, ext_traits::{AsyncExt, ValueExt}, id_type::CustomerId, link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus}, types::{MinorUnit, UnifiedCode, UnifiedMessage}, }; use scheduler::utils as pt_utils; use time::Duration; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn add_external_account_addition_task( db: &dyn StorageInterface, payout_data: &PayoutData, schedule_time: time::PrimitiveDateTime, ) -> CustomResult<(), errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use diesel_models::{ enums as storage_enums, generic_link::{GenericLinkNew, PayoutLink}, CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord, }; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn complete_create_recipient_disburse_account( state: &SessionState, merchant_account: &domain::MerchantAccount, connector_data: &api::ConnectorData, payout_data: &mut PayoutData, key_store: &domain::MerchantKeyStore, ) -> RouterResult<()> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::payments as payment_enums; use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use common_utils::{ consts, ext_traits::{AsyncExt, ValueExt}, id_type::CustomerId, link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus}, types::{MinorUnit, UnifiedCode, UnifiedMessage}, }; use crate::types::domain::behaviour::Conversion; use crate::types::PayoutActionData; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn create_payout_retrieve( state: &SessionState, merchant_account: &domain::MerchantAccount, connector_data: &api::ConnectorData, payout_data: &mut PayoutData, ) -> RouterResult<()> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::payments as payment_enums; use common_utils::{ consts, ext_traits::{AsyncExt, ValueExt}, id_type::CustomerId, link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus}, types::{MinorUnit, UnifiedCode, UnifiedMessage}, }; use crate::types::domain::behaviour::Conversion; use crate::types::PayoutActionData; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; async fn complete_payout_quote_steps_if_required<F>( state: &SessionState, connector_data: &api::ConnectorData, router_data: &mut types::RouterData<F, types::PayoutsData, types::PayoutsResponseData>, ) -> RouterResult<()> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::payments as payment_enums; use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use diesel_models::{ enums as storage_enums, generic_link::{GenericLinkNew, PayoutLink}, CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord, }; use scheduler::utils as pt_utils; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn complete_create_payout( state: &SessionState, merchant_account: &domain::MerchantAccount, connector_data: &api::ConnectorData, payout_data: &mut PayoutData, ) -> RouterResult<()> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use error_stack::{report, ResultExt}; use scheduler::utils as pt_utils; use serde_json; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn complete_payout_eligibility( state: &SessionState, merchant_account: &domain::MerchantAccount, connector_data: &api::ConnectorData, payout_data: &mut PayoutData, ) -> RouterResult<()> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use common_enums::PayoutRetryType; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn complete_create_recipient( state: &SessionState, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, connector_data: &api::ConnectorData, payout_data: &mut PayoutData, ) -> RouterResult<()> { if !payout_data.should_terminate && matches!( payout_data.payout_attempt.status, common_enums::PayoutStatus::RequiresCreation | common_enums::PayoutStatus::RequiresConfirmation | common_enums::PayoutStatus::RequiresPayoutMethodData ) && connector_data .connector_name .supports_create_recipient(payout_data.payouts.payout_type) { Box::pin(create_recipient( state, merchant_account, key_store, connector_data, payout_data, )) .await .attach_printable("Creation of customer failed")?; } Ok(()) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use common_utils::{ consts, ext_traits::{AsyncExt, ValueExt}, id_type::CustomerId, link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus}, types::{MinorUnit, UnifiedCode, UnifiedMessage}, }; use diesel_models::{ enums as storage_enums, generic_link::{GenericLinkNew, PayoutLink}, CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord, }; use crate::types::domain::behaviour::Conversion; use crate::types::PayoutActionData; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn payouts_list_available_filters_core( state: SessionState, merchant_account: domain::MerchantAccount, profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>, time_range: common_utils::types::TimeRange, ) -> RouterResponse<api::PayoutListFilters> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use common_utils::{ consts, ext_traits::{AsyncExt, ValueExt}, id_type::CustomerId, link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus}, types::{MinorUnit, UnifiedCode, UnifiedMessage}, }; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn payouts_retrieve_core( state: SessionState, merchant_account: domain::MerchantAccount, profile_id: Option<common_utils::id_type::ProfileId>, key_store: domain::MerchantKeyStore, req: payouts::PayoutRetrieveRequest, ) -> RouterResponse<payouts::PayoutCreateResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use error_stack::{report, ResultExt}; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn payouts_update_core( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, req: payouts::PayoutCreateRequest, ) -> RouterResponse<payouts::PayoutCreateResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use common_utils::{ consts, ext_traits::{AsyncExt, ValueExt}, id_type::CustomerId, link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus}, types::{MinorUnit, UnifiedCode, UnifiedMessage}, }; use diesel_models::{ enums as storage_enums, generic_link::{GenericLinkNew, PayoutLink}, CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord, }; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn payouts_confirm_core( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, req: payouts::PayoutCreateRequest, ) -> RouterResponse<payouts::PayoutCreateResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn payouts_create_core( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, req: payouts::PayoutCreateRequest, ) -> RouterResponse<payouts::PayoutCreateResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use serde_json; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn payouts_core( state: &SessionState, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, payout_data: &mut PayoutData, routing_algorithm: Option<serde_json::Value>, eligible_connectors: Option<Vec<api_enums::PayoutConnectors>>, ) -> RouterResult<()> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use diesel_models::{ enums as storage_enums, generic_link::{GenericLinkNew, PayoutLink}, CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord, }; use serde_json; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn get_connector_choice( state: &SessionState, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, connector: Option<String>, routing_algorithm: Option<serde_json::Value>, payout_data: &mut PayoutData, eligible_connectors: Option<Vec<api_enums::PayoutConnectors>>, ) -> RouterResult<api::ConnectorCallType> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router + Duration::seconds(payout_link_data.session_expiry.into()), ..Default::default() }; db.insert_payout_link(payout_link) .await .to_duplicate_response(errors::ApiErrorResponse::GenericDuplicateError { message: "payout link already exists".to_string(), }) } #[instrument(skip_all)] pub async fn get_mca_from_profile_id( state: &SessionState, merchant_account: &domain::MerchantAccount, profile_id: &common_utils::id_type::ProfileId, connector_name: &str, merchant_connector_id: Option<&common_utils::id_type::MerchantConnectorAccountId>, key_store: &domain::MerchantKeyStore, ) -> RouterResult<payment_helpers::MerchantConnectorAccountType> { let merchant_connector_account = payment_helpers::get_merchant_connector_account( state, merchant_account.get_id(), None, key_store, pub async fn get_mca_from_profile_id( state: &SessionState, merchant_account: &domain::MerchantAccount, profile_id: &common_utils::id_type::ProfileId, connector_name: &str, merchant_connector_id: Option<&common_utils::id_type::MerchantConnectorAccountId>, key_store: &domain::MerchantKeyStore, ) -> RouterResult<payment_helpers::MerchantConnectorAccountType> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router { Ok(business_profile) } else { db.find_business_profile_by_profile_id(key_manager_state, merchant_key_store, profile_id) .await .to_not_found_response(errors::ApiErrorResponse::ProfileNotFound { id: profile_id.get_string_repr().to_owned(), }) } } #[allow(clippy::too_many_arguments)] pub async fn create_payout_link( state: &SessionState, business_profile: &domain::Profile, customer_id: &CustomerId, merchant_id: &common_utils::id_type::MerchantId, req: &payouts::PayoutCreateRequest, payout_id: &str, locale: &str, ) -> RouterResult<PayoutLink> { let payout_link_config_req = req.payout_link_config.to_owned(); // Fetch all configs let default_config = &state.conf.generic_link.payout_link; pub async fn create_payout_link( state: &SessionState, business_profile: &domain::Profile, customer_id: &CustomerId, merchant_id: &common_utils::id_type::MerchantId, req: &payouts::PayoutCreateRequest, payout_id: &str, locale: &str, ) -> RouterResult<PayoutLink> { { Some(config) => (config.logo, config.merchant_name, config.theme),<|fim_suffix|> <|fim_middle|> _ => (None, None, None), } }
ast_fragments
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use common_utils::{ consts, ext_traits::{AsyncExt, ValueExt}, id_type::CustomerId, link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus}, types::{MinorUnit, UnifiedCode, UnifiedMessage}, }; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn get_mca_from_profile_id( state: &SessionState, merchant_account: &domain::MerchantAccount, profile_id: &common_utils::id_type::ProfileId, connector_name: &str, merchant_connector_id: Option<&common_utils::id_type::MerchantConnectorAccountId>, key_store: &domain::MerchantKeyStore, ) -> RouterResult<payment_helpers::MerchantConnectorAccountType> { let merchant_connector_account = payment_helpers::get_merchant_connector_account( state, merchant_account.get_id(), None, key_store, profile_id, connector_name, merchant_connector_id, ) .await?; Ok(merchant_connector_account) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use common_utils::{ consts, ext_traits::{AsyncExt, ValueExt}, id_type::CustomerId, link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus}, types::{MinorUnit, UnifiedCode, UnifiedMessage}, }; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn make_payout_data( _state: &SessionState, _merchant_account: &domain::MerchantAccount, _auth_profile_id: Option<common_utils::id_type::ProfileId>, _key_store: &domain::MerchantKeyStore, _req: &payouts::PayoutRequest, locale: &str, ) -> RouterResult<PayoutData> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payouts.rs | crate: router use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse}; use hyperswitch_domain_models::payment_methods::PaymentMethod; use crate::types::domain::behaviour::Conversion; use crate::{ core::{ errors::{ self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt, }, payments::{self, customers, helpers as payment_helpers}, utils as core_utils, }, db::StorageInterface, routes::SessionState, services, types::{ self, api::{self, payments as payment_api_types, payouts}, domain, storage::{self, PaymentRoutingInfo}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; pub async fn payout_create_db_entries( _state: &SessionState, _merchant_account: &domain::MerchantAccount, _key_store: &domain::MerchantKeyStore, _req: &payouts::PayoutCreateRequest, _payout_id: &str, _profile_id: &str, _stored_payout_method_data: Option<&payouts::PayoutMethodData>, _locale: &str, _customer: Option<&domain::Customer>, _payment_method: Option<PaymentMethod>, ) -> RouterResult<PayoutData> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
8