id
stringlengths
11
116
type
stringclasses
1 value
granularity
stringclasses
4 values
content
stringlengths
16
477k
metadata
dict
fn_clm_hyperswitch_connectors_try_from_-3617604517156111351
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/mpgs/transformers // Implementation of RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> fn try_from( item: RefundsResponseRouterData<RSync, RefundResponse>, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: item.response.id.to_string(), refund_status: enums::RefundStatus::from(item.response.status), }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2661, "total_crates": null }
fn_clm_hyperswitch_connectors_from_-3617604517156111351
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/mpgs/transformers // Implementation of enums::RefundStatus for From<RefundStatus> fn from(item: RefundStatus) -> Self { match item { RefundStatus::Succeeded => Self::Success, RefundStatus::Failed => Self::Failure, RefundStatus::Processing => Self::Pending, //TODO: Review mapping } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_8172365369647723890
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/hyperwallet/transformers // Implementation of RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> fn try_from( item: RefundsResponseRouterData<RSync, RefundResponse>, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: item.response.id.to_string(), refund_status: enums::RefundStatus::from(item.response.status), }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2661, "total_crates": null }
fn_clm_hyperswitch_connectors_from_8172365369647723890
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/hyperwallet/transformers // Implementation of enums::RefundStatus for From<RefundStatus> fn from(item: RefundStatus) -> Self { match item { RefundStatus::Succeeded => Self::Success, RefundStatus::Failed => Self::Failure, RefundStatus::Processing => Self::Pending, //TODO: Review mapping } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-5992793861046149467
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/paytm/transformers // Implementation of RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> fn try_from( item: RefundsResponseRouterData<RSync, RefundResponse>, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: item.response.id.to_string(), refund_status: enums::RefundStatus::from(item.response.status), }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2661, "total_crates": null }
fn_clm_hyperswitch_connectors_from_-5992793861046149467
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/paytm/transformers // Implementation of enums::RefundStatus for From<RefundStatus> fn from(item: RefundStatus) -> Self { match item { RefundStatus::Succeeded => Self::Success, RefundStatus::Failed => Self::Failure, RefundStatus::Processing => Self::Pending, //TODO: Review mapping } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-800805324088406301
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/bambora/transformers // Implementation of types::RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> fn try_from( item: RefundsResponseRouterData<RSync, RefundResponse>, ) -> Result<Self, Self::Error> { let refund_status = if item.response.approved.as_str() == "1" { enums::RefundStatus::Success } else { enums::RefundStatus::Failure }; Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: item.response.id.to_string(), refund_status, }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2661, "total_crates": null }
fn_clm_hyperswitch_connectors_from_-800805324088406301
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/bambora/transformers // Implementation of enums::RefundStatus for From<RefundStatus> fn from(item: RefundStatus) -> Self { match item { RefundStatus::Succeeded => Self::Success, RefundStatus::Failed => Self::Failure, RefundStatus::Processing => Self::Pending, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_get_browser_info_-800805324088406301
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/bambora/transformers fn get_browser_info( item: &types::PaymentsAuthorizeRouterData, ) -> Result<Option<BamboraBrowserInfo>, error_stack::Report<errors::ConnectorError>> { if matches!(item.auth_type, enums::AuthenticationType::ThreeDs) { item.request .browser_info .as_ref() .map(|info| { Ok(BamboraBrowserInfo { accept_header: info.get_accept_header()?, java_enabled: info.get_java_enabled()?, language: info.get_language()?, screen_height: info.get_screen_height()?, screen_width: info.get_screen_width()?, color_depth: info.get_color_depth()?, user_agent: info.get_user_agent()?, time_zone: info.get_time_zone()?, javascript_enabled: info.get_java_script_enabled()?, }) }) .transpose() } else { Ok(None) } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 48, "total_crates": null }
fn_clm_hyperswitch_connectors_str_or_i32_-800805324088406301
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/bambora/transformers fn str_or_i32<'de, D>(deserializer: D) -> Result<String, D::Error> where D: Deserializer<'de>, { #[derive(Deserialize)] #[serde(untagged)] enum StrOrI32 { Str(String), I32(i32), } let value = StrOrI32::deserialize(deserializer)?; let res = match value { StrOrI32::Str(v) => v, StrOrI32::I32(v) => v.to_string(), }; Ok(res) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 4, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_1740011358662066977
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/custombilling/transformers // Implementation of RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> fn try_from( item: RefundsResponseRouterData<RSync, RefundResponse>, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: item.response.id.to_string(), refund_status: enums::RefundStatus::from(item.response.status), }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2661, "total_crates": null }
fn_clm_hyperswitch_connectors_from_1740011358662066977
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/custombilling/transformers // Implementation of enums::RefundStatus for From<RefundStatus> fn from(item: RefundStatus) -> Self { match item { RefundStatus::Succeeded => Self::Success, RefundStatus::Failed => Self::Failure, RefundStatus::Processing => Self::Pending, //TODO: Review mapping } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_7397138961467464228
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/gocardless/transformers // Implementation of GocardlessPaymentStatus for TryFrom<&WebhookAction> fn try_from(item: &WebhookAction) -> Result<Self, Self::Error> { match item { WebhookAction::PaymentsAction(action) => match action { PaymentsAction::CustomerApprovalGranted | PaymentsAction::Submitted => { Ok(Self::Submitted) } PaymentsAction::CustomerApprovalDenied => Ok(Self::CustomerApprovalDenied), PaymentsAction::LateFailureSettled => Ok(Self::Failed), PaymentsAction::Failed => Ok(Self::Failed), PaymentsAction::Cancelled => Ok(Self::Cancelled), PaymentsAction::Confirmed => Ok(Self::Confirmed), PaymentsAction::PaidOut => Ok(Self::PaidOut), PaymentsAction::SurchargeFeeDebited | PaymentsAction::ResubmissionRequired | PaymentsAction::Created => Err(errors::ConnectorError::WebhookEventTypeNotFound)?, }, WebhookAction::RefundsAction(_) | WebhookAction::MandatesAction(_) => { Err(errors::ConnectorError::WebhookEventTypeNotFound)? } } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2657, "total_crates": null }
fn_clm_hyperswitch_connectors_from_7397138961467464228
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/gocardless/transformers // Implementation of enums::AttemptStatus for From<GocardlessPaymentStatus> fn from(item: GocardlessPaymentStatus) -> Self { match item { GocardlessPaymentStatus::PendingCustomerApproval | GocardlessPaymentStatus::PendingSubmission | GocardlessPaymentStatus::Submitted => Self::Pending, GocardlessPaymentStatus::Confirmed | GocardlessPaymentStatus::PaidOut => Self::Charged, GocardlessPaymentStatus::Cancelled => Self::Voided, GocardlessPaymentStatus::CustomerApprovalDenied => Self::AuthenticationFailed, GocardlessPaymentStatus::Failed => Self::Failure, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_get_region_7397138961467464228
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/gocardless/transformers fn get_region( address_details: &AddressDetails, ) -> Result<Option<Secret<String>>, error_stack::Report<errors::ConnectorError>> { match address_details.country { Some(CountryAlpha2::US) => { let state = address_details.get_state()?.to_owned(); Ok(Some(Secret::new( UsStatesAbbreviation::foreign_try_from(state.expose())?.to_string(), ))) } _ => Ok(None), } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 12, "total_crates": null }
fn_clm_hyperswitch_connectors_get_ip_if_required_7397138961467464228
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/gocardless/transformers fn get_ip_if_required( bank_debit_data: &BankDebitData, item: &types::SetupMandateRouterData, ) -> Result<Option<Secret<String, IpAddress>>, error_stack::Report<errors::ConnectorError>> { let ip_address = item.request.get_browser_info()?.get_ip_address()?; match bank_debit_data { BankDebitData::AchBankDebit { .. } => Ok(Some(ip_address)), BankDebitData::SepaBankDebit { .. } | BankDebitData::SepaGuarenteedBankDebit { .. } | BankDebitData::BecsBankDebit { .. } | BankDebitData::BacsBankDebit { .. } => Ok(None), } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 4, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-7585120007165972895
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/netcetera/transformers // Implementation of NetceteraAuthenticationRequest for TryFrom<&NetceteraRouterData<&ConnectorAuthenticationRouterData>> fn try_from( item: &NetceteraRouterData<&ConnectorAuthenticationRouterData>, ) -> Result<Self, Self::Error> { let now = common_utils::date_time::now(); let request = item.router_data.request.clone(); let pre_authn_data = request.pre_authentication_data.clone(); let ip_address = request .browser_details .as_ref() .and_then(|browser| browser.ip_address); let three_ds_requestor = netcetera_types::ThreeDSRequestor::new( ip_address, item.router_data.psd2_sca_exemption_type, item.router_data.request.force_3ds_challenge, item.router_data .request .pre_authentication_data .message_version .clone(), ); let card = get_card_details(request.payment_method_data, "netcetera")?; let is_cobadged_card = card .card_number .clone() .is_cobadged_card() .change_context(ConnectorError::RequestEncodingFailed) .attach_printable("error while checking is_cobadged_card")?; let cardholder_account = netcetera_types::CardholderAccount { acct_type: None, card_expiry_date: Some(card.get_expiry_date_as_yymm()?), acct_info: None, acct_number: card.card_number, scheme_id: card .card_network .clone() .and_then(|card_network| { is_cobadged_card.then_some(netcetera_types::SchemeId::try_from(card_network)) }) .transpose()?, acct_id: None, pay_token_ind: None, pay_token_info: None, card_security_code: Some(card.card_cvc), }; let currency = request .currency .get_required_value("currency") .change_context(ConnectorError::MissingRequiredField { field_name: "currency", })?; let purchase = netcetera_types::Purchase { purchase_instal_data: None, merchant_risk_indicator: None, purchase_amount: request.amount, purchase_currency: currency.iso_4217().to_string(), purchase_exponent: currency.number_of_digits_after_decimal_point(), purchase_date: Some( common_utils::date_time::format_date( now, common_utils::date_time::DateFormat::YYYYMMDDHHmmss, ) .change_context( ConnectorError::RequestEncodingFailedWithReason( "Failed to format Date".to_string(), ), )?, ), recurring_expiry: None, recurring_frequency: None, // 01 -> Goods and Services, hardcoding this as we serve this usecase only for now trans_type: Some("01".to_string()), recurring_amount: None, recurring_currency: None, recurring_exponent: None, recurring_date: None, amount_ind: None, frequency_ind: None, }; let acquirer_details = netcetera_types::AcquirerData { acquirer_bin: request.pre_authentication_data.acquirer_bin, acquirer_merchant_id: request.pre_authentication_data.acquirer_merchant_id, acquirer_country_code: request.pre_authentication_data.acquirer_country_code, }; let connector_meta_data: NetceteraMetaData = item .router_data .connector_meta_data .clone() .parse_value("NetceteraMetaData") .change_context(ConnectorError::RequestEncodingFailed)?; let merchant_data = netcetera_types::MerchantData { merchant_configuration_id: connector_meta_data.merchant_configuration_id, mcc: connector_meta_data.mcc, merchant_country_code: connector_meta_data.merchant_country_code, merchant_name: connector_meta_data.merchant_name, notification_url: request.return_url.clone(), three_ds_requestor_id: connector_meta_data.three_ds_requestor_id, three_ds_requestor_name: connector_meta_data.three_ds_requestor_name, white_list_status: None, trust_list_status: None, seller_info: None, results_response_notification_url: Some(request.webhook_url), }; let browser_information = match request.device_channel { api_models::payments::DeviceChannel::Browser => { request.browser_details.map(netcetera_types::Browser::from) } api_models::payments::DeviceChannel::App => None, }; let sdk_information = match request.device_channel { api_models::payments::DeviceChannel::App => { request.sdk_information.map(netcetera_types::Sdk::from) } api_models::payments::DeviceChannel::Browser => None, }; let device_render_options = match request.device_channel { api_models::payments::DeviceChannel::App => { Some(netcetera_types::DeviceRenderingOptionsSupported { // hard-coded until core provides these values. sdk_interface: netcetera_types::SdkInterface::Both, sdk_ui_type: vec![ netcetera_types::SdkUiType::Text, netcetera_types::SdkUiType::SingleSelect, netcetera_types::SdkUiType::MultiSelect, netcetera_types::SdkUiType::Oob, netcetera_types::SdkUiType::HtmlOther, ], }) } api_models::payments::DeviceChannel::Browser => None, }; Ok(Self { preferred_protocol_version: Some(pre_authn_data.message_version), // For Device channel App, we should enforce the preferred protocol version enforce_preferred_protocol_version: Some(matches!( request.device_channel, api_models::payments::DeviceChannel::App )), device_channel: netcetera_types::NetceteraDeviceChannel::from(request.device_channel), message_category: netcetera_types::NetceteraMessageCategory::from( request.message_category, ), three_ds_comp_ind: Some(netcetera_types::ThreeDSMethodCompletionIndicator::from( request.threeds_method_comp_ind, )), three_ds_method_id: None, three_ds_requestor: Some(three_ds_requestor), three_ds_server_trans_id: pre_authn_data.threeds_server_transaction_id, three_ds_requestor_url: Some(request.three_ds_requestor_url), cardholder_account, cardholder: Some(netcetera_types::Cardholder::try_from(( request.billing_address, request.shipping_address, ))?), purchase: Some(purchase), acquirer: Some(acquirer_details), merchant: Some(merchant_data), broad_info: None, device_render_options, message_extension: None, challenge_message_extension: None, browser_information, three_ri_ind: None, sdk_information, device: None, multi_transaction: None, device_id: None, user_id: None, payee_origin: None, }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2733, "total_crates": null }
fn_clm_hyperswitch_connectors_get_three_ds_method_url_-7585120007165972895
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/netcetera/transformers // Inherent implementation for CardRange pub fn get_three_ds_method_url(&self) -> Option<String> { self.acs_protocol_versions .iter() .find(|acs_protocol_version| { acs_protocol_version.version == self.highest_common_supported_version }) .and_then(|acs_version| acs_version.three_ds_method_url.clone()) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 26, "total_crates": null }
fn_clm_hyperswitch_connectors_get_card_range_if_available_-7585120007165972895
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/netcetera/transformers // Inherent implementation for NetceteraPreAuthenticationResponseData pub fn get_card_range_if_available(&self) -> Option<CardRange> { let card_range = self .card_ranges .iter() .max_by_key(|card_range| &card_range.highest_common_supported_version); card_range.cloned() }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 24, "total_crates": null }
fn_clm_hyperswitch_connectors_new_2679292992101742566
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/netcetera/netcetera_types // Inherent implementation for ThreeDSRequestor pub fn new( app_ip: Option<std::net::IpAddr>, psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>, force_3ds_challenge: bool, message_version: SemanticVersion, ) -> Self { // if sca exemption is provided, we need to set the challenge indicator to NoChallengeRequestedTransactionalRiskAnalysis let three_ds_requestor_challenge_ind = if force_3ds_challenge { Some(SingleOrListElement::get_version_checked( message_version, ThreeDSRequestorChallengeIndicator::ChallengeRequestedMandate, )) } else if let Some(common_enums::ScaExemptionType::TransactionRiskAnalysis) = psd2_sca_exemption_type { Some(SingleOrListElement::get_version_checked( message_version, ThreeDSRequestorChallengeIndicator::NoChallengeRequestedTransactionalRiskAnalysis, )) } else { None }; Self { three_ds_requestor_authentication_ind: ThreeDSRequestorAuthenticationIndicator::Payment, three_ds_requestor_authentication_info: None, three_ds_requestor_challenge_ind, three_ds_requestor_prior_authentication_info: None, three_ds_requestor_dec_req_ind: None, three_ds_requestor_dec_max_time: None, app_ip, three_ds_requestor_spc_support: None, spc_incomp_ind: None, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14467, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_2679292992101742566
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/netcetera/netcetera_types // Implementation of SchemeId for TryFrom<common_enums::CardNetwork> fn try_from(network: common_enums::CardNetwork) -> Result<Self, Self::Error> { match network { common_enums::CardNetwork::Visa => Ok(Self::Visa), common_enums::CardNetwork::Mastercard => Ok(Self::Mastercard), common_enums::CardNetwork::JCB => Ok(Self::Jcb), common_enums::CardNetwork::AmericanExpress => Ok(Self::AmericanExpress), common_enums::CardNetwork::DinersClub => Ok(Self::Diners), common_enums::CardNetwork::CartesBancaires => Ok(Self::CartesBancaires), common_enums::CardNetwork::UnionPay => Ok(Self::UnionPay), _ => Err(ConnectorError::RequestEncodingFailedWithReason( "Invalid card network".to_string(), ))?, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2661, "total_crates": null }
fn_clm_hyperswitch_connectors_from_2679292992101742566
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/netcetera/netcetera_types // Implementation of ThreeDSMethodCompletionIndicator for From<api_models::payments::ThreeDsCompletionIndicator> fn from(value: api_models::payments::ThreeDsCompletionIndicator) -> Self { match value { api_models::payments::ThreeDsCompletionIndicator::Success => Self::Y, api_models::payments::ThreeDsCompletionIndicator::Failure => Self::N, api_models::payments::ThreeDsCompletionIndicator::NotAvailable => Self::U, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_ (bil_2679292992101742566
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/netcetera/netcetera_types // Implementation of type Er for hyperswitch_domain_models::address::Address, Option<hyperswitch_domain_models::address::Address>, )> for Cardholde (billing_address, shipping_address): ( hyperswitch_domain_models::address::Address, Option<hyperswitch_domain_models::address::Address>, ), ) -> Result<Self, Self::Error> { Ok(Self { addr_match: None, bill_addr_city: billing_address .address .as_ref() .and_then(|add| add.city.clone()), bill_addr_country: billing_address.address.as_ref().and_then(|add| { add.country.map(|country| { common_enums::Country::from_alpha2(country) .to_numeric() .to_string() }) }), bill_addr_line1: billing_address .address .as_ref() .and_then(|add| add.line1.clone()), bill_addr_line2: billing_address .address .as_ref() .and_then(|add| add.line2.clone()), bill_addr_line3: billing_address .address .as_ref() .and_then(|add| add.line3.clone()), bill_addr_post_code: billing_address .address .as_ref() .and_then(|add| add.zip.clone()), bill_addr_state: billing_address .address .as_ref() .and_then(|add| add.to_state_code_as_optional().transpose()) .transpose()?, email: billing_address.email, home_phone: billing_address .phone .clone() .map(PhoneNumber::try_from) .transpose()?, mobile_phone: billing_address .phone .clone() .map(PhoneNumber::try_from) .transpose()?, work_phone: billing_address .phone .clone() .map(PhoneNumber::try_from) .transpose()?, cardholder_name: billing_address.address.and_then(|address| { address .get_optional_full_name() .map(|name| masking::Secret::new(unidecode(&name.expose()))) }), ship_addr_city: shipping_address .as_ref() .and_then(|shipping_add| shipping_add.address.as_ref()) .and_then(|add| add.city.clone()), ship_addr_country: shipping_address .as_ref() .and_then(|shipping_add| shipping_add.address.as_ref()) .and_then(|add| { add.country.map(|country| { common_enums::Country::from_alpha2(country) .to_numeric() .to_string() }) }), ship_addr_line1: shipping_address .as_ref() .and_then(|shipping_add| shipping_add.address.as_ref()) .and_then(|add| add.line1.clone()), ship_addr_line2: shipping_address .as_ref() .and_then(|shipping_add| shipping_add.address.as_ref()) .and_then(|add| add.line2.clone()), ship_addr_line3: shipping_address .as_ref() .and_then(|shipping_add| shipping_add.address.as_ref()) .and_then(|add| add.line3.clone()), ship_addr_post_code: shipping_address .as_ref() .and_then(|shipping_add| shipping_add.address.as_ref()) .and_then(|add| add.zip.clone()), ship_addr_state: shipping_address .as_ref() .and_then(|shipping_add| shipping_add.address.as_ref()) .and_then(|add| add.to_state_code_as_optional().transpose()) .transpose()?, tax_id: None, }) } } #[derive(S
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 172, "total_crates": null }
fn_clm_hyperswitch_connectors_rInf_2679292992101742566
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/netcetera/netcetera_types // Implementation of rom(val for ation> for Browser { wserInformation) -> Self { Self { browser_accept_header: value.accept_header, browser_ip: value .ip_address .map(|ip| masking::Secret::new(ip.to_string())), browser_java_enabled: value.java_enabled, browser_language: value.language, browser_color_depth: value.color_depth.map(|cd| cd.to_string()), browser_screen_height: value.screen_height, browser_screen_width: value.screen_width, browser_tz: value.time_zone, browser_user_agent: value.user_agent, challenge_window_size: Some(ChallengeWindowSizeEnum::FullScreen), browser_javascript_enabled: value.java_script_enabled, // Default to ["en"] locale if accept_language is not provided accept_language: value .accept_language .map(get_list_of_accept_languages) .or(Some(vec!["en".to_string()])), } } } #[derive(Seria
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 26, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-4355251612681710148
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/vgs/transformers // Implementation of RouterData<ExternalVaultRetrieveFlow, VaultRequestData, VaultResponseData> for TryFrom< ResponseRouterData< ExternalVaultRetrieveFlow, VgsRetrieveResponse, VaultRequestData, VaultResponseData, >, > fn try_from( item: ResponseRouterData< ExternalVaultRetrieveFlow, VgsRetrieveResponse, VaultRequestData, VaultResponseData, >, ) -> Result<Self, Self::Error> { let token_response_item = item .response .data .first() .ok_or(errors::ConnectorError::ResponseHandlingFailed)?; let card_detail: api_models::payment_methods::CardDetail = token_response_item .value .clone() .expose() .parse_struct("CardDetail") .change_context(errors::ConnectorError::ParsingFailed)?; Ok(Self { status: common_enums::AttemptStatus::Started, response: Ok(VaultResponseData::ExternalVaultRetrieveResponse { vault_data: PaymentMethodVaultingData::Card(card_detail), }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2671, "total_crates": null }
fn_clm_hyperswitch_connectors_from_-4355251612681710148
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/vgs/transformers // Implementation of VgsRouterData<T> for From<(StringMinorUnit, T)> fn from((amount, item): (StringMinorUnit, T)) -> Self { Self { amount, router_data: item, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-1790975345476444787
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/ebanx/transformers // Implementation of PayoutsRouterData<F> for TryFrom<PayoutsResponseRouterData<F, EbanxCancelResponse>> fn try_from( item: PayoutsResponseRouterData<F, EbanxCancelResponse>, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(PayoutsResponseData { status: Some(PayoutStatus::from(item.response.status)), connector_payout_id: item.data.request.connector_payout_id.clone(), payout_eligible: None, should_add_next_step_to_process_tracker: false, error_code: None, error_message: None, payout_connector_metadata: None, }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2661, "total_crates": null }
fn_clm_hyperswitch_connectors_from_-1790975345476444787
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/ebanx/transformers // Implementation of PayoutStatus for From<EbanxCancelStatus> fn from(item: EbanxCancelStatus) -> Self { match item { EbanxCancelStatus::Success => Self::Cancelled, EbanxCancelStatus::ApiError | EbanxCancelStatus::AuthenticationError | EbanxCancelStatus::InvalidRequestError | EbanxCancelStatus::RequestError => Self::Failed, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-1134394307801330947
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/signifyd/transformers/auth // Implementation of SignifydAuthType for TryFrom<&ConnectorAuthType> fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> { match auth_type { ConnectorAuthType::HeaderKey { api_key } => Ok(Self { api_key: api_key.to_owned(), }), _ => Err(ConnectorError::FailedToObtainAuthType.into()), } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2661, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-6038759364228259021
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/signifyd/transformers/api // Implementation of SignifydPaymentsRecordReturnRequest for TryFrom<&FrmRecordReturnRouterData> fn try_from(item: &FrmRecordReturnRouterData) -> Result<Self, Self::Error> { let currency = item.request.get_currency()?; let refund = SignifydRefund { method: item.request.refund_method.clone(), amount: item.request.amount.to_string(), currency, }; Ok(Self { return_id: uuid::Uuid::new_v4().to_string(), refund_transaction_id: item.request.refund_transaction_id.clone(), refund, order_id: item.attempt_id.clone(), }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2671, "total_crates": null }
fn_clm_hyperswitch_connectors_from_-6038759364228259021
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/signifyd/transformers/api // Implementation of IncomingWebhookEvent for From<ReviewDisposition> fn from(value: ReviewDisposition) -> Self { match value { ReviewDisposition::Fraudulent => Self::FrmRejected, ReviewDisposition::Good => Self::FrmApproved, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_get_signifyd_fulfillments_from_frm_fulfillment_request_-6038759364228259021
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/signifyd/transformers/api pub(crate) fn get_signifyd_fulfillments_from_frm_fulfillment_request( fulfillment_req: &FrmFulfillmentRequest, ) -> Vec<Fulfillments> { fulfillment_req .fulfillments .iter() .map(|fulfillment| Fulfillments { shipment_id: fulfillment.shipment_id.clone(), products: fulfillment .products .as_ref() .map(|products| products.iter().map(|p| Product::from(p.clone())).collect()), destination: Destination::from(fulfillment.destination.clone()), tracking_urls: fulfillment_req.tracking_urls.clone(), tracking_numbers: fulfillment_req.tracking_numbers.clone(), fulfillment_method: fulfillment_req.fulfillment_method.clone(), carrier: fulfillment_req.carrier.clone(), shipment_status: fulfillment_req.shipment_status.clone(), shipped_at: fulfillment_req.shipped_at.clone(), }) .collect() }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 48, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_8014478438432946168
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/paybox/transformers // Implementation of PayboxAuthType for TryFrom<&ConnectorAuthType> fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> { if let ConnectorAuthType::MultiAuthKey { api_key, key1, api_secret, key2, } = auth_type { Ok(Self { site: api_key.to_owned(), rang: key1.to_owned(), cle: api_secret.to_owned(), merchant_id: key2.to_owned(), }) } else { Err(errors::ConnectorError::FailedToObtainAuthType)? } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2665, "total_crates": null }
fn_clm_hyperswitch_connectors_from_8014478438432946168
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/paybox/transformers // Implementation of PayboxRouterData<T> for From<(MinorUnit, T)> fn from((amount, item): (MinorUnit, T)) -> Self { Self { amount, router_data: item, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_rom( _8014478438432946168
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/paybox/transformers // Implementation of tePaymentRequest { for om<( &PayboxRouterData<&types::PaymentsAuthorizeRouterData>, CardMandateInfo, )> for y_from( (item, card_mandate_info): ( &PayboxRouterData<&types::PaymentsAuthorizeRouterData>, CardMandateInfo, ), ) -> Result<Self, Self::Error> { let auth_data: PayboxAuthType = PayboxAuthType::try_from(&item.router_data.connector_auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; let transaction_type = match item.router_data.request.capture_method { Some(enums::CaptureMethod::Automatic) | None | Some(enums::CaptureMethod::SequentialAutomatic) => { Ok(MANDATE_AUTH_AND_CAPTURE_ONLY.to_string()) } Some(enums::CaptureMethod::Manual) => Ok(MANDATE_AUTH_ONLY.to_string()), _ => Err(errors::ConnectorError::CaptureMethodNotSupported), }?; let currency = enums::Currency::iso_4217(item.router_data.request.currency).to_string(); let format_time = common_utils::date_time::format_date( common_utils::date_time::now(), DateFormat::DDMMYYYYHHmmss, ) .change_context(errors::ConnectorError::RequestEncodingFailed)?; Ok(Self { date: format_time.clone(), transaction_type, paybox_request_number: get_paybox_request_number()?, amount: item.router_data.request.minor_amount, description_reference: item.router_data.connector_request_reference_id.clone(), version: VERSION_PAYBOX.to_string(), currency, activity: RECURRING_ORIGIN.to_string(), site: auth_data.site, rank: auth_data.rang, key: auth_data.cle, customer_id: Secret::new( item.router_data .request .get_connector_mandate_request_reference_id()?, ), carrier_id: Secret::new(item.router_data.request.get_connector_mandate_id()?), cc_exp_date: get_card_expiry_month_year_2_digit( card_mandate_info.card_exp_month.clone(), card_mandate_info.card_exp_year.clone(), )?, }) } } f
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 58, "total_crates": null }
fn_clm_hyperswitch_connectors_parse_paybox_response_8014478438432946168
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/paybox/transformers pub fn parse_paybox_response( query_bytes: Bytes, is_three_ds: bool, ) -> CustomResult<PayboxResponse, errors::ConnectorError> { let (cow, _, _) = encoding_rs::ISO_8859_15.decode(&query_bytes); let response_str = cow.as_ref().trim(); if utils::is_html_response(response_str) && is_three_ds { let response = response_str.to_string(); return Ok(if response.contains("Erreur 201") { PayboxResponse::Error(response) } else { PayboxResponse::ThreeDs(response.into()) }); } serde_qs::from_str::<TransactionResponse>(response_str) .map(PayboxResponse::NonThreeDs) .change_context(errors::ConnectorError::ParsingFailed) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 32, "total_crates": null }
fn_clm_hyperswitch_connectors_parse_url_encoded_to_struct_8014478438432946168
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/paybox/transformers pub fn parse_url_encoded_to_struct<T: DeserializeOwned>( query_bytes: Bytes, ) -> CustomResult<T, errors::ConnectorError> { let (cow, _, _) = encoding_rs::ISO_8859_15.decode(&query_bytes); serde_qs::from_str::<T>(cow.as_ref()).change_context(errors::ConnectorError::ParsingFailed) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 25, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-9003432441930126450
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/flexiti/transformers // Implementation of RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> fn try_from( item: RefundsResponseRouterData<RSync, RefundResponse>, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: item.response.id.to_string(), refund_status: enums::RefundStatus::from(item.response.status), }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2661, "total_crates": null }
fn_clm_hyperswitch_connectors_from_-9003432441930126450
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/flexiti/transformers // Implementation of enums::RefundStatus for From<RefundStatus> fn from(item: RefundStatus) -> Self { match item { RefundStatus::Succeeded => Self::Success, RefundStatus::Failed => Self::Failure, RefundStatus::Processing => Self::Pending, //TODO: Review mapping } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-8332627886813769219
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/mifinity/transformers // Implementation of RouterData<F, T, PaymentsResponseData> for TryFrom<ResponseRouterData<F, MifinityPsyncResponse, T, PaymentsResponseData>> fn try_from( item: ResponseRouterData<F, MifinityPsyncResponse, T, PaymentsResponseData>, ) -> Result<Self, Self::Error> { let payload = item.response.payload.first(); match payload { Some(payload) => { let status = payload.to_owned().status.clone(); let payment_response = payload.payment_response.clone(); match payment_response { Some(payment_response) => { let transaction_reference = payment_response.transaction_reference.clone(); Ok(Self { status: enums::AttemptStatus::from(status), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId( transaction_reference, ), redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, charges: None, }), ..item.data }) } None => Ok(Self { status: enums::AttemptStatus::from(status), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::NoResponseId, redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, charges: None, }), ..item.data }), } } None => Ok(Self { status: item.data.status, response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::NoResponseId, redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, charges: None, }), ..item.data }), } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2685, "total_crates": null }
fn_clm_hyperswitch_connectors_from_-8332627886813769219
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/mifinity/transformers // Implementation of enums::AttemptStatus for From<MifinityPaymentStatus> fn from(item: MifinityPaymentStatus) -> Self { match item { MifinityPaymentStatus::Successful => Self::Charged, MifinityPaymentStatus::Failed => Self::Failure, MifinityPaymentStatus::NotCompleted => Self::AuthenticationPending, MifinityPaymentStatus::Pending => Self::Pending, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-6342451164505952825
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/stripebilling/transformers // Implementation of recovery_router_data_types::InvoiceRecordBackRouterData for TryFrom< ResponseRouterData< recovery_router_flows::InvoiceRecordBack, StripebillingRecordBackResponse, recovery_request_types::InvoiceRecordBackRequest, recovery_response_types::InvoiceRecordBackResponse, >, > fn try_from( item: ResponseRouterData< recovery_router_flows::InvoiceRecordBack, StripebillingRecordBackResponse, recovery_request_types::InvoiceRecordBackRequest, recovery_response_types::InvoiceRecordBackResponse, >, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(recovery_response_types::InvoiceRecordBackResponse { merchant_reference_id: id_type::PaymentReferenceId::from_str( item.response.id.as_str(), ) .change_context(errors::ConnectorError::MissingRequiredField { field_name: "invoice_id in the response", })?, }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2663, "total_crates": null }
fn_clm_hyperswitch_connectors_from_-6342451164505952825
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/stripebilling/transformers // Implementation of enums::CardNetwork for From<StripebillingCardNetwork> fn from(item: StripebillingCardNetwork) -> Self { match item { StripebillingCardNetwork::Visa => Self::Visa, StripebillingCardNetwork::Mastercard => Self::Mastercard, StripebillingCardNetwork::AmericanExpress => Self::AmericanExpress, StripebillingCardNetwork::JCB => Self::JCB, StripebillingCardNetwork::DinersClub => Self::DinersClub, StripebillingCardNetwork::Discover => Self::Discover, StripebillingCardNetwork::CartesBancaires => Self::CartesBancaires, StripebillingCardNetwork::UnionPay => Self::UnionPay, StripebillingCardNetwork::Interac => Self::Interac, StripebillingCardNetwork::RuPay => Self::RuPay, StripebillingCardNetwork::Maestro => Self::Maestro, StripebillingCardNetwork::Star => Self::Star, StripebillingCardNetwork::Pulse => Self::Pulse, StripebillingCardNetwork::Accel => Self::Accel, StripebillingCardNetwork::Nyce => Self::Nyce, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_get_webhook_object_from_body_-6342451164505952825
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/stripebilling/transformers // Inherent implementation for StripebillingWebhookBody pub fn get_webhook_object_from_body(body: &[u8]) -> CustomResult<Self, errors::ConnectorError> { let webhook_body: Self = body .parse_struct::<Self>("StripebillingWebhookBody") .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(webhook_body) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 140, "total_crates": null }
fn_clm_hyperswitch_connectors_get_invoice_webhook_data_from_body_-6342451164505952825
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/stripebilling/transformers // Inherent implementation for StripebillingInvoiceBody pub fn get_invoice_webhook_data_from_body( body: &[u8], ) -> CustomResult<Self, errors::ConnectorError> { let webhook_body = body .parse_struct::<Self>("StripebillingInvoiceBody") .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(webhook_body) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 41, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-8879378153175344630
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/paysafe/transformers // Implementation of RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> fn try_from( item: RefundsResponseRouterData<RSync, RefundResponse>, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: item.response.id.to_string(), refund_status: enums::RefundStatus::from(item.response.status), }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2661, "total_crates": null }
fn_clm_hyperswitch_connectors_from_-8879378153175344630
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/paysafe/transformers // Implementation of enums::RefundStatus for From<RefundStatus> fn from(item: RefundStatus) -> Self { match item { RefundStatus::Received | RefundStatus::Completed => Self::Success, RefundStatus::Failed | RefundStatus::Cancelled | RefundStatus::Expired => Self::Failure, RefundStatus::Pending | RefundStatus::Initiated => Self::Pending, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_get_applepay_encrypt_account_id_-8879378153175344630
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/paysafe/transformers // Inherent implementation for PaysafePaymentMethodDetails pub fn get_applepay_encrypt_account_id( &self, currency: Currency, ) -> Result<Secret<String>, errors::ConnectorError> { self.apple_pay .as_ref() .and_then(|apple_pay| apple_pay.get(&currency)) .and_then(|flow| flow.encrypt.clone()) .ok_or_else(|| errors::ConnectorError::InvalidConnectorConfig { config: "Missing ApplePay encrypt account_id", }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 30, "total_crates": null }
fn_clm_hyperswitch_connectors_get_applepay_decrypt_account_id_-8879378153175344630
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/paysafe/transformers // Inherent implementation for PaysafePaymentMethodDetails pub fn get_applepay_decrypt_account_id( &self, currency: Currency, ) -> Result<Secret<String>, errors::ConnectorError> { self.apple_pay .as_ref() .and_then(|apple_pay| apple_pay.get(&currency)) .and_then(|flow| flow.decrypt.clone()) .ok_or_else(|| errors::ConnectorError::InvalidConnectorConfig { config: "Missing ApplePay decrypt account_id", }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 30, "total_crates": null }
fn_clm_hyperswitch_connectors_get_no_three_ds_account_id_-8879378153175344630
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/paysafe/transformers // Inherent implementation for PaysafePaymentMethodDetails pub fn get_no_three_ds_account_id( &self, currency: Currency, ) -> Result<Secret<String>, errors::ConnectorError> { self.card .as_ref() .and_then(|cards| cards.get(&currency)) .and_then(|card| card.no_three_ds.clone()) .ok_or(errors::ConnectorError::InvalidConnectorConfig { config: "Missing no_3ds account_id", }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 30, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-202238323222819579
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/multisafepay/transformers // Implementation of types::RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, MultisafepayRefundResponse>> fn try_from( item: RefundsResponseRouterData<RSync, MultisafepayRefundResponse>, ) -> Result<Self, Self::Error> { match item.response { MultisafepayRefundResponse::RefundResponse(refund_data) => { let refund_status = if refund_data.success { RefundStatus::Succeeded } else { RefundStatus::Failed }; Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: refund_data.data.refund_id.to_string(), refund_status: enums::RefundStatus::from(refund_status), }), ..item.data }) } MultisafepayRefundResponse::ErrorResponse(error_response) => Ok(Self { response: Err(populate_error_reason( Some(error_response.error_code.to_string()), Some(error_response.error_info.clone()), Some(error_response.error_info), item.http_code, None, None, )), ..item.data }), } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2667, "total_crates": null }
fn_clm_hyperswitch_connectors_from_-202238323222819579
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/multisafepay/transformers // Implementation of Option<AttemptStatus> for From<MultisafepayErrorResponse> fn from(error_data: MultisafepayErrorResponse) -> Self { match error_data.error_code { 10001 // InvalidAmount | 1002 // InvalidCurrency | 1003 // InvalidAccountID | 1004 // InvalidSiteID | 1005 // InvalidSecurityCode | 1006 // InvalidTransactionID | 1007 // InvalidIPAddress | 1008 // InvalidDescription | 1010 // InvalidVariable | 1011 // InvalidCustomerAccountID | 1012 // InvalidCustomerSecurityCode | 1013 // InvalidSignature | 1015 //UnknownAccountID | 1016 // MissingData | 1018 // InvalidCountryCode | 1025 // MultisafepayErrorCodes::IncorrectCustomerIPAddress | 1026 // MultisafepayErrorCodes::MultipleCurrenciesInCart | 1027 // MultisafepayErrorCodes::CartCurrencyDifferentToOrderCurrency | 1028 // IncorrectCustomTaxRate | 1029 // IncorrectItemTaxRate | 1030 // IncorrectItemCurrency | 1031 // IncorrectItemPrice | 1035 // InvalidSignatureRefund | 1036 // InvalidIdealIssuerID | 5001 // CartDataNotValidated | 1032 // InvalidAPIKey => { Some(AttemptStatus::AuthenticationFailed) } 1034 // CannotRefundTransaction | 1022 // CannotInitiateTransaction | 1024 //TransactionDeclined => Some(AttemptStatus::Failure), 1017 // InsufficientFunds => Some(AttemptStatus::AuthorizationFailed), _ => None, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_populate_error_reason_-202238323222819579
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/multisafepay/transformers pub fn populate_error_reason( code: Option<String>, message: Option<String>, reason: Option<String>, http_code: u16, attempt_status: Option<AttemptStatus>, connector_transaction_id: Option<String>, ) -> ErrorResponse { ErrorResponse { code: code.unwrap_or(NO_ERROR_CODE.to_string()), message: message.clone().unwrap_or(NO_ERROR_MESSAGE.to_string()), reason, status_code: http_code, attempt_status, connector_transaction_id, network_advice_code: None, network_decline_code: None, network_error_message: None, connector_metadata: None, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 26, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_1244530845785343950
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/payeezy/transformers // Implementation of RefundsRouterData<Execute> for TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> fn try_from( item: RefundsResponseRouterData<Execute, RefundResponse>, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: item.response.transaction_id, refund_status: enums::RefundStatus::from(item.response.transaction_status), }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2659, "total_crates": null }
fn_clm_hyperswitch_connectors_from_1244530845785343950
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/payeezy/transformers // Implementation of enums::RefundStatus for From<RefundStatus> fn from(item: RefundStatus) -> Self { match item { RefundStatus::Approved => Self::Success, RefundStatus::Declined => Self::Failure, RefundStatus::NotProcessed => Self::Pending, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_get_payment_method_data_1244530845785343950
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/payeezy/transformers fn get_payment_method_data( item: &PayeezyRouterData<&PaymentsAuthorizeRouterData>, ) -> Result<PayeezyPaymentMethod, error_stack::Report<ConnectorError>> { match item.router_data.request.payment_method_data { PaymentMethodData::Card(ref card) => { let card_type = PayeezyCardType::try_from(card.get_card_issuer()?)?; let payeezy_card = PayeezyCard { card_type, cardholder_name: item .router_data .get_optional_billing_full_name() .unwrap_or(Secret::new("".to_string())), card_number: card.card_number.clone(), exp_date: card.get_card_expiry_month_year_2_digit_with_delimiter("".to_string())?, cvv: card.card_cvc.clone(), }; Ok(PayeezyPaymentMethod::PayeezyCard(payeezy_card)) } PaymentMethodData::CardRedirect(_) | PaymentMethodData::Wallet(_) | PaymentMethodData::PayLater(_) | PaymentMethodData::BankRedirect(_) | PaymentMethodData::BankDebit(_) | PaymentMethodData::BankTransfer(_) | PaymentMethodData::Crypto(_) | PaymentMethodData::MandatePayment | PaymentMethodData::Reward | PaymentMethodData::RealTimePayment(_) | PaymentMethodData::MobilePayment(_) | PaymentMethodData::Upi(_) | PaymentMethodData::Voucher(_) | PaymentMethodData::GiftCard(_) | PaymentMethodData::OpenBanking(_) | PaymentMethodData::CardToken(_) | PaymentMethodData::NetworkToken(_) | PaymentMethodData::CardDetailsForNetworkTransactionId(_) => { Err(ConnectorError::NotImplemented( get_unimplemented_payment_method_error_message("Payeezy"), ))? } } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 110, "total_crates": null }
fn_clm_hyperswitch_connectors_get_transaction_type_and_stored_creds_1244530845785343950
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/payeezy/transformers fn get_transaction_type_and_stored_creds( item: &PaymentsAuthorizeRouterData, ) -> Result<(PayeezyTransactionType, Option<StoredCredentials>), error_stack::Report<ConnectorError>> { let connector_mandate_id = item.request.mandate_id.as_ref().and_then(|mandate_ids| { match mandate_ids.mandate_reference_id.clone() { Some(api_models::payments::MandateReferenceId::ConnectorMandateId( connector_mandate_ids, )) => connector_mandate_ids.get_connector_mandate_id(), _ => None, } }); let (transaction_type, stored_credentials) = if is_mandate_payment(item, connector_mandate_id.as_ref()) { // Mandate payment ( PayeezyTransactionType::Recurring, Some(StoredCredentials { // connector_mandate_id is not present then it is a First payment, else it is a Subsequent mandate payment sequence: match connector_mandate_id.is_some() { true => Sequence::Subsequent, false => Sequence::First, }, // off_session true denotes the customer not present during the checkout process. In other cases customer present at the checkout. initiator: match item.request.off_session { Some(true) => Initiator::Merchant, _ => Initiator::CardHolder, }, is_scheduled: true, // In case of first mandate payment connector_mandate_id would be None, otherwise holds some value cardbrand_original_transaction_id: connector_mandate_id.map(Secret::new), }), ) } else { match item.request.capture_method { Some(CaptureMethod::Manual) => Ok((PayeezyTransactionType::Authorize, None)), Some(CaptureMethod::SequentialAutomatic) | Some(CaptureMethod::Automatic) => { Ok((PayeezyTransactionType::Purchase, None)) } Some(CaptureMethod::ManualMultiple) | Some(CaptureMethod::Scheduled) | None => { Err(ConnectorError::FlowNotSupported { flow: item.request.capture_method.unwrap_or_default().to_string(), connector: "Payeezy".to_string(), }) } }? }; Ok((transaction_type, stored_credentials)) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 25, "total_crates": null }
fn_clm_hyperswitch_connectors_is_mandate_payment_1244530845785343950
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/payeezy/transformers fn is_mandate_payment( item: &PaymentsAuthorizeRouterData, connector_mandate_id: Option<&String>, ) -> bool { item.request.setup_mandate_details.is_some() || connector_mandate_id.is_some() }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 22, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-1953517580268110896
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/stripe/transformers // Implementation of Evidence for TryFrom<&SubmitEvidenceRouterData> fn try_from(item: &SubmitEvidenceRouterData) -> Result<Self, Self::Error> { let submit_evidence_request_data = item.request.clone(); Ok(Self { access_activity_log: submit_evidence_request_data.access_activity_log, billing_address: submit_evidence_request_data .billing_address .map(Secret::new), cancellation_policy: submit_evidence_request_data.cancellation_policy_provider_file_id, cancellation_policy_disclosure: submit_evidence_request_data .cancellation_policy_disclosure, cancellation_rebuttal: submit_evidence_request_data.cancellation_rebuttal, customer_communication: submit_evidence_request_data .customer_communication_provider_file_id, customer_email_address: submit_evidence_request_data .customer_email_address .map(Secret::new), customer_name: submit_evidence_request_data.customer_name.map(Secret::new), customer_purchase_ip: submit_evidence_request_data .customer_purchase_ip .map(Secret::new), customer_signature: submit_evidence_request_data .customer_signature_provider_file_id .map(Secret::new), product_description: submit_evidence_request_data.product_description, receipt: submit_evidence_request_data .receipt_provider_file_id .map(Secret::new), refund_policy: submit_evidence_request_data.refund_policy_provider_file_id, refund_policy_disclosure: submit_evidence_request_data.refund_policy_disclosure, refund_refusal_explanation: submit_evidence_request_data.refund_refusal_explanation, service_date: submit_evidence_request_data.service_date, service_documentation: submit_evidence_request_data .service_documentation_provider_file_id, shipping_address: submit_evidence_request_data .shipping_address .map(Secret::new), shipping_carrier: submit_evidence_request_data.shipping_carrier, shipping_date: submit_evidence_request_data.shipping_date, shipping_documentation: submit_evidence_request_data .shipping_documentation_provider_file_id .map(Secret::new), shipping_tracking_number: submit_evidence_request_data .shipping_tracking_number .map(Secret::new), uncategorized_file: submit_evidence_request_data.uncategorized_file_provider_file_id, uncategorized_text: submit_evidence_request_data.uncategorized_text, submit: true, }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2677, "total_crates": null }
fn_clm_hyperswitch_connectors_from_-1953517580268110896
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/stripe/transformers // Implementation of enums::RefundStatus for From<RefundStatus> fn from(item: RefundStatus) -> Self { match item { RefundStatus::Succeeded => Self::Success, RefundStatus::Failed => Self::Failure, RefundStatus::Pending => Self::Pending, RefundStatus::RequiresAction => Self::ManualReview, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_get_url_-1953517580268110896
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/stripe/transformers // Inherent implementation for StripeNextActionResponse fn get_url(&self) -> Option<Url> { match self { Self::RedirectToUrl(redirect_to_url) | Self::AlipayHandleRedirect(redirect_to_url) => { Some(redirect_to_url.url.to_owned()) } Self::WechatPayDisplayQrCode(_) => None, Self::VerifyWithMicrodeposits(verify_with_microdeposits) => { Some(verify_with_microdeposits.hosted_verification_url.to_owned()) } Self::CashappHandleRedirectOrDisplayQrCode(_) => None, Self::DisplayBankTransferInstructions(_) => None, Self::MultibancoDisplayDetails(_) => None, Self::NoNextActionBody => None, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 411, "total_crates": null }
fn_clm_hyperswitch_connectors_get_connector_metadata_-1953517580268110896
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/stripe/transformers pub fn get_connector_metadata( next_action: Option<&StripeNextActionResponse>, amount: MinorUnit, ) -> CustomResult<Option<Value>, ConnectorError> { let next_action_response = next_action .and_then(|next_action_response| match next_action_response { StripeNextActionResponse::DisplayBankTransferInstructions(response) => { match response.financial_addresses.clone() { FinancialInformation::StripeFinancialInformation(financial_addresses) => { let bank_instructions = financial_addresses.first(); let (sepa_bank_instructions, bacs_bank_instructions) = bank_instructions .map_or((None, None), |financial_address| { ( financial_address.iban.to_owned().map( |sepa_financial_details| SepaFinancialDetails { account_holder_name: sepa_financial_details .account_holder_name, bic: sepa_financial_details.bic, country: sepa_financial_details.country, iban: sepa_financial_details.iban, reference: response.reference.to_owned(), }, ), financial_address.sort_code.to_owned(), ) }); let bank_transfer_instructions = SepaAndBacsBankTransferInstructions { sepa_bank_instructions, bacs_bank_instructions, receiver: SepaAndBacsReceiver { amount_received: amount - response.amount_remaining, amount_remaining: response.amount_remaining, }, }; Some(bank_transfer_instructions.encode_to_value()) } FinancialInformation::AchFinancialInformation(financial_addresses) => { let mut ach_financial_information = HashMap::new(); for address in financial_addresses { match address.financial_details { AchFinancialDetails::Aba(aba_details) => { ach_financial_information .insert("account_number", aba_details.account_number); ach_financial_information .insert("bank_name", aba_details.bank_name); ach_financial_information .insert("routing_number", aba_details.routing_number); } AchFinancialDetails::Swift(swift_details) => { ach_financial_information .insert("swift_code", swift_details.swift_code); } } } let ach_financial_information_value = serde_json::to_value(ach_financial_information).ok()?; let ach_transfer_instruction = serde_json::from_value::<payments::AchTransfer>( ach_financial_information_value, ) .ok()?; let bank_transfer_instructions = payments::BankTransferNextStepsData { bank_transfer_instructions: payments::BankTransferInstructions::AchCreditTransfer(Box::new( ach_transfer_instruction, )), receiver: None, }; Some(bank_transfer_instructions.encode_to_value()) } } } StripeNextActionResponse::WechatPayDisplayQrCode(response) => { let wechat_pay_instructions = QrCodeNextInstructions { image_data_url: response.image_data_url.to_owned(), display_to_timestamp: None, }; Some(wechat_pay_instructions.encode_to_value()) } StripeNextActionResponse::CashappHandleRedirectOrDisplayQrCode(response) => { let cashapp_qr_instructions: QrCodeNextInstructions = QrCodeNextInstructions { image_data_url: response.qr_code.image_url_png.to_owned(), display_to_timestamp: response.qr_code.expires_at.to_owned(), }; Some(cashapp_qr_instructions.encode_to_value()) } StripeNextActionResponse::MultibancoDisplayDetails(response) => { let multibanco_bank_transfer_instructions = payments::BankTransferNextStepsData { bank_transfer_instructions: payments::BankTransferInstructions::Multibanco( Box::new(payments::MultibancoTransferInstructions { reference: response.clone().reference, entity: response.clone().entity.expose(), }), ), receiver: None, }; Some(multibanco_bank_transfer_instructions.encode_to_value()) } _ => None, }) .transpose() .change_context(ConnectorError::ResponseHandlingFailed)?; Ok(next_action_response) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 250, "total_crates": null }
fn_clm_hyperswitch_connectors_deserialize_-1953517580268110896
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/stripe/transformers // Implementation of StripeNextActionResponse for Deserialize<'de> fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { #[derive(Deserialize)] struct Wrapper { #[serde(rename = "type")] _ignore: String, #[serde(flatten, with = "StripeNextActionResponse")] inner: StripeNextActionResponse, } // There is some exception in the stripe next action, it usually sends : // "next_action": { // "redirect_to_url": { "return_url": "...", "url": "..." }, // "type": "redirect_to_url" // }, // But there is a case where it only sends the type and not other field named as it's type let stripe_next_action_response = Wrapper::deserialize(deserializer).map_or(Self::NoNextActionBody, |w| w.inner); Ok(stripe_next_action_response) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 138, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_8162783719862392118
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/stripe/transformers/connect // Implementation of PayoutsRouterData<F> for TryFrom<PayoutsResponseRouterData<F, StripeConnectRecipientAccountCreateResponse>> fn try_from( item: PayoutsResponseRouterData<F, StripeConnectRecipientAccountCreateResponse>, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(PayoutsResponseData { status: Some(enums::PayoutStatus::RequiresCreation), connector_payout_id: item.data.request.connector_payout_id.clone(), payout_eligible: None, should_add_next_step_to_process_tracker: false, error_code: None, error_message: None, payout_connector_metadata: None, }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2659, "total_crates": null }
fn_clm_hyperswitch_connectors_from_8162783719862392118
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/stripe/transformers/connect // Implementation of enums::PayoutStatus for From<StripeConnectPayoutStatus> fn from(stripe_connect_status: StripeConnectPayoutStatus) -> Self { match stripe_connect_status { StripeConnectPayoutStatus::Paid => Self::Success, StripeConnectPayoutStatus::Failed => Self::Failed, StripeConnectPayoutStatus::Canceled => Self::Cancelled, StripeConnectPayoutStatus::Pending | StripeConnectPayoutStatus::InTransit => { Self::Pending } } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_3962318831617059669
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers // Implementation of RouterData<F, RefundsData, RefundsResponseData> for TryFrom<ResponseRouterData<F, BamboraapacSyncResponse, RefundsData, RefundsResponseData>> fn try_from( item: ResponseRouterData<F, BamboraapacSyncResponse, RefundsData, RefundsResponseData>, ) -> Result<Self, Self::Error> { let response_code = item .response .body .query_transaction_response .query_transaction_result .query_response .response .response_code; let connector_refund_id = item .response .body .query_transaction_response .query_transaction_result .query_response .response .receipt; Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: connector_refund_id.to_owned(), refund_status: get_status(response_code), }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2661, "total_crates": null }
fn_clm_hyperswitch_connectors_get_setup_mandate_body_3962318831617059669
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers pub fn get_setup_mandate_body(req: &types::SetupMandateRouterData) -> Result<Vec<u8>, Error> { let card_holder_name = req.get_billing_full_name()?; let auth_details = BamboraapacAuthType::try_from(&req.connector_auth_type)?; let body = match &req.request.payment_method_data { PaymentMethodData::Card(card) => { format!( r#" <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sipp="http://www.ippayments.com.au/interface/api/sipp"> <soapenv:Header/> <soapenv:Body> <sipp:TokeniseCreditCard> <sipp:tokeniseCreditCardXML> <![CDATA[ <TokeniseCreditCard> <CardNumber>{}</CardNumber> <ExpM>{}</ExpM> <ExpY>{}</ExpY> <CardHolderName>{}</CardHolderName> <TokeniseAlgorithmID>2</TokeniseAlgorithmID> <UserName>{}</UserName> <Password>{}</Password> </TokeniseCreditCard> ]]> </sipp:tokeniseCreditCardXML> </sipp:TokeniseCreditCard> </soapenv:Body> </soapenv:Envelope> "#, card.card_number.get_card_no(), card.card_exp_month.peek(), card.get_expiry_year_4_digit().peek(), card_holder_name.peek(), auth_details.username.peek(), auth_details.password.peek(), ) } _ => { return Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Bambora APAC"), ))?; } }; Ok(body.as_bytes().to_vec()) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 22, "total_crates": null }
fn_clm_hyperswitch_connectors_get_payment_sync_body_3962318831617059669
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers pub fn get_payment_sync_body(req: &types::PaymentsSyncRouterData) -> Result<Vec<u8>, Error> { let auth_details = BamboraapacAuthType::try_from(&req.connector_auth_type)?; let connector_transaction_id = req .request .connector_transaction_id .get_connector_transaction_id() .change_context(errors::ConnectorError::MissingConnectorTransactionID)?; let body = format!( r#" <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dts="http://www.ippayments.com.au/interface/api/dts"> <soapenv:Header/> <soapenv:Body> <dts:QueryTransaction> <dts:queryXML> <![CDATA[ <QueryTransaction> <Criteria> <AccountNumber>{}</AccountNumber> <TrnStartTimestamp>2024-06-23 00:00:00</TrnStartTimestamp> <TrnEndTimestamp>2099-12-31 23:59:59</TrnEndTimestamp> <Receipt>{}</Receipt> </Criteria> <Security> <UserName>{}</UserName> <Password>{}</Password> </Security> </QueryTransaction> ]]> </dts:queryXML> </dts:QueryTransaction> </soapenv:Body> </soapenv:Envelope> "#, auth_details.account_number.peek(), connector_transaction_id, auth_details.username.peek(), auth_details.password.peek(), ); Ok(body.as_bytes().to_vec()) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 20, "total_crates": null }
fn_clm_hyperswitch_connectors_get_refund_sync_body_3962318831617059669
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers pub fn get_refund_sync_body(req: &types::RefundSyncRouterData) -> Result<Vec<u8>, Error> { let auth_details = BamboraapacAuthType::try_from(&req.connector_auth_type)?; let body = format!( r#" <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dts="http://www.ippayments.com.au/interface/api/dts"> <soapenv:Header/> <soapenv:Body> <dts:QueryTransaction> <dts:queryXML> <![CDATA[ <QueryTransaction> <Criteria> <AccountNumber>{}</AccountNumber> <TrnStartTimestamp>2024-06-23 00:00:00</TrnStartTimestamp> <TrnEndTimestamp>2099-12-31 23:59:59</TrnEndTimestamp> <CustRef>{}</CustRef> </Criteria> <Security> <UserName>{}</UserName> <Password>{}</Password> </Security> </QueryTransaction> ]]> </dts:queryXML> </dts:QueryTransaction> </soapenv:Body> </soapenv:Envelope> "#, auth_details.account_number.peek(), req.request.refund_id, auth_details.username.peek(), auth_details.password.peek(), ); Ok(body.as_bytes().to_vec()) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 19, "total_crates": null }
fn_clm_hyperswitch_connectors_get_capture_body_3962318831617059669
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers pub fn get_capture_body( req: &BamboraapacRouterData<&types::PaymentsCaptureRouterData>, ) -> Result<Vec<u8>, Error> { let receipt = req.router_data.request.connector_transaction_id.to_owned(); let auth_details = BamboraapacAuthType::try_from(&req.router_data.connector_auth_type)?; let body = format!( r#" <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dts="http://www.ippayments.com.au/interface/api/dts"> <soapenv:Body> <dts:SubmitSingleCapture> <dts:trnXML> <![CDATA[ <Capture> <Receipt>{}</Receipt> <Amount>{}</Amount> <Security> <UserName>{}</UserName> <Password>{}</Password> </Security> </Capture> ]]> </dts:trnXML> </dts:SubmitSingleCapture> </soapenv:Body> </soapenv:Envelope> "#, receipt, req.amount, auth_details.username.peek(), auth_details.password.peek(), ); Ok(body.as_bytes().to_vec()) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 18, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_-2897929204991030229
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/checkbook/transformers // Implementation of RouterData<F, T, PaymentsResponseData> for TryFrom<ResponseRouterData<F, CheckbookPaymentsResponse, T, PaymentsResponseData>> fn try_from( item: ResponseRouterData<F, CheckbookPaymentsResponse, T, PaymentsResponseData>, ) -> Result<Self, Self::Error> { Ok(Self { status: common_enums::AttemptStatus::from(item.response.status), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.id), redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, charges: None, }), ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2665, "total_crates": null }
fn_clm_hyperswitch_connectors_from_-2897929204991030229
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/checkbook/transformers // Implementation of IncomingWebhookEvent for From<CheckbookPaymentStatus> fn from(status: CheckbookPaymentStatus) -> Self { match status { CheckbookPaymentStatus::Mailed | CheckbookPaymentStatus::Printed | CheckbookPaymentStatus::Paid => Self::PaymentIntentSuccess, CheckbookPaymentStatus::Failed | CheckbookPaymentStatus::Expired => { Self::PaymentIntentFailure } CheckbookPaymentStatus::Unpaid | CheckbookPaymentStatus::InProcess | CheckbookPaymentStatus::Processing => Self::PaymentIntentProcessing, CheckbookPaymentStatus::Void => Self::PaymentIntentCancelled, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_try_from_8116350173321244940
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/amazonpay/transformers // Implementation of RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> fn try_from( item: RefundsResponseRouterData<RSync, RefundResponse>, ) -> Result<Self, Self::Error> { let refund_status = enums::RefundStatus::from(item.response.status_details.state); let response = if is_refund_failure(refund_status) { Err(ErrorResponse { code: consts::NO_ERROR_CODE.to_owned(), message: "Amazon has declined the refund.".to_owned(), reason: Some("Amazon has declined the refund because maximum amount has been refunded or there was some other issue.".to_owned()), status_code: item.http_code, attempt_status: None, connector_transaction_id: Some(item.response.refund_id.clone()), network_advice_code: None, network_decline_code: None, network_error_message: None, connector_metadata: None, }) } else { Ok(RefundsResponseData { connector_refund_id: item.response.refund_id.to_string(), refund_status, }) }; Ok(Self { response, ..item.data }) }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2671, "total_crates": null }
fn_clm_hyperswitch_connectors_from_8116350173321244940
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/amazonpay/transformers // Implementation of enums::RefundStatus for From<RefundStatus> fn from(item: RefundStatus) -> Self { match item { RefundStatus::RefundInitiated => Self::Pending, RefundStatus::Refunded => Self::Success, RefundStatus::Declined => Self::Failure, } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_hyperswitch_connectors_get_amazonpay_capture_type_8116350173321244940
clm
function
// Repository: hyperswitch // Crate: hyperswitch_connectors // Purpose: Payment provider integrations (Stripe, PayPal, etc.) // Module: crates/hyperswitch_connectors/src/connectors/amazonpay/transformers fn get_amazonpay_capture_type( item: Option<CaptureMethod>, ) -> CustomResult<PaymentIntent, errors::ConnectorError> { match item { Some(CaptureMethod::Automatic) | None => Ok(PaymentIntent::AuthorizeWithCapture), Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()), } }
{ "crate": "hyperswitch_connectors", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2, "total_crates": null }
fn_clm_smithy_generate_enum_impl_-8671859264310343722
clm
function
// Repository: hyperswitch // Crate: smithy // Module: crates/smithy/src/lib fn generate_enum_impl( name: &syn::Ident, namespace: &str, data_enum: &syn::DataEnum, attrs: &[Attribute], ) -> syn::Result<TokenStream2> { let variants = extract_enum_variants(&data_enum.variants)?; let serde_enum_attrs = parse_serde_enum_attributes(attrs)?; let enum_doc = extract_documentation(attrs); let enum_doc_expr = enum_doc .as_ref() .map(|doc| quote! { Some(#doc.to_string()) }) .unwrap_or(quote! { None }); // Check if this is a string enum (all variants are unit variants) or a union let is_string_enum = variants.iter().all(|v| v.fields.is_empty()); if is_string_enum { // Generate as Smithy enum let variant_implementations = variants .iter() .map(|variant| { let variant_name = &variant.name; let variant_doc = variant .documentation .as_ref() .map(|doc| quote! { Some(#doc.to_string()) }) .unwrap_or(quote! { None }); // Apply serde rename transformation if specified let rename_all = serde_enum_attrs.rename_all.as_deref(); let transformed_name = if let Some(rename_pattern) = rename_all { // Generate the transformation at compile time let transformed = transform_variant_name(variant_name, Some(rename_pattern)); quote! { #transformed.to_string() } } else { quote! { #variant_name.to_string() } }; quote! { enum_values.insert(#transformed_name, smithy_core::SmithyEnumValue { name: #transformed_name, documentation: #variant_doc, is_default: false, }); } }) .collect::<Vec<_>>(); let expanded = quote! { impl smithy_core::SmithyModelGenerator for #name { fn generate_smithy_model() -> smithy_core::SmithyModel { let mut shapes = std::collections::HashMap::new(); let mut enum_values = std::collections::HashMap::new(); #(#variant_implementations)* let shape = smithy_core::SmithyShape::Enum { values: enum_values, documentation: #enum_doc_expr, traits: vec![] }; shapes.insert(stringify!(#name).to_string(), shape); smithy_core::SmithyModel { namespace: #namespace.to_string(), shapes } } } }; Ok(expanded) } else { // Generate as Smithy union let variant_implementations = variants .iter() .filter_map(|variant| { let variant_name = &variant.name; let variant_doc = variant .documentation .as_ref() .map(|doc| quote! { Some(#doc.to_string()) }) .unwrap_or(quote! { None }); let target_type_expr = if variant.fields.is_empty() { // If there are no fields with `value_type`, this variant should be skipped. return None; } else if variant.fields.len() == 1 { // Single field - reference the type directly instead of creating a wrapper let field = &variant.fields[0]; let field_value_type = &field.value_type; if field_value_type.is_empty() { return None; } quote! { { let (target_type, new_shapes) = smithy_core::types::resolve_type_and_generate_shapes(#field_value_type, &mut shapes).unwrap(); shapes.extend(new_shapes); target_type } } } else { // Multiple fields - create an inline structure let inline_struct_members = variant.fields.iter().map(|field| { let field_name = &field.name; let field_value_type = &field.value_type; let field_doc = field .documentation .as_ref() .map(|doc| quote! { Some(#doc.to_string()) }) .unwrap_or(quote! { None }); let mut field_constraints = field.constraints.clone(); if !field.optional && !field_constraints.iter().any(|c| matches!(c, SmithyConstraint::Required)) { field_constraints.push(SmithyConstraint::Required); } let field_traits = if field_constraints.is_empty() { quote! { vec![] } } else { let trait_tokens = field_constraints .iter() .map(|constraint| match constraint { SmithyConstraint::Pattern(pattern) => quote! { smithy_core::SmithyTrait::Pattern { pattern: #pattern.to_string() } }, SmithyConstraint::Range(min, max) => { let min_expr = min.map(|v| quote! { Some(#v) }).unwrap_or(quote! { None }); let max_expr = max.map(|v| quote! { Some(#v) }).unwrap_or(quote! { None }); quote! { smithy_core::SmithyTrait::Range { min: #min_expr, max: #max_expr } } }, SmithyConstraint::Length(min, max) => { let min_expr = min.map(|v| quote! { Some(#v) }).unwrap_or(quote! { None }); let max_expr = max.map(|v| quote! { Some(#v) }).unwrap_or(quote! { None }); quote! { smithy_core::SmithyTrait::Length { min: #min_expr, max: #max_expr } } }, SmithyConstraint::Required => quote! { smithy_core::SmithyTrait::Required }, SmithyConstraint::HttpLabel => quote! { smithy_core::SmithyTrait::HttpLabel }, SmithyConstraint::HttpQuery(name) => quote! { smithy_core::SmithyTrait::HttpQuery { name: #name.to_string() } }, }) .collect::<Vec<_>>(); quote! { vec![#(#trait_tokens),*] } }; quote! { { let (field_target, field_shapes) = smithy_core::types::resolve_type_and_generate_shapes(#field_value_type, &mut shapes).unwrap(); shapes.extend(field_shapes); inline_members.insert(#field_name.to_string(), smithy_core::SmithyMember { target: field_target, documentation: #field_doc, traits: #field_traits, }); } } }); quote! { { let inline_struct_name = format!("{}{}Data", stringify!(#name), #variant_name); let mut inline_members = std::collections::HashMap::new(); #(#inline_struct_members)* let inline_shape = smithy_core::SmithyShape::Structure { members: inline_members, documentation: None, traits: vec![], }; shapes.insert(inline_struct_name.clone(), inline_shape); inline_struct_name } } }; // Apply serde rename transformation if specified let rename_all = serde_enum_attrs.rename_all.as_deref(); let transformed_name = if let Some(rename_pattern) = rename_all { // Generate the transformation at compile time let transformed = transform_variant_name(variant_name, Some(rename_pattern)); quote! { #transformed.to_string() } } else { quote! { #variant_name.to_string() } }; Some(quote! { let target_type = #target_type_expr; members.insert(#transformed_name, smithy_core::SmithyMember { target: target_type, documentation: #variant_doc, traits: vec![] }); }) }) .collect::<Vec<_>>(); let expanded = quote! { impl smithy_core::SmithyModelGenerator for #name { fn generate_smithy_model() -> smithy_core::SmithyModel { let mut shapes = std::collections::HashMap::new(); let mut members = std::collections::HashMap::new(); #(#variant_implementations;)* let shape = smithy_core::SmithyShape::Union { members, documentation: #enum_doc_expr, traits: vec![] }; shapes.insert(stringify!(#name).to_string(), shape); smithy_core::SmithyModel { namespace: #namespace.to_string(), shapes } } } }; Ok(expanded) } }
{ "crate": "smithy", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 95, "total_crates": null }
fn_clm_smithy_parse_smithy_field_attributes_-8671859264310343722
clm
function
// Repository: hyperswitch // Crate: smithy // Module: crates/smithy/src/lib fn parse_smithy_field_attributes(attrs: &[Attribute]) -> syn::Result<SmithyFieldAttributes> { let mut field_attributes = SmithyFieldAttributes::default(); for attr in attrs { if attr.path().is_ident("smithy") { attr.parse_nested_meta(|meta| { if meta.path.is_ident("value_type") { if let Ok(value) = meta.value() { if let Ok(Lit::Str(lit_str)) = value.parse::<Lit>() { field_attributes.value_type = Some(lit_str.value()); } } } else if meta.path.is_ident("pattern") { if let Ok(value) = meta.value() { if let Ok(Lit::Str(lit_str)) = value.parse::<Lit>() { field_attributes .constraints .push(SmithyConstraint::Pattern(lit_str.value())); } } } else if meta.path.is_ident("range") { if let Ok(value) = meta.value() { if let Ok(Lit::Str(lit_str)) = value.parse::<Lit>() { let range_str = lit_str.value(); match parse_range(&range_str) { Ok((min, max)) => { field_attributes .constraints .push(SmithyConstraint::Range(min, max)); } Err(e) => { return Err(syn::Error::new_spanned( &meta.path, format!("Invalid range: {}", e), )); } } } } } else if meta.path.is_ident("length") { if let Ok(value) = meta.value() { if let Ok(Lit::Str(lit_str)) = value.parse::<Lit>() { let length_str = lit_str.value(); match parse_length(&length_str) { Ok((min, max)) => { field_attributes .constraints .push(SmithyConstraint::Length(min, max)); } Err(e) => { return Err(syn::Error::new_spanned( &meta.path, format!("Invalid length: {}", e), )); } } } } } else if meta.path.is_ident("required") { field_attributes .constraints .push(SmithyConstraint::Required); } else if meta.path.is_ident("http_label") { field_attributes .constraints .push(SmithyConstraint::HttpLabel); } else if meta.path.is_ident("http_query") { if let Ok(value) = meta.value() { if let Ok(Lit::Str(lit_str)) = value.parse::<Lit>() { field_attributes .constraints .push(SmithyConstraint::HttpQuery(lit_str.value())); } } } Ok(()) })?; } } // Automatically add Required for http_label fields if field_attributes .constraints .iter() .any(|c| matches!(c, SmithyConstraint::HttpLabel)) && !field_attributes .constraints .iter() .any(|c| matches!(c, SmithyConstraint::Required)) { field_attributes .constraints .push(SmithyConstraint::Required); } Ok(field_attributes) }
{ "crate": "smithy", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 92, "total_crates": null }
fn_clm_smithy_generate_struct_impl_-8671859264310343722
clm
function
// Repository: hyperswitch // Crate: smithy // Module: crates/smithy/src/lib fn generate_struct_impl( name: &syn::Ident, namespace: &str, data_struct: &syn::DataStruct, attrs: &[Attribute], is_mixin: bool, ) -> syn::Result<TokenStream2> { let fields = extract_fields(&data_struct.fields)?; let struct_doc = extract_documentation(attrs); let struct_doc_expr = struct_doc .as_ref() .map(|doc| quote! { Some(#doc.to_string()) }) .unwrap_or(quote! { None }); let field_implementations = fields.iter().map(|field| { let field_name = &field.name; let value_type = &field.value_type; let documentation = &field.documentation; let constraints = &field.constraints; let optional = field.optional; let flatten = field.flatten; if flatten { // Extract the inner type from Option<T> if it's an optional type let inner_type = if value_type.starts_with("Option<") && value_type.ends_with('>') { let start_idx = "Option<".len(); let end_idx = value_type.len() - 1; &value_type[start_idx..end_idx] } else { value_type }; let inner_type_ident = syn::parse_str::<syn::Type>(inner_type).unwrap(); // For flattened fields, we merge the fields from the inner type // but we don't add the field itself to the structure quote! { { let flattened_model = <#inner_type_ident as smithy_core::SmithyModelGenerator>::generate_smithy_model(); let flattened_struct_name = stringify!(#inner_type_ident).to_string(); for (shape_name, shape) in flattened_model.shapes { if shape_name == flattened_struct_name { match shape { smithy_core::SmithyShape::Structure { members: flattened_members, .. } | smithy_core::SmithyShape::Union { members: flattened_members, .. } => { members.extend(flattened_members); } _ => { // Potentially handle other shapes or log a warning } } } else { shapes.insert(shape_name, shape); } } } } } else { let field_doc = documentation .as_ref() .map(|doc| quote! { Some(#doc.to_string()) }) .unwrap_or(quote! { None }); let mut all_constraints = constraints.clone(); if !optional && !all_constraints.iter().any(|c| matches!(c, SmithyConstraint::Required)) { all_constraints.push(SmithyConstraint::Required); } let traits = if all_constraints.is_empty() { quote! { vec![] } } else { let trait_tokens = all_constraints .iter() .map(|constraint| match constraint { SmithyConstraint::Pattern(pattern) => quote! { smithy_core::SmithyTrait::Pattern { pattern: #pattern.to_string() } }, SmithyConstraint::Range(min, max) => { let min_expr = min.map(|v| quote! { Some(#v) }).unwrap_or(quote! { None }); let max_expr = max.map(|v| quote! { Some(#v) }).unwrap_or(quote! { None }); quote! { smithy_core::SmithyTrait::Range { min: #min_expr, max: #max_expr } } }, SmithyConstraint::Length(min, max) => { let min_expr = min.map(|v| quote! { Some(#v) }).unwrap_or(quote! { None }); let max_expr = max.map(|v| quote! { Some(#v) }).unwrap_or(quote! { None }); quote! { smithy_core::SmithyTrait::Length { min: #min_expr, max: #max_expr } } }, SmithyConstraint::Required => quote! { smithy_core::SmithyTrait::Required }, SmithyConstraint::HttpLabel => quote! { smithy_core::SmithyTrait::HttpLabel }, SmithyConstraint::HttpQuery(name) => quote! { smithy_core::SmithyTrait::HttpQuery { name: #name.to_string() } }, }) .collect::<Vec<_>>(); quote! { vec![#(#trait_tokens),*] } }; quote! { { let (target_type, new_shapes) = smithy_core::types::resolve_type_and_generate_shapes(#value_type, &mut shapes).unwrap(); shapes.extend(new_shapes); members.insert(#field_name.to_string(), smithy_core::SmithyMember { target: target_type, documentation: #field_doc, traits: #traits, }); } } } }); let traits_expr = if is_mixin { quote! { vec![smithy_core::SmithyTrait::Mixin] } } else { quote! { vec![] } }; let expanded = quote! { impl smithy_core::SmithyModelGenerator for #name { fn generate_smithy_model() -> smithy_core::SmithyModel { let mut shapes = std::collections::HashMap::new(); let mut members = std::collections::HashMap::new(); #(#field_implementations;)* let shape = smithy_core::SmithyShape::Structure { members, documentation: #struct_doc_expr, traits: #traits_expr }; shapes.insert(stringify!(#name).to_string(), shape); smithy_core::SmithyModel { namespace: #namespace.to_string(), shapes } } } }; Ok(expanded) }
{ "crate": "smithy", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 61, "total_crates": null }
fn_clm_smithy_parse_serde_enum_attributes_-8671859264310343722
clm
function
// Repository: hyperswitch // Crate: smithy // Module: crates/smithy/src/lib fn parse_serde_enum_attributes(attrs: &[Attribute]) -> syn::Result<SerdeEnumAttributes> { let mut serde_enum_attributes = SerdeEnumAttributes::default(); for attr in attrs { if attr.path().is_ident("serde") { // Use more robust parsing that handles all serde attributes let parse_result = attr.parse_nested_meta(|meta| { if meta.path.is_ident("rename_all") { if let Ok(value) = meta.value() { if let Ok(Lit::Str(lit_str)) = value.parse::<Lit>() { serde_enum_attributes.rename_all = Some(lit_str.value()); } } } else if meta.path.is_ident("tag") { // Parse and ignore the tag attribute if let Ok(value) = meta.value() { let _ = value.parse::<Lit>(); } } else if meta.path.is_ident("content") { // Parse and ignore the content attribute if let Ok(value) = meta.value() { let _ = value.parse::<Lit>(); } } else if meta.path.is_ident("rename") { // Parse and ignore the rename attribute (used for enum renaming) if let Ok(value) = meta.value() { let _ = value.parse::<Lit>(); } } else if meta.path.is_ident("deny_unknown_fields") { // Handle deny_unknown_fields (no value needed) // This is a flag attribute with no value } else if meta.path.is_ident("skip_serializing") { // Handle skip_serializing } else if meta.path.is_ident("skip_deserializing") { // Handle skip_deserializing } else if meta.path.is_ident("skip_serializing_if") { // Handle skip_serializing_if if let Ok(value) = meta.value() { let _ = value.parse::<syn::Expr>(); } } else if meta.path.is_ident("default") { // Handle default attribute // Could have a value or be a flag if meta.value().is_ok() { let _ = meta.value().and_then(|v| v.parse::<syn::Expr>()); } } else if meta.path.is_ident("flatten") { // Handle flatten (flag attribute) } else if meta.path.is_ident("untagged") { // Handle untagged (flag attribute) } else if meta.path.is_ident("bound") { // Handle bound attribute if let Ok(value) = meta.value() { let _ = value.parse::<Lit>(); } } // Silently ignore any other serde attributes to prevent parsing errors Ok(()) }); // If parsing failed, provide a more helpful error message if let Err(e) = parse_result { return Err(syn::Error::new_spanned( attr, format!("Failed to parse serde attribute: {}. This may be due to multiple serde attributes on separate lines. Consider consolidating them into a single #[serde(...)] attribute.", e) )); } } } Ok(serde_enum_attributes) }
{ "crate": "smithy", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 59, "total_crates": null }
fn_clm_smithy_extract_enum_variants_-8671859264310343722
clm
function
// Repository: hyperswitch // Crate: smithy // Module: crates/smithy/src/lib fn extract_enum_variants( variants: &syn::punctuated::Punctuated<Variant, syn::token::Comma>, ) -> syn::Result<Vec<SmithyEnumVariant>> { let mut smithy_variants = Vec::new(); for variant in variants { let variant_name = variant.ident.to_string(); let documentation = extract_documentation(&variant.attrs); let variant_attrs = parse_smithy_field_attributes(&variant.attrs)?; // Extract fields from the variant let fields = match &variant.fields { Fields::Unit => Vec::new(), Fields::Named(fields_named) => { let mut variant_fields = Vec::new(); for field in &fields_named.named { let field_name = field.ident.as_ref().unwrap().to_string(); let field_attrs = parse_smithy_field_attributes(&field.attrs)?; if let Some(value_type) = field_attrs.value_type { let field_documentation = extract_documentation(&field.attrs); let optional = value_type.trim().starts_with("Option<"); variant_fields.push(SmithyField { name: field_name, value_type, constraints: field_attrs.constraints, documentation: field_documentation, optional, flatten: false, }); } } variant_fields } Fields::Unnamed(fields_unnamed) => { let mut variant_fields = Vec::new(); for (index, field) in fields_unnamed.unnamed.iter().enumerate() { let field_name = format!("field_{}", index); let field_attrs = parse_smithy_field_attributes(&field.attrs)?; // For single unnamed fields, use the variant attribute if field doesn't have one let value_type = field_attrs .value_type .or_else(|| variant_attrs.value_type.clone()); if let Some(value_type) = value_type { let field_documentation = extract_documentation(&field.attrs); let optional = value_type.trim().starts_with("Option<"); variant_fields.push(SmithyField { name: field_name, value_type, constraints: field_attrs.constraints, documentation: field_documentation, optional, flatten: false, }); } } variant_fields } }; smithy_variants.push(SmithyEnumVariant { name: variant_name, fields, constraints: variant_attrs.constraints, documentation, }); } Ok(smithy_variants) }
{ "crate": "smithy", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 51, "total_crates": null }
fn_clm_common_enums_try_from_-3848676809601563737
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/connector_enums // Implementation of RoutableConnectors for TryFrom<Connector> fn try_from(connector: Connector) -> Result<Self, Self::Error> { match connector { Connector::Authipay => Ok(Self::Authipay), Connector::Adyenplatform => Ok(Self::Adyenplatform), #[cfg(feature = "dummy_connector")] Connector::DummyBillingConnector => Ok(Self::DummyBillingConnector), #[cfg(feature = "dummy_connector")] Connector::DummyConnector1 => Ok(Self::DummyConnector1), #[cfg(feature = "dummy_connector")] Connector::DummyConnector2 => Ok(Self::DummyConnector2), #[cfg(feature = "dummy_connector")] Connector::DummyConnector3 => Ok(Self::DummyConnector3), #[cfg(feature = "dummy_connector")] Connector::DummyConnector4 => Ok(Self::DummyConnector4), #[cfg(feature = "dummy_connector")] Connector::DummyConnector5 => Ok(Self::DummyConnector5), #[cfg(feature = "dummy_connector")] Connector::DummyConnector6 => Ok(Self::DummyConnector6), #[cfg(feature = "dummy_connector")] Connector::DummyConnector7 => Ok(Self::DummyConnector7), Connector::Aci => Ok(Self::Aci), Connector::Adyen => Ok(Self::Adyen), Connector::Affirm => Ok(Self::Affirm), Connector::Airwallex => Ok(Self::Airwallex), Connector::Amazonpay => Ok(Self::Amazonpay), Connector::Archipel => Ok(Self::Archipel), Connector::Authorizedotnet => Ok(Self::Authorizedotnet), Connector::Bankofamerica => Ok(Self::Bankofamerica), Connector::Barclaycard => Ok(Self::Barclaycard), Connector::Billwerk => Ok(Self::Billwerk), Connector::Bitpay => Ok(Self::Bitpay), Connector::Bambora => Ok(Self::Bambora), Connector::Bamboraapac => Ok(Self::Bamboraapac), Connector::Bluesnap => Ok(Self::Bluesnap), Connector::Blackhawknetwork => Ok(Self::Blackhawknetwork), Connector::Calida => Ok(Self::Calida), Connector::Boku => Ok(Self::Boku), Connector::Braintree => Ok(Self::Braintree), Connector::Breadpay => Ok(Self::Breadpay), Connector::Cashtocode => Ok(Self::Cashtocode), Connector::Celero => Ok(Self::Celero), Connector::Chargebee => Ok(Self::Chargebee), Connector::Checkbook => Ok(Self::Checkbook), Connector::Checkout => Ok(Self::Checkout), Connector::Coinbase => Ok(Self::Coinbase), Connector::Coingate => Ok(Self::Coingate), Connector::Cryptopay => Ok(Self::Cryptopay), Connector::Custombilling => Ok(Self::Custombilling), Connector::Cybersource => Ok(Self::Cybersource), Connector::Datatrans => Ok(Self::Datatrans), Connector::Deutschebank => Ok(Self::Deutschebank), Connector::Digitalvirgo => Ok(Self::Digitalvirgo), Connector::Dlocal => Ok(Self::Dlocal), Connector::Dwolla => Ok(Self::Dwolla), Connector::Ebanx => Ok(Self::Ebanx), Connector::Elavon => Ok(Self::Elavon), Connector::Facilitapay => Ok(Self::Facilitapay), Connector::Finix => Ok(Self::Finix), Connector::Fiserv => Ok(Self::Fiserv), Connector::Fiservemea => Ok(Self::Fiservemea), Connector::Fiuu => Ok(Self::Fiuu), Connector::Flexiti => Ok(Self::Flexiti), Connector::Forte => Ok(Self::Forte), Connector::Globalpay => Ok(Self::Globalpay), Connector::Globepay => Ok(Self::Globepay), Connector::Gocardless => Ok(Self::Gocardless), Connector::Helcim => Ok(Self::Helcim), Connector::Iatapay => Ok(Self::Iatapay), Connector::Itaubank => Ok(Self::Itaubank), Connector::Jpmorgan => Ok(Self::Jpmorgan), Connector::Klarna => Ok(Self::Klarna), Connector::Loonio => Ok(Self::Loonio), Connector::Mifinity => Ok(Self::Mifinity), Connector::Mollie => Ok(Self::Mollie), Connector::Moneris => Ok(Self::Moneris), Connector::Multisafepay => Ok(Self::Multisafepay), Connector::Nexinets => Ok(Self::Nexinets), Connector::Nexixpay => Ok(Self::Nexixpay), Connector::Nmi => Ok(Self::Nmi), Connector::Nomupay => Ok(Self::Nomupay), Connector::Noon => Ok(Self::Noon), Connector::Nordea => Ok(Self::Nordea), Connector::Novalnet => Ok(Self::Novalnet), Connector::Nuvei => Ok(Self::Nuvei), Connector::Opennode => Ok(Self::Opennode), Connector::Paybox => Ok(Self::Paybox), Connector::Payload => Ok(Self::Payload), Connector::Payme => Ok(Self::Payme), Connector::Payone => Ok(Self::Payone), Connector::Paypal => Ok(Self::Paypal), Connector::Paysafe => Ok(Self::Paysafe), Connector::Paystack => Ok(Self::Paystack), Connector::Payu => Ok(Self::Payu), Connector::Peachpayments => Ok(Self::Peachpayments), Connector::Placetopay => Ok(Self::Placetopay), Connector::Powertranz => Ok(Self::Powertranz), Connector::Prophetpay => Ok(Self::Prophetpay), Connector::Rapyd => Ok(Self::Rapyd), Connector::Razorpay => Ok(Self::Razorpay), Connector::Riskified => Ok(Self::Riskified), Connector::Santander => Ok(Self::Santander), Connector::Shift4 => Ok(Self::Shift4), Connector::Signifyd => Ok(Self::Signifyd), Connector::Silverflow => Ok(Self::Silverflow), Connector::Square => Ok(Self::Square), Connector::Stax => Ok(Self::Stax), Connector::Stripe => Ok(Self::Stripe), Connector::Stripebilling => Ok(Self::Stripebilling), Connector::Tokenio => Ok(Self::Tokenio), Connector::Tesouro => Ok(Self::Tesouro), Connector::Trustpay => Ok(Self::Trustpay), Connector::Trustpayments => Ok(Self::Trustpayments), Connector::Tsys => Ok(Self::Tsys), Connector::Volt => Ok(Self::Volt), Connector::Wellsfargo => Ok(Self::Wellsfargo), Connector::Wise => Ok(Self::Wise), Connector::Worldline => Ok(Self::Worldline), Connector::Worldpay => Ok(Self::Worldpay), Connector::Worldpayvantiv => Ok(Self::Worldpayvantiv), Connector::Worldpayxml => Ok(Self::Worldpayxml), Connector::Xendit => Ok(Self::Xendit), Connector::Zen => Ok(Self::Zen), Connector::Plaid => Ok(Self::Plaid), Connector::Zsl => Ok(Self::Zsl), Connector::Recurly => Ok(Self::Recurly), Connector::Getnet => Ok(Self::Getnet), Connector::Gigadat => Ok(Self::Gigadat), Connector::Hipay => Ok(Self::Hipay), Connector::Inespay => Ok(Self::Inespay), Connector::Redsys => Ok(Self::Redsys), Connector::Paytm => Ok(Self::Paytm), Connector::Phonepe => Ok(Self::Phonepe), Connector::CtpMastercard | Connector::Gpayments | Connector::HyperswitchVault | Connector::Juspaythreedsserver | Connector::Netcetera | Connector::Taxjar | Connector::Threedsecureio | Connector::Vgs | Connector::CtpVisa | Connector::Cardinal | Connector::Tokenex => Err("Invalid conversion. Not a routable connector"), } }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2657, "total_crates": null }
fn_clm_common_enums_from_-3848676809601563737
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/connector_enums // Implementation of Connector for From<RoutableConnectors> fn from(routable_connector: RoutableConnectors) -> Self { match routable_connector { RoutableConnectors::Authipay => Self::Authipay, RoutableConnectors::Adyenplatform => Self::Adyenplatform, #[cfg(feature = "dummy_connector")] RoutableConnectors::DummyBillingConnector => Self::DummyBillingConnector, #[cfg(feature = "dummy_connector")] RoutableConnectors::DummyConnector1 => Self::DummyConnector1, #[cfg(feature = "dummy_connector")] RoutableConnectors::DummyConnector2 => Self::DummyConnector2, #[cfg(feature = "dummy_connector")] RoutableConnectors::DummyConnector3 => Self::DummyConnector3, #[cfg(feature = "dummy_connector")] RoutableConnectors::DummyConnector4 => Self::DummyConnector4, #[cfg(feature = "dummy_connector")] RoutableConnectors::DummyConnector5 => Self::DummyConnector5, #[cfg(feature = "dummy_connector")] RoutableConnectors::DummyConnector6 => Self::DummyConnector6, #[cfg(feature = "dummy_connector")] RoutableConnectors::DummyConnector7 => Self::DummyConnector7, RoutableConnectors::Aci => Self::Aci, RoutableConnectors::Adyen => Self::Adyen, RoutableConnectors::Affirm => Self::Affirm, RoutableConnectors::Airwallex => Self::Airwallex, RoutableConnectors::Amazonpay => Self::Amazonpay, RoutableConnectors::Archipel => Self::Archipel, RoutableConnectors::Authorizedotnet => Self::Authorizedotnet, RoutableConnectors::Bankofamerica => Self::Bankofamerica, RoutableConnectors::Barclaycard => Self::Barclaycard, RoutableConnectors::Billwerk => Self::Billwerk, RoutableConnectors::Bitpay => Self::Bitpay, RoutableConnectors::Bambora => Self::Bambora, RoutableConnectors::Bamboraapac => Self::Bamboraapac, RoutableConnectors::Bluesnap => Self::Bluesnap, RoutableConnectors::Blackhawknetwork => Self::Blackhawknetwork, RoutableConnectors::Calida => Self::Calida, RoutableConnectors::Boku => Self::Boku, RoutableConnectors::Braintree => Self::Braintree, RoutableConnectors::Breadpay => Self::Breadpay, RoutableConnectors::Cashtocode => Self::Cashtocode, RoutableConnectors::Celero => Self::Celero, RoutableConnectors::Chargebee => Self::Chargebee, RoutableConnectors::Custombilling => Self::Custombilling, RoutableConnectors::Checkbook => Self::Checkbook, RoutableConnectors::Checkout => Self::Checkout, RoutableConnectors::Coinbase => Self::Coinbase, RoutableConnectors::Cryptopay => Self::Cryptopay, RoutableConnectors::Cybersource => Self::Cybersource, RoutableConnectors::Datatrans => Self::Datatrans, RoutableConnectors::Deutschebank => Self::Deutschebank, RoutableConnectors::Digitalvirgo => Self::Digitalvirgo, RoutableConnectors::Dlocal => Self::Dlocal, RoutableConnectors::Dwolla => Self::Dwolla, RoutableConnectors::Ebanx => Self::Ebanx, RoutableConnectors::Elavon => Self::Elavon, RoutableConnectors::Facilitapay => Self::Facilitapay, RoutableConnectors::Finix => Self::Finix, RoutableConnectors::Fiserv => Self::Fiserv, RoutableConnectors::Fiservemea => Self::Fiservemea, RoutableConnectors::Fiuu => Self::Fiuu, RoutableConnectors::Flexiti => Self::Flexiti, RoutableConnectors::Forte => Self::Forte, RoutableConnectors::Getnet => Self::Getnet, RoutableConnectors::Gigadat => Self::Gigadat, RoutableConnectors::Globalpay => Self::Globalpay, RoutableConnectors::Globepay => Self::Globepay, RoutableConnectors::Gocardless => Self::Gocardless, RoutableConnectors::Helcim => Self::Helcim, RoutableConnectors::Iatapay => Self::Iatapay, RoutableConnectors::Itaubank => Self::Itaubank, RoutableConnectors::Jpmorgan => Self::Jpmorgan, RoutableConnectors::Klarna => Self::Klarna, RoutableConnectors::Loonio => Self::Loonio, RoutableConnectors::Mifinity => Self::Mifinity, RoutableConnectors::Mollie => Self::Mollie, RoutableConnectors::Moneris => Self::Moneris, RoutableConnectors::Multisafepay => Self::Multisafepay, RoutableConnectors::Nexinets => Self::Nexinets, RoutableConnectors::Nexixpay => Self::Nexixpay, RoutableConnectors::Nmi => Self::Nmi, RoutableConnectors::Nomupay => Self::Nomupay, RoutableConnectors::Noon => Self::Noon, RoutableConnectors::Nordea => Self::Nordea, RoutableConnectors::Novalnet => Self::Novalnet, RoutableConnectors::Nuvei => Self::Nuvei, RoutableConnectors::Opennode => Self::Opennode, RoutableConnectors::Paybox => Self::Paybox, RoutableConnectors::Payload => Self::Payload, RoutableConnectors::Payme => Self::Payme, RoutableConnectors::Payone => Self::Payone, RoutableConnectors::Paypal => Self::Paypal, RoutableConnectors::Paysafe => Self::Paysafe, RoutableConnectors::Paystack => Self::Paystack, RoutableConnectors::Payu => Self::Payu, RoutableConnectors::Peachpayments => Self::Peachpayments, RoutableConnectors::Placetopay => Self::Placetopay, RoutableConnectors::Powertranz => Self::Powertranz, RoutableConnectors::Prophetpay => Self::Prophetpay, RoutableConnectors::Rapyd => Self::Rapyd, RoutableConnectors::Razorpay => Self::Razorpay, RoutableConnectors::Recurly => Self::Recurly, RoutableConnectors::Redsys => Self::Redsys, RoutableConnectors::Riskified => Self::Riskified, RoutableConnectors::Santander => Self::Santander, RoutableConnectors::Shift4 => Self::Shift4, RoutableConnectors::Signifyd => Self::Signifyd, RoutableConnectors::Silverflow => Self::Silverflow, RoutableConnectors::Square => Self::Square, RoutableConnectors::Stax => Self::Stax, RoutableConnectors::Stripe => Self::Stripe, RoutableConnectors::Stripebilling => Self::Stripebilling, RoutableConnectors::Tesouro => Self::Tesouro, RoutableConnectors::Tokenio => Self::Tokenio, RoutableConnectors::Trustpay => Self::Trustpay, RoutableConnectors::Trustpayments => Self::Trustpayments, // RoutableConnectors::Tokenio => Self::Tokenio, RoutableConnectors::Tsys => Self::Tsys, RoutableConnectors::Volt => Self::Volt, RoutableConnectors::Wellsfargo => Self::Wellsfargo, RoutableConnectors::Wise => Self::Wise, RoutableConnectors::Worldline => Self::Worldline, RoutableConnectors::Worldpay => Self::Worldpay, RoutableConnectors::Worldpayvantiv => Self::Worldpayvantiv, RoutableConnectors::Worldpayxml => Self::Worldpayxml, RoutableConnectors::Zen => Self::Zen, RoutableConnectors::Plaid => Self::Plaid, RoutableConnectors::Zsl => Self::Zsl, RoutableConnectors::Xendit => Self::Xendit, RoutableConnectors::Inespay => Self::Inespay, RoutableConnectors::Coingate => Self::Coingate, RoutableConnectors::Hipay => Self::Hipay, RoutableConnectors::Paytm => Self::Paytm, RoutableConnectors::Phonepe => Self::Phonepe, } }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_common_enums_requires_order_creation_before_payment_-3848676809601563737
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/connector_enums // Implementation of None for Connector pub fn requires_order_creation_before_payment(self, payment_method: PaymentMethod) -> bool { matches!((self, payment_method), (Self::Razorpay, PaymentMethod::Upi)) }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 24, "total_crates": null }
fn_clm_common_enums_is_separate_authentication_supported_-3848676809601563737
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/connector_enums // Implementation of None for Connector pub fn is_separate_authentication_supported(self) -> bool { match self { #[cfg(feature = "dummy_connector")] Self::DummyBillingConnector => false, #[cfg(feature = "dummy_connector")] Self::DummyConnector1 | Self::DummyConnector2 | Self::DummyConnector3 | Self::DummyConnector4 | Self::DummyConnector5 | Self::DummyConnector6 | Self::DummyConnector7 => false, Self::Aci // Add Separate authentication support for connectors | Self::Authipay | Self::Adyen | Self::Affirm | Self::Adyenplatform | Self::Airwallex | Self::Amazonpay | Self::Authorizedotnet | Self::Bambora | Self::Bamboraapac | Self::Bankofamerica | Self::Barclaycard | Self::Billwerk | Self::Bitpay | Self::Bluesnap | Self::Blackhawknetwork | Self::Calida | Self::Boku | Self::Braintree | Self::Breadpay | Self::Cashtocode | Self::Celero | Self::Chargebee | Self::Checkbook | Self::Coinbase | Self::Coingate | Self::Cryptopay | Self::Custombilling | Self::Deutschebank | Self::Digitalvirgo | Self::Dlocal | Self::Dwolla | Self::Ebanx | Self::Elavon | Self::Facilitapay | Self::Finix | Self::Fiserv | Self::Fiservemea | Self::Fiuu | Self::Flexiti | Self::Forte | Self::Getnet | Self::Gigadat | Self::Globalpay | Self::Globepay | Self::Gocardless | Self::Gpayments | Self::Hipay | Self::Helcim | Self::HyperswitchVault | Self::Iatapay | Self::Inespay | Self::Itaubank | Self::Jpmorgan | Self::Juspaythreedsserver | Self::Klarna | Self::Loonio | Self::Mifinity | Self::Mollie | Self::Moneris | Self::Multisafepay | Self::Nexinets | Self::Nexixpay | Self::Nomupay | Self::Nordea | Self::Novalnet | Self::Opennode | Self::Paybox | Self::Payload | Self::Payme | Self::Payone | Self::Paypal | Self::Paysafe | Self::Paystack | Self::Payu | Self::Peachpayments | Self::Placetopay | Self::Powertranz | Self::Prophetpay | Self::Rapyd | Self::Recurly | Self::Redsys | Self::Santander | Self::Shift4 | Self::Silverflow | Self::Square | Self::Stax | Self::Stripebilling | Self::Taxjar | Self::Tesouro // | Self::Thunes | Self::Trustpay | Self::Trustpayments // | Self::Tokenio | Self::Tsys // | Self::UnifiedAuthenticationService | Self::Vgs | Self::Volt | Self::Wellsfargo // | Self::Wellsfargopayout | Self::Wise | Self::Worldline | Self::Worldpay | Self::Worldpayvantiv | Self::Worldpayxml | Self::Xendit | Self::Zen | Self::Zsl | Self::Signifyd | Self::Plaid | Self::Razorpay | Self::Riskified | Self::Threedsecureio | Self::Netcetera | Self::CtpMastercard | Self::Cardinal | Self::CtpVisa | Self::Noon | Self::Tokenex | Self::Tokenio | Self::Stripe | Self::Datatrans | Self::Paytm | Self::Phonepe => false, Self::Checkout | Self::Nmi |Self::Cybersource | Self::Archipel | Self::Nuvei => true, } }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 24, "total_crates": null }
fn_clm_common_enums_get_payment_methods_supporting_extended_authorization_-3848676809601563737
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/connector_enums // Implementation of None for Connector pub fn get_payment_methods_supporting_extended_authorization(self) -> HashSet<PaymentMethod> { HashSet::from([PaymentMethod::Card]) }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 23, "total_crates": null }
fn_clm_common_enums_from_8736821621322496592
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/transformers // Implementation of Option<EventType> for From<MandateStatus> fn from(value: MandateStatus) -> Self { match value { MandateStatus::Active => Some(EventType::MandateActive), MandateStatus::Revoked => Some(EventType::MandateRevoked), MandateStatus::Inactive | MandateStatus::Pending => None, } }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_common_enums_deserialize_8736821621322496592
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/transformers pub fn deserialize<'a, D>(deserializer: D) -> Result<Country, D::Error> where D: serde::Deserializer<'a>, { u32::deserialize(deserializer) .and_then(|value| Country::from_numeric(value).map_err(serde::de::Error::custom)) }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 144, "total_crates": null }
fn_clm_common_enums_serialize_8736821621322496592
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/transformers pub fn serialize<S>(code: &Country, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { code.to_numeric().serialize(serializer) }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 89, "total_crates": null }
fn_clm_common_enums_from_alpha2_8736821621322496592
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/transformers // Inherent implementation for Country pub const fn from_alpha2(code: CountryAlpha2) -> Self { match code { CountryAlpha2::AF => Self::Afghanistan, CountryAlpha2::AX => Self::AlandIslands, CountryAlpha2::AL => Self::Albania, CountryAlpha2::DZ => Self::Algeria, CountryAlpha2::AS => Self::AmericanSamoa, CountryAlpha2::AD => Self::Andorra, CountryAlpha2::AO => Self::Angola, CountryAlpha2::AI => Self::Anguilla, CountryAlpha2::AQ => Self::Antarctica, CountryAlpha2::AG => Self::AntiguaAndBarbuda, CountryAlpha2::AR => Self::Argentina, CountryAlpha2::AM => Self::Armenia, CountryAlpha2::AW => Self::Aruba, CountryAlpha2::AU => Self::Australia, CountryAlpha2::AT => Self::Austria, CountryAlpha2::AZ => Self::Azerbaijan, CountryAlpha2::BS => Self::Bahamas, CountryAlpha2::BH => Self::Bahrain, CountryAlpha2::BD => Self::Bangladesh, CountryAlpha2::BB => Self::Barbados, CountryAlpha2::BY => Self::Belarus, CountryAlpha2::BE => Self::Belgium, CountryAlpha2::BZ => Self::Belize, CountryAlpha2::BJ => Self::Benin, CountryAlpha2::BM => Self::Bermuda, CountryAlpha2::BT => Self::Bhutan, CountryAlpha2::BO => Self::BoliviaPlurinationalState, CountryAlpha2::BQ => Self::BonaireSintEustatiusAndSaba, CountryAlpha2::BA => Self::BosniaAndHerzegovina, CountryAlpha2::BW => Self::Botswana, CountryAlpha2::BV => Self::BouvetIsland, CountryAlpha2::BR => Self::Brazil, CountryAlpha2::IO => Self::BritishIndianOceanTerritory, CountryAlpha2::BN => Self::BruneiDarussalam, CountryAlpha2::BG => Self::Bulgaria, CountryAlpha2::BF => Self::BurkinaFaso, CountryAlpha2::BI => Self::Burundi, CountryAlpha2::CV => Self::CaboVerde, CountryAlpha2::KH => Self::Cambodia, CountryAlpha2::CM => Self::Cameroon, CountryAlpha2::CA => Self::Canada, CountryAlpha2::KY => Self::CaymanIslands, CountryAlpha2::CF => Self::CentralAfricanRepublic, CountryAlpha2::TD => Self::Chad, CountryAlpha2::CL => Self::Chile, CountryAlpha2::CN => Self::China, CountryAlpha2::CX => Self::ChristmasIsland, CountryAlpha2::CC => Self::CocosKeelingIslands, CountryAlpha2::CO => Self::Colombia, CountryAlpha2::KM => Self::Comoros, CountryAlpha2::CG => Self::Congo, CountryAlpha2::CD => Self::CongoDemocraticRepublic, CountryAlpha2::CK => Self::CookIslands, CountryAlpha2::CR => Self::CostaRica, CountryAlpha2::CI => Self::CotedIvoire, CountryAlpha2::HR => Self::Croatia, CountryAlpha2::CU => Self::Cuba, CountryAlpha2::CW => Self::Curacao, CountryAlpha2::CY => Self::Cyprus, CountryAlpha2::CZ => Self::Czechia, CountryAlpha2::DK => Self::Denmark, CountryAlpha2::DJ => Self::Djibouti, CountryAlpha2::DM => Self::Dominica, CountryAlpha2::DO => Self::DominicanRepublic, CountryAlpha2::EC => Self::Ecuador, CountryAlpha2::EG => Self::Egypt, CountryAlpha2::SV => Self::ElSalvador, CountryAlpha2::GQ => Self::EquatorialGuinea, CountryAlpha2::ER => Self::Eritrea, CountryAlpha2::EE => Self::Estonia, CountryAlpha2::ET => Self::Ethiopia, CountryAlpha2::FK => Self::FalklandIslandsMalvinas, CountryAlpha2::FO => Self::FaroeIslands, CountryAlpha2::FJ => Self::Fiji, CountryAlpha2::FI => Self::Finland, CountryAlpha2::FR => Self::France, CountryAlpha2::GF => Self::FrenchGuiana, CountryAlpha2::PF => Self::FrenchPolynesia, CountryAlpha2::TF => Self::FrenchSouthernTerritories, CountryAlpha2::GA => Self::Gabon, CountryAlpha2::GM => Self::Gambia, CountryAlpha2::GE => Self::Georgia, CountryAlpha2::DE => Self::Germany, CountryAlpha2::GH => Self::Ghana, CountryAlpha2::GI => Self::Gibraltar, CountryAlpha2::GR => Self::Greece, CountryAlpha2::GL => Self::Greenland, CountryAlpha2::GD => Self::Grenada, CountryAlpha2::GP => Self::Guadeloupe, CountryAlpha2::GU => Self::Guam, CountryAlpha2::GT => Self::Guatemala, CountryAlpha2::GG => Self::Guernsey, CountryAlpha2::GN => Self::Guinea, CountryAlpha2::GW => Self::GuineaBissau, CountryAlpha2::GY => Self::Guyana, CountryAlpha2::HT => Self::Haiti, CountryAlpha2::HM => Self::HeardIslandAndMcDonaldIslands, CountryAlpha2::VA => Self::HolySee, CountryAlpha2::HN => Self::Honduras, CountryAlpha2::HK => Self::HongKong, CountryAlpha2::HU => Self::Hungary, CountryAlpha2::IS => Self::Iceland, CountryAlpha2::IN => Self::India, CountryAlpha2::ID => Self::Indonesia, CountryAlpha2::IR => Self::IranIslamicRepublic, CountryAlpha2::IQ => Self::Iraq, CountryAlpha2::IE => Self::Ireland, CountryAlpha2::IM => Self::IsleOfMan, CountryAlpha2::IL => Self::Israel, CountryAlpha2::IT => Self::Italy, CountryAlpha2::JM => Self::Jamaica, CountryAlpha2::JP => Self::Japan, CountryAlpha2::JE => Self::Jersey, CountryAlpha2::JO => Self::Jordan, CountryAlpha2::KZ => Self::Kazakhstan, CountryAlpha2::KE => Self::Kenya, CountryAlpha2::KI => Self::Kiribati, CountryAlpha2::KP => Self::KoreaDemocraticPeoplesRepublic, CountryAlpha2::KR => Self::KoreaRepublic, CountryAlpha2::KW => Self::Kuwait, CountryAlpha2::KG => Self::Kyrgyzstan, CountryAlpha2::LA => Self::LaoPeoplesDemocraticRepublic, CountryAlpha2::LV => Self::Latvia, CountryAlpha2::LB => Self::Lebanon, CountryAlpha2::LS => Self::Lesotho, CountryAlpha2::LR => Self::Liberia, CountryAlpha2::LY => Self::Libya, CountryAlpha2::LI => Self::Liechtenstein, CountryAlpha2::LT => Self::Lithuania, CountryAlpha2::LU => Self::Luxembourg, CountryAlpha2::MO => Self::Macao, CountryAlpha2::MK => Self::MacedoniaTheFormerYugoslavRepublic, CountryAlpha2::MG => Self::Madagascar, CountryAlpha2::MW => Self::Malawi, CountryAlpha2::MY => Self::Malaysia, CountryAlpha2::MV => Self::Maldives, CountryAlpha2::ML => Self::Mali, CountryAlpha2::MT => Self::Malta, CountryAlpha2::MH => Self::MarshallIslands, CountryAlpha2::MQ => Self::Martinique, CountryAlpha2::MR => Self::Mauritania, CountryAlpha2::MU => Self::Mauritius, CountryAlpha2::YT => Self::Mayotte, CountryAlpha2::MX => Self::Mexico, CountryAlpha2::FM => Self::MicronesiaFederatedStates, CountryAlpha2::MD => Self::MoldovaRepublic, CountryAlpha2::MC => Self::Monaco, CountryAlpha2::MN => Self::Mongolia, CountryAlpha2::ME => Self::Montenegro, CountryAlpha2::MS => Self::Montserrat, CountryAlpha2::MA => Self::Morocco, CountryAlpha2::MZ => Self::Mozambique, CountryAlpha2::MM => Self::Myanmar, CountryAlpha2::NA => Self::Namibia, CountryAlpha2::NR => Self::Nauru, CountryAlpha2::NP => Self::Nepal, CountryAlpha2::NL => Self::Netherlands, CountryAlpha2::NC => Self::NewCaledonia, CountryAlpha2::NZ => Self::NewZealand, CountryAlpha2::NI => Self::Nicaragua, CountryAlpha2::NE => Self::Niger, CountryAlpha2::NG => Self::Nigeria, CountryAlpha2::NU => Self::Niue, CountryAlpha2::NF => Self::NorfolkIsland, CountryAlpha2::MP => Self::NorthernMarianaIslands, CountryAlpha2::NO => Self::Norway, CountryAlpha2::OM => Self::Oman, CountryAlpha2::PK => Self::Pakistan, CountryAlpha2::PW => Self::Palau, CountryAlpha2::PS => Self::PalestineState, CountryAlpha2::PA => Self::Panama, CountryAlpha2::PG => Self::PapuaNewGuinea, CountryAlpha2::PY => Self::Paraguay, CountryAlpha2::PE => Self::Peru, CountryAlpha2::PH => Self::Philippines, CountryAlpha2::PN => Self::Pitcairn, CountryAlpha2::PL => Self::Poland, CountryAlpha2::PT => Self::Portugal, CountryAlpha2::PR => Self::PuertoRico, CountryAlpha2::QA => Self::Qatar, CountryAlpha2::RE => Self::Reunion, CountryAlpha2::RO => Self::Romania, CountryAlpha2::RU => Self::RussianFederation, CountryAlpha2::RW => Self::Rwanda, CountryAlpha2::BL => Self::SaintBarthelemy, CountryAlpha2::SH => Self::SaintHelenaAscensionAndTristandaCunha, CountryAlpha2::KN => Self::SaintKittsAndNevis, CountryAlpha2::LC => Self::SaintLucia, CountryAlpha2::MF => Self::SaintMartinFrenchpart, CountryAlpha2::PM => Self::SaintPierreAndMiquelon, CountryAlpha2::VC => Self::SaintVincentAndTheGrenadines, CountryAlpha2::WS => Self::Samoa, CountryAlpha2::SM => Self::SanMarino, CountryAlpha2::ST => Self::SaoTomeAndPrincipe, CountryAlpha2::SA => Self::SaudiArabia, CountryAlpha2::SN => Self::Senegal, CountryAlpha2::RS => Self::Serbia, CountryAlpha2::SC => Self::Seychelles, CountryAlpha2::SL => Self::SierraLeone, CountryAlpha2::SG => Self::Singapore, CountryAlpha2::SX => Self::SintMaartenDutchpart, CountryAlpha2::SK => Self::Slovakia, CountryAlpha2::SI => Self::Slovenia, CountryAlpha2::SB => Self::SolomonIslands, CountryAlpha2::SO => Self::Somalia, CountryAlpha2::ZA => Self::SouthAfrica, CountryAlpha2::GS => Self::SouthGeorgiaAndTheSouthSandwichIslands, CountryAlpha2::SS => Self::SouthSudan, CountryAlpha2::ES => Self::Spain, CountryAlpha2::LK => Self::SriLanka, CountryAlpha2::SD => Self::Sudan, CountryAlpha2::SR => Self::Suriname, CountryAlpha2::SJ => Self::SvalbardAndJanMayen, CountryAlpha2::SZ => Self::Swaziland, CountryAlpha2::SE => Self::Sweden, CountryAlpha2::CH => Self::Switzerland, CountryAlpha2::SY => Self::SyrianArabRepublic, CountryAlpha2::TW => Self::TaiwanProvinceOfChina, CountryAlpha2::TJ => Self::Tajikistan, CountryAlpha2::TZ => Self::TanzaniaUnitedRepublic, CountryAlpha2::TH => Self::Thailand, CountryAlpha2::TL => Self::TimorLeste, CountryAlpha2::TG => Self::Togo, CountryAlpha2::TK => Self::Tokelau, CountryAlpha2::TO => Self::Tonga, CountryAlpha2::TT => Self::TrinidadAndTobago, CountryAlpha2::TN => Self::Tunisia, CountryAlpha2::TR => Self::Turkey, CountryAlpha2::TM => Self::Turkmenistan, CountryAlpha2::TC => Self::TurksAndCaicosIslands, CountryAlpha2::TV => Self::Tuvalu, CountryAlpha2::UG => Self::Uganda, CountryAlpha2::UA => Self::Ukraine, CountryAlpha2::AE => Self::UnitedArabEmirates, CountryAlpha2::GB => Self::UnitedKingdomOfGreatBritainAndNorthernIreland, CountryAlpha2::US => Self::UnitedStatesOfAmerica, CountryAlpha2::UM => Self::UnitedStatesMinorOutlyingIslands, CountryAlpha2::UY => Self::Uruguay, CountryAlpha2::UZ => Self::Uzbekistan, CountryAlpha2::VU => Self::Vanuatu, CountryAlpha2::VE => Self::VenezuelaBolivarianRepublic, CountryAlpha2::VN => Self::Vietnam, CountryAlpha2::VG => Self::VirginIslandsBritish, CountryAlpha2::VI => Self::VirginIslandsUS, CountryAlpha2::WF => Self::WallisAndFutuna, CountryAlpha2::EH => Self::WesternSahara, CountryAlpha2::YE => Self::Yemen, CountryAlpha2::ZM => Self::Zambia, CountryAlpha2::ZW => Self::Zimbabwe, } }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 42, "total_crates": null }
fn_clm_common_enums_fmt_8736821621322496592
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/transformers // Implementation of NumericCountryCodeParseError for Display fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "Invalid Country Code") }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 38, "total_crates": null }
fn_clm_common_enums_from_-4653388397050517354
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/enums // Implementation of PaymentMethodStatus for From<AttemptStatus> fn from(attempt_status: AttemptStatus) -> Self { match attempt_status { AttemptStatus::Failure | AttemptStatus::Voided | AttemptStatus::VoidedPostCharge | AttemptStatus::Started | AttemptStatus::Pending | AttemptStatus::Unresolved | AttemptStatus::CodInitiated | AttemptStatus::Authorizing | AttemptStatus::VoidInitiated | AttemptStatus::AuthorizationFailed | AttemptStatus::RouterDeclined | AttemptStatus::AuthenticationSuccessful | AttemptStatus::PaymentMethodAwaited | AttemptStatus::AuthenticationFailed | AttemptStatus::AuthenticationPending | AttemptStatus::CaptureInitiated | AttemptStatus::CaptureFailed | AttemptStatus::VoidFailed | AttemptStatus::AutoRefunded | AttemptStatus::PartialCharged | AttemptStatus::PartialChargedAndChargeable | AttemptStatus::PartiallyAuthorized | AttemptStatus::ConfirmationAwaited | AttemptStatus::DeviceDataCollectionPending | AttemptStatus::IntegrityFailure | AttemptStatus::Expired => Self::Inactive, AttemptStatus::Charged | AttemptStatus::Authorized => Self::Active, } }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 2600, "total_crates": null }
fn_clm_common_enums_ _-4653388397050517354
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/enums // Inherent implementation for | Inten d | IntentStatus::PartiallyCapturedAndCapturable | IntentStatus::PartiallyAuthorizedAndRequiresCapture | IntentStatus::Processing | IntentStatus::RequiresCustomerAction | IntentStatus::RequiresConfirmation | IntentStatus::RequiresPaymentMethod => Self::PaymentPending, IntentStatus::RequiresMerchantAction => Self::ManualReview, IntentStatus::Cancelled | IntentStatus::CancelledPostCapture => Self::PaymentCanceled, IntentStatus::Expired => Self::PaymentPendingTimeout, IntentStatus::Failed | IntentStatus::Conflicted => Self::PaymentFailed, } } }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 158, "total_crates": null }
fn_clm_common_enums_is_success_-4653388397050517354
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/enums // Inherent implementation for PaymentResourceUpdateStatus pub fn is_success(&self) -> bool { matches!(self, Self::Success) }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 51, "total_crates": null }
fn_clm_common_enums_to_currency_base_unit_asf64_-4653388397050517354
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/enums // Implementation of None for Currency /// Convert the amount to its base denomination based on Currency and return f64 pub fn to_currency_base_unit_asf64(self, amount: i64) -> Result<f64, TryFromIntError> { let amount_f64: f64 = u32::try_from(amount)?.into(); let amount = if self.is_zero_decimal_currency() { amount_f64 } else if self.is_three_decimal_currency() { amount_f64 / 1000.00 } else { amount_f64 / 100.00 }; Ok(amount) }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 41, "total_crates": null }
fn_clm_common_enums_is_zero_decimal_currency_-4653388397050517354
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/enums // Implementation of None for Currency pub fn is_zero_decimal_currency(self) -> bool { match self { Self::BIF | Self::CLP | Self::DJF | Self::GNF | Self::IRR | Self::JPY | Self::KMF | Self::KRW | Self::MGA | Self::PYG | Self::RWF | Self::UGX | Self::VND | Self::VUV | Self::XAF | Self::XOF | Self::XPF => true, Self::AED | Self::AFN | Self::ALL | Self::AMD | Self::ANG | Self::AOA | Self::ARS | Self::AUD | Self::AWG | Self::AZN | Self::BAM | Self::BBD | Self::BDT | Self::BGN | Self::BHD | Self::BMD | Self::BND | Self::BOB | Self::BRL | Self::BSD | Self::BTN | Self::BWP | Self::BYN | Self::BZD | Self::CAD | Self::CDF | Self::CHF | Self::CLF | Self::CNY | Self::COP | Self::CRC | Self::CUC | Self::CUP | Self::CVE | Self::CZK | Self::DKK | Self::DOP | Self::DZD | Self::EGP | Self::ERN | Self::ETB | Self::EUR | Self::FJD | Self::FKP | Self::GBP | Self::GEL | Self::GHS | Self::GIP | Self::GMD | Self::GTQ | Self::GYD | Self::HKD | Self::HNL | Self::HRK | Self::HTG | Self::HUF | Self::IDR | Self::ILS | Self::INR | Self::IQD | Self::ISK | Self::JMD | Self::JOD | Self::KES | Self::KGS | Self::KHR | Self::KPW | Self::KWD | Self::KYD | Self::KZT | Self::LAK | Self::LBP | Self::LKR | Self::LRD | Self::LSL | Self::LYD | Self::MAD | Self::MDL | Self::MKD | Self::MMK | Self::MNT | Self::MOP | Self::MRU | Self::MUR | Self::MVR | Self::MWK | Self::MXN | Self::MYR | Self::MZN | Self::NAD | Self::NGN | Self::NIO | Self::NOK | Self::NPR | Self::NZD | Self::OMR | Self::PAB | Self::PEN | Self::PGK | Self::PHP | Self::PKR | Self::PLN | Self::QAR | Self::RON | Self::RSD | Self::RUB | Self::SAR | Self::SBD | Self::SCR | Self::SDG | Self::SEK | Self::SGD | Self::SHP | Self::SLE | Self::SLL | Self::SOS | Self::SRD | Self::SSP | Self::STD | Self::STN | Self::SVC | Self::SYP | Self::SZL | Self::THB | Self::TJS | Self::TMT | Self::TND | Self::TOP | Self::TRY | Self::TTD | Self::TWD | Self::TZS | Self::UAH | Self::USD | Self::UYU | Self::UZS | Self::VES | Self::WST | Self::XCD | Self::YER | Self::ZAR | Self::ZMW | Self::ZWL => false, } }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 39, "total_crates": null }
fn_clm_common_enums_deserialize_-1303504664952992440
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/enums/ui // Implementation of ElementSize for Deserialize<'de> fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de>, { struct ElementSizeVisitor; impl Visitor<'_> for ElementSizeVisitor { type Value = ElementSize; fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("a string with possible values - contain, cover or values in percentage or pixels. For eg: 48px or 50%") } fn visit_str<E>(self, value: &str) -> Result<ElementSize, E> where E: serde::de::Error, { if let Some(percent) = value.strip_suffix('%') { percent .parse::<u32>() .map(ElementSize::Percentage) .map_err(E::custom) } else if let Some(px) = value.strip_suffix("px") { px.parse::<u32>() .map(ElementSize::Pixels) .map_err(E::custom) } else { match value { "cover" => Ok(ElementSize::Variants(SizeVariants::Cover)), "contain" => Ok(ElementSize::Variants(SizeVariants::Contain)), _ => Err(E::custom("invalid size variant")), } } } } deserializer.deserialize_str(ElementSizeVisitor) }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 156, "total_crates": null }
fn_clm_common_enums_serialize_-1303504664952992440
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/enums/ui // Implementation of ElementSize for Serialize fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::ser::Serializer, { match self { Self::Variants(variant) => serializer.serialize_str(variant.to_string().as_str()), Self::Pixels(pixel_count) => { serializer.serialize_str(format!("{pixel_count}px").as_str()) } Self::Percentage(pixel_count) => { serializer.serialize_str(format!("{pixel_count}%").as_str()) } } }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 97, "total_crates": null }
fn_clm_common_enums_visit_str_-1303504664952992440
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/enums/ui // Implementation of ElementSizeVisitor for Visitor<'_> fn visit_str<E>(self, value: &str) -> Result<ElementSize, E> where E: serde::de::Error, { if let Some(percent) = value.strip_suffix('%') { percent .parse::<u32>() .map(ElementSize::Percentage) .map_err(E::custom) } else if let Some(px) = value.strip_suffix("px") { px.parse::<u32>() .map(ElementSize::Pixels) .map_err(E::custom) } else { match value { "cover" => Ok(ElementSize::Variants(SizeVariants::Cover)), "contain" => Ok(ElementSize::Variants(SizeVariants::Contain)), _ => Err(E::custom("invalid size variant")), } } }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 26, "total_crates": null }
fn_clm_common_enums_expecting_-1303504664952992440
clm
function
// Repository: hyperswitch // Crate: common_enums // Purpose: Shared enumerations across request/response and database types // Module: crates/common_enums/src/enums/ui // Implementation of ElementSizeVisitor for Visitor<'_> fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("a string with possible values - contain, cover or values in percentage or pixels. For eg: 48px or 50%") }
{ "crate": "common_enums", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 10, "total_crates": null }
fn_clm_hyperswitch_constraint_graph_new_-1830864881707238091
clm
function
// Repository: hyperswitch // Crate: hyperswitch_constraint_graph // Module: crates/hyperswitch_constraint_graph/src/types // Inherent implementation for CycleCheck pub fn new() -> Self { Self(FxHashMap::default()) }
{ "crate": "hyperswitch_constraint_graph", "file": null, "file_size": null, "is_async": false, "is_pub": true, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14467, "total_crates": null }