id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
connector-service_fn_connector-integration_663277235311379812
clm
function
// connector-service/backend/connector-integration/src/connectors/novalnet/transformers.rs pub fn get_incoming_webhook_event( status: WebhookEventType, transaction_status: NovalnetTransactionStatus, ) -> EventType { match status { WebhookEventType::Payment => match transaction_status { NovalnetTransactionStatus::Confirmed | NovalnetTransactionStatus::Success => { EventType::PaymentIntentSuccess } NovalnetTransactionStatus::OnHold => EventType::PaymentIntentAuthorizationSuccess, NovalnetTransactionStatus::Pending => EventType::PaymentIntentProcessing, NovalnetTransactionStatus::Progress => EventType::IncomingWebhookEventUnspecified, _ => EventType::PaymentIntentFailure, }, WebhookEventType::TransactionCapture => match transaction_status { NovalnetTransactionStatus::Confirmed | NovalnetTransactionStatus::Success => { EventType::PaymentIntentCaptureSuccess } _ => EventType::PaymentIntentCaptureFailure, }, WebhookEventType::TransactionCancel => match transaction_status { NovalnetTransactionStatus::Deactivated => EventType::PaymentIntentCancelled, _ => EventType::PaymentIntentCancelFailure, }, WebhookEventType::TransactionRefund => match transaction_status { NovalnetTransactionStatus::Confirmed | NovalnetTransactionStatus::Success => { EventType::RefundSuccess } _ => EventType::RefundFailure, }, WebhookEventType::Chargeback => EventType::DisputeOpened, WebhookEventType::Credit => EventType::DisputeWon, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_incoming_webhook_event", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-6952957663247157186
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/test.rs fn test_build_request_valid() { let api_key = "test_adyen_api_key".to_string(); // Hardcoded dummy value let key1 = "test_adyen_key1".to_string(); // Hardcoded dummy value let req: RouterDataV2< Authorize, PaymentFlowData, PaymentsAuthorizeData<DefaultPCIHolder>, PaymentsResponseData, > = RouterDataV2 { flow: PhantomData::<domain_types::connector_flow::Authorize>, resource_common_data: PaymentFlowData { merchant_id: common_utils::id_type::MerchantId::default(), customer_id: None, connector_customer: Some("conn_cust_987654".to_string()), payment_id: "pay_abcdef123456".to_string(), attempt_id: "attempt_123456abcdef".to_string(), status: common_enums::AttemptStatus::Pending, payment_method: common_enums::PaymentMethod::Card, description: Some("Payment for order #12345".to_string()), return_url: Some("www.google.com".to_string()), address: domain_types::payment_address::PaymentAddress::new( None, None, None, None, ), auth_type: common_enums::AuthenticationType::ThreeDs, connector_meta_data: None, amount_captured: None, minor_amount_captured: None, access_token: None, session_token: None, reference_id: None, payment_method_token: None, preprocessing_id: None, connector_api_version: None, connector_request_reference_id: "conn_ref_123456789".to_string(), test_mode: None, connector_http_status_code: None, connectors: Connectors { adyen: ConnectorParams { base_url: "https://checkout-test.adyen.com/".to_string(), dispute_base_url: Some("https://ca-test.adyen.com/ca/services/DisputeService/v30/defendDispute".to_string()), ..Default::default() }, ..Default::default() }, external_latency: None, connector_response_headers: None, raw_connector_response: None, vault_headers: None, raw_connector_request: None, minor_amount_capturable: None, connector_response: None, recurring_mandate_payment_data: None, }, connector_auth_type: ConnectorAuthType::BodyKey { api_key: Secret::new(api_key), key1: Secret::new(key1), }, request: PaymentsAuthorizeData { authentication_data: None, payment_method_data: PaymentMethodData::Card( domain_types::payment_method_data::Card { card_number: RawCardNumber(cards::CardNumber::from_str( "5123456789012346", ) .unwrap()), card_cvc: Secret::new("100".into()), card_exp_month: Secret::new("03".into()), card_exp_year: Secret::new("2030".into()), ..Default::default() }, ), amount: 1000, order_tax_amount: None, email: Some( Email::try_from("test@example.com".to_string()) .expect("Failed to parse email"), ), customer_name: None, currency: common_enums::Currency::USD, confirm: true, statement_descriptor_suffix: None, statement_descriptor: None, capture_method: None, integrity_object: None, router_return_url: Some("www.google.com".to_string()), webhook_url: None, complete_authorize_url: None, mandate_id: None, setup_future_usage: None, off_session: None, browser_info: Some( domain_types::router_request_types::BrowserInformation { color_depth: None, java_enabled: Some(false), screen_height: Some(1080), screen_width: Some(1920), user_agent: Some( "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)".to_string(), ), accept_header: Some( "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" .to_string(), ), java_script_enabled: Some(false), language: Some("en-US".to_string()), time_zone: None, referer: None, ip_address: None, os_type: None, os_version: None, device_model: None, accept_language: None, }, ), order_category: None, session_token: None, enrolled_for_3ds: true, related_transaction_id: None, payment_experience: None, payment_method_type: Some(common_enums::PaymentMethodType::Credit), customer_id: Some( common_utils::id_type::CustomerId::try_from(Cow::from( "cus_123456789".to_string(), )) .unwrap(), ), request_incremental_authorization: false, metadata: None, minor_amount: MinorUnit::new(1000), merchant_order_reference_id: None, shipping_cost: None, merchant_account_id: None, merchant_config_currency: None, all_keys_required: None, access_token: None, customer_acceptance: None, split_payments: None, request_extended_authorization: None, setup_mandate_details: None, enable_overcapture: None, merchant_account_metadata: None, }, response: Err(ErrorResponse::default()), }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Adyen::new()); let connector_data = ConnectorData { connector, connector_name: ConnectorEnum::Adyen, }; let connector_integration: BoxedConnectorIntegrationV2< '_, Authorize, PaymentFlowData, PaymentsAuthorizeData<DefaultPCIHolder>, PaymentsResponseData, > = connector_data.connector.get_connector_integration_v2(); let request = connector_integration.build_request_v2(&req).unwrap(); let req_body = request.as_ref().map(|request_val| { let masked_request = match request_val.body.as_ref() { Some(request_content) => match request_content { RequestContent::Json(i) | RequestContent::FormUrlEncoded(i) | RequestContent::Xml(i) => i.masked_serialize().unwrap_or( json!({ "error": "failed to mask serialize connector request"}), ), RequestContent::FormData(_) => json!({"request_type": "FORM_DATA"}), RequestContent::RawBytes(_) => json!({"request_type": "RAW_BYTES"}), }, None => serde_json::Value::Null, }; masked_request }); println!("request: {req_body:?}"); assert_eq!( req_body.as_ref().unwrap()["reference"], "conn_ref_123456789" ); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_build_request_valid", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-5681562439064172875
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/test.rs fn test_build_request_missing() { let api_key = "test_adyen_api_key_missing".to_string(); // Hardcoded dummy value let key1 = "test_adyen_key1_missing".to_string(); // Hardcoded dummy value let req: RouterDataV2< Authorize, PaymentFlowData, PaymentsAuthorizeData<DefaultPCIHolder>, PaymentsResponseData, > = RouterDataV2 { flow: PhantomData::<Authorize>, resource_common_data: PaymentFlowData { merchant_id: common_utils::id_type::MerchantId::default(), customer_id: None, connector_customer: None, payment_id: "".to_string(), attempt_id: "".to_string(), status: common_enums::AttemptStatus::Pending, payment_method: common_enums::PaymentMethod::Card, description: None, return_url: None, address: domain_types::payment_address::PaymentAddress::new( None, None, None, None, ), auth_type: common_enums::AuthenticationType::ThreeDs, connector_meta_data: None, amount_captured: None, minor_amount_captured: None, access_token: None, session_token: None, reference_id: None, payment_method_token: None, preprocessing_id: None, connector_api_version: None, connector_request_reference_id: "".to_string(), test_mode: None, connector_http_status_code: None, connectors: Connectors { adyen: ConnectorParams { base_url: "https://checkout-test.adyen.com/".to_string(), dispute_base_url: Some("https://ca-test.adyen.com/ca/services/DisputeService/v30/defendDispute".to_string()), ..Default::default() }, ..Default::default() }, external_latency: None, connector_response_headers: None, raw_connector_response: None, vault_headers: None, raw_connector_request: None, minor_amount_capturable: None, connector_response: None, recurring_mandate_payment_data: None, }, connector_auth_type: ConnectorAuthType::BodyKey { api_key: Secret::new(api_key), key1: Secret::new(key1), }, request: PaymentsAuthorizeData { authentication_data: None, payment_method_data: PaymentMethodData::Card(Default::default()), amount: 0, order_tax_amount: None, email: None, customer_name: None, currency: common_enums::Currency::USD, confirm: true, statement_descriptor_suffix: None, statement_descriptor: None, capture_method: None, router_return_url: None, webhook_url: None, complete_authorize_url: None, mandate_id: None, setup_future_usage: None, off_session: None, browser_info: None, integrity_object: None, order_category: None, session_token: None, enrolled_for_3ds: false, related_transaction_id: None, payment_experience: None, payment_method_type: None, customer_id: None, request_incremental_authorization: false, metadata: None, minor_amount: MinorUnit::new(0), merchant_order_reference_id: None, shipping_cost: None, merchant_account_id: None, merchant_config_currency: None, all_keys_required: None, access_token: None, customer_acceptance: None, split_payments: None, request_extended_authorization: None, setup_mandate_details: None, enable_overcapture: None, merchant_account_metadata: None, }, response: Err(ErrorResponse::default()), }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Adyen::new()); let connector_data = ConnectorData { connector, connector_name: ConnectorEnum::Adyen, }; let connector_integration: BoxedConnectorIntegrationV2< '_, Authorize, PaymentFlowData, PaymentsAuthorizeData<DefaultPCIHolder>, PaymentsResponseData, > = connector_data.connector.get_connector_integration_v2(); let result = connector_integration.build_request_v2(&req); assert!(result.is_err(), "Expected error for missing fields"); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_build_request_missing", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-4241795342393484524
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn from( item: &RouterDataV2< SetupMandate, PaymentFlowData, SetupMandateRequestData<T>, PaymentsResponseData, >, ) -> Self { match item.request.off_session { Some(true) => Self::ContinuedAuthentication, _ => Self::Ecommerce, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_167136384757826940
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn try_from( value: ResponseRouterData<AdyenDefendDisputeResponse, Self>, ) -> Result<Self, Self::Error> { let ResponseRouterData { response, router_data, http_code, } = value; match response { AdyenDefendDisputeResponse::DefendDisputeSuccessResponse(result) => { let dispute_status = if result.dispute_service_result.success { common_enums::DisputeStatus::DisputeWon } else { common_enums::DisputeStatus::DisputeLost }; Ok(Self { response: Ok(DisputeResponseData { dispute_status, connector_dispute_status: None, connector_dispute_id: router_data .resource_common_data .connector_dispute_id .clone(), status_code: http_code, }), ..router_data }) } AdyenDefendDisputeResponse::DefendDisputeFailedResponse(result) => Ok(Self { response: Err(ErrorResponse { code: result.error_code, message: result.message.clone(), reason: Some(result.message), status_code: http_code, attempt_status: None, connector_transaction_id: Some(result.psp_reference), network_decline_code: None, network_advice_code: None, network_error_message: None, }), ..router_data }), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_8179419796355489933
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn get_amount_data< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( item: &AdyenRouterData< RouterDataV2<Authorize, PaymentFlowData, PaymentsAuthorizeData<T>, PaymentsResponseData>, T, >, ) -> Amount { Amount { currency: item.router_data.request.currency, value: item.router_data.request.minor_amount.to_owned(), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_amount_data", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_7518099285019130191
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn get_adyen_payment_status( is_manual_capture: bool, adyen_status: AdyenStatus, _pmt: Option<common_enums::PaymentMethodType>, ) -> AttemptStatus { match adyen_status { AdyenStatus::AuthenticationFinished => AttemptStatus::AuthenticationSuccessful, AdyenStatus::AuthenticationNotRequired | AdyenStatus::Received => AttemptStatus::Pending, AdyenStatus::Authorised => match is_manual_capture { true => AttemptStatus::Authorized, // In case of Automatic capture Authorized is the final status of the payment false => AttemptStatus::Charged, }, AdyenStatus::Cancelled => AttemptStatus::Voided, AdyenStatus::ChallengeShopper | AdyenStatus::RedirectShopper | AdyenStatus::PresentToShopper => AttemptStatus::AuthenticationPending, AdyenStatus::Error | AdyenStatus::Refused => AttemptStatus::Failure, AdyenStatus::Pending => AttemptStatus::Pending, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_adyen_payment_status", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-7674069107723274930
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn foreign_try_from(item: AdyenVoidStatus) -> Result<Self, Self::Error> { match item { AdyenVoidStatus::Received => Ok(Self::Voided), AdyenVoidStatus::Processing => Ok(Self::VoidInitiated), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "foreign_try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5367736282980672519
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs pub fn get_adyen_response( response: AdyenResponse, is_capture_manual: bool, status_code: u16, pmt: Option<common_enums::PaymentMethodType>, ) -> CustomResult< ( common_enums::AttemptStatus, Option<domain_types::router_data::ErrorResponse>, PaymentsResponseData, ), domain_types::errors::ConnectorError, > { let status = get_adyen_payment_status(is_capture_manual, response.result_code, pmt); let error = if response.refusal_reason.is_some() || response.refusal_reason_code.is_some() || status == common_enums::AttemptStatus::Failure { Some(domain_types::router_data::ErrorResponse { code: response .refusal_reason_code .unwrap_or_else(|| NO_ERROR_CODE.to_string()), message: response .refusal_reason .clone() .unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()), reason: response.refusal_reason, status_code, attempt_status: Some(common_enums::AttemptStatus::Failure), connector_transaction_id: Some(response.psp_reference.clone()), network_decline_code: None, network_advice_code: None, network_error_message: None, }) } else { None }; let mandate_reference = response .additional_data .as_ref() .and_then(|data| data.recurring_detail_reference.to_owned()) .map(|mandate_id| MandateReference { connector_mandate_id: Some(mandate_id.expose()), payment_method_id: None, }); let network_txn_id = response.additional_data.and_then(|additional_data| { additional_data .network_tx_reference .map(|network_tx_id| network_tx_id.expose()) }); let payments_response_data = PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(response.psp_reference), redirection_data: None, connector_metadata: None, network_txn_id, connector_response_reference_id: Some(response.merchant_reference), incremental_authorization_allowed: None, mandate_reference: mandate_reference.map(Box::new), status_code, }; Ok((status, error, payments_response_data)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_adyen_response", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_2801762041728564160
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs pub fn get_redirection_response( response: RedirectionResponse, is_manual_capture: bool, status_code: u16, pmt: Option<common_enums::PaymentMethodType>, ) -> CustomResult< ( common_enums::AttemptStatus, Option<ErrorResponse>, PaymentsResponseData, ), domain_types::errors::ConnectorError, > { let status = get_adyen_payment_status(is_manual_capture, response.result_code.clone(), pmt); let error = if response.refusal_reason.is_some() || response.refusal_reason_code.is_some() || status == common_enums::AttemptStatus::Failure { Some(ErrorResponse { code: response .refusal_reason_code .clone() .unwrap_or_else(|| NO_ERROR_CODE.to_string()), message: response .refusal_reason .clone() .unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()), reason: response.refusal_reason.to_owned(), status_code, attempt_status: None, connector_transaction_id: response.psp_reference.clone(), network_decline_code: None, network_advice_code: None, network_error_message: None, }) } else { None }; let redirection_data = response.action.url.clone().map(|url| { let form_fields = response.action.data.clone().unwrap_or_else(|| { std::collections::HashMap::from_iter( url.query_pairs() .map(|(key, value)| (key.to_string(), value.to_string())), ) }); RedirectForm::Form { endpoint: url.to_string(), method: response.action.method.unwrap_or(Method::Get), form_fields, } }); let connector_metadata = get_wait_screen_metadata(&response)?; let payments_response_data = PaymentsResponseData::TransactionResponse { resource_id: match response.psp_reference.as_ref() { Some(psp) => ResponseId::ConnectorTransactionId(psp.to_string()), None => ResponseId::NoResponseId, }, redirection_data: redirection_data.map(Box::new), connector_metadata, network_txn_id: None, connector_response_reference_id: response .merchant_reference .clone() .or(response.psp_reference), incremental_authorization_allowed: None, mandate_reference: None, status_code, }; Ok((status, error, payments_response_data)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_redirection_response", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_6071155414175732482
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs pub fn get_wait_screen_metadata( next_action: &RedirectionResponse, ) -> CustomResult<Option<serde_json::Value>, domain_types::errors::ConnectorError> { match next_action.action.payment_method_type { PaymentType::Blik => { let current_time = OffsetDateTime::now_utc().unix_timestamp_nanos(); Ok(Some(serde_json::json!(WaitScreenData { display_from_timestamp: current_time, display_to_timestamp: Some(current_time + Duration::minutes(1).whole_nanoseconds()) }))) } PaymentType::Mbway => { let current_time = OffsetDateTime::now_utc().unix_timestamp_nanos(); Ok(Some(serde_json::json!(WaitScreenData { display_from_timestamp: current_time, display_to_timestamp: None }))) } PaymentType::Affirm | PaymentType::Oxxo | PaymentType::Afterpaytouch | PaymentType::Alipay | PaymentType::AlipayHk | PaymentType::Alfamart | PaymentType::Alma | PaymentType::Applepay | PaymentType::Bizum | PaymentType::Atome | PaymentType::BoletoBancario | PaymentType::ClearPay | PaymentType::Dana | PaymentType::Eps | PaymentType::Gcash | PaymentType::Googlepay | PaymentType::GoPay | PaymentType::Ideal | PaymentType::Indomaret | PaymentType::Klarna | PaymentType::Kakaopay | PaymentType::MobilePay | PaymentType::Momo | PaymentType::MomoAtm | PaymentType::OnlineBankingCzechRepublic | PaymentType::OnlineBankingFinland | PaymentType::OnlineBankingPoland | PaymentType::OnlineBankingSlovakia | PaymentType::OnlineBankingFpx | PaymentType::OnlineBankingThailand | PaymentType::OpenBankingUK | PaymentType::PayBright | PaymentType::Paypal | PaymentType::Scheme | PaymentType::NetworkToken | PaymentType::Trustly | PaymentType::TouchNGo | PaymentType::Walley | PaymentType::WeChatPayWeb | PaymentType::AchDirectDebit | PaymentType::SepaDirectDebit | PaymentType::BacsDirectDebit | PaymentType::Samsungpay | PaymentType::Twint | PaymentType::Vipps | PaymentType::Swish | PaymentType::Knet | PaymentType::Benefit | PaymentType::PermataBankTransfer | PaymentType::BcaBankTransfer | PaymentType::BniVa | PaymentType::BriVa | PaymentType::CimbVa | PaymentType::DanamonVa | PaymentType::Giftcard | PaymentType::MandiriVa | PaymentType::PaySafeCard | PaymentType::SevenEleven | PaymentType::Lawson => Ok(None), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_wait_screen_metadata", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_3561066937783713324
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn is_success_scenario(is_success: &str) -> bool { is_success == "true" }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "is_success_scenario", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-3798901867030574420
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs pub(crate) fn get_adyen_payment_webhook_event( code: WebhookEventCode, is_success: String, ) -> Result<AttemptStatus, errors::ConnectorError> { match code { WebhookEventCode::Authorisation => { if is_success_scenario(&is_success) { Ok(AttemptStatus::Authorized) } else { Ok(AttemptStatus::Failure) } } WebhookEventCode::Cancellation => { if is_success_scenario(&is_success) { Ok(AttemptStatus::Voided) } else { Ok(AttemptStatus::Authorized) } } WebhookEventCode::Capture => { if is_success_scenario(&is_success) { Ok(AttemptStatus::Charged) } else { Ok(AttemptStatus::Failure) } } WebhookEventCode::CaptureFailed => Ok(AttemptStatus::Failure), _ => Err(errors::ConnectorError::RequestEncodingFailed), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_adyen_payment_webhook_event", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-6403774252104309111
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs pub(crate) fn get_adyen_refund_webhook_event( code: WebhookEventCode, is_success: String, ) -> Result<RefundStatus, errors::ConnectorError> { match code { WebhookEventCode::Refund | WebhookEventCode::CancelOrRefund => { if is_success_scenario(&is_success) { Ok(RefundStatus::Success) } else { Ok(RefundStatus::Failure) } } WebhookEventCode::RefundFailed | WebhookEventCode::RefundReversed => { Ok(RefundStatus::Failure) } _ => Err(errors::ConnectorError::RequestEncodingFailed), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_adyen_refund_webhook_event", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_7571493179599046255
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs pub(crate) fn get_adyen_webhook_event_type(code: WebhookEventCode) -> EventType { match code { WebhookEventCode::Authorisation => EventType::PaymentIntentAuthorizationSuccess, WebhookEventCode::Cancellation => EventType::PaymentIntentCancelled, WebhookEventCode::Capture => EventType::PaymentIntentCaptureSuccess, WebhookEventCode::CaptureFailed => EventType::PaymentIntentCaptureFailure, WebhookEventCode::Refund | WebhookEventCode::CancelOrRefund => EventType::RefundSuccess, WebhookEventCode::RefundFailed | WebhookEventCode::RefundReversed => { EventType::RefundFailure } WebhookEventCode::NotificationOfChargeback | WebhookEventCode::Chargeback => { EventType::DisputeOpened } WebhookEventCode::ChargebackReversed | WebhookEventCode::PrearbitrationWon => { EventType::DisputeWon } WebhookEventCode::SecondChargeback | WebhookEventCode::PrearbitrationLost => { EventType::DisputeLost } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_adyen_webhook_event_type", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-1298008982947510298
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs pub fn get_webhook_object_from_body( body: Vec<u8>, ) -> Result<AdyenNotificationRequestItemWH, error_stack::Report<errors::ConnectorError>> { let mut webhook: AdyenIncomingWebhook = body .parse_struct("AdyenIncomingWebhook") .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; let item_object = webhook .notification_items .drain(..) .next() .ok_or(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(item_object.notification_request_item) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_webhook_object_from_body", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-7646778122907162140
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn build_shopper_reference( customer_id: &Option<common_utils::id_type::CustomerId>, merchant_id: common_utils::id_type::MerchantId, ) -> Option<String> { customer_id.clone().map(|c_id| { format!( "{}_{}", merchant_id.get_string_repr(), c_id.get_string_repr() ) }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "build_shopper_reference", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-8386024224868229444
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn get_recurring_processing_model< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( item: &RouterDataV2<Authorize, PaymentFlowData, PaymentsAuthorizeData<T>, PaymentsResponseData>, ) -> Result<RecurringDetails, Error> { let customer_id = item .request .customer_id .clone() .ok_or_else(Box::new(move || { errors::ConnectorError::MissingRequiredField { field_name: "customer_id", } }))?; match (item.request.setup_future_usage, item.request.off_session) { (Some(common_enums::FutureUsage::OffSession), _) => { let shopper_reference = format!( "{}_{}", item.resource_common_data.merchant_id.get_string_repr(), customer_id.get_string_repr() ); let store_payment_method = is_mandate_payment(item); Ok(( Some(AdyenRecurringModel::UnscheduledCardOnFile), Some(store_payment_method), Some(shopper_reference), )) } (_, Some(true)) => Ok(( Some(AdyenRecurringModel::UnscheduledCardOnFile), None, Some(format!( "{}_{}", item.resource_common_data.merchant_id.get_string_repr(), customer_id.get_string_repr() )), )), _ => Ok((None, None, None)), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_recurring_processing_model", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-8798471421830085579
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn is_mandate_payment< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( item: &RouterDataV2<Authorize, PaymentFlowData, PaymentsAuthorizeData<T>, PaymentsResponseData>, ) -> bool { (item.request.setup_future_usage == Some(common_enums::FutureUsage::OffSession)) || item .request .mandate_id .as_ref() .and_then(|mandate_ids| mandate_ids.mandate_reference_id.as_ref()) .is_some() }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "is_mandate_payment", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_78658032047515618
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs pub fn get_address_info( address: Option<&domain_types::payment_address::Address>, ) -> Option<Result<Address, error_stack::Report<domain_types::errors::ConnectorError>>> { address.and_then(|add| { add.address.as_ref().map( |a| -> Result<Address, error_stack::Report<domain_types::errors::ConnectorError>> { Ok(Address { city: a.city.clone().unwrap(), country: a.country.unwrap(), house_number_or_name: a.line1.clone().unwrap(), postal_code: a.zip.clone().unwrap(), state_or_province: a.state.clone(), street: a.line2.clone(), }) }, ) }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_address_info", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2107408566965000745
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn get_additional_data< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( item: &RouterDataV2<Authorize, PaymentFlowData, PaymentsAuthorizeData<T>, PaymentsResponseData>, ) -> Option<AdditionalData> { let (authorisation_type, manual_capture) = match item.request.capture_method { Some(common_enums::CaptureMethod::Manual) | Some(common_enums::CaptureMethod::ManualMultiple) => { (Some(AuthType::PreAuth), Some("true".to_string())) } _ => (None, None), }; let riskdata = item.request.metadata.clone().and_then(get_risk_data); let execute_three_d = if matches!( item.resource_common_data.auth_type, common_enums::AuthenticationType::ThreeDs ) { Some("true".to_string()) } else { None }; if authorisation_type.is_none() && manual_capture.is_none() && execute_three_d.is_none() && riskdata.is_none() { //without this if-condition when the above 3 values are None, additionalData will be serialized to JSON like this -> additionalData: {} //returning None, ensures that additionalData key will not be present in the serialized JSON None } else { Some(AdditionalData { authorisation_type, manual_capture, execute_three_d, network_tx_reference: None, recurring_detail_reference: None, recurring_shopper_reference: None, recurring_processing_model: None, riskdata, ..AdditionalData::default() }) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_additional_data", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_6960544220320963518
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs pub fn get_risk_data(metadata: serde_json::Value) -> Option<RiskData> { let item_i_d = get_str("riskdata.basket.item1.itemID", &metadata); let product_title = get_str("riskdata.basket.item1.productTitle", &metadata); let amount_per_item = get_str("riskdata.basket.item1.amountPerItem", &metadata); let currency = get_str("riskdata.basket.item1.currency", &metadata); let upc = get_str("riskdata.basket.item1.upc", &metadata); let brand = get_str("riskdata.basket.item1.brand", &metadata); let manufacturer = get_str("riskdata.basket.item1.manufacturer", &metadata); let category = get_str("riskdata.basket.item1.category", &metadata); let quantity = get_str("riskdata.basket.item1.quantity", &metadata); let color = get_str("riskdata.basket.item1.color", &metadata); let size = get_str("riskdata.basket.item1.size", &metadata); let device_country = get_str("riskdata.deviceCountry", &metadata); let house_numberor_name = get_str("riskdata.houseNumberorName", &metadata); let account_creation_date = get_str("riskdata.accountCreationDate", &metadata); let affiliate_channel = get_str("riskdata.affiliateChannel", &metadata); let avg_order_value = get_str("riskdata.avgOrderValue", &metadata); let delivery_method = get_str("riskdata.deliveryMethod", &metadata); let email_name = get_str("riskdata.emailName", &metadata); let email_domain = get_str("riskdata.emailDomain", &metadata); let last_order_date = get_str("riskdata.lastOrderDate", &metadata); let merchant_reference = get_str("riskdata.merchantReference", &metadata); let payment_method = get_str("riskdata.paymentMethod", &metadata); let promotion_name = get_str("riskdata.promotionName", &metadata); let secondary_phone_number = get_str("riskdata.secondaryPhoneNumber", &metadata); let timefrom_loginto_order = get_str("riskdata.timefromLogintoOrder", &metadata); let total_session_time = get_str("riskdata.totalSessionTime", &metadata); let total_authorized_amount_in_last30_days = get_str("riskdata.totalAuthorizedAmountInLast30Days", &metadata); let total_order_quantity = get_str("riskdata.totalOrderQuantity", &metadata); let total_lifetime_value = get_str("riskdata.totalLifetimeValue", &metadata); let visits_month = get_str("riskdata.visitsMonth", &metadata); let visits_week = get_str("riskdata.visitsWeek", &metadata); let visits_year = get_str("riskdata.visitsYear", &metadata); let ship_to_name = get_str("riskdata.shipToName", &metadata); let first8charactersof_address_line1_zip = get_str("riskdata.first8charactersofAddressLine1Zip", &metadata); let affiliate_order = get_bool("riskdata.affiliateOrder", &metadata); Some(RiskData { item_i_d, product_title, amount_per_item, currency, upc, brand, manufacturer, category, quantity, color, size, device_country, house_numberor_name, account_creation_date, affiliate_channel, avg_order_value, delivery_method, email_name, email_domain, last_order_date, merchant_reference, payment_method, promotion_name, secondary_phone_number: secondary_phone_number.map(Secret::new), timefrom_loginto_order, total_session_time, total_authorized_amount_in_last30_days, total_order_quantity, total_lifetime_value, visits_month, visits_week, visits_year, ship_to_name, first8charactersof_address_line1_zip, affiliate_order, }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_risk_data", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_8517754732124571319
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn get_str(key: &str, riskdata: &serde_json::Value) -> Option<String> { riskdata .get(key) .and_then(|v| v.as_str()) .map(|s| s.to_string()) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_str", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_3605896462610306993
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn get_bool(key: &str, riskdata: &serde_json::Value) -> Option<bool> { riskdata.get(key).and_then(|v| v.as_bool()) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_bool", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5334923471569566333
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn get_amount_data_for_setup_mandate< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( item: &AdyenRouterData< RouterDataV2< SetupMandate, PaymentFlowData, SetupMandateRequestData<T>, PaymentsResponseData, >, T, >, ) -> Amount { Amount { currency: item.router_data.request.currency, value: MinorUnit::new(item.router_data.request.amount.unwrap_or(0)), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_amount_data_for_setup_mandate", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5705254874498825781
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn get_recurring_processing_model_for_setup_mandate< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( item: &RouterDataV2< SetupMandate, PaymentFlowData, SetupMandateRequestData<T>, PaymentsResponseData, >, ) -> Result<RecurringDetails, Error> { let customer_id = item .request .customer_id .clone() .ok_or_else(Box::new(move || { errors::ConnectorError::MissingRequiredField { field_name: "customer_id", } }))?; match (item.request.setup_future_usage, item.request.off_session) { (Some(common_enums::FutureUsage::OffSession), _) => { let shopper_reference = format!( "{}_{}", item.resource_common_data.merchant_id.get_string_repr(), customer_id.get_string_repr() ); let store_payment_method = is_mandate_payment_for_setup_mandate(item); Ok(( Some(AdyenRecurringModel::UnscheduledCardOnFile), Some(store_payment_method), Some(shopper_reference), )) } (_, Some(true)) => Ok(( Some(AdyenRecurringModel::UnscheduledCardOnFile), None, Some(format!( "{}_{}", item.resource_common_data.merchant_id.get_string_repr(), customer_id.get_string_repr() )), )), _ => Ok((None, None, None)), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_recurring_processing_model_for_setup_mandate", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_6768865710378008378
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn get_additional_data_for_setup_mandate< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( item: &RouterDataV2< SetupMandate, PaymentFlowData, SetupMandateRequestData<T>, PaymentsResponseData, >, ) -> Option<AdditionalData> { let (authorisation_type, manual_capture) = match item.request.capture_method { Some(common_enums::CaptureMethod::Manual) | Some(common_enums::CaptureMethod::ManualMultiple) => { (Some(AuthType::PreAuth), Some("true".to_string())) } _ => (None, None), }; let riskdata = item.request.metadata.clone().and_then(get_risk_data); let execute_three_d = if matches!( item.resource_common_data.auth_type, common_enums::AuthenticationType::ThreeDs ) { Some("true".to_string()) } else { None }; if authorisation_type.is_none() && manual_capture.is_none() && execute_three_d.is_none() && riskdata.is_none() { //without this if-condition when the above 3 values are None, additionalData will be serialized to JSON like this -> additionalData: {} //returning None, ensures that additionalData key will not be present in the serialized JSON None } else { Some(AdditionalData { authorisation_type, manual_capture, execute_three_d, network_tx_reference: None, recurring_detail_reference: None, recurring_shopper_reference: None, recurring_processing_model: None, riskdata, ..AdditionalData::default() }) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_additional_data_for_setup_mandate", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_7767464531085360465
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn is_mandate_payment_for_setup_mandate< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( item: &RouterDataV2< SetupMandate, PaymentFlowData, SetupMandateRequestData<T>, PaymentsResponseData, >, ) -> bool { (item.request.setup_future_usage == Some(common_enums::FutureUsage::OffSession)) || item .request .mandate_id .as_ref() .and_then(|mandate_ids| mandate_ids.mandate_reference_id.as_ref()) .is_some() }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "is_mandate_payment_for_setup_mandate", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1903287790605873704
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn get_defence_documents(item: SubmitEvidenceData) -> Option<Vec<DefenseDocuments>> { let mut defense_documents: Vec<DefenseDocuments> = Vec::new(); if let Some(shipping_documentation) = item.shipping_documentation { defense_documents.push(DefenseDocuments { content: get_content(shipping_documentation).into(), content_type: item.shipping_documentation_provider_file_id, defense_document_type_code: "DefenseMaterial".into(), }) } if let Some(receipt) = item.receipt { defense_documents.push(DefenseDocuments { content: get_content(receipt).into(), content_type: item.receipt_file_type, defense_document_type_code: "DefenseMaterial".into(), }) } if let Some(invoice_showing_distinct_transactions) = item.invoice_showing_distinct_transactions { defense_documents.push(DefenseDocuments { content: get_content(invoice_showing_distinct_transactions).into(), content_type: item.invoice_showing_distinct_transactions_file_type, defense_document_type_code: "DefenseMaterial".into(), }) } if let Some(customer_communication) = item.customer_communication { defense_documents.push(DefenseDocuments { content: get_content(customer_communication).into(), content_type: item.customer_communication_file_type, defense_document_type_code: "DefenseMaterial".into(), }) } if let Some(refund_policy) = item.refund_policy { defense_documents.push(DefenseDocuments { content: get_content(refund_policy).into(), content_type: item.refund_policy_file_type, defense_document_type_code: "DefenseMaterial".into(), }) } if let Some(recurring_transaction_agreement) = item.recurring_transaction_agreement { defense_documents.push(DefenseDocuments { content: get_content(recurring_transaction_agreement).into(), content_type: item.recurring_transaction_agreement_file_type, defense_document_type_code: "DefenseMaterial".into(), }) } if let Some(uncategorized_file) = item.uncategorized_file { defense_documents.push(DefenseDocuments { content: get_content(uncategorized_file).into(), content_type: item.uncategorized_file_type, defense_document_type_code: "DefenseMaterial".into(), }) } if let Some(cancellation_policy) = item.cancellation_policy { defense_documents.push(DefenseDocuments { content: get_content(cancellation_policy).into(), content_type: item.cancellation_policy_file_type, defense_document_type_code: "DefenseMaterial".into(), }) } if let Some(customer_signature) = item.customer_signature { defense_documents.push(DefenseDocuments { content: get_content(customer_signature).into(), content_type: item.customer_signature_file_type, defense_document_type_code: "DefenseMaterial".into(), }) } if let Some(service_documentation) = item.service_documentation { defense_documents.push(DefenseDocuments { content: get_content(service_documentation).into(), content_type: item.service_documentation_file_type, defense_document_type_code: "DefenseMaterial".into(), }) } if defense_documents.is_empty() { None } else { Some(defense_documents) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_defence_documents", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_844114116097667743
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs fn get_content(item: Vec<u8>) -> String { STANDARD.encode(item) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_content", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_4575633659855848483
clm
function
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs pub(crate) fn get_dispute_stage_and_status( code: WebhookEventCode, dispute_status: Option<DisputeStatus>, ) -> (common_enums::DisputeStage, common_enums::DisputeStatus) { use common_enums::{DisputeStage, DisputeStatus as HSDisputeStatus}; match code { WebhookEventCode::NotificationOfChargeback => { (DisputeStage::PreDispute, HSDisputeStatus::DisputeOpened) } WebhookEventCode::Chargeback => { let status = match dispute_status { Some(DisputeStatus::Undefended) | Some(DisputeStatus::Pending) => { HSDisputeStatus::DisputeOpened } Some(DisputeStatus::Lost) | None => HSDisputeStatus::DisputeLost, Some(DisputeStatus::Accepted) => HSDisputeStatus::DisputeAccepted, Some(DisputeStatus::Won) => HSDisputeStatus::DisputeWon, }; (DisputeStage::Dispute, status) } WebhookEventCode::ChargebackReversed => { let status = match dispute_status { Some(DisputeStatus::Pending) => HSDisputeStatus::DisputeChallenged, _ => HSDisputeStatus::DisputeWon, }; (DisputeStage::Dispute, status) } WebhookEventCode::SecondChargeback => { (DisputeStage::PreArbitration, HSDisputeStatus::DisputeLost) } WebhookEventCode::PrearbitrationWon => { let status = match dispute_status { Some(DisputeStatus::Pending) => HSDisputeStatus::DisputeOpened, _ => HSDisputeStatus::DisputeWon, }; (DisputeStage::PreArbitration, status) } WebhookEventCode::PrearbitrationLost => { (DisputeStage::PreArbitration, HSDisputeStatus::DisputeLost) } _ => (DisputeStage::Dispute, HSDisputeStatus::DisputeOpened), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_dispute_stage_and_status", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_3599345303620624584
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn extract_report_group( connector_meta_data: &Option<hyperswitch_masking::Secret<serde_json::Value>>, ) -> Option<String> { connector_meta_data.as_ref().and_then(|metadata| { let metadata_value = metadata.peek(); if let serde_json::Value::String(metadata_str) = metadata_value { // Try to parse the metadata string as JSON serde_json::from_str::<WorldpayvantivMetadataObject>(metadata_str) .ok() .map(|obj| obj.report_group) } else { // Try to parse metadata directly as object serde_json::from_value::<WorldpayvantivMetadataObject>(metadata_value.clone()) .ok() .map(|obj| obj.report_group) } }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_report_group", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2933899005532021293
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { let full_xml = crate::utils::serialize_to_xml_string_with_root("cnpOnlineRequest", &self.cnp_request) .map_err(serde::ser::Error::custom)?; // Serialize the complete XML string full_xml.serialize(serializer) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "serialize", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2920064525125606314
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn try_from( item: ResponseRouterData< CnpOnlineResponse, RouterDataV2< VoidPC, PaymentFlowData, PaymentsCancelPostCaptureData, PaymentsResponseData, >, >, ) -> Result<Self, Self::Error> { if let Some(void_response) = item.response.void_response { let status = get_attempt_status(WorldpayvantivPaymentFlow::VoidPC, void_response.response)?; if is_payment_failure(status) { let error_response = ErrorResponse { code: void_response.response.to_string(), message: void_response.message.clone(), reason: Some(void_response.message.clone()), status_code: item.http_code, attempt_status: Some(status), connector_transaction_id: Some(void_response.cnp_txn_id.clone()), network_decline_code: None, network_advice_code: None, network_error_message: None, }; Ok(Self { resource_common_data: PaymentFlowData { status, ..item.router_data.resource_common_data }, response: Err(error_response), ..item.router_data }) } else { let payments_response = PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId( void_response.cnp_txn_id.clone(), ), redirection_data: None, mandate_reference: None, connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(void_response.id.clone()), incremental_authorization_allowed: None, status_code: item.http_code, }; Ok(Self { resource_common_data: PaymentFlowData { status, ..item.router_data.resource_common_data }, response: Ok(payments_response), ..item.router_data }) } } else { let error_response = ErrorResponse { code: item.response.response_code, message: item.response.message.clone(), reason: Some(item.response.message.clone()), status_code: item.http_code, attempt_status: Some(common_enums::AttemptStatus::VoidFailed), connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }; Ok(Self { resource_common_data: PaymentFlowData { status: common_enums::AttemptStatus::VoidFailed, ..item.router_data.resource_common_data }, response: Err(error_response), ..item.router_data }) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_3035509291250244028
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn from(payment_method_data: PaymentMethodData<T>) -> Self { match payment_method_data { PaymentMethodData::Wallet(WalletData::ApplePay(_)) => Self::ApplePay, PaymentMethodData::Wallet(WalletData::GooglePay(_)) => Self::AndroidPay, _ => Self::Ecommerce, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-7654649454580742779
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn get_payment_flow_type( merchant_txn_id: &str, ) -> Result<WorldpayvantivPaymentFlow, ConnectorError> { let merchant_txn_id_lower = merchant_txn_id.to_lowercase(); if merchant_txn_id_lower.contains("auth") { Ok(WorldpayvantivPaymentFlow::Auth) } else if merchant_txn_id_lower.contains("sale") { Ok(WorldpayvantivPaymentFlow::Sale) } else if merchant_txn_id_lower.contains("voidpc") { Ok(WorldpayvantivPaymentFlow::VoidPC) } else if merchant_txn_id_lower.contains("void") { Ok(WorldpayvantivPaymentFlow::Void) } else if merchant_txn_id_lower.contains("capture") { Ok(WorldpayvantivPaymentFlow::Capture) } else { Err(ConnectorError::NotSupported { message: format!( "Unable to determine payment flow type from merchant transaction ID: {}", merchant_txn_id ), connector: "worldpayvantiv", }) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_payment_flow_type", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-9124039887709848639
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn determine_attempt_status_for_psync( payment_status: PaymentStatus, merchant_txn_id: &str, current_status: common_enums::AttemptStatus, ) -> Result<common_enums::AttemptStatus, ConnectorError> { let flow_type = get_payment_flow_type(merchant_txn_id)?; match payment_status { PaymentStatus::ProcessedSuccessfully => match flow_type { WorldpayvantivPaymentFlow::Sale | WorldpayvantivPaymentFlow::Capture => { Ok(common_enums::AttemptStatus::Charged) } WorldpayvantivPaymentFlow::Auth => Ok(common_enums::AttemptStatus::Authorized), WorldpayvantivPaymentFlow::Void => Ok(common_enums::AttemptStatus::Voided), WorldpayvantivPaymentFlow::VoidPC => Ok(common_enums::AttemptStatus::VoidedPostCapture), }, PaymentStatus::TransactionDeclined => match flow_type { WorldpayvantivPaymentFlow::Sale | WorldpayvantivPaymentFlow::Capture => { Ok(common_enums::AttemptStatus::Failure) } WorldpayvantivPaymentFlow::Auth => Ok(common_enums::AttemptStatus::AuthorizationFailed), WorldpayvantivPaymentFlow::Void | WorldpayvantivPaymentFlow::VoidPC => { Ok(common_enums::AttemptStatus::VoidFailed) } }, PaymentStatus::PaymentStatusNotFound | PaymentStatus::NotYetProcessed | PaymentStatus::StatusUnavailable => Ok(current_status), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "determine_attempt_status_for_psync", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-1274446670798807345
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn create_raw_card_number_from_string<T: PaymentMethodDataTypes>( card_string: String, ) -> Result<RawCardNumber<T>, error_stack::Report<ConnectorError>> where T::Inner: From<String>, { Ok(RawCardNumber(T::Inner::from(card_string))) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_raw_card_number_from_string", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_178137810697241402
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn get_payment_info<T: PaymentMethodDataTypes>( payment_method_data: &PaymentMethodData<T>, payment_method_token: Option<PaymentMethodToken>, ) -> Result<PaymentInfo<T>, error_stack::Report<ConnectorError>> where T::Inner: From<String> + Clone, { match payment_method_data { PaymentMethodData::Card(card_data) => { let card_type = match card_data.card_network.clone() { Some(network) => WorldpayvativCardType::try_from(network)?, None => { // Determine from card number if network not provided return Err(ConnectorError::MissingRequiredField { field_name: "card_network", } .into()); } }; let year_str = card_data.card_exp_year.peek(); let formatted_year = if year_str.len() == 4 { &year_str[2..] } else { year_str }; let exp_date = format!("{}{}", card_data.card_exp_month.peek(), formatted_year); let worldpay_card = WorldpayvantivCardData { card_type, number: card_data.card_number.clone(), exp_date: exp_date.into(), card_validation_num: Some(card_data.card_cvc.clone()), }; Ok(PaymentInfo::Card(CardData { card: worldpay_card, processing_type: None, network_transaction_id: None, })) } PaymentMethodData::Wallet(wallet_data) => { match wallet_data { WalletData::ApplePay(apple_pay_data) => { match payment_method_token { Some(PaymentMethodToken::ApplePayDecrypt(apple_pay_decrypted_data)) => { let card_type = determine_apple_pay_card_type( &apple_pay_data.payment_method.network, )?; // Extract expiry date from Apple Pay decrypted data let expiry_month: Secret<String> = apple_pay_decrypted_data.get_expiry_month()?; let expiry_year = apple_pay_decrypted_data.get_four_digit_expiry_year()?; let formatted_year = &expiry_year.expose()[2..]; // Convert to 2-digit year let exp_date = format!("{}{}", expiry_month.expose(), formatted_year); let card_number_string = apple_pay_decrypted_data .application_primary_account_number .expose(); let raw_card_number = create_raw_card_number_from_string::<T>(card_number_string)?; let worldpay_card = WorldpayvantivCardData { card_type, number: raw_card_number, exp_date: exp_date.into(), card_validation_num: None, // Apple Pay doesn't provide CVV }; Ok(PaymentInfo::Card(CardData { card: worldpay_card, processing_type: None, network_transaction_id: None, })) } _ => Err(ConnectorError::MissingRequiredField { field_name: "apple_pay_decrypted_data", } .into()), } } WalletData::GooglePay(google_pay_data) => { match payment_method_token { Some(PaymentMethodToken::GooglePayDecrypt(google_pay_decrypted_data)) => { let card_type = determine_google_pay_card_type(&google_pay_data.info.card_network)?; // Extract expiry date from Google Pay decrypted data let expiry_month = google_pay_decrypted_data .payment_method_details .expiration_month .two_digits(); // Since CardExpirationYear doesn't have a public accessor, we need to deserialize it // This follows the pattern where year is extracted from the validated data let expiry_year_bytes = serde_json::to_vec( &google_pay_decrypted_data .payment_method_details .expiration_year, ) .change_context(ConnectorError::RequestEncodingFailed)?; let expiry_year: u16 = serde_json::from_slice(&expiry_year_bytes) .change_context(ConnectorError::RequestEncodingFailed)?; let formatted_year = format!("{:02}", expiry_year % 100); // Convert to 2-digit year let exp_date = format!("{}{}", expiry_month, formatted_year); let card_number_string = google_pay_decrypted_data .payment_method_details .pan .peek() .to_string(); let raw_card_number = create_raw_card_number_from_string::<T>(card_number_string)?; let worldpay_card = WorldpayvantivCardData { card_type, number: raw_card_number, exp_date: exp_date.into(), card_validation_num: None, // Google Pay doesn't provide CVV }; Ok(PaymentInfo::Card(CardData { card: worldpay_card, processing_type: None, network_transaction_id: None, })) } _ => Err(ConnectorError::MissingRequiredField { field_name: "google_pay_decrypted_data", } .into()), } } _ => Err(ConnectorError::NotSupported { message: "Wallet type".to_string(), connector: "worldpayvantiv", } .into()), } } _ => Err(ConnectorError::NotSupported { message: "Payment method".to_string(), connector: "worldpayvantiv", } .into()), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_payment_info", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_3194244177523120164
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn determine_apple_pay_card_type( network: &str, ) -> Result<WorldpayvativCardType, error_stack::Report<ConnectorError>> { match network.to_lowercase().as_str() { "visa" => Ok(WorldpayvativCardType::Visa), "mastercard" => Ok(WorldpayvativCardType::MasterCard), "amex" => Ok(WorldpayvativCardType::AmericanExpress), "discover" => Ok(WorldpayvativCardType::Discover), _ => Err(ConnectorError::NotSupported { message: format!("Apple Pay network: {}", network), connector: "worldpayvantiv", } .into()), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "determine_apple_pay_card_type", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-8885578609909770066
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn determine_google_pay_card_type( network: &str, ) -> Result<WorldpayvativCardType, error_stack::Report<ConnectorError>> { match network.to_lowercase().as_str() { "visa" => Ok(WorldpayvativCardType::Visa), "mastercard" => Ok(WorldpayvativCardType::MasterCard), "amex" => Ok(WorldpayvativCardType::AmericanExpress), "discover" => Ok(WorldpayvativCardType::Discover), _ => Err(ConnectorError::NotSupported { message: format!("Google Pay network: {}", network), connector: "worldpayvantiv", } .into()), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "determine_google_pay_card_type", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1255259492471053568
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn get_billing_address( billing_address: &Option<domain_types::payment_address::Address>, ) -> Option<BillToAddress> { billing_address.as_ref().map(|addr| BillToAddress { name: addr.get_optional_full_name(), company: addr .address .as_ref() .and_then(|a| a.first_name.as_ref().map(|f| f.peek().to_string())), address_line1: addr .address .as_ref() .and_then(|a| a.line1.as_ref().map(|l| Secret::new(l.peek().to_string()))), address_line2: addr .address .as_ref() .and_then(|a| a.line2.as_ref().map(|l| Secret::new(l.peek().to_string()))), city: addr.address.as_ref().and_then(|a| a.city.clone()), state: addr .address .as_ref() .and_then(|a| a.state.as_ref().map(|s| Secret::new(s.peek().to_string()))), zip: addr .address .as_ref() .and_then(|a| a.zip.as_ref().map(|z| Secret::new(z.peek().to_string()))), country: addr.address.as_ref().and_then(|a| a.country), email: addr.email.clone(), phone: addr .phone .as_ref() .and_then(|p| p.number.as_ref().map(|n| Secret::new(n.peek().to_string()))), }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_billing_address", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_8626123784555749664
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn get_shipping_address( shipping_address: &Option<domain_types::payment_address::Address>, ) -> Option<ShipToAddress> { shipping_address.as_ref().map(|addr| ShipToAddress { name: addr.get_optional_full_name(), company: addr .address .as_ref() .and_then(|a| a.first_name.as_ref().map(|f| f.peek().to_string())), address_line1: addr .address .as_ref() .and_then(|a| a.line1.as_ref().map(|l| Secret::new(l.peek().to_string()))), address_line2: addr .address .as_ref() .and_then(|a| a.line2.as_ref().map(|l| Secret::new(l.peek().to_string()))), city: addr.address.as_ref().and_then(|a| a.city.clone()), state: addr .address .as_ref() .and_then(|a| a.state.as_ref().map(|s| Secret::new(s.peek().to_string()))), zip: addr .address .as_ref() .and_then(|a| a.zip.as_ref().map(|z| Secret::new(z.peek().to_string()))), country: addr.address.as_ref().and_then(|a| a.country), email: addr.email.clone(), phone: addr .phone .as_ref() .and_then(|p| p.number.as_ref().map(|n| Secret::new(n.peek().to_string()))), }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_shipping_address", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_335763248767403508
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn get_valid_transaction_id( id: String, _error_field_name: &str, ) -> Result<String, error_stack::Report<ConnectorError>> { if id.len() <= worldpayvantiv_constants::MAX_PAYMENT_REFERENCE_ID_LENGTH { Ok(id) } else { Err(ConnectorError::InvalidConnectorConfig { config: "Transaction ID length exceeds maximum limit", } .into()) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_valid_transaction_id", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_7159559712404024324
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn get_attempt_status( flow: WorldpayvantivPaymentFlow, response: WorldpayvantivResponseCode, ) -> Result<common_enums::AttemptStatus, ConnectorError> { match response { WorldpayvantivResponseCode::Approved | WorldpayvantivResponseCode::PartiallyApproved | WorldpayvantivResponseCode::OfflineApproval | WorldpayvantivResponseCode::TransactionReceived => match flow { WorldpayvantivPaymentFlow::Sale => Ok(common_enums::AttemptStatus::Pending), WorldpayvantivPaymentFlow::Auth => Ok(common_enums::AttemptStatus::Authorizing), WorldpayvantivPaymentFlow::Capture => Ok(common_enums::AttemptStatus::CaptureInitiated), WorldpayvantivPaymentFlow::Void => Ok(common_enums::AttemptStatus::VoidInitiated), WorldpayvantivPaymentFlow::VoidPC => { Ok(common_enums::AttemptStatus::VoidPostCaptureInitiated) } }, // Decline codes - all other response codes not listed above WorldpayvantivResponseCode::InsufficientFunds | WorldpayvantivResponseCode::CallIssuer | WorldpayvantivResponseCode::ExceedsApprovalAmountLimit | WorldpayvantivResponseCode::ExceedsActivityAmountLimit | WorldpayvantivResponseCode::InvalidEffectiveDate | WorldpayvantivResponseCode::InvalidAccountNumber | WorldpayvantivResponseCode::AccountNumberDoesNotMatchPaymentType | WorldpayvantivResponseCode::InvalidExpirationDate | WorldpayvantivResponseCode::InvalidCVV | WorldpayvantivResponseCode::InvalidCardValidationNum | WorldpayvantivResponseCode::ExpiredCard | WorldpayvantivResponseCode::InvalidPin | WorldpayvantivResponseCode::InvalidTransactionType | WorldpayvantivResponseCode::AccountNumberNotOnFile | WorldpayvantivResponseCode::AccountNumberLocked | WorldpayvantivResponseCode::InvalidLocation | WorldpayvantivResponseCode::InvalidMerchantId | WorldpayvantivResponseCode::InvalidLocation2 | WorldpayvantivResponseCode::InvalidMerchantClassCode | WorldpayvantivResponseCode::InvalidExpirationDate2 | WorldpayvantivResponseCode::InvalidData | WorldpayvantivResponseCode::InvalidPin2 | WorldpayvantivResponseCode::ExceedsNumberofPINEntryTries | WorldpayvantivResponseCode::InvalidCryptoBox | WorldpayvantivResponseCode::InvalidRequestFormat | WorldpayvantivResponseCode::InvalidApplicationData | WorldpayvantivResponseCode::InvalidMerchantCategoryCode | WorldpayvantivResponseCode::TransactionCannotBeCompleted | WorldpayvantivResponseCode::TransactionTypeNotSupportedForCard | WorldpayvantivResponseCode::TransactionTypeNotAllowedAtTerminal | WorldpayvantivResponseCode::GenericDecline | WorldpayvantivResponseCode::DeclineByCard | WorldpayvantivResponseCode::DoNotHonor | WorldpayvantivResponseCode::InvalidMerchant | WorldpayvantivResponseCode::PickUpCard | WorldpayvantivResponseCode::CardOk | WorldpayvantivResponseCode::CallVoiceOperator | WorldpayvantivResponseCode::StopRecurring | WorldpayvantivResponseCode::NoChecking | WorldpayvantivResponseCode::NoCreditAccount | WorldpayvantivResponseCode::NoCreditAccountType | WorldpayvantivResponseCode::InvalidCreditPlan | WorldpayvantivResponseCode::InvalidTransactionCode | WorldpayvantivResponseCode::TransactionNotPermittedToCardholderAccount | WorldpayvantivResponseCode::TransactionNotPermittedToMerchant | WorldpayvantivResponseCode::PINTryExceeded | WorldpayvantivResponseCode::SecurityViolation | WorldpayvantivResponseCode::HardCapturePickUpCard | WorldpayvantivResponseCode::ResponseReceivedTooLate | WorldpayvantivResponseCode::SoftDecline | WorldpayvantivResponseCode::ContactCardIssuer | WorldpayvantivResponseCode::CallVoiceCenter | WorldpayvantivResponseCode::InvalidMerchantTerminal | WorldpayvantivResponseCode::InvalidAmount | WorldpayvantivResponseCode::ResubmitTransaction | WorldpayvantivResponseCode::InvalidTransaction | WorldpayvantivResponseCode::MerchantNotFound | WorldpayvantivResponseCode::PickUpCard2 | WorldpayvantivResponseCode::ExpiredCard2 | WorldpayvantivResponseCode::SuspectedFraud | WorldpayvantivResponseCode::ContactCardIssuer2 | WorldpayvantivResponseCode::DoNotHonor2 | WorldpayvantivResponseCode::InvalidMerchant2 | WorldpayvantivResponseCode::InsufficientFunds2 | WorldpayvantivResponseCode::AccountNumberNotOnFile2 | WorldpayvantivResponseCode::InvalidAmount2 | WorldpayvantivResponseCode::InvalidCardNumber | WorldpayvantivResponseCode::InvalidExpirationDate3 | WorldpayvantivResponseCode::InvalidCVV2 | WorldpayvantivResponseCode::InvalidCardValidationNum2 | WorldpayvantivResponseCode::InvalidPin3 | WorldpayvantivResponseCode::CardRestricted | WorldpayvantivResponseCode::OverCreditLimit | WorldpayvantivResponseCode::AccountClosed | WorldpayvantivResponseCode::AccountFrozen | WorldpayvantivResponseCode::InvalidTransactionType2 | WorldpayvantivResponseCode::InvalidMerchantId2 | WorldpayvantivResponseCode::ProcessorNotAvailable | WorldpayvantivResponseCode::NetworkTimeOut | WorldpayvantivResponseCode::SystemError | WorldpayvantivResponseCode::DuplicateTransaction | WorldpayvantivResponseCode::VoiceAuthRequired | WorldpayvantivResponseCode::AuthenticationRequired | WorldpayvantivResponseCode::SecurityCodeRequired | WorldpayvantivResponseCode::SecurityCodeNotMatch | WorldpayvantivResponseCode::ZipCodeNotMatch | WorldpayvantivResponseCode::AddressNotMatch | WorldpayvantivResponseCode::AVSFailure | WorldpayvantivResponseCode::CVVFailure | WorldpayvantivResponseCode::ServiceNotAllowed | WorldpayvantivResponseCode::CreditNotSupported | WorldpayvantivResponseCode::InvalidCreditAmount | WorldpayvantivResponseCode::CreditAmountExceedsDebitAmount | WorldpayvantivResponseCode::RefundNotSupported | WorldpayvantivResponseCode::InvalidRefundAmount | WorldpayvantivResponseCode::RefundAmountExceedsOriginalAmount | WorldpayvantivResponseCode::VoidNotSupported | WorldpayvantivResponseCode::VoidNotAllowed | WorldpayvantivResponseCode::CaptureNotSupported | WorldpayvantivResponseCode::CaptureNotAllowed | WorldpayvantivResponseCode::InvalidCaptureAmount | WorldpayvantivResponseCode::CaptureAmountExceedsAuthAmount | WorldpayvantivResponseCode::TransactionAlreadySettled | WorldpayvantivResponseCode::TransactionAlreadyVoided | WorldpayvantivResponseCode::TransactionAlreadyCaptured | WorldpayvantivResponseCode::TransactionNotFound => match flow { WorldpayvantivPaymentFlow::Sale => Ok(common_enums::AttemptStatus::Failure), WorldpayvantivPaymentFlow::Auth => Ok(common_enums::AttemptStatus::AuthorizationFailed), WorldpayvantivPaymentFlow::Capture => Ok(common_enums::AttemptStatus::CaptureFailed), WorldpayvantivPaymentFlow::Void | WorldpayvantivPaymentFlow::VoidPC => { Ok(common_enums::AttemptStatus::VoidFailed) } }, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_attempt_status", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_3754702375660269929
clm
function
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs fn is_payment_failure(status: common_enums::AttemptStatus) -> bool { matches!( status, common_enums::AttemptStatus::Failure | common_enums::AttemptStatus::AuthorizationFailed | common_enums::AttemptStatus::CaptureFailed | common_enums::AttemptStatus::VoidFailed ) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "is_payment_failure", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-5155121359121515293
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs fn create_raw_card_number_for_default_pci( card_string: String, ) -> Result<RawCardNumber<DefaultPCIHolder>, Error> { let card_number = cards::CardNumber::from_str(&card_string) .change_context(ConnectorError::RequestEncodingFailed)?; Ok(RawCardNumber(card_number)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_raw_card_number_for_default_pci", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2219739182727366911
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs fn create_raw_card_number_for_vault_token(card_string: String) -> RawCardNumber<VaultTokenHolder> { RawCardNumber(card_string) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_raw_card_number_for_vault_token", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_6721622592975040523
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs fn get_random_string() -> String { Alphanumeric.sample_string(&mut rand::thread_rng(), MAX_ID_LENGTH) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_random_string", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2986431828104026782
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs fn get_invoice_number_or_random(merchant_order_reference_id: Option<String>) -> String { match merchant_order_reference_id { Some(num) if num.len() <= MAX_ID_LENGTH => num, None | Some(_) => get_random_string(), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_invoice_number_or_random", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-4308006372678627083
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs fn validate_customer_id_length(customer_id: Option<String>) -> Option<String> { customer_id.filter(|id| id.len() <= MAX_ID_LENGTH) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "validate_customer_id_length", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-3854798871631725056
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs fn metadata_to_user_fields( metadata: Option<serde_json::Value>, needs_serialization: bool, ) -> Result<Option<UserFields>, Error> { let meta = match metadata { Some(m) => m, None => return Ok(None), }; let value = if needs_serialization { serde_json::to_value(meta).change_context(ConnectorError::RequestEncodingFailed)? } else { meta }; Ok(Some(UserFields { user_field: Vec::<UserField>::foreign_try_from(value)?, })) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "metadata_to_user_fields", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2330294263747065860
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs pub fn from_card_number_string(card_number: String) -> Result<Self, Error> { let card_number = cards::CardNumber::from_str(&card_number) .change_context(ConnectorError::RequestEncodingFailed)?; Ok(AuthorizedotnetRawCardNumber(RawCardNumber(card_number))) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from_card_number_string", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2333010937321597690
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs pub fn from_token_string(token: String) -> Self { AuthorizedotnetRawCardNumber(RawCardNumber(token)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from_token_string", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_3451905258368451318
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs fn from(wrapper: AuthorizedotnetRawCardNumber<T>) -> Self { wrapper.0 }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1449465646301967676
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs fn try_from( item: AuthorizedotnetRouterData< RouterDataV2<Refund, RefundFlowData, RefundsData, RefundsResponseData>, VaultTokenHolder, >, ) -> Result<Self, Self::Error> { // Get connector metadata which contains payment details let payment_details = item .router_data .request .refund_connector_metadata .as_ref() .get_required_value("refund_connector_metadata") .change_context(HsInterfacesConnectorError::MissingRequiredField { field_name: "refund_connector_metadata", })? .clone(); let merchant_authentication = AuthorizedotnetAuthType::try_from(&item.router_data.connector_auth_type)?; // Handle the payment details which might be a JSON string or a serde_json::Value let payment_details_inner = payment_details.peek(); let payment_details_value = match payment_details_inner { serde_json::Value::String(s) => { serde_json::from_str::<serde_json::Value>(s.as_str()) .change_context(HsInterfacesConnectorError::RequestEncodingFailed)? } _ => payment_details_inner.clone(), }; // For refunds, we need to reconstruct the payment details from the metadata let payment_details = match payment_details_value.get("payment") { Some(payment_obj) => { if let Some(credit_card) = payment_obj.get("creditCard") { let card_number = credit_card .get("cardNumber") .and_then(|v| v.as_str()) .unwrap_or("****") .to_string(); let expiration_date = credit_card .get("expirationDate") .and_then(|v| v.as_str()) .unwrap_or("YYYY-MM") .to_string(); // For VaultTokenHolder, use the string directly as a token let raw_card_number = create_raw_card_number_for_vault_token(card_number); let credit_card_details = CreditCardDetails { card_number: raw_card_number, expiration_date: Secret::new(expiration_date), card_code: None, // Not needed for refunds }; PaymentDetails::CreditCard(credit_card_details) } else { return Err(error_stack::report!( HsInterfacesConnectorError::MissingRequiredField { field_name: "credit_card_details", } )); } } None => { return Err(error_stack::report!( HsInterfacesConnectorError::MissingRequiredField { field_name: "payment_details", } )); } }; // Build the refund transaction request with parsed payment details let transaction_request = AuthorizedotnetRefundTransactionDetails { transaction_type: TransactionType::RefundTransaction, amount: item .connector .amount_converter .convert( item.router_data.request.minor_refund_amount, item.router_data.request.currency, ) .change_context(ConnectorError::AmountConversionFailed) .attach_printable( "Failed to convert refund amount for refund transaction (VaultTokenHolder)", )?, payment: payment_details, ref_trans_id: item.router_data.request.connector_transaction_id.clone(), }; let ref_id = Some(&item.router_data.request.refund_id) .filter(|id| !id.is_empty()) .cloned(); let ref_id = get_the_truncate_id(ref_id, MAX_ID_LENGTH); Ok(Self { create_transaction_request: CreateTransactionRefundRequest { merchant_authentication, ref_id, transaction_request, }, }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5951716956232968074
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs fn foreign_try_from(metadata: serde_json::Value) -> Result<Self, Self::Error> { let mut vector = Self::new(); if let serde_json::Value::Object(obj) = metadata { for (key, value) in obj { vector.push(UserField { name: key, value: match value { serde_json::Value::String(s) => s, _ => value.to_string(), }, }); } } Ok(vector) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "foreign_try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-8393901036551814101
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs fn create_regular_transaction_request< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( item: &AuthorizedotnetRouterData< RouterDataV2<Authorize, PaymentFlowData, PaymentsAuthorizeData<T>, PaymentsResponseData>, T, >, currency: api_enums::Currency, ) -> Result<AuthorizedotnetTransactionRequest<T>, Error> { let card_data = match &item.router_data.request.payment_method_data { PaymentMethodData::Card(card) => Ok(card), _ => Err(ConnectorError::RequestEncodingFailed), }?; let expiry_month = card_data.card_exp_month.peek().clone(); let year = card_data.card_exp_year.peek().clone(); let expiry_year = if year.len() == 2 { format!("20{year}") } else { year }; let expiration_date = format!("{expiry_year}-{expiry_month}"); let credit_card_details = CreditCardDetails { card_number: card_data.card_number.clone(), expiration_date: Secret::new(expiration_date), card_code: Some(card_data.card_cvc.clone()), }; let payment_details = PaymentDetails::CreditCard(credit_card_details); let transaction_type = match item.router_data.request.capture_method { Some(enums::CaptureMethod::Manual) => TransactionType::AuthOnlyTransaction, Some(enums::CaptureMethod::Automatic) | None | Some(enums::CaptureMethod::SequentialAutomatic) => { TransactionType::AuthCaptureTransaction } Some(_) => { return Err(error_stack::report!(ConnectorError::NotSupported { message: "Capture method not supported".to_string(), connector: "authorizedotnet", })) } }; let order_description = item .router_data .resource_common_data .connector_request_reference_id .clone(); // Get invoice number (random string if > MAX_ID_LENGTH or None) let invoice_number = get_invoice_number_or_random(item.router_data.request.merchant_order_reference_id.clone()); let order = Order { invoice_number, description: order_description, }; // Extract user fields from metadata let user_fields = metadata_to_user_fields(item.router_data.request.metadata.clone(), false)?; // Process billing address let billing_address = item .router_data .resource_common_data .address .get_payment_billing(); let bill_to = billing_address.as_ref().map(|billing| { let first_name = billing.address.as_ref().and_then(|a| a.first_name.clone()); let last_name = billing.address.as_ref().and_then(|a| a.last_name.clone()); BillTo { first_name, last_name, address: billing.address.as_ref().and_then(|a| a.line1.clone()), city: billing.address.as_ref().and_then(|a| a.city.clone()), state: billing.address.as_ref().and_then(|a| a.state.clone()), zip: billing.address.as_ref().and_then(|a| a.zip.clone()), country: billing .address .as_ref() .and_then(|a| a.country) .and_then(|api_country| { enums::CountryAlpha2::from_str(&api_country.to_string()).ok() }), } }); let customer_details = item .router_data .request .customer_id .as_ref() .filter(|_| { !item .router_data .request .is_customer_initiated_mandate_payment() }) .and_then(|customer| { let customer_id = customer.get_string_repr(); (customer_id.len() <= MAX_ID_LENGTH).then_some(CustomerDetails { id: customer_id.to_string(), email: item.router_data.request.get_optional_email(), }) }); // Check if we should create a profile for future mandate usage let profile = item .router_data .request .is_customer_initiated_mandate_payment() .then(|| { ProfileDetails::CreateProfileDetails(CreateProfileDetails { create_profile: true, customer_profile_id: item .router_data .resource_common_data .connector_customer .as_ref() .map(|cid| Secret::new(cid.to_string())), }) }); Ok(AuthorizedotnetTransactionRequest { transaction_type, amount: Some( item.connector .amount_converter .convert( item.router_data.request.minor_amount, item.router_data.request.currency, ) .change_context(ConnectorError::AmountConversionFailed) .attach_printable("Failed to convert payment amount for authorize transaction")?, ), currency_code: Some(currency), payment: Some(payment_details), profile, order: Some(order), customer: customer_details, bill_to, user_fields, processing_options: None, subsequent_auth_information: None, authorization_indicator_type: match item.router_data.request.capture_method { Some(capture_method) => Some(AuthorizationIndicator { authorization_indicator: capture_method.try_into()?, }), None => None, }, ref_trans_id: None, }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_regular_transaction_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-3734865662635749939
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs fn get_avs_response_description(code: &str) -> Option<&'static str> { match code { "A" => Some("The street address matched, but the postal code did not."), "B" => Some("No address information was provided."), "E" => Some("The AVS check returned an error."), "G" => Some("The card was issued by a bank outside the U.S. and does not support AVS."), "N" => Some("Neither the street address nor postal code matched."), "P" => Some("AVS is not applicable for this transaction."), "R" => Some("Retry — AVS was unavailable or timed out."), "S" => Some("AVS is not supported by card issuer."), "U" => Some("Address information is unavailable."), "W" => Some("The US ZIP+4 code matches, but the street address does not."), "X" => Some("Both the street address and the US ZIP+4 code matched."), "Y" => Some("The street address and postal code matched."), "Z" => Some("The postal code matched, but the street address did not."), _ => None, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_avs_response_description", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-4656878146433900601
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs convert_to_additional_payment_method_connector_response( transaction_response: &AuthorizedotnetTransactionResponse, ) -> Option<domain_types::router_data::AdditionalPaymentMethodConnectorResponse> { match transaction_response.avs_result_code.as_deref() { Some("P") | None => None, Some(code) => { let description = get_avs_response_description(code); let payment_checks = serde_json::json!({ "avs_result_code": code, "description": description }); Some( domain_types::router_data::AdditionalPaymentMethodConnectorResponse::Card { authentication_data: None, payment_checks: Some(payment_checks), card_network: None, domestic_network: None, }, ) } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "nvert_to_additional_payment_method_connector_response(\n", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_6010903139813919966
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs from(response: AuthorizedotnetPaymentsResponse) -> Self { Self(response) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "om(r", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_9037382331236320121
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs try_from( value: ResponseRouterData< AuthorizedotnetCreateConnectorCustomerResponse, RouterDataV2< CreateConnectorCustomer, PaymentFlowData, ConnectorCustomerData, ConnectorCustomerResponse, >, >, ) -> Result<Self, Self::Error> { let ResponseRouterData { response, router_data, http_code, } = value; let mut new_router_data = router_data; if let Some(profile_id) = response.customer_profile_id { // Success - return the connector customer ID new_router_data.response = Ok(ConnectorCustomerResponse { connector_customer_id: profile_id, }); } else { // Check if this is a "duplicate customer" error (E00039) let first_error = response.messages.message.first(); let error_code = first_error.map(|m| m.code.as_str()).unwrap_or(""); let error_text = first_error.map(|m| m.text.as_str()).unwrap_or(""); if error_code == "E00039" { // Extract customer profile ID from error message // Message format: "A duplicate record with ID 933042598 already exists." if let Some(existing_profile_id) = extract_customer_id_from_error(error_text) { tracing::info!( "Customer profile already exists with ID: {}, treating as success", existing_profile_id ); new_router_data.response = Ok(ConnectorCustomerResponse { connector_customer_id: existing_profile_id, }); } else { // Couldn't extract ID, return error new_router_data.response = Err(ErrorResponse { status_code: http_code, code: error_code.to_string(), message: error_text.to_string(), reason: None, attempt_status: None, connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }); } } else { // Other error - return error response new_router_data.response = Err(ErrorResponse { status_code: http_code, code: error_code.to_string(), message: error_text.to_string(), reason: None, attempt_status: None, connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }); } } Ok(new_router_data) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "y_from(\n", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-8564265908370233728
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs extract_error_details( response: &AuthorizedotnetPaymentsResponse, trans_res: Option<&AuthorizedotnetTransactionResponse>, ) -> (String, String) { let error_code = trans_res .and_then(|tr| { tr.errors .as_ref() .and_then(|e| e.first().map(|e| e.error_code.clone())) }) .or_else(|| response.messages.message.first().map(|m| m.code.clone())) .unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()); let error_message = trans_res .and_then(|tr| { tr.errors .as_ref() .and_then(|e| e.first().map(|e| e.error_text.clone())) }) .or_else(|| response.messages.message.first().map(|m| m.text.clone())) .unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()); (error_code, error_message) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "tract_error_details(\n", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5855480377509409594
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs create_error_response( http_status_code: u16, error_code: String, error_message: String, status: AttemptStatus, connector_transaction_id: Option<String>, _raw_connector_response: Option<Secret<String>>, ) -> ErrorResponse { ErrorResponse { status_code: http_status_code, code: error_code, message: error_message, reason: None, attempt_status: Some(status), connector_transaction_id, network_decline_code: None, network_advice_code: None, network_error_message: None, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "eate_error_response(\n", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_417871852355829100
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs from(item: AuthorizedotnetRefundStatus) -> Self { match item { AuthorizedotnetRefundStatus::Declined | AuthorizedotnetRefundStatus::Error => { Self::Failure } AuthorizedotnetRefundStatus::Approved | AuthorizedotnetRefundStatus::HeldForReview => { Self::Pending } } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "om(i", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5412980936206162976
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs get_hs_status( response: &AuthorizedotnetPaymentsResponse, _http_status_code: u16, operation: Operation, capture_method: Option<enums::CaptureMethod>, ) -> AttemptStatus { // Return failure immediately if result code is Error if response.messages.result_code == ResultCode::Error { return AttemptStatus::Failure; } // Handle case when transaction_response is None if response.transaction_response.is_none() { return match operation { Operation::Void => AttemptStatus::Voided, Operation::Authorize | Operation::Capture => AttemptStatus::Pending, Operation::Refund => AttemptStatus::Failure, }; } // Now handle transaction_response cases match response.transaction_response.as_ref().unwrap() { TransactionResponse::AuthorizedotnetTransactionResponseError(_) => AttemptStatus::Failure, TransactionResponse::AuthorizedotnetTransactionResponse(trans_res) => { match trans_res.response_code { AuthorizedotnetPaymentStatus::Declined | AuthorizedotnetPaymentStatus::Error => { AttemptStatus::Failure } AuthorizedotnetPaymentStatus::HeldForReview => AttemptStatus::Pending, AuthorizedotnetPaymentStatus::RequiresAction => { AttemptStatus::AuthenticationPending } AuthorizedotnetPaymentStatus::Approved => { // For Approved status, determine specific status based on operation and capture method match operation { Operation::Authorize => match capture_method { Some(enums::CaptureMethod::Manual) => AttemptStatus::Authorized, _ => AttemptStatus::Charged, // Automatic or None defaults to Charged }, Operation::Capture | Operation::Refund => AttemptStatus::Charged, Operation::Void => AttemptStatus::Voided, } } } } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "t_hs_status(\n", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2858375450846860317
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs build_connector_metadata( transaction_response: &AuthorizedotnetTransactionResponse, ) -> Option<serde_json::Value> { // Check if accountNumber is available // Note: accountType contains card brand (e.g., "MasterCard"), not expiration date // Authorize.net does not return the expiration date in authorization response // Debug logging to understand what we're receiving tracing::info!( "build_connector_metadata: account_number={:?}, account_type={:?}", transaction_response .account_number .as_ref() .map(|n| n.peek()), transaction_response.account_type.as_ref().map(|t| t.peek()) ); if let Some(card_number) = &transaction_response.account_number { let card_number_value = card_number.peek(); // Create nested credit card structure let credit_card_data = serde_json::json!({ "cardNumber": card_number_value, "expirationDate": "XXXX" // Hardcoded since Auth.net doesn't return it }); // Serialize to JSON string for proto compatibility (proto expects map<string, string>) let credit_card_json = serde_json::to_string(&credit_card_data).unwrap_or_else(|_| "{}".to_string()); // Create flat metadata map with JSON string value let metadata = serde_json::json!({ "creditCard": credit_card_json }); tracing::info!( "build_connector_metadata: Successfully built metadata: {:?}", metadata ); return Some(metadata); } tracing::warn!("build_connector_metadata: account_number is None, returning empty metadata"); None }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "ild_connector_metadata(\n", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_3436968530880363225
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs b fn convert_to_payments_response_data_or_error( response: &AuthorizedotnetPaymentsResponse, http_status_code: u16, operation: Operation, capture_method: Option<enums::CaptureMethod>, raw_connector_response: Option<Secret<String>>, ) -> PaymentConversionResult { let status = get_hs_status(response, http_status_code, operation, capture_method); let is_successful_status = matches!( status, AttemptStatus::Authorized | AttemptStatus::Pending | AttemptStatus::AuthenticationPending | AttemptStatus::Charged | AttemptStatus::Voided ); // Extract connector response data from transaction response if available let connector_response_data = match &response.transaction_response { Some(TransactionResponse::AuthorizedotnetTransactionResponse(trans_res)) => { convert_to_additional_payment_method_connector_response(trans_res) .map(domain_types::router_data::ConnectorResponseData::with_additional_payment_method_data) } _ => None, }; let response_payload_result = match &response.transaction_response { Some(TransactionResponse::AuthorizedotnetTransactionResponse(trans_res)) if is_successful_status => { let connector_metadata = build_connector_metadata(trans_res); // Extract mandate_reference from profile_response if available let mandate_reference = response.profile_response.as_ref().map(|profile_response| { let payment_profile_id = profile_response .customer_payment_profile_id_list .as_ref() .and_then(|list| list.first().cloned()); domain_types::connector_types::MandateReference { connector_mandate_id: profile_response.customer_profile_id.as_ref().and_then( |customer_profile_id| { payment_profile_id.map(|payment_profile_id| { format!("{customer_profile_id}-{payment_profile_id}") }) }, ), payment_method_id: None, } }); Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(trans_res.transaction_id.clone()), redirection_data: None, connector_metadata, mandate_reference: mandate_reference.map(Box::new), network_txn_id: trans_res .network_trans_id .as_ref() .map(|s| s.peek().clone()), connector_response_reference_id: Some(trans_res.transaction_id.clone()), incremental_authorization_allowed: None, status_code: http_status_code, }) } Some(TransactionResponse::AuthorizedotnetTransactionResponse(trans_res)) => { // Failure status or other non-successful statuses let (error_code, error_message) = extract_error_details(response, Some(trans_res)); Err(create_error_response( http_status_code, error_code, error_message, status, Some(trans_res.transaction_id.clone()), raw_connector_response.clone(), )) } Some(TransactionResponse::AuthorizedotnetTransactionResponseError(_)) => { let (error_code, error_message) = extract_error_details(response, None); Err(create_error_response( http_status_code, error_code, error_message, status, None, raw_connector_response.clone(), )) } None if status == AttemptStatus::Voided && operation == Operation::Void => { Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::NoResponseId, redirection_data: None, connector_metadata: None, mandate_reference: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, status_code: http_status_code, }) } None => { let (error_code, error_message) = extract_error_details(response, None); Err(create_error_response( http_status_code, error_code, error_message, status, None, raw_connector_response.clone(), )) } }; Ok((status, response_payload_result, connector_response_data)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "nvert_to_payments_response_data_or_error(\n", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_919126133519516816
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs from(transaction_status: RSyncStatus) -> Self { match transaction_status { RSyncStatus::RefundSettledSuccessfully => Self::Success, RSyncStatus::RefundPendingSettlement => Self::Pending, RSyncStatus::Declined | RSyncStatus::GeneralError | RSyncStatus::Voided => { Self::Failure } } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "om(t", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1890478765028840185
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs get_the_truncate_id(id: Option<String>, max_length: usize) -> Option<String> { id.map(|s| { if s.len() > max_length { s[..max_length].to_string() } else { s } }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "t_the_truncate_id(i", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2179520109239481419
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs from(event_type: AuthorizedotnetWebhookEvent) -> Self { match event_type { AuthorizedotnetWebhookEvent::AuthorizationCreated => Self::AuthorizedPendingCapture, AuthorizedotnetWebhookEvent::CaptureCreated | AuthorizedotnetWebhookEvent::AuthCapCreated => Self::CapturedPendingSettlement, AuthorizedotnetWebhookEvent::PriorAuthCapture => Self::SettledSuccessfully, AuthorizedotnetWebhookEvent::VoidCreated => Self::Voided, AuthorizedotnetWebhookEvent::RefundCreated => Self::RefundSettledSuccessfully, AuthorizedotnetWebhookEvent::CustomerCreated => Self::SettledSuccessfully, // Customer profile successfully created and settled AuthorizedotnetWebhookEvent::CustomerPaymentProfileCreated => Self::SettledSuccessfully, // Payment profile successfully created and settled } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "om(e", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_2758684568890164551
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs b fn get_trans_id(details: &AuthorizedotnetWebhookObjectId) -> Result<String, ConnectorError> { match details.event_type { AuthorizedotnetWebhookEvent::CustomerPaymentProfileCreated => { // For payment profile creation, use the customer_profile_id as the primary identifier if let Some(customer_profile_id) = details.payload.customer_profile_id { tracing::debug!( target: "authorizedotnet_webhook", "Extracted customer profile ID {} for payment profile creation webhook", customer_profile_id ); Ok(customer_profile_id.to_string()) } else { match details.payload.id.clone() { Some(id) => { tracing::debug!( target: "authorizedotnet_webhook", "Extracted transaction ID {} from payment profile webhook payload", id ); Ok(id) } None => { tracing::error!( target: "authorizedotnet_webhook", "No customer_profile_id or id found in CustomerPaymentProfileCreated webhook payload" ); Err(ConnectorError::WebhookReferenceIdNotFound) } } } } _ => { // For all other events, use the standard id field match details.payload.id.clone() { Some(id) => { tracing::debug!( target: "authorizedotnet_webhook", "Extracted transaction ID {} for webhook event type: {:?}", id, details.event_type ); Ok(id) } None => { tracing::error!( target: "authorizedotnet_webhook", "No transaction ID found in webhook payload for event type: {:?}", details.event_type ); Err(ConnectorError::WebhookReferenceIdNotFound) } } } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "t_trans_id(d", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-5371550544248545374
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs try_from(item: AuthorizedotnetWebhookObjectId) -> Result<Self, Self::Error> { Ok(Self { transaction: Some(SyncTransactionResponse { transaction_id: get_trans_id(&item)?, transaction_status: SyncStatus::from(item.event_type), response_code: Some(1), response_reason_code: Some(1), response_reason_description: Some("Approved".to_string()), network_trans_id: None, }), messages: ResponseMessages { result_code: ResultCode::Ok, message: vec![ResponseMessage { code: "I00001".to_string(), text: "Successful.".to_string(), }], }, }) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "y_from(i", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-6131087668102972734
clm
function
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs extract_customer_id_from_error(error_text: &str) -> Option<String> { // Look for pattern "ID <numbers>" error_text .split_whitespace() .skip_while(|&word| word != "ID") .nth(1) // Get the word after "ID" .and_then(|id_str| { // Remove any trailing punctuation and validate it's numeric let cleaned = id_str.trim_end_matches(|c: char| !c.is_numeric()); if cleaned.chars().all(char::is_numeric) && !cleaned.is_empty() { Some(cleaned.to_string()) } else { None } }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "tract_customer_id_from_error(e", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_3396203944950998792
clm
function
// connector-service/backend/connector-integration/src/connectors/payload/transformers.rs fn is_manual_capture(capture_method: Option<enums::CaptureMethod>) -> bool { matches!(capture_method, Some(enums::CaptureMethod::Manual)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "is_manual_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1803423271331507929
clm
function
// connector-service/backend/connector-integration/src/connectors/payload/transformers.rs fn try_from( item: ResponseRouterData< responses::PayloadRefundResponse, RouterDataV2<RSync, RefundFlowData, RefundSyncData, RefundsResponseData>, >, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: item.response.transaction_id.to_string(), refund_status: enums::RefundStatus::from(item.response.status), status_code: item.http_code, }), ..item.router_data }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-9163984201023871770
clm
function
// connector-service/backend/connector-integration/src/connectors/payload/transformers.rs fn build_payload_cards_request_data<T: PaymentMethodDataTypes>( payment_method_data: &PaymentMethodData<T>, connector_auth_type: &ConnectorAuthType, currency: enums::Currency, amount: FloatMajorUnit, resource_common_data: &PaymentFlowData, capture_method: Option<enums::CaptureMethod>, is_mandate: bool, ) -> Result<requests::PayloadCardsRequestData<T>, Error> { if let PaymentMethodData::Card(req_card) = payment_method_data { let payload_auth = PayloadAuth::try_from((connector_auth_type, currency))?; let card = requests::PayloadCard { number: req_card.card_number.clone(), expiry: req_card.get_card_expiry_month_year_2_digit_with_delimiter("/".to_string())?, cvc: req_card.card_cvc.clone(), }; // Get billing address to access zip and state let billing_addr = resource_common_data.get_billing_address()?; let billing_address = requests::BillingAddress { city: resource_common_data.get_billing_city()?, country: resource_common_data.get_billing_country()?, postal_code: billing_addr.zip.clone().ok_or( errors::ConnectorError::MissingRequiredField { field_name: "billing.address.zip", }, )?, state_province: billing_addr.state.clone().ok_or( errors::ConnectorError::MissingRequiredField { field_name: "billing.address.state", }, )?, street_address: resource_common_data.get_billing_line1()?, }; // For manual capture, set status to "authorized" let status = if is_manual_capture(capture_method) { Some(responses::PayloadPaymentStatus::Authorized) } else { None }; Ok(requests::PayloadCardsRequestData { amount, card, transaction_types: requests::TransactionTypes::Payment, payment_method_type: PAYMENT_METHOD_TYPE_CARD.to_string(), status, billing_address, processing_id: payload_auth.processing_account_id, keep_active: is_mandate, }) } else { Err(errors::ConnectorError::NotSupported { message: "Payment method".to_string(), connector: "Payload", } .into()) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "build_payload_cards_request_data", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-5848746094280989925
clm
function
// connector-service/backend/connector-integration/src/connectors/payload/transformers.rs fn from(item: responses::RefundStatus) -> Self { match item { responses::RefundStatus::Processed => Self::Success, responses::RefundStatus::Processing => Self::Pending, responses::RefundStatus::Declined | responses::RefundStatus::Rejected => Self::Failure, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-8615135968919749553
clm
function
// connector-service/backend/connector-integration/src/connectors/payload/transformers.rs fn handle_payment_response<F, T>( response: responses::PayloadPaymentsResponse, router_data: RouterDataV2<F, PaymentFlowData, T, PaymentsResponseData>, http_code: u16, is_mandate_payment: bool, ) -> Result<RouterDataV2<F, PaymentFlowData, T, PaymentsResponseData>, Error> { match response { responses::PayloadPaymentsResponse::PayloadCardsResponse(card_response) => { let status = common_enums::AttemptStatus::from(card_response.status); let mandate_reference = if is_mandate_payment { let connector_payment_method_id = card_response .connector_payment_method_id .clone() .expose_option(); connector_payment_method_id.map(|id| MandateReference { connector_mandate_id: Some(id), payment_method_id: None, }) } else { None }; let connector_response = card_response .avs .map(|avs_response| { let payment_checks = serde_json::json!({ "avs_result": avs_response }); AdditionalPaymentMethodConnectorResponse::Card { authentication_data: None, payment_checks: Some(payment_checks), card_network: None, domestic_network: None, } }) .map(ConnectorResponseData::with_additional_payment_method_data); let response_result = if status == common_enums::AttemptStatus::Failure { Err(ErrorResponse { attempt_status: None, code: card_response .status_code .clone() .unwrap_or_else(|| NO_ERROR_CODE.to_string()), message: card_response .status_message .clone() .unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()), reason: card_response.status_message, status_code: http_code, connector_transaction_id: Some(card_response.transaction_id.clone()), network_decline_code: None, network_advice_code: None, network_error_message: None, }) } else { Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(card_response.transaction_id), redirection_data: None, mandate_reference: mandate_reference.map(Box::new), connector_metadata: None, network_txn_id: None, connector_response_reference_id: card_response.ref_number, incremental_authorization_allowed: None, status_code: http_code, }) }; // Create a mutable copy to set the status let mut router_data_with_status = router_data; router_data_with_status .resource_common_data .set_status(status); Ok(RouterDataV2 { resource_common_data: PaymentFlowData { connector_response, ..router_data_with_status.resource_common_data }, response: response_result, ..router_data_with_status }) } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "handle_payment_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_4668990175512520684
clm
function
// connector-service/backend/connector-integration/src/connectors/payload/transformers.rs pub fn parse_webhook_event( body: &[u8], ) -> Result<PayloadWebhookEvent, error_stack::Report<errors::ConnectorError>> { serde_json::from_slice::<PayloadWebhookEvent>(body) .change_context(errors::ConnectorError::WebhookBodyDecodingFailed) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "parse_webhook_event", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_3895517059563962266
clm
function
// connector-service/backend/connector-integration/src/connectors/payload/transformers.rs pub fn get_event_type_from_trigger( trigger: responses::PayloadWebhooksTrigger, ) -> domain_types::connector_types::EventType { match trigger { // Payment Success Events responses::PayloadWebhooksTrigger::Processed => { domain_types::connector_types::EventType::PaymentIntentSuccess } responses::PayloadWebhooksTrigger::Authorized => { domain_types::connector_types::EventType::PaymentIntentAuthorizationSuccess } // Payment Processing Events responses::PayloadWebhooksTrigger::Payment | responses::PayloadWebhooksTrigger::AutomaticPayment => { domain_types::connector_types::EventType::PaymentIntentProcessing } // Payment Failure Events responses::PayloadWebhooksTrigger::Decline | responses::PayloadWebhooksTrigger::Reject | responses::PayloadWebhooksTrigger::BankAccountReject => { domain_types::connector_types::EventType::PaymentIntentFailure } responses::PayloadWebhooksTrigger::Void | responses::PayloadWebhooksTrigger::Reversal => { domain_types::connector_types::EventType::PaymentIntentCancelled } // Refund Events responses::PayloadWebhooksTrigger::Refund => { domain_types::connector_types::EventType::RefundSuccess } // Dispute Events responses::PayloadWebhooksTrigger::Chargeback => { domain_types::connector_types::EventType::DisputeOpened } responses::PayloadWebhooksTrigger::ChargebackReversal => { domain_types::connector_types::EventType::DisputeWon } // Other payment-related events - treat as generic payment processing responses::PayloadWebhooksTrigger::PaymentActivationStatus | responses::PayloadWebhooksTrigger::Credit | responses::PayloadWebhooksTrigger::Deposit | responses::PayloadWebhooksTrigger::PaymentLinkStatus | responses::PayloadWebhooksTrigger::ProcessingStatus | responses::PayloadWebhooksTrigger::TransactionOperation | responses::PayloadWebhooksTrigger::TransactionOperationClear => { domain_types::connector_types::EventType::PaymentIntentProcessing } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_event_type_from_trigger", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2778568033487643384
clm
function
// connector-service/backend/connector-integration/src/connectors/bluecode/test.rs fn test_build_request_valid() { let api_key = "test_bluecode_api_key".to_string(); let req: RouterDataV2< Authorize, PaymentFlowData, PaymentsAuthorizeData<DefaultPCIHolder>, PaymentsResponseData, > = RouterDataV2 { flow: PhantomData::<domain_types::connector_flow::Authorize>, resource_common_data: PaymentFlowData { vault_headers: None, merchant_id: common_utils::id_type::MerchantId::default(), customer_id: None, connector_customer: Some("conn_cust_987654".to_string()), payment_id: "pay_abcdef123456".to_string(), attempt_id: "attempt_123456abcdef".to_string(), status: common_enums::AttemptStatus::Pending, payment_method: common_enums::PaymentMethod::Wallet, description: Some("Payment for order #12345".to_string()), return_url: Some("https://www.google.com".to_string()), address: domain_types::payment_address::PaymentAddress::new( None, Some(domain_types::payment_address::Address { address: Some(domain_types::payment_address::AddressDetails { first_name: Some(Secret::new("John".to_string())), last_name: Some(Secret::new("Doe".to_string())), line1: Some(Secret::new("123 Main St".to_string())), city: Some("Anytown".to_string()), zip: Some(Secret::new("12345".to_string())), country: Some(common_enums::CountryAlpha2::US), ..Default::default() }), phone: None, email: None, }), None, None, ), auth_type: common_enums::AuthenticationType::NoThreeDs, connector_meta_data: Some(pii::SecretSerdeValue::new( serde_json::json!({ "shop_name": "test_shop" }), )), amount_captured: None, minor_amount_captured: None, access_token: None, session_token: None, reference_id: None, payment_method_token: None, preprocessing_id: None, connector_api_version: None, connector_request_reference_id: "conn_ref_123456789".to_string(), test_mode: None, connector_http_status_code: None, connectors: Connectors { bluecode: ConnectorParams { base_url: "https://api.bluecode.com/".to_string(), dispute_base_url: None, ..Default::default() }, ..Default::default() }, external_latency: None, connector_response_headers: None, raw_connector_response: None, raw_connector_request: None, minor_amount_capturable: None, connector_response: None, recurring_mandate_payment_data: None, }, connector_auth_type: ConnectorAuthType::HeaderKey { api_key: Secret::new(api_key), }, request: PaymentsAuthorizeData { authentication_data: None, access_token: None, payment_method_data: PaymentMethodData::Wallet(WalletData::BluecodeRedirect {}), amount: 1000, order_tax_amount: None, email: Some( Email::try_from("test@example.com".to_string()) .expect("Failed to parse email"), ), customer_name: None, currency: common_enums::Currency::USD, confirm: true, statement_descriptor_suffix: None, statement_descriptor: None, capture_method: None, integrity_object: None, router_return_url: Some("https://www.google.com".to_string()), webhook_url: Some("https://webhook.site/".to_string()), complete_authorize_url: None, mandate_id: None, setup_future_usage: None, off_session: None, browser_info: None, order_category: None, session_token: None, enrolled_for_3ds: false, related_transaction_id: None, payment_experience: None, payment_method_type: None, customer_id: Some( common_utils::id_type::CustomerId::try_from(Cow::from( "cus_123456789".to_string(), )) .unwrap(), ), request_incremental_authorization: false, metadata: None, minor_amount: MinorUnit::new(1000), merchant_order_reference_id: None, shipping_cost: None, merchant_account_id: None, merchant_config_currency: None, all_keys_required: None, customer_acceptance: None, split_payments: None, request_extended_authorization: None, setup_mandate_details: None, enable_overcapture: None, merchant_account_metadata: None, }, response: Err(ErrorResponse::default()), }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Bluecode::new()); let connector_data = ConnectorData { connector, connector_name: ConnectorEnum::Bluecode, }; let connector_integration: BoxedConnectorIntegrationV2< '_, Authorize, PaymentFlowData, PaymentsAuthorizeData<DefaultPCIHolder>, PaymentsResponseData, > = connector_data.connector.get_connector_integration_v2(); let request = connector_integration.build_request_v2(&req).unwrap(); let req_body = request.as_ref().map(|request_val| { let masked_request = match request_val.body.as_ref() { Some(request_content) => match request_content { RequestContent::Json(i) | RequestContent::FormUrlEncoded(i) | RequestContent::Xml(i) => i.masked_serialize().unwrap_or( json!({ "error": "failed to mask serialize connector request"}), ), RequestContent::FormData(_) => json!({"request_type": "FORM_DATA"}), RequestContent::RawBytes(_) => json!({"request_type": "RAW_BYTES"}), }, None => serde_json::Value::Null, }; masked_request }); println!("request: {req_body:?}"); assert_eq!( req_body.as_ref().unwrap()["reference"], "conn_ref_123456789" ); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_build_request_valid", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1629462245576856132
clm
function
// connector-service/backend/connector-integration/src/connectors/bluecode/test.rs fn test_build_request_missing_fields() { let api_key = "test_bluecode_api_key_missing".to_string(); let req: RouterDataV2< Authorize, PaymentFlowData, PaymentsAuthorizeData<DefaultPCIHolder>, PaymentsResponseData, > = RouterDataV2 { flow: PhantomData::<Authorize>, resource_common_data: PaymentFlowData { vault_headers: None, merchant_id: common_utils::id_type::MerchantId::default(), customer_id: None, connector_customer: None, payment_id: "".to_string(), attempt_id: "".to_string(), status: common_enums::AttemptStatus::Pending, payment_method: common_enums::PaymentMethod::Wallet, description: None, return_url: None, address: domain_types::payment_address::PaymentAddress::new( None, None, None, None, ), auth_type: common_enums::AuthenticationType::NoThreeDs, connector_meta_data: None, amount_captured: None, minor_amount_captured: None, access_token: None, session_token: None, reference_id: None, payment_method_token: None, preprocessing_id: None, connector_api_version: None, connector_request_reference_id: "".to_string(), test_mode: None, connector_http_status_code: None, connectors: Connectors { bluecode: ConnectorParams { base_url: "https://api.bluecode.com/".to_string(), dispute_base_url: None, ..Default::default() }, ..Default::default() }, external_latency: None, connector_response_headers: None, raw_connector_response: None, raw_connector_request: None, minor_amount_capturable: None, connector_response: None, recurring_mandate_payment_data: None, }, connector_auth_type: ConnectorAuthType::HeaderKey { api_key: Secret::new(api_key), }, request: PaymentsAuthorizeData { authentication_data: None, access_token: None, payment_method_data: PaymentMethodData::Wallet(WalletData::BluecodeRedirect {}), amount: 0, order_tax_amount: None, email: None, customer_name: None, currency: common_enums::Currency::USD, confirm: true, statement_descriptor_suffix: None, statement_descriptor: None, capture_method: None, router_return_url: None, webhook_url: None, complete_authorize_url: None, mandate_id: None, setup_future_usage: None, off_session: None, browser_info: None, integrity_object: None, order_category: None, session_token: None, enrolled_for_3ds: false, related_transaction_id: None, payment_experience: None, payment_method_type: None, customer_id: None, request_incremental_authorization: false, metadata: None, minor_amount: MinorUnit::new(0), merchant_order_reference_id: None, shipping_cost: None, merchant_account_id: None, merchant_config_currency: None, all_keys_required: None, customer_acceptance: None, split_payments: None, request_extended_authorization: None, setup_mandate_details: None, enable_overcapture: None, merchant_account_metadata: None, }, response: Err(ErrorResponse::default()), }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Bluecode::new()); let connector_data = ConnectorData { connector, connector_name: ConnectorEnum::Bluecode, }; let connector_integration: BoxedConnectorIntegrationV2< '_, Authorize, PaymentFlowData, PaymentsAuthorizeData<DefaultPCIHolder>, PaymentsResponseData, > = connector_data.connector.get_connector_integration_v2(); let result = connector_integration.build_request_v2(&req); assert!(result.is_err(), "Expected error for missing fields"); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_build_request_missing_fields", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_712796704108455929
clm
function
// connector-service/backend/connector-integration/src/connectors/bluecode/transformers.rs fn try_from(item: ResponseRouterData<BluecodeSyncResponse, Self>) -> Result<Self, Self::Error> { let ResponseRouterData { response, router_data, http_code, } = item; let status = AttemptStatus::from(response.status); let response = if status == common_enums::AttemptStatus::Failure { Err(ErrorResponse { code: NO_ERROR_CODE.to_string(), message: NO_ERROR_MESSAGE.to_string(), reason: Some(NO_ERROR_MESSAGE.to_string()), attempt_status: Some(status), connector_transaction_id: Some(response.order_id.clone()), status_code: http_code, network_advice_code: None, network_decline_code: None, network_error_message: None, }) } else { Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(response.order_id.clone()), redirection_data: None, mandate_reference: None, connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, status_code: http_code, }) }; Ok(Self { response, resource_common_data: PaymentFlowData { status, ..router_data.resource_common_data }, ..router_data }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_6464085239513599515
clm
function
// connector-service/backend/connector-integration/src/connectors/bluecode/transformers.rs fn from(item: BluecodePaymentStatus) -> Self { match item { BluecodePaymentStatus::ManualProcessing => Self::Pending, BluecodePaymentStatus::Pending | BluecodePaymentStatus::PaymentInitiated => { Self::AuthenticationPending } BluecodePaymentStatus::Failed => Self::Failure, BluecodePaymentStatus::Completed => Self::Charged, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2217067328481082276
clm
function
// connector-service/backend/connector-integration/src/connectors/bluecode/transformers.rs pub fn sort_and_minify_json(value: &Value) -> Result<String, errors::ConnectorError> { fn sort_value(val: &Value) -> Value { match val { Value::Object(map) => { let mut entries: Vec<_> = map.iter().collect(); entries.sort_by_key(|(k, _)| k.to_owned()); let sorted_map: Map<String, Value> = entries .into_iter() .map(|(k, v)| (k.clone(), sort_value(v))) .collect(); Value::Object(sorted_map) } Value::Array(arr) => Value::Array(arr.iter().map(sort_value).collect()), _ => val.clone(), } } let sorted_value = sort_value(value); serde_json::to_string(&sorted_value) .map_err(|_| errors::ConnectorError::WebhookBodyDecodingFailed) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "sort_and_minify_json", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_171653661457081326
clm
function
// connector-service/backend/connector-integration/src/connectors/bluecode/transformers.rs fn sort_value(val: &Value) -> Value { match val { Value::Object(map) => { let mut entries: Vec<_> = map.iter().collect(); entries.sort_by_key(|(k, _)| k.to_owned()); let sorted_map: Map<String, Value> = entries .into_iter() .map(|(k, v)| (k.clone(), sort_value(v))) .collect(); Value::Object(sorted_map) } Value::Array(arr) => Value::Array(arr.iter().map(sort_value).collect()), _ => val.clone(), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "sort_value", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-544205696326195527
clm
function
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs fn try_from(notif: FiuuRefundSyncResponse) -> Result<Self, Self::Error> { match notif { FiuuRefundSyncResponse::Webhook(fiuu_webhooks_refund_response) => Ok(Self { connector_refund_id: Some(fiuu_webhooks_refund_response.refund_id), status: common_enums::RefundStatus::from( fiuu_webhooks_refund_response.status.clone(), ), status_code: 200, connector_response_reference_id: None, error_code: None, error_message: None, raw_connector_response: None, response_headers: None, }), _ => Err(errors::ConnectorError::WebhookBodyDecodingFailed)?, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-1178774123721862547
clm
function
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs pub fn calculate_check_sum( req: FiuuRecurringRequest, ) -> CustomResult<Secret<String>, errors::ConnectorError> { let formatted_string = format!( "{}{}{}{}{}{}{}", req.record_type, req.merchant_id.peek(), req.token.peek(), req.order_id, req.currency, req.amount.get_amount_as_string(), req.verify_key.peek() ); Ok(Secret::new(hex::encode( crypto::Md5 .generate_digest(formatted_string.as_bytes()) .change_context(errors::ConnectorError::RequestEncodingFailed)?, ))) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "calculate_check_sum", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1148353608393418178
clm
function
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs pub fn calculate_signature( signature_data: String, ) -> Result<Secret<String>, error_stack::Report<errors::ConnectorError>> { let message = signature_data.as_bytes(); let encoded_data = hex::encode( crypto::Md5 .generate_digest(message) .change_context(errors::ConnectorError::RequestEncodingFailed)?, ); Ok(Secret::new(encoded_data)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "calculate_signature", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_8988377329679646038
clm
function
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs fn from(value: FiuuRefundsWebhookStatus) -> Self { match value { FiuuRefundsWebhookStatus::RefundSuccess => Self::RefundSuccess, FiuuRefundsWebhookStatus::RefundFailure => Self::RefundFailure, FiuuRefundsWebhookStatus::RefundPending => Self::IncomingWebhookEventUnspecified, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_7436998386497302050
clm
function
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs fn capture_status_codes() -> HashMap<&'static str, &'static str> { [ ("00", "Capture successful"), ("11", "Capture failed"), ("12", "Invalid or unmatched security hash string"), ("13", "Not a credit card transaction"), ("15", "Requested day is on settlement day"), ("16", "Forbidden transaction"), ("17", "Transaction not found"), ("18", "Missing required parameter"), ("19", "Domain not found"), ("20", "Temporary out of service"), ("21", "Authorization expired"), ("23", "Partial capture not allowed"), ("24", "Transaction already captured"), ("25", "Requested amount exceeds available capture amount"), ("99", "General error (contact payment gateway support)"), ] .into_iter() .collect() }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "capture_status_codes", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-8534463597789796036
clm
function
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs fn void_status_codes() -> HashMap<&'static str, &'static str> { [ ("00", "Success (will proceed the request)"), ("11", "Failure"), ("12", "Invalid or unmatched security hash string"), ("13", "Not a refundable transaction"), ("14", "Transaction date more than 180 days"), ("15", "Requested day is on settlement day"), ("16", "Forbidden transaction"), ("17", "Transaction not found"), ("18", "Duplicate partial refund request"), ("19", "Merchant not found"), ("20", "Missing required parameter"), ( "21", "Transaction must be in authorized/captured/settled status", ), ] .into_iter() .collect() }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "void_status_codes", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_764780647771770914
clm
function
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs pub fn get_qr_metadata( response: &DuitNowQrCodeResponse, ) -> CustomResult<Option<serde_json::Value>, errors::ConnectorError> { let image_data = QrImage::new_colored_from_data( response.txn_data.request_data.qr_data.peek().clone(), DUIT_NOW_BRAND_COLOR, ) .change_context(errors::ConnectorError::ResponseHandlingFailed)?; let image_data_url = Url::parse(image_data.data.clone().as_str()).ok(); let display_to_timestamp = None; if let Some(color_image_data_url) = image_data_url { let qr_code_info = QrCodeInformation::QrColorDataUrl { color_image_data_url, display_to_timestamp, display_text: Some(DUIT_NOW_BRAND_TEXT.to_string()), border_color: Some(DUIT_NOW_BRAND_COLOR.to_string()), }; Some(qr_code_info.encode_to_value()) .transpose() .change_context(errors::ConnectorError::ResponseHandlingFailed) } else { Ok(None) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_qr_metadata", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-7862255721192696591
clm
function
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs fn get_form_data(&self) -> reqwest::multipart::Form { build_form_from_struct(self).unwrap_or_else(|_| reqwest::multipart::Form::new()) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_form_data", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-4757302051768782463
clm
function
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs pub fn build_form_from_struct<T: Serialize>( data: T, ) -> Result<reqwest::multipart::Form, errors::ParsingError> { let mut form = reqwest::multipart::Form::new(); let serialized = serde_json::to_value(&data).map_err(|_| errors::ParsingError::EncodeError("json-value"))?; let serialized_object = serialized .as_object() .ok_or(errors::ParsingError::EncodeError("Expected object"))?; for (key, values) in serialized_object { let value = match values { Value::String(s) => s.clone(), Value::Number(n) => n.to_string(), Value::Bool(b) => b.to_string(), Value::Array(_) | Value::Object(_) | Value::Null => "".to_string(), }; form = form.text(key.clone(), value.clone()); } Ok(form) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "build_form_from_struct", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5459057106939751601
clm
function
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs pub fn new_from_data(data: String) -> Result<Self, error_stack::Report<QrCodeError>> { let qr_code = qrcode::QrCode::new(data.as_bytes()) .change_context(QrCodeError::FailedToCreateQrCode)?; let qrcode_image_buffer = qr_code.render::<Luma<u8>>().build(); let qrcode_dynamic_image = DynamicImage::ImageLuma8(qrcode_image_buffer); let mut image_bytes = std::io::BufWriter::new(std::io::Cursor::new(Vec::new())); // Encodes qrcode_dynamic_image and write it to image_bytes let _ = qrcode_dynamic_image.write_to(&mut image_bytes, ImageFormat::Png); let image_data_source = format!( "{},{}", QR_IMAGE_DATA_SOURCE_STRING, BASE64_ENGINE.encode(image_bytes.buffer()) ); Ok(Self { data: image_data_source, }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "new_from_data", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-313731343863386829
clm
function
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs pub fn new_colored_from_data( data: String, hex_color: &str, ) -> Result<Self, error_stack::Report<QrCodeError>> { let qr_code = qrcode::QrCode::new(data.as_bytes()) .change_context(QrCodeError::FailedToCreateQrCode)?; let qrcode_image_buffer = qr_code.render::<Luma<u8>>().build(); let (width, height) = qrcode_image_buffer.dimensions(); let mut colored_image = ImageBuffer::new(width, height); let rgb = Self::parse_hex_color(hex_color)?; for (x, y, pixel) in qrcode_image_buffer.enumerate_pixels() { let luminance = pixel.0[0]; let color = if luminance == 0 { Rgba([rgb.0, rgb.1, rgb.2, 255]) } else { Rgba([255, 255, 255, 255]) }; colored_image.put_pixel(x, y, color); } let qrcode_dynamic_image = DynamicImage::ImageRgba8(colored_image); let mut image_bytes = std::io::Cursor::new(Vec::new()); qrcode_dynamic_image .write_to(&mut image_bytes, ImageFormat::Png) .change_context(QrCodeError::FailedToCreateQrCode)?; let image_data_source = format!( "{},{}", QR_IMAGE_DATA_SOURCE_STRING, BASE64_ENGINE.encode(image_bytes.get_ref()) ); Ok(Self { data: image_data_source, }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "new_colored_from_data", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1626286669194681363
clm
function
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs pub fn parse_hex_color(hex: &str) -> Result<(u8, u8, u8), QrCodeError> { let hex = hex.trim_start_matches('#'); if hex.len() == 6 { let r = u8::from_str_radix(&hex[0..2], 16).ok(); let g = u8::from_str_radix(&hex[2..4], 16).ok(); let b = u8::from_str_radix(&hex[4..6], 16).ok(); if let (Some(r), Some(g), Some(b)) = (r, g, b) { return Ok((r, g, b)); } } Err(QrCodeError::InvalidHexColor) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "parse_hex_color", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_8919356045498212877
clm
function
// connector-service/backend/connector-integration/src/connectors/aci/transformers.rs fn get_capture_method(&self) -> Option<common_enums::CaptureMethod> { None }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_capture_method", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }