id stringlengths 20 153 | type stringclasses 1
value | granularity stringclasses 14
values | content stringlengths 16 84.3k | metadata dict |
|---|---|---|---|---|
connector-service_fn_grpc-server_1768227964673979343 | clm | function | // connector-service/backend/grpc-server/tests/test_currency.rs
fn test_currency_classification_completeness() {
// Test that all currencies in the enum are properly classified
let mut tested_currencies = 0;
let mut successful_classifications = 0;
// We'll iterate through some key currencies to verify they're all classified
let test_currencies = vec![
Currency::USD,
Currency::EUR,
Currency::GBP,
Currency::JPY,
Currency::KRW,
Currency::BHD,
Currency::JOD,
Currency::CLF,
Currency::CNY,
Currency::INR,
Currency::CAD,
Currency::AUD,
Currency::CHF,
Currency::SEK,
Currency::NOK,
Currency::DKK,
Currency::PLN,
Currency::CZK,
Currency::HUF,
Currency::RUB,
];
let mut failed_currencies = Vec::new();
for currency in test_currencies {
tested_currencies += 1;
match currency.number_of_digits_after_decimal_point() {
Ok(_) => successful_classifications += 1,
Err(_) => {
failed_currencies.push(currency);
println!("❌ Currency {currency:?} not properly classified");
}
}
}
// Fail the test if any currencies failed
assert!(
failed_currencies.is_empty(),
"The following currencies are not properly classified: {failed_currencies:?}"
);
println!("✅ Tested {tested_currencies} currencies, {successful_classifications} successful classifications");
assert_eq!(
tested_currencies, successful_classifications,
"All tested currencies should be properly classified"
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_currency_classification_completeness",
"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_grpc-server_1270060618791218265 | clm | function | // connector-service/backend/grpc-server/tests/test_currency.rs
est_currency_error_message() {
// Since all current currencies should be classified, we can't easily test
// the error case without adding a fake currency. Instead, let's verify
// the error type exists and can be created
let error = CurrencyError::UnsupportedCurrency {
currency: "TEST".to_string(),
};
let error_string = format!("{error}");
assert!(error_string.contains("Unsupported currency: TEST"));
assert!(error_string.contains("Please add this currency to the supported currency list"));
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "_currency_error_message() {",
"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_grpc-server_5749166719857765785 | clm | function | // connector-service/backend/grpc-server/tests/test_currency.rs
est_comprehensive_currency_coverage() {
// Test a representative sample from each classification
let currencies_to_test = vec![
// Zero decimal currencies
(Currency::BIF, 0),
(Currency::CLP, 0),
(Currency::DJF, 0),
(Currency::GNF, 0),
(Currency::JPY, 0),
(Currency::KMF, 0),
(Currency::KRW, 0),
(Currency::MGA, 0),
(Currency::PYG, 0),
(Currency::RWF, 0),
(Currency::UGX, 0),
(Currency::VND, 0),
(Currency::VUV, 0),
(Currency::XAF, 0),
(Currency::XOF, 0),
(Currency::XPF, 0),
// Three decimal currencies
(Currency::BHD, 3),
(Currency::JOD, 3),
(Currency::KWD, 3),
(Currency::OMR, 3),
(Currency::TND, 3),
// Four decimal currencies
(Currency::CLF, 4),
// Two decimal currencies (sample)
(Currency::USD, 2),
(Currency::EUR, 2),
(Currency::GBP, 2),
(Currency::AED, 2),
(Currency::AFN, 2),
(Currency::ALL, 2),
(Currency::AMD, 2),
(Currency::ANG, 2),
(Currency::AOA, 2),
];
for (currency, expected_decimals) in currencies_to_test {
match currency.number_of_digits_after_decimal_point() {
Ok(decimals) => {
assert_eq!(decimals, expected_decimals,
"Currency {currency:?} should have {expected_decimals} decimals, got {decimals}");
}
Err(e) => {
panic!("Currency {currency:?} should be classified but got error: {e}");
}
}
}
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "_comprehensive_currency_coverage() {",
"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_grpc-server_5922106177325068942 | clm | function | // connector-service/backend/grpc-server/tests/common.rs
fn new(channel: Channel) -> Self {
Self::new(channel)
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "new",
"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_grpc-server_1430823553091514736 | clm | function | // connector-service/backend/grpc-server/tests/common.rs
pub async fn server_and_client_stub<T>(
service: grpc_server::app::Service,
) -> Result<(impl Future<Output = ()>, T), Box<dyn std::error::Error>>
where
T: AutoClient,
{
let socket = NamedTempFile::new()?;
let socket = Arc::new(socket.into_temp_path());
std::fs::remove_file(&*socket)?;
let uds = UnixListener::bind(&*socket)?;
let stream = UnixListenerStream::new(uds);
let serve_future = async {
let result = Server::builder()
.add_service(
grpc_api_types::health_check::health_server::HealthServer::new(
service.health_check_service,
),
)
.add_service(
grpc_api_types::payments::payment_service_server::PaymentServiceServer::new(
service.payments_service,
),
)
.add_service(
grpc_api_types::payments::refund_service_server::RefundServiceServer::new(
service.refunds_service,
),
)
.serve_with_incoming(stream)
.await;
// Server must be running fine...
assert!(result.is_ok());
};
let socket = Arc::clone(&socket);
// Connect to the server over a Unix socket
// The URL will be ignored.
let channel = Endpoint::try_from("http://any.url")?
.connect_with_connector(service_fn(move |_: Uri| {
let socket = Arc::clone(&socket);
async move {
// Wrap the UnixStream with TokioIo to make it compatible with hyper
let unix_stream = tokio::net::UnixStream::connect(&*socket).await?;
Ok::<_, std::io::Error>(TokioIo::new(unix_stream))
}
}))
.await?;
let client = T::new(channel);
Ok((serve_future, client))
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "server_and_client_stub",
"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_grpc-server_-4517455844453642043 | clm | function | // connector-service/backend/grpc-server/tests/utils/credential_utils.rs
fn get_creds_file_path() -> String {
std::env::var("CONNECTOR_AUTH_FILE_PATH")
.unwrap_or_else(|_| "../../.github/test/creds.json".to_string())
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_creds_file_path",
"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_grpc-server_-2862916656505513545 | clm | function | // connector-service/backend/grpc-server/tests/utils/credential_utils.rs
pub fn load_connector_auth(connector_name: &str) -> Result<ConnectorAuthType, CredentialError> {
load_from_json(connector_name)
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "load_connector_auth",
"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_grpc-server_-5490418293903000641 | clm | function | // connector-service/backend/grpc-server/tests/utils/credential_utils.rs
pub fn load_connector_metadata(
connector_name: &str,
) -> Result<HashMap<String, String>, CredentialError> {
let creds_file_path = get_creds_file_path();
let creds_content = fs::read_to_string(&creds_file_path)?;
let json_value: serde_json::Value = serde_json::from_str(&creds_content)?;
let all_credentials = match load_credentials_individually(&json_value) {
Ok(creds) => creds,
Err(_e) => {
// Try standard parsing as fallback
serde_json::from_value(json_value)?
}
};
let connector_creds = all_credentials
.get(connector_name)
.ok_or_else(|| CredentialError::ConnectorNotFound(connector_name.to_string()))?;
match &connector_creds.metadata {
Some(serde_json::Value::Object(map)) => {
let mut result = HashMap::new();
for (key, value) in map {
if let Some(string_val) = value.as_str() {
result.insert(key.clone(), string_val.to_string());
}
}
Ok(result)
}
_ => Ok(HashMap::new()),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "load_connector_metadata",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_234538463359408036 | clm | function | // connector-service/backend/grpc-server/tests/utils/credential_utils.rs
fn load_from_json(connector_name: &str) -> Result<ConnectorAuthType, CredentialError> {
let creds_file_path = get_creds_file_path();
let creds_content = fs::read_to_string(&creds_file_path)?;
let json_value: serde_json::Value = serde_json::from_str(&creds_content)?;
let all_credentials = match load_credentials_individually(&json_value) {
Ok(creds) => creds,
Err(_e) => {
// Try standard parsing as fallback
serde_json::from_value(json_value)?
}
};
let connector_creds = all_credentials
.get(connector_name)
.ok_or_else(|| CredentialError::ConnectorNotFound(connector_name.to_string()))?;
convert_to_auth_type(&connector_creds.connector_account_details, connector_name)
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "load_from_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_grpc-server_-5707773763803755018 | clm | function | // connector-service/backend/grpc-server/tests/utils/credential_utils.rs
fn load_credentials_individually(
json_value: &serde_json::Value,
) -> Result<AllCredentials, CredentialError> {
let mut all_credentials = HashMap::new();
let root_object = json_value.as_object().ok_or_else(|| {
CredentialError::InvalidStructure(
"root".to_string(),
"Expected JSON object at root".to_string(),
)
})?;
for (connector_name, connector_value) in root_object {
match parse_single_connector(connector_name, connector_value) {
Ok(creds) => {
all_credentials.insert(connector_name.clone(), creds);
}
Err(_e) => {
// Continue loading other connectors instead of failing completely
}
}
}
if all_credentials.is_empty() {
return Err(CredentialError::InvalidStructure(
"root".to_string(),
"No valid connectors found".to_string(),
));
}
Ok(all_credentials)
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "load_credentials_individually",
"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_grpc-server_3726245327309402691 | clm | function | // connector-service/backend/grpc-server/tests/utils/credential_utils.rs
fn parse_single_connector(
connector_name: &str,
connector_value: &serde_json::Value,
) -> Result<ConnectorCredentials, CredentialError> {
let connector_obj = connector_value.as_object().ok_or_else(|| {
CredentialError::InvalidStructure(
connector_name.to_string(),
"Expected JSON object".to_string(),
)
})?;
// Check if this is a flat structure (has connector_account_details directly)
if connector_obj.contains_key("connector_account_details") {
// Flat structure: connector_name -> { connector_account_details: {...} }
return parse_connector_credentials(connector_name, connector_value);
}
// Nested structure: connector_name -> { connector_1: {...}, connector_2: {...} } eg. stripe
for (_sub_name, sub_value) in connector_obj.iter() {
if let Some(sub_obj) = sub_value.as_object() {
if sub_obj.contains_key("connector_account_details") {
return parse_connector_credentials(connector_name, sub_value);
}
}
}
// If we get here, no valid connector_account_details was found
Err(CredentialError::InvalidStructure(
connector_name.to_string(),
"No connector_account_details found in flat or nested structure".to_string(),
))
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "parse_single_connector",
"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_grpc-server_-8407269880674003498 | clm | function | // connector-service/backend/grpc-server/tests/utils/credential_utils.rs
fn parse_connector_credentials(
connector_name: &str,
connector_value: &serde_json::Value,
) -> Result<ConnectorCredentials, CredentialError> {
let connector_obj = connector_value.as_object().ok_or_else(|| {
CredentialError::InvalidStructure(
connector_name.to_string(),
"Expected JSON object".to_string(),
)
})?;
let account_details_value =
connector_obj
.get("connector_account_details")
.ok_or_else(|| {
CredentialError::InvalidStructure(
connector_name.to_string(),
"Missing connector_account_details".to_string(),
)
})?;
let account_details = parse_connector_account_details(connector_name, account_details_value)?;
// Parse metadata if present
let metadata = connector_obj
.get("metadata")
.map(|v| serde_json::from_value(v.clone()))
.transpose()?;
Ok(ConnectorCredentials {
connector_account_details: account_details,
metadata,
})
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "parse_connector_credentials",
"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_grpc-server_-3278319753363087812 | clm | function | // connector-service/backend/grpc-server/tests/utils/credential_utils.rs
fn parse_connector_account_details(
connector_name: &str,
value: &serde_json::Value,
) -> Result<ConnectorAccountDetails, CredentialError> {
let obj = value.as_object().ok_or_else(|| {
CredentialError::InvalidStructure(
connector_name.to_string(),
"connector_account_details must be an object".to_string(),
)
})?;
// Extract auth_type first
let auth_type = obj
.get("auth_type")
.and_then(|v| v.as_str())
.ok_or_else(|| {
CredentialError::InvalidStructure(
connector_name.to_string(),
"Missing or invalid auth_type".to_string(),
)
})?
.to_string();
// Handle different auth types with specific parsing logic
match auth_type.as_str() {
"CurrencyAuthKey" => {
// Special handling for CurrencyAuthKey which has complex nested structure
parse_currency_auth_key_details(connector_name, obj)
}
_ => {
// For other auth types, use standard serde parsing
serde_json::from_value(value.clone()).map_err(CredentialError::ParseError)
}
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "parse_connector_account_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_grpc-server_-6421449900676208475 | clm | function | // connector-service/backend/grpc-server/tests/utils/credential_utils.rs
fn parse_currency_auth_key_details(
connector_name: &str,
obj: &serde_json::Map<String, serde_json::Value>,
) -> Result<ConnectorAccountDetails, CredentialError> {
let auth_key_map_value = obj.get("auth_key_map").ok_or_else(|| {
CredentialError::InvalidStructure(
connector_name.to_string(),
"Missing auth_key_map for CurrencyAuthKey".to_string(),
)
})?;
let auth_key_map_obj = auth_key_map_value.as_object().ok_or_else(|| {
CredentialError::InvalidStructure(
connector_name.to_string(),
"auth_key_map must be an object".to_string(),
)
})?;
let mut auth_key_map = HashMap::new();
for (currency_str, secret_value) in auth_key_map_obj {
let currency = currency_str.parse::<Currency>().map_err(|_| {
CredentialError::InvalidStructure(
connector_name.to_string(),
format!("Invalid currency: {}", currency_str),
)
})?;
let secret_serde_value = SecretSerdeValue::new(secret_value.clone());
auth_key_map.insert(currency, secret_serde_value);
}
Ok(ConnectorAccountDetails {
auth_type: "CurrencyAuthKey".to_string(),
api_key: None,
key1: None,
api_secret: None,
key2: None,
certificate: None,
private_key: None,
auth_key_map: Some(auth_key_map),
})
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "parse_currency_auth_key_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_grpc-server_-3398576078936142422 | clm | function | // connector-service/backend/grpc-server/tests/utils/credential_utils.rs
fn convert_to_auth_type(
details: &ConnectorAccountDetails,
connector_name: &str,
) -> Result<ConnectorAuthType, CredentialError> {
match details.auth_type.as_str() {
"HeaderKey" => {
let api_key = details.api_key.as_ref().ok_or_else(|| {
CredentialError::MissingField("api_key".to_string(), "HeaderKey".to_string())
})?;
Ok(ConnectorAuthType::HeaderKey {
api_key: Secret::new(api_key.clone()),
})
}
"BodyKey" => {
let api_key = details.api_key.as_ref().ok_or_else(|| {
CredentialError::MissingField("api_key".to_string(), "BodyKey".to_string())
})?;
let key1 = details.key1.as_ref().ok_or_else(|| {
CredentialError::MissingField("key1".to_string(), "BodyKey".to_string())
})?;
Ok(ConnectorAuthType::BodyKey {
api_key: Secret::new(api_key.clone()),
key1: Secret::new(key1.clone()),
})
}
"SignatureKey" => {
let api_key = details.api_key.as_ref().ok_or_else(|| {
CredentialError::MissingField("api_key".to_string(), "SignatureKey".to_string())
})?;
let key1 = details.key1.as_ref().ok_or_else(|| {
CredentialError::MissingField("key1".to_string(), "SignatureKey".to_string())
})?;
let api_secret = details.api_secret.as_ref().ok_or_else(|| {
CredentialError::MissingField("api_secret".to_string(), "SignatureKey".to_string())
})?;
Ok(ConnectorAuthType::SignatureKey {
api_key: Secret::new(api_key.clone()),
key1: Secret::new(key1.clone()),
api_secret: Secret::new(api_secret.clone()),
})
}
"MultiAuthKey" => {
let api_key = details.api_key.as_ref().ok_or_else(|| {
CredentialError::MissingField("api_key".to_string(), "MultiAuthKey".to_string())
})?;
let key1 = details.key1.as_ref().ok_or_else(|| {
CredentialError::MissingField("key1".to_string(), "MultiAuthKey".to_string())
})?;
let api_secret = details.api_secret.as_ref().ok_or_else(|| {
CredentialError::MissingField("api_secret".to_string(), "MultiAuthKey".to_string())
})?;
let key2 = details.key2.as_ref().ok_or_else(|| {
CredentialError::MissingField("key2".to_string(), "MultiAuthKey".to_string())
})?;
Ok(ConnectorAuthType::MultiAuthKey {
api_key: Secret::new(api_key.clone()),
key1: Secret::new(key1.clone()),
api_secret: Secret::new(api_secret.clone()),
key2: Secret::new(key2.clone()),
})
}
"CurrencyAuthKey" => {
// For CurrencyAuthKey, we expect the auth_key_map field to contain the mapping
let auth_key_map = details.auth_key_map.as_ref().ok_or_else(|| {
CredentialError::MissingField(
"auth_key_map".to_string(),
"CurrencyAuthKey".to_string(),
)
})?;
Ok(ConnectorAuthType::CurrencyAuthKey {
auth_key_map: auth_key_map.clone(),
})
}
"CertificateAuth" => {
let certificate = details.certificate.as_ref().ok_or_else(|| {
CredentialError::MissingField(
"certificate".to_string(),
"CertificateAuth".to_string(),
)
})?;
let private_key = details.private_key.as_ref().ok_or_else(|| {
CredentialError::MissingField(
"private_key".to_string(),
"CertificateAuth".to_string(),
)
})?;
Ok(ConnectorAuthType::CertificateAuth {
certificate: Secret::new(certificate.clone()),
private_key: Secret::new(private_key.clone()),
})
}
"NoKey" => Ok(ConnectorAuthType::NoKey),
"TemporaryAuth" => Ok(ConnectorAuthType::TemporaryAuth),
_ => Err(CredentialError::InvalidAuthType(
details.auth_type.clone(),
connector_name.to_string(),
)),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "convert_to_auth_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_grpc-server_-9087335898387241108 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
fn get_timestamp() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_timestamp",
"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_grpc-server_8037225562947343480 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
fn add_dlocal_metadata<T>(request: &mut Request<T>) {
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load dlocal credentials");
let (api_key, key1, api_secret) = match auth {
domain_types::router_data::ConnectorAuthType::SignatureKey {
api_key,
key1,
api_secret,
} => (api_key.expose(), key1.expose(), api_secret.expose()),
_ => panic!("Expected SignatureKey auth type for dlocal"),
};
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request.metadata_mut().append(
"x-auth",
"signature-key".parse().expect("Failed to parse x-auth"),
);
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
request
.metadata_mut()
.append("x-key1", key1.parse().expect("Failed to parse x-key1"));
request.metadata_mut().append(
"x-api-secret",
api_secret.parse().expect("Failed to parse x-api-secret"),
);
request.metadata_mut().append(
"x-merchant-id",
"test_merchant"
.parse()
.expect("Failed to parse x-merchant-id"),
);
request.metadata_mut().append(
"x-tenant-id",
"default".parse().expect("Failed to parse x-tenant-id"),
);
request.metadata_mut().append(
"x-request-id",
format!("test_request_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_dlocal_metadata",
"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_grpc-server_8530497804729948052 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
fn extract_transaction_id(response: &PaymentServiceAuthorizeResponse) -> String {
match &response.transaction_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector transaction ID"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_transaction_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-7004692653611065816 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
fn create_payment_authorize_request(
capture_method: common_enums::CaptureMethod,
) -> PaymentServiceAuthorizeRequest {
// Initialize with all required fields
let mut request = PaymentServiceAuthorizeRequest::default();
// Set request reference ID
let mut request_ref_id = Identifier::default();
request_ref_id.id_type = Some(IdType::Id(format!("dlocal_test_{}", get_timestamp())));
request.request_ref_id = Some(request_ref_id);
// Set the basic payment details
request.amount = TEST_AMOUNT;
request.minor_amount = TEST_AMOUNT;
request.currency = i32::from(Currency::Myr);
// Set up card payment method using the correct structure
let card_details = card_payment_method_type::CardType::Credit(CardDetails {
card_number: Some(CardNumber::from_str(TEST_CARD_NUMBER).unwrap()),
card_exp_month: Some(Secret::new(TEST_CARD_EXP_MONTH.to_string())),
card_exp_year: Some(Secret::new(TEST_CARD_EXP_YEAR.to_string())),
card_cvc: Some(Secret::new(TEST_CARD_CVC.to_string())),
card_holder_name: Some(Secret::new(TEST_CARD_HOLDER.to_string())),
card_issuer: None,
card_network: Some(1_i32), // Default to Visa network
card_type: None,
card_issuing_country_alpha2: None,
bank_code: None,
nick_name: None,
});
request.payment_method = Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType {
card_type: Some(card_details),
})),
});
// Set connector customer ID
request.customer_id = Some("TEST_CONNECTOR".to_string());
// Set the customer information with static email (can be made dynamic)
request.email = Some(TEST_EMAIL.to_string().into());
// Set up address structure
request.address = Some(PaymentAddress {
billing_address: Some(Address {
first_name: Some("Test".to_string().into()),
last_name: Some("User".to_string().into()),
line1: Some("123 Test Street".to_string().into()),
line2: None,
line3: None,
city: Some("Test City".to_string().into()),
state: Some("NY".to_string().into()),
zip_code: Some("10001".to_string().into()),
country_alpha2_code: Some(i32::from(CountryAlpha2::My)),
phone_number: None,
phone_country_code: None,
email: None,
}),
shipping_address: None,
});
// Set up browser information
let browser_info = BrowserInformation {
color_depth: None,
java_enabled: Some(false),
screen_height: Some(1080),
screen_width: Some(1920),
user_agent: Some("Mozilla/5.0 (compatible; TestAgent/1.0)".to_string()),
accept_header: Some(
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8".to_string(),
),
java_script_enabled: Some(false),
language: Some("en-US".to_string()),
ip_address: None,
os_type: None,
os_version: None,
device_model: None,
accept_language: None,
time_zone_offset_minutes: None,
referer: None,
};
request.browser_info = Some(browser_info);
// Set return URL
request.return_url = Some("https://example.com/return".to_string());
// Set the transaction details
request.auth_type = i32::from(AuthenticationType::NoThreeDs);
request.request_incremental_authorization = true;
request.enrolled_for_3ds = true;
// Set capture method with proper conversion
if let common_enums::CaptureMethod::Manual = capture_method {
request.capture_method = Some(i32::from(CaptureMethod::Manual));
} else {
request.capture_method = Some(i32::from(CaptureMethod::Automatic));
}
// Set connector metadata (empty for generic template)
request.metadata = HashMap::new();
request
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_authorize_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_537690575096248511 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
fn create_payment_sync_request(transaction_id: &str) -> PaymentServiceGetRequest {
PaymentServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("dlocal_sync_{}", get_timestamp()))),
}),
capture_method: None,
handle_response: None,
amount: TEST_AMOUNT,
currency: i32::from(Currency::Myr),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_sync_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_2593228449678822534 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
fn create_payment_capture_request(transaction_id: &str) -> PaymentServiceCaptureRequest {
PaymentServiceCaptureRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
amount_to_capture: TEST_AMOUNT,
currency: i32::from(Currency::Myr),
multiple_capture_data: None,
connector_metadata: HashMap::new(),
request_ref_id: None,
browser_info: None,
capture_method: None,
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_capture_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_580218554360138093 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
fn create_refund_request(transaction_id: &str) -> PaymentServiceRefundRequest {
PaymentServiceRefundRequest {
refund_id: format!("refund_{}", get_timestamp()),
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
currency: i32::from(Currency::Myr),
payment_amount: TEST_AMOUNT,
refund_amount: TEST_AMOUNT,
minor_payment_amount: TEST_AMOUNT,
minor_refund_amount: TEST_AMOUNT,
reason: None,
webhook_url: None,
metadata: HashMap::new(),
refund_metadata: HashMap::new(),
browser_info: None,
merchant_account_id: None,
capture_method: None,
request_ref_id: None,
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_1269185978118303654 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
fn create_refund_sync_request(transaction_id: &str, refund_id: &str) -> RefundServiceGetRequest {
RefundServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
refund_id: refund_id.to_string(),
refund_reason: None,
browser_info: None,
request_ref_id: None,
refund_metadata: HashMap::new(),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_sync_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_7718810210258698677 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
fn create_payment_void_request(transaction_id: &str) -> PaymentServiceVoidRequest {
PaymentServiceVoidRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
cancellation_reason: Some("Customer requested cancellation".to_string()),
request_ref_id: None,
all_keys_required: None,
browser_info: None,
amount: None,
currency: None,
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_void_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-1920577028512035934 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
async fn test_health() {
grpc_test!(client, HealthClient<Channel>, {
let response = client
.check(Request::new(HealthCheckRequest {
service: "connector_service".to_string(),
}))
.await
.expect("Failed to call health check")
.into_inner();
assert_eq!(
response.status(),
grpc_api_types::health_check::health_check_response::ServingStatus::Serving
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_health",
"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_grpc-server_-4618166132756716006 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
async fn test_payment_authorization_auto_capture() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request
let request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_dlocal_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Verify the response
assert!(
response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let _transaction_id = extract_transaction_id(&response);
// Verify payment status - in sandbox, payments may be rejected
let acceptable_statuses = [i32::from(PaymentStatus::Charged)];
assert!(
acceptable_statuses.contains(&response.status),
"Payment should be in CHARGED state (sandbox). Got status: {}",
response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_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_grpc-server_-865282097424566206 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
async fn test_payment_authorization_manual_capture() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_dlocal_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
assert!(
auth_response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let _transaction_id = extract_transaction_id(&auth_response);
// Verify payment status - in sandbox, payments may be rejected
let acceptable_auth_statuses = [i32::from(PaymentStatus::Authorized)];
assert!(
acceptable_auth_statuses.contains(&auth_response.status),
"Payment should be in AUTHORIZED state (sandbox). Got status: {}",
auth_response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_manual_capture",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_9068228309996836759 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
async fn test_payment_sync() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to sync
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_dlocal_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Add 5-second delay before sync request
sleep(Duration::from_secs(5)).await;
// Create sync request
let sync_request = create_payment_sync_request(&transaction_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_dlocal_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// Verify the sync response - in sandbox, payments may be rejected
let acceptable_sync_statuses = [i32::from(PaymentStatus::Authorized)];
assert!(
acceptable_sync_statuses.contains(&sync_response.status),
"Payment should be in AUTHORIZED state (sandbox). Got status: {}",
sync_response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_sync",
"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_grpc-server_-2099337265614418177 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
async fn test_payment_capture() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_dlocal_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
assert!(
auth_response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status - in sandbox, payments may be rejected
let acceptable_capture_auth_statuses = [i32::from(PaymentStatus::Authorized)];
assert!(
acceptable_capture_auth_statuses.contains(&auth_response.status),
"Payment should be in AUTHORIZED state (sandbox). Got status: {}",
auth_response.status
);
// Add 5-second delay before capture request
sleep(Duration::from_secs(5)).await;
// Create capture request
let capture_request = create_payment_capture_request(&transaction_id);
// Add metadata headers for capture request
let mut capture_grpc_request = Request::new(capture_request);
add_dlocal_metadata(&mut capture_grpc_request);
// Send the capture request
let capture_response = client
.capture(capture_grpc_request)
.await
.expect("gRPC payment_capture call failed")
.into_inner();
// Verify payment status after capture - in sandbox, may still be rejected
let acceptable_capture_statuses = [i32::from(PaymentStatus::Charged)];
assert!(
acceptable_capture_statuses.contains(&capture_response.status),
"Payment should be in CHARGED state (sandbox). Got status: {}",
capture_response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_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_grpc-server_2665088033369565649 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
async fn test_refund() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to refund
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_dlocal_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status - in sandbox, payments may be rejected
let acceptable_payment_statuses = [i32::from(PaymentStatus::Charged)];
assert!(
acceptable_payment_statuses.contains(&auth_response.status),
"Payment should be in CHARGED state (sandbox). Got status: {}",
auth_response.status
);
// Add 5-second delay before refund request
sleep(Duration::from_secs(5)).await;
// Create refund request
let refund_request = create_refund_request(&transaction_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_dlocal_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
// Extract the refund ID
let refund_id = refund_response.refund_id.clone();
// Verify the refund response
assert!(!refund_id.is_empty(), "Refund ID should not be empty");
assert!(
refund_response.status == i32::from(RefundStatus::RefundSuccess),
"Refund should be in SUCCESS state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund",
"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_grpc-server_7913222816220234402 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
async fn test_refund_sync() {
grpc_test!(client, PaymentServiceClient<Channel>, {
grpc_test!(refund_client, RefundServiceClient<Channel>, {
// First create a payment
let auth_request =
create_payment_authorize_request(common_enums::CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_dlocal_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Add 5-second delay before refund request
sleep(Duration::from_secs(5)).await;
// Create refund request
let refund_request = create_refund_request(&transaction_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_dlocal_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
// Extract the refund ID
let refund_id = refund_response.refund_id.clone();
// Verify the refund response
assert!(!refund_id.is_empty(), "Refund ID should not be empty");
// Add 5-second delay before refund sync request
sleep(Duration::from_secs(5)).await;
// Create refund sync request
let refund_sync_request = create_refund_sync_request(&transaction_id, &refund_id);
// Add metadata headers for refund sync request
let mut refund_sync_grpc_request = Request::new(refund_sync_request);
add_dlocal_metadata(&mut refund_sync_grpc_request);
// Send the refund sync request
let refund_sync_response = refund_client
.get(refund_sync_grpc_request)
.await
.expect("gRPC refund_sync call failed")
.into_inner();
// Verify the refund sync response
assert!(
refund_sync_response.status == i32::from(RefundStatus::RefundSuccess),
"Refund should be in SUCCESS state"
);
});
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund_sync",
"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_grpc-server_271339099011406746 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
async fn test_payment_void() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment with manual capture (so it stays in authorized state)
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_dlocal_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status - in sandbox, payments may be rejected
let acceptable_void_auth_statuses = [i32::from(PaymentStatus::Authorized)];
assert!(
acceptable_void_auth_statuses.contains(&auth_response.status),
"Payment should be in AUTHORIZED state (sandbox). Got status: {}",
auth_response.status
);
// Add 5-second delay before void request
sleep(Duration::from_secs(5)).await;
// Create void request
let void_request = create_payment_void_request(&transaction_id);
// Add metadata headers for void request
let mut void_grpc_request = Request::new(void_request);
add_dlocal_metadata(&mut void_grpc_request);
// Send the void request
let void_response = client
.void(void_grpc_request)
.await
.expect("gRPC payment_void call failed")
.into_inner();
// Verify the void response - in sandbox, may have different statuses
let acceptable_void_statuses = [i32::from(PaymentStatus::Voided)];
assert!(
acceptable_void_statuses.contains(&void_response.status),
"Payment should be in VOIDED state (sandbox). Got status: {}",
void_response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_void",
"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_grpc-server_5405538557574920359 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
fn get_timestamp() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_timestamp",
"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_grpc-server_5203756819315463270 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
fn add_nexinets_metadata<T>(request: &mut Request<T>) {
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load nexinets credentials");
let (api_key, key1) = match auth {
domain_types::router_data::ConnectorAuthType::BodyKey { api_key, key1 } => {
(api_key.expose(), key1.expose())
}
_ => panic!("Expected BodyKey auth type for nexinets"),
};
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request
.metadata_mut()
.append("x-auth", AUTH_TYPE.parse().expect("Failed to parse x-auth"));
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
request
.metadata_mut()
.append("x-key1", key1.parse().expect("Failed to parse x-key1"));
request.metadata_mut().append(
"x-merchant-id",
MERCHANT_ID.parse().expect("Failed to parse x-merchant-id"),
);
request.metadata_mut().append(
"x-request-id",
format!("test_request_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_nexinets_metadata",
"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_grpc-server_-8143901725655754752 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
fn extract_transaction_id(response: &PaymentServiceAuthorizeResponse) -> String {
match &response.transaction_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector transaction ID"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_transaction_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-8982527752397817585 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
fn extract_refund_id(response: &RefundResponse) -> &String {
&response.refund_id
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_refund_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-7324568418767787954 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
fn extract_request_ref_id(response: &PaymentServiceAuthorizeResponse) -> String {
match &response.response_ref_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector response_ref_id"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_request_ref_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-3349245867297723084 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
fn create_payment_authorize_request(
capture_method: CaptureMethod,
) -> PaymentServiceAuthorizeRequest {
let card_details = card_payment_method_type::CardType::Credit(CardDetails {
card_number: Some(CardNumber::from_str(TEST_CARD_NUMBER).unwrap()),
card_exp_month: Some(Secret::new(TEST_CARD_EXP_MONTH.to_string())),
card_exp_year: Some(Secret::new(TEST_CARD_EXP_YEAR.to_string())),
card_cvc: Some(Secret::new(TEST_CARD_CVC.to_string())),
card_holder_name: Some(Secret::new(TEST_CARD_HOLDER.to_string())),
card_network: Some(1),
card_issuer: None,
card_type: None,
card_issuing_country_alpha2: None,
bank_code: None,
nick_name: None,
});
PaymentServiceAuthorizeRequest {
amount: TEST_AMOUNT,
minor_amount: TEST_AMOUNT,
currency: i32::from(Currency::Eur),
payment_method: Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType {
card_type: Some(card_details),
})),
}),
return_url: Some("https://duck.com".to_string()),
email: Some(TEST_EMAIL.to_string().into()),
address: Some(grpc_api_types::payments::PaymentAddress::default()),
auth_type: i32::from(AuthenticationType::NoThreeDs),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("nexinets_test_{}", get_timestamp()))),
}),
enrolled_for_3ds: false,
request_incremental_authorization: false,
capture_method: Some(i32::from(capture_method)),
// payment_method_type: Some(i32::from(PaymentMethodType::Credit)),
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_authorize_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_7750518949056343709 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
fn create_payment_sync_request(
transaction_id: &str,
request_ref_id: &str,
) -> PaymentServiceGetRequest {
PaymentServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(request_ref_id.to_string())),
}),
// all_keys_required: None,
capture_method: None,
amount: TEST_AMOUNT,
currency: i32::from(Currency::Eur),
handle_response: None,
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_sync_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_1921466990052191499 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
fn create_payment_capture_request(
transaction_id: &str,
request_ref_id: &str,
) -> PaymentServiceCaptureRequest {
PaymentServiceCaptureRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
amount_to_capture: TEST_AMOUNT,
currency: i32::from(Currency::Eur),
multiple_capture_data: None,
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(request_ref_id.to_string())),
}),
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_capture_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-3675490571471844015 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
fn create_refund_request(
transaction_id: &str,
request_ref_id: &str,
) -> PaymentServiceRefundRequest {
// Create connector metadata as a proper JSON object
let mut connector_metadata = HashMap::new();
connector_metadata.insert("order_id".to_string(), request_ref_id);
let connector_metadata_json =
serde_json::to_string(&connector_metadata).expect("Failed to serialize connector metadata");
let mut metadata = HashMap::new();
metadata.insert("connector_metadata".to_string(), connector_metadata_json);
PaymentServiceRefundRequest {
refund_id: format!("refund_{}", get_timestamp()),
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
currency: i32::from(Currency::Eur),
payment_amount: TEST_AMOUNT,
refund_amount: TEST_AMOUNT,
minor_payment_amount: TEST_AMOUNT,
minor_refund_amount: TEST_AMOUNT,
reason: None,
webhook_url: None,
browser_info: None,
merchant_account_id: None,
capture_method: None,
request_ref_id: None,
metadata,
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-783794505401645596 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
fn create_refund_sync_request(
transaction_id: &str,
refund_id: &str,
request_ref_id: &str,
) -> RefundServiceGetRequest {
RefundServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
refund_id: refund_id.to_string(),
refund_reason: None,
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(request_ref_id.to_string())),
}),
browser_info: None,
refund_metadata: HashMap::new(),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_sync_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-2494081581764821774 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
async fn visit_3ds_authentication_url(
request_ref_id: &str,
) -> Result<(), Box<dyn std::error::Error>> {
// Get the key1 value from auth credentials for the URL
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load nexinets credentials");
let key1 = match auth {
domain_types::router_data::ConnectorAuthType::BodyKey { key1, .. } => key1.expose(),
_ => panic!("Expected BodyKey auth type for nexinets"),
};
// Construct the 3DS authentication URL with correct format
let url = format!("https://pptest.payengine.de/three-ds-v2-order/{key1}/{request_ref_id}",);
// Create reqwest client with timeout and proper TLS configuration
let client = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(30))
.danger_accept_invalid_certs(false) // Keep TLS verification enabled
.user_agent("nexinets-test-client/1.0")
.build()?;
// Send GET request
let response = client.get(&url).send().await?;
// Read response body for additional debugging (optional)
let body = response.text().await?;
// Log first 200 characters of response for debugging (if not empty)
if !body.is_empty() {
let _preview = if body.len() > 200 {
&body[..200]
} else {
&body
};
}
Ok(())
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "visit_3ds_authentication_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_grpc-server_-8975909391053314531 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
async fn test_health() {
grpc_test!(client, HealthClient<Channel>, {
let response = client
.check(Request::new(HealthCheckRequest {
service: "connector_service".to_string(),
}))
.await
.expect("Failed to call health check")
.into_inner();
assert_eq!(
response.status(),
grpc_api_types::health_check::health_check_response::ServingStatus::Serving
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_health",
"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_grpc-server_2573844904315562311 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
async fn test_payment_authorization_auto_capture() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request
let request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_nexinets_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Verify the response
assert!(
response.transaction_id.is_some(),
"Resource ID should be present"
);
assert!(
response.status == i32::from(PaymentStatus::AuthenticationPending)
|| response.status == i32::from(PaymentStatus::Pending)
|| response.status == i32::from(PaymentStatus::Charged),
"Payment should be in AuthenticationPending or Pending state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_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_grpc-server_-6349149238852943944 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
async fn test_payment_authorization_manual_capture() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Add delay of 2 seconds
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_nexinets_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Extract the request ref ID which is Order_id for nexinets
let request_ref_id = extract_request_ref_id(&auth_response);
let mut final_payment_status = auth_response.status;
// Check if payment requires 3DS authentication
if auth_response.status == i32::from(PaymentStatus::AuthenticationPending) {
// Visit the 3DS authentication URL to simulate user completing authentication
let _ = visit_3ds_authentication_url(&request_ref_id).await;
// Wait a moment for the authentication state to be updated
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
// Sync the payment to get updated status after 3DS authentication
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
let mut sync_grpc_request = Request::new(sync_request);
add_nexinets_metadata(&mut sync_grpc_request);
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
final_payment_status = sync_response.status;
// Note: Simply visiting the 3DS URL doesn't complete the authentication
// The payment may still be in AuthenticationPending state
// In a real scenario, the user would interact with the 3DS page
// For testing purposes, we'll accept either AuthenticationPending or Authorized
assert!(
final_payment_status == i32::from(PaymentStatus::Authorized)
|| final_payment_status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AUTHORIZED or still AUTHENTICATION_PENDING state after visiting 3DS URL. Current status: {final_payment_status}",
);
} else {
// Verify payment status is authorized (for manual capture without 3DS)
assert!(
auth_response.status == i32::from(PaymentStatus::Authorized),
"Payment should be in AUTHORIZED state with manual capture"
);
}
// Only proceed with capture if payment is in Authorized state
// If still in AuthenticationPending, skip capture as it requires user
// interaction
if final_payment_status == i32::from(PaymentStatus::Authorized) {
// Create capture request (which already includes proper connector metadata)
let capture_request = create_payment_capture_request(&transaction_id, &request_ref_id);
// Add metadata headers for capture request
let mut capture_grpc_request = Request::new(capture_request);
add_nexinets_metadata(&mut capture_grpc_request);
// Send the capture request
let capture_response = client
.capture(capture_grpc_request)
.await
.expect("gRPC payment_capture call failed")
.into_inner();
// Verify payment status is charged after capture
assert!(
capture_response.status == i32::from(PaymentStatus::Charged),
"Payment should be in CHARGED state after capture"
);
}
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_manual_capture",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-7562603936132445620 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
async fn test_payment_sync() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Add delay of 4 seconds
tokio::time::sleep(std::time::Duration::from_secs(4)).await;
// First create a payment to sync
let auth_request = create_payment_authorize_request(CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_nexinets_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Extract the request ref ID which is Order_id for nexinets
let request_ref_id = extract_request_ref_id(&auth_response);
// Check if payment requires 3DS authentication
if auth_response.status == i32::from(PaymentStatus::AuthenticationPending) {
let _ = visit_3ds_authentication_url(&request_ref_id).await;
// Wait a moment for the authentication state to be updated
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
}
// Create sync request
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_nexinets_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// For testing purposes, we'll accept AuthenticationPending or Authorized
assert!(
sync_response.status == i32::from(PaymentStatus::Authorized)
|| sync_response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AUTHORIZED or AUTHENTICATION_PENDING state. Current status: {}",
sync_response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_sync",
"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_grpc-server_8168760420965969864 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
async fn test_refund() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Add delay of 6 seconds
tokio::time::sleep(std::time::Duration::from_secs(6)).await;
// Create the payment authorization request
let request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_nexinets_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&response);
// Extract the request ref ID which is Order_id for nexinets
let request_ref_id = extract_request_ref_id(&response);
// Check if payment requires 3DS authentication
if response.status == i32::from(PaymentStatus::AuthenticationPending) {
let _ = visit_3ds_authentication_url(&request_ref_id).await;
// Wait a moment for the authentication state to be updated
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
// Sync the payment to get updated status after 3DS authentication
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
let mut sync_grpc_request = Request::new(sync_request);
add_nexinets_metadata(&mut sync_grpc_request);
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
assert!(
sync_response.status == i32::from(PaymentStatus::Charged)
|| sync_response.status == i32::from(PaymentStatus::Authorized)
|| sync_response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in CHARGED, AUTHORIZED, or AUTHENTICATION_PENDING state after 3DS URL visit. Current status: {}",
sync_response.status
);
} else {
assert!(
response.status == i32::from(PaymentStatus::AuthenticationPending)
|| response.status == i32::from(PaymentStatus::Pending)
|| response.status == i32::from(PaymentStatus::Charged),
"Payment should be in AuthenticationPending or Pending state"
);
}
// Wait a bit longer to ensure the payment is fully processed
tokio::time::sleep(tokio::time::Duration::from_secs(12)).await;
// Only attempt refund if payment is in a refundable state
// Check final payment status to determine if refund is possible
let final_sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
let mut final_sync_grpc_request = Request::new(final_sync_request);
add_nexinets_metadata(&mut final_sync_grpc_request);
let final_sync_response = client
.get(final_sync_grpc_request)
.await
.expect("gRPC final payment_sync call failed")
.into_inner();
if final_sync_response.status == i32::from(PaymentStatus::Charged)
|| final_sync_response.status == i32::from(PaymentStatus::Authorized)
{
// Create refund request
let refund_request = create_refund_request(&transaction_id, &request_ref_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_nexinets_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
// Verify the refund response
assert!(
refund_response.status == i32::from(RefundStatus::RefundSuccess),
"Refund should be in RefundSuccess state"
);
}
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund",
"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_grpc-server_7650594654503475134 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
async fn test_refund_sync() {
grpc_test!(client, PaymentServiceClient<Channel>, {
grpc_test!(refund_client, RefundServiceClient<Channel>, {
// Add delay of 8 seconds
tokio::time::sleep(std::time::Duration::from_secs(8)).await;
// First create a payment
let auth_request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_nexinets_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Extract the request ref ID which is Order_id for nexinets
let request_ref_id = extract_request_ref_id(&auth_response);
// Check if payment requires 3DS authentication
if auth_response.status == i32::from(PaymentStatus::AuthenticationPending) {
let _ = visit_3ds_authentication_url(&request_ref_id).await;
// Wait a moment for the authentication state to be updated
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
} else {
// Wait for payment to process
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
}
// Create sync request to check payment status
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_nexinets_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
assert!(
sync_response.status == i32::from(PaymentStatus::Charged)
|| sync_response.status == i32::from(PaymentStatus::Authorized)
|| sync_response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in CHARGED, AUTHORIZED, or AUTHENTICATION_PENDING state. Current status: {}",
sync_response.status
);
// Only attempt refund if payment is in a refundable state
if sync_response.status == i32::from(PaymentStatus::Charged)
|| sync_response.status == i32::from(PaymentStatus::Authorized)
{
// Create refund request
let refund_request = create_refund_request(&transaction_id, &request_ref_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_nexinets_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
// Verify the refund response
assert!(
refund_response.status == i32::from(RefundStatus::RefundSuccess),
"Refund should be in RefundSuccess state"
);
let refund_id = extract_refund_id(&refund_response);
// Wait a bit longer to ensure the refund is fully processed
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
// Create refund sync request with our mock ID
let refund_sync_request =
create_refund_sync_request(&transaction_id, refund_id, &request_ref_id);
// Add metadata headers for refund sync request
let mut refund_sync_grpc_request = Request::new(refund_sync_request);
add_nexinets_metadata(&mut refund_sync_grpc_request);
// Send the refund sync request
let refund_sync_response = refund_client
.get(refund_sync_grpc_request)
.await
.expect("gRPC refund sync call failed")
.into_inner();
// Verify the refund sync response
assert!(
refund_sync_response.status == i32::from(RefundStatus::RefundSuccess),
"Refund Sync should be in RefundSuccess state"
);
}
});
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund_sync",
"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_grpc-server_5684780175290799450 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
fn get_timestamp() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_timestamp",
"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_grpc-server_8361750996602241665 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
fn add_aci_metadata<T>(request: &mut Request<T>) {
// Get API credentials using the common credential loading utility
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load ACI credentials");
let (api_key, key1) = match auth {
domain_types::router_data::ConnectorAuthType::BodyKey { api_key, key1 } => {
(api_key.expose(), key1.expose())
}
_ => panic!("Expected BodyKey auth type for ACI"),
};
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request.metadata_mut().append(
"x-auth",
"body-key".parse().expect("Failed to parse x-auth"),
);
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
request
.metadata_mut()
.append("x-key1", key1.parse().expect("Failed to parse x-key1"));
request.metadata_mut().append(
"x-merchant-id",
"test_merchant"
.parse()
.expect("Failed to parse x-merchant-id"),
);
request.metadata_mut().append(
"x-tenant-id",
"default".parse().expect("Failed to parse x-tenant-id"),
);
request.metadata_mut().append(
"x-request-id",
format!("test_request_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
request.metadata_mut().append(
"x-connector-request-reference-id",
format!("conn_ref_{}", get_timestamp())
.parse()
.expect("Failed to parse x-connector-request-reference-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_aci_metadata",
"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_grpc-server_-6353093418592794739 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
fn extract_transaction_id(response: &PaymentServiceAuthorizeResponse) -> String {
match &response.transaction_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector transaction ID"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_transaction_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-5349812120216172950 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
fn create_payment_authorize_request(
capture_method: common_enums::CaptureMethod,
) -> PaymentServiceAuthorizeRequest {
// Initialize with all required fields
let mut request = PaymentServiceAuthorizeRequest::default();
// Set request reference ID
request.request_ref_id = Some(Identifier {
id_type: Some(IdType::Id(format!("aci_test_{}", get_timestamp()))),
});
// Set the basic payment details
request.amount = TEST_AMOUNT;
request.minor_amount = TEST_AMOUNT;
request.currency = i32::from(Currency::Usd);
// Set up card payment method using the correct structure
let card_details = card_payment_method_type::CardType::Credit(CardDetails {
card_number: Some(CardNumber::from_str(TEST_CARD_NUMBER).unwrap()),
card_exp_month: Some(Secret::new(TEST_CARD_EXP_MONTH.to_string())),
card_exp_year: Some(Secret::new(TEST_CARD_EXP_YEAR.to_string())),
card_cvc: Some(Secret::new(TEST_CARD_CVC.to_string())),
card_holder_name: Some(Secret::new(TEST_CARD_HOLDER.to_string())),
card_issuer: None,
card_network: Some(1_i32), // Default to Visa network
card_type: None,
card_issuing_country_alpha2: None,
bank_code: None,
nick_name: None,
});
request.payment_method = Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType {
card_type: Some(card_details),
})),
});
// Set connector customer ID
request.customer_id = Some("TEST_CONNECTOR".to_string());
// Set the customer information with static email (can be made dynamic)
request.email = Some(TEST_EMAIL.to_string().into());
// Set up address structure
request.address = Some(PaymentAddress {
billing_address: Some(Address {
first_name: Some("Test".to_string().into()),
last_name: Some("User".to_string().into()),
line1: Some("123 Test Street".to_string().into()),
line2: None,
line3: None,
city: Some("Test City".to_string().into()),
state: Some("NY".to_string().into()),
zip_code: Some("10001".to_string().into()),
country_alpha2_code: Some(i32::from(CountryAlpha2::Us)),
phone_number: None,
phone_country_code: None,
email: None,
}),
shipping_address: None,
});
// Set up browser information
let browser_info = BrowserInformation {
color_depth: None,
java_enabled: Some(false),
screen_height: Some(1080),
screen_width: Some(1920),
user_agent: Some("Mozilla/5.0 (compatible; TestAgent/1.0)".to_string()),
accept_header: Some(
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8".to_string(),
),
java_script_enabled: Some(false),
language: Some("en-US".to_string()),
ip_address: None,
os_type: None,
os_version: None,
device_model: None,
accept_language: None,
time_zone_offset_minutes: None,
referer: None,
};
request.browser_info = Some(browser_info);
// Set return URL
request.return_url = Some("https://example.com/return".to_string());
// Set the transaction details
request.auth_type = i32::from(AuthenticationType::NoThreeDs);
request.request_incremental_authorization = true;
request.enrolled_for_3ds = true;
// Set capture method with proper conversion
if let common_enums::CaptureMethod::Manual = capture_method {
request.capture_method = Some(i32::from(CaptureMethod::Manual));
} else {
request.capture_method = Some(i32::from(CaptureMethod::Automatic));
}
// Set connector metadata (empty for generic template)
request.metadata = HashMap::new();
request
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_authorize_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-867160144935410371 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
fn create_payment_sync_request(transaction_id: &str) -> PaymentServiceGetRequest {
PaymentServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("aci_sync_{}", get_timestamp()))),
}),
capture_method: Some(i32::from(CaptureMethod::Automatic)),
handle_response: None,
amount: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_sync_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-1023234141265144615 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
fn create_payment_capture_request(transaction_id: &str) -> PaymentServiceCaptureRequest {
PaymentServiceCaptureRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
amount_to_capture: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
multiple_capture_data: None,
connector_metadata: HashMap::new(),
request_ref_id: None,
browser_info: None,
capture_method: None,
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_capture_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_8755601822934380549 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
fn create_refund_request(transaction_id: &str) -> PaymentServiceRefundRequest {
PaymentServiceRefundRequest {
refund_id: format!("refund_{}", get_timestamp()),
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
currency: i32::from(Currency::Usd),
payment_amount: TEST_AMOUNT,
refund_amount: TEST_AMOUNT,
minor_payment_amount: TEST_AMOUNT,
minor_refund_amount: TEST_AMOUNT,
reason: None,
webhook_url: None,
metadata: HashMap::new(),
refund_metadata: HashMap::new(),
browser_info: None,
merchant_account_id: None,
capture_method: None,
request_ref_id: None,
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_7024445772183144600 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
fn create_payment_void_request(transaction_id: &str) -> PaymentServiceVoidRequest {
PaymentServiceVoidRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
cancellation_reason: Some("Customer requested cancellation".to_string()),
request_ref_id: None,
all_keys_required: None,
browser_info: None,
amount: None,
currency: None,
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_void_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_2170273383780895929 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
fn create_register_request() -> PaymentServiceRegisterRequest {
let card_details = card_payment_method_type::CardType::Credit(CardDetails {
card_number: Some(CardNumber::from_str(TEST_CARD_NUMBER).unwrap()),
card_exp_month: Some(Secret::new(TEST_CARD_EXP_MONTH.to_string())),
card_exp_year: Some(Secret::new(TEST_CARD_EXP_YEAR.to_string())),
card_cvc: Some(Secret::new(TEST_CARD_CVC.to_string())),
card_holder_name: Some(Secret::new(TEST_CARD_HOLDER.to_string())),
card_issuer: None,
card_network: Some(1_i32), // Visa network
card_type: None,
card_issuing_country_alpha2: None,
bank_code: None,
nick_name: None,
});
PaymentServiceRegisterRequest {
minor_amount: Some(TEST_AMOUNT),
currency: i32::from(Currency::Usd),
payment_method: Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType {
card_type: Some(card_details),
})),
}),
customer_name: Some(TEST_CARD_HOLDER.to_string()),
email: Some(TEST_EMAIL.to_string().into()),
customer_acceptance: Some(CustomerAcceptance {
acceptance_type: i32::from(AcceptanceType::Offline),
accepted_at: 0,
online_mandate_details: None,
}),
address: Some(PaymentAddress {
billing_address: Some(Address {
first_name: Some("Test".to_string().into()),
last_name: Some("Customer".to_string().into()),
line1: Some("123 Test St".to_string().into()),
line2: None,
line3: None,
city: Some("Test City".to_string().into()),
state: Some("NY".to_string().into()),
zip_code: Some("10001".to_string().into()),
country_alpha2_code: Some(i32::from(CountryAlpha2::Us)),
phone_number: None,
phone_country_code: None,
email: Some(TEST_EMAIL.to_string().into()),
}),
shipping_address: None,
}),
auth_type: i32::from(AuthenticationType::NoThreeDs),
setup_future_usage: Some(i32::from(FutureUsage::OffSession)),
enrolled_for_3ds: false,
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("mandate_{}", get_timestamp()))),
}),
metadata: HashMap::new(),
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_register_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-317732705414966404 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
fn create_repeat_payment_request(mandate_id: &str) -> PaymentServiceRepeatEverythingRequest {
let mandate_reference = MandateReference {
mandate_id: Some(mandate_id.to_string()),
payment_method_id: None,
};
// Create metadata matching your JSON format
let mut metadata = HashMap::new();
metadata.insert("order_type".to_string(), "recurring".to_string());
metadata.insert(
"customer_note".to_string(),
"Monthly subscription payment".to_string(),
);
PaymentServiceRepeatEverythingRequest {
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("mandate_{}", get_timestamp()))),
}),
mandate_reference: Some(mandate_reference),
amount: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
minor_amount: TEST_AMOUNT,
merchant_order_reference_id: Some(format!("repeat_order_{}", get_timestamp())),
metadata,
webhook_url: Some("https://your-webhook-url.com/payments/webhook".to_string()),
capture_method: None,
email: None,
browser_info: None,
test_mode: None,
payment_method_type: None,
merchant_account_metadata: HashMap::new(),
state: None,
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_repeat_payment_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_5653901729355680281 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
async fn test_health() {
grpc_test!(client, HealthClient<Channel>, {
let response = client
.check(Request::new(HealthCheckRequest {
service: "connector_service".to_string(),
}))
.await
.expect("Failed to call health check")
.into_inner();
assert_eq!(
response.status(),
grpc_api_types::health_check::health_check_response::ServingStatus::Serving
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_health",
"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_grpc-server_-5925368234883700383 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
async fn test_payment_authorization_auto_capture() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request
let request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_aci_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Verify the response
assert!(
response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let _transaction_id = extract_transaction_id(&response);
// Verify payment status
assert_eq!(
response.status,
i32::from(PaymentStatus::Charged),
"Payment should be in CHARGED state for automatic capture"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_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_grpc-server_7058534996290360287 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
async fn test_payment_authorization_manual_capture() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_aci_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
assert!(
auth_response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let _transaction_id = extract_transaction_id(&auth_response);
// Verify payment status is authorized (for manual capture)
assert_eq!(
auth_response.status,
i32::from(PaymentStatus::Authorized),
"Payment should be in AUTHORIZED state with manual capture"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_manual_capture",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-8371798294911903448 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
async fn test_payment_sync() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to sync
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_aci_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Create sync request
let sync_request = create_payment_sync_request(&transaction_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_aci_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// Verify the sync response - allow both AUTHORIZED and PENDING states
let acceptable_sync_statuses = [
i32::from(PaymentStatus::Authorized),
i32::from(PaymentStatus::Charged),
];
assert!(
acceptable_sync_statuses.contains(&sync_response.status),
"Payment should be in AUTHORIZED or CHARGED state, but was: {}",
sync_response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_sync",
"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_grpc-server_1782508465075671306 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
async fn test_payment_capture() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_aci_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
assert!(
auth_response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status is authorized (for manual capture)
assert!(
auth_response.status == i32::from(PaymentStatus::Authorized),
"Payment should be in AUTHORIZED state with manual capture"
);
// Create capture request
let capture_request = create_payment_capture_request(&transaction_id);
// Add metadata headers for capture request
let mut capture_grpc_request = Request::new(capture_request);
add_aci_metadata(&mut capture_grpc_request);
// Send the capture request
let capture_response = client
.capture(capture_grpc_request)
.await
.expect("gRPC payment_capture call failed")
.into_inner();
// Verify payment status is charged after capture
assert!(
capture_response.status == i32::from(PaymentStatus::Charged),
"Payment should be in CHARGED state after capture"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_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_grpc-server_-5471520689611595850 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
async fn test_refund() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to refund
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_aci_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status - allow both CHARGED and PENDING states
let acceptable_payment_statuses = [i32::from(PaymentStatus::Charged)];
assert!(
acceptable_payment_statuses.contains(&auth_response.status),
"Payment should be in CHARGED state before attempting refund, but was: {}",
auth_response.status
);
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
// Create refund request
let refund_request = create_refund_request(&transaction_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_aci_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
// Extract the refund ID
let refund_id = refund_response.refund_id.clone();
// Verify the refund response
assert!(!refund_id.is_empty(), "Refund ID should not be empty");
assert!(
refund_response.status == i32::from(RefundStatus::RefundSuccess)
|| refund_response.status == i32::from(RefundStatus::RefundPending),
"Refund should be in SUCCESS or PENDING state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund",
"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_grpc-server_5205300293550621183 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
async fn test_payment_void() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment with manual capture (so it stays in authorized state)
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_aci_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment is in authorized state
assert!(
auth_response.status == i32::from(PaymentStatus::Authorized),
"Payment should be in AUTHORIZED state before void"
);
// Create void request
let void_request = create_payment_void_request(&transaction_id);
// Add metadata headers for void request
let mut void_grpc_request = Request::new(void_request);
add_aci_metadata(&mut void_grpc_request);
// Send the void request
let void_response = client
.void(void_grpc_request)
.await
.expect("gRPC payment_void call failed")
.into_inner();
// Verify the void response
assert!(
void_response.status == i32::from(PaymentStatus::Voided),
"Payment should be in VOIDED state after void"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_void",
"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_grpc-server_-2168281538200383900 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
async fn test_register() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the register request
let request = create_register_request();
// Add metadata headers
let mut grpc_request = Request::new(request);
add_aci_metadata(&mut grpc_request);
// Send the request
let response = client
.register(grpc_request)
.await
.expect("gRPC register call failed")
.into_inner();
// Verify the response
assert!(
response.registration_id.is_some(),
"Registration ID should be present"
);
// Check if we have a mandate reference
assert!(
response.mandate_reference.is_some(),
"Mandate reference should be present"
);
// Verify the mandate reference has the expected structure
if let Some(mandate_ref) = &response.mandate_reference {
assert!(
mandate_ref.mandate_id.is_some(),
"Mandate ID should be present"
);
// Verify the mandate ID is not empty
if let Some(mandate_id) = &mandate_ref.mandate_id {
assert!(!mandate_id.is_empty(), "Mandate ID should not be empty");
}
}
// Verify no error occurred
assert!(
response.error_message.is_none() || response.error_message.as_ref().unwrap().is_empty(),
"No error message should be present for successful register"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_register",
"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_grpc-server_6132595416930104492 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
async fn test_repeat_everything() {
grpc_test!(client, PaymentServiceClient<Channel>, {
tokio::time::sleep(std::time::Duration::from_secs(4)).await;
// First, create a mandate using register
let register_request = create_register_request();
let mut register_grpc_request = Request::new(register_request);
add_aci_metadata(&mut register_grpc_request);
let register_response = client
.register(register_grpc_request)
.await
.expect("gRPC register call failed")
.into_inner();
// Verify we got a mandate reference
assert!(
register_response.mandate_reference.is_some(),
"Mandate reference should be present"
);
let mandate_id = register_response
.mandate_reference
.as_ref()
.unwrap()
.mandate_id
.as_ref()
.expect("Mandate ID should be present");
// Now perform a repeat payment using the mandate
let repeat_request = create_repeat_payment_request(mandate_id);
let mut repeat_grpc_request = Request::new(repeat_request);
add_aci_metadata(&mut repeat_grpc_request);
// Send the repeat payment request
let repeat_response = client
.repeat_everything(repeat_grpc_request)
.await
.expect("gRPC repeat_everything call failed")
.into_inner();
// Verify the response
assert!(
repeat_response.transaction_id.is_some(),
"Transaction ID should be present"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_repeat_everything",
"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_grpc-server_-3528268766551265674 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/cryptopay_payment_flows_test.rs
fn get_timestamp() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_timestamp",
"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_grpc-server_-5781097228737042236 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/cryptopay_payment_flows_test.rs
fn add_cryptopay_metadata<T>(request: &mut Request<T>) {
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load cryptopay credentials");
let (api_key, key1) = match auth {
domain_types::router_data::ConnectorAuthType::BodyKey { api_key, key1 } => {
(api_key.expose(), key1.expose())
}
_ => panic!("Expected BodyKey auth type for cryptopay"),
};
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request
.metadata_mut()
.append("x-auth", AUTH_TYPE.parse().expect("Failed to parse x-auth"));
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
request
.metadata_mut()
.append("x-key1", key1.parse().expect("Failed to parse x-key1"));
request.metadata_mut().append(
"x-merchant-id",
MERCHANT_ID.parse().expect("Failed to parse x-merchant-id"),
);
request.metadata_mut().append(
"x-request-id",
format!("test_request_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_cryptopay_metadata",
"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_grpc-server_2679368741617297680 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/cryptopay_payment_flows_test.rs
fn extract_request_ref_id(response: &PaymentServiceAuthorizeResponse) -> String {
match &response.response_ref_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector response_ref_id"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_request_ref_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-4983914962124537193 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/cryptopay_payment_flows_test.rs
fn create_authorize_request(capture_method: CaptureMethod) -> PaymentServiceAuthorizeRequest {
PaymentServiceAuthorizeRequest {
amount: TEST_AMOUNT,
minor_amount: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
payment_method: Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Crypto(
CryptoCurrencyPaymentMethodType {
crypto_currency: Some(CryptoCurrency {
pay_currency: Some(TEST_PAY_CURRENCY.to_string()),
network: Some(TEST_NETWORK.to_string()),
}),
},
)),
}),
return_url: Some(
"https://hyperswitch.io/connector-service/authnet_webhook_grpcurl".to_string(),
),
webhook_url: Some(
"https://hyperswitch.io/connector-service/authnet_webhook_grpcurl".to_string(),
),
email: Some(TEST_EMAIL.to_string().into()),
address: Some(grpc_api_types::payments::PaymentAddress::default()),
auth_type: i32::from(AuthenticationType::NoThreeDs),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("cryptopay_test_{}", get_timestamp()))),
}),
enrolled_for_3ds: false,
request_incremental_authorization: false,
capture_method: Some(i32::from(capture_method)),
// payment_method_type: Some(i32::from(PaymentMethodType::Credit)),
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_authorize_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_4930655635886646064 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/cryptopay_payment_flows_test.rs
fn create_payment_sync_request(request_ref_id: &str) -> PaymentServiceGetRequest {
PaymentServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id("not_required".to_string())),
}),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(request_ref_id.to_string())),
}),
capture_method: None,
handle_response: None,
amount: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_sync_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-57979169531772516 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/cryptopay_payment_flows_test.rs
async fn test_health() {
grpc_test!(client, HealthClient<Channel>, {
let response = client
.check(Request::new(HealthCheckRequest {
service: "connector_service".to_string(),
}))
.await
.expect("Failed to call health check")
.into_inner();
assert_eq!(
response.status(),
grpc_api_types::health_check::health_check_response::ServingStatus::Serving
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_health",
"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_grpc-server_8114262160946874902 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/cryptopay_payment_flows_test.rs
async fn test_payment_authorization_and_psync() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request
let request = create_authorize_request(CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_cryptopay_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC authorize call failed")
.into_inner();
// Add comprehensive logging for debugging
println!("=== CRYPTOPAY PAYMENT RESPONSE DEBUG ===");
println!("Response: {:#?}", response);
println!("Status: {}", response.status);
println!("Error code: {:?}", response.error_code);
println!("Error message: {:?}", response.error_message);
println!("Status code: {:?}", response.status_code);
println!("=== END DEBUG ===");
// Check for different possible statuses that Cryptopay might return
// Status 21 = Failure, which indicates auth/credential issues
if response.status == 21 {
// This is a failure status - likely auth/credential issues
assert_eq!(response.status, 21, "Expected failure status due to auth issues");
println!("Cryptopay authentication/credential issue detected - test expecting failure");
return; // Exit early since we can't proceed with sync test
}
let acceptable_statuses = [
i32::from(PaymentStatus::AuthenticationPending),
i32::from(PaymentStatus::Pending),
i32::from(PaymentStatus::Charged),
];
assert!(
acceptable_statuses.contains(&response.status),
"Payment should be in AuthenticationPending, Pending, or Charged state, but was: {}",
response.status
);
let request_ref_id = extract_request_ref_id(&response);
// Create sync request
let sync_request = create_payment_sync_request(&request_ref_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_cryptopay_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// Verify the sync response
assert!(
sync_response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AuthenticationPending state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_and_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_grpc-server_8821256745700309602 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
fn get_timestamp() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_timestamp",
"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_grpc-server_5872467265881890296 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
fn add_noon_metadata<T>(request: &mut Request<T>) {
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load noon credentials");
let (api_key, key1, api_secret) = match auth {
domain_types::router_data::ConnectorAuthType::SignatureKey {
api_key,
key1,
api_secret,
} => (api_key.expose(), key1.expose(), api_secret.expose()),
_ => panic!("Expected SignatureKey auth type for noon"),
};
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request
.metadata_mut()
.append("x-auth", AUTH_TYPE.parse().expect("Failed to parse x-auth"));
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
request
.metadata_mut()
.append("x-key1", key1.parse().expect("Failed to parse x-key1"));
// Add merchant ID which is required by the server
request.metadata_mut().append(
"x-merchant-id",
"12abc123-f8a3-99b8-9ef8-b31180358hh4"
.parse()
.expect("Failed to parse x-merchant-id"),
);
request.metadata_mut().append(
"x-api-secret",
api_secret.parse().expect("Failed to parse x-api-secret"),
);
// Add tenant ID which is required by the server
request.metadata_mut().append(
"x-tenant-id",
"default".parse().expect("Failed to parse x-tenant-id"),
);
// Add request ID which is required by the server
request.metadata_mut().append(
"x-request-id",
format!("noon_req_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_noon_metadata",
"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_grpc-server_-146625334556709608 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
fn extract_transaction_id(response: &PaymentServiceAuthorizeResponse) -> String {
match &response.transaction_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector transaction ID"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_transaction_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_7555674274079742481 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
fn extract_request_ref_id(response: &PaymentServiceAuthorizeResponse) -> String {
match &response.response_ref_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector response_ref_id"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_request_ref_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-8164854619557722318 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
fn create_payment_authorize_request(
capture_method: CaptureMethod,
) -> PaymentServiceAuthorizeRequest {
let card_details = card_payment_method_type::CardType::Credit(CardDetails {
card_number: Some(CardNumber::from_str(TEST_CARD_NUMBER).unwrap()),
card_exp_month: Some(Secret::new(TEST_CARD_EXP_MONTH.to_string())),
card_exp_year: Some(Secret::new(TEST_CARD_EXP_YEAR.to_string())),
card_cvc: Some(Secret::new(TEST_CARD_CVC.to_string())),
card_holder_name: Some(Secret::new(TEST_CARD_HOLDER.to_string())),
card_network: Some(1),
card_issuer: None,
card_type: None,
card_issuing_country_alpha2: None,
bank_code: None,
nick_name: None,
});
let mut metadata = HashMap::new();
metadata.insert(
"description".to_string(),
"Its my first payment request".to_string(),
);
PaymentServiceAuthorizeRequest {
amount: TEST_AMOUNT,
minor_amount: TEST_AMOUNT,
currency: i32::from(Currency::Aed),
payment_method: Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType {
card_type: Some(card_details),
})),
}),
return_url: Some("https://duck.com".to_string()),
email: Some(TEST_EMAIL.to_string().into()),
address: Some(grpc_api_types::payments::PaymentAddress::default()),
auth_type: i32::from(AuthenticationType::NoThreeDs),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("noon_test_{}", get_timestamp()))),
}),
enrolled_for_3ds: false,
request_incremental_authorization: false,
capture_method: Some(i32::from(capture_method)),
order_category: Some("PAY".to_string()),
metadata,
// payment_method_type: Some(i32::from(PaymentMethodType::Credit)),
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_authorize_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_8826172285940183611 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
fn create_payment_sync_request(
transaction_id: &str,
request_ref_id: &str,
) -> PaymentServiceGetRequest {
PaymentServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(request_ref_id.to_string())),
}),
// all_keys_required: None,
capture_method: None,
handle_response: None,
amount: TEST_AMOUNT,
currency: i32::from(Currency::Aed),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_sync_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-6457728065766127221 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
fn create_payment_capture_request(transaction_id: &str) -> PaymentServiceCaptureRequest {
PaymentServiceCaptureRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
amount_to_capture: TEST_AMOUNT,
currency: i32::from(Currency::Aed),
multiple_capture_data: None,
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("capture_ref_{}", get_timestamp()))),
}),
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_capture_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_4152489787873224962 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
fn create_payment_void_request(transaction_id: &str) -> PaymentServiceVoidRequest {
PaymentServiceVoidRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
cancellation_reason: None,
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("void_ref_{}", get_timestamp()))),
}),
all_keys_required: None,
browser_info: None,
amount: None,
currency: None,
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_void_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-8629193561626734012 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
fn create_refund_request(transaction_id: &str) -> PaymentServiceRefundRequest {
PaymentServiceRefundRequest {
refund_id: format!("refund_{}", get_timestamp()),
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
currency: i32::from(Currency::Aed),
payment_amount: TEST_AMOUNT,
refund_amount: TEST_AMOUNT,
minor_payment_amount: TEST_AMOUNT,
minor_refund_amount: TEST_AMOUNT,
reason: None,
webhook_url: None,
browser_info: None,
merchant_account_id: None,
capture_method: None,
request_ref_id: None,
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_1791230683314187804 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
fn create_refund_sync_request(transaction_id: &str, refund_id: &str) -> RefundServiceGetRequest {
RefundServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
refund_id: refund_id.to_string(),
refund_reason: None,
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("rsync_ref_{}", get_timestamp()))),
}),
browser_info: None,
refund_metadata: HashMap::new(),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_sync_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-2605752462423009826 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
async fn test_health() {
grpc_test!(client, HealthClient<Channel>, {
let response = client
.check(Request::new(HealthCheckRequest {
service: "connector_service".to_string(),
}))
.await
.expect("Failed to call health check")
.into_inner();
assert_eq!(
response.status(),
grpc_api_types::health_check::health_check_response::ServingStatus::Serving
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_health",
"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_grpc-server_-4719570876155636254 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
async fn test_payment_authorization_auto_capture() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request
let request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_noon_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Verify the response
assert!(
response.transaction_id.is_some(),
"Resource ID should be present"
);
assert!(
response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AuthenticationPending state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_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_grpc-server_9183401992826346460 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
async fn test_payment_authorization_manual_capture() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_noon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
assert!(
auth_response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status is authorized
if auth_response.status == i32::from(PaymentStatus::Authorized) {
// Create capture request
let capture_request = create_payment_capture_request(&transaction_id);
// Add metadata headers for capture request
let mut capture_grpc_request = Request::new(capture_request);
add_noon_metadata(&mut capture_grpc_request);
// Send the capture request
let capture_response = client
.capture(capture_grpc_request)
.await
.expect("gRPC payment_capture call failed")
.into_inner();
// Verify payment status is charged after capture
assert!(
capture_response.status == i32::from(PaymentStatus::Charged),
"Payment should be in CHARGED state after capture"
);
}
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_manual_capture",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_7089941731956718787 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
async fn test_payment_void() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment with manual capture to void
let auth_request = create_payment_authorize_request(CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_noon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Extract the request ref ID
let request_ref_id = extract_request_ref_id(&auth_response);
// After authentication, sync the payment to get updated status
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
let mut sync_grpc_request = Request::new(sync_request);
add_noon_metadata(&mut sync_grpc_request);
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
std::thread::sleep(std::time::Duration::from_secs(1));
// Verify payment status is authorized
if sync_response.status == i32::from(PaymentStatus::Authorized) {
// Create void request with a unique reference ID
let void_request = create_payment_void_request(&transaction_id);
// Add metadata headers for void request
let mut void_grpc_request = Request::new(void_request);
add_noon_metadata(&mut void_grpc_request);
// Send the void request
let void_response = client
.void(void_grpc_request)
.await
.expect("gRPC void_payment call failed")
.into_inner();
// Verify the void response
assert!(
void_response.transaction_id.is_some(),
"Transaction ID should be present in void response"
);
assert!(
void_response.status == i32::from(PaymentStatus::Voided),
"Payment should be in VOIDED state after void"
);
// Verify the payment status with a sync operation
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
let mut sync_grpc_request = Request::new(sync_request);
add_noon_metadata(&mut sync_grpc_request);
// Send the sync request to verify void status
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// Verify the payment is properly voided
assert!(
sync_response.status == i32::from(PaymentStatus::Voided),
"Payment should be in VOIDED state after void sync"
);
}
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_void",
"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_grpc-server_5396101851851836151 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
async fn test_payment_sync() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to sync
let auth_request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_noon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Extract the request ref ID
let request_ref_id = extract_request_ref_id(&auth_response);
// Wait longer for the transaction to be processed - some async processing may happen
std::thread::sleep(std::time::Duration::from_secs(2));
// Create sync request with the specific transaction ID
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_noon_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("Payment sync request failed")
.into_inner();
// Verify the sync response - could be charged, authorized, or pending for automatic capture
assert!(
sync_response.status == i32::from(PaymentStatus::AuthenticationPending)
|| sync_response.status == i32::from(PaymentStatus::Charged),
"Payment should be in AUTHENTICATIONPENDING or CHARGED state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_sync",
"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_grpc-server_9016381403424127332 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
async fn test_refund() {
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment with automatic capture
let auth_request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_noon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Extract the request ref ID
let request_ref_id = extract_request_ref_id(&auth_response);
// Verify payment status is authorized (for manual capture)
assert!(
auth_response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AUTHENTICATIONPENDING state with auto capture"
);
// Create sync request with the specific transaction ID
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_noon_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("Payment sync request failed")
.into_inner();
// Allow more time for the capture to be processed - increase wait time
std::thread::sleep(std::time::Duration::from_secs(1));
if sync_response.status == i32::from(PaymentStatus::Authorized) {
// Create refund request with a unique refund_id that includes timestamp
let refund_request = create_refund_request(&transaction_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_noon_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("Refund request failed")
.into_inner();
// Extract the refund ID
let _refund_id = refund_response.refund_id.clone();
// Verify the refund status
assert!(
refund_response.status == i32::from(RefundStatus::RefundSuccess)
|| refund_response.status == i32::from(RefundStatus::RefundPending),
"Refund should be in SUCCESS or PENDING state"
);
}
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund",
"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_grpc-server_3275927551467653273 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
async fn test_refund_sync() {
grpc_test!(client, PaymentServiceClient<Channel>, {
grpc_test!(refund_client, RefundServiceClient<Channel>, {
// First create a payment with manual capture (same as the script)
let auth_request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_noon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status is authorized (for manual capture)
assert!(
auth_response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AUTHENTICATIONPENDING state with auto capture"
);
// Create refund request
let refund_request = create_refund_request(&transaction_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_noon_metadata(&mut refund_grpc_request);
// Send the refund request and expect a successful response
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
if refund_response.status == i32::from(RefundStatus::RefundSuccess) {
// Extract the request ref ID
let request_ref_id = extract_request_ref_id(&auth_response);
// Allow more time for the refund to be processed
std::thread::sleep(std::time::Duration::from_secs(4));
// Create refund sync request
let refund_sync_request =
create_refund_sync_request(&transaction_id, &request_ref_id);
// Add metadata headers for refund sync request
let mut refund_sync_grpc_request = Request::new(refund_sync_request);
add_noon_metadata(&mut refund_sync_grpc_request);
// Send the refund sync request and expect a successful response
let response = refund_client
.get(refund_sync_grpc_request)
.await
.expect("gRPC refund_sync call failed");
let refund_sync_response = response.into_inner();
// Verify the refund sync status
assert!(
refund_sync_response.status == i32::from(RefundStatus::RefundSuccess)
|| refund_sync_response.status == i32::from(RefundStatus::RefundPending),
"Refund sync should be in SUCCESS or PENDING state"
);
}
});
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund_sync",
"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_grpc-server_-1380551729036978428 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
fn get_timestamp() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_timestamp",
"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_grpc-server_3970691218555679357 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
fn add_bluecode_metadata<T>(request: &mut Request<T>) {
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load bluecode credentials");
let api_key = match auth {
domain_types::router_data::ConnectorAuthType::HeaderKey { api_key } => api_key.expose(),
_ => panic!("Expected HeaderKey auth type for bluecode"),
};
// Get the shop_name from metadata
let metadata = utils::credential_utils::load_connector_metadata(CONNECTOR_NAME)
.expect("Failed to load bluecode metadata");
let shop_name = metadata
.get("shop_name")
.expect("shop_name not found in bluecode metadata")
.clone();
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request.metadata_mut().append(
"x-auth",
"header-key".parse().expect("Failed to parse x-auth"),
);
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
// Add the terminal_id in the metadata JSON
// This metadata must be in the proper format that the connector expects
let metadata_json = format!(r#"{{"shop_name":"{shop_name}"}}"#);
request.metadata_mut().append(
"x-metadata",
metadata_json.parse().expect("Failed to parse x-metadata"),
);
request.metadata_mut().append(
"x-tenant-id",
"default".parse().expect("Failed to parse x-tenant-id"),
);
// Add request ID which is required by the server
request.metadata_mut().append(
"x-request-id",
format!("mifinity_req_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
request.metadata_mut().append(
"x-merchant-id",
"12abc123-f8a3-99b8-9ef8-b31180358hh4"
.parse()
.expect("Failed to parse x-merchant-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_bluecode_metadata",
"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_grpc-server_6336146637317658246 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
fn extract_transaction_id(response: &PaymentServiceAuthorizeResponse) -> String {
match &response.transaction_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector transaction ID"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_transaction_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_3611113021516572301 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
fn generate_unique_request_ref_id(prefix: &str) -> String {
format!(
"{}_{}",
prefix,
&uuid::Uuid::new_v4().simple().to_string()[..8]
)
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_unique_request_ref_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_-9108865463031905054 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
fn generate_unique_email() -> String {
format!("testcustomer{}@gmail.com", get_timestamp())
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_unique_email",
"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_grpc-server_6767914616292971212 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
fn random_name() -> String {
rand::thread_rng()
.sample_iter(&Alphanumeric)
.take(8)
.map(char::from)
.collect()
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "random_name",
"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_grpc-server_-4164371956302311382 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
fn create_payment_authorize_request(
capture_method: common_enums::CaptureMethod,
) -> PaymentServiceAuthorizeRequest {
// Initialize with all required fields
let mut request = PaymentServiceAuthorizeRequest {
payment_method: Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Wallet(
WalletPaymentMethodType {
wallet_type: Some(wallet_payment_method_type::WalletType::Bluecode(
Bluecode {},
)),
},
)),
}),
..Default::default()
};
if let common_enums::CaptureMethod::Manual = capture_method {
request.capture_method = Some(i32::from(CaptureMethod::Manual));
// request.request_incremental_authorization = true;
} else {
request.capture_method = Some(i32::from(CaptureMethod::Automatic));
}
let mut request_ref_id = Identifier::default();
request_ref_id.id_type = Some(IdType::Id(
generate_unique_request_ref_id("req_"), // Using timestamp to make unique
));
request.request_ref_id = Some(request_ref_id);
// Set the basic payment details matching working grpcurl
request.amount = TEST_AMOUNT;
request.minor_amount = TEST_AMOUNT;
request.currency = 146; // Currency value from working grpcurl
request.email = Some(Secret::new(generate_unique_email()));
// Generate random names for billing to prevent duplicate transaction errors
let billing_first_name = random_name();
let billing_last_name = random_name();
// Minimal address structure matching working grpcurl
request.address = Some(PaymentAddress {
billing_address: Some(Address {
first_name: Some(Secret::new(billing_first_name)),
last_name: Some(Secret::new(billing_last_name)),
line1: Some(Secret::new("14 Main Street".to_string())),
line2: None,
line3: None,
city: Some(Secret::new("Pecan Springs".to_string())),
state: Some(Secret::new("TX".to_string())),
zip_code: Some(Secret::new("44628".to_string())),
country_alpha2_code: Some(i32::from(CountryAlpha2::Us)),
phone_number: None,
phone_country_code: None,
email: None,
}),
shipping_address: None, // Minimal address - no shipping for working grpcurl
});
let browser_info = BrowserInformation {
color_depth: None,
java_enabled: Some(false),
screen_height: Some(1080),
screen_width: Some(1920),
user_agent: Some("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)".to_string()),
accept_header: Some(
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8".to_string(),
),
java_script_enabled: Some(false),
language: Some("en-US".to_string()),
ip_address: None,
os_type: None,
os_version: None,
device_model: None,
accept_language: None,
time_zone_offset_minutes: None,
referer: None,
};
request.browser_info = Some(browser_info);
request.return_url = Some("www.google.com".to_string());
// Set the transaction details
request.auth_type = i32::from(AuthenticationType::NoThreeDs);
request.request_incremental_authorization = true;
request.enrolled_for_3ds = true;
// Set capture method
// request.capture_method = Some(i32::from(CaptureMethod::from(capture_method)));
// Get shop_name for metadata
let metadata = utils::credential_utils::load_connector_metadata(CONNECTOR_NAME)
.expect("Failed to load bluecode metadata");
let shop_name = metadata
.get("shop_name")
.expect("shop_name not found in bluecode metadata")
.clone();
// Create connector metadata as a proper JSON object
let mut connector_metadata = HashMap::new();
connector_metadata.insert("shop_name".to_string(), shop_name);
let connector_metadata_json =
serde_json::to_string(&connector_metadata).expect("Failed to serialize connector metadata");
let mut metadata = HashMap::new();
metadata.insert("connector_meta_data".to_string(), connector_metadata_json);
request.metadata = metadata;
request
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_authorize_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_fn_grpc-server_2312538677176562114 | clm | function | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
fn create_payment_sync_request(transaction_id: &str) -> PaymentServiceGetRequest {
PaymentServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("fiserv_sync_{}", get_timestamp()))),
}),
capture_method: None,
handle_response: None,
// all_keys_required: None,
amount: TEST_AMOUNT,
currency: 146, // Currency value from working grpcurl
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_sync_request",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.