id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
connector-service_body_connector-integration_2289989151232074751
clm
function_body
// connector-service/backend/connector-integration/src/connectors/payu/transformers.rs // Function: determine_upi_app_name { // From Haskell getUpiAppName implementation: // getUpiAppName txnDetail = case getJuspayBankCodeFromInternalMetadata txnDetail of // Just "JP_PHONEPE" -> "phonepe" // Just "JP_GOOGLEPAY" -> "googlepay" // Just "JP_BHIM" -> "bhim" // Just "JP_PAYTM" -> "paytm" // Just "JP_CRED" -> "cred" // Just "JP_AMAZONPAY" -> "amazonpay" // Just "JP_WHATSAPP" -> "whatsapp" // _ -> "genericintent" match &request.payment_method_data { PaymentMethodData::Upi(upi_data) => { match upi_data { UpiData::UpiIntent(_) | UpiData::UpiQr(_) => { // For UPI Intent and UPI QR, return generic intent as fallback // TODO: Extract bank code from metadata if available Ok(None) } UpiData::UpiCollect(upi_collect_data) => { // UPI Collect doesn't typically use app name Ok(upi_collect_data.vpa_id.clone().map(|vpa| vpa.expose())) } } } _ => Ok(None), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "determine_upi_app_name", "is_async": null, "is_pub": null, "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_body_connector-integration_8900165179528914744
clm
function_body
// connector-service/backend/connector-integration/src/connectors/payu/transformers.rs // Function: determine_upi_flow { // Based on Haskell implementation: // getTxnS2SType :: Bool -> Bool -> Bool -> Bool -> Bool -> Maybe Text // getTxnS2SType isTxnS2SFlow4Enabled s2sEnabled isDirectOTPTxn isEmandateRegister isDirectAuthorization match &request.payment_method_data { PaymentMethodData::Upi(upi_data) => { match upi_data { UpiData::UpiCollect(collect_data) => { if let Some(vpa) = &collect_data.vpa_id { // UPI Collect flow - based on Haskell implementation // For UPI Collect: pg = UPI, bankcode = UPI, VPA required // The key is that VPA must be populated for sourceObject == "UPI_COLLECT" Ok(( Some(constants::UPI_PG.to_string()), Some(constants::UPI_COLLECT_BANKCODE.to_string()), Some(vpa.peek().to_string()), constants::UPI_S2S_FLOW.to_string(), // UPI Collect typically uses S2S flow "2" )) } else { // Missing VPA for UPI Collect - this should be an error Err(ConnectorError::MissingRequiredField { field_name: "vpa_id", }) } } UpiData::UpiIntent(_) | UpiData::UpiQr(_) => { // UPI Intent flow - uses S2S flow "2" for intent-based transactions // pg=UPI, bankcode=INTENT for intent flows Ok(( Some(constants::UPI_PG.to_string()), Some(constants::UPI_INTENT_BANKCODE.to_string()), None, constants::UPI_S2S_FLOW.to_string(), )) } } } _ => Err(ConnectorError::NotSupported { message: "Payment method not supported by PayU. Only UPI payments are supported" .to_string(), connector: "PayU", }), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "determine_upi_flow", "is_async": null, "is_pub": null, "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_body_connector-integration_3597595834915444626
clm
function_body
// connector-service/backend/connector-integration/src/connectors/payu/transformers.rs // Function: is_upi_collect_flow { // Check if the payment method is UPI Collect matches!( request.payment_method_data, PaymentMethodData::Upi(UpiData::UpiCollect(_)) ) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "is_upi_collect_flow", "is_async": null, "is_pub": null, "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_body_connector-integration_-3675838075248781401
clm
function_body
// connector-service/backend/connector-integration/src/connectors/payu/transformers.rs // Function: generate_payu_hash { use sha2::{Digest, Sha512}; // Build hash fields array exactly as PayU expects based on Haskell implementation // Pattern from Haskell: key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10|salt let hash_fields = vec![ request.key.clone(), // key request.txnid.clone(), // txnid request.amount.get_amount_as_string(), // amount request.productinfo.clone(), // productinfo request.firstname.peek().clone(), // firstname request.email.peek().clone(), // email request.udf1.as_deref().unwrap_or("").to_string(), // udf1 request.udf2.as_deref().unwrap_or("").to_string(), // udf2 request.udf3.as_deref().unwrap_or("").to_string(), // udf3 request.udf4.as_deref().unwrap_or("").to_string(), // udf4 request.udf5.as_deref().unwrap_or("").to_string(), // udf5 request.udf6.as_deref().unwrap_or("").to_string(), // udf6 request.udf7.as_deref().unwrap_or("").to_string(), // udf7 request.udf8.as_deref().unwrap_or("").to_string(), // udf8 request.udf9.as_deref().unwrap_or("").to_string(), // udf9 request.udf10.as_deref().unwrap_or("").to_string(), // udf10 merchant_salt.peek().to_string(), // salt ]; // Join with pipe separator as PayU expects let hash_string = hash_fields.join("|"); // Log hash string for debugging (remove in production) #[cfg(debug_assertions)] { let masked_hash = format!( "{}|***MASKED***", hash_fields[..hash_fields.len() - 1].join("|") ); tracing::debug!("PayU hash string (salt masked): {}", masked_hash); tracing::debug!("PayU expected format from Haskell: key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10|salt"); } // Generate SHA-512 hash as PayU expects let mut hasher = Sha512::new(); hasher.update(hash_string.as_bytes()); let result = hasher.finalize(); Ok(hex::encode(result)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "generate_payu_hash", "is_async": null, "is_pub": null, "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_body_connector-integration_-2560433793100919787
clm
function_body
// connector-service/backend/connector-integration/src/connectors/payu/transformers.rs // Function: map_payu_sync_status { match payu_status.to_lowercase().as_str() { "success" => { // For success, check if it's captured or just authorized // Based on Haskell: "success" + "captured" -> CHARGED, "success" + "auth" -> AUTHORIZED if txn_detail.field3.as_deref() == Some("captured") { AttemptStatus::Charged } else if txn_detail.field3.as_deref() == Some("auth") { AttemptStatus::Authorized } else { // Default success case - treat as charged for UPI AttemptStatus::Charged } } "pending" => { // Pending status - typically for UPI Collect waiting for customer approval AttemptStatus::AuthenticationPending } "failure" | "failed" | "cancel" | "cancelled" => { // Transaction failed AttemptStatus::Failure } _ => { // Unknown status - treat as failure for safety AttemptStatus::Failure } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "map_payu_sync_status", "is_async": null, "is_pub": null, "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_body_connector-integration_2732015306476645324
clm
function_body
// connector-service/backend/connector-integration/src/connectors/elavon/transformers.rs // Function: try_from { let ResponseRouterData { response, router_data, http_code: _, } = value; let final_status = match response.ssl_trans_status { TransactionSyncStatus::STL => match response.ssl_transaction_type { SyncTransactionType::Sale => HyperswitchAttemptStatus::Charged, SyncTransactionType::AuthOnly => HyperswitchAttemptStatus::Charged, SyncTransactionType::Return => HyperswitchAttemptStatus::Pending, }, TransactionSyncStatus::OPN => match response.ssl_transaction_type { SyncTransactionType::AuthOnly => HyperswitchAttemptStatus::Authorized, SyncTransactionType::Sale => HyperswitchAttemptStatus::Pending, SyncTransactionType::Return => HyperswitchAttemptStatus::Pending, }, TransactionSyncStatus::PEN | TransactionSyncStatus::REV => { HyperswitchAttemptStatus::Pending } TransactionSyncStatus::PST | TransactionSyncStatus::FPR | TransactionSyncStatus::PRE => { if response.ssl_transaction_type == SyncTransactionType::AuthOnly && response.ssl_trans_status == TransactionSyncStatus::PRE { HyperswitchAttemptStatus::AuthenticationFailed } else { HyperswitchAttemptStatus::Failure } } }; let payments_response_data = PaymentsResponseData::TransactionResponse { resource_id: DomainResponseId::ConnectorTransactionId(response.ssl_txn_id.clone()), redirection_data: None, connector_metadata: Some(serde_json::json!(response)), network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, mandate_reference: None, status_code: value.http_code, }; Ok(RouterDataV2 { response: Ok(payments_response_data), resource_common_data: PaymentFlowData { status: final_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": null, "is_pub": null, "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_body_connector-integration_-1702963613683631798
clm
function_body
// connector-service/backend/connector-integration/src/connectors/elavon/transformers.rs // Function: serialize { let value = match self { TransactionType::CcSale => "ccsale", TransactionType::CcAuthOnly => "ccauthonly", TransactionType::CcComplete => "cccomplete", TransactionType::CcReturn => "ccreturn", TransactionType::TxnQuery => "txnquery", }; serializer.serialize_str(value) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "serialize", "is_async": null, "is_pub": null, "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_body_connector-integration_-3064796422281063914
clm
function_body
// connector-service/backend/connector-integration/src/connectors/elavon/transformers.rs // Function: get_avs_details_from_payment_address { payment_address .and_then(|addr| { addr.get_payment_billing() .as_ref() .and_then(|billing_api_address| { billing_api_address .address .as_ref() .map(|detailed_address| { (detailed_address.line1.clone(), detailed_address.zip.clone()) }) }) }) .unwrap_or((None, None)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_avs_details_from_payment_address", "is_async": null, "is_pub": null, "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_body_connector-integration_-2823517166006697268
clm
function_body
// connector-service/backend/connector-integration/src/connectors/elavon/transformers.rs // Function: deserialize { #[derive(Deserialize, Debug)] #[serde(rename = "txn")] struct XmlIshResponse { #[serde(default)] error_code: Option<String>, #[serde(default)] error_message: Option<String>, #[serde(default)] error_name: Option<String>, #[serde(default)] ssl_result: Option<String>, #[serde(default)] ssl_txn_id: Option<String>, #[serde(default)] ssl_result_message: Option<String>, #[serde(default)] ssl_token: Option<Secret<String>>, #[serde(default)] ssl_token_response: Option<Secret<String>>, #[serde(default)] ssl_approval_code: Option<String>, #[serde(default)] ssl_transaction_type: Option<String>, #[serde(default)] ssl_cvv2_response: Option<Secret<String>>, #[serde(default)] ssl_avs_response: Option<String>, } let flat_res = XmlIshResponse::deserialize(deserializer)?; let result = { if flat_res.ssl_result.as_deref() == Some("0") { ElavonResult::Success(PaymentResponse { ssl_result: SslResult::try_from( flat_res .ssl_result .expect("ssl_result checked to be Some(\\\"0\\\")"), ) .map_err(de::Error::custom)?, ssl_txn_id: flat_res .ssl_txn_id .ok_or_else(|| de::Error::missing_field("ssl_txn_id"))?, ssl_result_message: flat_res .ssl_result_message .ok_or_else(|| de::Error::missing_field("ssl_result_message"))?, ssl_token: flat_res.ssl_token, ssl_approval_code: flat_res.ssl_approval_code, ssl_transaction_type: flat_res.ssl_transaction_type.clone(), ssl_cvv2_response: flat_res.ssl_cvv2_response, ssl_avs_response: flat_res.ssl_avs_response, ssl_token_response: flat_res.ssl_token_response.map(|s| s.expose()), }) } else if flat_res.error_message.is_some() { ElavonResult::Error(ElavonErrorResponse { error_code: flat_res.error_code.or(flat_res.ssl_result.clone()), error_message: flat_res.error_message.expect("error_message checked"), error_name: flat_res.error_name, ssl_txn_id: flat_res.ssl_txn_id, }) } else if flat_res.ssl_result.is_some() { ElavonResult::Error(ElavonErrorResponse { error_code: flat_res.ssl_result.clone(), error_message: flat_res .ssl_result_message .unwrap_or_else(|| "Transaction resulted in an error".to_string()), error_name: None, ssl_txn_id: flat_res.ssl_txn_id, }) } else { return Err(de::Error::custom( "Invalid Response from Elavon - cannot determine success or error state, missing critical fields.", )); } }; Ok(Self { result }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "deserialize", "is_async": null, "is_pub": null, "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_body_connector-integration_6917755796682060175
clm
function_body
// connector-service/backend/connector-integration/src/connectors/elavon/transformers.rs // Function: get_elavon_attempt_status { match elavon_result { ElavonResult::Success(payment_response) => { let status = match payment_response.ssl_transaction_type.as_deref() { Some("ccauthonly") | Some("AUTHONLY") => HyperswitchAttemptStatus::Authorized, Some("ccsale") | Some("cccomplete") | Some("SALE") | Some("COMPLETE") => { HyperswitchAttemptStatus::Charged } _ => match payment_response.ssl_result { SslResult::Approved => HyperswitchAttemptStatus::Charged, _ => HyperswitchAttemptStatus::Failure, }, }; (status, None) } ElavonResult::Error(error_resp) => ( HyperswitchAttemptStatus::Failure, Some(ErrorResponse { status_code: http_code, code: error_resp .error_code .clone() .unwrap_or_else(|| NO_ERROR_CODE.to_string()), message: error_resp.error_message.clone(), reason: error_resp.error_name.clone(), attempt_status: Some(HyperswitchAttemptStatus::Failure), connector_transaction_id: error_resp.ssl_txn_id.clone(), 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": "get_elavon_attempt_status", "is_async": null, "is_pub": null, "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_body_connector-integration_9130526359630749664
clm
function_body
// connector-service/backend/connector-integration/src/connectors/elavon/transformers.rs // Function: get_refund_status_from_elavon_sync_response { match elavon_response.ssl_transaction_type { SyncTransactionType::Return => match elavon_response.ssl_trans_status { TransactionSyncStatus::STL => common_enums::RefundStatus::Success, TransactionSyncStatus::PEN => common_enums::RefundStatus::Pending, TransactionSyncStatus::OPN => common_enums::RefundStatus::Pending, TransactionSyncStatus::REV => common_enums::RefundStatus::ManualReview, TransactionSyncStatus::PST | TransactionSyncStatus::FPR | TransactionSyncStatus::PRE => common_enums::RefundStatus::Failure, }, _ => common_enums::RefundStatus::Pending, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_refund_status_from_elavon_sync_response", "is_async": null, "is_pub": null, "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_body_connector-integration_2575278218298512298
clm
function_body
// connector-service/backend/connector-integration/src/connectors/phonepe/transformers.rs // Function: try_from { let response = &item.response; if response.success { if let Some(data) = &response.data { // Check if we have required fields for a successful transaction if let (Some(merchant_transaction_id), Some(transaction_id)) = (&data.merchant_transaction_id, &data.transaction_id) { // Map PhonePe response codes to payment statuses based on documentation let status = match response.code.as_str() { "PAYMENT_SUCCESS" => common_enums::AttemptStatus::Charged, "PAYMENT_PENDING" => common_enums::AttemptStatus::Pending, "PAYMENT_ERROR" | "PAYMENT_DECLINED" | "TIMED_OUT" => { common_enums::AttemptStatus::Failure } "BAD_REQUEST" | "AUTHORIZATION_FAILED" | "TRANSACTION_NOT_FOUND" => { common_enums::AttemptStatus::Failure } "INTERNAL_SERVER_ERROR" => common_enums::AttemptStatus::Pending, // Requires retry per docs _ => common_enums::AttemptStatus::Pending, // Default to pending for unknown codes }; Ok(Self { response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(transaction_id.clone()), redirection_data: None, mandate_reference: None, connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(merchant_transaction_id.clone()), incremental_authorization_allowed: None, status_code: item.http_code, }), resource_common_data: PaymentFlowData { status, ..item.router_data.resource_common_data }, ..item.router_data }) } else { // Data object exists but missing required fields - treat as error Ok(Self { response: Err(domain_types::router_data::ErrorResponse { code: response.code.clone(), message: response.message.clone(), reason: None, status_code: item.http_code, attempt_status: Some(common_enums::AttemptStatus::Failure), connector_transaction_id: data.transaction_id.clone(), network_decline_code: None, network_advice_code: None, network_error_message: None, }), ..item.router_data }) } } else { Err(errors::ConnectorError::ResponseDeserializationFailed.into()) } } else { // Error response from sync API - handle specific PhonePe error codes let error_message = response.message.clone(); let error_code = response.code.clone(); // Map PhonePe error codes to attempt status let attempt_status = get_phonepe_error_status(&error_code); Ok(Self { response: Err(domain_types::router_data::ErrorResponse { code: error_code, message: error_message, reason: None, status_code: item.http_code, attempt_status, connector_transaction_id: response .data .as_ref() .and_then(|data| data.transaction_id.clone()), network_decline_code: None, network_advice_code: None, network_error_message: None, }), ..item.router_data }) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": null, "is_pub": null, "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_body_connector-integration_6457933934134066336
clm
function_body
// connector-service/backend/connector-integration/src/connectors/phonepe/transformers.rs // Function: generate_phonepe_checksum { // PhonePe checksum algorithm: SHA256(base64Payload + apiPath + saltKey) + "###" + keyIndex let checksum_input = format!("{}{}{}", base64_payload, api_path, salt_key.peek()); let sha256 = crypto::Sha256; let hash_bytes = sha256 .generate_digest(checksum_input.as_bytes()) .change_context(errors::ConnectorError::RequestEncodingFailed)?; let hash = hash_bytes.iter().fold(String::new(), |mut acc, byte| { use std::fmt::Write; write!(&mut acc, "{byte:02x}").unwrap(); acc }); // Format: hash###keyIndex Ok(format!( "{}{}{}", hash, constants::CHECKSUM_SEPARATOR, key_index )) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "generate_phonepe_checksum", "is_async": null, "is_pub": null, "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_body_connector-integration_2939302677369426907
clm
function_body
// connector-service/backend/connector-integration/src/connectors/phonepe/transformers.rs // Function: generate_phonepe_sync_checksum { // PhonePe sync checksum algorithm: SHA256(apiPath + saltKey) + "###" + keyIndex let checksum_input = format!("{}{}", api_path, salt_key.peek()); let sha256 = crypto::Sha256; let hash_bytes = sha256 .generate_digest(checksum_input.as_bytes()) .change_context(errors::ConnectorError::RequestEncodingFailed)?; let hash = hash_bytes.iter().fold(String::new(), |mut acc, byte| { use std::fmt::Write; write!(&mut acc, "{byte:02x}").unwrap(); acc }); // Format: hash###keyIndex Ok(format!( "{}{}{}", hash, constants::CHECKSUM_SEPARATOR, key_index )) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "generate_phonepe_sync_checksum", "is_async": null, "is_pub": null, "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_body_connector-integration_1109601933934871398
clm
function_body
// connector-service/backend/connector-integration/src/connectors/phonepe/transformers.rs // Function: get_phonepe_error_status { match error_code { "TRANSACTION_NOT_FOUND" => Some(common_enums::AttemptStatus::Failure), "401" => Some(common_enums::AttemptStatus::AuthenticationFailed), "400" | "BAD_REQUEST" => Some(common_enums::AttemptStatus::Failure), "PAYMENT_ERROR" | "PAYMENT_DECLINED" | "TIMED_OUT" => { Some(common_enums::AttemptStatus::Failure) } "AUTHORIZATION_FAILED" => Some(common_enums::AttemptStatus::AuthenticationFailed), _ => None, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_phonepe_error_status", "is_async": null, "is_pub": null, "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_body_connector-integration_-423506458149436971
clm
function_body
// connector-service/backend/connector-integration/src/connectors/novalnet/transformers.rs // Function: get_test_mode { match item { Some(true) => TEST_MODE_ENABLED, Some(false) | None => TEST_MODE_DISABLED, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_test_mode", "is_async": null, "is_pub": null, "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_body_connector-integration_8971430297847553901
clm
function_body
// connector-service/backend/connector-integration/src/connectors/novalnet/transformers.rs // Function: try_from { match notif.result.status { NovalnetAPIStatus::Success => { let refund_id = notif .transaction .refund .tid .map(|tid| tid.expose().to_string()) .ok_or(errors::ConnectorError::ResponseHandlingFailed)?; let transaction_status = notif.transaction.status; Ok(Self { connector_refund_id: Some(refund_id), status: common_enums::RefundStatus::from(transaction_status), status_code: 200, connector_response_reference_id: None, error_code: None, error_message: None, raw_connector_response: None, response_headers: None, }) } NovalnetAPIStatus::Failure => Ok(Self { status: common_enums::RefundStatus::Failure, connector_refund_id: None, status_code: 200, connector_response_reference_id: None, error_code: Some(notif.result.status.to_string()), error_message: Some(notif.result.status_text), raw_connector_response: None, response_headers: None, }), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": null, "is_pub": null, "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_body_connector-integration_7149848726103475960
clm
function_body
// connector-service/backend/connector-integration/src/connectors/novalnet/transformers.rs // Function: from { match item { NovalnetTransactionStatus::Success | NovalnetTransactionStatus::Confirmed => { Self::Success } NovalnetTransactionStatus::Pending => Self::Pending, NovalnetTransactionStatus::Failure | NovalnetTransactionStatus::OnHold | NovalnetTransactionStatus::Deactivated | NovalnetTransactionStatus::Progress => Self::Failure, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": null, "is_pub": null, "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_body_connector-integration_8414870376191667064
clm
function_body
// connector-service/backend/connector-integration/src/connectors/novalnet/transformers.rs // Function: get_error_response { let error_code = result.status; let error_reason = result.status_text.clone(); ErrorResponse { code: error_code.to_string(), message: error_reason.clone(), reason: Some(error_reason), status_code, attempt_status: None, connector_transaction_id: None, network_advice_code: None, network_decline_code: None, network_error_message: None, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_error_response", "is_async": null, "is_pub": null, "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_body_connector-integration_6459422468261500668
clm
function_body
// connector-service/backend/connector-integration/src/connectors/novalnet/transformers.rs // Function: get_token { if let Some(data) = transaction_data { match &data.payment_data { Some(NovalnetResponsePaymentData::Card(card_data)) => { card_data.token.clone().map(|token| token.expose()) } Some(NovalnetResponsePaymentData::Paypal(paypal_data)) => { paypal_data.token.clone().map(|token| token.expose()) } None => None, } } else { None } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_token", "is_async": null, "is_pub": null, "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_body_connector-integration_-2304903721614685179
clm
function_body
// connector-service/backend/connector-integration/src/connectors/novalnet/transformers.rs // Function: get_novalnet_dispute_status { match status { WebhookEventType::Chargeback => WebhookDisputeStatus::DisputeOpened, WebhookEventType::Credit => WebhookDisputeStatus::DisputeWon, _ => WebhookDisputeStatus::Unknown, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_novalnet_dispute_status", "is_async": null, "is_pub": null, "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_body_connector-integration_-8263213910061241151
clm
function_body
// connector-service/backend/connector-integration/src/connectors/novalnet/transformers.rs // Function: foreign_try_from { match value { WebhookDisputeStatus::DisputeOpened => Ok(Self::DisputeOpened), WebhookDisputeStatus::DisputeWon => Ok(Self::DisputeWon), WebhookDisputeStatus::Unknown => Err(ConnectorError::WebhookBodyDecodingFailed)?, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "foreign_try_from", "is_async": null, "is_pub": null, "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_body_connector-integration_663277235311379812
clm
function_body
// connector-service/backend/connector-integration/src/connectors/novalnet/transformers.rs // Function: get_incoming_webhook_event { 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": null, "is_pub": null, "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_body_connector-integration_-6952957663247157186
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/test.rs // Function: 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": null, "is_pub": null, "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_body_connector-integration_-5681562439064172875
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/test.rs // Function: 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": null, "is_pub": null, "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_body_connector-integration_-4241795342393484524
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: from { 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": null, "is_pub": null, "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_body_connector-integration_167136384757826940
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: try_from { 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": null, "is_pub": null, "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_body_connector-integration_8179419796355489933
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_amount_data { 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": null, "is_pub": null, "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_body_connector-integration_7518099285019130191
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_adyen_payment_status { 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": null, "is_pub": null, "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_body_connector-integration_-7674069107723274930
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: foreign_try_from { 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": null, "is_pub": null, "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_body_connector-integration_5367736282980672519
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_adyen_response { 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": null, "is_pub": null, "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_body_connector-integration_2801762041728564160
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_redirection_response { 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": null, "is_pub": null, "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_body_connector-integration_6071155414175732482
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_wait_screen_metadata { 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": null, "is_pub": null, "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_body_connector-integration_-3798901867030574420
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_adyen_payment_webhook_event { 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": null, "is_pub": null, "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_body_connector-integration_-6403774252104309111
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_adyen_refund_webhook_event { 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": null, "is_pub": null, "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_body_connector-integration_7571493179599046255
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_adyen_webhook_event_type { 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": null, "is_pub": null, "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_body_connector-integration_-1298008982947510298
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_webhook_object_from_body { 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": null, "is_pub": null, "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_body_connector-integration_-7646778122907162140
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: build_shopper_reference { 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": null, "is_pub": null, "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_body_connector-integration_-8386024224868229444
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_recurring_processing_model { 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": null, "is_pub": null, "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_body_connector-integration_-8798471421830085579
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: is_mandate_payment { (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": null, "is_pub": null, "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_body_connector-integration_78658032047515618
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_address_info { 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": null, "is_pub": null, "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_body_connector-integration_-2107408566965000745
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_additional_data { 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": null, "is_pub": null, "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_body_connector-integration_6960544220320963518
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_risk_data { 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": null, "is_pub": null, "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_body_connector-integration_5334923471569566333
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_amount_data_for_setup_mandate { 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": null, "is_pub": null, "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_body_connector-integration_5705254874498825781
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_recurring_processing_model_for_setup_mandate { 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": null, "is_pub": null, "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_body_connector-integration_6768865710378008378
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_additional_data_for_setup_mandate { 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": null, "is_pub": null, "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_body_connector-integration_7767464531085360465
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: is_mandate_payment_for_setup_mandate { (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": null, "is_pub": null, "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_body_connector-integration_1903287790605873704
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_defence_documents { 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": null, "is_pub": null, "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_body_connector-integration_4575633659855848483
clm
function_body
// connector-service/backend/connector-integration/src/connectors/adyen/transformers.rs // Function: get_dispute_stage_and_status { 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": null, "is_pub": null, "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_body_connector-integration_3599345303620624584
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: extract_report_group { 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": null, "is_pub": null, "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_body_connector-integration_-2933899005532021293
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: serialize { 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": null, "is_pub": null, "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_body_connector-integration_-2920064525125606314
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: try_from { 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": null, "is_pub": null, "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_body_connector-integration_3035509291250244028
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: from { 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": null, "is_pub": null, "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_body_connector-integration_-7654649454580742779
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: get_payment_flow_type { 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": null, "is_pub": null, "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_body_connector-integration_-9124039887709848639
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: determine_attempt_status_for_psync { 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": null, "is_pub": null, "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_body_connector-integration_178137810697241402
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: get_payment_info { 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": null, "is_pub": null, "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_body_connector-integration_3194244177523120164
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: determine_apple_pay_card_type { 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": null, "is_pub": null, "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_body_connector-integration_-8885578609909770066
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: determine_google_pay_card_type { 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": null, "is_pub": null, "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_body_connector-integration_1255259492471053568
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: get_billing_address { 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": null, "is_pub": null, "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_body_connector-integration_8626123784555749664
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: get_shipping_address { 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": null, "is_pub": null, "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_body_connector-integration_335763248767403508
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: get_valid_transaction_id { 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": null, "is_pub": null, "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_body_connector-integration_7159559712404024324
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: get_attempt_status { 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": null, "is_pub": null, "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_body_connector-integration_3754702375660269929
clm
function_body
// connector-service/backend/connector-integration/src/connectors/worldpayvantiv/transformers.rs // Function: is_payment_failure { 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": null, "is_pub": null, "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_body_connector-integration_-5155121359121515293
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: create_raw_card_number_for_default_pci { 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": null, "is_pub": null, "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_body_connector-integration_-2986431828104026782
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: get_invoice_number_or_random { 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": null, "is_pub": null, "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_body_connector-integration_-3854798871631725056
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: metadata_to_user_fields { 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": null, "is_pub": null, "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_body_connector-integration_-2330294263747065860
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: from_card_number_string { 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": null, "is_pub": null, "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_body_connector-integration_1449465646301967676
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: try_from { // 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": null, "is_pub": null, "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_body_connector-integration_5951716956232968074
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: foreign_try_from { 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": null, "is_pub": null, "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_body_connector-integration_-8393901036551814101
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: create_regular_transaction_request { 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": null, "is_pub": null, "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_body_connector-integration_-3734865662635749939
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: get_avs_response_description { 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": null, "is_pub": null, "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_body_connector-integration_-4656878146433900601
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: nvert_to_additional_payment_method_connector_response( 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": null, "is_pub": null, "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_body_connector-integration_9037382331236320121
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: y_from( 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": null, "is_pub": null, "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_body_connector-integration_-8564265908370233728
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: tract_error_details( 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": null, "is_pub": null, "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_body_connector-integration_5855480377509409594
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: eate_error_response( 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": null, "is_pub": null, "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_body_connector-integration_417871852355829100
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: om(i 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": null, "is_pub": null, "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_body_connector-integration_5412980936206162976
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: t_hs_status( // 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": null, "is_pub": null, "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_body_connector-integration_-2858375450846860317
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: ild_connector_metadata( // 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": null, "is_pub": null, "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_body_connector-integration_3436968530880363225
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: nvert_to_payments_response_data_or_error( 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": null, "is_pub": null, "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_body_connector-integration_919126133519516816
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: om(t 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": null, "is_pub": null, "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_body_connector-integration_1890478765028840185
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: t_the_truncate_id(i 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": null, "is_pub": null, "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_body_connector-integration_-2179520109239481419
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: om(e 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": null, "is_pub": null, "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_body_connector-integration_2758684568890164551
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: t_trans_id(d 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": null, "is_pub": null, "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_body_connector-integration_-5371550544248545374
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: y_from(i 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": null, "is_pub": null, "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_body_connector-integration_-6131087668102972734
clm
function_body
// connector-service/backend/connector-integration/src/connectors/authorizedotnet/transformers.rs // Function: tract_customer_id_from_error(e // 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": null, "is_pub": null, "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_body_connector-integration_1803423271331507929
clm
function_body
// connector-service/backend/connector-integration/src/connectors/payload/transformers.rs // Function: try_from { 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": null, "is_pub": null, "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_body_connector-integration_-9163984201023871770
clm
function_body
// connector-service/backend/connector-integration/src/connectors/payload/transformers.rs // Function: build_payload_cards_request_data { 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": null, "is_pub": null, "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_body_connector-integration_-5848746094280989925
clm
function_body
// connector-service/backend/connector-integration/src/connectors/payload/transformers.rs // Function: from { 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": null, "is_pub": null, "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_body_connector-integration_-8615135968919749553
clm
function_body
// connector-service/backend/connector-integration/src/connectors/payload/transformers.rs // Function: handle_payment_response { 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": null, "is_pub": null, "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_body_connector-integration_4668990175512520684
clm
function_body
// connector-service/backend/connector-integration/src/connectors/payload/transformers.rs // Function: parse_webhook_event { 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": null, "is_pub": null, "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_body_connector-integration_3895517059563962266
clm
function_body
// connector-service/backend/connector-integration/src/connectors/payload/transformers.rs // Function: get_event_type_from_trigger { 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": null, "is_pub": null, "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_body_connector-integration_-2778568033487643384
clm
function_body
// connector-service/backend/connector-integration/src/connectors/bluecode/test.rs // Function: 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": null, "is_pub": null, "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_body_connector-integration_1629462245576856132
clm
function_body
// connector-service/backend/connector-integration/src/connectors/bluecode/test.rs // Function: 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": null, "is_pub": null, "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_body_connector-integration_712796704108455929
clm
function_body
// connector-service/backend/connector-integration/src/connectors/bluecode/transformers.rs // Function: try_from { 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": null, "is_pub": null, "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_body_connector-integration_6464085239513599515
clm
function_body
// connector-service/backend/connector-integration/src/connectors/bluecode/transformers.rs // Function: from { 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": null, "is_pub": null, "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_body_connector-integration_-2217067328481082276
clm
function_body
// connector-service/backend/connector-integration/src/connectors/bluecode/transformers.rs // Function: sort_and_minify_json { 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": null, "is_pub": null, "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_body_connector-integration_171653661457081326
clm
function_body
// connector-service/backend/connector-integration/src/connectors/bluecode/transformers.rs // Function: sort_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": null, "is_pub": null, "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_body_connector-integration_-544205696326195527
clm
function_body
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs // Function: try_from { 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": null, "is_pub": null, "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_body_connector-integration_-1178774123721862547
clm
function_body
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs // Function: calculate_check_sum { 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": null, "is_pub": null, "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_body_connector-integration_1148353608393418178
clm
function_body
// connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs // Function: calculate_signature { 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": null, "is_pub": null, "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 }