id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
hyperswitch_method_router_NewUserMerchant_create_new_merchant_and_insert_in_db
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for NewUserMerchant pub async fn create_new_merchant_and_insert_in_db( &self, state: SessionState, ) -> UserResult<domain::MerchantAccount> { self.check_if_already_exists_in_db(state.clone()).await?; let merchant_account_create_request = self .create_merchant_account_request() .attach_printable("unable to construct merchant account create request")?; let ApplicationResponse::Json(merchant_account_response) = Box::pin( admin::create_merchant_account(state.clone(), merchant_account_create_request, None), ) .await .change_context(UserErrors::InternalServerError) .attach_printable("Error while creating a merchant")? else { return Err(UserErrors::InternalServerError.into()); }; let profile_create_request = admin_api::ProfileCreate { profile_name: consts::user::DEFAULT_PROFILE_NAME.to_string(), ..Default::default() }; let key_manager_state = &(&state).into(); let merchant_key_store = state .store .get_merchant_key_store_by_merchant_id( key_manager_state, &merchant_account_response.id, &state.store.get_master_key().to_vec().into(), ) .await .change_context(UserErrors::InternalServerError) .attach_printable("Failed to retrieve merchant key store by merchant_id")?; let merchant_account = state .store .find_merchant_account_by_merchant_id( key_manager_state, &merchant_account_response.id, &merchant_key_store, ) .await .change_context(UserErrors::InternalServerError) .attach_printable("Failed to retrieve merchant account by merchant_id")?; let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(domain::Context( merchant_account.clone(), merchant_key_store, ))); Box::pin(admin::create_profile( state, profile_create_request, merchant_context, )) .await .change_context(UserErrors::InternalServerError) .attach_printable("Error while creating a profile")?; Ok(merchant_account) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "NewUserMerchant", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "create_new_merchant_and_insert_in_db", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_NewUser_check_if_already_exists_in_db
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for NewUser pub async fn check_if_already_exists_in_db(&self, state: SessionState) -> UserResult<()> { if state .global_store .find_user_by_email(&self.get_email()) .await .is_ok() { return Err(report!(UserErrors::UserExists)); } Ok(()) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "NewUser", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "check_if_already_exists_in_db", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_NewUser_get_new_merchant
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for NewUser pub fn get_new_merchant(&self) -> NewUserMerchant { self.new_merchant.clone() }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "NewUser", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_new_merchant", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_NewUser_get_password
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for NewUser pub fn get_password(&self) -> Option<UserPassword> { self.password .as_ref() .map(|password| password.deref().clone()) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "NewUser", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_password", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_NewUser_insert_user_in_db
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for NewUser pub async fn insert_user_in_db( &self, db: &dyn GlobalStorageInterface, ) -> UserResult<UserFromStorage> { match db.insert_user(self.clone().try_into()?).await { Ok(user) => Ok(user.into()), Err(e) => { if e.current_context().is_db_unique_violation() { Err(e.change_context(UserErrors::UserExists)) } else { Err(e.change_context(UserErrors::InternalServerError)) } } } .attach_printable("Error while inserting user") }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "NewUser", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "insert_user_in_db", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_NewUser_insert_user_and_merchant_in_db
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for NewUser pub async fn insert_user_and_merchant_in_db( &self, state: SessionState, ) -> UserResult<UserFromStorage> { self.check_if_already_exists_in_db(state.clone()).await?; let db = state.global_store.as_ref(); let merchant_id = self.get_new_merchant().get_merchant_id(); self.new_merchant .create_new_merchant_and_insert_in_db(state.clone()) .await?; let created_user = self.insert_user_in_db(db).await; if created_user.is_err() { let _ = admin::merchant_account_delete(state, merchant_id).await; }; created_user }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "NewUser", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "insert_user_and_merchant_in_db", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_NewUser_get_no_level_user_role
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for NewUser pub fn get_no_level_user_role( self, role_id: String, user_status: UserStatus, ) -> NewUserRole<NoLevel> { let now = common_utils::date_time::now(); let user_id = self.get_user_id(); NewUserRole { status: user_status, created_by: user_id.clone(), last_modified_by: user_id.clone(), user_id, role_id, created_at: now, last_modified: now, entity: NoLevel, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "NewUser", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_no_level_user_role", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_NewUser_insert_org_level_user_role_in_db
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for NewUser pub async fn insert_org_level_user_role_in_db( self, state: SessionState, role_id: String, user_status: UserStatus, ) -> UserResult<UserRole> { let org_id = self .get_new_merchant() .get_new_organization() .get_organization_id(); let org_user_role = self .get_no_level_user_role(role_id, user_status) .add_entity(OrganizationLevel { tenant_id: state.tenant.tenant_id.clone(), org_id, }); org_user_role.insert_in_v2(&state).await }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "NewUser", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "insert_org_level_user_role_in_db", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_UserFromStorage_get_user_id
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for UserFromStorage pub fn get_user_id(&self) -> &str { self.0.user_id.as_str() }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "UserFromStorage", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_user_id", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_UserFromStorage_get_email
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for UserFromStorage pub fn get_email(&self) -> pii::Email { self.0.email.clone() }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "UserFromStorage", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_email", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_UserFromStorage_get_name
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for UserFromStorage pub fn get_name(&self) -> Secret<String> { self.0.name.clone() }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "UserFromStorage", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_name", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_UserFromStorage_compare_password
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for UserFromStorage pub fn compare_password(&self, candidate: &Secret<String>) -> UserResult<()> { if let Some(password) = self.0.password.as_ref() { match password::is_correct_password(candidate, password) { Ok(true) => Ok(()), Ok(false) => Err(UserErrors::InvalidCredentials.into()), Err(e) => Err(e), } } else { Err(UserErrors::InvalidCredentials.into()) } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "UserFromStorage", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "compare_password", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_UserFromStorage_get_verification_days_left
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for UserFromStorage pub fn get_verification_days_left(&self, state: &SessionState) -> UserResult<Option<i64>> { if self.0.is_verified { return Ok(None); } let allowed_unverified_duration = time::Duration::days(state.conf.email.allowed_unverified_days); let user_created = self.0.created_at.date(); let last_date_for_verification = user_created .checked_add(allowed_unverified_duration) .ok_or(UserErrors::InternalServerError)?; let today = common_utils::date_time::now().date(); if today >= last_date_for_verification { return Err(UserErrors::UnverifiedUser.into()); } let days_left_for_verification = last_date_for_verification - today; Ok(Some(days_left_for_verification.whole_days())) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "UserFromStorage", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_verification_days_left", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_UserFromStorage_is_verified
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for UserFromStorage pub fn is_verified(&self) -> bool { self.0.is_verified }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "UserFromStorage", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "is_verified", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_UserFromStorage_is_password_rotate_required
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for UserFromStorage pub fn is_password_rotate_required(&self, state: &SessionState) -> UserResult<bool> { let last_password_modified_at = if let Some(last_password_modified_at) = self.0.last_password_modified_at { last_password_modified_at.date() } else { return Ok(true); }; let password_change_duration = time::Duration::days(state.conf.user.password_validity_in_days.into()); let last_date_for_password_rotate = last_password_modified_at .checked_add(password_change_duration) .ok_or(UserErrors::InternalServerError)?; let today = common_utils::date_time::now().date(); let days_left_for_password_rotate = last_date_for_password_rotate - today; Ok(days_left_for_password_rotate.whole_days() < 0) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "UserFromStorage", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "is_password_rotate_required", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_UserFromStorage_get_or_create_key_store
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for UserFromStorage pub async fn get_or_create_key_store(&self, state: &SessionState) -> UserResult<UserKeyStore> { let master_key = state.store.get_master_key(); let key_manager_state = &state.into(); let key_store_result = state .global_store .get_user_key_store_by_user_id( key_manager_state, self.get_user_id(), &master_key.to_vec().into(), ) .await; if let Ok(key_store) = key_store_result { Ok(key_store) } else if key_store_result .as_ref() .map_err(|e| e.current_context().is_db_not_found()) .err() .unwrap_or(false) { let key = services::generate_aes256_key() .change_context(UserErrors::InternalServerError) .attach_printable("Unable to generate aes 256 key")?; #[cfg(feature = "keymanager_create")] { common_utils::keymanager::transfer_key_to_key_manager( key_manager_state, EncryptionTransferRequest { identifier: Identifier::User(self.get_user_id().to_string()), key: consts::BASE64_ENGINE.encode(key), }, ) .await .change_context(UserErrors::InternalServerError)?; } let key_store = UserKeyStore { user_id: self.get_user_id().to_string(), key: domain_types::crypto_operation( key_manager_state, type_name!(UserKeyStore), domain_types::CryptoOperation::Encrypt(key.to_vec().into()), Identifier::User(self.get_user_id().to_string()), master_key, ) .await .and_then(|val| val.try_into_operation()) .change_context(UserErrors::InternalServerError)?, created_at: common_utils::date_time::now(), }; state .global_store .insert_user_key_store(key_manager_state, key_store, &master_key.to_vec().into()) .await .change_context(UserErrors::InternalServerError) } else { Err(key_store_result .err() .map(|e| e.change_context(UserErrors::InternalServerError)) .unwrap_or(UserErrors::InternalServerError.into())) } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "UserFromStorage", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_or_create_key_store", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_UserFromStorage_get_totp_status
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for UserFromStorage pub fn get_totp_status(&self) -> TotpStatus { self.0.totp_status }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "UserFromStorage", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_totp_status", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_UserFromStorage_get_recovery_codes
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for UserFromStorage pub fn get_recovery_codes(&self) -> Option<Vec<Secret<String>>> { self.0.totp_recovery_codes.clone() }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "UserFromStorage", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_recovery_codes", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_UserFromStorage_decrypt_and_get_totp_secret
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for UserFromStorage pub async fn decrypt_and_get_totp_secret( &self, state: &SessionState, ) -> UserResult<Option<Secret<String>>> { if self.0.totp_secret.is_none() { return Ok(None); } let key_manager_state = &state.into(); let user_key_store = state .global_store .get_user_key_store_by_user_id( key_manager_state, self.get_user_id(), &state.store.get_master_key().to_vec().into(), ) .await .change_context(UserErrors::InternalServerError)?; Ok(domain_types::crypto_operation::<String, masking::WithType>( key_manager_state, type_name!(storage_user::User), domain_types::CryptoOperation::DecryptOptional(self.0.totp_secret.clone()), Identifier::User(user_key_store.user_id.clone()), user_key_store.key.peek(), ) .await .and_then(|val| val.try_into_optionaloperation()) .change_context(UserErrors::InternalServerError)? .map(Encryptable::into_inner)) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "UserFromStorage", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "decrypt_and_get_totp_secret", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RoleName_new
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for RoleName pub fn new(name: String) -> UserResult<Self> { let is_empty_or_whitespace = name.trim().is_empty(); let is_too_long = name.graphemes(true).count() > consts::user_role::MAX_ROLE_NAME_LENGTH; if is_empty_or_whitespace || is_too_long || name.contains(' ') { Err(UserErrors::RoleNameParsingError.into()) } else { Ok(Self(name.to_lowercase())) } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RoleName", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RoleName_get_role_name
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for RoleName pub fn get_role_name(self) -> String { self.0 }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RoleName", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_role_name", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RecoveryCodes_into_inner
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for RecoveryCodes pub fn into_inner(self) -> Vec<Secret<String>> { self.0 }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RecoveryCodes", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "into_inner", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RecoveryCodes_generate_new
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for RecoveryCodes pub fn generate_new() -> Self { let mut rand = rand::thread_rng(); let recovery_codes = (0..consts::user::RECOVERY_CODES_COUNT) .map(|_| { let code_part_1 = Alphanumeric.sample_string(&mut rand, consts::user::RECOVERY_CODE_LENGTH / 2); let code_part_2 = Alphanumeric.sample_string(&mut rand, consts::user::RECOVERY_CODE_LENGTH / 2); Secret::new(format!("{code_part_1}-{code_part_2}")) }) .collect::<Vec<_>>(); Self(recovery_codes) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RecoveryCodes", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "generate_new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RecoveryCodes_get_hashed
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for RecoveryCodes pub fn get_hashed(&self) -> UserResult<Vec<Secret<String>>> { self.0 .iter() .cloned() .map(password::generate_password_hash) .collect::<Result<Vec<_>, _>>() }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RecoveryCodes", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_hashed", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_NewUserRole<NoLevel>_add_entity
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for NewUserRole<NoLevel> pub fn add_entity<T>(self, entity: T) -> NewUserRole<T> where T: Clone, { NewUserRole { entity, user_id: self.user_id, role_id: self.role_id, status: self.status, created_by: self.created_by, last_modified_by: self.last_modified_by, created_at: self.created_at, last_modified: self.last_modified, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "NewUserRole<NoLevel>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_entity", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_NewUserRole<E>_convert_to_new_v2_role
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for NewUserRole<E> fn convert_to_new_v2_role(self, entity: EntityInfo) -> UserRoleNew { UserRoleNew { user_id: self.user_id, role_id: self.role_id, status: self.status, created_by: self.created_by, last_modified_by: self.last_modified_by, created_at: self.created_at, last_modified: self.last_modified, org_id: entity.org_id, merchant_id: entity.merchant_id, profile_id: entity.profile_id, entity_id: Some(entity.entity_id), entity_type: Some(entity.entity_type), version: UserRoleVersion::V2, tenant_id: entity.tenant_id, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "NewUserRole<E>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "convert_to_new_v2_role", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_NewUserRole<E>_insert_in_v2
clm
method
// hyperswitch/crates/router/src/types/domain/user.rs // impl for NewUserRole<E> pub async fn insert_in_v2(self, state: &SessionState) -> UserResult<UserRole> { let entity = self.entity.clone(); let new_v2_role = self.convert_to_new_v2_role(entity.into()); state .global_store .insert_user_role(new_v2_role) .await .change_context(UserErrors::InternalServerError) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "NewUserRole<E>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "insert_in_v2", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_SPTFlow_generate_spt
clm
method
// hyperswitch/crates/router/src/types/domain/user/decision_manager.rs // impl for SPTFlow pub async fn generate_spt( self, state: &SessionState, next_flow: &NextFlow, ) -> UserResult<Secret<String>> { auth::SinglePurposeToken::new_token( next_flow.user.get_user_id().to_string(), self.into(), next_flow.origin.clone(), &state.conf, next_flow.path.to_vec(), Some(state.tenant.tenant_id.clone()), ) .await .map(|token| token.into()) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "SPTFlow", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "generate_spt", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_Origin_get_flows
clm
method
// hyperswitch/crates/router/src/types/domain/user/decision_manager.rs // impl for Origin fn get_flows(&self) -> &'static [UserFlow] { match self { Self::SignInWithSSO => &SIGNIN_WITH_SSO_FLOW, Self::SignIn => &SIGNIN_FLOW, Self::SignUp => &SIGNUP_FLOW, Self::VerifyEmail => &VERIFY_EMAIL_FLOW, Self::MagicLink => &MAGIC_LINK_FLOW, Self::AcceptInvitationFromEmail => &ACCEPT_INVITATION_FROM_EMAIL_FLOW, Self::ResetPassword => &RESET_PASSWORD_FLOW, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "Origin", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_flows", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RequiredFieldsInput_new
clm
method
// hyperswitch/crates/router/src/core/payment_methods.rs // impl for RequiredFieldsInput fn new(required_fields_config: settings::RequiredFields) -> Self { Self { required_fields_config, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RequiredFieldsInput", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RequiredFieldsInput_new
clm
method
// hyperswitch/crates/router/src/core/payments/payment_methods.rs // impl for RequiredFieldsInput fn new( required_fields_config: settings::RequiredFields, setup_future_usage: common_enums::FutureUsage, ) -> Self { Self { required_fields_config, setup_future_usage, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RequiredFieldsInput", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RequiredFieldsForEnabledPaymentMethodTypes_generate_response_for_session
clm
method
// hyperswitch/crates/router/src/core/payment_methods.rs // impl for RequiredFieldsForEnabledPaymentMethodTypes fn generate_response_for_session( self, customer_payment_methods: Vec<payment_methods::CustomerPaymentMethodResponseItem>, ) -> payment_methods::PaymentMethodListResponseForSession { let response_payment_methods = self .0 .into_iter() .map( |payment_methods_enabled| payment_methods::ResponsePaymentMethodTypes { payment_method_type: payment_methods_enabled.payment_method_type, payment_method_subtype: payment_methods_enabled.payment_method_subtype, required_fields: payment_methods_enabled.required_fields, extra_information: None, }, ) .collect(); payment_methods::PaymentMethodListResponseForSession { payment_methods_enabled: response_payment_methods, customer_payment_methods, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RequiredFieldsForEnabledPaymentMethodTypes", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "generate_response_for_session", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_pm_types::SavedPMLPaymentsInfo_form_payments_info
clm
method
// hyperswitch/crates/router/src/core/payment_methods.rs // impl for pm_types::SavedPMLPaymentsInfo pub async fn form_payments_info( payment_intent: PaymentIntent, merchant_context: &domain::MerchantContext, profile: domain::Profile, db: &dyn StorageInterface, key_manager_state: &util_types::keymanager::KeyManagerState, ) -> 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 ); 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, }) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "pm_types::SavedPMLPaymentsInfo", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "form_payments_info", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_pm_types::SavedPMLPaymentsInfo_perform_payment_ops
clm
method
// hyperswitch/crates/router/src/core/payment_methods.rs // impl for pm_types::SavedPMLPaymentsInfo pub async fn perform_payment_ops( &self, state: &SessionState, parent_payment_method_token: Option<String>, pma: &api::CustomerPaymentMethodResponseItem, 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")?; let intent_fulfillment_time = self .profile .get_order_fulfillment_time() .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(()) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "pm_types::SavedPMLPaymentsInfo", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "perform_payment_ops", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_CardInfoMigrateExecutor<'a>_update_card_info
clm
method
// hyperswitch/crates/router/src/core/cards_info.rs // impl for CardInfoMigrateExecutor<'a> async fn update_card_info(&self) -> RouterResult<card_info_models::CardInfo> { let db = self.state.store.as_ref(); let card_info = cards_info::CardsInfoInterface::update_card_info( db, self.record.card_iin.clone(), card_info_models::UpdateCardInfo { card_issuer: self.record.card_issuer.clone(), card_network: self.record.card_network.clone(), card_type: self.record.card_type.clone(), card_subtype: self.record.card_subtype.clone(), card_issuing_country: self.record.card_issuing_country.clone(), bank_code_id: self.record.bank_code_id.clone(), bank_code: self.record.bank_code.clone(), country_code: self.record.country_code.clone(), last_updated: Some(common_utils::date_time::now()), last_updated_provider: self.record.last_updated_provider.clone(), }, ) .await .to_not_found_response(errors::ApiErrorResponse::GenericNotFoundError { message: "Card info with given key does not exist in our records".to_string(), }) .attach_printable("Failed while updating card info")?; Ok(card_info) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "CardInfoMigrateExecutor<'a>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "update_card_info", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_CardInfoMigrateExecutor<'a>_fetch_card_info
clm
method
// hyperswitch/crates/router/src/core/cards_info.rs // impl for CardInfoMigrateExecutor<'a> async fn fetch_card_info(&self) -> RouterResult<Option<card_info_models::CardInfo>> { let db = self.state.store.as_ref(); let maybe_card_info = db .get_card_info(&self.record.card_iin) .await .change_context(errors::ApiErrorResponse::InvalidCardIin)?; Ok(maybe_card_info) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "CardInfoMigrateExecutor<'a>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "fetch_card_info", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_CardInfoMigrateExecutor<'a>_add_card_info
clm
method
// hyperswitch/crates/router/src/core/cards_info.rs // impl for CardInfoMigrateExecutor<'a> async fn add_card_info(&self) -> RouterResult<card_info_models::CardInfo> { let db = self.state.store.as_ref(); let card_info = cards_info::CardsInfoInterface::add_card_info(db, self.record.clone().foreign_into()) .await .to_duplicate_response(errors::ApiErrorResponse::GenericDuplicateError { message: "CardInfo with given key already exists in our records".to_string(), })?; Ok(card_info) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "CardInfoMigrateExecutor<'a>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_card_info", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_CardInfoBuilder<CardInfoFetch>_new
clm
method
// hyperswitch/crates/router/src/core/cards_info.rs // impl for CardInfoBuilder<CardInfoFetch> fn new() -> Self { Self { state: std::marker::PhantomData, card_info: None, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "CardInfoBuilder<CardInfoFetch>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_CardInfoBuilder<CardInfoFetch>_set_card_info
clm
method
// hyperswitch/crates/router/src/core/cards_info.rs // impl for CardInfoBuilder<CardInfoFetch> fn set_card_info( self, card_info: card_info_models::CardInfo, ) -> CardInfoBuilder<CardInfoUpdate> { CardInfoBuilder { state: std::marker::PhantomData, card_info: Some(card_info), } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "CardInfoBuilder<CardInfoFetch>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "set_card_info", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_CardInfoBuilder<CardInfoFetch>_transition
clm
method
// hyperswitch/crates/router/src/core/cards_info.rs // impl for CardInfoBuilder<CardInfoFetch> fn transition(self) -> CardInfoBuilder<CardInfoAdd> { CardInfoBuilder { state: std::marker::PhantomData, card_info: None, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "CardInfoBuilder<CardInfoFetch>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "transition", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_CardInfoBuilder<CardInfoUpdate>_set_updated_card_info
clm
method
// hyperswitch/crates/router/src/core/cards_info.rs // impl for CardInfoBuilder<CardInfoUpdate> fn set_updated_card_info( self, card_info: card_info_models::CardInfo, ) -> CardInfoBuilder<CardInfoResponse> { CardInfoBuilder { state: std::marker::PhantomData, card_info: Some(card_info), } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "CardInfoBuilder<CardInfoUpdate>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "set_updated_card_info", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_CardInfoBuilder<CardInfoAdd>_set_added_card_info
clm
method
// hyperswitch/crates/router/src/core/cards_info.rs // impl for CardInfoBuilder<CardInfoAdd> fn set_added_card_info( self, card_info: card_info_models::CardInfo, ) -> CardInfoBuilder<CardInfoResponse> { CardInfoBuilder { state: std::marker::PhantomData, card_info: Some(card_info), } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "CardInfoBuilder<CardInfoAdd>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "set_added_card_info", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_CardInfoBuilder<CardInfoResponse>_build
clm
method
// hyperswitch/crates/router/src/core/cards_info.rs // impl for CardInfoBuilder<CardInfoResponse> pub fn build(self) -> cards_info_api_types::CardInfoMigrateResponseRecord { match self.card_info { Some(card_info) => cards_info_api_types::CardInfoMigrateResponseRecord { card_iin: Some(card_info.card_iin), card_issuer: card_info.card_issuer, card_network: card_info.card_network.map(|cn| cn.to_string()), card_type: card_info.card_type, card_sub_type: card_info.card_subtype, card_issuing_country: card_info.card_issuing_country, }, None => cards_info_api_types::CardInfoMigrateResponseRecord { card_iin: None, card_issuer: None, card_network: None, card_type: None, card_sub_type: None, card_issuing_country: None, }, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "CardInfoBuilder<CardInfoResponse>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "build", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_ConnectorAuthTypeValidation<'_>_validate_connector_auth_type
clm
method
// hyperswitch/crates/router/src/core/connector_validation.rs // impl for ConnectorAuthTypeValidation<'_> fn validate_connector_auth_type( &self, ) -> Result<(), error_stack::Report<errors::ApiErrorResponse>> { let validate_non_empty_field = |field_value: &str, field_name: &str| { if field_value.trim().is_empty() { Err(errors::ApiErrorResponse::InvalidDataFormat { field_name: format!("connector_account_details.{field_name}"), expected_format: "a non empty String".to_string(), } .into()) } else { Ok(()) } }; match self.auth_type { hyperswitch_domain_models::router_data::ConnectorAuthType::TemporaryAuth => Ok(()), hyperswitch_domain_models::router_data::ConnectorAuthType::HeaderKey { api_key } => { validate_non_empty_field(api_key.peek(), "api_key") } hyperswitch_domain_models::router_data::ConnectorAuthType::BodyKey { api_key, key1, } => { validate_non_empty_field(api_key.peek(), "api_key")?; validate_non_empty_field(key1.peek(), "key1") } hyperswitch_domain_models::router_data::ConnectorAuthType::SignatureKey { api_key, key1, api_secret, } => { validate_non_empty_field(api_key.peek(), "api_key")?; validate_non_empty_field(key1.peek(), "key1")?; validate_non_empty_field(api_secret.peek(), "api_secret") } hyperswitch_domain_models::router_data::ConnectorAuthType::MultiAuthKey { api_key, key1, api_secret, key2, } => { validate_non_empty_field(api_key.peek(), "api_key")?; validate_non_empty_field(key1.peek(), "key1")?; validate_non_empty_field(api_secret.peek(), "api_secret")?; validate_non_empty_field(key2.peek(), "key2") } hyperswitch_domain_models::router_data::ConnectorAuthType::CurrencyAuthKey { auth_key_map, } => { if auth_key_map.is_empty() { Err(errors::ApiErrorResponse::InvalidDataFormat { field_name: "connector_account_details.auth_key_map".to_string(), expected_format: "a non empty map".to_string(), } .into()) } else { Ok(()) } } hyperswitch_domain_models::router_data::ConnectorAuthType::CertificateAuth { certificate, private_key, } => { client::create_identity_from_certificate_and_key( certificate.to_owned(), private_key.to_owned(), ) .change_context(errors::ApiErrorResponse::InvalidDataFormat { field_name: "connector_account_details.certificate or connector_account_details.private_key" .to_string(), expected_format: "a valid base64 encoded string of PEM encoded Certificate and Private Key" .to_string(), })?; Ok(()) } hyperswitch_domain_models::router_data::ConnectorAuthType::NoKey => Ok(()), } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "ConnectorAuthTypeValidation<'_>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "validate_connector_auth_type", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_DecideWalletFlow_get_paze_payment_processing_details
clm
method
// hyperswitch/crates/router/src/core/payments.rs // impl for DecideWalletFlow fn get_paze_payment_processing_details(&self) -> Option<&PazePaymentProcessingDetails> { if let Self::PazeDecrypt(details) = self { Some(details) } else { None } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "DecideWalletFlow", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_paze_payment_processing_details", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_DecideWalletFlow_get_apple_pay_payment_processing_details
clm
method
// hyperswitch/crates/router/src/core/payments.rs // impl for DecideWalletFlow fn get_apple_pay_payment_processing_details( &self, ) -> Option<&payments_api::PaymentProcessingDetails> { if let Self::ApplePayDecrypt(details) = self { Some(details) } else { None } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "DecideWalletFlow", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_apple_pay_payment_processing_details", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_DecideWalletFlow_get_google_pay_payment_processing_details
clm
method
// hyperswitch/crates/router/src/core/payments.rs // impl for DecideWalletFlow fn get_google_pay_payment_processing_details( &self, ) -> Option<&GooglePayPaymentProcessingDetails> { if let Self::GooglePayDecrypt(details) = self { Some(details) } else { None } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "DecideWalletFlow", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_google_pay_payment_processing_details", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_tEligibilityData { _equest(
clm
method
// hyperswitch/crates/router/src/core/payments.rs // impl for tEligibilityData { ync fn from_request( state: &SessionState, merchant_context: &domain::MerchantContext, payments_eligibility_request: &api_models::payments::PaymentsEligibilityRequest, ) -> CustomResult<Self, errors::ApiErrorResponse> { let key_manager_state = &(state).into(); let payment_method_data = payments_eligibility_request .payment_method_data .payment_method_data .clone() .map(domain::PaymentMethodData::from); let browser_info = payments_eligibility_request .browser_info .clone() .map(|browser_info| { serde_json::to_value(browser_info) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to encode payout method data") }) .transpose()? .map(pii::SecretSerdeValue::new); let payment_intent = state .store .find_payment_intent_by_payment_id_merchant_id( key_manager_state, &payments_eligibility_request.payment_id, merchant_context.get_merchant_account().get_id(), merchant_context.get_merchant_key_store(), merchant_context.get_merchant_account().storage_scheme, ) .await .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; Ok(Self { payment_method_data, browser_info, payment_intent, }) } } #[
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "tEligibilityData {\n ", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "equest(\n ", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_tData<F> { _rd_discovery_for_card_payment_method(&self
clm
method
// hyperswitch/crates/router/src/core/payments.rs // impl for tData<F> { _card_discovery_for_card_payment_method(&self) -> Option<common_enums::CardDiscovery> { match self.payment_attempt.payment_method { Some(storage_enums::PaymentMethod::Card) => { if self .token_data .as_ref() .map(storage::PaymentTokenData::is_permanent_card) .unwrap_or(false) { Some(common_enums::CardDiscovery::SavedCard) } else if self.service_details.is_some() { Some(common_enums::CardDiscovery::ClickToPay) } else { Some(common_enums::CardDiscovery::Manual) } } _ => None, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "tData<F> {\n ", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "rd_discovery_for_card_payment_method(&self", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_tData<F> { _nt(&self
clm
method
// hyperswitch/crates/router/src/core/payments.rs // impl for tData<F> { event(&self) -> PaymentEvent { PaymentEvent { payment_intent: self.payment_intent.clone(), payment_attempt: self.payment_attempt.clone(), } } } im
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "tData<F> {\n ", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "nt(&self", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_ilityHandler { _
clm
method
// hyperswitch/crates/router/src/core/payments.rs // impl for ilityHandler { ( state: SessionState, merchant_context: domain::MerchantContext, payment_eligibility_data: PaymentEligibilityData, business_profile: domain::Profile, ) -> Self { Self { state, merchant_context, payment_eligibility_data, business_profile, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "ilityHandler {\n ", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": " ", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_ilityHandler { _eck<C: El
clm
method
// hyperswitch/crates/router/src/core/payments.rs // impl for ilityHandler { fn run_check<C: EligibilityCheck>( &self, check: C, ) -> CustomResult<Option<api_models::payments::SdkNextAction>, errors::ApiErrorResponse> { let should_run = check .should_run(&self.state, &self.merchant_context) .await?; Ok(match should_run { true => check .execute_check( &self.state, &self.merchant_context, &self.payment_eligibility_data, &self.business_profile, ) .await .map(C::transform)?, false => None, }) } } #[
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "ilityHandler {\n ", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "eck<C: El", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_settings::ApiKeys_get_hash_key
clm
method
// hyperswitch/crates/router/src/core/api_keys.rs // impl for settings::ApiKeys pub fn get_hash_key( &self, ) -> errors::RouterResult<&'static StrongSecret<[u8; PlaintextApiKey::HASH_KEY_LEN]>> { HASH_KEY.get_or_try_init(|| { <[u8; PlaintextApiKey::HASH_KEY_LEN]>::try_from( hex::decode(self.hash_key.peek()) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("API key hash key has invalid hexadecimal data")? .as_slice(), ) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("The API hashing key has incorrect length") .map(StrongSecret::new) }) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "settings::ApiKeys", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_hash_key", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_WebhooksFlowError_is_webhook_delivery_retryable_error
clm
method
// hyperswitch/crates/router/src/core/errors.rs // impl for WebhooksFlowError pub(crate) fn is_webhook_delivery_retryable_error(&self) -> bool { match self { Self::MerchantConfigNotFound | Self::MerchantWebhookDetailsNotFound | Self::MerchantWebhookUrlNotConfigured | Self::OutgoingWebhookResponseEncodingFailed => false, Self::WebhookEventUpdationFailed | Self::OutgoingWebhookSigningFailed | Self::CallToMerchantFailed | Self::NotReceivedByMerchant | Self::DisputeWebhookValidationFailed | Self::OutgoingWebhookEncodingFailed | Self::OutgoingWebhookProcessTrackerTaskUpdateFailed | Self::OutgoingWebhookRetrySchedulingFailed | Self::IdGenerationFailed => true, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "WebhooksFlowError", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "is_webhook_delivery_retryable_error", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_AddressStructForDbEntry<'_>_encrypt_customer_address_and_set_to_db
clm
method
// hyperswitch/crates/router/src/core/customers.rs // impl for AddressStructForDbEntry<'_> async fn encrypt_customer_address_and_set_to_db( &self, db: &dyn StorageInterface, ) -> errors::CustomResult<Option<domain::Address>, errors::CustomersErrorResponse> { let encrypted_customer_address = self .address .async_map(|addr| async { self.customer_data .get_domain_address( self.state, addr.clone(), self.merchant_id, self.customer_id .ok_or(errors::CustomersErrorResponse::InternalServerError)?, // should we raise error since in v1 appilcation is supposed to have this id or generate it at this point. self.key_store.key.get_inner().peek(), self.storage_scheme, ) .await .switch() .attach_printable("Failed while encrypting address") }) .await .transpose()?; encrypted_customer_address .async_map(|encrypt_add| async { db.insert_address_for_customers(self.key_manager_state, encrypt_add, self.key_store) .await .switch() .attach_printable("Failed while inserting new address") }) .await .transpose() }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "AddressStructForDbEntry<'_>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "encrypt_customer_address_and_set_to_db", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MerchantReferenceIdForCustomer<'a>_verify_if_merchant_reference_not_present_by_optional_merchant_reference_id
clm
method
// hyperswitch/crates/router/src/core/customers.rs // impl for MerchantReferenceIdForCustomer<'a> async fn verify_if_merchant_reference_not_present_by_optional_merchant_reference_id( &self, db: &dyn StorageInterface, ) -> Result<Option<()>, error_stack::Report<errors::CustomersErrorResponse>> { self.merchant_reference_id .async_map(|merchant_ref| async { self.verify_if_merchant_reference_not_present_by_merchant_reference( merchant_ref, db, ) .await }) .await .transpose() }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MerchantReferenceIdForCustomer<'a>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "verify_if_merchant_reference_not_present_by_optional_merchant_reference_id", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MerchantReferenceIdForCustomer<'a>_verify_if_merchant_reference_not_present_by_merchant_reference_id
clm
method
// hyperswitch/crates/router/src/core/customers.rs // impl for MerchantReferenceIdForCustomer<'a> async fn verify_if_merchant_reference_not_present_by_merchant_reference_id( &self, cus: &'a id_type::CustomerId, db: &dyn StorageInterface, ) -> Result<(), error_stack::Report<errors::CustomersErrorResponse>> { match db .find_customer_by_customer_id_merchant_id( self.key_manager_state, cus, self.merchant_id, self.key_store, self.merchant_account.storage_scheme, ) .await { Err(err) => { if !err.current_context().is_db_not_found() { Err(err).switch() } else { Ok(()) } } Ok(_) => Err(report!( errors::CustomersErrorResponse::CustomerAlreadyExists )), } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MerchantReferenceIdForCustomer<'a>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "verify_if_merchant_reference_not_present_by_merchant_reference_id", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MerchantReferenceIdForCustomer<'a>_verify_if_merchant_reference_not_present_by_optional_merchant_reference_id
clm
method
// hyperswitch/crates/router/src/core/customers.rs // impl for MerchantReferenceIdForCustomer<'a> async fn verify_if_merchant_reference_not_present_by_optional_merchant_reference_id( &self, db: &dyn StorageInterface, ) -> Result<Option<()>, error_stack::Report<errors::CustomersErrorResponse>> { self.merchant_reference_id .async_map(|merchant_ref| async { self.verify_if_merchant_reference_not_present_by_merchant_reference( merchant_ref, db, ) .await }) .await .transpose() }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MerchantReferenceIdForCustomer<'a>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "verify_if_merchant_reference_not_present_by_optional_merchant_reference_id", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MerchantReferenceIdForCustomer<'a>_verify_if_merchant_reference_not_present_by_merchant_reference
clm
method
// hyperswitch/crates/router/src/core/customers.rs // impl for MerchantReferenceIdForCustomer<'a> async fn verify_if_merchant_reference_not_present_by_merchant_reference( &self, merchant_ref: &'a id_type::CustomerId, db: &dyn StorageInterface, ) -> Result<(), error_stack::Report<errors::CustomersErrorResponse>> { match db .find_customer_by_merchant_reference_id_merchant_id( self.key_manager_state, merchant_ref, self.merchant_id, self.key_store, self.merchant_account.storage_scheme, ) .await { Err(err) => { if !err.current_context().is_db_not_found() { Err(err).switch() } else { Ok(()) } } Ok(_) => Err(report!( errors::CustomersErrorResponse::CustomerAlreadyExists )), } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MerchantReferenceIdForCustomer<'a>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "verify_if_merchant_reference_not_present_by_merchant_reference", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_AddressStructForDbUpdate<'_>_update_address_if_sent
clm
method
// hyperswitch/crates/router/src/core/customers.rs // impl for AddressStructForDbUpdate<'_> async fn update_address_if_sent( &self, db: &dyn StorageInterface, ) -> errors::CustomResult<Option<domain::Address>, errors::CustomersErrorResponse> { let address = if let Some(addr) = &self.update_customer.address { match self.domain_customer.address_id.clone() { Some(address_id) => { let customer_address: api_models::payments::AddressDetails = addr.clone(); let update_address = self .update_customer .get_address_update( self.state, customer_address, self.key_store.key.get_inner().peek(), self.merchant_account.storage_scheme, self.merchant_account.get_id().clone(), ) .await .switch() .attach_printable("Failed while encrypting Address while Update")?; Some( db.update_address( self.key_manager_state, address_id, update_address, self.key_store, ) .await .switch() .attach_printable(format!( "Failed while updating address: merchant_id: {:?}, customer_id: {:?}", self.merchant_account.get_id(), self.domain_customer.customer_id ))?, ) } None => { let customer_address: api_models::payments::AddressDetails = addr.clone(); let address = self .update_customer .get_domain_address( self.state, customer_address, self.merchant_account.get_id(), &self.domain_customer.customer_id, self.key_store.key.get_inner().peek(), self.merchant_account.storage_scheme, ) .await .switch() .attach_printable("Failed while encrypting address")?; Some( db.insert_address_for_customers( self.key_manager_state, address, self.key_store, ) .await .switch() .attach_printable("Failed while inserting new address")?, ) } } } else { match &self.domain_customer.address_id { Some(address_id) => Some( db.find_address_by_address_id( self.key_manager_state, address_id, self.key_store, ) .await .switch()?, ), None => None, } }; Ok(address) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "AddressStructForDbUpdate<'_>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "update_address_if_sent", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_VerifyIdForUpdateCustomer<'_>_verify_id_and_get_customer_object
clm
method
// hyperswitch/crates/router/src/core/customers.rs // impl for VerifyIdForUpdateCustomer<'_> async fn verify_id_and_get_customer_object( &self, db: &dyn StorageInterface, ) -> Result<domain::Customer, error_stack::Report<errors::CustomersErrorResponse>> { let customer = db .find_customer_by_global_id( self.key_manager_state, self.id, self.key_store, self.merchant_account.storage_scheme, ) .await .switch()?; Ok(customer) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "VerifyIdForUpdateCustomer<'_>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "verify_id_and_get_customer_object", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_VerifyIdForUpdateCustomer<'_>_verify_id_and_get_customer_object
clm
method
// hyperswitch/crates/router/src/core/customers.rs // impl for VerifyIdForUpdateCustomer<'_> async fn verify_id_and_get_customer_object( &self, db: &dyn StorageInterface, ) -> Result<domain::Customer, error_stack::Report<errors::CustomersErrorResponse>> { let customer = db .find_customer_by_global_id( self.key_manager_state, self.id, self.key_store, self.merchant_account.storage_scheme, ) .await .switch()?; Ok(customer) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "VerifyIdForUpdateCustomer<'_>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "verify_id_and_get_customer_object", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_ExtractedCardInfo_new
clm
method
// hyperswitch/crates/router/src/core/debit_routing.rs // impl for ExtractedCardInfo fn new( co_badged_card_data: Option<api_models::payment_methods::CoBadgedCardData>, card_type: Option<String>, card_isin: Option<Secret<String>>, ) -> Self { Self { co_badged_card_data, card_type, card_isin, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "ExtractedCardInfo", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_ExtractedCardInfo_empty
clm
method
// hyperswitch/crates/router/src/core/debit_routing.rs // impl for ExtractedCardInfo fn empty() -> Self { Self::new(None, None, None) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "ExtractedCardInfo", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "empty", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_PaymentsDslInput<'a>_new
clm
method
// hyperswitch/crates/router/src/core/routing.rs // impl for PaymentsDslInput<'a> pub fn new( setup_mandate: Option<&'a mandates::MandateData>, payment_attempt: &'a storage::PaymentAttempt, payment_intent: &'a storage::PaymentIntent, payment_method_data: Option<&'a domain::PaymentMethodData>, address: &'a payment_address::PaymentAddress, recurring_details: Option<&'a mandates_api::RecurringDetails>, currency: storage_enums::Currency, ) -> Self { Self { setup_mandate, payment_attempt, payment_intent, payment_method_data, address, recurring_details, currency, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "PaymentsDslInput<'a>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RoutingAlgorithmUpdate_create_new_routing_algorithm
clm
method
// hyperswitch/crates/router/src/core/routing.rs // impl for RoutingAlgorithmUpdate pub fn create_new_routing_algorithm( request: &routing_types::RoutingConfigRequest, merchant_id: &common_utils::id_type::MerchantId, profile_id: common_utils::id_type::ProfileId, transaction_type: enums::TransactionType, ) -> Self { let algorithm_id = common_utils::generate_routing_id_of_default_length(); let timestamp = common_utils::date_time::now(); let algo = RoutingAlgorithm { algorithm_id, profile_id, merchant_id: merchant_id.clone(), name: request.name.clone(), description: Some(request.description.clone()), kind: request.algorithm.get_kind().foreign_into(), algorithm_data: serde_json::json!(request.algorithm), created_at: timestamp, modified_at: timestamp, algorithm_for: transaction_type, decision_engine_routing_id: None, }; Self(algo) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RoutingAlgorithmUpdate", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "create_new_routing_algorithm", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RoutingAlgorithmUpdate_fetch_routing_algo
clm
method
// hyperswitch/crates/router/src/core/routing.rs // impl for RoutingAlgorithmUpdate pub async fn fetch_routing_algo( merchant_id: &common_utils::id_type::MerchantId, algorithm_id: &common_utils::id_type::RoutingId, db: &dyn StorageInterface, ) -> RouterResult<Self> { let routing_algo = db .find_routing_algorithm_by_algorithm_id_merchant_id(algorithm_id, merchant_id) .await .change_context(errors::ApiErrorResponse::ResourceIdNotFound)?; Ok(Self(routing_algo)) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RoutingAlgorithmUpdate", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "fetch_routing_algo", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_Object_new
clm
method
// hyperswitch/crates/router/src/core/utils.rs // impl for Object pub fn new(profile_id: &'static str) -> Self { Self { profile_id: Some( common_utils::id_type::ProfileId::try_from(std::borrow::Cow::from( profile_id, )) .expect("invalid profile ID"), ), } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "Object", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_CreateOrValidateOrganization_create_or_validate
clm
method
// hyperswitch/crates/router/src/core/admin.rs // impl for CreateOrValidateOrganization async fn create_or_validate( &self, db: &dyn AccountsStorageInterface, ) -> RouterResult<diesel_models::organization::Organization> { match self { #[cfg(feature = "v1")] Self::Create => { let new_organization = api_models::organization::OrganizationNew::new( OrganizationType::Standard, None, ); let db_organization = ForeignFrom::foreign_from(new_organization); db.insert_organization(db_organization) .await .to_duplicate_response(errors::ApiErrorResponse::InternalServerError) .attach_printable("Error when creating organization") } Self::Validate { organization_id } => db .find_organization_by_org_id(organization_id) .await .to_not_found_response(errors::ApiErrorResponse::GenericNotFoundError { message: "organization with the given id does not exist".to_string(), }), } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "CreateOrValidateOrganization", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "create_or_validate", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_ConnectorStatusAndDisabledValidation<'_>_validate_status_and_disabled
clm
method
// hyperswitch/crates/router/src/core/admin.rs // impl for ConnectorStatusAndDisabledValidation<'_> fn validate_status_and_disabled( &self, ) -> RouterResult<(api_enums::ConnectorStatus, Option<bool>)> { let connector_status = match (self.status, self.auth) { ( Some(common_enums::ConnectorStatus::Active), types::ConnectorAuthType::TemporaryAuth, ) => { return Err(errors::ApiErrorResponse::InvalidRequestData { message: "Connector status cannot be active when using TemporaryAuth" .to_string(), } .into()); } (Some(status), _) => status, (None, types::ConnectorAuthType::TemporaryAuth) => { &common_enums::ConnectorStatus::Inactive } (None, _) => self.current_status, }; let disabled = match (self.disabled, connector_status) { (Some(false), common_enums::ConnectorStatus::Inactive) => { return Err(errors::ApiErrorResponse::InvalidRequestData { message: "Connector cannot be enabled when connector_status is inactive or when using TemporaryAuth" .to_string(), } .into()); } (Some(disabled), _) => Some(*disabled), (None, common_enums::ConnectorStatus::Inactive) => Some(true), // Enable the connector if nothing is passed in the request (None, _) => Some(false), }; Ok((*connector_status, disabled)) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "ConnectorStatusAndDisabledValidation<'_>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "validate_status_and_disabled", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_ConnectorMetadata<'_>_validate_apple_pay_certificates_in_mca_metadata
clm
method
// hyperswitch/crates/router/src/core/admin.rs // impl for ConnectorMetadata<'_> fn validate_apple_pay_certificates_in_mca_metadata(&self) -> RouterResult<()> { self.connector_metadata .clone() .map(api_models::payments::ConnectorMetadata::from_value) .transpose() .change_context(errors::ApiErrorResponse::InvalidDataFormat { field_name: "metadata".to_string(), expected_format: "connector metadata".to_string(), })? .and_then(|metadata| metadata.get_apple_pay_certificates()) .map(|(certificate, certificate_key)| { client::create_identity_from_certificate_and_key(certificate, certificate_key) }) .transpose() .change_context(errors::ApiErrorResponse::InvalidDataValue { field_name: "certificate/certificate key", })?; Ok(()) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "ConnectorMetadata<'_>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "validate_apple_pay_certificates_in_mca_metadata", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_ConnectorTypeAndConnectorName<'_>_get_routable_connector
clm
method
// hyperswitch/crates/router/src/core/admin.rs // impl for ConnectorTypeAndConnectorName<'_> fn get_routable_connector(&self) -> RouterResult<Option<api_enums::RoutableConnectors>> { let mut routable_connector = api_enums::RoutableConnectors::from_str(&self.connector_name.to_string()).ok(); let vault_connector = api_enums::convert_vault_connector(self.connector_name.to_string().as_str()); let pm_auth_connector = api_enums::convert_pm_auth_connector(self.connector_name.to_string().as_str()); let authentication_connector = api_enums::convert_authentication_connector(self.connector_name.to_string().as_str()); let tax_connector = api_enums::convert_tax_connector(self.connector_name.to_string().as_str()); let billing_connector = api_enums::convert_billing_connector(self.connector_name.to_string().as_str()); if pm_auth_connector.is_some() { if self.connector_type != &api_enums::ConnectorType::PaymentMethodAuth && self.connector_type != &api_enums::ConnectorType::PaymentProcessor { return Err(errors::ApiErrorResponse::InvalidRequestData { message: "Invalid connector type given".to_string(), } .into()); } } else if authentication_connector.is_some() { if self.connector_type != &api_enums::ConnectorType::AuthenticationProcessor { return Err(errors::ApiErrorResponse::InvalidRequestData { message: "Invalid connector type given".to_string(), } .into()); } } else if tax_connector.is_some() { if self.connector_type != &api_enums::ConnectorType::TaxProcessor { return Err(errors::ApiErrorResponse::InvalidRequestData { message: "Invalid connector type given".to_string(), } .into()); } } else if billing_connector.is_some() { if self.connector_type != &api_enums::ConnectorType::BillingProcessor { return Err(errors::ApiErrorResponse::InvalidRequestData { message: "Invalid connector type given".to_string(), } .into()); } } else if vault_connector.is_some() { if self.connector_type != &api_enums::ConnectorType::VaultProcessor { return Err(errors::ApiErrorResponse::InvalidRequestData { message: "Invalid connector type given".to_string(), } .into()); } } else { let routable_connector_option = self .connector_name .to_string() .parse::<api_enums::RoutableConnectors>() .change_context(errors::ApiErrorResponse::InvalidRequestData { message: "Invalid connector name given".to_string(), })?; routable_connector = Some(routable_connector_option); }; Ok(routable_connector) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "ConnectorTypeAndConnectorName<'_>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_routable_connector", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_DefaultFallbackRoutingConfigUpdate<'_>_retrieve_and_update_default_fallback_routing_algorithm_if_routable_connector_exists
clm
method
// hyperswitch/crates/router/src/core/admin.rs // impl for DefaultFallbackRoutingConfigUpdate<'_> async fn retrieve_and_update_default_fallback_routing_algorithm_if_routable_connector_exists( &self, ) -> RouterResult<()> { let profile_wrapper = ProfileWrapper::new(self.business_profile.clone()); let default_routing_config_for_profile = &mut profile_wrapper.get_default_fallback_list_of_connector_under_profile()?; if let Some(routable_connector_val) = self.routable_connector { let choice = routing_types::RoutableConnectorChoice { choice_kind: routing_types::RoutableChoiceKind::FullStruct, connector: *routable_connector_val, merchant_connector_id: Some(self.merchant_connector_id.clone()), }; if !default_routing_config_for_profile.contains(&choice.clone()) { default_routing_config_for_profile.push(choice); profile_wrapper .update_default_fallback_routing_of_connectors_under_profile( self.store, default_routing_config_for_profile, self.key_manager_state, &self.key_store, ) .await? } } Ok(()) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "DefaultFallbackRoutingConfigUpdate<'_>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "retrieve_and_update_default_fallback_routing_algorithm_if_routable_connector_exists", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_DefaultFallbackRoutingConfigUpdate<'_>_retrieve_and_delete_from_default_fallback_routing_algorithm_if_routable_connector_exists
clm
method
// hyperswitch/crates/router/src/core/admin.rs // impl for DefaultFallbackRoutingConfigUpdate<'_> async fn retrieve_and_delete_from_default_fallback_routing_algorithm_if_routable_connector_exists( &self, ) -> RouterResult<()> { let profile_wrapper = ProfileWrapper::new(self.business_profile.clone()); let default_routing_config_for_profile = &mut profile_wrapper.get_default_fallback_list_of_connector_under_profile()?; if let Some(routable_connector_val) = self.routable_connector { let choice = routing_types::RoutableConnectorChoice { choice_kind: routing_types::RoutableChoiceKind::FullStruct, connector: *routable_connector_val, merchant_connector_id: Some(self.merchant_connector_id.clone()), }; if default_routing_config_for_profile.contains(&choice.clone()) { default_routing_config_for_profile.retain(|mca| { mca.merchant_connector_id.as_ref() != Some(self.merchant_connector_id) }); profile_wrapper .update_default_fallback_routing_of_connectors_under_profile( self.store, default_routing_config_for_profile, self.key_manager_state, &self.key_store, ) .await? } } Ok(()) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "DefaultFallbackRoutingConfigUpdate<'_>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "retrieve_and_delete_from_default_fallback_routing_algorithm_if_routable_connector_exists", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_LockingInput_get_redis_locking_key
clm
method
// hyperswitch/crates/router/src/core/api_locking.rs // impl for LockingInput fn get_redis_locking_key(&self, merchant_id: &common_utils::id_type::MerchantId) -> String { format!( "{}_{}_{}_{}", API_LOCK_PREFIX, merchant_id.get_string_repr(), self.api_identifier, self.unique_locking_key ) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "LockingInput", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_redis_locking_key", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RequiredFieldsInput_new
clm
method
// hyperswitch/crates/router/src/core/payment_methods.rs // impl for RequiredFieldsInput fn new(required_fields_config: settings::RequiredFields) -> Self { Self { required_fields_config, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RequiredFieldsInput", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RequiredFieldsInput_new
clm
method
// hyperswitch/crates/router/src/core/payments/payment_methods.rs // impl for RequiredFieldsInput fn new( required_fields_config: settings::RequiredFields, setup_future_usage: common_enums::FutureUsage, ) -> Self { Self { required_fields_config, setup_future_usage, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RequiredFieldsInput", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RequiredFieldsForEnabledPaymentMethodTypes_perform_surcharge_calculation
clm
method
// hyperswitch/crates/router/src/core/payments/payment_methods.rs // impl for RequiredFieldsForEnabledPaymentMethodTypes fn perform_surcharge_calculation( self, ) -> RequiredFieldsAndSurchargeForEnabledPaymentMethodTypes { // TODO: Perform surcharge calculation let details_with_surcharge = self .0 .into_iter() .map( |payment_methods_enabled| RequiredFieldsAndSurchargeForEnabledPaymentMethodType { payment_method_type: payment_methods_enabled.payment_method_type, required_fields: payment_methods_enabled.required_fields, payment_method_subtype: payment_methods_enabled.payment_method_subtype, payment_experience: payment_methods_enabled.payment_experience, surcharge: None, connectors: payment_methods_enabled.connectors, }, ) .collect(); RequiredFieldsAndSurchargeForEnabledPaymentMethodTypes(details_with_surcharge) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RequiredFieldsForEnabledPaymentMethodTypes", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "perform_surcharge_calculation", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RequiredFieldsAndSurchargeForEnabledPaymentMethodTypes_populate_pm_subtype_specific_data
clm
method
// hyperswitch/crates/router/src/core/payments/payment_methods.rs // impl for RequiredFieldsAndSurchargeForEnabledPaymentMethodTypes fn populate_pm_subtype_specific_data( self, bank_config: &settings::BankRedirectConfig, ) -> RequiredFieldsAndSurchargeWithExtraInfoForEnabledPaymentMethodTypes { let response_payment_methods = self .0 .into_iter() .map(|payment_methods_enabled| { RequiredFieldsAndSurchargeWithExtraInfoForEnabledPaymentMethodType { payment_method_type: payment_methods_enabled.payment_method_type, payment_method_subtype: payment_methods_enabled.payment_method_subtype, payment_experience: payment_methods_enabled.payment_experience, required_fields: payment_methods_enabled.required_fields, surcharge: payment_methods_enabled.surcharge, pm_subtype_specific_data: get_pm_subtype_specific_data( bank_config, payment_methods_enabled.payment_method_type, payment_methods_enabled.payment_method_subtype, &payment_methods_enabled.connectors, ), } }) .collect(); RequiredFieldsAndSurchargeWithExtraInfoForEnabledPaymentMethodTypes( response_payment_methods, ) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RequiredFieldsAndSurchargeForEnabledPaymentMethodTypes", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "populate_pm_subtype_specific_data", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_RequiredFieldsAndSurchargeWithExtraInfoForEnabledPaymentMethodTypes_generate_response
clm
method
// hyperswitch/crates/router/src/core/payments/payment_methods.rs // impl for RequiredFieldsAndSurchargeWithExtraInfoForEnabledPaymentMethodTypes fn generate_response( self, customer_payment_methods: Option< Vec<api_models::payment_methods::CustomerPaymentMethodResponseItem>, >, ) -> api_models::payments::PaymentMethodListResponseForPayments { let response_payment_methods = self .0 .into_iter() .map(|payment_methods_enabled| { api_models::payments::ResponsePaymentMethodTypesForPayments { payment_method_type: payment_methods_enabled.payment_method_type, payment_method_subtype: payment_methods_enabled.payment_method_subtype, payment_experience: payment_methods_enabled.payment_experience, required_fields: payment_methods_enabled.required_fields, surcharge_details: payment_methods_enabled.surcharge, extra_information: payment_methods_enabled.pm_subtype_specific_data, } }) .collect(); api_models::payments::PaymentMethodListResponseForPayments { payment_methods_enabled: response_payment_methods, customer_payment_methods, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "RequiredFieldsAndSurchargeWithExtraInfoForEnabledPaymentMethodTypes", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "generate_response", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_new_for_sync
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn new_for_sync( captures: Vec<storage::Capture>, expand_captures: Option<bool>, ) -> RouterResult<Self> { let latest_capture = captures .last() .ok_or(errors::ApiErrorResponse::InternalServerError) .attach_printable("Cannot create MultipleCaptureData with empty captures list")? .clone(); let multiple_capture_data = Self { all_captures: captures .into_iter() .map(|capture| (capture.capture_id.clone(), capture)) .collect(), latest_capture, _private: Private {}, expand_captures, }; Ok(multiple_capture_data) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new_for_sync", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_new_for_create
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn new_for_create( mut previous_captures: Vec<storage::Capture>, new_capture: storage::Capture, ) -> Self { previous_captures.push(new_capture.clone()); Self { all_captures: previous_captures .into_iter() .map(|capture| (capture.capture_id.clone(), capture)) .collect(), latest_capture: new_capture, _private: Private {}, expand_captures: None, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new_for_create", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_update_capture
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn update_capture(&mut self, updated_capture: storage::Capture) { let capture_id = &updated_capture.capture_id; if self.all_captures.contains_key(capture_id) { self.all_captures .entry(capture_id.into()) .and_modify(|capture| *capture = updated_capture.clone()); } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "update_capture", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_get_total_blocked_amount
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn get_total_blocked_amount(&self) -> common_types::MinorUnit { self.all_captures .iter() .fold(common_types::MinorUnit::new(0), |accumulator, capture| { accumulator + match capture.1.status { storage_enums::CaptureStatus::Charged | storage_enums::CaptureStatus::Pending => capture.1.amount, storage_enums::CaptureStatus::Started | storage_enums::CaptureStatus::Failed => common_types::MinorUnit::new(0), } }) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_total_blocked_amount", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_get_total_charged_amount
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn get_total_charged_amount(&self) -> common_types::MinorUnit { self.all_captures .iter() .fold(common_types::MinorUnit::new(0), |accumulator, capture| { accumulator + match capture.1.status { storage_enums::CaptureStatus::Charged => capture.1.amount, storage_enums::CaptureStatus::Pending | storage_enums::CaptureStatus::Started | storage_enums::CaptureStatus::Failed => common_types::MinorUnit::new(0), } }) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_total_charged_amount", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_get_captures_count
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn get_captures_count(&self) -> RouterResult<i16> { i16::try_from(self.all_captures.len()) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Error while converting from usize to i16") }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_captures_count", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_get_status_count
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn get_status_count(&self) -> HashMap<storage_enums::CaptureStatus, i16> { let mut hash_map: HashMap<storage_enums::CaptureStatus, i16> = HashMap::new(); hash_map.insert(storage_enums::CaptureStatus::Charged, 0); hash_map.insert(storage_enums::CaptureStatus::Pending, 0); hash_map.insert(storage_enums::CaptureStatus::Started, 0); hash_map.insert(storage_enums::CaptureStatus::Failed, 0); self.all_captures .iter() .fold(hash_map, |mut accumulator, capture| { let current_capture_status = capture.1.status; accumulator .entry(current_capture_status) .and_modify(|count| *count += 1); accumulator }) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_status_count", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_get_attempt_status
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn get_attempt_status( &self, authorized_amount: common_types::MinorUnit, ) -> storage_enums::AttemptStatus { let total_captured_amount = self.get_total_charged_amount(); if authorized_amount == total_captured_amount { return storage_enums::AttemptStatus::Charged; } let status_count_map = self.get_status_count(); if status_count_map.get(&storage_enums::CaptureStatus::Charged) > Some(&0) { storage_enums::AttemptStatus::PartialChargedAndChargeable } else { storage_enums::AttemptStatus::CaptureInitiated } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_attempt_status", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_get_pending_captures
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn get_pending_captures(&self) -> Vec<&storage::Capture> { self.all_captures .iter() .filter(|capture| capture.1.status == storage_enums::CaptureStatus::Pending) .map(|key_value| key_value.1) .collect() }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_pending_captures", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_get_all_captures
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn get_all_captures(&self) -> Vec<&storage::Capture> { self.all_captures .iter() .map(|key_value| key_value.1) .collect() }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_all_captures", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_get_capture_by_capture_id
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn get_capture_by_capture_id(&self, capture_id: String) -> Option<&storage::Capture> { self.all_captures.get(&capture_id) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_capture_by_capture_id", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_get_capture_by_connector_capture_id
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn get_capture_by_connector_capture_id( &self, connector_capture_id: &String, ) -> Option<&storage::Capture> { self.all_captures .iter() .find(|(_, capture)| { capture.get_optional_connector_transaction_id() == Some(connector_capture_id) }) .map(|(_, capture)| capture) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_capture_by_connector_capture_id", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_get_latest_capture
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn get_latest_capture(&self) -> &storage::Capture { &self.latest_capture }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_latest_capture", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_get_pending_connector_capture_ids
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn get_pending_connector_capture_ids(&self) -> Vec<String> { let pending_connector_capture_ids = self .get_pending_captures() .into_iter() .filter_map(|capture| capture.get_optional_connector_transaction_id().cloned()) .collect(); pending_connector_capture_ids }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_pending_connector_capture_ids", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_MultipleCaptureData_get_pending_captures_without_connector_capture_id
clm
method
// hyperswitch/crates/router/src/core/payments/types.rs // impl for MultipleCaptureData pub fn get_pending_captures_without_connector_capture_id(&self) -> Vec<&storage::Capture> { self.get_pending_captures() .into_iter() .filter(|capture| capture.get_optional_connector_transaction_id().is_none()) .collect() }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "MultipleCaptureData", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_pending_captures_without_connector_capture_id", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_PaymentCreate_make_payment_attempt
clm
method
// hyperswitch/crates/router/src/core/payments/operations/payment_create.rs // impl for PaymentCreate pub async fn make_payment_attempt( payment_id: &common_utils::id_type::PaymentId, merchant_id: &common_utils::id_type::MerchantId, organization_id: &common_utils::id_type::OrganizationId, money: (api::Amount, enums::Currency), payment_method: Option<enums::PaymentMethod>, payment_method_type: Option<enums::PaymentMethodType>, request: &api::PaymentsRequest, browser_info: Option<serde_json::Value>, state: &SessionState, optional_payment_method_billing_address_id: Option<String>, payment_method_info: &Option<domain::PaymentMethod>, key_store: &domain::MerchantKeyStore, profile_id: common_utils::id_type::ProfileId, customer_acceptance: &Option<common_payments_types::CustomerAcceptance>, storage_scheme: enums::MerchantStorageScheme, ) -> RouterResult<( storage::PaymentAttemptNew, Option<api_models::payments::AdditionalPaymentData>, )> { let payment_method_data = request .payment_method_data .as_ref() .and_then(|payment_method_data_request| { payment_method_data_request.payment_method_data.as_ref() }); let created_at @ modified_at @ last_synced = Some(common_utils::date_time::now()); let status = helpers::payment_attempt_status_fsm(payment_method_data, request.confirm); let (amount, currency) = (money.0, Some(money.1)); let mut additional_pm_data = request .payment_method_data .as_ref() .and_then(|payment_method_data_request| { payment_method_data_request.payment_method_data.clone() }) .async_map(|payment_method_data| async { helpers::get_additional_payment_data( &payment_method_data.into(), &*state.store, &profile_id, ) .await }) .await .transpose()? .flatten(); if additional_pm_data.is_none() { // If recurring payment is made using payment_method_id, then fetch payment_method_data from retrieved payment_method object additional_pm_data = payment_method_info.as_ref().and_then(|pm_info| { pm_info .payment_method_data .clone() .map(|x| x.into_inner().expose()) .and_then(|v| { serde_json::from_value::<PaymentMethodsData>(v) .map_err(|err| { logger::error!( "Unable to deserialize payment methods data: {:?}", err ) }) .ok() }) .and_then(|pmd| match pmd { PaymentMethodsData::Card(card) => { Some(api_models::payments::AdditionalPaymentData::Card(Box::new( api::CardDetailFromLocker::from(card).into(), ))) } PaymentMethodsData::WalletDetails(wallet) => match payment_method_type { Some(enums::PaymentMethodType::ApplePay) => { Some(api_models::payments::AdditionalPaymentData::Wallet { apple_pay: api::payments::ApplepayPaymentMethod::try_from( wallet, ) .inspect_err(|err| { logger::error!( "Unable to transform PaymentMethodDataWalletInfo to ApplepayPaymentMethod: {:?}", err ) }) .ok(), google_pay: None, samsung_pay: None, }) } Some(enums::PaymentMethodType::GooglePay) => { Some(api_models::payments::AdditionalPaymentData::Wallet { apple_pay: None, google_pay: Some(wallet.into()), samsung_pay: None, }) } Some(enums::PaymentMethodType::SamsungPay) => { Some(api_models::payments::AdditionalPaymentData::Wallet { apple_pay: None, google_pay: None, samsung_pay: Some(wallet.into()), }) } _ => None, }, _ => None, }) .or_else(|| match payment_method_type { Some(enums::PaymentMethodType::Paypal) => { Some(api_models::payments::AdditionalPaymentData::Wallet { apple_pay: None, google_pay: None, samsung_pay: None, }) } _ => None, }) }); }; let additional_pm_data_value = additional_pm_data .as_ref() .map(Encode::encode_to_value) .transpose() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to encode additional pm data")?; let attempt_id = if core_utils::is_merchant_enabled_for_payment_id_as_connector_request_id( &state.conf, merchant_id, ) { payment_id.get_string_repr().to_owned() } else { payment_id.get_attempt_id(1) }; if request.mandate_data.as_ref().is_some_and(|mandate_data| { mandate_data.update_mandate_id.is_some() && mandate_data.mandate_type.is_some() }) { Err(errors::ApiErrorResponse::InvalidRequestData {message:"Only one field out of 'mandate_type' and 'update_mandate_id' was expected, found both".to_string()})? } let mandate_data = if let Some(update_id) = request .mandate_data .as_ref() .and_then(|inner| inner.update_mandate_id.clone()) { let mandate_details = MandateDetails { update_mandate_id: Some(update_id), }; Some(mandate_details) } else { None }; let payment_method_type = Option::<enums::PaymentMethodType>::foreign_from(( payment_method_type, additional_pm_data.as_ref(), payment_method, )); // TODO: remove once https://github.com/juspay/hyperswitch/issues/7421 is fixed let payment_method_billing_address_id = match optional_payment_method_billing_address_id { None => payment_method_info .as_ref() .and_then(|pm_info| pm_info.payment_method_billing_address.as_ref()) .map(|address| { address.clone().deserialize_inner_value(|value| { value.parse_value::<api_models::payments::Address>("Address") }) }) .transpose() .change_context(errors::ApiErrorResponse::InternalServerError) .ok() .flatten() .async_map(|addr| async move { helpers::create_or_find_address_for_payment_by_request( state, Some(addr.get_inner()), None, merchant_id, payment_method_info .as_ref() .map(|pmd_info| pmd_info.customer_id.clone()) .as_ref(), key_store, payment_id, storage_scheme, ) .await }) .await .transpose() .change_context(errors::ApiErrorResponse::InternalServerError)? .flatten() .map(|address| address.address_id), address_id => address_id, }; let is_stored_credential = helpers::is_stored_credential( &request.recurring_details, &request.payment_token, request.mandate_id.is_some(), request.is_stored_credential, ); Ok(( storage::PaymentAttemptNew { payment_id: payment_id.to_owned(), merchant_id: merchant_id.to_owned(), attempt_id, status, currency, payment_method, capture_method: request.capture_method, capture_on: request.capture_on, confirm: request.confirm.unwrap_or(false), created_at, modified_at, last_synced, authentication_type: request.authentication_type, browser_info, payment_experience: request.payment_experience, payment_method_type, payment_method_data: additional_pm_data_value, amount_to_capture: request.amount_to_capture, payment_token: request.payment_token.clone(), mandate_id: request.mandate_id.clone(), business_sub_label: request.business_sub_label.clone(), mandate_details: request .mandate_data .as_ref() .and_then(|inner| inner.mandate_type.clone().map(Into::into)), external_three_ds_authentication_attempted: None, mandate_data, payment_method_billing_address_id, net_amount: hyperswitch_domain_models::payments::payment_attempt::NetAmount::from_payments_request( request, MinorUnit::from(amount), ), save_to_locker: None, connector: None, error_message: None, offer_amount: None, payment_method_id: payment_method_info .as_ref() .map(|pm_info| pm_info.get_id().clone()), cancellation_reason: None, error_code: None, connector_metadata: None, straight_through_algorithm: None, preprocessing_step_id: None, error_reason: None, connector_response_reference_id: None, multiple_capture_count: None, amount_capturable: MinorUnit::new(i64::default()), updated_by: String::default(), authentication_data: None, encoded_data: None, merchant_connector_id: None, unified_code: None, unified_message: None, fingerprint_id: None, authentication_connector: None, authentication_id: None, client_source: None, client_version: None, customer_acceptance: customer_acceptance .clone() .map(|customer_acceptance| customer_acceptance.encode_to_value()) .transpose() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to serialize customer_acceptance")? .map(Secret::new), organization_id: organization_id.clone(), profile_id, connector_mandate_detail: None, request_extended_authorization: None, extended_authorization_applied: None, capture_before: None, card_discovery: None, processor_merchant_id: merchant_id.to_owned(), created_by: None, setup_future_usage_applied: request.setup_future_usage, routing_approach: Some(common_enums::RoutingApproach::default()), connector_request_reference_id: None, network_transaction_id:None, network_details:None, is_stored_credential, authorized_amount: None, }, additional_pm_data, )) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "PaymentCreate", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "make_payment_attempt", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_PaymentCreate_make_payment_intent
clm
method
// hyperswitch/crates/router/src/core/payments/operations/payment_create.rs // impl for PaymentCreate async fn make_payment_intent( state: &SessionState, payment_id: &common_utils::id_type::PaymentId, merchant_context: &domain::MerchantContext, money: (api::Amount, enums::Currency), request: &api::PaymentsRequest, shipping_address_id: Option<String>, payment_link_data: Option<api_models::payments::PaymentLinkResponse>, billing_address_id: Option<String>, active_attempt_id: String, profile_id: common_utils::id_type::ProfileId, session_expiry: PrimitiveDateTime, business_profile: &domain::Profile, is_payment_id_from_merchant: bool, ) -> RouterResult<storage::PaymentIntent> { let created_at @ modified_at @ last_synced = common_utils::date_time::now(); let status = helpers::payment_intent_status_fsm( request .payment_method_data .as_ref() .and_then(|request_payment_method_data| { request_payment_method_data.payment_method_data.as_ref() }), request.confirm, ); let client_secret = payment_id.generate_client_secret(); let (amount, currency) = (money.0, Some(money.1)); let order_details = request .get_order_details_as_value() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to convert order details to value")?; let allowed_payment_method_types = request .get_allowed_payment_method_types_as_value() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Error converting allowed_payment_types to Value")?; let connector_metadata = request .get_connector_metadata_as_value() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Error converting connector_metadata to Value")?; let feature_metadata = request .get_feature_metadata_as_value() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Error converting feature_metadata to Value")?; let payment_link_id = payment_link_data.map(|pl_data| pl_data.payment_link_id); let request_incremental_authorization = core_utils::get_request_incremental_authorization_value( request.request_incremental_authorization, request.capture_method, )?; let split_payments = request.split_payments.clone(); // Derivation of directly supplied Customer data in our Payment Create Request let raw_customer_details = if request.customer_id.is_none() && (request.name.is_some() || request.email.is_some() || request.phone.is_some() || request.phone_country_code.is_some()) { Some(CustomerData { name: request.name.clone(), phone: request.phone.clone(), email: request.email.clone(), phone_country_code: request.phone_country_code.clone(), tax_registration_id: None, }) } else { None }; let is_payment_processor_token_flow = request.recurring_details.as_ref().and_then( |recurring_details| match recurring_details { RecurringDetails::ProcessorPaymentToken(_) => Some(true), _ => None, }, ); let key = merchant_context .get_merchant_key_store() .key .get_inner() .peek(); let identifier = Identifier::Merchant( merchant_context .get_merchant_key_store() .merchant_id .clone(), ); let key_manager_state: KeyManagerState = state.into(); let shipping_details_encoded = request .shipping .clone() .map(|shipping| Encode::encode_to_value(&shipping).map(Secret::new)) .transpose() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to encode billing details to serde_json::Value")?; let billing_details_encoded = request .billing .clone() .map(|billing| Encode::encode_to_value(&billing).map(Secret::new)) .transpose() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to encode billing details to serde_json::Value")?; let customer_details_encoded = raw_customer_details .map(|customer| Encode::encode_to_value(&customer).map(Secret::new)) .transpose() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to encode shipping details to serde_json::Value")?; let encrypted_data = domain::types::crypto_operation( &key_manager_state, type_name!(storage::PaymentIntent), domain::types::CryptoOperation::BatchEncrypt( FromRequestEncryptablePaymentIntent::to_encryptable( FromRequestEncryptablePaymentIntent { shipping_details: shipping_details_encoded, billing_details: billing_details_encoded, customer_details: customer_details_encoded, }, ), ), identifier.clone(), key, ) .await .and_then(|val| val.try_into_batchoperation()) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to encrypt data")?; let encrypted_data = FromRequestEncryptablePaymentIntent::from_encryptable(encrypted_data) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to encrypt the payment intent data")?; let skip_external_tax_calculation = request.skip_external_tax_calculation; let tax_details = request .order_tax_amount .map(|tax_amount| diesel_models::TaxDetails { default: Some(diesel_models::DefaultTax { order_tax_amount: tax_amount, }), payment_method_type: None, }); let force_3ds_challenge_trigger = request .force_3ds_challenge .unwrap_or(business_profile.force_3ds_challenge); Ok(storage::PaymentIntent { payment_id: payment_id.to_owned(), merchant_id: merchant_context.get_merchant_account().get_id().to_owned(), status, amount: MinorUnit::from(amount), currency, description: request.description.clone(), created_at, modified_at, last_synced: Some(last_synced), client_secret: Some(client_secret), setup_future_usage: request.setup_future_usage, off_session: request.off_session, return_url: request.return_url.as_ref().map(|a| a.to_string()), shipping_address_id, billing_address_id, statement_descriptor_name: request.statement_descriptor_name.clone(), statement_descriptor_suffix: request.statement_descriptor_suffix.clone(), metadata: request.metadata.clone(), business_country: request.business_country, business_label: request.business_label.clone(), active_attempt: hyperswitch_domain_models::RemoteStorageObject::ForeignID( active_attempt_id, ), order_details, amount_captured: None, customer_id: request.get_customer_id().cloned(), connector_id: None, allowed_payment_method_types, connector_metadata, feature_metadata, attempt_count: 1, profile_id: Some(profile_id), merchant_decision: None, payment_link_id, payment_confirm_source: None, surcharge_applicable: None, updated_by: merchant_context .get_merchant_account() .storage_scheme .to_string(), request_incremental_authorization, incremental_authorization_allowed: None, authorization_count: None, fingerprint_id: None, session_expiry: Some(session_expiry), request_external_three_ds_authentication: request .request_external_three_ds_authentication, split_payments, frm_metadata: request.frm_metadata.clone(), billing_details: encrypted_data.billing_details, customer_details: encrypted_data.customer_details, merchant_order_reference_id: request.merchant_order_reference_id.clone(), shipping_details: encrypted_data.shipping_details, is_payment_processor_token_flow, organization_id: merchant_context .get_merchant_account() .organization_id .clone(), shipping_cost: request.shipping_cost, tax_details, skip_external_tax_calculation, request_extended_authorization: request.request_extended_authorization, psd2_sca_exemption_type: request.psd2_sca_exemption_type, processor_merchant_id: merchant_context.get_merchant_account().get_id().to_owned(), created_by: None, force_3ds_challenge: request.force_3ds_challenge, force_3ds_challenge_trigger: Some(force_3ds_challenge_trigger), is_iframe_redirection_enabled: request .is_iframe_redirection_enabled .or(business_profile.is_iframe_redirection_enabled), is_payment_id_from_merchant: Some(is_payment_id_from_merchant), payment_channel: request.payment_channel.clone(), order_date: request.order_date, discount_amount: request.discount_amount, duty_amount: request.duty_amount, tax_status: request.tax_status, shipping_amount_tax: request.shipping_amount_tax, enable_partial_authorization: request.enable_partial_authorization, enable_overcapture: request.enable_overcapture, mit_category: request.mit_category, }) }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "PaymentCreate", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "make_payment_intent", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_PaymentCreate_get_ephemeral_key
clm
method
// hyperswitch/crates/router/src/core/payments/operations/payment_create.rs // impl for PaymentCreate pub async fn get_ephemeral_key( request: &api::PaymentsRequest, state: &SessionState, merchant_context: &domain::MerchantContext, ) -> Option<ephemeral_key::EphemeralKey> { match request.get_customer_id() { Some(customer_id) => helpers::make_ephemeral_key( state.clone(), customer_id.clone(), merchant_context .get_merchant_account() .get_id() .to_owned() .clone(), ) .await .ok() .and_then(|ek| { if let services::ApplicationResponse::Json(ek) = ek { Some(ek) } else { None } }), None => None, } }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "PaymentCreate", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_ephemeral_key", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_PaymentUpdate_populate_payment_attempt_with_request
clm
method
// hyperswitch/crates/router/src/core/payments/operations/payment_update.rs // impl for PaymentUpdate fn populate_payment_attempt_with_request( payment_attempt: &mut storage::PaymentAttempt, request: &api::PaymentsRequest, ) { request .business_sub_label .clone() .map(|bsl| payment_attempt.business_sub_label.replace(bsl)); request .payment_method_type .map(|pmt| payment_attempt.payment_method_type.replace(pmt)); request .payment_experience .map(|experience| payment_attempt.payment_experience.replace(experience)); payment_attempt.amount_to_capture = request .amount_to_capture .or(payment_attempt.amount_to_capture); request .capture_method .map(|i| payment_attempt.capture_method.replace(i)); }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "PaymentUpdate", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "populate_payment_attempt_with_request", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_router_PaymentUpdate_populate_payment_intent_with_request
clm
method
// hyperswitch/crates/router/src/core/payments/operations/payment_update.rs // impl for PaymentUpdate fn populate_payment_intent_with_request( payment_intent: &mut storage::PaymentIntent, request: &api::PaymentsRequest, ) { request .return_url .clone() .map(|i| payment_intent.return_url.replace(i.to_string())); payment_intent.business_country = request.business_country; payment_intent .business_label .clone_from(&request.business_label); request .description .clone() .map(|i| payment_intent.description.replace(i)); request .statement_descriptor_name .clone() .map(|i| payment_intent.statement_descriptor_name.replace(i)); request .statement_descriptor_suffix .clone() .map(|i| payment_intent.statement_descriptor_suffix.replace(i)); request .client_secret .clone() .map(|i| payment_intent.client_secret.replace(i)); }
{ "chunk": null, "crate": "router", "enum_name": null, "file_size": null, "for_type": "PaymentUpdate", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "populate_payment_intent_with_request", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }