id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
connector-service_fn_connector-integration_-2475670696279178684
clm
function
// connector-service/backend/connector-integration/src/connectors/aci/transformers.rs fn try_from( item: AciRouterData< RouterDataV2<RepeatPayment, PaymentFlowData, RepeatPaymentData, PaymentsResponseData>, T, >, ) -> Result<Self, Self::Error> { let auth = AciAuthType::try_from(&item.router_data.connector_auth_type)?; let amount = item .connector .amount_converter .convert( item.router_data.request.minor_amount, item.router_data.request.currency, ) .change_context(ConnectorError::AmountConversionFailed)?; let payment_type = if item.router_data.request.is_auto_capture()? { AciPaymentType::Debit } else { AciPaymentType::Preauthorization }; let instruction = Some(Instruction { mode: InstructionMode::Repeated, transaction_type: InstructionType::Unscheduled, source: InstructionSource::MerchantInitiatedTransaction, create_registration: None, }); let txn_details = TransactionDetails { entity_id: auth.entity_id, amount, currency: item.router_data.request.currency.to_string(), payment_type, }; let recurring_type = Some(AciRecurringType::Repeated); Ok(Self { txn_details, payment_method: PaymentDetails::Mandate, instruction, shopper_result_url: item.router_data.resource_common_data.return_url.clone(), three_ds_two_enrolled: None, recurring_type, }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5868182820372981165
clm
function
// connector-service/backend/connector-integration/src/connectors/aci/transformers.rs fn get_aci_payment_brand( card_network: Option<common_enums::CardNetwork>, is_network_token_flow: bool, ) -> Result<PaymentBrand, Error> { match card_network { Some(common_enums::CardNetwork::Visa) => Ok(PaymentBrand::Visa), Some(common_enums::CardNetwork::Mastercard) => Ok(PaymentBrand::Mastercard), Some(common_enums::CardNetwork::AmericanExpress) => Ok(PaymentBrand::AmericanExpress), Some(common_enums::CardNetwork::JCB) => Ok(PaymentBrand::Jcb), Some(common_enums::CardNetwork::DinersClub) => Ok(PaymentBrand::DinersClub), Some(common_enums::CardNetwork::Discover) => Ok(PaymentBrand::Discover), Some(common_enums::CardNetwork::UnionPay) => Ok(PaymentBrand::UnionPay), Some(common_enums::CardNetwork::Maestro) => Ok(PaymentBrand::Maestro), Some(unsupported_network) => Err(errors::ConnectorError::NotSupported { message: format!("Card network {unsupported_network} is not supported by ACI"), connector: "ACI", })?, None => { if is_network_token_flow { Ok(PaymentBrand::Visa) } else { Err(errors::ConnectorError::MissingRequiredField { field_name: "card.card_network", } .into()) } } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_aci_payment_brand", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5993362075725529143
clm
function
// connector-service/backend/connector-integration/src/connectors/aci/transformers.rs fn get_transaction_details< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( item: &AciRouterData< RouterDataV2<Authorize, PaymentFlowData, PaymentsAuthorizeData<T>, PaymentsResponseData>, T, >, ) -> Result<TransactionDetails, error_stack::Report<errors::ConnectorError>> { let auth = AciAuthType::try_from(&item.router_data.connector_auth_type)?; let amount = item .connector .amount_converter .convert( item.router_data.request.minor_amount, item.router_data.request.currency, ) .change_context(ConnectorError::AmountConversionFailed)?; let payment_type = if item.router_data.request.is_auto_capture()? { AciPaymentType::Debit } else { AciPaymentType::Preauthorization }; Ok(TransactionDetails { entity_id: auth.entity_id, amount, currency: item.router_data.request.currency.to_string(), payment_type, }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_transaction_details", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-6818782463916748221
clm
function
// connector-service/backend/connector-integration/src/connectors/aci/transformers.rs fn get_instruction_details< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( item: &AciRouterData< RouterDataV2<Authorize, PaymentFlowData, PaymentsAuthorizeData<T>, PaymentsResponseData>, T, >, ) -> Option<Instruction> { if item.router_data.request.customer_acceptance.is_some() && item.router_data.request.setup_future_usage == Some(common_enums::FutureUsage::OffSession) { return Some(Instruction { mode: InstructionMode::Initial, transaction_type: InstructionType::Unscheduled, source: InstructionSource::CardholderInitiatedTransaction, create_registration: Some(true), }); } else if item.router_data.request.mandate_id.is_some() { return Some(Instruction { mode: InstructionMode::Repeated, transaction_type: InstructionType::Unscheduled, source: InstructionSource::MerchantInitiatedTransaction, create_registration: None, }); } None }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_instruction_details", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-5309365021088424429
clm
function
// connector-service/backend/connector-integration/src/connectors/aci/transformers.rs fn get_recurring_type< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( item: &AciRouterData< RouterDataV2<Authorize, PaymentFlowData, PaymentsAuthorizeData<T>, PaymentsResponseData>, T, >, ) -> Option<AciRecurringType> { if item.router_data.request.customer_acceptance.is_some() && item.router_data.request.setup_future_usage == Some(common_enums::FutureUsage::OffSession) { Some(AciRecurringType::Initial) } else { None } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_recurring_type", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-6266609253027953232
clm
function
// connector-service/backend/connector-integration/src/connectors/aci/transformers.rs fn map_aci_attempt_status( item: AciPaymentStatus, auto_capture: bool, ) -> common_enums::AttemptStatus { match item { AciPaymentStatus::Succeeded => { if auto_capture { common_enums::AttemptStatus::Charged } else { common_enums::AttemptStatus::Authorized } } AciPaymentStatus::Failed => common_enums::AttemptStatus::Failure, AciPaymentStatus::Pending => common_enums::AttemptStatus::Authorizing, AciPaymentStatus::RedirectShopper => common_enums::AttemptStatus::AuthenticationPending, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "map_aci_attempt_status", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2349756336930730154
clm
function
// connector-service/backend/connector-integration/src/connectors/aci/transformers.rs fn from_str(s: &str) -> Result<Self, Self::Err> { if FAILURE_CODES.contains(&s) { Ok(Self::Failed) } else if PENDING_CODES.contains(&s) { Ok(Self::Pending) } else if SUCCESSFUL_CODES.contains(&s) { Ok(Self::Succeeded) } else { Err(report!(errors::ConnectorError::UnexpectedResponseError( bytes::Bytes::from(s.to_owned()) ))) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from_str", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-324582186595130169
clm
function
// connector-service/backend/connector-integration/src/connectors/aci/transformers.rs fn map_aci_capture_status(item: AciStatus) -> common_enums::AttemptStatus { match item { AciStatus::Succeeded => common_enums::AttemptStatus::Charged, AciStatus::Failed => common_enums::AttemptStatus::Failure, AciStatus::Pending => common_enums::AttemptStatus::Pending, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "map_aci_capture_status", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_4759838529303483321
clm
function
// connector-service/backend/connector-integration/src/connectors/aci/transformers.rs fn map_aci_void_status(item: AciStatus) -> common_enums::AttemptStatus { match item { AciStatus::Succeeded => common_enums::AttemptStatus::Voided, AciStatus::Failed => common_enums::AttemptStatus::VoidFailed, AciStatus::Pending => common_enums::AttemptStatus::VoidInitiated, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "map_aci_void_status", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5967455669209128865
clm
function
// connector-service/backend/connector-integration/src/connectors/aci/transformers.rs fn from(item: AciRefundStatus) -> Self { match item { AciRefundStatus::Succeeded => Self::Success, AciRefundStatus::Failed => Self::Failure, AciRefundStatus::Pending => Self::Pending, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_6772711868557895414
clm
function
// connector-service/backend/connector-integration/src/connectors/fiserv/transformers.rs fn get_card_expiry_year_4_digit_placeholder( year_yy: &Secret<String>, ) -> Result<Secret<String>, error_stack::Report<ConnectorError>> { let year_str = year_yy.peek(); if year_str.len() == 2 && year_str.chars().all(char::is_numeric) { Ok(Secret::new(format!("20{year_str}"))) } else if year_str.len() == 4 && year_str.chars().all(char::is_numeric) { Ok(year_yy.clone()) } else { Err(report!(ConnectorError::RequestEncodingFailed)) .attach_printable("Invalid card expiry year format: expected YY or YYYY") } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_card_expiry_year_4_digit_placeholder", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_2816155212846388580
clm
function
// connector-service/backend/connector-integration/src/connectors/fiserv/transformers.rs fn try_from(item: ResponseRouterData<FiservErrorResponse, Self>) -> Result<Self, Self::Error> { let ResponseRouterData { response, router_data, http_code, } = item; let error_details = response .error .as_ref() .or(response.details.as_ref()) .and_then(|e| e.first()); let message = error_details.map_or(NO_ERROR_MESSAGE.to_string(), |e| e.message.clone()); let code = error_details .and_then(|e| e.code.clone()) .unwrap_or_else(|| NO_ERROR_CODE.to_string()); let reason = error_details.and_then(|e| e.field.clone()); let mut router_data_out = router_data; router_data_out.response = Err(ErrorResponse { code, message, reason, status_code: http_code, attempt_status: None, connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }); Ok(router_data_out) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_4136552758440614962
clm
function
// connector-service/backend/connector-integration/src/connectors/fiserv/transformers.rs fn from(item: FiservPaymentStatus) -> Self { match item { FiservPaymentStatus::Captured | FiservPaymentStatus::Succeeded | FiservPaymentStatus::Authorized => Self::Success, FiservPaymentStatus::Declined | FiservPaymentStatus::Failed => Self::Failure, FiservPaymentStatus::Voided | FiservPaymentStatus::Processing => Self::Pending, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-3758289943798318162
clm
function
// connector-service/backend/connector-integration/src/connectors/checkout/transformers.rs fn to_connector_meta( connector_meta: Option<serde_json::Value>, ) -> CustomResult<CheckoutMeta, ConnectorError> { connector_meta .map(|meta| { serde_json::from_value::<CheckoutMeta>(meta) .map_err(|_| report!(errors::ConnectorError::ResponseDeserializationFailed)) }) .unwrap_or(Ok(CheckoutMeta { psync_flow: CheckoutPaymentIntent::Capture, })) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "to_connector_meta", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-6306299953775902384
clm
function
// connector-service/backend/connector-integration/src/connectors/checkout/transformers.rs fn get_connector_meta( capture_method: enums::CaptureMethod, ) -> CustomResult<serde_json::Value, ConnectorError> { match capture_method { enums::CaptureMethod::Automatic | enums::CaptureMethod::SequentialAutomatic => { Ok(serde_json::json!(CheckoutMeta { psync_flow: CheckoutPaymentIntent::Capture, })) } enums::CaptureMethod::Manual | enums::CaptureMethod::ManualMultiple => { Ok(serde_json::json!(CheckoutMeta { psync_flow: CheckoutPaymentIntent::Authorize, })) } enums::CaptureMethod::Scheduled => { Err(errors::ConnectorError::CaptureMethodNotSupported.into()) } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_connector_meta", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_4376085001000379583
clm
function
// connector-service/backend/connector-integration/src/connectors/checkout/transformers.rs fn from(status: CheckoutPaymentStatus) -> Self { get_attempt_status_bal((status, None)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5289544423721072476
clm
function
// connector-service/backend/connector-integration/src/connectors/checkout/transformers.rs fn get_attempt_status_cap( item: (CheckoutPaymentStatus, Option<enums::CaptureMethod>), ) -> enums::AttemptStatus { let (status, capture_method) = item; match status { CheckoutPaymentStatus::Authorized => { if capture_method == Some(enums::CaptureMethod::Automatic) || capture_method.is_none() { enums::AttemptStatus::Pending } else { enums::AttemptStatus::Authorized } } CheckoutPaymentStatus::Captured | CheckoutPaymentStatus::PartiallyRefunded | CheckoutPaymentStatus::Refunded => enums::AttemptStatus::Charged, CheckoutPaymentStatus::PartiallyCaptured => enums::AttemptStatus::PartialCharged, CheckoutPaymentStatus::Declined | CheckoutPaymentStatus::Expired | CheckoutPaymentStatus::Canceled => enums::AttemptStatus::Failure, CheckoutPaymentStatus::Pending => enums::AttemptStatus::AuthenticationPending, CheckoutPaymentStatus::CardVerified | CheckoutPaymentStatus::RetryScheduled => { enums::AttemptStatus::Pending } CheckoutPaymentStatus::Voided => enums::AttemptStatus::Voided, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_attempt_status_cap", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5008216598957983708
clm
function
// connector-service/backend/connector-integration/src/connectors/checkout/transformers.rs fn get_attempt_status_intent( item: (CheckoutPaymentStatus, CheckoutPaymentIntent), ) -> enums::AttemptStatus { let (status, psync_flow) = item; match status { CheckoutPaymentStatus::Authorized => { if psync_flow == CheckoutPaymentIntent::Capture { enums::AttemptStatus::Pending } else { enums::AttemptStatus::Authorized } } CheckoutPaymentStatus::Captured | CheckoutPaymentStatus::PartiallyRefunded | CheckoutPaymentStatus::Refunded => enums::AttemptStatus::Charged, CheckoutPaymentStatus::PartiallyCaptured => enums::AttemptStatus::PartialCharged, CheckoutPaymentStatus::Declined | CheckoutPaymentStatus::Expired | CheckoutPaymentStatus::Canceled => enums::AttemptStatus::Failure, CheckoutPaymentStatus::Pending => enums::AttemptStatus::AuthenticationPending, CheckoutPaymentStatus::CardVerified | CheckoutPaymentStatus::RetryScheduled => { enums::AttemptStatus::Pending } CheckoutPaymentStatus::Voided => enums::AttemptStatus::Voided, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_attempt_status_intent", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5133014760509552792
clm
function
// connector-service/backend/connector-integration/src/connectors/checkout/transformers.rs fn get_attempt_status_bal(item: (CheckoutPaymentStatus, Option<Balances>)) -> enums::AttemptStatus { let (status, balances) = item; match status { CheckoutPaymentStatus::Authorized => { if let Some(Balances { available_to_capture: 0, }) = balances { enums::AttemptStatus::Charged } else { enums::AttemptStatus::Authorized } } CheckoutPaymentStatus::Captured | CheckoutPaymentStatus::PartiallyRefunded | CheckoutPaymentStatus::Refunded => enums::AttemptStatus::Charged, CheckoutPaymentStatus::PartiallyCaptured => enums::AttemptStatus::PartialCharged, CheckoutPaymentStatus::Declined | CheckoutPaymentStatus::Expired | CheckoutPaymentStatus::Canceled => enums::AttemptStatus::Failure, CheckoutPaymentStatus::Pending => enums::AttemptStatus::AuthenticationPending, CheckoutPaymentStatus::CardVerified | CheckoutPaymentStatus::RetryScheduled => { enums::AttemptStatus::Pending } CheckoutPaymentStatus::Voided => enums::AttemptStatus::Voided, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_attempt_status_bal", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-3841855297523034765
clm
function
// connector-service/backend/connector-integration/src/connectors/checkout/transformers.rs fn try_from( item: ResponseRouterData< &ActionResponse, RouterDataV2<F, RefundFlowData, RefundSyncData, RefundsResponseData>, >, ) -> Result<Self, Self::Error> { let ResponseRouterData { response, router_data, http_code, } = item; // Get the refund status using the From implementation let refund_status = enums::RefundStatus::from(response); let mut router_data = router_data; router_data.response = Ok(RefundsResponseData { connector_refund_id: response.action_id.clone(), refund_status, status_code: http_code, }); Ok(router_data) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2434093513669160601
clm
function
// connector-service/backend/connector-integration/src/connectors/cashtocode/transformers.rs fn get_mid( connector_auth_type: &ConnectorAuthType, payment_method_type: Option<common_enums::PaymentMethodType>, currency: common_enums::Currency, ) -> Result<Secret<String>, errors::ConnectorError> { match CashtocodeAuth::try_from((connector_auth_type, &currency)) { Ok(cashtocode_auth) => match payment_method_type { Some(common_enums::PaymentMethodType::ClassicReward) => Ok(cashtocode_auth .merchant_id_classic .ok_or(errors::ConnectorError::FailedToObtainAuthType)?), Some(common_enums::PaymentMethodType::Evoucher) => Ok(cashtocode_auth .merchant_id_evoucher .ok_or(errors::ConnectorError::FailedToObtainAuthType)?), _ => Err(errors::ConnectorError::FailedToObtainAuthType), }, Err(_) => Err(errors::ConnectorError::FailedToObtainAuthType)?, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_mid", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1867878338672038562
clm
function
// connector-service/backend/connector-integration/src/connectors/cashtocode/transformers.rs fn try_from( item: ResponseRouterData<CashtocodePaymentsResponse, Self>, ) -> Result<Self, Self::Error> { let ResponseRouterData { response, router_data, http_code, } = item; let (status, response) = match response { CashtocodePaymentsResponse::CashtoCodeError(error_data) => ( common_enums::AttemptStatus::Failure, Err(ErrorResponse { code: error_data.error.to_string(), status_code: item.http_code, message: error_data.error_description.clone(), reason: Some(error_data.error_description), attempt_status: None, connector_transaction_id: None, network_advice_code: None, network_decline_code: None, network_error_message: None, }), ), CashtocodePaymentsResponse::CashtoCodeData(response_data) => { let payment_method_type = router_data .request .payment_method_type .ok_or(errors::ConnectorError::MissingPaymentMethodType)?; let redirection_data = get_redirect_form_data(payment_method_type, response_data)?; ( common_enums::AttemptStatus::AuthenticationPending, Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId( router_data .resource_common_data .connector_request_reference_id .clone(), ), redirection_data: Some(Box::new(redirection_data)), 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 { resource_common_data: PaymentFlowData { status, ..router_data.resource_common_data }, response, ..router_data }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-5154119684211301797
clm
function
// connector-service/backend/connector-integration/src/connectors/cashtocode/transformers.rs fn from(item: CashtocodePaymentStatus) -> Self { match item { CashtocodePaymentStatus::Succeeded => Self::Charged, CashtocodePaymentStatus::Processing => Self::AuthenticationPending, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_6883614331911483996
clm
function
// connector-service/backend/connector-integration/src/connectors/cashtocode/transformers.rs fn get_redirect_form_data( payment_method_type: common_enums::PaymentMethodType, response_data: CashtocodePaymentsResponseData, ) -> CustomResult<RedirectForm, errors::ConnectorError> { match payment_method_type { common_enums::PaymentMethodType::ClassicReward => Ok(RedirectForm::Form { //redirect form is manually constructed because the connector for this pm type expects query params in the url endpoint: response_data.pay_url.to_string(), method: Method::Post, form_fields: Default::default(), }), common_enums::PaymentMethodType::Evoucher => Ok(RedirectForm::Form { //here the pay url gets parsed, and query params are sent as formfields as the connector expects endpoint: response_data.pay_url.to_string(), method: Method::Get, form_fields: Default::default(), }), _ => Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("CashToCode"), ))?, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_redirect_form_data", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_8339934356743527216
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn card_issuer_to_string(card_issuer: CardIssuer) -> String { let card_type = match card_issuer { CardIssuer::AmericanExpress => "003", CardIssuer::Master => "002", //"042" is the type code for Masetro Cards(International). For Maestro Cards(UK-Domestic) the mapping should be "024" CardIssuer::Maestro => "042", CardIssuer::Visa => "001", CardIssuer::Discover => "004", CardIssuer::DinersClub => "005", CardIssuer::CarteBlanche => "006", CardIssuer::JCB => "007", CardIssuer::CartesBancaires => "036", }; card_type.to_string() }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "card_issuer_to_string", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_7619619377881359831
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn try_from( (item, solution, network): ( &CybersourceRouterData< RouterDataV2< RepeatPayment, PaymentFlowData, RepeatPaymentData, PaymentsResponseData, >, T, >, Option<PaymentSolution>, Option<String>, ), ) -> Result<Self, Self::Error> { let commerce_indicator = solution .as_ref() .map(|pm_solution| match pm_solution { PaymentSolution::ApplePay | PaymentSolution::SamsungPay => network .as_ref() .map(|card_network| match card_network.to_lowercase().as_str() { "mastercard" => "spa", _ => "internet", }) .unwrap_or("internet"), PaymentSolution::GooglePay => "internet", }) .unwrap_or("internet") .to_string(); let connector_merchant_config = CybersourceConnectorMetadataObject::try_from( &item.router_data.request.merchant_account_metadata, )?; // Extract connector mandate ID from mandate_reference let connector_mandate_id = match &item.router_data.request.mandate_reference { MandateReferenceId::ConnectorMandateId(connector_mandate_data) => { connector_mandate_data .get_connector_mandate_id() .ok_or_else(|| errors::ConnectorError::MissingRequiredField { field_name: "connector_mandate_id", })? } MandateReferenceId::NetworkMandateId(_) | MandateReferenceId::NetworkTokenWithNTI(_) => { return Err(error_stack::report!(errors::ConnectorError::NotSupported { message: "Network mandate ID not supported for Cybersource repeat payments" .to_string(), connector: "cybersource", })); } }; let (action_list, action_token_types, authorization_options) = if !connector_mandate_id .is_empty() { match item.router_data.request.mandate_reference.clone() { MandateReferenceId::ConnectorMandateId(_) => { let original_amount = item .router_data .request .recurring_mandate_payment_data .as_ref() .and_then(|recurring_mandate_payment_data| { recurring_mandate_payment_data.original_payment_authorized_amount }); let original_currency = item .router_data .request .recurring_mandate_payment_data .as_ref() .and_then(|recurring_mandate_payment_data| { recurring_mandate_payment_data.original_payment_authorized_currency }); let original_authorized_amount = match original_amount.zip(original_currency) { Some((original_amount, original_currency)) => { Some(domain_types::utils::get_amount_as_string( &common_enums::CurrencyUnit::Base, original_amount, original_currency, )?) } None => None, }; ( None, None, Some(CybersourceAuthorizationOptions { initiator: None, merchant_initiated_transaction: Some(MerchantInitiatedTransaction { reason: None, original_authorized_amount, previous_transaction_id: None, }), ignore_avs_result: connector_merchant_config.disable_avs, ignore_cv_result: connector_merchant_config.disable_cvn, }), ) } MandateReferenceId::NetworkMandateId(_) | MandateReferenceId::NetworkTokenWithNTI(_) => { return Err(error_stack::report!(errors::ConnectorError::NotSupported { message: "Network mandate ID not supported for Cybersource repeat payments" .to_string(), connector: "cybersource", })); } } } else { ( None, None, Some(CybersourceAuthorizationOptions { initiator: None, merchant_initiated_transaction: None, ignore_avs_result: connector_merchant_config.disable_avs, ignore_cv_result: connector_merchant_config.disable_cvn, }), ) }; Ok(Self { capture: Some(matches!( item.router_data.request.capture_method, Some(common_enums::CaptureMethod::Automatic) | None )), payment_solution: solution.map(String::from), action_list, action_token_types, authorization_options, capture_options: None, commerce_indicator, }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-4165971609938476048
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn from(item: CybersourceRefundStatus) -> Self { match item { CybersourceRefundStatus::Succeeded | CybersourceRefundStatus::Transmitted => { Self::Success } CybersourceRefundStatus::Cancelled | CybersourceRefundStatus::Failed | CybersourceRefundStatus::Voided => Self::Failure, CybersourceRefundStatus::Pending => Self::Pending, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-8019715245686394547
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn get_authentication_data_for_check_enrollment_response( response: CybersourceConsumerAuthInformationEnrollmentResponse, ) -> router_request_types::AuthenticationData { let trans_status = response .validate_response .pares_status .map(common_enums::TransactionStatus::from); // CAVV is populated from UCAF data if available(for mastercard), else from CAVV field let cavv = response .validate_response .ucaf_authentication_data .or(response.validate_response.cavv); let eci = response.validate_response.ecommerce_indicator; let ucaf_collection_indicator = response.validate_response.ucaf_collection_indicator.clone(); let ds_trans_id = response .validate_response .directory_server_transaction_id .map(|id| id.expose()); router_request_types::AuthenticationData { ucaf_collection_indicator, eci, cavv, threeds_server_transaction_id: response.validate_response.three_d_s_server_transaction_id, message_version: response.validate_response.specification_version, trans_status, ds_trans_id, acs_transaction_id: response.validate_response.acs_transaction_id, transaction_id: response.validate_response.xid, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_authentication_data_for_check_enrollment_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_305558305954841632
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn get_authentication_data_for_validation_response( response: CybersourceConsumerAuthInformationEnrollmentResponse, ) -> router_request_types::AuthenticationData { let trans_status = response .validate_response .pares_status .map(common_enums::TransactionStatus::from); // CAVV is populated from UCAF data if available(for mastercard), else from CAVV field let cavv = response .validate_response .ucaf_authentication_data .or(response.validate_response.cavv); let eci = response.validate_response.indicator; let ucaf_collection_indicator = response.validate_response.ucaf_collection_indicator.clone(); let ds_trans_id = response .validate_response .directory_server_transaction_id .map(|id| id.expose()); router_request_types::AuthenticationData { ucaf_collection_indicator, eci, cavv, threeds_server_transaction_id: response.validate_response.three_d_s_server_transaction_id, message_version: response.validate_response.specification_version, trans_status, ds_trans_id, acs_transaction_id: response.validate_response.acs_transaction_id, transaction_id: response.validate_response.xid, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_authentication_data_for_validation_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_7498401018909472574
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn truncate_string(state: &Secret<String>, max_len: usize) -> Secret<String> { let exposed = state.clone().expose(); let truncated = exposed.get(..max_len).unwrap_or(&exposed); Secret::new(truncated.to_string()) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "truncate_string", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_8046806024228547471
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn build_bill_to( address_details: Option<&Address>, email: pii::Email, ) -> Result<BillTo, error_stack::Report<errors::ConnectorError>> { let default_address = BillTo { first_name: None, last_name: None, address1: None, locality: None, administrative_area: None, postal_code: None, country: None, email: email.clone(), }; Ok(address_details .and_then(|addr| { addr.address.as_ref().map(|addr| BillTo { first_name: addr.first_name.remove_new_line(), last_name: addr.last_name.remove_new_line(), address1: addr.line1.remove_new_line(), locality: addr.city.remove_new_line(), administrative_area: addr.to_state_code_as_optional().unwrap_or_else(|_| { addr.state .remove_new_line() .as_ref() .map(|state| truncate_string(state, 20)) //NOTE: Cybersource connector throws error if billing state exceeds 20 characters, so truncation is done to avoid payment failure }), postal_code: addr.zip.remove_new_line(), country: addr.country, email, }) }) .unwrap_or(default_address)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "build_bill_to", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-8939643827257498663
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn convert_metadata_to_merchant_defined_info(metadata: Value) -> Vec<MerchantDefinedInformation> { let hashmap: std::collections::BTreeMap<String, Value> = serde_json::from_str(&metadata.to_string()).unwrap_or(std::collections::BTreeMap::new()); let mut vector = Vec::new(); let mut iter = 1; for (key, value) in hashmap { vector.push(MerchantDefinedInformation { key: iter, value: format!("{key}={value}"), }); iter += 1; } vector }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "convert_metadata_to_merchant_defined_info", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-8248328403727091815
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn get_samsung_pay_payment_information< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( samsung_pay_data: &payment_method_data::SamsungPayWalletData, ) -> Result<PaymentInformation<T>, error_stack::Report<errors::ConnectorError>> { let samsung_pay_fluid_data_value = get_samsung_pay_fluid_data_value(&samsung_pay_data.payment_credential.token_data)?; let samsung_pay_fluid_data_str = serde_json::to_string(&samsung_pay_fluid_data_value) .change_context(errors::ConnectorError::RequestEncodingFailed) .attach_printable("Failed to serialize samsung pay fluid data")?; let payment_information = PaymentInformation::SamsungPay(Box::new(SamsungPayPaymentInformation { fluid_data: FluidData { value: Secret::new(BASE64_ENGINE.encode(samsung_pay_fluid_data_str)), descriptor: Some(BASE64_ENGINE.encode(FLUID_DATA_DESCRIPTOR_FOR_SAMSUNG_PAY)), }, tokenized_card: SamsungPayTokenizedCard { transaction_type: TransactionType::InApp, }, })); Ok(payment_information) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_samsung_pay_payment_information", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5532048770562631172
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn get_samsung_pay_fluid_data_value( samsung_pay_token_data: &payment_method_data::SamsungPayTokenData, ) -> Result<SamsungPayFluidDataValue, error_stack::Report<errors::ConnectorError>> { let samsung_pay_header = jwt::decode_header(samsung_pay_token_data.data.clone().peek()) .change_context(errors::ConnectorError::RequestEncodingFailed) .attach_printable("Failed to decode samsung pay header")?; let samsung_pay_kid_optional = samsung_pay_header.kid; let samsung_pay_fluid_data_value = SamsungPayFluidDataValue { public_key_hash: Secret::new( samsung_pay_kid_optional .get_required_value("samsung pay public_key_hash") .change_context(errors::ConnectorError::RequestEncodingFailed)? .to_string(), ), version: samsung_pay_token_data.version.clone(), data: Secret::new(BASE64_ENGINE.encode(samsung_pay_token_data.data.peek())), }; Ok(samsung_pay_fluid_data_value) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_samsung_pay_fluid_data_value", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_8082865412243660934
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs pub fn map_cybersource_attempt_status( status: CybersourcePaymentStatus, capture: bool, ) -> common_enums::AttemptStatus { match status { CybersourcePaymentStatus::Authorized => { if capture { // Because Cybersource will return Payment Status as Authorized even in AutoCapture Payment common_enums::AttemptStatus::Charged } else { common_enums::AttemptStatus::Authorized } } CybersourcePaymentStatus::Succeeded | CybersourcePaymentStatus::Transmitted => { common_enums::AttemptStatus::Charged } CybersourcePaymentStatus::Voided | CybersourcePaymentStatus::Reversed | CybersourcePaymentStatus::Cancelled => common_enums::AttemptStatus::Voided, CybersourcePaymentStatus::Failed | CybersourcePaymentStatus::Declined | CybersourcePaymentStatus::AuthorizedRiskDeclined | CybersourcePaymentStatus::Rejected | CybersourcePaymentStatus::InvalidRequest | CybersourcePaymentStatus::ServerError => common_enums::AttemptStatus::Failure, CybersourcePaymentStatus::PendingAuthentication => { common_enums::AttemptStatus::AuthenticationPending } CybersourcePaymentStatus::PendingReview | CybersourcePaymentStatus::StatusNotReceived | CybersourcePaymentStatus::Challenge | CybersourcePaymentStatus::Accepted | CybersourcePaymentStatus::Pending | CybersourcePaymentStatus::AuthorizedPendingReview => common_enums::AttemptStatus::Pending, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "map_cybersource_attempt_status", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-4136628398086485022
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn get_error_response_if_failure( (info_response, status, http_code): ( &CybersourcePaymentsResponse, common_enums::AttemptStatus, u16, ), ) -> Option<ErrorResponse> { if domain_types::utils::is_payment_failure(status) { Some(get_error_response( &info_response.error_information, &info_response.processor_information, &info_response.risk_information, Some(status), http_code, info_response.id.clone(), )) } else { None } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_error_response_if_failure", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2599135435502679244
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn get_payment_response( (info_response, status, http_code): ( &CybersourcePaymentsResponse, common_enums::AttemptStatus, u16, ), ) -> Result<PaymentsResponseData, Box<ErrorResponse>> { let error_response = get_error_response_if_failure((info_response, status, http_code)); match error_response { Some(error) => Err(Box::new(error)), None => { let incremental_authorization_allowed = Some(status == common_enums::AttemptStatus::Authorized); let mandate_reference = info_response .token_information .clone() .map(|token_info| MandateReference { connector_mandate_id: token_info .payment_instrument .map(|payment_instrument| payment_instrument.id.expose()), payment_method_id: None, }); Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(info_response.id.clone()), redirection_data: None, mandate_reference: mandate_reference.map(Box::new), connector_metadata: None, network_txn_id: info_response.processor_information.as_ref().and_then( |processor_information| processor_information.network_transaction_id.clone(), ), connector_response_reference_id: Some( info_response .client_reference_information .clone() .and_then(|client_reference_information| client_reference_information.code) .unwrap_or(info_response.id.clone()), ), incremental_authorization_allowed, status_code: http_code, }) } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_payment_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-1078727645221439739
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs pub fn get_error_response( error_data: &Option<CybersourceErrorInformation>, processor_information: &Option<ClientProcessorInformation>, risk_information: &Option<ClientRiskInformation>, attempt_status: Option<common_enums::AttemptStatus>, status_code: u16, transaction_id: String, ) -> ErrorResponse { let avs_message = risk_information .clone() .map(|client_risk_information| { client_risk_information.rules.map(|rules| { rules .iter() .map(|risk_info| { risk_info.name.clone().map_or("".to_string(), |name| { format!(" , {}", name.clone().expose()) }) }) .collect::<Vec<String>>() .join("") }) }) .unwrap_or(Some("".to_string())); let detailed_error_info = error_data.as_ref().and_then(|error_data| { error_data.details.as_ref().map(|details| { details .iter() .map(|detail| format!("{} : {}", detail.field, detail.reason)) .collect::<Vec<_>>() .join(", ") }) }); let network_decline_code = processor_information .as_ref() .and_then(|info| info.response_code.clone()); let network_advice_code = processor_information.as_ref().and_then(|info| { info.merchant_advice .as_ref() .and_then(|merchant_advice| merchant_advice.code_raw.clone()) }); let reason = get_error_reason( error_data .as_ref() .and_then(|error_info| error_info.message.clone()), detailed_error_info, avs_message, ); let error_message = error_data .as_ref() .and_then(|error_info| error_info.reason.clone()); ErrorResponse { code: error_message .clone() .unwrap_or_else(|| NO_ERROR_CODE.to_string()), message: error_message.unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()), reason, status_code, attempt_status, connector_transaction_id: Some(transaction_id), network_advice_code, network_decline_code, 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": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-439592443807537185
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs pub fn get_error_reason( error_info: Option<String>, detailed_error_info: Option<String>, avs_error_info: Option<String>, ) -> Option<String> { match (error_info, detailed_error_info, avs_error_info) { (Some(message), Some(details), Some(avs_message)) => Some(format!( "{message}, detailed_error_information: {details}, avs_message: {avs_message}", )), (Some(message), Some(details), None) => { Some(format!("{message}, detailed_error_information: {details}")) } (Some(message), None, Some(avs_message)) => { Some(format!("{message}, avs_message: {avs_message}")) } (None, Some(details), Some(avs_message)) => { Some(format!("{details}, avs_message: {avs_message}")) } (Some(message), None, None) => Some(message), (None, Some(details), None) => Some(details), (None, None, Some(avs_message)) => Some(avs_message), (None, None, None) => None, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_error_reason", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_7012713584769309075
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn get_cybersource_card_type(card_network: common_enums::CardNetwork) -> Option<&'static str> { match card_network { common_enums::CardNetwork::Visa => Some("001"), common_enums::CardNetwork::Mastercard => Some("002"), common_enums::CardNetwork::AmericanExpress => Some("003"), common_enums::CardNetwork::JCB => Some("007"), common_enums::CardNetwork::DinersClub => Some("005"), common_enums::CardNetwork::Discover => Some("004"), common_enums::CardNetwork::CartesBancaires => Some("036"), common_enums::CardNetwork::UnionPay => Some("062"), //"042" is the type code for Masetro Cards(International). For Maestro Cards(UK-Domestic) the mapping should be "024" common_enums::CardNetwork::Maestro => Some("042"), common_enums::CardNetwork::Interac | common_enums::CardNetwork::RuPay | common_enums::CardNetwork::Star | common_enums::CardNetwork::Accel | common_enums::CardNetwork::Pulse | common_enums::CardNetwork::Nyce => None, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_cybersource_card_type", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-4004266570812326990
clm
function
// connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs fn remove_new_line(&self) -> Self { self.clone().map(|value| value.replace("\n", " ")) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "remove_new_line", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-445441321632269646
clm
function
// connector-service/backend/connector-integration/src/connectors/cryptopay/transformers.rs fn try_from(notif: CryptopayWebhookDetails) -> Result<Self, Self::Error> { let status = common_enums::AttemptStatus::from(notif.data.status.clone()); if is_payment_failure(status) { Ok(Self { error_code: Some( notif .data .name .clone() .unwrap_or(consts::NO_ERROR_CODE.to_string()), ), error_message: Some( notif .data .status_context .clone() .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), ), error_reason: notif.data.status_context.clone(), status_code: 200, status: common_enums::AttemptStatus::Unknown, resource_id: Some(ResponseId::ConnectorTransactionId(notif.data.id.clone())), connector_response_reference_id: None, mandate_reference: None, raw_connector_response: None, response_headers: None, transformation_status: common_enums::WebhookTransformationStatus::Complete, minor_amount_captured: None, amount_captured: None, network_txn_id: None, }) } else { let amount_captured_in_minor_units = match (notif.data.price_amount, notif.data.price_currency) { (Some(amount), Some(currency)) => { Some(CryptopayAmountConvertor::convert_back(amount, currency)?) } _ => None, }; match (amount_captured_in_minor_units, status) { (Some(minor_amount), common_enums::AttemptStatus::Charged) => { let amount_captured = Some(minor_amount.get_amount_as_i64()); Ok(Self { amount_captured, minor_amount_captured: amount_captured_in_minor_units, status, resource_id: Some(ResponseId::ConnectorTransactionId( notif.data.id.clone(), )), error_reason: None, mandate_reference: None, status_code: 200, connector_response_reference_id: notif .data .custom_id .or(Some(notif.data.id)), error_code: None, error_message: None, raw_connector_response: None, response_headers: None, network_txn_id: None, transformation_status: common_enums::WebhookTransformationStatus::Complete, }) } _ => Ok(Self { status, resource_id: Some(ResponseId::ConnectorTransactionId(notif.data.id.clone())), mandate_reference: None, status_code: 200, connector_response_reference_id: notif.data.custom_id.or(Some(notif.data.id)), error_code: None, error_message: None, raw_connector_response: None, response_headers: None, minor_amount_captured: None, amount_captured: None, error_reason: None, network_txn_id: None, transformation_status: common_enums::WebhookTransformationStatus::Complete, }), } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-5655207447427497326
clm
function
// connector-service/backend/connector-integration/src/connectors/cryptopay/transformers.rs fn from(item: CryptopayPaymentStatus) -> Self { match item { CryptopayPaymentStatus::New => Self::AuthenticationPending, CryptopayPaymentStatus::Completed => Self::Charged, CryptopayPaymentStatus::Cancelled => Self::Failure, CryptopayPaymentStatus::Unresolved | CryptopayPaymentStatus::Refunded => { Self::Unresolved } //mapped refunded to Unresolved because refund api is not available, also merchant has done the action on the connector dashboard. } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_6584227525461909224
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpayv2/test.rs fn test_upi_flow_determination() { // Add tests for UPI flow determination logic // TODO: Implement comprehensive tests }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_upi_flow_determination", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1558662536331175589
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpayv2/test.rs fn test_create_order_request_building() { // Add tests for create order request building // TODO: Implement comprehensive tests }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_create_order_request_building", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_7335008701231297933
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpayv2/test.rs fn test_payments_request_building() { // Add tests for payments request building // TODO: Implement comprehensive tests }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payments_request_building", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1676547017282257746
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpayv2/transformers.rs pub fn generate_authorization_header(&self) -> String { match self { RazorpayV2AuthType::AuthToken(token) => format!("Bearer {}", token.peek()), RazorpayV2AuthType::ApiKeySecret { api_key, api_secret, } => { let credentials = format!("{}:{}", api_key.peek(), api_secret.peek()); let encoded = STANDARD.encode(credentials); format!("Basic {encoded}") } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "generate_authorization_header", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-4026817227612703553
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpayv2/transformers.rs fn try_from(item: &RazorpayV2RouterData<&RefundsData, U>) -> Result<Self, Self::Error> { let amount_in_minor_units = item.amount.get_amount_as_i64(); Ok(Self { amount: amount_in_minor_units, }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_593002213147923887
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpayv2/transformers.rs fn get_psync_razorpay_payment_status(razorpay_status: RazorpayStatus) -> AttemptStatus { match razorpay_status { RazorpayStatus::Created => AttemptStatus::Pending, RazorpayStatus::Authorized => AttemptStatus::Authorized, RazorpayStatus::Captured => AttemptStatus::Charged, RazorpayStatus::Refunded => AttemptStatus::AutoRefunded, RazorpayStatus::Failed => AttemptStatus::Failure, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_psync_razorpay_payment_status", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2965787975485232033
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpayv2/transformers.rs fn foreign_try_from( (response, data, _status_code, __raw_response): ( RazorpayV2PaymentsResponse, RouterDataV2< Authorize, PaymentFlowData, PaymentsAuthorizeData<T>, PaymentsResponseData, >, u16, Vec<u8>, ), ) -> Result<Self, Self::Error> { let payments_response_data = PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(response.id), redirection_data: None, connector_metadata: None, mandate_reference: None, network_txn_id: None, connector_response_reference_id: data.resource_common_data.reference_id.clone(), incremental_authorization_allowed: None, status_code: _status_code, }; Ok(RouterDataV2 { response: Ok(payments_response_data), resource_common_data: PaymentFlowData { status: AttemptStatus::AuthenticationPending, ..data.resource_common_data }, ..data }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "foreign_try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-1285128844360666749
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs fn try_from( item: ResponseRouterData< TrustpayAuthUpdateResponse, RouterDataV2< CreateAccessToken, PaymentFlowData, AccessTokenRequestData, AccessTokenResponseData, >, >, ) -> Result<Self, Self::Error> { match (item.response.access_token, item.response.expires_in) { (Some(access_token), Some(expires_in)) => Ok(Self { response: Ok(AccessTokenResponseData { access_token: access_token.expose(), expires_in: Some(expires_in), token_type: Some(item.router_data.request.grant_type.clone()), }), ..item.router_data }), _ => Ok(Self { response: Err(ErrorResponse { code: item.response.result_info.result_code.to_string(), // message vary for the same code, so relying on code alone as it is unique message: item.response.result_info.result_code.to_string(), reason: item.response.result_info.additional_info, status_code: item.http_code, attempt_status: None, connector_transaction_id: None, network_advice_code: None, network_decline_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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_7812994628977182480
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs pub fn error_message(&self) -> &'static str { match self { Self::EmptyCvvNotAllowed => "Empty CVV for VISA, MASTER not allowed", Self::SessionRejected => "Referenced session is rejected (no action possible)", Self::UserAuthenticationFailed => "User authentication failed", Self::RiskManagementTimeout => "Risk management transaction timeout", Self::PaResValidationFailed => "PARes validation failed - problem with signature", Self::ThreeDSecureSystemError => "Transaction rejected because of technical error in 3DSecure system", Self::DirectoryServerError => "Communication error to VISA/Mastercard Directory Server", Self::ThreeDSystemError => "Technical error in 3D system", Self::AuthenticationInvalidFormat => "Authentication failed due to invalid message format", Self::AuthenticationSuspectedFraud => "Authentication failed due to suspected fraud", Self::InvalidInputData => "Invalid input data", Self::AmountOutsideBoundaries => "Amount is outside allowed ticket size boundaries", Self::InvalidOrMissingParameter => "Invalid or missing parameter", Self::AdditionalAuthRequired => "Transaction declined (additional customer authentication required)", Self::CardNotEnrolledIn3DS => "Card not enrolled in 3DS", Self::AuthenticationError => "Authentication error", Self::TransactionDeclinedAuth => "Transaction declined (auth. declined)", Self::InvalidTransaction1 => "Invalid transaction", Self::InvalidTransaction2 => "Invalid transaction", Self::NoDescription => "No description available.", Self::CannotRefund => "Cannot refund (refund volume exceeded or tx reversed or invalid workflow)", Self::TooManyTransactions => "Referenced session contains too many transactions", Self::TestAccountsNotAllowed => "Test accounts not allowed in production", Self::DeclinedUnknownReason => "Transaction declined for unknown reason", Self::DeclinedInvalidCard => "Transaction declined (invalid card)", Self::DeclinedByAuthSystem => "Transaction declined by authorization system", Self::DeclinedInvalidCvv => "Transaction declined (invalid CVV)", Self::DeclinedExceedsCredit => "Transaction declined (amount exceeds credit)", Self::DeclinedWrongExpiry => "Transaction declined (wrong expiry date)", Self::DeclinedSuspectingManipulation => "transaction declined (suspecting manipulation)", Self::DeclinedCardBlocked => "transaction declined (card blocked)", Self::DeclinedLimitExceeded => "Transaction declined (limit exceeded)", Self::DeclinedFrequencyExceeded => "Transaction declined (maximum transaction frequency exceeded)", Self::DeclinedCardLost => "Transaction declined (card lost)", Self::DeclinedRestrictedCard => "Transaction declined (restricted card)", Self::DeclinedNotPermitted => "Transaction declined (transaction not permitted)", Self::DeclinedPickUpCard => "transaction declined (pick up card)", Self::DeclinedAccountBlocked => "Transaction declined (account blocked)", Self::DeclinedInvalidConfig => "Transaction declined (invalid configuration data)", Self::AccountClosed => "Account Closed", Self::InsufficientFunds => "Insufficient Funds", Self::RejectedByThrottling => "Rejected by throttling", Self::CountryBlacklisted => "Country blacklisted", Self::BinBlacklisted => "Bin blacklisted", Self::SessionBeingProcessed => "Transaction for the same session is currently being processed, please try again later", Self::CommunicationError => "Unexpected communication error with connector/acquirer", Self::TimeoutUncertainResult => "Timeout, uncertain result", Self::Unknown => "", } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "error_message", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_6693742641953233707
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs pub fn is_failure(&self) -> bool { !matches!(self, Self::Unknown) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "is_failure", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1583704845102738579
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs fn from(item: TrustpayBankRedirectPaymentStatus) -> Self { match item { TrustpayBankRedirectPaymentStatus::Paid => Self::Success, TrustpayBankRedirectPaymentStatus::Rejected => Self::Failure, _ => Self::Pending, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-5912870118739466683
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs fn is_payment_failed(payment_status: &str) -> (bool, &'static str) { let status_code = TrustpayPaymentStatusCode::from(payment_status); (status_code.is_failure(), status_code.error_message()) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "is_payment_failed", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_6622341884730005451
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs fn is_payment_successful(payment_status: &str) -> CustomResult<bool, errors::ConnectorError> { match payment_status { "000.400.100" => Ok(true), _ => { let allowed_prefixes = [ "000.000.", "000.100.1", "000.3", "000.6", "000.400.01", "000.400.02", "000.400.04", "000.400.05", "000.400.06", "000.400.07", "000.400.08", "000.400.09", ]; let is_valid = allowed_prefixes .iter() .any(|&prefix| payment_status.starts_with(prefix)); Ok(is_valid) } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "is_payment_successful", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_2952569615443560748
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs fn get_pending_status_based_on_redirect_url(redirect_url: Option<Url>) -> enums::AttemptStatus { match redirect_url { Some(_url) => enums::AttemptStatus::AuthenticationPending, None => enums::AttemptStatus::Pending, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_pending_status_based_on_redirect_url", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-5915264256727995919
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs fn get_transaction_status( payment_status: Option<String>, redirect_url: Option<Url>, ) -> CustomResult<(enums::AttemptStatus, Option<String>), errors::ConnectorError> { // We don't get payment_status only in case, when the user doesn't complete the authentication step. // If we receive status, then return the proper status based on the connector response if let Some(payment_status) = payment_status { let (is_failed, failure_message) = is_payment_failed(&payment_status); if is_failed { Ok(( enums::AttemptStatus::Failure, Some(failure_message.to_string()), )) } else if is_payment_successful(&payment_status)? { Ok((enums::AttemptStatus::Charged, None)) } else { let pending_status = get_pending_status_based_on_redirect_url(redirect_url); Ok((pending_status, None)) } } else { Ok((enums::AttemptStatus::AuthenticationPending, None)) } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_transaction_status", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1583055968923952888
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs fn handle_cards_response( response: PaymentsResponseCards, status_code: u16, ) -> CustomResult< ( enums::AttemptStatus, Option<ErrorResponse>, PaymentsResponseData, ), errors::ConnectorError, > { let (status, message) = get_transaction_status( response.payment_status.to_owned(), response.redirect_url.to_owned(), )?; let form_fields = response.redirect_params.unwrap_or_default(); let redirection_data = response.redirect_url.map(|url| RedirectForm::Form { endpoint: url.to_string(), method: Method::Post, form_fields, }); let error = if message.is_some() { Some(ErrorResponse { code: response .payment_status .unwrap_or_else(|| NO_ERROR_CODE.to_string()), message: message .clone() .unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()), reason: message, status_code, attempt_status: None, connector_transaction_id: Some(response.instance_id.clone()), network_advice_code: None, network_decline_code: None, network_error_message: None, }) } else { None }; let payment_response_data = PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(response.instance_id.clone()), redirection_data: redirection_data.map(Box::new), mandate_reference: None, connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, status_code, }; Ok((status, error, payment_response_data)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "handle_cards_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-3517347824656025567
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs fn handle_bank_redirects_response( response: PaymentsResponseBankRedirect, status_code: u16, ) -> CustomResult< ( enums::AttemptStatus, Option<ErrorResponse>, PaymentsResponseData, ), errors::ConnectorError, > { let status = enums::AttemptStatus::AuthenticationPending; let error = None; let payment_response_data = PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(response.payment_request_id.to_string()), redirection_data: Some(Box::new(RedirectForm::from(( response.gateway_url, Method::Get, )))), mandate_reference: None, connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, status_code, }; Ok((status, error, payment_response_data)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "handle_bank_redirects_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-4374479314201853124
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs fn handle_bank_redirects_error_response( response: ErrorResponseBankRedirect, status_code: u16, previous_attempt_status: enums::AttemptStatus, ) -> CustomResult< ( enums::AttemptStatus, Option<ErrorResponse>, PaymentsResponseData, ), errors::ConnectorError, > { let status = if matches!(response.payment_result_info.result_code, 1132014 | 1132005) { previous_attempt_status } else { enums::AttemptStatus::AuthorizationFailed }; let error = Some(ErrorResponse { code: response.payment_result_info.result_code.to_string(), // message vary for the same code, so relying on code alone as it is unique message: response.payment_result_info.result_code.to_string(), reason: response.payment_result_info.additional_info, status_code, attempt_status: Some(status), connector_transaction_id: None, network_advice_code: None, network_decline_code: None, network_error_message: None, }); let payment_response_data = PaymentsResponseData::TransactionResponse { resource_id: ResponseId::NoResponseId, redirection_data: None, mandate_reference: None, connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, status_code, }; Ok((status, error, payment_response_data)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "handle_bank_redirects_error_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-1347416815255535494
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs fn handle_bank_redirects_sync_response( response: SyncResponseBankRedirect, status_code: u16, ) -> CustomResult< ( enums::AttemptStatus, Option<ErrorResponse>, PaymentsResponseData, ), errors::ConnectorError, > { let status = enums::AttemptStatus::from(response.payment_information.status); let error = if domain_types::utils::is_payment_failure(status) { let reason_info = response .payment_information .status_reason_information .unwrap_or_default(); Some(ErrorResponse { code: reason_info .reason .code .clone() .unwrap_or(NO_ERROR_CODE.to_string()), // message vary for the same code, so relying on code alone as it is unique message: reason_info .reason .code .unwrap_or(NO_ERROR_MESSAGE.to_string()), reason: reason_info.reason.reject_reason, status_code, attempt_status: None, connector_transaction_id: Some( response .payment_information .references .payment_request_id .clone(), ), network_advice_code: None, network_decline_code: None, network_error_message: None, }) } else { None }; let payment_response_data = PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId( response .payment_information .references .payment_request_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, }; Ok((status, error, payment_response_data)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "handle_bank_redirects_sync_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2715685907814403815
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs pub fn handle_webhook_response( payment_information: WebhookPaymentInformation, status_code: u16, ) -> CustomResult< ( enums::AttemptStatus, Option<ErrorResponse>, PaymentsResponseData, ), errors::ConnectorError, > { let status = enums::AttemptStatus::try_from(payment_information.status)?; let error = if domain_types::utils::is_payment_failure(status) { let reason_info = payment_information .status_reason_information .unwrap_or_default(); Some(ErrorResponse { code: reason_info .reason .code .clone() .unwrap_or(NO_ERROR_CODE.to_string()), // message vary for the same code, so relying on code alone as it is unique message: reason_info .reason .code .unwrap_or(NO_ERROR_MESSAGE.to_string()), reason: reason_info.reason.reject_reason, status_code, attempt_status: None, connector_transaction_id: payment_information.references.payment_request_id.clone(), network_advice_code: None, network_decline_code: None, network_error_message: None, }) } else { None }; let payment_response_data = PaymentsResponseData::TransactionResponse { resource_id: ResponseId::NoResponseId, redirection_data: None, mandate_reference: None, connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, status_code, }; Ok((status, error, payment_response_data)) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "handle_webhook_response", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1129761068507008509
clm
function
// connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs pub fn get_trustpay_response( response: TrustpayPaymentsResponse, status_code: u16, previous_attempt_status: enums::AttemptStatus, ) -> CustomResult< ( enums::AttemptStatus, Option<ErrorResponse>, PaymentsResponseData, ), errors::ConnectorError, > { match response { TrustpayPaymentsResponse::CardsPayments(response) => { handle_cards_response(*response, status_code) } TrustpayPaymentsResponse::BankRedirectPayments(response) => { handle_bank_redirects_response(*response, status_code) } TrustpayPaymentsResponse::BankRedirectSync(response) => { handle_bank_redirects_sync_response(*response, status_code) } TrustpayPaymentsResponse::BankRedirectError(response) => { handle_bank_redirects_error_response(*response, status_code, previous_attempt_status) } TrustpayPaymentsResponse::WebhookResponse(response) => { handle_webhook_response(*response, status_code) } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_trustpay_response", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-6845142066205286710
clm
function
// connector-service/backend/connector-integration/src/connectors/xendit/transformers.rs fn try_from(item: ResponseRouterData<RefundResponse, Self>) -> Result<Self, Self::Error> { let ResponseRouterData { response, router_data, http_code, } = item; Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: response.id, refund_status: common_enums::RefundStatus::from(response.status), status_code: http_code, }), ..router_data }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-7764359483446056564
clm
function
// connector-service/backend/connector-integration/src/connectors/xendit/transformers.rs fn is_auto_capture< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( data: &PaymentsAuthorizeData<T>, ) -> Result<bool, ConnectorError> { match data.capture_method { Some(common_enums::CaptureMethod::Automatic) | None => Ok(true), Some(common_enums::CaptureMethod::Manual) => Ok(false), Some(_) => Err(ConnectorError::CaptureMethodNotSupported), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "is_auto_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_2957072239002240268
clm
function
// connector-service/backend/connector-integration/src/connectors/xendit/transformers.rs fn is_auto_capture_psync(data: &PaymentsSyncData) -> Result<bool, ConnectorError> { match data.capture_method { Some(common_enums::CaptureMethod::Automatic) | None => Ok(true), Some(common_enums::CaptureMethod::Manual) => Ok(false), Some(_) => Err(ConnectorError::CaptureMethodNotSupported), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "is_auto_capture_psync", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_1220201645857116306
clm
function
// connector-service/backend/connector-integration/src/connectors/xendit/transformers.rs fn map_payment_response_to_attempt_status( response: XenditPaymentResponse, is_auto_capture: bool, ) -> common_enums::AttemptStatus { match response.status { PaymentStatus::Failed => common_enums::AttemptStatus::Failure, PaymentStatus::Succeeded | PaymentStatus::Verified => { if is_auto_capture { common_enums::AttemptStatus::Charged } else { common_enums::AttemptStatus::Authorized } } PaymentStatus::Pending => common_enums::AttemptStatus::Pending, PaymentStatus::RequiresAction => common_enums::AttemptStatus::AuthenticationPending, PaymentStatus::AwaitingCapture => common_enums::AttemptStatus::Authorized, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "map_payment_response_to_attempt_status", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_4328141175566158444
clm
function
// connector-service/backend/connector-integration/src/connectors/xendit/transformers.rs fn from(item: RefundStatus) -> Self { match item { RefundStatus::Succeeded => Self::Success, RefundStatus::Failed | RefundStatus::Cancelled => Self::Failure, RefundStatus::Pending | RefundStatus::RequiresAction => Self::Pending, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-7080870094687339040
clm
function
// connector-service/backend/connector-integration/src/connectors/xendit/transformers.rs fn is_mandate_payment< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( item: &PaymentsAuthorizeData<T>, ) -> bool { (item.setup_future_usage == Some(common_enums::enums::FutureUsage::OffSession)) || item .mandate_id .as_ref() .and_then(|mandate_ids| mandate_ids.mandate_reference_id.as_ref()) .is_some() }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "is_mandate_payment", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-5499501572199064837
clm
function
// connector-service/backend/connector-integration/src/connectors/volt/transformers.rs fn try_from(item: RefundsResponseRouterData<F, RefundResponse>) -> Result<Self, Self::Error> { Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: item.response.id.to_string(), refund_status: common_enums::RefundStatus::Pending, //We get Refund Status only by Webhooks status_code: item.http_code, }), ..item.router_data }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-4471542057309744522
clm
function
// connector-service/backend/connector-integration/src/connectors/volt/transformers.rs fn get_attempt_status((item, current_status): (VoltPaymentStatus, AttemptStatus)) -> AttemptStatus { match item { VoltPaymentStatus::Received | VoltPaymentStatus::Settled => AttemptStatus::Charged, VoltPaymentStatus::Completed | VoltPaymentStatus::DelayedAtBank => AttemptStatus::Pending, VoltPaymentStatus::NewPayment | VoltPaymentStatus::BankRedirect | VoltPaymentStatus::AwaitingCheckoutAuthorisation => AttemptStatus::AuthenticationPending, VoltPaymentStatus::RefusedByBank | VoltPaymentStatus::RefusedByRisk | VoltPaymentStatus::NotReceived | VoltPaymentStatus::ErrorAtBank | VoltPaymentStatus::CancelledByUser | VoltPaymentStatus::AbandonedByUser | VoltPaymentStatus::Failed => AttemptStatus::Failure, VoltPaymentStatus::Unknown => current_status, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_attempt_status", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-8121934653120202201
clm
function
// connector-service/backend/connector-integration/src/connectors/volt/transformers.rs fn from(status: VoltWebhookBodyEventType) -> Self { match status { VoltWebhookBodyEventType::Payment(payment_data) => match payment_data.status { VoltWebhookPaymentStatus::Received => Self::PaymentIntentSuccess, VoltWebhookPaymentStatus::Failed | VoltWebhookPaymentStatus::NotReceived => { Self::PaymentIntentFailure } VoltWebhookPaymentStatus::Completed | VoltWebhookPaymentStatus::Pending => { Self::PaymentIntentProcessing } }, VoltWebhookBodyEventType::Refund(refund_data) => match refund_data.status { VoltWebhookRefundsStatus::RefundConfirmed => Self::RefundSuccess, VoltWebhookRefundsStatus::RefundFailed => Self::RefundFailure, }, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_4840959861993344353
clm
function
// connector-service/backend/connector-integration/src/connectors/noon/transformers.rs fn get_value_as_string(value: &serde_json::Value) -> String { match value { serde_json::Value::String(string) => string.to_owned(), serde_json::Value::Null | serde_json::Value::Bool(_) | serde_json::Value::Number(_) | serde_json::Value::Array(_) | serde_json::Value::Object(_) => value.to_string(), } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_value_as_string", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_3000270290517726204
clm
function
// connector-service/backend/connector-integration/src/connectors/noon/transformers.rs pub fn new(metadata: &serde_json::Value) -> Self { let metadata_as_string = metadata.to_string(); let hash_map: std::collections::BTreeMap<String, serde_json::Value> = serde_json::from_str(&metadata_as_string).unwrap_or(std::collections::BTreeMap::new()); let inner = hash_map .into_iter() .enumerate() .map(|(index, (hs_key, hs_value))| { let noon_key = format!("{}", index + 1); // to_string() function on serde_json::Value returns a string with "" quotes. Noon doesn't allow this. Hence get_value_as_string function let noon_value = format!("{hs_key}={}", get_value_as_string(&hs_value)); (noon_key, Secret::new(noon_value)) }) .collect(); Self { inner } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "new", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_4862076425151944515
clm
function
// connector-service/backend/connector-integration/src/connectors/noon/transformers.rs fn try_from(item: ResponseRouterData<SetupMandateResponse, Self>) -> Result<Self, Self::Error> { let order = item.response.result.order; let current_attempt_status = item.router_data.resource_common_data.status; let status = get_payment_status((order.status, current_attempt_status)); let redirection_data = item.response.result.checkout_data.map(|redirection_data| { Box::new(RedirectForm::Form { endpoint: redirection_data.post_url.to_string(), method: Method::Post, form_fields: std::collections::HashMap::new(), }) }); let mandate_reference = item.response.result.subscription.map(|subscription_data| { Box::new(MandateReference { connector_mandate_id: Some(subscription_data.identifier.expose()), payment_method_id: None, }) }); Ok(Self { resource_common_data: PaymentFlowData { status, ..item.router_data.resource_common_data }, response: match order.error_message { Some(error_message) => Err(ErrorResponse { code: order.error_code.to_string(), message: error_message.clone(), reason: Some(error_message), status_code: item.http_code, attempt_status: Some(status), connector_transaction_id: Some(order.id.to_string()), network_advice_code: None, network_decline_code: None, network_error_message: None, }), _ => { let connector_response_reference_id = order.reference.or(Some(order.id.to_string())); Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(order.id.to_string()), redirection_data, mandate_reference, connector_metadata: None, network_txn_id: None, connector_response_reference_id, incremental_authorization_allowed: None, status_code: item.http_code, }) } }, ..item.router_data }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_6624040959457726474
clm
function
// connector-service/backend/connector-integration/src/connectors/noon/transformers.rs fn get_payment_status(data: (NoonPaymentStatus, AttemptStatus)) -> AttemptStatus { let (item, current_status) = data; match item { NoonPaymentStatus::Authorized => AttemptStatus::Authorized, NoonPaymentStatus::Captured | NoonPaymentStatus::PartiallyCaptured | NoonPaymentStatus::PartiallyRefunded | NoonPaymentStatus::Refunded => AttemptStatus::Charged, NoonPaymentStatus::Reversed | NoonPaymentStatus::PartiallyReversed => AttemptStatus::Voided, NoonPaymentStatus::Cancelled | NoonPaymentStatus::Expired => { AttemptStatus::AuthenticationFailed } NoonPaymentStatus::ThreeDsEnrollInitiated | NoonPaymentStatus::ThreeDsEnrollChecked => { AttemptStatus::AuthenticationPending } NoonPaymentStatus::ThreeDsResultVerified => AttemptStatus::AuthenticationSuccessful, NoonPaymentStatus::Failed | NoonPaymentStatus::Rejected => AttemptStatus::Failure, NoonPaymentStatus::Pending | NoonPaymentStatus::MarkedForReview => AttemptStatus::Pending, NoonPaymentStatus::Initiated | NoonPaymentStatus::PaymentInfoAdded | NoonPaymentStatus::Authenticated => AttemptStatus::Started, NoonPaymentStatus::Locked => current_status, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_payment_status", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_253263964257174660
clm
function
// connector-service/backend/connector-integration/src/connectors/noon/transformers.rs fn from(value: NoonWebhookObject) -> Self { Self { result: NoonPaymentsResponseResult { order: NoonPaymentsOrderResponse { status: value.order_status, id: value.order_id, //For successful payments Noon Always populates error_code as 0. error_code: 0, error_message: None, reference: None, }, checkout_data: None, subscription: None, }, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-8659267270991720171
clm
function
// connector-service/backend/connector-integration/src/connectors/placetopay/transformers.rs fn try_from( item: ResponseRouterData<PlacetopayRefundResponse, Self>, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: item.response.internal_reference.to_string(), refund_status: common_enums::RefundStatus::from(item.response.status.status), status_code: item.http_code, }), ..item.router_data }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-6218284339970308393
clm
function
// connector-service/backend/connector-integration/src/connectors/placetopay/transformers.rs fn from(item: PlacetopayRefundStatus) -> Self { match item { PlacetopayRefundStatus::Ok | PlacetopayRefundStatus::Approved | PlacetopayRefundStatus::Refunded => Self::Success, PlacetopayRefundStatus::Failed | PlacetopayRefundStatus::Rejected | PlacetopayRefundStatus::Error => Self::Failure, PlacetopayRefundStatus::Pending | PlacetopayRefundStatus::PendingProcess | PlacetopayRefundStatus::PendingValidation => Self::Pending, } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_3152717781405429979
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_build_request_valid() { let email = Email::try_from("testuser@gmail.com".to_string()).unwrap(); let test_router_data = RouterDataV2 { flow: std::marker::PhantomData, resource_common_data: PaymentFlowData { merchant_id: MerchantId::default(), customer_id: None, connector_customer: None, payment_id: "IRRELEVANT_PAYMENT_ID".to_string(), attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(), status: AttemptStatus::Pending, payment_method: PaymentMethod::Card, description: None, return_url: None, address: PaymentAddress::new( None, Some(Address { address: None, phone: Some(PhoneDetails { number: Some("1234567890".to_string().into()), country_code: Some("+1".to_string()), }), email: Some(email.clone()), }), None, None, ), auth_type: AuthenticationType::NoThreeDs, connector_meta_data: None, amount_captured: None, minor_amount_captured: None, access_token: None, session_token: None, reference_id: Some("order_QMSVrXxHS9sBmu".to_string()), payment_method_token: None, preprocessing_id: None, connector_api_version: None, connector_request_reference_id: "ref_12345".to_string(), test_mode: None, connector_http_status_code: None, external_latency: None, raw_connector_response: None, connectors: Connectors { razorpay: ConnectorParams { base_url: "https://api.razorpay.com/".to_string(), dispute_base_url: None, ..Default::default() }, ..Default::default() }, vault_headers: None, connector_response_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: "dummy_api_key".to_string().into(), key1: "dummy_key1".to_string().into(), }, request: PaymentsAuthorizeData { authentication_data: None, payment_method_data: PaymentMethodData::Card(Card { card_number: RawCardNumber( CardNumber::from_str("5123456789012346").unwrap(), ), card_exp_month: "12".to_string().into(), card_exp_year: "2026".to_string().into(), card_cvc: "123".to_string().into(), card_issuer: None, card_network: None, card_type: None, card_issuing_country: None, bank_code: None, nick_name: None, card_holder_name: Some("Test User".to_string().into()), co_badged_card_data: None, }), amount: 1000, order_tax_amount: None, email: Some(email.clone()), customer_name: None, currency: Currency::USD, confirm: true, statement_descriptor_suffix: None, statement_descriptor: None, capture_method: None, router_return_url: None, webhook_url: None, integrity_object: None, complete_authorize_url: None, mandate_id: None, setup_future_usage: None, off_session: None, browser_info: Some(BrowserInformation { color_depth: None, java_enabled: Some(false), java_script_enabled: None, language: Some("en-US".to_string()), screen_height: Some(1080), screen_width: Some(1920), time_zone: None, ip_address: None, accept_header: Some( "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" .to_string(), ), user_agent: Some( "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)".to_string(), ), referer: None, os_type: None, os_version: None, device_model: None, accept_language: None, }), order_category: None, session_token: None, enrolled_for_3ds: false, related_transaction_id: None, payment_experience: None, payment_method_type: Some(PaymentMethodType::Credit), customer_id: None, 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 { code: "HE_00".to_string(), message: "Something went wrong".to_string(), reason: None, status_code: 500, attempt_status: None, connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }), }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let result = connector.get_request_body(&test_router_data); let request_content = result.unwrap(); let actual_json: Value = match request_content { Some(RequestContent::Json(payload)) => { to_value(&payload).expect("Failed to serialize payload to JSON") } _ => panic!("Expected JSON payload"), }; let expected_json: Value = json!({ "amount": 1000, "currency": "USD", "contact": "1234567890", "email": "testuser@gmail.com", "order_id": "order_QMSVrXxHS9sBmu", "method": "card", "card": { "number": "5123456789012346", "expiry_month": "12", "expiry_year": "2026", "cvv": "123" }, "authentication": { "authentication_channel": "browser" }, "browser": { "java_enabled": false, "language": "en-US", "screen_height": 1080, "screen_width": 1920 }, "ip": "127.0.0.1", "referer": "https://example.com", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)" }); assert_eq!(actual_json, expected_json); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_build_request_valid", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-6108357518927124253
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_build_request_missing() { use common_enums::Currency; use common_utils::{id_type::MerchantId, types::MinorUnit}; use domain_types::{ connector_types::PaymentCreateOrderData, payment_address::PaymentAddress, router_data::{ConnectorAuthType, ErrorResponse}, router_data_v2::RouterDataV2, }; use crate::connectors::Razorpay; let test_router_data = RouterDataV2 { flow: std::marker::PhantomData, resource_common_data: domain_types::connector_types::PaymentFlowData { merchant_id: 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: PaymentAddress::default(), 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, external_latency: None, raw_connector_response: None, connectors: Connectors { razorpay: ConnectorParams { base_url: "https://api.razorpay.com/".to_string(), dispute_base_url: None, ..Default::default() }, ..Default::default() }, vault_headers: None, connector_response_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: "dummy_api_key".to_string().into(), key1: "dummy_key1".to_string().into(), }, request: PaymentCreateOrderData { amount: MinorUnit::new(0), currency: Currency::default(), integrity_object: None, metadata: None, webhook_url: None, }, response: Err(ErrorResponse { code: "HE_01".to_string(), message: "Missing required fields".to_string(), reason: None, status_code: 400, attempt_status: None, connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }), }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let result = connector.get_request_body(&test_router_data); let req = result.unwrap(); let actual_json: Value = match req { Some(RequestContent::Json(payload)) => { to_value(&payload).expect("Failed to serialize payload") } None => { return; } Some(RequestContent::RawBytes(bytes)) => { let json_str = String::from_utf8(bytes).expect("Failed to convert bytes to string"); serde_json::from_str(&json_str).expect("Failed to parse bytes as JSON") } Some(RequestContent::FormUrlEncoded(form_data)) => { to_value(&form_data).expect("Failed to serialize form data") } Some(other) => panic!("Unexpected RequestContent type: {other:?}"), }; assert_eq!(actual_json["amount"], 0); assert_eq!(actual_json["currency"], "USD"); let receipt_value = &actual_json["receipt"]; assert!( receipt_value.is_string(), "Expected receipt to be a string, got: {receipt_value:?}" ); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_build_request_missing", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-4559112145041872844
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_build_request_invalid() { use common_enums::{ AttemptStatus, AuthenticationType, Currency, PaymentMethod, PaymentMethodType, }; use common_utils::{id_type::MerchantId, types::MinorUnit}; use domain_types::{ connector_types::{PaymentFlowData, PaymentsAuthorizeData}, payment_address::PaymentAddress, payment_method_data::{Card, PaymentMethodData}, router_data::ErrorResponse, router_data_v2::RouterDataV2, types::{ConnectorParams, Connectors}, }; use crate::connectors::Razorpay; let test_router_data = RouterDataV2 { flow: std::marker::PhantomData, resource_common_data: PaymentFlowData { merchant_id: MerchantId::default(), customer_id: None, connector_customer: None, payment_id: "invalid_payment_id".to_string(), attempt_id: "invalid_attempt_id".to_string(), status: AttemptStatus::Pending, payment_method: PaymentMethod::Card, description: None, return_url: None, address: PaymentAddress::new(None, None, None, None), auth_type: AuthenticationType::NoThreeDs, connector_meta_data: None, amount_captured: None, minor_amount_captured: None, access_token: None, session_token: None, reference_id: Some("order_invalid".to_string()), payment_method_token: None, preprocessing_id: None, connector_api_version: None, connector_request_reference_id: "ref_invalid".to_string(), test_mode: None, connector_http_status_code: None, external_latency: None, raw_connector_response: None, connectors: Connectors { razorpay: ConnectorParams { base_url: "https://api.razorpay.com/".to_string(), dispute_base_url: None, ..Default::default() }, ..Default::default() }, vault_headers: None, connector_response_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: "invalid_key".to_string().into(), key1: "invalid_key1".to_string().into(), }, request: PaymentsAuthorizeData { authentication_data: None, payment_method_data: PaymentMethodData::Card(Card { card_number: Default::default(), card_exp_month: "".to_string().into(), card_exp_year: "".to_string().into(), card_cvc: "".to_string().into(), card_issuer: None, card_network: None, card_type: None, card_issuing_country: None, bank_code: None, nick_name: None, card_holder_name: Some("Test User".to_string().into()), co_badged_card_data: None, }), amount: 1000, order_tax_amount: None, email: None, customer_name: None, currency: 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, order_category: None, session_token: None, enrolled_for_3ds: false, related_transaction_id: None, payment_experience: None, payment_method_type: Some(PaymentMethodType::Credit), customer_id: None, request_incremental_authorization: false, metadata: None, integrity_object: 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 { code: "HE_INVALID".to_string(), message: "Invalid request body".to_string(), reason: None, status_code: 422, attempt_status: None, connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }), }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let result = connector.get_request_body(&test_router_data); assert!( result.is_err(), "Expected error for invalid request data, but got: {result:?}" ); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_build_request_invalid", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-3871210758204669158
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_handle_response_v2_valid_authorize_response() { use std::str::FromStr; use common_enums::Currency; use common_utils::{id_type::MerchantId, pii::Email, types::MinorUnit}; use domain_types::{ connector_types::PaymentFlowData, payment_address::PaymentAddress, router_data::{ConnectorAuthType, ErrorResponse}, router_data_v2::RouterDataV2, types::{ConnectorParams, Connectors}, }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let email = Email::try_from("testuser@gmail.com".to_string()).unwrap(); let data = RouterDataV2 { flow: std::marker::PhantomData, resource_common_data: PaymentFlowData { merchant_id: MerchantId::default(), customer_id: None, connector_customer: None, payment_id: "IRRELEVANT_PAYMENT_ID".to_string(), attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(), status: AttemptStatus::Pending, payment_method: PaymentMethod::Card, description: None, return_url: None, address: PaymentAddress::new( None, Some(Address { address: None, phone: Some(PhoneDetails { number: Some("1234567890".to_string().into()), country_code: Some("+1".to_string()), }), email: Some(email.clone()), }), None, None, ), auth_type: AuthenticationType::NoThreeDs, connector_meta_data: None, amount_captured: None, minor_amount_captured: None, access_token: None, session_token: None, reference_id: Some("order_QMsUrrLPdwNxPG".to_string()), payment_method_token: None, preprocessing_id: None, connector_api_version: None, connector_request_reference_id: "ref_12345".to_string(), test_mode: None, connector_http_status_code: None, external_latency: None, raw_connector_response: None, connectors: Connectors { razorpay: ConnectorParams { base_url: "https://api.razorpay.com/".to_string(), dispute_base_url: None, ..Default::default() }, ..Default::default() }, vault_headers: None, connector_response_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: "dummy_api_key".to_string().into(), key1: "dummy_key1".to_string().into(), }, request: PaymentsAuthorizeData { authentication_data: None, payment_method_data: PaymentMethodData::Card(Card { card_number: RawCardNumber( CardNumber::from_str("5123450000000008").unwrap(), ), card_exp_month: "12".to_string().into(), card_exp_year: "2025".to_string().into(), card_cvc: "123".to_string().into(), card_issuer: None, card_network: None, card_type: None, card_issuing_country: None, bank_code: None, nick_name: None, card_holder_name: Some("Test User".to_string().into()), co_badged_card_data: None, }), amount: 1000, order_tax_amount: None, email: Some(email), customer_name: None, currency: Currency::USD, confirm: true, statement_descriptor_suffix: None, statement_descriptor: None, capture_method: None, router_return_url: None, webhook_url: None, integrity_object: None, complete_authorize_url: None, mandate_id: None, setup_future_usage: None, off_session: None, browser_info: Some(BrowserInformation { color_depth: None, java_enabled: Some(false), java_script_enabled: None, language: Some("en-US".to_string()), screen_height: Some(1080), screen_width: Some(1920), time_zone: None, ip_address: None, accept_header: Some( "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" .to_string(), ), user_agent: Some( "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)".to_string(), ), referer: None, os_type: None, os_version: None, device_model: None, accept_language: None, }), order_category: None, session_token: None, enrolled_for_3ds: false, related_transaction_id: None, payment_experience: None, payment_method_type: Some(common_enums::PaymentMethodType::Credit), customer_id: None, 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 { code: "HE_00".to_string(), message: "Something went wrong".to_string(), reason: None, status_code: 500, attempt_status: None, connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }), }; let http_response = Response { headers: None, response: br#"{ "razorpay_payment_id":"pay_QMsUsXCDy9sX3b", "next":[ { "action":"redirect", "url":"https://api.razorpay.com/v1/payments/QMsUsXCDy9sX3b/authenticate" } ] }"# .to_vec() .into(), status_code: 200, }; let result = connector .handle_response_v2(&data, None, http_response) .unwrap(); assert!(matches!( result.resource_common_data.status, AttemptStatus::AuthenticationPending )); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_handle_response_v2_valid_authorize_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-8922597920826393306
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_handle_authorize_error_response() { use domain_types::{ connector_flow::Authorize, connector_types::{PaymentFlowData, PaymentsAuthorizeData, PaymentsResponseData}, }; let http_response = Response { headers: None, response: br#"{ "error": { "code": "BAD_REQUEST_ERROR", "description": "The id provided does not exist", "source": "internal", "step": "payment_initiation", "reason": "input_validation_failed", "metadata": {} } }"# .to_vec() .into(), status_code: 400, }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let result = <dyn ConnectorServiceTrait<DefaultPCIHolder> + Sync as ConnectorIntegrationV2< Authorize, PaymentFlowData, PaymentsAuthorizeData<DefaultPCIHolder>, PaymentsResponseData, >>::get_error_response_v2(&**connector, http_response, None) .unwrap(); let actual_json = to_value(&result).unwrap(); let expected_json = json!({ "code": "BAD_REQUEST_ERROR", "message": "The id provided does not exist", "reason": "input_validation_failed", "status_code": 400, "attempt_status": "failure", "connector_transaction_id": null, "network_advice_code": null, "network_decline_code": null, "network_error_message": null }); assert_eq!(actual_json, expected_json); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_handle_authorize_error_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_901397538912186964
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_handle_authorize_missing_required_fields() { use domain_types::{ connector_flow::Authorize, connector_types::{PaymentFlowData, PaymentsAuthorizeData, PaymentsResponseData}, }; let http_response = Response { headers: None, response: br#"{ "error": { "description": "Missing required fields", "step": "payment_initiation", "reason": "input_validation_failed" } }"# .to_vec() .into(), status_code: 400, }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let result = <dyn ConnectorServiceTrait<DefaultPCIHolder> + Sync as ConnectorIntegrationV2< Authorize, PaymentFlowData, PaymentsAuthorizeData<DefaultPCIHolder>, PaymentsResponseData, >>::get_error_response_v2(&**connector, http_response, None); assert!( result.is_err(), "Expected panic due to missing required fields", ); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_handle_authorize_missing_required_fields", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-4972240173322938778
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_handle_authorize_invalid_error_fields() { use domain_types::{ connector_flow::Authorize, connector_types::{PaymentFlowData, PaymentsAuthorizeData, PaymentsResponseData}, }; let http_response = Response { headers: None, response: br#"{ "error": { "code": 500, "description": "Card number is invalid.", "step": "payment_authorization", "reason": "input_validation_failed", "source": "business", "metadata": {} } }"# .to_vec() .into(), status_code: 400, }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let result = <dyn ConnectorServiceTrait<DefaultPCIHolder> + Sync as ConnectorIntegrationV2< Authorize, PaymentFlowData, PaymentsAuthorizeData<DefaultPCIHolder>, PaymentsResponseData, >>::get_error_response_v2(&**connector, http_response, None); assert!( result.is_err(), "Expected panic due to missing required fields" ); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_handle_authorize_invalid_error_fields", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_8878164691626727343
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_handle_response_v2_missing_fields_authorize_response() { use std::str::FromStr; use common_enums::Currency; use common_utils::{id_type::MerchantId, pii::Email, types::MinorUnit}; use domain_types::{ connector_types::PaymentFlowData, payment_address::PaymentAddress, router_data::{ConnectorAuthType, ErrorResponse}, router_data_v2::RouterDataV2, types::{ConnectorParams, Connectors}, }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let email = Email::try_from("testuser@gmail.com".to_string()).unwrap(); let data = RouterDataV2 { flow: std::marker::PhantomData, resource_common_data: PaymentFlowData { merchant_id: MerchantId::default(), customer_id: None, connector_customer: None, payment_id: "IRRELEVANT_PAYMENT_ID".to_string(), attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(), status: AttemptStatus::Pending, payment_method: PaymentMethod::Card, description: None, return_url: None, address: PaymentAddress::new( None, Some(Address { address: None, phone: Some(PhoneDetails { number: Some("1234567890".to_string().into()), country_code: Some("+1".to_string()), }), email: Some(email.clone()), }), None, None, ), auth_type: AuthenticationType::NoThreeDs, connector_meta_data: None, amount_captured: None, minor_amount_captured: None, access_token: None, session_token: None, reference_id: Some("order_QMsUrrLPdwNxPG".to_string()), payment_method_token: None, preprocessing_id: None, connector_api_version: None, connector_request_reference_id: "ref_12345".to_string(), test_mode: None, connector_http_status_code: None, external_latency: None, raw_connector_response: None, connectors: Connectors { razorpay: ConnectorParams { base_url: "https://api.razorpay.com/".to_string(), dispute_base_url: None, ..Default::default() }, ..Default::default() }, vault_headers: None, connector_response_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: "dummy_api_key".to_string().into(), key1: "dummy_key1".to_string().into(), }, request: PaymentsAuthorizeData { authentication_data: None, payment_method_data: PaymentMethodData::Card(Card { card_number: RawCardNumber(CardNumber::from_str("5123450000000008").unwrap()), card_exp_month: "12".to_string().into(), card_exp_year: "2025".to_string().into(), card_cvc: "123".to_string().into(), card_issuer: None, card_network: None, card_type: None, card_issuing_country: None, bank_code: None, nick_name: None, card_holder_name: Some("Test User".to_string().into()), co_badged_card_data: None, }), amount: 1000, order_tax_amount: None, email: Some(email), customer_name: None, currency: 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: Some(BrowserInformation { color_depth: None, java_enabled: Some(false), java_script_enabled: None, language: Some("en-US".to_string()), screen_height: Some(1080), screen_width: Some(1920), time_zone: None, ip_address: None, accept_header: Some( "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" .to_string(), ), user_agent: Some("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)".to_string()), referer: None, os_type: None, os_version: None, device_model: None, accept_language: None, }), order_category: None, session_token: None, enrolled_for_3ds: false, related_transaction_id: None, payment_experience: None, payment_method_type: Some(common_enums::PaymentMethodType::Credit), customer_id: None, request_incremental_authorization: false, metadata: None, minor_amount: MinorUnit::new(1000), merchant_order_reference_id: None, shipping_cost: None, integrity_object: 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 { code: "HE_00".to_string(), message: "Something went wrong".to_string(), reason: None, status_code: 500, attempt_status: None, connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }), }; let http_response = Response { headers: None, response: br#"{ "next":[ { "action":"redirect", "url":"https://api.razorpay.com/v1/payments/QMsUsXCDy9sX3b/authenticate" } ] }"# .to_vec() .into(), status_code: 200, }; let result = connector.handle_response_v2(&data, None, http_response); assert!( result.is_err(), "Expected error due to missing razorpay_payment_id, but got success." ); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_handle_response_v2_missing_fields_authorize_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-1262477012638053872
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_handle_response_v2_invalid_json_authorize_response() { use std::str::FromStr; use common_enums::Currency; use common_utils::{id_type::MerchantId, pii::Email, types::MinorUnit}; use domain_types::{ connector_types::PaymentFlowData, payment_address::PaymentAddress, router_data::{ConnectorAuthType, ErrorResponse}, router_data_v2::RouterDataV2, types::{ConnectorParams, Connectors}, }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let email = Email::try_from("testuser@gmail.com".to_string()).unwrap(); let data = RouterDataV2 { flow: std::marker::PhantomData, resource_common_data: PaymentFlowData { merchant_id: MerchantId::default(), customer_id: None, connector_customer: None, payment_id: "IRRELEVANT_PAYMENT_ID".to_string(), attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(), status: AttemptStatus::Pending, payment_method: PaymentMethod::Card, description: None, return_url: None, address: PaymentAddress::new( None, Some(Address { address: None, phone: Some(PhoneDetails { number: Some("1234567890".to_string().into()), country_code: Some("+1".to_string()), }), email: Some(email.clone()), }), None, None, ), auth_type: AuthenticationType::NoThreeDs, connector_meta_data: None, amount_captured: None, minor_amount_captured: None, access_token: None, session_token: None, reference_id: Some("order_QMsUrrLPdwNxPG".to_string()), payment_method_token: None, preprocessing_id: None, connector_api_version: None, connector_request_reference_id: "ref_12345".to_string(), test_mode: None, connector_http_status_code: None, external_latency: None, raw_connector_response: None, connectors: Connectors { razorpay: ConnectorParams { base_url: "https://api.razorpay.com/".to_string(), dispute_base_url: None, ..Default::default() }, ..Default::default() }, vault_headers: None, connector_response_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: "dummy_api_key".to_string().into(), key1: "dummy_key1".to_string().into(), }, request: PaymentsAuthorizeData { authentication_data: None, payment_method_data: PaymentMethodData::Card(Card { card_number: RawCardNumber(CardNumber::from_str("5123450000000008").unwrap()), card_exp_month: "12".to_string().into(), card_exp_year: "2025".to_string().into(), card_cvc: "123".to_string().into(), card_issuer: None, card_network: None, card_type: None, card_issuing_country: None, bank_code: None, nick_name: None, card_holder_name: Some("Test User".to_string().into()), co_badged_card_data: None, }), amount: 1000, order_tax_amount: None, email: Some(email), customer_name: None, currency: 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: Some(BrowserInformation { color_depth: None, java_enabled: Some(false), java_script_enabled: None, language: Some("en-US".to_string()), screen_height: Some(1080), screen_width: Some(1920), time_zone: None, ip_address: None, accept_header: Some( "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" .to_string(), ), user_agent: Some("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)".to_string()), referer: None, os_type: None, os_version: None, device_model: None, accept_language: None, }), order_category: None, session_token: None, enrolled_for_3ds: false, related_transaction_id: None, payment_experience: None, payment_method_type: Some(common_enums::PaymentMethodType::Credit), customer_id: None, request_incremental_authorization: false, metadata: None, minor_amount: MinorUnit::new(1000), merchant_order_reference_id: None, shipping_cost: None, integrity_object: 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 { code: "HE_00".to_string(), message: "Something went wrong".to_string(), reason: None, status_code: 500, attempt_status: None, connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }), }; let http_response = Response { headers: None, response: br#"{"razorpay_payment_id": "pay_xyz", "next": [ { "action": "redirect" "url": "https://api.razorpay.com/v1/payments/xyz/authenticate" } ]"#.to_vec().into(), status_code: 200, }; let result = connector.handle_response_v2(&data, None, http_response); assert!( result.is_err(), "Expected error due to missing razorpay_payment_id, but got success." ); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_handle_response_v2_invalid_json_authorize_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-7908791156729419999
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_build_request_valid_order() { use common_enums::Currency; use common_utils::{id_type::MerchantId, request::RequestContent, types::MinorUnit}; use domain_types::{ connector_types::PaymentCreateOrderData, payment_address::PaymentAddress, router_data::{ConnectorAuthType, ErrorResponse}, router_data_v2::RouterDataV2, }; use serde_json::{to_value, Value}; let email = Email::try_from("testuser@gmail.com".to_string()).unwrap(); let test_router_data = RouterDataV2 { flow: std::marker::PhantomData, resource_common_data: domain_types::connector_types::PaymentFlowData { merchant_id: MerchantId::default(), customer_id: None, connector_customer: None, payment_id: "IRRELEVANT_PAYMENT_ID".to_string(), attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(), status: common_enums::AttemptStatus::Pending, payment_method: common_enums::PaymentMethod::Card, description: None, return_url: None, address: PaymentAddress::new( None, Some(Address { address: None, phone: Some(PhoneDetails { number: Some("1234567890".to_string().into()), country_code: Some("+1".to_string()), }), email: Some(email.clone()), }), 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: "ref_12345".to_string(), test_mode: None, connector_http_status_code: None, external_latency: None, raw_connector_response: None, connectors: domain_types::types::Connectors { razorpay: ConnectorParams { base_url: "https://api.razorpay.com/".to_string(), dispute_base_url: None, ..Default::default() }, ..Default::default() }, vault_headers: None, connector_response_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: "dummy_api_key".to_string().into(), key1: "dummy_key1".to_string().into(), }, request: PaymentCreateOrderData { amount: MinorUnit::new(1000), currency: Currency::USD, integrity_object: None, metadata: None, webhook_url: None, }, response: Err(ErrorResponse { code: "HE_00".to_string(), message: "Something went wrong".to_string(), reason: None, status_code: 500, attempt_status: None, connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }), }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let result = connector.get_request_body(&test_router_data).unwrap(); let actual_json: Value = match result { Some(RequestContent::Json(payload)) => { to_value(&payload).expect("Failed to serialize payload") } Some(RequestContent::RawBytes(bytes)) => { // Handle raw bytes - try to parse as JSON let json_str = String::from_utf8(bytes).expect("Failed to convert bytes to string"); serde_json::from_str(&json_str).expect("Failed to parse bytes as JSON") } Some(RequestContent::FormUrlEncoded(form_data)) => { // Convert form data to JSON for comparison to_value(&form_data).expect("Failed to serialize form data") } None => panic!("Expected some request content"), Some(other) => panic!("Unexpected RequestContent type: {other:?}"), }; assert_eq!(actual_json["amount"], 1000); assert_eq!(actual_json["currency"], "USD"); let receipt_value = &actual_json["receipt"]; assert!( receipt_value.is_string(), "Expected receipt to be a string, got: {receipt_value:?}" ); let receipt_str = receipt_value.as_str().unwrap(); assert!(!receipt_str.is_empty(), "Expected non-empty receipt string"); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_build_request_valid_order", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-2250098341918712889
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_handle_response_v2_valid_order_response() { use common_enums::Currency; use common_utils::{id_type::MerchantId, pii::Email, types::MinorUnit}; use domain_types::{ connector_types::{PaymentCreateOrderData, PaymentFlowData}, payment_address::PaymentAddress, router_data::{ConnectorAuthType, ErrorResponse}, router_data_v2::RouterDataV2, types::{ConnectorParams, Connectors}, }; let email = Email::try_from("testuser@gmail.com".to_string()).unwrap(); let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let data = RouterDataV2 { flow: std::marker::PhantomData, resource_common_data: PaymentFlowData { merchant_id: MerchantId::default(), customer_id: None, connector_customer: None, payment_id: "IRRELEVANT_PAYMENT_ID".to_string(), attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(), status: common_enums::AttemptStatus::Pending, payment_method: common_enums::PaymentMethod::Card, description: None, return_url: None, address: PaymentAddress::new( None, Some(Address { address: None, phone: Some(PhoneDetails { number: Some("1234567890".to_string().into()), country_code: Some("+1".to_string()), }), email: Some(email.clone()), }), 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: "ref_12345".to_string(), test_mode: None, connector_http_status_code: None, external_latency: None, raw_connector_response: None, connectors: Connectors { razorpay: ConnectorParams { base_url: "https://api.razorpay.com/".to_string(), dispute_base_url: None, ..Default::default() }, ..Default::default() }, vault_headers: None, connector_response_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: "dummy_api_key".to_string().into(), key1: "dummy_key1".to_string().into(), }, request: PaymentCreateOrderData { amount: MinorUnit::new(1000), currency: Currency::USD, integrity_object: None, metadata: None, webhook_url: None, }, response: Err(ErrorResponse { code: "HE_00".to_string(), message: "Something went wrong".to_string(), reason: None, status_code: 500, attempt_status: None, connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }), }; let http_response = Response { headers: None, response: br#"{ "amount":1000, "amount_due":1000, "amount_paid":0, "attempts":0, "created_at":1745490447, "currency":"USD", "entity":"order", "id":"order_QMrTOdLWvEHsXz", "notes":[], "offer_id":null, "receipt":"141674f6-30d3-4a17-b904-27fe6ca085c7", "status":"created" }"# .to_vec() .into(), status_code: 200, }; let result = connector .handle_response_v2(&data, None, http_response) .unwrap(); assert_eq!( result.response.unwrap().order_id, "order_QMrTOdLWvEHsXz".to_string() ); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_handle_response_v2_valid_order_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_6941333131051758840
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_handle_response_missing() { use common_enums::Currency; use common_utils::{id_type::MerchantId, pii::Email, types::MinorUnit}; use domain_types::{ connector_types::PaymentCreateOrderData, payment_address::PaymentAddress, router_data::{ConnectorAuthType, ErrorResponse}, router_data_v2::RouterDataV2, types::{ConnectorParams, Connectors}, }; let email = Email::try_from("testuser@gmail.com".to_string()).unwrap(); let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let data = RouterDataV2 { flow: std::marker::PhantomData, resource_common_data: PaymentFlowData { merchant_id: MerchantId::default(), customer_id: None, connector_customer: None, payment_id: "IRRELEVANT_PAYMENT_ID".to_string(), attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(), status: common_enums::AttemptStatus::Pending, payment_method: common_enums::PaymentMethod::Card, description: None, return_url: None, address: PaymentAddress::new( None, Some(Address { address: None, phone: Some(PhoneDetails { number: Some("1234567890".to_string().into()), country_code: Some("+1".to_string()), }), email: Some(email.clone()), }), 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: "ref_12345".to_string(), test_mode: None, connector_http_status_code: None, external_latency: None, raw_connector_response: None, connectors: Connectors { razorpay: ConnectorParams { base_url: "https://api.razorpay.com/".to_string(), dispute_base_url: None, ..Default::default() }, ..Default::default() }, vault_headers: None, connector_response_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: "dummy_api_key".to_string().into(), key1: "dummy_key1".to_string().into(), }, request: PaymentCreateOrderData { amount: MinorUnit::new(1000), currency: Currency::USD, integrity_object: None, metadata: None, webhook_url: None, }, response: Err(ErrorResponse { code: "HE_00".to_string(), message: "Something went wrong".to_string(), reason: None, status_code: 500, attempt_status: None, connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }), }; let http_response = Response { headers: None, response: br#"{ "amount":1000, "currency":"USD", "status":"created" }"# .to_vec() .into(), status_code: 200, }; let result = connector.handle_response_v2(&data, None, http_response); assert!( result.is_err(), "Expected error due to missing order_id or receipt" ); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_handle_response_missing", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_989211878059782093
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_handle_response_invalid() { use common_enums::Currency; use common_utils::{id_type::MerchantId, pii::Email, types::MinorUnit}; use domain_types::{ connector_types::PaymentCreateOrderData, payment_address::PaymentAddress, router_data::{ConnectorAuthType, ErrorResponse}, router_data_v2::RouterDataV2, types::{ConnectorParams, Connectors}, }; let email = Email::try_from("testuser@gmail.com".to_string()).unwrap(); let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let data = RouterDataV2 { flow: std::marker::PhantomData, resource_common_data: PaymentFlowData { merchant_id: MerchantId::default(), customer_id: None, connector_customer: None, payment_id: "IRRELEVANT_PAYMENT_ID".to_string(), attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(), status: common_enums::AttemptStatus::Pending, payment_method: common_enums::PaymentMethod::Card, description: None, return_url: None, address: PaymentAddress::new( None, Some(Address { address: None, phone: Some(PhoneDetails { number: Some("1234567890".to_string().into()), country_code: Some("+1".to_string()), }), email: Some(email.clone()), }), 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: "ref_12345".to_string(), test_mode: None, connector_http_status_code: None, external_latency: None, raw_connector_response: None, connectors: Connectors { razorpay: ConnectorParams { base_url: "https://api.razorpay.com/".to_string(), dispute_base_url: None, ..Default::default() }, ..Default::default() }, vault_headers: None, connector_response_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: "dummy_api_key".to_string().into(), key1: "dummy_key1".to_string().into(), }, request: PaymentCreateOrderData { amount: MinorUnit::new(1000), currency: Currency::USD, integrity_object: None, metadata: None, webhook_url: None, }, response: Err(ErrorResponse { code: "HE_00".to_string(), message: "Something went wrong".to_string(), reason: None, status_code: 500, attempt_status: None, connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }), }; let http_response = Response { headers: None, response: br#"{ "amount":1000, "currency":"USD", "status":"created" }"# .to_vec() .into(), status_code: 500, }; let result = connector.handle_response_v2(&data, None, http_response); assert!( result.is_err(), "Expected error due to invalid response format" ); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_handle_response_invalid", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_3435598897392635562
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_handle_error_response_valid() { let http_response = Response { headers: None, response: br#"{ "error": { "code": "BAD_REQUEST_ERROR", "description": "Order receipt should be unique.", "step": "payment_initiation", "reason": "input_validation_failed", "source": "business", "metadata": { "order_id": "order_OL0t841dI8F9NV" } } }"# .to_vec() .into(), status_code: 400, }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let result = <dyn ConnectorServiceTrait<DefaultPCIHolder> + Sync as ConnectorIntegrationV2< domain_types::connector_flow::CreateOrder, domain_types::connector_types::PaymentFlowData, domain_types::connector_types::PaymentCreateOrderData, domain_types::connector_types::PaymentCreateOrderResponse, >>::get_error_response_v2(&**connector, http_response, None) .unwrap(); let actual_json = to_value(&result).unwrap(); let expected_json = json!({ "code": "BAD_REQUEST_ERROR", "message": "Order receipt should be unique.", "reason": "input_validation_failed", "status_code": 400, "attempt_status": "failure", "connector_transaction_id": null, "network_advice_code": null, "network_decline_code": null, "network_error_message": null }); assert_eq!(actual_json, expected_json); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_handle_error_response_valid", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_8132296736493886026
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_handle_error_response_invalid_json() { let http_response = Response { headers: None, response: br#"{ "error": { "code": "BAD_REQUEST_ERROR" "#.to_vec().into(), status_code: 400, }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let result = <dyn ConnectorServiceTrait<DefaultPCIHolder> + Sync as ConnectorIntegrationV2< domain_types::connector_flow::CreateOrder, domain_types::connector_types::PaymentFlowData, domain_types::connector_types::PaymentCreateOrderData, domain_types::connector_types::PaymentCreateOrderResponse, >>::get_error_response_v2(&**connector, http_response, None); assert!(result.is_err(), "Expected error for invalid JSON"); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_handle_error_response_invalid_json", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_4630970440140951762
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/test.rs fn test_handle_error_response_missing_error_field() { let http_response = Response { headers: None, response: br#"{ "message": "Some generic message", "status": "failed" }"# .to_vec() .into(), status_code: 400, }; let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new()); let result = <dyn ConnectorServiceTrait<DefaultPCIHolder> + Sync as ConnectorIntegrationV2< domain_types::connector_flow::CreateOrder, domain_types::connector_types::PaymentFlowData, domain_types::connector_types::PaymentCreateOrderData, domain_types::connector_types::PaymentCreateOrderResponse, >>::get_error_response_v2(&**connector, http_response, None) .unwrap(); let actual_json = to_value(&result).unwrap(); let expected_json = json!({ "code": "ROUTE_ERROR", "message": "Some generic message", "reason": "Some generic message", "status_code": 400, "attempt_status": "failure", "connector_transaction_id": null, "network_advice_code": null, "network_decline_code": null, "network_error_message": null }); assert_eq!(actual_json, expected_json); }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_handle_error_response_missing_error_field", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-9078528393221723888
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/transformers.rs fn try_from( item: &RazorpayRouterData< &RouterDataV2< domain_types::connector_flow::Authorize, PaymentFlowData, PaymentsAuthorizeData<T>, PaymentsResponseData, >, >, ) -> Result<Self, Self::Error> { use domain_types::payment_method_data::{PaymentMethodData, UpiData}; use hyperswitch_masking::PeekInterface; // Determine flow type and extract VPA based on UPI payment method let (flow_type, vpa) = match &item.router_data.request.payment_method_data { PaymentMethodData::Upi(UpiData::UpiCollect(collect_data)) => { let vpa = collect_data .vpa_id .as_ref() .ok_or(errors::ConnectorError::MissingRequiredField { field_name: "vpa_id", })? .peek() .to_string(); (None, Some(vpa)) } PaymentMethodData::Upi(UpiData::UpiIntent(_)) | PaymentMethodData::Upi(UpiData::UpiQr(_)) => (Some("intent"), None), _ => (None, None), // Default fallback }; // Get order_id from the CreateOrder response (stored in reference_id) let order_id = item .router_data .resource_common_data .reference_id .as_ref() .ok_or(errors::ConnectorError::MissingRequiredField { field_name: "order_id (reference_id)", })? .clone(); // Extract metadata as a HashMap let metadata_map = item .router_data .request .metadata .as_ref() .and_then(|metadata| metadata.as_object()) .map(|obj| { obj.iter() .map(|(k, v)| (k.clone(), v.as_str().unwrap_or_default().to_string())) .collect::<HashMap<String, String>>() }) .unwrap_or_default(); Ok(Self { currency: item.router_data.request.currency.to_string(), amount: item.amount, email: item .router_data .resource_common_data .get_billing_email() .ok(), order_id: order_id.to_string(), contact: item .router_data .resource_common_data .get_billing_phone_number() .ok(), method: match &item.router_data.request.payment_method_data { PaymentMethodData::Upi(_) => "upi".to_string(), PaymentMethodData::Card(_) => "card".to_string(), _ => "card".to_string(), // Default to card }, vpa: vpa.clone().map(Secret::new), __notes_91_txn_uuid_93_: metadata_map.get("__notes_91_txn_uuid_93_").cloned(), __notes_91_transaction_id_93_: metadata_map .get("__notes_91_transaction_id_93_") .cloned(), callback_url: item.router_data.request.get_router_return_url()?, ip: item .router_data .request .get_ip_address_as_optional() .map(|ip| Secret::new(ip.expose())) .unwrap_or_else(|| Secret::new("127.0.0.1".to_string())), referer: item .router_data .request .browser_info .as_ref() .and_then(|info| info.get_referer().ok()) .unwrap_or_else(|| "https://example.com".to_string()), user_agent: item .router_data .request .browser_info .as_ref() .and_then(|info| info.get_user_agent().ok()) .unwrap_or_else(|| "Mozilla/5.0".to_string()), description: Some("".to_string()), flow: flow_type.map(|s| s.to_string()), __notes_91_cust_id_93_: metadata_map.get("__notes_91_cust_id_93_").cloned(), __notes_91_cust_name_93_: metadata_map.get("__notes_91_cust_name_93_").cloned(), __upi_91_flow_93_: metadata_map.get("__upi_91_flow_93_").cloned(), __upi_91_type_93_: metadata_map.get("__upi_91_type_93_").cloned(), __upi_91_end_date_93_: metadata_map .get("__upi_91_end_date_93_") .and_then(|v| v.parse::<i64>().ok()), __upi_91_vpa_93_: metadata_map.get("__upi_91_vpa_93_").cloned(), recurring: None, customer_id: None, __upi_91_expiry_time_93_: metadata_map .get("__upi_91_expiry_time_93_") .and_then(|v| v.parse::<i64>().ok()), fee: None, __notes_91_booking_id_93: metadata_map.get("__notes_91_booking_id_93").cloned(), __notes_91_pnr_93: metadata_map.get("__notes_91_pnr_93").cloned(), __notes_91_payment_id_93: metadata_map.get("__notes_91_payment_id_93").cloned(), __notes_91_lob_93_: metadata_map.get("__notes_91_lob_93_").cloned(), __notes_91_credit_line_id_93_: metadata_map .get("__notes_91_credit_line_id_93_") .cloned(), __notes_91_loan_id_93_: metadata_map.get("__notes_91_loan_id_93_").cloned(), __notes_91_transaction_type_93_: metadata_map .get("__notes_91_transaction_type_93_") .cloned(), __notes_91_loan_product_code_93_: metadata_map .get("__notes_91_loan_product_code_93_") .cloned(), __notes_91_pg_flow_93_: metadata_map.get("__notes_91_pg_flow_93_").cloned(), __notes_91_tid_93: metadata_map.get("__notes_91_tid_93").cloned(), account_id: None, }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_5939746031037116638
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/transformers.rs pub fn generate_authorization_header(&self) -> String { let auth_type_name = match self { RazorpayAuthType::AuthToken(_) => "AuthToken", RazorpayAuthType::ApiKeySecret { .. } => "ApiKeySecret", }; info!("Type of auth Token is {}", auth_type_name); match self { RazorpayAuthType::AuthToken(token) => format!("Bearer {}", token.peek()), RazorpayAuthType::ApiKeySecret { api_key, api_secret, } => { let credentials = format!("{}:{}", api_key.peek(), api_secret.peek()); let encoded = STANDARD.encode(credentials); format!("Basic {encoded}") } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "generate_authorization_header", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-7098095553287580584
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/transformers.rs fn extract_payment_method_and_data< T: PaymentMethodDataTypes + std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static + Serialize, >( payment_method_data: &PaymentMethodData<T>, customer_name: Option<String>, ) -> Result<(PaymentMethodType, PaymentMethodSpecificData<T>), domain_types::errors::ConnectorError> { match payment_method_data { PaymentMethodData::Card(card_data) => { let card_holder_name = customer_name.clone(); let card = PaymentMethodSpecificData::Card(CardDetails { number: card_data.card_number.clone(), name: card_holder_name.map(Secret::new), expiry_month: Some(card_data.card_exp_month.clone()), expiry_year: card_data.card_exp_year.clone(), cvv: Some(card_data.card_cvc.clone()), }); Ok((PaymentMethodType::Card, card)) } PaymentMethodData::CardRedirect(_) | PaymentMethodData::Wallet(_) | PaymentMethodData::PayLater(_) | PaymentMethodData::BankRedirect(_) | PaymentMethodData::BankDebit(_) | PaymentMethodData::BankTransfer(_) | PaymentMethodData::Crypto(_) | PaymentMethodData::MandatePayment | PaymentMethodData::Reward | PaymentMethodData::RealTimePayment(_) | PaymentMethodData::Upi(_) | PaymentMethodData::Voucher(_) | PaymentMethodData::GiftCard(_) | PaymentMethodData::CardToken(_) | PaymentMethodData::CardDetailsForNetworkTransactionId(_) | PaymentMethodData::NetworkToken(_) | PaymentMethodData::MobilePayment(_) | PaymentMethodData::OpenBanking(_) => { Err(domain_types::errors::ConnectorError::NotImplemented( "Only Card payment method is supported for Razorpay".to_string(), )) } } }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_payment_method_and_data", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_connector-integration_-7952878649503609795
clm
function
// connector-service/backend/connector-integration/src/connectors/razorpay/transformers.rs fn foreign_try_from( (upi_response, data, _status_code, _raw_response): ( RazorpayUpiPaymentsResponse, RouterDataV2<F, PaymentFlowData, Req, PaymentsResponseData>, u16, Vec<u8>, ), ) -> Result<Self, Self::Error> { let (transaction_id, redirection_data) = match upi_response { RazorpayUpiPaymentsResponse::SuccessIntent { razorpay_payment_id, link, } => { let redirect_form = domain_types::router_response_types::RedirectForm::Uri { uri: link }; ( ResponseId::ConnectorTransactionId(razorpay_payment_id), Some(redirect_form), ) } RazorpayUpiPaymentsResponse::SuccessCollect { razorpay_payment_id, } => { // For UPI Collect, there's no link, so no redirection data ( ResponseId::ConnectorTransactionId(razorpay_payment_id), None, ) } RazorpayUpiPaymentsResponse::NullResponse { razorpay_payment_id, } => { // Handle null response - likely an error condition match razorpay_payment_id { Some(payment_id) => (ResponseId::ConnectorTransactionId(payment_id), None), None => { // Payment ID is null, this is likely an error return Err(domain_types::errors::ConnectorError::ResponseHandlingFailed); } } } RazorpayUpiPaymentsResponse::Error { error: _ } => { // Handle error case - this should probably return an error instead return Err(domain_types::errors::ConnectorError::ResponseHandlingFailed); } }; let payments_response_data = PaymentsResponseData::TransactionResponse { resource_id: transaction_id, redirection_data: redirection_data.map(Box::new), connector_metadata: None, mandate_reference: None, network_txn_id: None, connector_response_reference_id: data.resource_common_data.reference_id.clone(), incremental_authorization_allowed: None, status_code: _status_code, }; Ok(RouterDataV2 { response: Ok(payments_response_data), resource_common_data: PaymentFlowData { status: AttemptStatus::AuthenticationPending, ..data.resource_common_data }, ..data }) }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": "foreign_try_from", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }