id stringlengths 20 153 | type stringclasses 1
value | granularity stringclasses 14
values | content stringlengths 16 84.3k | metadata dict |
|---|---|---|---|---|
hyperswitch_fn_hyperswitch_domain_models_7524579118216999242 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
pub fn get_connector_test_mode(&self) -> Option<bool> {
todo!()
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_connector_test_mode",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-1963271255920854715 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
pub fn get_connector_name_as_string(&self) -> String {
self.connector_name.clone().to_string()
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_connector_name_as_string",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-1580782013264534401 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
pub fn get_metadata(&self) -> Option<pii::SecretSerdeValue> {
self.metadata.clone()
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_metadata",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-7879399193763192568 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
pub fn is_disabled(&self) -> bool {
self.disabled.unwrap_or(false)
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "is_disabled",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_5502193371764046865 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
pub fn get_mca_id(&self) -> Option<id_type::MerchantConnectorAccountId> {
match self {
Self::MerchantConnectorAccount(merchant_connector_account) => {
Some(merchant_connector_account.get_id())
}
Self::MerchantConnectorDetails(_) => None,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_mca_id",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_5168857999299418453 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
pub fn get_connector_name(&self) -> common_enums::connector_enums::Connector {
self.connector_name
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_connector_name",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_576292533784151479 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
pub fn get_inner_db_merchant_connector_account(&self) -> Option<&MerchantConnectorAccount> {
match self {
Self::MerchantConnectorAccount(merchant_connector_account) => {
Some(merchant_connector_account)
}
Self::MerchantConnectorDetails(_) => None,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_inner_db_merchant_connector_account",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-3868526644307944851 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
pub fn get_retry_threshold(&self) -> Option<u16> {
self.feature_metadata
.as_ref()
.and_then(|metadata| metadata.revenue_recovery.as_ref())
.map(|recovery| recovery.billing_connector_retry_threshold)
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_retry_threshold",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_3926826507139965414 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
pub fn get_payment_merchant_connector_account_id_using_account_reference_id(
&self,
account_reference_id: String,
) -> Option<id_type::MerchantConnectorAccountId> {
self.feature_metadata.as_ref().and_then(|metadata| {
metadata.revenue_recovery.as_ref().and_then(|recovery| {
recovery
.mca_reference
.billing_to_recovery
.get(&account_reference_id)
.cloned()
})
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_payment_merchant_connector_account_id_using_account_reference_id",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-4227421232003718301 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
pub fn get_account_reference_id_using_payment_merchant_connector_account_id(
&self,
payment_merchant_connector_account_id: id_type::MerchantConnectorAccountId,
) -> Option<String> {
self.feature_metadata.as_ref().and_then(|metadata| {
metadata.revenue_recovery.as_ref().and_then(|recovery| {
recovery
.mca_reference
.recovery_to_billing
.get(&payment_merchant_connector_account_id)
.cloned()
})
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_account_reference_id_using_payment_merchant_connector_account_id",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_4076313364154482429 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
pub fn new(
hash_map: HashMap<id_type::MerchantConnectorAccountId, String>,
) -> Result<Self, api_error_response::ApiErrorResponse> {
Self::validate(&hash_map)?;
let recovery_to_billing = hash_map.clone();
let mut billing_to_recovery = HashMap::new();
for (key, value) in &hash_map {
billing_to_recovery.insert(value.clone(), key.clone());
}
Ok(Self {
recovery_to_billing,
billing_to_recovery,
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "new",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_6800605348270293304 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
fn validate(
hash_map: &HashMap<id_type::MerchantConnectorAccountId, String>,
) -> Result<(), api_error_response::ApiErrorResponse> {
let mut seen_values = std::collections::HashSet::new(); // To check uniqueness of values
for value in hash_map.values() {
if !seen_values.insert(value.clone()) {
return Err(api_error_response::ApiErrorResponse::InvalidRequestData {
message: "Duplicate account reference IDs found in Recovery feature metadata. Each account reference ID must be unique.".to_string(),
});
}
}
Ok(())
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "validate",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-7943702204194837571 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
pub fn from_payment_connectors_list(payment_connectors: Vec<MerchantConnectorAccount>) -> Self {
let payment_methods_enabled_flattened_with_connector = payment_connectors
.into_iter()
.map(|connector| {
(
connector
.payment_methods_enabled
.clone()
.unwrap_or_default(),
connector.connector_name,
connector.get_id(),
)
})
.flat_map(
|(payment_method_enabled, connector, merchant_connector_id)| {
payment_method_enabled
.into_iter()
.flat_map(move |payment_method| {
let request_payment_methods_enabled =
payment_method.payment_method_subtypes.unwrap_or_default();
let length = request_payment_methods_enabled.len();
request_payment_methods_enabled
.into_iter()
.zip(std::iter::repeat_n(
(
connector,
merchant_connector_id.clone(),
payment_method.payment_method_type,
),
length,
))
})
},
)
.map(
|(request_payment_methods, (connector, merchant_connector_id, payment_method))| {
PaymentMethodsEnabledForConnector {
payment_methods_enabled: request_payment_methods,
connector,
payment_method,
merchant_connector_id,
}
},
)
.collect();
Self {
payment_methods_enabled: payment_methods_enabled_flattened_with_connector,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from_payment_connectors_list",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_806747566092828300 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
async fn convert(self) -> CustomResult<Self::DstType, ValidationError> {
Ok(storage::MerchantConnectorAccount {
id: self.id,
merchant_id: self.merchant_id,
connector_name: self.connector_name,
connector_account_details: self.connector_account_details.into(),
disabled: self.disabled,
payment_methods_enabled: self.payment_methods_enabled,
connector_type: self.connector_type,
metadata: self.metadata,
frm_config: self.frm_configs,
connector_label: self.connector_label,
created_at: self.created_at,
modified_at: self.modified_at,
connector_webhook_details: self.connector_webhook_details,
profile_id: self.profile_id,
applepay_verified_domains: self.applepay_verified_domains,
pm_auth_config: self.pm_auth_config,
status: self.status,
connector_wallets_details: self.connector_wallets_details.map(Encryption::from),
additional_merchant_data: self.additional_merchant_data.map(|data| data.into()),
version: self.version,
feature_metadata: self.feature_metadata.map(From::from),
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "convert",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-3087837434183936855 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
async fn convert_back(
state: &KeyManagerState,
other: Self::DstType,
key: &Secret<Vec<u8>>,
_key_manager_identifier: Identifier,
) -> CustomResult<Self, ValidationError> {
let identifier = Identifier::Merchant(other.merchant_id.clone());
let decrypted_data = crypto_operation(
state,
type_name!(Self::DstType),
CryptoOperation::BatchDecrypt(EncryptedMerchantConnectorAccount::to_encryptable(
EncryptedMerchantConnectorAccount {
connector_account_details: other.connector_account_details,
additional_merchant_data: other.additional_merchant_data,
connector_wallets_details: other.connector_wallets_details,
},
)),
identifier.clone(),
key.peek(),
)
.await
.and_then(|val| val.try_into_batchoperation())
.change_context(ValidationError::InvalidValue {
message: "Failed while decrypting connector account details".to_string(),
})?;
let decrypted_data = EncryptedMerchantConnectorAccount::from_encryptable(decrypted_data)
.change_context(ValidationError::InvalidValue {
message: "Failed while decrypting connector account details".to_string(),
})?;
Ok(Self {
id: other.id,
merchant_id: other.merchant_id,
connector_name: other.connector_name,
connector_account_details: decrypted_data.connector_account_details,
disabled: other.disabled,
payment_methods_enabled: other.payment_methods_enabled,
connector_type: other.connector_type,
metadata: other.metadata,
frm_configs: other.frm_config,
connector_label: other.connector_label,
created_at: other.created_at,
modified_at: other.modified_at,
connector_webhook_details: other.connector_webhook_details,
profile_id: other.profile_id,
applepay_verified_domains: other.applepay_verified_domains,
pm_auth_config: other.pm_auth_config,
status: other.status,
connector_wallets_details: decrypted_data.connector_wallets_details,
additional_merchant_data: decrypted_data.additional_merchant_data,
version: other.version,
feature_metadata: other.feature_metadata.map(From::from),
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "convert_back",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_4325071268409916643 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
async fn construct_new(self) -> CustomResult<Self::NewDstType, ValidationError> {
let now = date_time::now();
Ok(Self::NewDstType {
id: self.id,
merchant_id: Some(self.merchant_id),
connector_name: Some(self.connector_name),
connector_account_details: Some(self.connector_account_details.into()),
disabled: self.disabled,
payment_methods_enabled: self.payment_methods_enabled,
connector_type: Some(self.connector_type),
metadata: self.metadata,
frm_config: self.frm_configs,
connector_label: self.connector_label,
created_at: now,
modified_at: now,
connector_webhook_details: self.connector_webhook_details,
profile_id: self.profile_id,
applepay_verified_domains: self.applepay_verified_domains,
pm_auth_config: self.pm_auth_config,
status: self.status,
connector_wallets_details: self.connector_wallets_details.map(Encryption::from),
additional_merchant_data: self.additional_merchant_data.map(|data| data.into()),
version: self.version,
feature_metadata: self.feature_metadata.map(From::from),
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "construct_new",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-3500694619051862497 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
fn from(feature_metadata: DieselMerchantConnectorAccountFeatureMetadata) -> Self {
let revenue_recovery = feature_metadata.revenue_recovery.map(|recovery_metadata| {
let mut billing_to_recovery = HashMap::new();
for (key, value) in &recovery_metadata.billing_account_reference.0 {
billing_to_recovery.insert(value.to_string(), key.clone());
}
RevenueRecoveryMetadata {
max_retry_count: recovery_metadata.max_retry_count,
billing_connector_retry_threshold: recovery_metadata
.billing_connector_retry_threshold,
mca_reference: AccountReferenceMap {
recovery_to_billing: recovery_metadata.billing_account_reference.0,
billing_to_recovery,
},
}
});
Self { revenue_recovery }
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_4872697930653883124 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_id(&self) -> &id_type::GlobalPaymentId {
&self.id
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_id",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_393383445770394914 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn create_start_redirection_url(
&self,
base_url: &str,
publishable_key: String,
) -> CustomResult<url::Url, errors::api_error_response::ApiErrorResponse> {
let start_redirection_url = &format!(
"{}/v2/payments/{}/start-redirection?publishable_key={}&profile_id={}",
base_url,
self.get_id().get_string_repr(),
publishable_key,
self.profile_id.get_string_repr()
);
url::Url::parse(start_redirection_url)
.change_context(errors::api_error_response::ApiErrorResponse::InternalServerError)
.attach_printable("Error creating start redirection url")
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_start_redirection_url",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_3115037740087280408 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_request_extended_authorization_bool_if_connector_supports(
&self,
connector: common_enums::connector_enums::Connector,
always_request_extended_authorization_optional: Option<AlwaysRequestExtendedAuthorization>,
payment_method_optional: Option<common_enums::PaymentMethod>,
payment_method_type_optional: Option<common_enums::PaymentMethodType>,
) -> Option<RequestExtendedAuthorizationBool> {
use router_env::logger;
let is_extended_authorization_supported_by_connector = || {
let supported_pms = connector.get_payment_methods_supporting_extended_authorization();
let supported_pmts =
connector.get_payment_method_types_supporting_extended_authorization();
// check if payment method or payment method type is supported by the connector
logger::info!(
"Extended Authentication Connector:{:?}, Supported payment methods: {:?}, Supported payment method types: {:?}, Payment method Selected: {:?}, Payment method type Selected: {:?}",
connector,
supported_pms,
supported_pmts,
payment_method_optional,
payment_method_type_optional
);
match (payment_method_optional, payment_method_type_optional) {
(Some(payment_method), Some(payment_method_type)) => {
supported_pms.contains(&payment_method)
&& supported_pmts.contains(&payment_method_type)
}
(Some(payment_method), None) => supported_pms.contains(&payment_method),
(None, Some(payment_method_type)) => supported_pmts.contains(&payment_method_type),
(None, None) => false,
}
};
let intent_request_extended_authorization_optional = self.request_extended_authorization;
let is_extended_authorization_requested = intent_request_extended_authorization_optional
.map(|should_request_extended_authorization| *should_request_extended_authorization)
.or(always_request_extended_authorization_optional.map(
|should_always_request_extended_authorization| {
*should_always_request_extended_authorization
},
));
is_extended_authorization_requested
.map(|requested| {
if requested {
is_extended_authorization_supported_by_connector()
} else {
false
}
})
.map(RequestExtendedAuthorizationBool::from)
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_request_extended_authorization_bool_if_connector_supports",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_1553819098447030303 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_enable_overcapture_bool_if_connector_supports(
&self,
connector: common_enums::connector_enums::Connector,
always_enable_overcapture: Option<primitive_wrappers::AlwaysEnableOvercaptureBool>,
capture_method: &Option<common_enums::CaptureMethod>,
) -> Option<EnableOvercaptureBool> {
let is_overcapture_supported_by_connector =
connector.is_overcapture_supported_by_connector();
if matches!(capture_method, Some(common_enums::CaptureMethod::Manual))
&& is_overcapture_supported_by_connector
{
self.enable_overcapture
.or_else(|| always_enable_overcapture.map(EnableOvercaptureBool::from))
} else {
None
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_enable_overcapture_bool_if_connector_supports",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_8529528227986638271 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn create_finish_redirection_url(
&self,
base_url: &str,
publishable_key: &str,
) -> CustomResult<url::Url, errors::api_error_response::ApiErrorResponse> {
let finish_redirection_url = format!(
"{base_url}/v2/payments/{}/finish-redirection/{publishable_key}/{}",
self.id.get_string_repr(),
self.profile_id.get_string_repr()
);
url::Url::parse(&finish_redirection_url)
.change_context(errors::api_error_response::ApiErrorResponse::InternalServerError)
.attach_printable("Error creating finish redirection url")
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_finish_redirection_url",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-8281498156716970282 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn parse_and_get_metadata<T>(
&self,
type_name: &'static str,
) -> CustomResult<Option<T>, common_utils::errors::ParsingError>
where
T: for<'de> masking::Deserialize<'de>,
{
self.metadata
.clone()
.map(|metadata| metadata.parse_value(type_name))
.transpose()
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "parse_and_get_metadata",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_3350251824259610511 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn merge_metadata(
&self,
request_metadata: Value,
) -> Result<Value, common_utils::errors::ParsingError> {
if !request_metadata.is_null() {
match (&self.metadata, &request_metadata) {
(Some(Value::Object(existing_map)), Value::Object(req_map)) => {
let mut merged = existing_map.clone();
merged.extend(req_map.clone());
Ok(Value::Object(merged))
}
(None, Value::Object(_)) => Ok(request_metadata),
_ => {
router_env::logger::error!(
"Expected metadata to be an object, got: {:?}",
request_metadata
);
Err(common_utils::errors::ParsingError::UnknownError)
}
}
} else {
router_env::logger::error!("Metadata does not contain any key");
Err(common_utils::errors::ParsingError::UnknownError)
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "merge_metadata",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_727103452463669350 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
fn get_surcharge_action_as_bool(&self) -> bool {
self.skip_surcharge_calculation.as_bool()
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_surcharge_action_as_bool",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_2511712500593433118 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_external_tax_action_as_bool(&self) -> bool {
self.skip_external_tax_calculation.as_bool()
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_external_tax_action_as_bool",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_5699667480688682923 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn calculate_net_amount(&self) -> MinorUnit {
self.order_amount
+ self.shipping_cost.unwrap_or(MinorUnit::zero())
+ self.surcharge_amount.unwrap_or(MinorUnit::zero())
+ self.tax_on_surcharge.unwrap_or(MinorUnit::zero())
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "calculate_net_amount",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-5375950482375547219 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn create_attempt_amount_details(
&self,
confirm_intent_request: &api_models::payments::PaymentsConfirmIntentRequest,
) -> payment_attempt::AttemptAmountDetails {
let net_amount = self.calculate_net_amount();
let surcharge_amount = match self.skip_surcharge_calculation {
common_enums::SurchargeCalculationOverride::Skip => self.surcharge_amount,
common_enums::SurchargeCalculationOverride::Calculate => None,
};
let tax_on_surcharge = match self.skip_surcharge_calculation {
common_enums::SurchargeCalculationOverride::Skip => self.tax_on_surcharge,
common_enums::SurchargeCalculationOverride::Calculate => None,
};
let order_tax_amount = match self.skip_external_tax_calculation {
common_enums::TaxCalculationOverride::Skip => {
self.tax_details.as_ref().and_then(|tax_details| {
tax_details.get_tax_amount(Some(confirm_intent_request.payment_method_subtype))
})
}
common_enums::TaxCalculationOverride::Calculate => None,
};
payment_attempt::AttemptAmountDetails::from(payment_attempt::AttemptAmountDetailsSetter {
net_amount,
amount_to_capture: None,
surcharge_amount,
tax_on_surcharge,
// This will be updated when we receive response from the connector
amount_capturable: MinorUnit::zero(),
shipping_cost: self.shipping_cost,
order_tax_amount,
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_attempt_amount_details",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-6160114239231691710 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn proxy_create_attempt_amount_details(
&self,
_confirm_intent_request: &api_models::payments::ProxyPaymentsRequest,
) -> payment_attempt::AttemptAmountDetails {
let net_amount = self.calculate_net_amount();
let surcharge_amount = match self.skip_surcharge_calculation {
common_enums::SurchargeCalculationOverride::Skip => self.surcharge_amount,
common_enums::SurchargeCalculationOverride::Calculate => None,
};
let tax_on_surcharge = match self.skip_surcharge_calculation {
common_enums::SurchargeCalculationOverride::Skip => self.tax_on_surcharge,
common_enums::SurchargeCalculationOverride::Calculate => None,
};
let order_tax_amount = match self.skip_external_tax_calculation {
common_enums::TaxCalculationOverride::Skip => self
.tax_details
.as_ref()
.and_then(|tax_details| tax_details.get_tax_amount(None)),
common_enums::TaxCalculationOverride::Calculate => None,
};
payment_attempt::AttemptAmountDetails::from(payment_attempt::AttemptAmountDetailsSetter {
net_amount,
amount_to_capture: None,
surcharge_amount,
tax_on_surcharge,
// This will be updated when we receive response from the connector
amount_capturable: MinorUnit::zero(),
shipping_cost: self.shipping_cost,
order_tax_amount,
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "proxy_create_attempt_amount_details",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-2243627078169156124 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn update_from_request(self, req: &api_models::payments::AmountDetailsUpdate) -> Self {
Self {
order_amount: req
.order_amount()
.unwrap_or(self.order_amount.into())
.into(),
currency: req.currency().unwrap_or(self.currency),
shipping_cost: req.shipping_cost().or(self.shipping_cost),
tax_details: req
.order_tax_amount()
.map(|order_tax_amount| TaxDetails {
default: Some(diesel_models::DefaultTax { order_tax_amount }),
payment_method_type: None,
})
.or(self.tax_details),
skip_external_tax_calculation: req
.skip_external_tax_calculation()
.unwrap_or(self.skip_external_tax_calculation),
skip_surcharge_calculation: req
.skip_surcharge_calculation()
.unwrap_or(self.skip_surcharge_calculation),
surcharge_amount: req.surcharge_amount().or(self.surcharge_amount),
tax_on_surcharge: req.tax_on_surcharge().or(self.tax_on_surcharge),
amount_captured: self.amount_captured,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_from_request",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_580036968132037312 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn extract_connector_customer_id_from_payment_intent(
&self,
) -> Result<String, common_utils::errors::ValidationError> {
self.feature_metadata
.as_ref()
.and_then(|metadata| metadata.payment_revenue_recovery_metadata.as_ref())
.map(|recovery| {
recovery
.billing_connector_payment_details
.connector_customer_id
.clone()
})
.ok_or(
common_utils::errors::ValidationError::MissingRequiredField {
field_name: "connector_customer_id".to_string(),
},
)
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_connector_customer_id_from_payment_intent",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-8712799422134838853 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
fn get_payment_method_sub_type(&self) -> Option<common_enums::PaymentMethodType> {
self.feature_metadata
.as_ref()
.and_then(|metadata| metadata.get_payment_method_sub_type())
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_payment_method_sub_type",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-170383630682958585 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
fn get_payment_method_type(&self) -> Option<common_enums::PaymentMethod> {
self.feature_metadata
.as_ref()
.and_then(|metadata| metadata.get_payment_method_type())
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_payment_method_type",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_7681496936416712139 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_connector_customer_id_from_feature_metadata(&self) -> Option<String> {
self.feature_metadata
.as_ref()
.and_then(|metadata| metadata.payment_revenue_recovery_metadata.as_ref())
.map(|recovery_metadata| {
recovery_metadata
.billing_connector_payment_details
.connector_customer_id
.clone()
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_connector_customer_id_from_feature_metadata",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-7759276813314928079 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_billing_merchant_connector_account_id(
&self,
) -> Option<id_type::MerchantConnectorAccountId> {
self.feature_metadata.as_ref().and_then(|feature_metadata| {
feature_metadata.get_billing_merchant_connector_account_id()
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_billing_merchant_connector_account_id",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_4025388446862969506 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
fn get_request_incremental_authorization_value(
request: &api_models::payments::PaymentsCreateIntentRequest,
) -> CustomResult<
common_enums::RequestIncrementalAuthorization,
errors::api_error_response::ApiErrorResponse,
> {
request.request_incremental_authorization
.map(|request_incremental_authorization| {
if request_incremental_authorization == common_enums::RequestIncrementalAuthorization::True {
if request.capture_method == Some(common_enums::CaptureMethod::Automatic) {
Err(errors::api_error_response::ApiErrorResponse::InvalidRequestData { message: "incremental authorization is not supported when capture_method is automatic".to_owned() })?
}
Ok(common_enums::RequestIncrementalAuthorization::True)
} else {
Ok(common_enums::RequestIncrementalAuthorization::False)
}
})
.unwrap_or(Ok(common_enums::RequestIncrementalAuthorization::default()))
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_request_incremental_authorization_value",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-3507624184900813856 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub async fn create_domain_model_from_request(
payment_id: &id_type::GlobalPaymentId,
merchant_context: &merchant_context::MerchantContext,
profile: &business_profile::Profile,
request: api_models::payments::PaymentsCreateIntentRequest,
decrypted_payment_intent: DecryptedPaymentIntent,
) -> CustomResult<Self, errors::api_error_response::ApiErrorResponse> {
let request_incremental_authorization =
Self::get_request_incremental_authorization_value(&request)?;
let allowed_payment_method_types = request.allowed_payment_method_types;
let session_expiry =
common_utils::date_time::now().saturating_add(time::Duration::seconds(
request.session_expiry.map(i64::from).unwrap_or(
profile
.session_expiry
.unwrap_or(common_utils::consts::DEFAULT_SESSION_EXPIRY),
),
));
let order_details = request.order_details.map(|order_details| {
order_details
.into_iter()
.map(|order_detail| Secret::new(OrderDetailsWithAmount::convert_from(order_detail)))
.collect()
});
Ok(Self {
id: payment_id.clone(),
merchant_id: merchant_context.get_merchant_account().get_id().clone(),
// Intent status would be RequiresPaymentMethod because we are creating a new payment intent
status: common_enums::IntentStatus::RequiresPaymentMethod,
amount_details: AmountDetails::from(request.amount_details),
amount_captured: None,
customer_id: request.customer_id,
description: request.description,
return_url: request.return_url,
metadata: request.metadata,
statement_descriptor: request.statement_descriptor,
created_at: common_utils::date_time::now(),
modified_at: common_utils::date_time::now(),
last_synced: None,
setup_future_usage: request.setup_future_usage.unwrap_or_default(),
active_attempt_id: None,
active_attempt_id_type: common_enums::ActiveAttemptIDType::AttemptID,
active_attempts_group_id: None,
order_details,
allowed_payment_method_types,
connector_metadata: request.connector_metadata,
feature_metadata: request.feature_metadata.map(FeatureMetadata::convert_from),
// Attempt count is 0 in create intent as no attempt is made yet
attempt_count: 0,
profile_id: profile.get_id().clone(),
payment_link_id: None,
frm_merchant_decision: None,
updated_by: merchant_context
.get_merchant_account()
.storage_scheme
.to_string(),
request_incremental_authorization,
// Authorization count is 0 in create intent as no authorization is made yet
authorization_count: Some(0),
session_expiry,
request_external_three_ds_authentication: request
.request_external_three_ds_authentication
.unwrap_or_default(),
split_txns_enabled: profile.split_txns_enabled,
frm_metadata: request.frm_metadata,
customer_details: None,
merchant_reference_id: request.merchant_reference_id,
billing_address: decrypted_payment_intent
.billing_address
.as_ref()
.map(|data| {
data.clone()
.deserialize_inner_value(|value| value.parse_value("Address"))
})
.transpose()
.change_context(errors::api_error_response::ApiErrorResponse::InternalServerError)
.attach_printable("Unable to decode billing address")?,
shipping_address: decrypted_payment_intent
.shipping_address
.as_ref()
.map(|data| {
data.clone()
.deserialize_inner_value(|value| value.parse_value("Address"))
})
.transpose()
.change_context(errors::api_error_response::ApiErrorResponse::InternalServerError)
.attach_printable("Unable to decode shipping address")?,
capture_method: request.capture_method.unwrap_or_default(),
authentication_type: request.authentication_type,
prerouting_algorithm: None,
organization_id: merchant_context
.get_merchant_account()
.organization_id
.clone(),
enable_payment_link: request.payment_link_enabled.unwrap_or_default(),
apply_mit_exemption: request.apply_mit_exemption.unwrap_or_default(),
customer_present: request.customer_present.unwrap_or_default(),
payment_link_config: request
.payment_link_config
.map(ApiModelToDieselModelConvertor::convert_from),
routing_algorithm_id: request.routing_algorithm_id,
split_payments: None,
force_3ds_challenge: None,
force_3ds_challenge_trigger: None,
processor_merchant_id: merchant_context.get_merchant_account().get_id().clone(),
created_by: None,
is_iframe_redirection_enabled: None,
is_payment_id_from_merchant: None,
enable_partial_authorization: request.enable_partial_authorization,
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_domain_model_from_request",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-4776055097301064337 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_revenue_recovery_metadata(
&self,
) -> Option<diesel_models::types::PaymentRevenueRecoveryMetadata> {
self.feature_metadata
.as_ref()
.and_then(|feature_metadata| feature_metadata.payment_revenue_recovery_metadata.clone())
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_revenue_recovery_metadata",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_2567203247062559612 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_feature_metadata(&self) -> Option<FeatureMetadata> {
self.feature_metadata.clone()
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_feature_metadata",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_5568234268255227388 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn create_revenue_recovery_attempt_data(
&self,
revenue_recovery_metadata: api_models::payments::PaymentRevenueRecoveryMetadata,
billing_connector_account: &merchant_connector_account::MerchantConnectorAccount,
card_info: api_models::payments::AdditionalCardInfo,
payment_processor_token: &str,
) -> CustomResult<
revenue_recovery::RevenueRecoveryAttemptData,
errors::api_error_response::ApiErrorResponse,
> {
let merchant_reference_id = self.merchant_reference_id.clone().ok_or_else(|| {
error_stack::report!(
errors::api_error_response::ApiErrorResponse::GenericNotFoundError {
message: "mandate reference id not found".to_string()
}
)
})?;
let connector_account_reference_id = billing_connector_account
.get_account_reference_id_using_payment_merchant_connector_account_id(
revenue_recovery_metadata.active_attempt_payment_connector_id,
)
.ok_or_else(|| {
error_stack::report!(
errors::api_error_response::ApiErrorResponse::GenericNotFoundError {
message: "connector account reference id not found".to_string()
}
)
})?;
Ok(revenue_recovery::RevenueRecoveryAttemptData {
amount: self.amount_details.order_amount,
currency: self.amount_details.currency,
merchant_reference_id,
connector_transaction_id: None, // No connector id
error_code: None,
error_message: None,
processor_payment_method_token: payment_processor_token.to_string(),
connector_customer_id: revenue_recovery_metadata
.billing_connector_payment_details
.connector_customer_id,
connector_account_reference_id,
transaction_created_at: None, // would unwrap_or as now
status: common_enums::AttemptStatus::Started,
payment_method_type: self
.get_payment_method_type()
.unwrap_or(revenue_recovery_metadata.payment_method_type),
payment_method_sub_type: self
.get_payment_method_sub_type()
.unwrap_or(revenue_recovery_metadata.payment_method_subtype),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
retry_count: None,
invoice_next_billing_time: None,
invoice_billing_started_at_time: None,
// No charge id is present here since it is an internal payment and we didn't call connector yet.
charge_id: None,
card_info: card_info.clone(),
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_revenue_recovery_attempt_data",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_7628334668144385690 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_optional_customer_id(
&self,
) -> CustomResult<Option<id_type::CustomerId>, common_utils::errors::ValidationError> {
self.customer_id
.as_ref()
.map(|customer_id| id_type::CustomerId::try_from(customer_id.clone()))
.transpose()
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_optional_customer_id",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-52487330085375309 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_currency(&self) -> storage_enums::Currency {
self.amount_details.currency
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_currency",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-1801231373093372122 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn with_source(payment_confirm_source: common_enums::PaymentSource) -> Self {
Self {
payment_confirm_source: Some(payment_confirm_source),
..Default::default()
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "with_source",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-6272292418623674799 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_connector_customer_id(
&self,
customer: Option<&customer::Customer>,
merchant_connector_account: &MerchantConnectorAccountTypeDetails,
) -> Option<String> {
match merchant_connector_account {
MerchantConnectorAccountTypeDetails::MerchantConnectorAccount(_) => customer
.and_then(|customer| customer.get_connector_customer_id(merchant_connector_account))
.map(|id| id.to_string())
.or_else(|| {
self.payment_intent
.get_connector_customer_id_from_feature_metadata()
}),
MerchantConnectorAccountTypeDetails::MerchantConnectorDetails(_) => None,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_connector_customer_id",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-549310430713155411 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn update_payment_method_data(
&mut self,
payment_method_data: payment_method_data::PaymentMethodData,
) {
self.payment_method_data = Some(payment_method_data);
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_payment_method_data",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_5835162132386389603 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn update_payment_method_and_pm_id(
&mut self,
payment_method_id: id_type::GlobalPaymentMethodId,
payment_method: payment_methods::PaymentMethod,
) {
self.payment_attempt.payment_method_id = Some(payment_method_id);
self.payment_method = Some(payment_method);
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_payment_method_and_pm_id",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_1671261531441677404 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_payment_id(&self) -> &id_type::GlobalPaymentId {
&self.payment_intent.id
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_payment_id",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_5283930008238826929 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_updated_feature_metadata(
&self,
) -> CustomResult<Option<FeatureMetadata>, errors::api_error_response::ApiErrorResponse> {
let payment_intent_feature_metadata = self.payment_intent.get_feature_metadata();
let revenue_recovery = self.payment_intent.get_revenue_recovery_metadata();
let payment_attempt_connector = self.payment_attempt.connector.clone();
let feature_metadata_first_pg_error_code = revenue_recovery
.as_ref()
.and_then(|data| data.first_payment_attempt_pg_error_code.clone());
let (first_pg_error_code, first_network_advice_code, first_network_decline_code) =
feature_metadata_first_pg_error_code.map_or_else(
|| {
let first_pg_error_code = self
.payment_attempt
.error
.as_ref()
.map(|error| error.code.clone());
let first_network_advice_code = self
.payment_attempt
.error
.as_ref()
.and_then(|error| error.network_advice_code.clone());
let first_network_decline_code = self
.payment_attempt
.error
.as_ref()
.and_then(|error| error.network_decline_code.clone());
(
first_pg_error_code,
first_network_advice_code,
first_network_decline_code,
)
},
|pg_code| {
let advice_code = revenue_recovery
.as_ref()
.and_then(|data| data.first_payment_attempt_network_advice_code.clone());
let decline_code = revenue_recovery
.as_ref()
.and_then(|data| data.first_payment_attempt_network_decline_code.clone());
(Some(pg_code), advice_code, decline_code)
},
);
let billing_connector_payment_method_details = Some(
diesel_models::types::BillingConnectorPaymentMethodDetails::Card(
diesel_models::types::BillingConnectorAdditionalCardInfo {
card_network: self.revenue_recovery_data.card_network.clone(),
card_issuer: self.revenue_recovery_data.card_issuer.clone(),
},
),
);
let payment_revenue_recovery_metadata = match payment_attempt_connector {
Some(connector) => Some(diesel_models::types::PaymentRevenueRecoveryMetadata {
// Update retry count by one.
total_retry_count: revenue_recovery.as_ref().map_or(
self.revenue_recovery_data
.retry_count
.map_or_else(|| 1, |retry_count| retry_count),
|data| (data.total_retry_count + 1),
),
// Since this is an external system call, marking this payment_connector_transmission to ConnectorCallSucceeded.
payment_connector_transmission:
common_enums::PaymentConnectorTransmission::ConnectorCallUnsuccessful,
billing_connector_id: self.revenue_recovery_data.billing_connector_id.clone(),
active_attempt_payment_connector_id: self
.payment_attempt
.get_attempt_merchant_connector_account_id()?,
billing_connector_payment_details:
diesel_models::types::BillingConnectorPaymentDetails {
payment_processor_token: self
.revenue_recovery_data
.processor_payment_method_token
.clone(),
connector_customer_id: self
.revenue_recovery_data
.connector_customer_id
.clone(),
},
payment_method_type: self.payment_attempt.payment_method_type,
payment_method_subtype: self.payment_attempt.payment_method_subtype,
connector: connector.parse().map_err(|err| {
router_env::logger::error!(?err, "Failed to parse connector string to enum");
errors::api_error_response::ApiErrorResponse::InternalServerError
})?,
invoice_next_billing_time: self.revenue_recovery_data.invoice_next_billing_time,
invoice_billing_started_at_time: self
.revenue_recovery_data
.invoice_next_billing_time,
billing_connector_payment_method_details,
first_payment_attempt_network_advice_code: first_network_advice_code,
first_payment_attempt_network_decline_code: first_network_decline_code,
first_payment_attempt_pg_error_code: first_pg_error_code,
}),
None => Err(errors::api_error_response::ApiErrorResponse::InternalServerError)
.attach_printable("Connector not found in payment attempt")?,
};
Ok(Some(FeatureMetadata {
redirect_response: payment_intent_feature_metadata
.as_ref()
.and_then(|data| data.redirect_response.clone()),
search_tags: payment_intent_feature_metadata
.as_ref()
.and_then(|data| data.search_tags.clone()),
apple_pay_recurring_details: payment_intent_feature_metadata
.as_ref()
.and_then(|data| data.apple_pay_recurring_details.clone()),
payment_revenue_recovery_metadata,
}))
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_updated_feature_metadata",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-2303598201326789201 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_updated_vault_data(
existing_vault_data: Option<&Self>,
payment_method_data: &payment_method_data::PaymentMethodData,
) -> Option<Self> {
match (existing_vault_data, payment_method_data) {
(None, payment_method_data::PaymentMethodData::Card(card)) => {
Some(Self::ExistingVaultData(VaultData::Card(card.clone())))
}
(None, payment_method_data::PaymentMethodData::NetworkToken(nt_data)) => Some(
Self::ExistingVaultData(VaultData::NetworkToken(nt_data.clone())),
),
(Some(Self::ExistingVaultData(vault_data)), payment_method_data) => {
match (vault_data, payment_method_data) {
(
VaultData::Card(card),
payment_method_data::PaymentMethodData::NetworkToken(nt_data),
) => Some(Self::ExistingVaultData(VaultData::CardAndNetworkToken(
Box::new(CardAndNetworkTokenData {
card_data: card.clone(),
network_token_data: nt_data.clone(),
}),
))),
(
VaultData::NetworkToken(nt_data),
payment_method_data::PaymentMethodData::Card(card),
) => Some(Self::ExistingVaultData(VaultData::CardAndNetworkToken(
Box::new(CardAndNetworkTokenData {
card_data: card.clone(),
network_token_data: nt_data.clone(),
}),
))),
_ => Some(Self::ExistingVaultData(vault_data.clone())),
}
}
//payment_method_data is not card or network token
_ => None,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_updated_vault_data",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_9143708865562689413 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_card_vault_data(&self) -> Option<payment_method_data::Card> {
match self {
Self::Card(card_data) => Some(card_data.clone()),
Self::NetworkToken(_network_token_data) => None,
Self::CardAndNetworkToken(vault_data) => Some(vault_data.card_data.clone()),
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_card_vault_data",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_6118887878042885969 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/payments.rs
pub fn get_network_token_data(&self) -> Option<payment_method_data::NetworkTokenData> {
match self {
Self::Card(_card_data) => None,
Self::NetworkToken(network_token_data) => Some(network_token_data.clone()),
Self::CardAndNetworkToken(vault_data) => Some(vault_data.network_token_data.clone()),
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_network_token_data",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_6923429912582845586 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_context.rs
pub fn get_merchant_account(&self) -> &MerchantAccount {
match self {
Self::NormalMerchant(merchant_account) => &merchant_account.0,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_merchant_account",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_9055294334108245910 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/merchant_context.rs
pub fn get_merchant_key_store(&self) -> &MerchantKeyStore {
match self {
Self::NormalMerchant(merchant_account) => &merchant_account.1,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_merchant_key_store",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_7919649034005065086 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/lib.rs
fn from(error: &api_models::payments::RecordAttemptErrorDetails) -> Self {
Self {
code: error.code.clone(),
message: error.message.clone(),
reason: Some(error.message.clone()),
unified_code: None,
unified_message: None,
network_advice_code: error.network_advice_code.clone(),
network_decline_code: error.network_decline_code.clone(),
network_error_message: error.network_error_message.clone(),
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_4692654944488895251 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/lib.rs
pub fn get_id(&self) -> String {
match self {
Self::ForeignID(id) => id.clone(),
Self::Object(i) => i.foreign_id(),
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_id",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-4117844570527724170 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/lib.rs
fn convert_from(from: api_models::admin::TransactionDetailsUiConfiguration) -> Self {
Self {
position: from.position,
is_key_bold: from.is_key_bold,
is_value_bold: from.is_value_bold,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "convert_from",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-3537425359216272808 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/lib.rs
fn convert_back(self) -> api_models::admin::TransactionDetailsUiConfiguration {
let Self {
position,
is_key_bold,
is_value_bold,
} = self;
api_models::admin::TransactionDetailsUiConfiguration {
position,
is_key_bold,
is_value_bold,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "convert_back",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_335582844142438966 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/connector_endpoints.rs
pub fn get_connector_params(
&self,
connector: connector_enums::Connector,
) -> CustomResult<ConnectorParams, api_error_response::ApiErrorResponse> {
match connector {
connector_enums::Connector::Recurly => Ok(self.recurly.clone()),
connector_enums::Connector::Stripebilling => Ok(self.stripebilling.clone()),
connector_enums::Connector::Chargebee => Ok(self.chargebee.clone()),
_ => Err(api_error_response::ApiErrorResponse::IncorrectConnectorNameGiven.into()),
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_connector_params",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-5796073831042791681 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/connector_endpoints.rs
pub fn validate(&self, _parent_field: &str) -> Result<(), ApplicationError> {
Ok(())
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "validate",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_890378505422206567 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/disputes.rs
fn try_from(
(value, auth_profile_id_list): (
api_models::disputes::DisputeListGetConstraints,
Option<Vec<common_utils::id_type::ProfileId>>,
),
) -> Result<Self, Self::Error> {
let api_models::disputes::DisputeListGetConstraints {
dispute_id,
payment_id,
limit,
offset,
profile_id,
dispute_status,
dispute_stage,
reason,
connector,
merchant_connector_id,
currency,
time_range,
} = value;
let profile_id_from_request_body = profile_id;
// Match both the profile ID from the request body and the list of authenticated profile IDs coming from auth layer
let profile_id_list = match (profile_id_from_request_body, auth_profile_id_list) {
(None, None) => None,
// Case when the request body profile ID is None, but authenticated profile IDs are available, return the auth list
(None, Some(auth_profile_id_list)) => Some(auth_profile_id_list),
// Case when the request body profile ID is provided, but the auth list is None, create a vector with the request body profile ID
(Some(profile_id_from_request_body), None) => Some(vec![profile_id_from_request_body]),
(Some(profile_id_from_request_body), Some(auth_profile_id_list)) => {
// Check if the profile ID from the request body is present in the authenticated profile ID list
let profile_id_from_request_body_is_available_in_auth_profile_id_list =
auth_profile_id_list.contains(&profile_id_from_request_body);
if profile_id_from_request_body_is_available_in_auth_profile_id_list {
Some(vec![profile_id_from_request_body])
} else {
// If the profile ID is not valid, return an error indicating access is not available
return Err(error_stack::Report::new(
errors::api_error_response::ApiErrorResponse::PreconditionFailed {
message: format!(
"Access not available for the given profile_id {profile_id_from_request_body:?}",
),
},
));
}
}
};
Ok(Self {
dispute_id,
payment_id,
limit,
offset,
profile_id: profile_id_list,
dispute_status,
dispute_stage,
reason,
connector,
merchant_connector_id,
currency,
time_range,
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_2417196684591801278 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/subscription.rs
pub fn new(
connector_subscription_id: Option<String>,
payment_method_id: Option<Secret<String>>,
status: Option<String>,
plan_id: Option<String>,
item_price_id: Option<String>,
) -> Self {
Self {
connector_subscription_id,
payment_method_id: payment_method_id.map(|pmid| pmid.peek().clone()),
status,
modified_at: common_utils::date_time::now(),
plan_id,
item_price_id,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "new",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_323925541664759039 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/subscription.rs
pub fn get_subscription_id(&self) -> error_stack::Result<String, ApiErrorResponse> {
let sub_id = self
.0
.split(SECRET_SPLIT)
.next()
.ok_or(ApiErrorResponse::MissingRequiredField {
field_name: "client_secret",
})
.attach_printable("Failed to extract subscription_id from client_secret")?;
Ok(sub_id.to_string())
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_subscription_id",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_9202216504673024922 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/subscription.rs
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Active => write!(f, "Active"),
Self::Created => write!(f, "Created"),
Self::InActive => write!(f, "InActive"),
Self::Pending => write!(f, "Pending"),
Self::Trial => write!(f, "Trial"),
Self::Paused => write!(f, "Paused"),
Self::Unpaid => write!(f, "Unpaid"),
Self::Onetime => write!(f, "Onetime"),
Self::Cancelled => write!(f, "Cancelled"),
Self::Failed => write!(f, "Failed"),
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "fmt",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_532278354837082155 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/subscription.rs
fn from(domain_secret: ClientSecret) -> Self {
Self::new(domain_secret.to_string())
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_5767424117921312155 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/subscription.rs
pub fn generate_and_set_client_secret(&mut self) -> Secret<String> {
let client_secret =
generate_id_with_default_len(&format!("{}_secret", self.id.get_string_repr()));
self.client_secret = Some(client_secret.clone());
Secret::new(client_secret)
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_and_set_client_secret",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-7834475209741192878 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/subscription.rs
async fn convert(self) -> CustomResult<Self::DstType, ValidationError> {
Ok(diesel_models::subscription::SubscriptionUpdate {
connector_subscription_id: self.connector_subscription_id,
payment_method_id: self.payment_method_id,
status: self.status,
modified_at: self.modified_at,
plan_id: self.plan_id,
item_price_id: self.item_price_id,
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "convert",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_2198406858694349935 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/subscription.rs
async fn convert_back(
_state: &KeyManagerState,
item: Self::DstType,
_key: &Secret<Vec<u8>>,
_key_manager_identifier: keymanager::Identifier,
) -> CustomResult<Self, ValidationError>
where
Self: Sized,
{
Ok(Self {
connector_subscription_id: item.connector_subscription_id,
payment_method_id: item.payment_method_id,
status: item.status,
modified_at: item.modified_at,
plan_id: item.plan_id,
item_price_id: item.item_price_id,
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "convert_back",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-2465197129210620823 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/subscription.rs
async fn construct_new(self) -> CustomResult<Self::NewDstType, ValidationError> {
Ok(diesel_models::subscription::SubscriptionUpdate {
connector_subscription_id: self.connector_subscription_id,
payment_method_id: self.payment_method_id,
status: self.status,
modified_at: self.modified_at,
plan_id: self.plan_id,
item_price_id: self.item_price_id,
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "construct_new",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_6254340534042606013 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/address.rs
pub fn unify_address(&self, other: Option<&Self>) -> Self {
let other_address_details = other.and_then(|address| address.address.as_ref());
Self {
address: self
.address
.as_ref()
.map(|address| address.unify_address_details(other_address_details))
.or(other_address_details.cloned()),
email: self
.email
.clone()
.or(other.and_then(|other| other.email.clone())),
phone: {
self.phone
.clone()
.and_then(|phone_details| {
if phone_details.number.is_some() {
Some(phone_details)
} else {
None
}
})
.or_else(|| other.and_then(|other| other.phone.clone()))
},
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "unify_address",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-8722852173115030398 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/address.rs
pub fn get_optional_full_name(&self) -> Option<Secret<String>> {
match (self.first_name.as_ref(), self.last_name.as_ref()) {
(Some(first_name), Some(last_name)) => Some(Secret::new(format!(
"{} {}",
first_name.peek(),
last_name.peek()
))),
(Some(name), None) | (None, Some(name)) => Some(name.to_owned()),
_ => None,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_optional_full_name",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_4276137794936254598 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/address.rs
pub fn unify_address_details(&self, other: Option<&Self>) -> Self {
if let Some(other) = other {
let (first_name, last_name) = if self
.first_name
.as_ref()
.is_some_and(|first_name| !first_name.peek().trim().is_empty())
{
(self.first_name.clone(), self.last_name.clone())
} else {
(other.first_name.clone(), other.last_name.clone())
};
Self {
first_name,
last_name,
city: self.city.clone().or(other.city.clone()),
country: self.country.or(other.country),
line1: self.line1.clone().or(other.line1.clone()),
line2: self.line2.clone().or(other.line2.clone()),
line3: self.line3.clone().or(other.line3.clone()),
zip: self.zip.clone().or(other.zip.clone()),
state: self.state.clone().or(other.state.clone()),
origin_zip: self.origin_zip.clone().or(other.origin_zip.clone()),
}
} else {
self.clone()
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "unify_address_details",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-3413398412947267645 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/address.rs
fn from(phone: PhoneDetails) -> Self {
Self {
number: phone.number,
country_code: phone.country_code,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-1908250291771306836 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/bulk_tokenization.rs
fn foreign_from(req: payments_api::PhoneDetails) -> Self {
Self {
number: req.number,
country_code: req.country_code,
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "foreign_from",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-7177635913977900590 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/bulk_tokenization.rs
fn foreign_try_from(customer: CustomerDetails) -> Result<Self, Self::Error> {
Ok(Self {
id: customer.customer_id.get_required_value("customer_id")?,
name: customer.name,
email: customer.email,
phone: customer.phone,
phone_country_code: customer.phone_country_code,
tax_registration_id: customer.tax_registration_id,
})
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "foreign_try_from",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_4439028206984887984 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
fn is_encryption_service_enabled(_state: &KeyManagerState) -> bool {
#[cfg(feature = "encryption_service")]
{
_state.enabled
}
#[cfg(not(feature = "encryption_service"))]
{
false
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "is_encryption_service_enabled",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-892125676665697440 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
async fn encrypt_via_api(
state: &KeyManagerState,
masked_data: Secret<Vec<u8>, S>,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<Self, errors::CryptoError> {
// If encryption service is not enabled, fall back to application encryption or else call encryption service
if !is_encryption_service_enabled(state) {
Self::encrypt(masked_data, key, crypt_algo).await
} else {
let result: Result<
EncryptDataResponse,
error_stack::Report<errors::KeyManagerClientError>,
> = call_encryption_service(
state,
Method::POST,
"data/encrypt",
EncryptDataRequest::from((masked_data.clone(), identifier)),
)
.await;
match result {
Ok(response) => Ok(ForeignFrom::foreign_from((masked_data.clone(), response))),
Err(err) => {
logger::error!("Encryption error {:?}", err);
metrics::ENCRYPTION_API_FAILURES.add(1, &[]);
logger::info!("Fall back to Application Encryption");
Self::encrypt(masked_data, key, crypt_algo).await
}
}
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "encrypt_via_api",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_3608176205316506309 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
async fn decrypt_via_api(
state: &KeyManagerState,
encrypted_data: Encryption,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<Self, errors::CryptoError> {
// If encryption service is not enabled, fall back to application encryption or else call encryption service
if !is_encryption_service_enabled(state) {
Self::decrypt(encrypted_data, key, crypt_algo).await
} else {
let result: Result<
DecryptDataResponse,
error_stack::Report<errors::KeyManagerClientError>,
> = call_encryption_service(
state,
Method::POST,
"data/decrypt",
TransientDecryptDataRequest::from((encrypted_data.clone(), identifier)),
)
.await;
let decrypted = match result {
Ok(decrypted_data) => {
ForeignTryFrom::foreign_try_from((encrypted_data.clone(), decrypted_data))
}
Err(err) => {
logger::error!("Decryption error {:?}", err);
Err(err.change_context(errors::CryptoError::DecodingFailed))
}
};
match decrypted {
Ok(de) => Ok(de),
Err(_) => {
metrics::DECRYPTION_API_FAILURES.add(1, &[]);
logger::info!("Fall back to Application Decryption");
Self::decrypt(encrypted_data, key, crypt_algo).await
}
}
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "decrypt_via_api",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_7455109433045699156 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
async fn encrypt<E: Clone, S>(
state: &KeyManagerState,
inner: Secret<E, S>,
identifier: Identifier,
key: &[u8],
) -> CustomResult<crypto::Encryptable<Secret<E, S>>, CryptoError>
where
S: masking::Strategy<E>,
crypto::Encryptable<Secret<E, S>>: TypeEncryption<E, crypto::GcmAes256, S>,
{
record_operation_time(
crypto::Encryptable::encrypt_via_api(state, inner, identifier, key, crypto::GcmAes256),
&metrics::ENCRYPTION_TIME,
&[],
)
.await
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "encrypt",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-4523624402048831262 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
async fn decrypt<T: Clone, S: masking::Strategy<T>>(
state: &KeyManagerState,
inner: Encryption,
identifier: Identifier,
key: &[u8],
) -> CustomResult<crypto::Encryptable<Secret<T, S>>, CryptoError>
where
crypto::Encryptable<Secret<T, S>>: TypeEncryption<T, crypto::GcmAes256, S>,
{
record_operation_time(
crypto::Encryptable::decrypt_via_api(state, inner, identifier, key, crypto::GcmAes256),
&metrics::DECRYPTION_TIME,
&[],
)
.await
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "decrypt",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-4530754146975254054 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
async fn batch_encrypt_via_api(
state: &KeyManagerState,
masked_data: FxHashMap<String, Secret<Vec<u8>, S>>,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<FxHashMap<String, Self>, errors::CryptoError> {
// If encryption service is not enabled, fall back to application encryption or else call encryption service
if !is_encryption_service_enabled(state) {
Self::batch_encrypt(masked_data, key, crypt_algo).await
} else {
let result: Result<
BatchEncryptDataResponse,
error_stack::Report<errors::KeyManagerClientError>,
> = call_encryption_service(
state,
Method::POST,
"data/encrypt",
BatchEncryptDataRequest::from((masked_data.clone(), identifier)),
)
.await;
match result {
Ok(response) => Ok(ForeignFrom::foreign_from((masked_data, response))),
Err(err) => {
metrics::ENCRYPTION_API_FAILURES.add(1, &[]);
logger::error!("Encryption error {:?}", err);
logger::info!("Fall back to Application Encryption");
Self::batch_encrypt(masked_data, key, crypt_algo).await
}
}
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "batch_encrypt_via_api",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_5970808827471527324 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
async fn batch_decrypt_via_api(
state: &KeyManagerState,
encrypted_data: FxHashMap<String, Encryption>,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<FxHashMap<String, Self>, errors::CryptoError> {
// If encryption service is not enabled, fall back to application encryption or else call encryption service
if !is_encryption_service_enabled(state) {
Self::batch_decrypt(encrypted_data, key, crypt_algo).await
} else {
let result: Result<
BatchDecryptDataResponse,
error_stack::Report<errors::KeyManagerClientError>,
> = call_encryption_service(
state,
Method::POST,
"data/decrypt",
TransientBatchDecryptDataRequest::from((encrypted_data.clone(), identifier)),
)
.await;
let decrypted = match result {
Ok(response) => {
ForeignTryFrom::foreign_try_from((encrypted_data.clone(), response))
}
Err(err) => {
logger::error!("Decryption error {:?}", err);
Err(err.change_context(errors::CryptoError::DecodingFailed))
}
};
match decrypted {
Ok(de) => Ok(de),
Err(_) => {
metrics::DECRYPTION_API_FAILURES.add(1, &[]);
logger::info!("Fall back to Application Decryption");
Self::batch_decrypt(encrypted_data, key, crypt_algo).await
}
}
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "batch_decrypt_via_api",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-1585404011527003728 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
async fn batch_encrypt<E: Clone, S>(
state: &KeyManagerState,
inner: FxHashMap<String, Secret<E, S>>,
identifier: Identifier,
key: &[u8],
) -> CustomResult<FxHashMap<String, crypto::Encryptable<Secret<E, S>>>, CryptoError>
where
S: masking::Strategy<E>,
crypto::Encryptable<Secret<E, S>>: TypeEncryption<E, crypto::GcmAes256, S>,
{
if !inner.is_empty() {
record_operation_time(
crypto::Encryptable::batch_encrypt_via_api(
state,
inner,
identifier,
key,
crypto::GcmAes256,
),
&metrics::ENCRYPTION_TIME,
&[],
)
.await
} else {
Ok(FxHashMap::default())
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "batch_encrypt",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-5672851741200423755 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
async fn batch_decrypt<E: Clone, S>(
state: &KeyManagerState,
inner: FxHashMap<String, Encryption>,
identifier: Identifier,
key: &[u8],
) -> CustomResult<FxHashMap<String, crypto::Encryptable<Secret<E, S>>>, CryptoError>
where
S: masking::Strategy<E>,
crypto::Encryptable<Secret<E, S>>: TypeEncryption<E, crypto::GcmAes256, S>,
{
if !inner.is_empty() {
record_operation_time(
crypto::Encryptable::batch_decrypt_via_api(
state,
inner,
identifier,
key,
crypto::GcmAes256,
),
&metrics::ENCRYPTION_TIME,
&[],
)
.await
} else {
Ok(FxHashMap::default())
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "batch_decrypt",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-3813859903363314882 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
fn serialize_json_bytes(&self) -> CustomResult<Secret<Vec<u8>>, errors::CryptoError> {
common_utils::ext_traits::Encode::encode_to_vec(self.inner())
.change_context(errors::CryptoError::EncodingFailed)
.attach_printable("Failed to JSON serialize data before encryption")
.map(Secret::new)
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "serialize_json_bytes",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-854310307419392671 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
fn deserialize_json_bytes<S>(
bytes: Secret<Vec<u8>>,
) -> CustomResult<Secret<Self, S>, errors::ParsingError>
where
S: masking::Strategy<Self>,
{
bytes
.peek()
.as_slice()
.parse_struct::<T>(std::any::type_name::<T>())
.map(|result| Secret::new(Self::from(result)))
.attach_printable("Failed to JSON deserialize data after decryption")
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "deserialize_json_bytes",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-6823772307633381233 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
pub fn inner(&self) -> &T {
&self.0
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "inner",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-8211523463936981928 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
pub fn into_inner(self) -> T {
self.0
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "into_inner",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_5331949100499371022 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
fn from(value: T) -> Self {
Self(value)
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_2277266164316966964 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
fn deref(&self) -> &Self::Target {
self.inner()
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "deref",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-5448336097492052546 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
fn lift<Func, E, V>(self, func: Func) -> Self::OtherWrapper<V, E>
where
Func: Fn(Self::SelfWrapper<U>) -> Self::OtherWrapper<V, E>,
{
func(self)
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "lift",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-1276086526346282380 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
async fn async_lift<Func, F, E, W>(self, func: Func) -> Self::OtherWrapper<W, E>
where
Func: Fn(Self::SelfWrapper<U>) -> F + Send + Sync,
F: futures::Future<Output = Self::OtherWrapper<W, E>> + Send,
{
func(self).await
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "async_lift",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-6358654009130481330 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
async fn encrypt_optional<E: Clone, S>(
state: &KeyManagerState,
inner: Option<Secret<E, S>>,
identifier: Identifier,
key: &[u8],
) -> CustomResult<Option<crypto::Encryptable<Secret<E, S>>>, CryptoError>
where
Secret<E, S>: Send,
S: masking::Strategy<E>,
crypto::Encryptable<Secret<E, S>>: TypeEncryption<E, crypto::GcmAes256, S>,
{
inner
.async_map(|f| encrypt(state, f, identifier, key))
.await
.transpose()
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "encrypt_optional",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-3701567201754306934 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
async fn decrypt_optional<T: Clone, S: masking::Strategy<T>>(
state: &KeyManagerState,
inner: Option<Encryption>,
identifier: Identifier,
key: &[u8],
) -> CustomResult<Option<crypto::Encryptable<Secret<T, S>>>, CryptoError>
where
crypto::Encryptable<Secret<T, S>>: TypeEncryption<T, crypto::GcmAes256, S>,
{
inner
.async_map(|item| decrypt(state, item, identifier, key))
.await
.transpose()
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "decrypt_optional",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_1524108210776772963 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs
pub async fn crypto_operation<T: Clone + Send, S: masking::Strategy<T>>(
state: &KeyManagerState,
table_name: &str,
operation: CryptoOperation<T, S>,
identifier: Identifier,
key: &[u8],
) -> CustomResult<CryptoOutput<T, S>, CryptoError>
where
Secret<T, S>: Send,
crypto::Encryptable<Secret<T, S>>: TypeEncryption<T, crypto::GcmAes256, S>,
{
match operation {
CryptoOperation::Encrypt(data) => {
let data = encrypt(state, data, identifier, key).await?;
Ok(CryptoOutput::Operation(data))
}
CryptoOperation::EncryptOptional(data) => {
let data = encrypt_optional(state, data, identifier, key).await?;
Ok(CryptoOutput::OptionalOperation(data))
}
CryptoOperation::Decrypt(data) => {
let data = decrypt(state, data, identifier, key).await?;
Ok(CryptoOutput::Operation(data))
}
CryptoOperation::DecryptOptional(data) => {
let data = decrypt_optional(state, data, identifier, key).await?;
Ok(CryptoOutput::OptionalOperation(data))
}
CryptoOperation::BatchEncrypt(data) => {
let data = batch_encrypt(state, data, identifier, key).await?;
Ok(CryptoOutput::BatchOperation(data))
}
CryptoOperation::BatchDecrypt(data) => {
let data = batch_decrypt(state, data, identifier, key).await?;
Ok(CryptoOutput::BatchOperation(data))
}
}
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "crypto_operation",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_17770200411330203 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs
pub fn get_shipping_country(&self) -> Option<common_enums::enums::CountryAlpha2> {
self.shipping_details
.as_ref()
.and_then(|address| address.country)
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_shipping_country",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-6886700310424094366 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs
pub fn get_shipping_city(&self) -> Option<String> {
self.shipping_details
.as_ref()
.and_then(|address| address.city.clone())
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_shipping_city",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-2486348682088495251 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs
pub fn get_shipping_state(&self) -> Option<Secret<String>> {
self.shipping_details
.as_ref()
.and_then(|address| address.state.clone())
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_shipping_state",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_-5217724013589552295 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs
pub fn get_shipping_origin_zip(&self) -> Option<Secret<String>> {
self.shipping_details
.as_ref()
.and_then(|address| address.origin_zip.clone())
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_shipping_origin_zip",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_1736229021758348520 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs
pub fn get_shipping_zip(&self) -> Option<Secret<String>> {
self.shipping_details
.as_ref()
.and_then(|address| address.zip.clone())
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_shipping_zip",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_hyperswitch_domain_models_1947345795818210234 | clm | function | // hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs
pub fn get_shipping_address_line1(&self) -> Option<Secret<String>> {
self.shipping_details
.as_ref()
.and_then(|address| address.line1.clone())
}
| {
"chunk": null,
"crate": "hyperswitch_domain_models",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_shipping_address_line1",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.