id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
hyperswitch_fn_hyperswitch_domain_models_-1327211571159529071
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/mandates.rs fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "deref_mut", "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_2087697644411157001
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/mandates.rs pub fn get_mandate_details_value(&self) -> CustomResult<serde_json::Value, ParsingError> { let mut payments = self .payments .as_ref() .map_or_else(|| Ok(serde_json::json!({})), serde_json::to_value) .change_context(ParsingError::StructParseFailure("payment mandate details"))?; self.payouts .as_ref() .map(|payouts_mandate| { serde_json::to_value(payouts_mandate).map(|payouts_mandate_value| { payments.as_object_mut().map(|payments_object| { payments_object.insert("payouts".to_string(), payouts_mandate_value); }) }) }) .transpose() .change_context(ParsingError::StructParseFailure("payout mandate details"))?; Ok(payments) }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_mandate_details_value", "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_6482836629176323194
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/mandates.rs pub fn insert_payment_token_reference_record( &mut self, connector_id: &common_utils::id_type::MerchantConnectorAccountId, record: ConnectorTokenReferenceRecord, ) { match self.payments { Some(ref mut payments_reference) => { payments_reference.insert(connector_id.clone(), record); } None => { let mut payments_reference = HashMap::new(); payments_reference.insert(connector_id.clone(), record); self.payments = Some(PaymentsTokenReference(payments_reference)); } } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "insert_payment_token_reference_record", "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_-743600637982676057
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/behaviour.rs async fn convert( self, state: &KeyManagerState, key: &Secret<Vec<u8>>, key_manager_identifier: Identifier, ) -> CustomResult<U, ValidationError> { U::convert_back(state, self, key, key_manager_identifier).await }
{ "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_4630468953508286997
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/api.rs pub fn get_json_body( self, ) -> common_utils::errors::CustomResult<R, common_utils::errors::ValidationError> { match self { Self::Json(body) | Self::JsonWithHeaders((body, _)) => Ok(body), Self::TextPlain(_) | Self::JsonForRedirection(_) | Self::Form(_) | Self::PaymentLinkForm(_) | Self::FileData(_) | Self::GenericLinkForm(_) | Self::StatusOk => Err(common_utils::errors::ValidationError::InvalidValue { message: "expected either Json or JsonWithHeaders Response".to_string(), } .into()), } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_json_body", "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_513371639116550406
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/api.rs fn get_api_event_type(&self) -> Option<ApiEventsType> { match self { Self::Json(r) => r.get_api_event_type(), Self::JsonWithHeaders((r, _)) => r.get_api_event_type(), _ => None, } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_api_event_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_7456636567529685406
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/api.rs fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, "{}", match *self { Self::ExpiredLink(_) => "ExpiredLink", Self::PaymentMethodCollect(_) => "PaymentMethodCollect", Self::PayoutLink(_) => "PayoutLink", Self::PayoutLinkStatus(_) => "PayoutLinkStatus", Self::PaymentMethodCollectStatus(_) => "PaymentMethodCollectStatus", Self::SecurePaymentLink(_) => "SecurePaymentLink", } ) }
{ "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_6871080655496339269
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/relay.rs pub fn new( relay_request: &api_models::relay::RelayRequest, merchant_id: &id_type::MerchantId, profile_id: &id_type::ProfileId, ) -> Self { let relay_id = id_type::RelayId::generate(); Self { id: relay_id.clone(), connector_resource_id: relay_request.connector_resource_id.clone(), connector_id: relay_request.connector_id.clone(), profile_id: profile_id.clone(), merchant_id: merchant_id.clone(), relay_type: common_enums::RelayType::Refund, request_data: relay_request.data.clone().map(From::from), status: common_enums::RelayStatus::Created, connector_reference_id: None, error_code: None, error_message: None, created_at: common_utils::date_time::now(), modified_at: common_utils::date_time::now(), response_data: None, } }
{ "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_6656830102948120272
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/relay.rs fn from(value: RelayUpdate) -> Self { match value { RelayUpdate::ErrorUpdate { error_code, error_message, status, } => Self { error_code: Some(error_code), error_message: Some(error_message), connector_reference_id: None, status: Some(status), modified_at: common_utils::date_time::now(), }, RelayUpdate::StatusUpdate { connector_reference_id, status, } => Self { connector_reference_id, status: Some(status), error_code: None, error_message: None, modified_at: common_utils::date_time::now(), }, } }
{ "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_7825497961664838537
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/relay.rs async fn convert(self) -> CustomResult<Self::DstType, ValidationError> { Ok(diesel_models::relay::Relay { id: self.id, connector_resource_id: self.connector_resource_id, connector_id: self.connector_id, profile_id: self.profile_id, merchant_id: self.merchant_id, relay_type: self.relay_type, request_data: self .request_data .map(|data| { serde_json::to_value(data).change_context(ValidationError::InvalidValue { message: "Failed while decrypting business profile data".to_string(), }) }) .transpose()? .map(Secret::new), status: self.status, connector_reference_id: self.connector_reference_id, error_code: self.error_code, error_message: self.error_message, created_at: self.created_at, modified_at: self.modified_at, response_data: self.response_data, }) }
{ "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_-7182220090872257646
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/relay.rs async fn convert_back( _state: &keymanager::KeyManagerState, item: Self::DstType, _key: &Secret<Vec<u8>>, _key_manager_identifier: keymanager::Identifier, ) -> CustomResult<Self, ValidationError> { Ok(Self { id: item.id, connector_resource_id: item.connector_resource_id, connector_id: item.connector_id, profile_id: item.profile_id, merchant_id: item.merchant_id, relay_type: enums::RelayType::Refund, request_data: item .request_data .map(|data| { serde_json::from_value(data.expose()).change_context( ValidationError::InvalidValue { message: "Failed while decrypting business profile data".to_string(), }, ) }) .transpose()?, status: item.status, connector_reference_id: item.connector_reference_id, error_code: item.error_code, error_message: item.error_message, created_at: item.created_at, modified_at: item.modified_at, response_data: item.response_data, }) }
{ "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_492255061038528385
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/relay.rs async fn construct_new(self) -> CustomResult<Self::NewDstType, ValidationError> { Ok(diesel_models::relay::RelayNew { id: self.id, connector_resource_id: self.connector_resource_id, connector_id: self.connector_id, profile_id: self.profile_id, merchant_id: self.merchant_id, relay_type: self.relay_type, request_data: self .request_data .map(|data| { serde_json::to_value(data).change_context(ValidationError::InvalidValue { message: "Failed while decrypting business profile data".to_string(), }) }) .transpose()? .map(Secret::new), status: self.status, connector_reference_id: self.connector_reference_id, error_code: self.error_code, error_message: self.error_message, created_at: self.created_at, modified_at: self.modified_at, response_data: self.response_data, }) }
{ "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_2394340551455125316
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/vault.rs pub fn get_card(&self) -> Option<&payment_methods::CardDetail> { match self { Self::Card(card) => Some(card), #[cfg(feature = "v2")] Self::NetworkToken(_) => None, Self::CardNumber(_) => None, } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_card", "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_8884735825416011058
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/vault.rs pub fn get_payment_methods_data(&self) -> payment_method_data::PaymentMethodsData { match self { Self::Card(card) => payment_method_data::PaymentMethodsData::Card( payment_method_data::CardDetailsPaymentMethod::from(card.clone()), ), #[cfg(feature = "v2")] Self::NetworkToken(network_token) => { payment_method_data::PaymentMethodsData::NetworkToken( payment_method_data::NetworkTokenDetailsPaymentMethod::from( network_token.clone(), ), ) } Self::CardNumber(_card_number) => payment_method_data::PaymentMethodsData::Card( payment_method_data::CardDetailsPaymentMethod { last4_digits: None, issuer_country: None, expiry_month: None, expiry_year: None, nick_name: None, card_holder_name: None, card_isin: None, card_issuer: None, card_network: None, card_type: None, saved_to_locker: false, #[cfg(feature = "v1")] co_badged_card_data: None, }, ), } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_payment_methods_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_-6833412571237327369
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/vault.rs fn get_vaulting_data_key(&self) -> String { match &self { Self::Card(card) => card.card_number.to_string(), #[cfg(feature = "v2")] Self::NetworkToken(network_token) => network_token.network_token.to_string(), Self::CardNumber(card_number) => card_number.to_string(), } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_vaulting_data_key", "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_5512280457309574650
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/vault.rs fn try_from(item: payment_methods::PaymentMethodCreateData) -> Result<Self, Self::Error> { match item { payment_methods::PaymentMethodCreateData::Card(card) => Ok(Self::Card(card)), payment_methods::PaymentMethodCreateData::ProxyCard(card) => Err( errors::api_error_response::ApiErrorResponse::UnprocessableEntity { message: "Proxy Card for PaymentMethodCreateData".to_string(), } .into(), ), } }
{ "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_3004374649144205636
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs fn from(item: DieselPaymentAttemptFeatureMetadata) -> Self { let revenue_recovery = item.revenue_recovery .map(|recovery_data| PaymentAttemptRevenueRecoveryData { attempt_triggered_by: recovery_data.attempt_triggered_by, charge_id: recovery_data.charge_id, }); 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_1943396728520963048
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_net_amount(&self) -> MinorUnit { self.net_amount }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_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_3433451541988971671
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_amount_to_capture(&self) -> Option<MinorUnit> { self.amount_to_capture }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_amount_to_capture", "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_-6007613151403368844
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_surcharge_amount(&self) -> Option<MinorUnit> { self.surcharge_amount }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_surcharge_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_468110124799375227
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_tax_on_surcharge(&self) -> Option<MinorUnit> { self.tax_on_surcharge }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_tax_on_surcharge", "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_5391495919709793920
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_amount_capturable(&self) -> MinorUnit { self.amount_capturable }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_amount_capturable", "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_-1862347812708329160
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_shipping_cost(&self) -> Option<MinorUnit> { self.shipping_cost }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_shipping_cost", "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_-2163361229700746844
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_order_tax_amount(&self) -> Option<MinorUnit> { self.order_tax_amount }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_order_tax_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_4012026764887419180
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn set_amount_to_capture(&mut self, amount_to_capture: MinorUnit) { self.amount_to_capture = Some(amount_to_capture); }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "set_amount_to_capture", "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_2960862305982515767
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn validate_amount_to_capture( &self, request_amount_to_capture: MinorUnit, ) -> Result<(), ValidationError> { common_utils::fp_utils::when(request_amount_to_capture > self.get_net_amount(), || { Err(ValidationError::IncorrectValueProvided { field_name: "amount_to_capture", }) }) }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "validate_amount_to_capture", "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_-4101575364341844067
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_payment_method(&self) -> Option<storage_enums::PaymentMethod> { // TODO: check if we can fix this Some(self.payment_method_type) }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_payment_method", "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_7196201233332200390
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_payment_method_type(&self) -> Option<storage_enums::PaymentMethodType> { // TODO: check if we can fix this Some(self.payment_method_subtype) }
{ "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": 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_-2018206335033799551
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_id(&self) -> &id_type::GlobalAttemptId { &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_7683303837607496581
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_connector_payment_id(&self) -> Option<&str> { self.connector_payment_id.as_deref() }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_connector_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_6411931238438996095
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub async fn create_domain_model( payment_intent: &super::PaymentIntent, cell_id: id_type::CellId, storage_scheme: storage_enums::MerchantStorageScheme, request: &api_models::payments::PaymentsConfirmIntentRequest, encrypted_data: DecryptedPaymentAttempt, ) -> CustomResult<Self, errors::api_error_response::ApiErrorResponse> { let id = id_type::GlobalAttemptId::generate(&cell_id); let intent_amount_details = payment_intent.amount_details.clone(); let attempt_amount_details = intent_amount_details.create_attempt_amount_details(request); let now = common_utils::date_time::now(); let payment_method_billing_address = encrypted_data .payment_method_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")?; let connector_token = Some(diesel_models::ConnectorTokenDetails { connector_mandate_id: None, connector_token_request_reference_id: Some(common_utils::generate_id_with_len( consts::CONNECTOR_MANDATE_REQUEST_REFERENCE_ID_LENGTH, )), }); let authentication_type = payment_intent.authentication_type.unwrap_or_default(); Ok(Self { payment_id: payment_intent.id.clone(), merchant_id: payment_intent.merchant_id.clone(), attempts_group_id: None, amount_details: attempt_amount_details, status: common_enums::AttemptStatus::Started, // This will be decided by the routing algorithm and updated in update trackers // right before calling the connector connector: None, authentication_type, created_at: now, modified_at: now, last_synced: None, cancellation_reason: None, browser_info: request.browser_info.clone(), payment_token: request.payment_token.clone(), connector_metadata: None, payment_experience: None, payment_method_data: None, routing_result: None, preprocessing_step_id: None, multiple_capture_count: None, connector_response_reference_id: None, updated_by: storage_scheme.to_string(), redirection_data: None, encoded_data: None, merchant_connector_id: None, external_three_ds_authentication_attempted: None, authentication_connector: None, authentication_id: None, fingerprint_id: None, charges: None, client_source: None, client_version: None, customer_acceptance: request.customer_acceptance.clone().map(Secret::new), profile_id: payment_intent.profile_id.clone(), organization_id: payment_intent.organization_id.clone(), payment_method_type: request.payment_method_type, payment_method_id: request.payment_method_id.clone(), connector_payment_id: None, payment_method_subtype: request.payment_method_subtype, authentication_applied: None, external_reference_id: None, payment_method_billing_address, error: None, connector_token_details: connector_token, id, card_discovery: None, feature_metadata: None, processor_merchant_id: payment_intent.merchant_id.clone(), created_by: None, connector_request_reference_id: None, network_transaction_id: None, authorized_amount: None, }) }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_domain_model", "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_-2497271348636333262
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub async fn proxy_create_domain_model( payment_intent: &super::PaymentIntent, cell_id: id_type::CellId, storage_scheme: storage_enums::MerchantStorageScheme, request: &api_models::payments::ProxyPaymentsRequest, encrypted_data: DecryptedPaymentAttempt, ) -> CustomResult<Self, errors::api_error_response::ApiErrorResponse> { let id = id_type::GlobalAttemptId::generate(&cell_id); let intent_amount_details = payment_intent.amount_details.clone(); let attempt_amount_details = intent_amount_details.proxy_create_attempt_amount_details(request); let now = common_utils::date_time::now(); let payment_method_billing_address = encrypted_data .payment_method_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")?; let connector_token = Some(diesel_models::ConnectorTokenDetails { connector_mandate_id: None, connector_token_request_reference_id: Some(common_utils::generate_id_with_len( consts::CONNECTOR_MANDATE_REQUEST_REFERENCE_ID_LENGTH, )), }); let payment_method_type_data = payment_intent.get_payment_method_type(); let payment_method_subtype_data = payment_intent.get_payment_method_sub_type(); let authentication_type = payment_intent.authentication_type.unwrap_or_default(); Ok(Self { payment_id: payment_intent.id.clone(), merchant_id: payment_intent.merchant_id.clone(), attempts_group_id: None, amount_details: attempt_amount_details, status: common_enums::AttemptStatus::Started, connector: Some(request.connector.clone()), authentication_type, created_at: now, modified_at: now, last_synced: None, cancellation_reason: None, browser_info: request.browser_info.clone(), payment_token: None, connector_metadata: None, payment_experience: None, payment_method_data: None, routing_result: None, preprocessing_step_id: None, multiple_capture_count: None, connector_response_reference_id: None, updated_by: storage_scheme.to_string(), redirection_data: None, encoded_data: None, merchant_connector_id: Some(request.merchant_connector_id.clone()), external_three_ds_authentication_attempted: None, authentication_connector: None, authentication_id: None, fingerprint_id: None, charges: None, client_source: None, client_version: None, customer_acceptance: None, profile_id: payment_intent.profile_id.clone(), organization_id: payment_intent.organization_id.clone(), payment_method_type: payment_method_type_data .unwrap_or(common_enums::PaymentMethod::Card), payment_method_id: None, connector_payment_id: None, payment_method_subtype: payment_method_subtype_data .unwrap_or(common_enums::PaymentMethodType::Credit), authentication_applied: None, external_reference_id: None, payment_method_billing_address, error: None, connector_token_details: connector_token, feature_metadata: None, id, card_discovery: None, processor_merchant_id: payment_intent.merchant_id.clone(), created_by: None, connector_request_reference_id: None, network_transaction_id: None, authorized_amount: None, }) }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "proxy_create_domain_model", "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_-129460944242637804
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub async fn external_vault_proxy_create_domain_model( payment_intent: &super::PaymentIntent, cell_id: id_type::CellId, storage_scheme: storage_enums::MerchantStorageScheme, request: &api_models::payments::ExternalVaultProxyPaymentsRequest, encrypted_data: DecryptedPaymentAttempt, ) -> CustomResult<Self, errors::api_error_response::ApiErrorResponse> { let id = id_type::GlobalAttemptId::generate(&cell_id); let intent_amount_details = payment_intent.amount_details.clone(); let attempt_amount_details = AttemptAmountDetails { net_amount: intent_amount_details.order_amount, amount_to_capture: None, surcharge_amount: None, tax_on_surcharge: None, amount_capturable: intent_amount_details.order_amount, shipping_cost: None, order_tax_amount: None, }; let now = common_utils::date_time::now(); let payment_method_billing_address = encrypted_data .payment_method_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")?; let connector_token = Some(diesel_models::ConnectorTokenDetails { connector_mandate_id: None, connector_token_request_reference_id: Some(common_utils::generate_id_with_len( consts::CONNECTOR_MANDATE_REQUEST_REFERENCE_ID_LENGTH, )), }); let payment_method_type_data = payment_intent.get_payment_method_type(); let payment_method_subtype_data = payment_intent.get_payment_method_sub_type(); let authentication_type = payment_intent.authentication_type.unwrap_or_default(); Ok(Self { payment_id: payment_intent.id.clone(), merchant_id: payment_intent.merchant_id.clone(), attempts_group_id: None, amount_details: attempt_amount_details, status: common_enums::AttemptStatus::Started, connector: None, authentication_type, created_at: now, modified_at: now, last_synced: None, cancellation_reason: None, browser_info: request.browser_info.clone(), payment_token: request.payment_token.clone(), connector_metadata: None, payment_experience: None, payment_method_data: None, routing_result: None, preprocessing_step_id: None, multiple_capture_count: None, connector_response_reference_id: None, updated_by: storage_scheme.to_string(), redirection_data: None, encoded_data: None, merchant_connector_id: None, external_three_ds_authentication_attempted: None, authentication_connector: None, authentication_id: None, fingerprint_id: None, charges: None, client_source: None, client_version: None, customer_acceptance: request.customer_acceptance.clone().map(Secret::new), profile_id: payment_intent.profile_id.clone(), organization_id: payment_intent.organization_id.clone(), payment_method_type: payment_method_type_data .unwrap_or(common_enums::PaymentMethod::Card), payment_method_id: request.payment_method_id.clone(), connector_payment_id: None, payment_method_subtype: payment_method_subtype_data .unwrap_or(common_enums::PaymentMethodType::Credit), authentication_applied: None, external_reference_id: None, payment_method_billing_address, error: None, connector_token_details: connector_token, feature_metadata: None, id, card_discovery: None, processor_merchant_id: payment_intent.merchant_id.clone(), created_by: None, connector_request_reference_id: None, network_transaction_id: None, authorized_amount: None, }) }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "external_vault_proxy_create_domain_model", "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_4676785070749245533
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub async fn create_domain_model_using_record_request( payment_intent: &super::PaymentIntent, cell_id: id_type::CellId, storage_scheme: storage_enums::MerchantStorageScheme, request: &api_models::payments::PaymentsAttemptRecordRequest, encrypted_data: DecryptedPaymentAttempt, ) -> CustomResult<Self, errors::api_error_response::ApiErrorResponse> { let id = id_type::GlobalAttemptId::generate(&cell_id); let amount_details = AttemptAmountDetailsSetter::from(&request.amount_details); let now = common_utils::date_time::now(); // we consume transaction_created_at from webhook request, if it is not present we take store current time as transaction_created_at. let transaction_created_at = request .transaction_created_at .unwrap_or(common_utils::date_time::now()); // This function is called in the record attempt flow, which tells us that this is a payment attempt created by an external system. let feature_metadata = PaymentAttemptFeatureMetadata { revenue_recovery: Some({ PaymentAttemptRevenueRecoveryData { attempt_triggered_by: request.triggered_by, charge_id: request.feature_metadata.as_ref().and_then(|metadata| { metadata .revenue_recovery .as_ref() .and_then(|data| data.charge_id.clone()) }), } }), }; let payment_method_data = request .payment_method_data .as_ref() .map(|data| data.payment_method_data.clone().encode_to_value()) .transpose() .change_context(errors::api_error_response::ApiErrorResponse::InternalServerError) .attach_printable("Unable to decode additional payment method data")? .map(pii::SecretSerdeValue::new); let payment_method_billing_address = encrypted_data .payment_method_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")?; let error = request.error.as_ref().map(ErrorDetails::from); let connector_payment_id = request .connector_transaction_id .as_ref() .map(|txn_id| txn_id.get_id().clone()); let connector = request.connector.map(|connector| connector.to_string()); let connector_request_reference_id = payment_intent .merchant_reference_id .as_ref() .map(|id| id.get_string_repr().to_owned()); Ok(Self { payment_id: payment_intent.id.clone(), merchant_id: payment_intent.merchant_id.clone(), attempts_group_id: None, amount_details: AttemptAmountDetails::from(amount_details), status: request.status, connector, authentication_type: storage_enums::AuthenticationType::NoThreeDs, created_at: transaction_created_at, modified_at: now, last_synced: None, cancellation_reason: None, browser_info: None, payment_token: None, connector_metadata: None, payment_experience: None, payment_method_data, routing_result: None, preprocessing_step_id: None, multiple_capture_count: None, connector_response_reference_id: None, updated_by: storage_scheme.to_string(), redirection_data: None, encoded_data: None, merchant_connector_id: request.payment_merchant_connector_id.clone(), external_three_ds_authentication_attempted: None, authentication_connector: None, authentication_id: None, fingerprint_id: None, client_source: None, client_version: None, customer_acceptance: None, profile_id: payment_intent.profile_id.clone(), organization_id: payment_intent.organization_id.clone(), payment_method_type: request.payment_method_type, payment_method_id: None, connector_payment_id, payment_method_subtype: request.payment_method_subtype, authentication_applied: None, external_reference_id: None, payment_method_billing_address, error, feature_metadata: Some(feature_metadata), id, connector_token_details: Some(diesel_models::ConnectorTokenDetails { connector_mandate_id: Some(request.processor_payment_method_token.clone()), connector_token_request_reference_id: None, }), card_discovery: None, charges: None, processor_merchant_id: payment_intent.merchant_id.clone(), created_by: None, connector_request_reference_id, network_transaction_id: None, authorized_amount: None, }) }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_domain_model_using_record_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_5667467384635321235
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_attempt_merchant_connector_account_id( &self, ) -> CustomResult< id_type::MerchantConnectorAccountId, errors::api_error_response::ApiErrorResponse, > { let merchant_connector_id = self .merchant_connector_id .clone() .get_required_value("merchant_connector_id") .change_context(errors::api_error_response::ApiErrorResponse::InternalServerError) .attach_printable("Merchant connector id is None")?; Ok(merchant_connector_id) }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_attempt_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_-6839457137583920885
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn new( order_amount: MinorUnit, shipping_cost: Option<MinorUnit>, order_tax_amount: Option<MinorUnit>, surcharge_amount: Option<MinorUnit>, tax_on_surcharge: Option<MinorUnit>, ) -> Self { Self { order_amount, shipping_cost, order_tax_amount, surcharge_amount, tax_on_surcharge, } }
{ "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_5532688523738131314
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_order_amount(&self) -> MinorUnit { self.order_amount }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_order_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_-8586222671211230539
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_total_surcharge_amount(&self) -> Option<MinorUnit> { self.net_amount.get_total_surcharge_amount() }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_total_surcharge_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_-7973481419365412655
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_total_amount(&self) -> MinorUnit { self.net_amount.get_total_amount() }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_total_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_4453628448183211489
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_additional_amount(&self) -> MinorUnit { self.get_total_amount() - self.get_order_amount() }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_additional_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_-3552374923610437416
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn set_order_amount(&mut self, order_amount: MinorUnit) { self.order_amount = order_amount; }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "set_order_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_-3055375851247488329
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn set_order_tax_amount(&mut self, order_tax_amount: Option<MinorUnit>) { self.order_tax_amount = order_tax_amount; }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "set_order_tax_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_8668135557104206451
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn set_surcharge_details( &mut self, surcharge_details: Option<router_request_types::SurchargeDetails>, ) { self.surcharge_amount = surcharge_details .clone() .map(|details| details.surcharge_amount); self.tax_on_surcharge = surcharge_details.map(|details| details.tax_on_surcharge_amount); }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "set_surcharge_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_-5370630894341018090
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn from_payments_request( payments_request: &api_models::payments::PaymentsRequest, order_amount: MinorUnit, ) -> Self { let surcharge_amount = payments_request .surcharge_details .map(|surcharge_details| surcharge_details.surcharge_amount); let tax_on_surcharge = payments_request .surcharge_details .and_then(|surcharge_details| surcharge_details.tax_amount); Self { order_amount, shipping_cost: payments_request.shipping_cost, order_tax_amount: payments_request.order_tax_amount, surcharge_amount, tax_on_surcharge, } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from_payments_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_-240361129573550598
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn from_payments_request_and_payment_attempt( payments_request: &api_models::payments::PaymentsRequest, payment_attempt: Option<&PaymentAttempt>, ) -> Option<Self> { let option_order_amount = payments_request .amount .map(MinorUnit::from) .or(payment_attempt .map(|payment_attempt| payment_attempt.net_amount.get_order_amount())); option_order_amount.map(|order_amount| { let shipping_cost = payments_request.shipping_cost.or(payment_attempt .and_then(|payment_attempt| payment_attempt.net_amount.get_shipping_cost())); let order_tax_amount = payment_attempt .and_then(|payment_attempt| payment_attempt.net_amount.get_order_tax_amount()); let surcharge_amount = payments_request .surcharge_details .map(|surcharge_details| surcharge_details.get_surcharge_amount()) .or_else(|| { payment_attempt.and_then(|payment_attempt| { payment_attempt.net_amount.get_surcharge_amount() }) }); let tax_on_surcharge = payments_request .surcharge_details .and_then(|surcharge_details| surcharge_details.get_tax_amount()) .or_else(|| { payment_attempt.and_then(|payment_attempt| { payment_attempt.net_amount.get_tax_on_surcharge() }) }); Self { order_amount, shipping_cost, order_tax_amount, surcharge_amount, tax_on_surcharge, } }) }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from_payments_request_and_payment_attempt", "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_-7546025545267526225
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn extract_card_network(&self) -> Option<common_enums::CardNetwork> { self.payment_method_data .as_ref() .and_then(|value| { value .clone() .parse_value::<api_models::payments::AdditionalPaymentData>( "AdditionalPaymentData", ) .ok() }) .and_then(|data| data.get_additional_card_info()) .and_then(|card_info| card_info.card_network) }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_card_network", "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_-3057225894138334031
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn set_debit_routing_savings(&mut self, debit_routing_savings: Option<&MinorUnit>) { self.debit_routing_savings = debit_routing_savings.copied(); }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "set_debit_routing_savings", "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_7737060999754752119
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_payment_method_data(&self) -> Option<api_models::payments::AdditionalPaymentData> { self.payment_method_data .clone() .and_then(|data| match data { serde_json::Value::Null => None, _ => Some(data.parse_value("AdditionalPaymentData")), }) .transpose() .map_err(|err| logger::error!("Failed to parse AdditionalPaymentData {err:?}")) .ok() .flatten() }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_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_5069005644687237925
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn to_storage_model(self) -> diesel_models::PaymentAttemptUpdate { match self { Self::Update { net_amount, currency, status, authentication_type, payment_method, payment_token, payment_method_data, payment_method_type, payment_experience, business_sub_label, amount_to_capture, capture_method, fingerprint_id, network_transaction_id, payment_method_billing_address_id, updated_by, } => DieselPaymentAttemptUpdate::Update { amount: net_amount.get_order_amount(), currency, status, authentication_type, payment_method, payment_token, payment_method_data, payment_method_type, payment_experience, business_sub_label, amount_to_capture, capture_method, surcharge_amount: net_amount.get_surcharge_amount(), tax_amount: net_amount.get_tax_on_surcharge(), fingerprint_id, payment_method_billing_address_id, network_transaction_id, updated_by, }, Self::UpdateTrackers { payment_token, connector, straight_through_algorithm, amount_capturable, updated_by, surcharge_amount, tax_amount, merchant_connector_id, routing_approach, is_stored_credential, } => DieselPaymentAttemptUpdate::UpdateTrackers { payment_token, connector, straight_through_algorithm, amount_capturable, surcharge_amount, tax_amount, updated_by, merchant_connector_id, routing_approach: routing_approach.map(|approach| match approach { storage_enums::RoutingApproach::Other(_) => { // we need to make sure Other variant is not stored in DB, in the rare case // where we attempt to store an unknown value, we default to the default value storage_enums::RoutingApproach::default() } _ => approach, }), is_stored_credential, }, Self::AuthenticationTypeUpdate { authentication_type, updated_by, } => DieselPaymentAttemptUpdate::AuthenticationTypeUpdate { authentication_type, updated_by, }, Self::BlocklistUpdate { status, error_code, error_message, updated_by, } => DieselPaymentAttemptUpdate::BlocklistUpdate { status, error_code, error_message, updated_by, }, Self::ConnectorMandateDetailUpdate { connector_mandate_detail, updated_by, } => DieselPaymentAttemptUpdate::ConnectorMandateDetailUpdate { connector_mandate_detail, updated_by, }, Self::PaymentMethodDetailsUpdate { payment_method_id, updated_by, } => DieselPaymentAttemptUpdate::PaymentMethodDetailsUpdate { payment_method_id, updated_by, }, Self::ConfirmUpdate { net_amount, currency, status, authentication_type, capture_method, payment_method, browser_info, connector, payment_token, payment_method_data, payment_method_type, payment_experience, business_sub_label, straight_through_algorithm, error_code, error_message, fingerprint_id, updated_by, merchant_connector_id: connector_id, payment_method_id, external_three_ds_authentication_attempted, authentication_connector, authentication_id, payment_method_billing_address_id, client_source, client_version, customer_acceptance, connector_mandate_detail, card_discovery, routing_approach, connector_request_reference_id, network_transaction_id, is_stored_credential, request_extended_authorization, } => DieselPaymentAttemptUpdate::ConfirmUpdate { amount: net_amount.get_order_amount(), currency, status, authentication_type, capture_method, payment_method, browser_info, connector, payment_token, payment_method_data, payment_method_type, payment_experience, business_sub_label, straight_through_algorithm, error_code, error_message, surcharge_amount: net_amount.get_surcharge_amount(), tax_amount: net_amount.get_tax_on_surcharge(), fingerprint_id, updated_by, merchant_connector_id: connector_id, payment_method_id, external_three_ds_authentication_attempted, authentication_connector, authentication_id, payment_method_billing_address_id, client_source, client_version, customer_acceptance, shipping_cost: net_amount.get_shipping_cost(), order_tax_amount: net_amount.get_order_tax_amount(), connector_mandate_detail, card_discovery, routing_approach: routing_approach.map(|approach| match approach { // we need to make sure Other variant is not stored in DB, in the rare case // where we attempt to store an unknown value, we default to the default value storage_enums::RoutingApproach::Other(_) => { storage_enums::RoutingApproach::default() } _ => approach, }), connector_request_reference_id, network_transaction_id, is_stored_credential, request_extended_authorization, }, Self::VoidUpdate { status, cancellation_reason, updated_by, } => DieselPaymentAttemptUpdate::VoidUpdate { status, cancellation_reason, updated_by, }, Self::ResponseUpdate { status, connector, connector_transaction_id, authentication_type, payment_method_id, mandate_id, connector_metadata, payment_token, error_code, error_message, error_reason, connector_response_reference_id, amount_capturable, updated_by, authentication_data, encoded_data, unified_code, unified_message, capture_before, extended_authorization_applied, payment_method_data, connector_mandate_detail, charges, setup_future_usage_applied, network_transaction_id, debit_routing_savings: _, is_overcapture_enabled, authorized_amount, } => DieselPaymentAttemptUpdate::ResponseUpdate { status, connector, connector_transaction_id, authentication_type, payment_method_id, mandate_id, connector_metadata, payment_token, error_code, error_message, error_reason, connector_response_reference_id, amount_capturable, updated_by, authentication_data, encoded_data, unified_code, unified_message, capture_before, extended_authorization_applied, payment_method_data, connector_mandate_detail, charges, setup_future_usage_applied, network_transaction_id, is_overcapture_enabled, authorized_amount, }, Self::UnresolvedResponseUpdate { status, connector, connector_transaction_id, payment_method_id, error_code, error_message, error_reason, connector_response_reference_id, updated_by, } => DieselPaymentAttemptUpdate::UnresolvedResponseUpdate { status, connector, connector_transaction_id, payment_method_id, error_code, error_message, error_reason, connector_response_reference_id, updated_by, }, Self::StatusUpdate { status, updated_by } => { DieselPaymentAttemptUpdate::StatusUpdate { status, updated_by } } Self::ErrorUpdate { connector, status, error_code, error_message, error_reason, amount_capturable, updated_by, unified_code, unified_message, connector_transaction_id, payment_method_data, authentication_type, issuer_error_code, issuer_error_message, network_details, } => DieselPaymentAttemptUpdate::ErrorUpdate { connector, status, error_code, error_message, error_reason, amount_capturable, updated_by, unified_code, unified_message, connector_transaction_id, payment_method_data, authentication_type, issuer_error_code, issuer_error_message, network_details, }, Self::CaptureUpdate { multiple_capture_count, updated_by, amount_to_capture, } => DieselPaymentAttemptUpdate::CaptureUpdate { multiple_capture_count, updated_by, amount_to_capture, }, Self::PreprocessingUpdate { status, payment_method_id, connector_metadata, preprocessing_step_id, connector_transaction_id, connector_response_reference_id, updated_by, } => DieselPaymentAttemptUpdate::PreprocessingUpdate { status, payment_method_id, connector_metadata, preprocessing_step_id, connector_transaction_id, connector_response_reference_id, updated_by, }, Self::RejectUpdate { status, error_code, error_message, updated_by, } => DieselPaymentAttemptUpdate::RejectUpdate { status, error_code, error_message, updated_by, }, Self::AmountToCaptureUpdate { status, amount_capturable, updated_by, } => DieselPaymentAttemptUpdate::AmountToCaptureUpdate { status, amount_capturable, updated_by, }, Self::ConnectorResponse { authentication_data, encoded_data, connector_transaction_id, connector, charges, updated_by, } => DieselPaymentAttemptUpdate::ConnectorResponse { authentication_data, encoded_data, connector_transaction_id, charges, connector, updated_by, }, Self::IncrementalAuthorizationAmountUpdate { net_amount, amount_capturable, } => DieselPaymentAttemptUpdate::IncrementalAuthorizationAmountUpdate { amount: net_amount.get_order_amount(), amount_capturable, }, Self::AuthenticationUpdate { status, external_three_ds_authentication_attempted, authentication_connector, authentication_id, updated_by, } => DieselPaymentAttemptUpdate::AuthenticationUpdate { status, external_three_ds_authentication_attempted, authentication_connector, authentication_id, updated_by, }, Self::ManualUpdate { status, error_code, error_message, error_reason, updated_by, unified_code, unified_message, connector_transaction_id, } => DieselPaymentAttemptUpdate::ManualUpdate { status, error_code, error_message, error_reason, updated_by, unified_code, unified_message, connector_transaction_id, }, Self::PostSessionTokensUpdate { updated_by, connector_metadata, } => DieselPaymentAttemptUpdate::PostSessionTokensUpdate { updated_by, connector_metadata, }, } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "to_storage_model", "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_2311480862667473191
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs pub fn get_debit_routing_savings(&self) -> Option<&MinorUnit> { match self { Self::ResponseUpdate { debit_routing_savings, .. } => debit_routing_savings.as_ref(), Self::Update { .. } | Self::UpdateTrackers { .. } | Self::AuthenticationTypeUpdate { .. } | Self::ConfirmUpdate { .. } | Self::RejectUpdate { .. } | Self::BlocklistUpdate { .. } | Self::PaymentMethodDetailsUpdate { .. } | Self::ConnectorMandateDetailUpdate { .. } | Self::VoidUpdate { .. } | Self::UnresolvedResponseUpdate { .. } | Self::StatusUpdate { .. } | Self::ErrorUpdate { .. } | Self::CaptureUpdate { .. } | Self::AmountToCaptureUpdate { .. } | Self::PreprocessingUpdate { .. } | Self::ConnectorResponse { .. } | Self::IncrementalAuthorizationAmountUpdate { .. } | Self::AuthenticationUpdate { .. } | Self::ManualUpdate { .. } | Self::PostSessionTokensUpdate { .. } => None, } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_debit_routing_savings", "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_-8963227093717425848
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs fn foreign_id(&self) -> String { self.attempt_id.clone() }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "foreign_id", "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_2727966911727756511
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs async fn convert(self) -> CustomResult<Self::DstType, ValidationError> { use common_utils::encryption::Encryption; let card_network = self .payment_method_data .as_ref() .and_then(|data| data.peek().as_object()) .and_then(|card| card.get("card")) .and_then(|data| data.as_object()) .and_then(|card| card.get("card_network")) .and_then(|network| network.as_str()) .map(|network| network.to_string()); let Self { payment_id, merchant_id, attempts_group_id, status, error, amount_details, authentication_type, created_at, modified_at, last_synced, cancellation_reason, browser_info, payment_token, connector_metadata, payment_experience, payment_method_data, routing_result, preprocessing_step_id, multiple_capture_count, connector_response_reference_id, updated_by, redirection_data, encoded_data, merchant_connector_id, external_three_ds_authentication_attempted, authentication_connector, authentication_id, fingerprint_id, client_source, client_version, customer_acceptance, profile_id, organization_id, payment_method_type, connector_payment_id, payment_method_subtype, authentication_applied, external_reference_id, id, payment_method_id, payment_method_billing_address, connector, connector_token_details, card_discovery, charges, feature_metadata, processor_merchant_id, created_by, connector_request_reference_id, network_transaction_id, authorized_amount, } = self; let AttemptAmountDetails { net_amount, tax_on_surcharge, surcharge_amount, order_tax_amount, shipping_cost, amount_capturable, amount_to_capture, } = amount_details; let (connector_payment_id, connector_payment_data) = connector_payment_id .map(ConnectorTransactionId::form_id_and_data) .map(|(txn_id, txn_data)| (Some(txn_id), txn_data)) .unwrap_or((None, None)); let feature_metadata = feature_metadata.as_ref().map(From::from); Ok(DieselPaymentAttempt { payment_id, merchant_id, id, status, error_message: error.as_ref().map(|details| details.message.clone()), payment_method_id, payment_method_type_v2: payment_method_type, connector_payment_id, authentication_type, created_at, modified_at, last_synced, cancellation_reason, amount_to_capture, browser_info, error_code: error.as_ref().map(|details| details.code.clone()), payment_token, connector_metadata, payment_experience, payment_method_subtype, payment_method_data, preprocessing_step_id, error_reason: error.as_ref().and_then(|details| details.reason.clone()), multiple_capture_count, connector_response_reference_id, amount_capturable, updated_by, merchant_connector_id, redirection_data: redirection_data.map(From::from), encoded_data, unified_code: error .as_ref() .and_then(|details| details.unified_code.clone()), unified_message: error .as_ref() .and_then(|details| details.unified_message.clone()), net_amount, external_three_ds_authentication_attempted, authentication_connector, authentication_id, fingerprint_id, client_source, client_version, customer_acceptance, profile_id, organization_id, card_network, order_tax_amount, shipping_cost, routing_result, authentication_applied, external_reference_id, connector, surcharge_amount, tax_on_surcharge, payment_method_billing_address: payment_method_billing_address.map(Encryption::from), connector_payment_data, connector_token_details, card_discovery, request_extended_authorization: None, extended_authorization_applied: None, capture_before: None, charges, feature_metadata, network_advice_code: error .as_ref() .and_then(|details| details.network_advice_code.clone()), network_decline_code: error .as_ref() .and_then(|details| details.network_decline_code.clone()), network_error_message: error .as_ref() .and_then(|details| details.network_error_message.clone()), processor_merchant_id: Some(processor_merchant_id), created_by: created_by.map(|cb| cb.to_string()), connector_request_reference_id, network_transaction_id, is_overcapture_enabled: None, network_details: None, attempts_group_id, is_stored_credential: None, authorized_amount, }) }
{ "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_-6774818795749080198
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs async fn convert_back( state: &KeyManagerState, storage_model: Self::DstType, key: &Secret<Vec<u8>>, key_manager_identifier: keymanager::Identifier, ) -> CustomResult<Self, ValidationError> where Self: Sized, { async { let connector_payment_id = storage_model .get_optional_connector_transaction_id() .cloned(); let decrypted_data = crypto_operation( state, common_utils::type_name!(Self::DstType), CryptoOperation::BatchDecrypt(EncryptedPaymentAttempt::to_encryptable( EncryptedPaymentAttempt { payment_method_billing_address: storage_model .payment_method_billing_address, }, )), key_manager_identifier, key.peek(), ) .await .and_then(|val| val.try_into_batchoperation())?; let decrypted_data = EncryptedPaymentAttempt::from_encryptable(decrypted_data) .change_context(common_utils::errors::CryptoError::DecodingFailed) .attach_printable("Invalid batch operation data")?; let payment_method_billing_address = decrypted_data .payment_method_billing_address .map(|billing| { billing.deserialize_inner_value(|value| value.parse_value("Address")) }) .transpose() .change_context(common_utils::errors::CryptoError::DecodingFailed) .attach_printable("Error while deserializing Address")?; let amount_details = AttemptAmountDetails { net_amount: storage_model.net_amount, tax_on_surcharge: storage_model.tax_on_surcharge, surcharge_amount: storage_model.surcharge_amount, order_tax_amount: storage_model.order_tax_amount, shipping_cost: storage_model.shipping_cost, amount_capturable: storage_model.amount_capturable, amount_to_capture: storage_model.amount_to_capture, }; let error = storage_model .error_code .zip(storage_model.error_message) .map(|(error_code, error_message)| ErrorDetails { code: error_code, message: error_message, reason: storage_model.error_reason, unified_code: storage_model.unified_code, unified_message: storage_model.unified_message, network_advice_code: storage_model.network_advice_code, network_decline_code: storage_model.network_decline_code, network_error_message: storage_model.network_error_message, }); Ok::<Self, error_stack::Report<common_utils::errors::CryptoError>>(Self { payment_id: storage_model.payment_id, merchant_id: storage_model.merchant_id.clone(), attempts_group_id: storage_model.attempts_group_id, id: storage_model.id, status: storage_model.status, amount_details, error, payment_method_id: storage_model.payment_method_id, payment_method_type: storage_model.payment_method_type_v2, connector_payment_id, authentication_type: storage_model.authentication_type, created_at: storage_model.created_at, modified_at: storage_model.modified_at, last_synced: storage_model.last_synced, cancellation_reason: storage_model.cancellation_reason, browser_info: storage_model.browser_info, payment_token: storage_model.payment_token, connector_metadata: storage_model.connector_metadata, payment_experience: storage_model.payment_experience, payment_method_data: storage_model.payment_method_data, routing_result: storage_model.routing_result, preprocessing_step_id: storage_model.preprocessing_step_id, multiple_capture_count: storage_model.multiple_capture_count, connector_response_reference_id: storage_model.connector_response_reference_id, updated_by: storage_model.updated_by, redirection_data: storage_model.redirection_data.map(From::from), encoded_data: storage_model.encoded_data, merchant_connector_id: storage_model.merchant_connector_id, external_three_ds_authentication_attempted: storage_model .external_three_ds_authentication_attempted, authentication_connector: storage_model.authentication_connector, authentication_id: storage_model.authentication_id, fingerprint_id: storage_model.fingerprint_id, charges: storage_model.charges, client_source: storage_model.client_source, client_version: storage_model.client_version, customer_acceptance: storage_model.customer_acceptance, profile_id: storage_model.profile_id, organization_id: storage_model.organization_id, payment_method_subtype: storage_model.payment_method_subtype, authentication_applied: storage_model.authentication_applied, external_reference_id: storage_model.external_reference_id, connector: storage_model.connector, payment_method_billing_address, connector_token_details: storage_model.connector_token_details, card_discovery: storage_model.card_discovery, feature_metadata: storage_model.feature_metadata.map(From::from), processor_merchant_id: storage_model .processor_merchant_id .unwrap_or(storage_model.merchant_id), created_by: storage_model .created_by .and_then(|created_by| created_by.parse::<CreatedBy>().ok()), connector_request_reference_id: storage_model.connector_request_reference_id, network_transaction_id: storage_model.network_transaction_id, authorized_amount: storage_model.authorized_amount, }) } .await .change_context(ValidationError::InvalidValue { message: "Failed while decrypting payment attempt".to_string(), }) }
{ "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_-2315557034734741735
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs async fn construct_new(self) -> CustomResult<Self::NewDstType, ValidationError> { use common_utils::encryption::Encryption; let Self { payment_id, merchant_id, attempts_group_id, status, error, amount_details, authentication_type, created_at, modified_at, last_synced, cancellation_reason, browser_info, payment_token, connector_metadata, payment_experience, payment_method_data, routing_result: _, preprocessing_step_id, multiple_capture_count, connector_response_reference_id, updated_by, redirection_data, encoded_data, merchant_connector_id, external_three_ds_authentication_attempted, authentication_connector, authentication_id, fingerprint_id, client_source, client_version, customer_acceptance, profile_id, organization_id, payment_method_type, connector_payment_id, payment_method_subtype, authentication_applied: _, external_reference_id: _, id, payment_method_id, payment_method_billing_address, connector, connector_token_details, card_discovery, charges, feature_metadata, processor_merchant_id, created_by, connector_request_reference_id, network_transaction_id, authorized_amount, } = self; let card_network = payment_method_data .as_ref() .and_then(|data| data.peek().as_object()) .and_then(|card| card.get("card")) .and_then(|data| data.as_object()) .and_then(|card| card.get("card_network")) .and_then(|network| network.as_str()) .map(|network| network.to_string()); let error_details = error; Ok(DieselPaymentAttemptNew { payment_id, merchant_id, status, network_transaction_id, error_message: error_details .as_ref() .map(|details| details.message.clone()), surcharge_amount: amount_details.surcharge_amount, tax_on_surcharge: amount_details.tax_on_surcharge, payment_method_id, authentication_type, created_at, modified_at, last_synced, cancellation_reason, browser_info, payment_token, error_code: error_details.as_ref().map(|details| details.code.clone()), connector_metadata, payment_experience, payment_method_data, preprocessing_step_id, error_reason: error_details .as_ref() .and_then(|details| details.reason.clone()), connector_response_reference_id, multiple_capture_count, amount_capturable: amount_details.amount_capturable, updated_by, merchant_connector_id, redirection_data: redirection_data.map(From::from), encoded_data, unified_code: error_details .as_ref() .and_then(|details| details.unified_code.clone()), unified_message: error_details .as_ref() .and_then(|details| details.unified_message.clone()), net_amount: amount_details.net_amount, external_three_ds_authentication_attempted, authentication_connector, authentication_id, fingerprint_id, client_source, client_version, customer_acceptance, profile_id, organization_id, card_network, order_tax_amount: amount_details.order_tax_amount, shipping_cost: amount_details.shipping_cost, amount_to_capture: amount_details.amount_to_capture, payment_method_billing_address: payment_method_billing_address.map(Encryption::from), payment_method_subtype, connector_payment_id: connector_payment_id .as_ref() .map(|txn_id| ConnectorTransactionId::TxnId(txn_id.clone())), payment_method_type_v2: payment_method_type, id, charges, connector_token_details, card_discovery, extended_authorization_applied: None, request_extended_authorization: None, capture_before: None, feature_metadata: feature_metadata.as_ref().map(From::from), connector, network_advice_code: error_details .as_ref() .and_then(|details| details.network_advice_code.clone()), network_decline_code: error_details .as_ref() .and_then(|details| details.network_decline_code.clone()), network_error_message: error_details .as_ref() .and_then(|details| details.network_error_message.clone()), processor_merchant_id: Some(processor_merchant_id), created_by: created_by.map(|cb| cb.to_string()), connector_request_reference_id, network_details: None, attempts_group_id, is_stored_credential: None, authorized_amount, }) }
{ "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_-8987528911516603606
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_intent.rs pub fn is_confirm_operation(&self) -> bool { matches!(self, Self::ConfirmIntent { .. }) }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "is_confirm_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_4168298316665643824
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_intent.rs fn try_from( (constraints, auth_profile_id_list): (T, Option<Vec<id_type::ProfileId>>), ) -> Result<Self, Self::Error> { let payment_intent_constraints = Self::from(constraints); if let Self::List(mut pi_list_params) = payment_intent_constraints { let profile_id_from_request_body = pi_list_params.profile_id; match (profile_id_from_request_body, auth_profile_id_list) { (None, None) => pi_list_params.profile_id = None, (None, Some(auth_profile_id_list)) => { pi_list_params.profile_id = Some(auth_profile_id_list) } (Some(profile_id_from_request_body), None) => { pi_list_params.profile_id = Some(profile_id_from_request_body) } (Some(profile_id_from_request_body), Some(auth_profile_id_list)) => { let profile_id_from_request_body_is_available_in_auth_profile_id_list = profile_id_from_request_body .iter() .all(|profile_id| auth_profile_id_list.contains(profile_id)); if profile_id_from_request_body_is_available_in_auth_profile_id_list { pi_list_params.profile_id = Some(profile_id_from_request_body) } else { // This scenario is very unlikely to happen let inaccessible_profile_ids: Vec<_> = profile_id_from_request_body .iter() .filter(|profile_id| !auth_profile_id_list.contains(profile_id)) .collect(); return Err(error_stack::Report::new( errors::api_error_response::ApiErrorResponse::PreconditionFailed { message: format!( "Access not available for the given profile_id {inaccessible_profile_ids:?}", ), }, )); } } } Ok(Self::List(pi_list_params)) } else { Ok(payment_intent_constraints) } }
{ "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_-7370504259205453443
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_intent.rs fn from(value: api_models::payments::PaymentListFilterConstraints) -> Self { let api_models::payments::PaymentListFilterConstraints { payment_id, profile_id, customer_id, limit, offset, amount_filter, time_range, connector, currency, status, payment_method, payment_method_type, authentication_type, merchant_connector_id, order, card_network, card_discovery, merchant_order_reference_id, } = value; if let Some(payment_intent_id) = payment_id { Self::Single { payment_intent_id } } else { Self::List(Box::new(PaymentIntentListParams { offset: offset.unwrap_or_default(), starting_at: time_range.map(|t| t.start_time), ending_at: time_range.and_then(|t| t.end_time), amount_filter, connector, currency, status, payment_method, payment_method_type, authentication_type, merchant_connector_id, profile_id: profile_id.map(|profile_id| vec![profile_id]), customer_id, starting_after_id: None, ending_before_id: None, limit: Some(std::cmp::min(limit, PAYMENTS_LIST_MAX_LIMIT_V2)), order, card_network, card_discovery, merchant_order_reference_id, })) } }
{ "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_-9066956987611646995
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_intent.rs pub fn get_profile_id_list(&self) -> Option<Vec<id_type::ProfileId>> { if let Self::List(pi_list_params) = self { pi_list_params.profile_id.clone() } else { None } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_profile_id_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_7351332951417189287
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_intent.rs pub fn get_profile_id(&self) -> Option<id_type::ProfileId> { let Self::List(pi_list_params) = self; pi_list_params.profile_id.clone() }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_profile_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_-6755766080506098650
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_intent.rs async fn convert(self) -> CustomResult<Self::DstType, ValidationError> { Ok(DieselPaymentIntent { payment_id: self.payment_id, merchant_id: self.merchant_id, status: self.status, amount: self.amount, currency: self.currency, amount_captured: self.amount_captured, customer_id: self.customer_id, description: self.description, return_url: None, // deprecated metadata: self.metadata, connector_id: self.connector_id, shipping_address_id: self.shipping_address_id, billing_address_id: self.billing_address_id, statement_descriptor_name: self.statement_descriptor_name, statement_descriptor_suffix: self.statement_descriptor_suffix, created_at: self.created_at, modified_at: self.modified_at, last_synced: self.last_synced, setup_future_usage: self.setup_future_usage, off_session: self.off_session, client_secret: self.client_secret, active_attempt_id: self.active_attempt.get_id(), business_country: self.business_country, business_label: self.business_label, order_details: self.order_details, allowed_payment_method_types: self.allowed_payment_method_types, connector_metadata: self.connector_metadata, feature_metadata: self.feature_metadata, attempt_count: self.attempt_count, profile_id: self.profile_id, merchant_decision: self.merchant_decision, payment_link_id: self.payment_link_id, payment_confirm_source: self.payment_confirm_source, updated_by: self.updated_by, surcharge_applicable: self.surcharge_applicable, request_incremental_authorization: self.request_incremental_authorization, incremental_authorization_allowed: self.incremental_authorization_allowed, authorization_count: self.authorization_count, fingerprint_id: self.fingerprint_id, session_expiry: self.session_expiry, request_external_three_ds_authentication: self.request_external_three_ds_authentication, charges: None, split_payments: self.split_payments, frm_metadata: self.frm_metadata, customer_details: self.customer_details.map(Encryption::from), billing_details: self.billing_details.map(Encryption::from), merchant_order_reference_id: self.merchant_order_reference_id, shipping_details: self.shipping_details.map(Encryption::from), is_payment_processor_token_flow: self.is_payment_processor_token_flow, organization_id: self.organization_id, shipping_cost: self.shipping_cost, tax_details: self.tax_details, skip_external_tax_calculation: self.skip_external_tax_calculation, request_extended_authorization: self.request_extended_authorization, psd2_sca_exemption_type: self.psd2_sca_exemption_type, platform_merchant_id: None, processor_merchant_id: Some(self.processor_merchant_id), created_by: self.created_by.map(|cb| cb.to_string()), force_3ds_challenge: self.force_3ds_challenge, force_3ds_challenge_trigger: self.force_3ds_challenge_trigger, is_iframe_redirection_enabled: self.is_iframe_redirection_enabled, extended_return_url: self.return_url, is_payment_id_from_merchant: self.is_payment_id_from_merchant, payment_channel: self.payment_channel, tax_status: self.tax_status, discount_amount: self.discount_amount, order_date: self.order_date, shipping_amount_tax: self.shipping_amount_tax, duty_amount: self.duty_amount, enable_partial_authorization: self.enable_partial_authorization, enable_overcapture: self.enable_overcapture, mit_category: self.mit_category, }) }
{ "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_4110651038266822056
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_intent.rs async fn convert_back( state: &KeyManagerState, storage_model: Self::DstType, key: &Secret<Vec<u8>>, key_manager_identifier: keymanager::Identifier, ) -> CustomResult<Self, ValidationError> where Self: Sized, { async { let decrypted_data = crypto_operation( state, type_name!(Self::DstType), CryptoOperation::BatchDecrypt(super::EncryptedPaymentIntent::to_encryptable( super::EncryptedPaymentIntent { billing_details: storage_model.billing_details, shipping_details: storage_model.shipping_details, customer_details: storage_model.customer_details, }, )), key_manager_identifier, key.peek(), ) .await .and_then(|val| val.try_into_batchoperation())?; let data = super::EncryptedPaymentIntent::from_encryptable(decrypted_data) .change_context(common_utils::errors::CryptoError::DecodingFailed) .attach_printable("Invalid batch operation data")?; Ok::<Self, error_stack::Report<common_utils::errors::CryptoError>>(Self { payment_id: storage_model.payment_id, merchant_id: storage_model.merchant_id.clone(), status: storage_model.status, amount: storage_model.amount, currency: storage_model.currency, amount_captured: storage_model.amount_captured, customer_id: storage_model.customer_id, description: storage_model.description, return_url: storage_model .extended_return_url .or(storage_model.return_url), // fallback to legacy metadata: storage_model.metadata, connector_id: storage_model.connector_id, shipping_address_id: storage_model.shipping_address_id, billing_address_id: storage_model.billing_address_id, statement_descriptor_name: storage_model.statement_descriptor_name, statement_descriptor_suffix: storage_model.statement_descriptor_suffix, created_at: storage_model.created_at, modified_at: storage_model.modified_at, last_synced: storage_model.last_synced, setup_future_usage: storage_model.setup_future_usage, off_session: storage_model.off_session, client_secret: storage_model.client_secret, active_attempt: RemoteStorageObject::ForeignID(storage_model.active_attempt_id), business_country: storage_model.business_country, business_label: storage_model.business_label, order_details: storage_model.order_details, allowed_payment_method_types: storage_model.allowed_payment_method_types, connector_metadata: storage_model.connector_metadata, feature_metadata: storage_model.feature_metadata, attempt_count: storage_model.attempt_count, profile_id: storage_model.profile_id, merchant_decision: storage_model.merchant_decision, payment_link_id: storage_model.payment_link_id, payment_confirm_source: storage_model.payment_confirm_source, updated_by: storage_model.updated_by, surcharge_applicable: storage_model.surcharge_applicable, request_incremental_authorization: storage_model.request_incremental_authorization, incremental_authorization_allowed: storage_model.incremental_authorization_allowed, authorization_count: storage_model.authorization_count, fingerprint_id: storage_model.fingerprint_id, session_expiry: storage_model.session_expiry, request_external_three_ds_authentication: storage_model .request_external_three_ds_authentication, split_payments: storage_model.split_payments, frm_metadata: storage_model.frm_metadata, shipping_cost: storage_model.shipping_cost, tax_details: storage_model.tax_details, customer_details: data.customer_details, billing_details: data.billing_details, merchant_order_reference_id: storage_model.merchant_order_reference_id, shipping_details: data.shipping_details, is_payment_processor_token_flow: storage_model.is_payment_processor_token_flow, organization_id: storage_model.organization_id, skip_external_tax_calculation: storage_model.skip_external_tax_calculation, request_extended_authorization: storage_model.request_extended_authorization, psd2_sca_exemption_type: storage_model.psd2_sca_exemption_type, processor_merchant_id: storage_model .processor_merchant_id .unwrap_or(storage_model.merchant_id), created_by: storage_model .created_by .and_then(|created_by| created_by.parse::<CreatedBy>().ok()), force_3ds_challenge: storage_model.force_3ds_challenge, force_3ds_challenge_trigger: storage_model.force_3ds_challenge_trigger, is_iframe_redirection_enabled: storage_model.is_iframe_redirection_enabled, is_payment_id_from_merchant: storage_model.is_payment_id_from_merchant, payment_channel: storage_model.payment_channel, tax_status: storage_model.tax_status, discount_amount: storage_model.discount_amount, shipping_amount_tax: storage_model.shipping_amount_tax, duty_amount: storage_model.duty_amount, order_date: storage_model.order_date, enable_partial_authorization: storage_model.enable_partial_authorization, enable_overcapture: storage_model.enable_overcapture, mit_category: storage_model.mit_category, }) } .await .change_context(ValidationError::InvalidValue { message: "Failed while decrypting payment intent".to_string(), }) }
{ "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_-8394798243775754777
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payments/payment_intent.rs async fn construct_new(self) -> CustomResult<Self::NewDstType, ValidationError> { Ok(DieselPaymentIntentNew { payment_id: self.payment_id, merchant_id: self.merchant_id, status: self.status, amount: self.amount, currency: self.currency, amount_captured: self.amount_captured, customer_id: self.customer_id, description: self.description, return_url: None, // deprecated metadata: self.metadata, connector_id: self.connector_id, shipping_address_id: self.shipping_address_id, billing_address_id: self.billing_address_id, statement_descriptor_name: self.statement_descriptor_name, statement_descriptor_suffix: self.statement_descriptor_suffix, created_at: self.created_at, modified_at: self.modified_at, last_synced: self.last_synced, setup_future_usage: self.setup_future_usage, off_session: self.off_session, client_secret: self.client_secret, active_attempt_id: self.active_attempt.get_id(), business_country: self.business_country, business_label: self.business_label, order_details: self.order_details, allowed_payment_method_types: self.allowed_payment_method_types, connector_metadata: self.connector_metadata, feature_metadata: self.feature_metadata, attempt_count: self.attempt_count, profile_id: self.profile_id, merchant_decision: self.merchant_decision, payment_link_id: self.payment_link_id, payment_confirm_source: self.payment_confirm_source, updated_by: self.updated_by, surcharge_applicable: self.surcharge_applicable, request_incremental_authorization: self.request_incremental_authorization, incremental_authorization_allowed: self.incremental_authorization_allowed, authorization_count: self.authorization_count, fingerprint_id: self.fingerprint_id, session_expiry: self.session_expiry, request_external_three_ds_authentication: self.request_external_three_ds_authentication, charges: None, split_payments: self.split_payments, frm_metadata: self.frm_metadata, customer_details: self.customer_details.map(Encryption::from), billing_details: self.billing_details.map(Encryption::from), merchant_order_reference_id: self.merchant_order_reference_id, shipping_details: self.shipping_details.map(Encryption::from), is_payment_processor_token_flow: self.is_payment_processor_token_flow, organization_id: self.organization_id, shipping_cost: self.shipping_cost, tax_details: self.tax_details, skip_external_tax_calculation: self.skip_external_tax_calculation, request_extended_authorization: self.request_extended_authorization, psd2_sca_exemption_type: self.psd2_sca_exemption_type, platform_merchant_id: None, processor_merchant_id: Some(self.processor_merchant_id), created_by: self.created_by.map(|cb| cb.to_string()), force_3ds_challenge: self.force_3ds_challenge, force_3ds_challenge_trigger: self.force_3ds_challenge_trigger, is_iframe_redirection_enabled: self.is_iframe_redirection_enabled, extended_return_url: self.return_url, is_payment_id_from_merchant: self.is_payment_id_from_merchant, payment_channel: self.payment_channel, tax_status: self.tax_status, discount_amount: self.discount_amount, order_date: self.order_date, shipping_amount_tax: self.shipping_amount_tax, duty_amount: self.duty_amount, enable_partial_authorization: self.enable_partial_authorization, enable_overcapture: self.enable_overcapture, mit_category: self.mit_category, }) }
{ "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_-4506937560482731425
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_request_types/subscriptions.rs pub fn new(limit: Option<u32>, offset: Option<u32>) -> Self { Self { limit, offset } }
{ "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_1950746111956266359
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_request_types/subscriptions.rs fn default() -> Self { Self { limit: Some(10), offset: Some(0), } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "default", "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_-3321351547526208628
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_request_types/fraud_check.rs fn get_api_event_type(&self) -> Option<ApiEventsType> { Some(ApiEventsType::FraudCheck) }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_api_event_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_-7990905782131394670
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs pub fn get_acs_url(&self) -> Option<String> { if let Self::Challenge(challenge_params) = self { challenge_params.acs_url.as_ref().map(ToString::to_string) } else { None } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_acs_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_1708622371723437711
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs pub fn get_challenge_request(&self) -> Option<String> { if let Self::Challenge(challenge_params) = self { challenge_params.challenge_request.clone() } else { None } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_challenge_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_6931439472111021006
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs pub fn get_challenge_request_key(&self) -> Option<String> { if let Self::Challenge(challenge_params) = self { challenge_params.challenge_request_key.clone() } else { None } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_challenge_request_key", "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_1683289446300908301
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs pub fn get_acs_reference_number(&self) -> Option<String> { if let Self::Challenge(challenge_params) = self { challenge_params.acs_reference_number.clone() } else { None } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_acs_reference_number", "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_-3799791077451130274
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs pub fn get_acs_trans_id(&self) -> Option<String> { if let Self::Challenge(challenge_params) = self { challenge_params.acs_trans_id.clone() } else { None } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_acs_trans_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_-7984295425605685800
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs pub fn get_acs_signed_content(&self) -> Option<String> { if let Self::Challenge(challenge_params) = self { challenge_params.acs_signed_content.clone() } else { None } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_acs_signed_content", "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_-249750202044993065
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs pub fn get_decoupled_authentication_type(&self) -> common_enums::DecoupledAuthenticationType { match self { Self::Challenge(_) => common_enums::DecoupledAuthenticationType::Challenge, Self::Frictionless => common_enums::DecoupledAuthenticationType::Frictionless, } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_decoupled_authentication_type", "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_3573675292648908604
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs fn try_from( authentication: &diesel_models::authentication::Authentication, ) -> Result<Self, Self::Error> { let error_message = ApiErrorResponse::UnprocessableEntity { message: "Pre Authentication must be completed successfully before Authentication can be performed".to_string() }; let threeds_server_transaction_id = authentication .threeds_server_transaction_id .clone() .get_required_value("threeds_server_transaction_id") .change_context(error_message.clone())?; let message_version = authentication .message_version .clone() .get_required_value("message_version") .change_context(error_message)?; Ok(Self { threeds_server_transaction_id, message_version, acquirer_bin: authentication.acquirer_bin.clone(), acquirer_merchant_id: authentication.acquirer_merchant_id.clone(), connector_metadata: authentication.connector_metadata.clone(), acquirer_country_code: authentication.acquirer_country_code.clone(), }) }
{ "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_-8477451510809137391
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_response_types/subscriptions.rs fn from(value: SubscriptionLineItem) -> Self { Self { item_id: value.item_id, description: value.description, item_type: value.item_type, amount: value.amount, currency: value.currency, quantity: value.quantity, } }
{ "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_2438066923552038013
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_response_types/fraud_check.rs fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> { Some(common_utils::events::ApiEventsType::FraudCheck) }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_api_event_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_-6847490099515245548
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_flow_types/webhooks.rs pub fn new(txn_id: masking::Secret<String>) -> Self { Self(txn_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_-5879487490753574200
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/router_flow_types/webhooks.rs pub fn get_id(&self) -> &masking::Secret<String> { &self.0 }
{ "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_-6951689381049000592
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/errors/api_error_response.rs fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, r#"{{"error":{}}}"#, serde_json::to_string(self).unwrap_or_else(|_| "API error response".to_string()) ) }
{ "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_3082965387643535210
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/errors/api_error_response.rs fn switch(&self) -> api_models::errors::types::ApiErrorResponse { use api_models::errors::types::{ApiError, ApiErrorResponse as AER}; match self { Self::ExternalConnectorError { code, message, connector, reason, status_code, } => AER::ConnectorError(ApiError::new("CE", 0, format!("{code}: {message}"), Some(Extra {connector: Some(connector.clone()), reason: reason.to_owned(), ..Default::default()})), StatusCode::from_u16(*status_code).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)), Self::PaymentAuthorizationFailed { data } => { AER::BadRequest(ApiError::new("CE", 1, "Payment failed during authorization with connector. Retry payment", Some(Extra { data: data.clone(), ..Default::default()}))) } Self::PaymentAuthenticationFailed { data } => { AER::BadRequest(ApiError::new("CE", 2, "Payment failed during authentication with connector. Retry payment", Some(Extra { data: data.clone(), ..Default::default()}))) } Self::PaymentCaptureFailed { data } => { AER::BadRequest(ApiError::new("CE", 3, "Capture attempt failed while processing with connector", Some(Extra { data: data.clone(), ..Default::default()}))) } Self::InvalidCardData { data } => AER::BadRequest(ApiError::new("CE", 4, "The card data is invalid", Some(Extra { data: data.clone(), ..Default::default()}))), Self::CardExpired { data } => AER::BadRequest(ApiError::new("CE", 5, "The card has expired", Some(Extra { data: data.clone(), ..Default::default()}))), Self::RefundFailed { data } => AER::BadRequest(ApiError::new("CE", 6, "Refund failed while processing with connector. Retry refund", Some(Extra { data: data.clone(), ..Default::default()}))), Self::VerificationFailed { data } => { AER::BadRequest(ApiError::new("CE", 7, "Verification failed while processing with connector. Retry operation", Some(Extra { data: data.clone(), ..Default::default()}))) }, Self::DisputeFailed { data } => { AER::BadRequest(ApiError::new("CE", 8, "Dispute operation failed while processing with connector. Retry operation", Some(Extra { data: data.clone(), ..Default::default()}))) } Self::ResourceBusy => { AER::Unprocessable(ApiError::new("HE", 0, "There was an issue processing the webhook body", None)) } Self::CurrencyConversionFailed => { AER::Unprocessable(ApiError::new("HE", 0, "Failed to convert currency to minor unit", None)) } Self::InternalServerError => { AER::InternalServerError(ApiError::new("HE", 0, "Something went wrong", None)) }, Self::HealthCheckError { message,component } => { AER::InternalServerError(ApiError::new("HE",0,format!("{component} health check failed with error: {message}"),None)) }, Self::DuplicateRefundRequest => AER::BadRequest(ApiError::new("HE", 1, "Duplicate refund request. Refund already attempted with the refund ID", None)), Self::DuplicateMandate => AER::BadRequest(ApiError::new("HE", 1, "Duplicate mandate request. Mandate already attempted with the Mandate ID", None)), Self::DuplicateMerchantAccount => AER::BadRequest(ApiError::new("HE", 1, "The merchant account with the specified details already exists in our records", None)), Self::DuplicateMerchantConnectorAccount { profile_id, connector_label: connector_name } => { AER::BadRequest(ApiError::new("HE", 1, format!("The merchant connector account with the specified profile_id '{profile_id}' and connector_label '{connector_name}' already exists in our records"), None)) } Self::DuplicatePaymentMethod => AER::BadRequest(ApiError::new("HE", 1, "The payment method with the specified details already exists in our records", None)), Self::DuplicatePayment { payment_id } => { AER::BadRequest(ApiError::new("HE", 1, "The payment with the specified payment_id already exists in our records", Some(Extra {reason: Some(format!("{payment_id:?} already exists")), ..Default::default()}))) } Self::DuplicatePayout { payout_id } => { AER::BadRequest(ApiError::new("HE", 1, format!("The payout with the specified payout_id '{payout_id:?}' already exists in our records"), None)) } Self::DuplicateConfig => { AER::BadRequest(ApiError::new("HE", 1, "The config with the specified key already exists in our records", None)) } Self::RefundNotFound => { AER::NotFound(ApiError::new("HE", 2, "Refund does not exist in our records.", None)) } Self::PaymentLinkNotFound => { AER::NotFound(ApiError::new("HE", 2, "Payment Link does not exist in our records", None)) } Self::CustomerNotFound => { AER::NotFound(ApiError::new("HE", 2, "Customer does not exist in our records", None)) } Self::ConfigNotFound => { AER::NotFound(ApiError::new("HE", 2, "Config key does not exist in our records.", None)) }, Self::PaymentNotFound => { AER::NotFound(ApiError::new("HE", 2, "Payment does not exist in our records", None)) } Self::PaymentMethodNotFound => { AER::NotFound(ApiError::new("HE", 2, "Payment method does not exist in our records", None)) } Self::MerchantAccountNotFound => { AER::NotFound(ApiError::new("HE", 2, "Merchant account does not exist in our records", None)) } Self::MerchantConnectorAccountNotFound {id } => { AER::NotFound(ApiError::new("HE", 2, "Merchant connector account does not exist in our records", Some(Extra {reason: Some(format!("{id} does not exist")), ..Default::default()}))) } Self::ProfileNotFound { id } => { AER::NotFound(ApiError::new("HE", 2, format!("Business profile with the given id {id} does not exist"), None)) } Self::ProfileAcquirerNotFound { profile_acquirer_id, profile_id } => { AER::NotFound(ApiError::new("HE", 2, format!("Profile acquirer with id '{profile_acquirer_id}' not found for profile '{profile_id}'."), None)) } Self::PollNotFound { .. } => { AER::NotFound(ApiError::new("HE", 2, "Poll does not exist in our records", None)) }, Self::ResourceIdNotFound => { AER::NotFound(ApiError::new("HE", 2, "Resource ID does not exist in our records", None)) } Self::MandateNotFound => { AER::NotFound(ApiError::new("HE", 2, "Mandate does not exist in our records", None)) } Self::AuthenticationNotFound { .. } => { AER::NotFound(ApiError::new("HE", 2, "Authentication does not exist in our records", None)) }, Self::MandateUpdateFailed => { AER::InternalServerError(ApiError::new("HE", 2, "Mandate update failed", None)) }, Self::ApiKeyNotFound => { AER::NotFound(ApiError::new("HE", 2, "API Key does not exist in our records", None)) } Self::PayoutNotFound => { AER::NotFound(ApiError::new("HE", 2, "Payout does not exist in our records", None)) } Self::EventNotFound => { AER::NotFound(ApiError::new("HE", 2, "Event does not exist in our records", None)) } Self::MandateSerializationFailed | Self::MandateDeserializationFailed => { AER::InternalServerError(ApiError::new("HE", 3, "Something went wrong", None)) }, Self::ReturnUrlUnavailable => AER::NotFound(ApiError::new("HE", 3, "Return URL is not configured and not passed in payments request", None)), Self::RefundNotPossible { connector } => { AER::BadRequest(ApiError::new("HE", 3, format!("This refund is not possible through Hyperswitch. Please raise the refund through {connector} dashboard"), None)) } Self::MandateValidationFailed { reason } => { AER::BadRequest(ApiError::new("HE", 3, "Mandate Validation Failed", Some(Extra { reason: Some(reason.to_owned()), ..Default::default() }))) } Self::PaymentNotSucceeded => AER::BadRequest(ApiError::new("HE", 3, "The payment has not succeeded yet. Please pass a successful payment to initiate refund", None)), Self::MerchantConnectorAccountDisabled => { AER::BadRequest(ApiError::new("HE", 3, "The selected merchant connector account is disabled", None)) } Self::PaymentBlockedError { message, reason, .. } => AER::DomainError(ApiError::new("HE", 3, message, Some(Extra { reason: Some(reason.clone()), ..Default::default() }))), Self::FileValidationFailed { reason } => { AER::BadRequest(ApiError::new("HE", 3, format!("File validation failed {reason}"), None)) } Self::DisputeStatusValidationFailed { .. } => { AER::BadRequest(ApiError::new("HE", 3, "Dispute status validation failed", None)) } Self::SuccessfulPaymentNotFound => { AER::NotFound(ApiError::new("HE", 4, "Successful payment not found for the given payment id", None)) } Self::IncorrectConnectorNameGiven => { AER::NotFound(ApiError::new("HE", 4, "The connector provided in the request is incorrect or not available", None)) } Self::AddressNotFound => { AER::NotFound(ApiError::new("HE", 4, "Address does not exist in our records", None)) }, Self::DisputeNotFound { .. } => { AER::NotFound(ApiError::new("HE", 4, "Dispute does not exist in our records", None)) }, Self::FileNotFound => { AER::NotFound(ApiError::new("HE", 4, "File does not exist in our records", None)) } Self::FileNotAvailable => { AER::NotFound(ApiError::new("HE", 4, "File not available", None)) } Self::MissingTenantId => { AER::InternalServerError(ApiError::new("HE", 5, "Missing Tenant ID in the request".to_string(), None)) } Self::InvalidTenant { tenant_id } => { AER::InternalServerError(ApiError::new("HE", 5, format!("Invalid Tenant {tenant_id}"), None)) } Self::AmountConversionFailed { amount_type } => { AER::InternalServerError(ApiError::new("HE", 6, format!("Failed to convert amount to {amount_type} type"), None)) } Self::NotImplemented { message } => { AER::NotImplemented(ApiError::new("IR", 0, format!("{message:?}"), None)) } Self::Unauthorized => AER::Unauthorized(ApiError::new( "IR", 1, "API key not provided or invalid API key used", None )), Self::InvalidRequestUrl => { AER::NotFound(ApiError::new("IR", 2, "Unrecognized request URL", None)) } Self::InvalidHttpMethod => AER::MethodNotAllowed(ApiError::new( "IR", 3, "The HTTP method is not applicable for this API", None )), Self::MissingRequiredField { field_name } => AER::BadRequest( ApiError::new("IR", 4, format!("Missing required param: {field_name}"), None), ), Self::InvalidDataFormat { field_name, expected_format, } => AER::Unprocessable(ApiError::new( "IR", 5, format!( "{field_name} contains invalid data. Expected format is {expected_format}" ), None )), Self::InvalidRequestData { message } => { AER::Unprocessable(ApiError::new("IR", 6, message.to_string(), None)) } Self::InvalidDataValue { field_name } => AER::BadRequest(ApiError::new( "IR", 7, format!("Invalid value provided: {field_name}"), None )), Self::ClientSecretNotGiven => AER::BadRequest(ApiError::new( "IR", 8, "client_secret was not provided", None )), Self::ClientSecretExpired => AER::BadRequest(ApiError::new( "IR", 8, "The provided client_secret has expired", None )), Self::ClientSecretInvalid => { AER::BadRequest(ApiError::new("IR", 9, "The client_secret provided does not match the client_secret associated with the Payment", None)) } Self::MandateActive => { AER::BadRequest(ApiError::new("IR", 10, "Customer has active mandate/subsciption", None)) } Self::CustomerRedacted => { AER::BadRequest(ApiError::new("IR", 11, "Customer has already been redacted", None)) } Self::MaximumRefundCount => AER::BadRequest(ApiError::new("IR", 12, "Reached maximum refund attempts", None)), Self::RefundAmountExceedsPaymentAmount => { AER::BadRequest(ApiError::new("IR", 13, "The refund amount exceeds the amount captured", None)) } Self::PaymentUnexpectedState { current_flow, field_name, current_value, states, } => AER::BadRequest(ApiError::new("IR", 14, format!("This Payment could not be {current_flow} because it has a {field_name} of {current_value}. The expected state is {states}"), None)), Self::InvalidEphemeralKey => AER::Unauthorized(ApiError::new("IR", 15, "Invalid Ephemeral Key for the customer", None)), Self::PreconditionFailed { message } => { AER::BadRequest(ApiError::new("IR", 16, message.to_string(), None)) } Self::InvalidJwtToken => AER::Unauthorized(ApiError::new("IR", 17, "Access forbidden, invalid JWT token was used", None)), Self::GenericUnauthorized { message } => { AER::Unauthorized(ApiError::new("IR", 18, message.to_string(), None)) }, Self::NotSupported { message } => { AER::BadRequest(ApiError::new("IR", 19, "Payment method type not supported", Some(Extra {reason: Some(message.to_owned()), ..Default::default()}))) }, Self::FlowNotSupported { flow, connector } => { AER::BadRequest(ApiError::new("IR", 20, format!("{flow} flow not supported"), Some(Extra {connector: Some(connector.to_owned()), ..Default::default()}))) //FIXME: error message } Self::MissingRequiredFields { field_names } => AER::BadRequest( ApiError::new("IR", 21, "Missing required params".to_string(), Some(Extra {data: Some(serde_json::json!(field_names)), ..Default::default() })), ), Self::AccessForbidden {resource} => { AER::ForbiddenCommonResource(ApiError::new("IR", 22, format!("Access forbidden. Not authorized to access this resource {resource}"), None)) }, Self::FileProviderNotSupported { message } => { AER::BadRequest(ApiError::new("IR", 23, message.to_string(), None)) }, Self::InvalidWalletToken { wallet_name} => AER::Unprocessable(ApiError::new( "IR", 24, format!("Invalid {wallet_name} wallet token"), None )), Self::PaymentMethodDeleteFailed => { AER::BadRequest(ApiError::new("IR", 25, "Cannot delete the default payment method", None)) } Self::InvalidCookie => { AER::BadRequest(ApiError::new("IR", 26, "Invalid Cookie", None)) } Self::ExtendedCardInfoNotFound => { AER::NotFound(ApiError::new("IR", 27, "Extended card info does not exist", None)) } Self::CurrencyNotSupported { message } => { AER::BadRequest(ApiError::new("IR", 28, message, None)) } Self::UnprocessableEntity {message} => AER::Unprocessable(ApiError::new("IR", 29, message.to_string(), None)), Self::InvalidConnectorConfiguration {config} => { AER::BadRequest(ApiError::new("IR", 30, format!("Merchant connector account is configured with invalid {config}"), None)) } Self::InvalidCardIin => AER::BadRequest(ApiError::new("IR", 31, "The provided card IIN does not exist", None)), Self::InvalidCardIinLength => AER::BadRequest(ApiError::new("IR", 32, "The provided card IIN length is invalid, please provide an IIN with 6 digits", None)), Self::MissingFile => { AER::BadRequest(ApiError::new("IR", 33, "File not found in the request", None)) } Self::MissingDisputeId => { AER::BadRequest(ApiError::new("IR", 34, "Dispute id not found in the request", None)) } Self::MissingFilePurpose => { AER::BadRequest(ApiError::new("IR", 35, "File purpose not found in the request or is invalid", None)) } Self::MissingFileContentType => { AER::BadRequest(ApiError::new("IR", 36, "File content type not found", None)) } Self::GenericNotFoundError { message } => { AER::NotFound(ApiError::new("IR", 37, message, None)) }, Self::GenericDuplicateError { message } => { AER::BadRequest(ApiError::new("IR", 38, message, None)) } Self::IncorrectPaymentMethodConfiguration => { AER::BadRequest(ApiError::new("IR", 39, "No eligible connector was found for the current payment method configuration", None)) } Self::LinkConfigurationError { message } => { AER::BadRequest(ApiError::new("IR", 40, message, None)) }, Self::PayoutFailed { data } => { AER::BadRequest(ApiError::new("IR", 41, "Payout failed while processing with connector.", Some(Extra { data: data.clone(), ..Default::default()}))) }, Self::CookieNotFound => { AER::Unauthorized(ApiError::new("IR", 42, "Cookies are not found in the request", None)) }, Self::ExternalVaultFailed => { AER::BadRequest(ApiError::new("IR", 45, "External Vault failed while processing with connector.", None)) }, Self::MandatePaymentDataMismatch { fields} => { AER::BadRequest(ApiError::new("IR", 46, format!("Field {fields} doesn't match with the ones used during mandate creation"), Some(Extra {fields: Some(fields.to_owned()), ..Default::default()}))) //FIXME: error message } Self::MaxFieldLengthViolated { connector, field_name, max_length, received_length} => { AER::BadRequest(ApiError::new("IR", 47, format!("Connector '{connector}' rejected field '{field_name}': length {received_length} exceeds maximum of {max_length}"), Some(Extra {connector: Some(connector.to_string()), ..Default::default()}))) } Self::WebhookAuthenticationFailed => { AER::Unauthorized(ApiError::new("WE", 1, "Webhook authentication failed", None)) } Self::WebhookBadRequest => { AER::BadRequest(ApiError::new("WE", 2, "Bad request body received", None)) } Self::WebhookProcessingFailure => { AER::InternalServerError(ApiError::new("WE", 3, "There was an issue processing the webhook", None)) }, Self::WebhookResourceNotFound => { AER::NotFound(ApiError::new("WE", 4, "Webhook resource was not found", None)) } Self::WebhookUnprocessableEntity => { AER::Unprocessable(ApiError::new("WE", 5, "There was an issue processing the webhook body", None)) }, Self::WebhookInvalidMerchantSecret => { AER::BadRequest(ApiError::new("WE", 6, "Merchant Secret set for webhook source verification is invalid", None)) } Self::IntegrityCheckFailed { reason, field_names, connector_transaction_id } => AER::InternalServerError(ApiError::new( "IE", 0, format!("{reason} as data mismatched for {field_names}"), Some(Extra { connector_transaction_id: connector_transaction_id.to_owned(), ..Default::default() }) )), Self::PlatformAccountAuthNotSupported => { AER::BadRequest(ApiError::new("IR", 43, "API does not support platform operation", None)) } Self::InvalidPlatformOperation => { AER::Unauthorized(ApiError::new("IR", 44, "Invalid platform account operation", None)) } Self::TokenizationRecordNotFound{ id } => { AER::NotFound(ApiError::new("HE", 2, format!("Tokenization record not found for the given token_id '{id}' "), None)) } Self::SubscriptionError { operation } => { AER::BadRequest(ApiError::new("CE", 9, format!("Subscription operation: {operation} failed with connector"), None)) } } }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "switch", "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_-8171761026377135865
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/errors/api_error_response.rs fn status_code(&self) -> StatusCode { ErrorSwitch::<api_models::errors::types::ApiErrorResponse>::switch(self).status_code() }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "status_code", "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_1061313390387256699
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/errors/api_error_response.rs fn error_response(&self) -> actix_web::HttpResponse { ErrorSwitch::<api_models::errors::types::ApiErrorResponse>::switch(self).error_response() }
{ "chunk": null, "crate": "hyperswitch_domain_models", "enum_name": null, "file_size": null, "for_type": null, "function_name": "error_response", "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_879766055057974385
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/errors/api_error_response.rs fn from(error: ApiErrorResponse) -> Self { Self { code: error.error_code(), message: error.error_message(), reason: None, status_code: match error { ApiErrorResponse::ExternalConnectorError { status_code, .. } => status_code, _ => 500, }, attempt_status: None, connector_transaction_id: None, network_advice_code: None, network_decline_code: None, network_error_message: None, connector_metadata: None, } }
{ "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_8269424740012943383
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payouts/payouts.rs fn from(payout_update: PayoutsUpdate) -> Self { match payout_update { PayoutsUpdate::Update { amount, destination_currency, source_currency, description, recurring, auto_fulfill, return_url, entity_type, metadata, profile_id, status, confirm, payout_type, address_id, customer_id, } => Self { amount: Some(amount), destination_currency: Some(destination_currency), source_currency: Some(source_currency), description, recurring: Some(recurring), auto_fulfill: Some(auto_fulfill), return_url, entity_type: Some(entity_type), metadata, profile_id, status, confirm, payout_type, address_id, customer_id, ..Default::default() }, PayoutsUpdate::PayoutMethodIdUpdate { payout_method_id } => Self { payout_method_id: Some(payout_method_id), ..Default::default() }, PayoutsUpdate::RecurringUpdate { recurring } => Self { recurring: Some(recurring), ..Default::default() }, PayoutsUpdate::AttemptCountUpdate { attempt_count } => Self { attempt_count: Some(attempt_count), ..Default::default() }, PayoutsUpdate::StatusUpdate { status } => Self { status: Some(status), ..Default::default() }, } }
{ "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_-7794243359741661463
clm
function
// hyperswitch/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs fn from(payout_update: PayoutAttemptUpdate) -> Self { match payout_update { PayoutAttemptUpdate::PayoutTokenUpdate { payout_token } => Self { payout_token: Some(payout_token), ..Default::default() }, PayoutAttemptUpdate::StatusUpdate { connector_payout_id, status, error_message, error_code, is_eligible, unified_code, unified_message, payout_connector_metadata, } => Self { connector_payout_id, status: Some(status), error_message, error_code, is_eligible, unified_code, unified_message, payout_connector_metadata, ..Default::default() }, PayoutAttemptUpdate::BusinessUpdate { business_country, business_label, address_id, customer_id, } => Self { business_country, business_label, address_id, customer_id, ..Default::default() }, PayoutAttemptUpdate::UpdateRouting { connector, routing_info, merchant_connector_id, } => Self { connector: Some(connector), routing_info, merchant_connector_id, ..Default::default() }, PayoutAttemptUpdate::AdditionalPayoutMethodDataUpdate { additional_payout_method_data, } => Self { additional_payout_method_data, ..Default::default() }, } }
{ "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_connectors_1200526048797536849
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/types.rs fn get_external_account_account_holder_type(&self) -> Result<String, Self::Error> { self.external_account_account_holder_type .clone() .ok_or_else(crate::utils::missing_field_err( "external_account_account_holder_type", )) }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_external_account_account_holder_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_connectors_7764910948367433443
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/default_implementations.rs fn get_flow_type( &self, _query_params: &str, _json_payload: Option<serde_json::Value>, _action: PaymentAction, ) -> CustomResult<CallConnectorAction, ConnectorError> { Ok(CallConnectorAction::Trigger) }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_flow_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_connectors_1106541760294215116
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs pub(crate) fn construct_not_supported_error_report( capture_method: enums::CaptureMethod, connector_name: &'static str, ) -> error_stack::Report<errors::ConnectorError> { errors::ConnectorError::NotSupported { message: capture_method.to_string(), connector: connector_name, } .into() }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "construct_not_supported_error_report", "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_connectors_5587059011977500777
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs pub(crate) fn to_currency_base_unit_with_zero_decimal_check( amount: i64, currency: enums::Currency, ) -> Result<String, error_stack::Report<errors::ConnectorError>> { currency .to_currency_base_unit_with_zero_decimal_check(amount) .change_context(errors::ConnectorError::RequestEncodingFailed) }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "to_currency_base_unit_with_zero_decimal_check", "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_connectors_-2778970090776409634
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs pub(crate) fn get_timestamp_in_milliseconds(datetime: &PrimitiveDateTime) -> i64 { let utc_datetime = datetime.assume_utc(); utc_datetime.unix_timestamp() * 1000 }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_timestamp_in_milliseconds", "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_connectors_4721637339030015306
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs pub(crate) fn get_amount_as_string( currency_unit: &api::CurrencyUnit, amount: i64, currency: enums::Currency, ) -> Result<String, error_stack::Report<errors::ConnectorError>> { let amount = match currency_unit { api::CurrencyUnit::Minor => amount.to_string(), api::CurrencyUnit::Base => to_currency_base_unit(amount, currency)?, }; Ok(amount) }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_amount_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_connectors_5092129398963370225
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs pub(crate) fn base64_decode(data: String) -> Result<Vec<u8>, Error> { BASE64_ENGINE .decode(data) .change_context(errors::ConnectorError::ResponseDeserializationFailed) }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "base64_decode", "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_connectors_-6798970654079709795
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs pub(crate) fn to_currency_base_unit( amount: i64, currency: enums::Currency, ) -> Result<String, error_stack::Report<errors::ConnectorError>> { currency .to_currency_base_unit(amount) .change_context(errors::ConnectorError::ParsingFailed) }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "to_currency_base_unit", "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_connectors_8845914548807721540
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs fn get_connector_error_type( &self, _error_code: String, _error_message: String, ) -> ConnectorErrorType { ConnectorErrorType::UnknownError }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_connector_error_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_connectors_3605738402438316761
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs pub(crate) fn get_error_code_error_message_based_on_priority( connector: impl ConnectorErrorTypeMapping, error_list: Vec<ErrorCodeAndMessage>, ) -> Option<ErrorCodeAndMessage> { let error_type_list = error_list .iter() .map(|error| { connector .get_connector_error_type(error.error_code.clone(), error.error_message.clone()) }) .collect::<Vec<ConnectorErrorType>>(); let mut error_zip_list = error_list .iter() .zip(error_type_list.iter()) .collect::<Vec<(&ErrorCodeAndMessage, &ConnectorErrorType)>>(); error_zip_list.sort_by_key(|&(_, error_type)| error_type); error_zip_list .first() .map(|&(error_code_message, _)| error_code_message) .cloned() }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_error_code_error_message_based_on_priority", "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_connectors_-3840831299160089936
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs fn get_connector_reference_id(&self) -> Option<String> { None }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_connector_reference_id", "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_connectors_324352095563208884
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs pub(crate) fn construct_captures_response_hashmap<T>( capture_sync_response_list: Vec<T>, ) -> CustomResult<HashMap<String, CaptureSyncResponse>, errors::ConnectorError> where T: MultipleCaptureSyncResponse, { let mut hashmap = HashMap::new(); for capture_sync_response in capture_sync_response_list { let connector_capture_id = capture_sync_response.get_connector_capture_id(); if capture_sync_response.is_capture_response() { hashmap.insert( connector_capture_id.clone(), CaptureSyncResponse::Success { resource_id: ResponseId::ConnectorTransactionId(connector_capture_id), status: capture_sync_response.get_capture_attempt_status(), connector_response_reference_id: capture_sync_response .get_connector_reference_id(), amount: capture_sync_response .get_amount_captured() .change_context(errors::ConnectorError::AmountConversionFailed) .attach_printable( "failed to convert back captured response amount to minor unit", )?, }, ); } } Ok(hashmap) }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "construct_captures_response_hashmap", "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_connectors_6653149355127852732
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs fn try_from(data: payment_method_data::GooglePayWalletData) -> Result<Self, Self::Error> { let tokenization_data = match data.tokenization_data { common_types::payments::GpayTokenizationData::Encrypted(encrypted_data) => { common_types::payments::GpayTokenizationData::Encrypted( common_types::payments::GpayEcryptedTokenizationData { token_type: encrypted_data.token_type, token: encrypted_data.token, }, ) } common_types::payments::GpayTokenizationData::Decrypted(_) => { return Err(common_utils::errors::ValidationError::InvalidValue { message: "Expected encrypted tokenization data, got decrypted".to_string(), }); } }; Ok(Self { pm_type: data.pm_type, description: data.description, info: GooglePayPaymentMethodInfo { card_network: data.info.card_network, card_details: data.info.card_details, assurance_details: data.info.assurance_details, card_funding_source: data.info.card_funding_source, }, tokenization_data, }) }
{ "chunk": null, "crate": "hyperswitch_connectors", "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_connectors_1373716712681818338
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs pub(crate) fn get_amount_as_f64( currency_unit: &api::CurrencyUnit, amount: i64, currency: enums::Currency, ) -> Result<f64, error_stack::Report<errors::ConnectorError>> { let amount = match currency_unit { api::CurrencyUnit::Base => to_currency_base_unit_asf64(amount, currency)?, api::CurrencyUnit::Minor => u32::try_from(amount) .change_context(errors::ConnectorError::ParsingFailed)? .into(), }; Ok(amount) }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_amount_as_f64", "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_connectors_5188718625304049519
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs pub(crate) fn to_currency_base_unit_asf64( amount: i64, currency: enums::Currency, ) -> Result<f64, error_stack::Report<errors::ConnectorError>> { currency .to_currency_base_unit_asf64(amount) .change_context(errors::ConnectorError::ParsingFailed) }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "to_currency_base_unit_asf64", "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_connectors_8807750879838805730
clm
function
// hyperswitch/crates/hyperswitch_connectors/src/utils.rs pub(crate) fn to_connector_meta_from_secret<T>( connector_meta: Option<Secret<Value>>, ) -> Result<T, Error> where T: serde::de::DeserializeOwned, { let connector_meta_secret = connector_meta.ok_or_else(missing_field_err("connector_meta_data"))?; let json = connector_meta_secret.expose(); json.parse_value(std::any::type_name::<T>()).switch() }
{ "chunk": null, "crate": "hyperswitch_connectors", "enum_name": null, "file_size": null, "for_type": null, "function_name": "to_connector_meta_from_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 }