id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
connector-service_body_grpc-server_-2778220097495755406
clm
function_body
// connector-service/backend/grpc-server/tests/fiuu_payment_flows_test.rs // Function: test_payment_authorization_manual_capture { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request with manual capture let auth_request = create_authorize_request(CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_fiuu_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC authorize call failed") .into_inner(); // Verify payment status assert!( auth_response.status == i32::from(PaymentStatus::Authorized), "Payment should be in Authorized state" ); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Add delay of 15 seconds tokio::time::sleep(std::time::Duration::from_secs(15)).await; // Create capture request let capture_request = create_payment_capture_request(&transaction_id); // Add metadata headers for capture request - make sure they include the terminal_id let mut capture_grpc_request = Request::new(capture_request); add_fiuu_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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_6079675630656059394
clm
function_body
// connector-service/backend/grpc-server/tests/fiuu_payment_flows_test.rs // Function: test_payment_sync_auto_capture { 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_fiuu_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); // Add delay of 10 seconds tokio::time::sleep(std::time::Duration::from_secs(10)).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_fiuu_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::Charged), "Payment should be in Charged state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_sync_auto_capture", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_2892820045989304020
clm
function_body
// connector-service/backend/grpc-server/tests/fiuu_payment_flows_test.rs // Function: test_refund { 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_fiuu_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); assert!( response.status == i32::from(PaymentStatus::Charged), "Payment should be in Charged state" ); // Wait a bit longer to ensure the payment is fully processed tokio::time::sleep(tokio::time::Duration::from_secs(12)).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_fiuu_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::RefundPending), "Refund should be in RefundPending state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_refund", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-8973434425799922017
clm
function_body
// connector-service/backend/grpc-server/tests/fiuu_payment_flows_test.rs // Function: test_refund_sync { grpc_test!(client, PaymentServiceClient<Channel>, { grpc_test!(refund_client, RefundServiceClient<Channel>, { // Create the payment authorization request let request = create_authorize_request(CaptureMethod::Automatic); // Add metadata headers let mut grpc_request = Request::new(request); add_fiuu_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); assert!( response.status == i32::from(PaymentStatus::Charged), "Payment should be in Charged state" ); // 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_fiuu_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::RefundPending), "Refund should be in RefundPending state" ); let refund_id = extract_refund_id(&refund_response); // Wait a bit longer to ensure the refund is fully processed std::thread::sleep(std::time::Duration::from_secs(30)); // 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_fiuu_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(); let is_valid_status = refund_sync_response.status == i32::from(RefundStatus::RefundPending) || refund_sync_response.status == i32::from(RefundStatus::RefundSuccess); assert!( is_valid_status, "Refund Sync should be in RefundPending or RefundSuccess state, got: {:?}", refund_sync_response.status ); }); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_refund_sync", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7430045541324335989
clm
function_body
// connector-service/backend/grpc-server/tests/fiuu_payment_flows_test.rs // Function: test_payment_void { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment with manual capture to void let auth_request = create_authorize_request(CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_fiuu_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 assert!( auth_response.status == i32::from(PaymentStatus::Authorized), "Payment should be in AUTHORIZED state before voiding" ); // Wait a bit longer to ensure the payment is fully processed std::thread::sleep(std::time::Duration::from_secs(12)); // 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_fiuu_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); let mut sync_grpc_request = Request::new(sync_request); add_fiuu_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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_8869138092229140600
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: get_unique_amount { // Use timestamp to create unique amounts between 1000-9999 cents ($10-$99.99) let timestamp = get_timestamp(); 1000 + i64::try_from(timestamp % 9000).unwrap_or(0) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_unique_amount", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-3757312685734316287
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: get_timestamp { SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_micros() .try_into() .unwrap_or(0) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_timestamp", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_2364100941022741392
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: add_helcim_metadata { let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load helcim credentials"); let api_key = match auth { domain_types::router_data::ConnectorAuthType::HeaderKey { api_key } => api_key.expose(), _ => panic!("Expected HeaderKey auth type for helcim"), }; 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"), ); // 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-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!("helcim_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_helcim_metadata", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4778332273903388137
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: extract_transaction_id { match &response.transaction_id { Some(id) => match &id.id_type { Some(IdType::Id(id)) => id.clone(), Some(IdType::EncodedData(id)) => id.clone(), Some(IdType::NoResponseIdMarker(_)) => { // For manual capture, extract the transaction ID from connector metadata if let Some(preauth_id) = response.connector_metadata.get("preauth_transaction_id") { return preauth_id.clone(); } panic!( "NoResponseIdMarker found but no preauth_transaction_id in connector metadata" ) } None => panic!("ID type is None in transaction_id"), }, None => panic!("Transaction ID is None"), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_transaction_id", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_3977945194282040687
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: extract_void_transaction_id { match &response.transaction_id { Some(id) => match &id.id_type { Some(IdType::Id(id)) => id.clone(), Some(IdType::EncodedData(id)) => id.clone(), Some(_) => panic!("Unexpected ID type in transaction_id"), None => panic!("ID type is None in transaction_id"), }, None => panic!("Transaction ID is None"), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_void_transaction_id", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_6841459307596222381
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: extract_request_ref_id { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4903993162695845931
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: create_test_browser_info { BrowserInformation { ip_address: Some("192.168.1.1".to_string()), user_agent: Some( "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36".to_string(), ), accept_header: Some( "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8".to_string(), ), language: Some("en-US".to_string()), color_depth: Some(24), screen_height: Some(1080), screen_width: Some(1920), time_zone_offset_minutes: Some(-300), // EST timezone offset java_enabled: Some(false), java_script_enabled: Some(true), referer: Some("https://example.com".to_string()), os_type: None, os_version: None, device_model: None, accept_language: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_test_browser_info", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_968571892235783847
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: create_test_billing_address { let timestamp = get_timestamp(); let unique_suffix = timestamp % 10000; PaymentAddress { shipping_address: Some(Address::default()), billing_address: Some(Address { first_name: Some("John".to_string().into()), last_name: Some("Doe".to_string().into()), phone_number: Some(format!("123456{unique_suffix:04}").into()), phone_country_code: Some("+1".to_string()), email: Some(format!("customer{unique_suffix}@example.com").into()), line1: Some(format!("{} Main St", 100 + unique_suffix).into()), line2: Some("Apt 4B".to_string().into()), line3: None, city: Some("New York".to_string().into()), state: Some("NY".to_string().into()), zip_code: Some(format!("{:05}", 10001 + (unique_suffix % 1000)).into()), country_alpha2_code: Some(CountryAlpha2::Us.into()), }), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_test_billing_address", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_4943138860847632817
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: create_payment_authorize_request_with_amount { 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, minor_amount: amount, currency: i32::from(Currency::Usd), 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(create_test_billing_address()), browser_info: Some(create_test_browser_info()), auth_type: i32::from(AuthenticationType::NoThreeDs), request_ref_id: Some(Identifier { id_type: Some(IdType::Id(format!("helcim_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_with_amount", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7382401364245253087
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: create_payment_sync_request { 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())), }), capture_method: None, handle_response: None, 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_6853123886252945043
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: create_payment_capture_request { PaymentServiceCaptureRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), amount_to_capture: amount, currency: i32::from(Currency::Usd), multiple_capture_data: None, request_ref_id: Some(Identifier { id_type: Some(IdType::Id(format!("capture_ref_{}", get_timestamp()))), }), browser_info: Some(create_test_browser_info()), ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_capture_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-3734385768345427032
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: create_payment_void_request { 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: Some(create_test_browser_info()), 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_821249874612333296
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_6528572516319153388
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: 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_helcim_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::Charged), "Payment should be in Charged state. Got status: {}, error_code: {:?}, error_message: {:?}", response.status, response.error_code, response.error_message ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authorization_auto_capture", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4049281139239586039
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: test_payment_authorization_manual_capture { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request with manual capture let unique_amount = get_unique_amount(); let auth_request = create_payment_authorize_request_with_amount(CaptureMethod::Manual, unique_amount); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_helcim_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, unique_amount); // Add metadata headers for capture request let mut capture_grpc_request = Request::new(capture_request); add_helcim_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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7767910100035517796
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: 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.clone()); add_helcim_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, auth_request.amount); let mut sync_grpc_request = Request::new(sync_request); add_helcim_metadata(&mut sync_grpc_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_helcim_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" ); // Extract the void transaction ID from the void response let void_transaction_id = extract_void_transaction_id(&void_response); // Verify the payment status with a sync operation using the void transaction ID let sync_request = create_payment_sync_request(&void_transaction_id, &request_ref_id, auth_request.amount); let mut sync_grpc_request = Request::new(sync_request); add_helcim_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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1894583929213168326
clm
function_body
// connector-service/backend/grpc-server/tests/helcim_payment_flows_test.rs // Function: 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.clone()); add_helcim_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, auth_request.amount); // Add metadata headers for sync request let mut sync_grpc_request = Request::new(sync_request); add_helcim_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::Charged), "Payment should be in CHARGED state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_sync", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_4387876469778041233
clm
function_body
// connector-service/backend/grpc-server/tests/test_health.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4504005984927142431
clm
function_body
// connector-service/backend/grpc-server/tests/cashtocode_payment_flows_test.rs // Function: add_cashtocode_metadata { let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load cashtocode credentials"); let auth_key_map = match auth { domain_types::router_data::ConnectorAuthType::CurrencyAuthKey { auth_key_map } => { auth_key_map } _ => panic!("Expected CurrencyAuthKey auth type for cashtocode"), }; // Serialize the auth_key_map to JSON for metadata let auth_key_map_json = serde_json::to_string(&auth_key_map).expect("Failed to serialize auth_key_map"); 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-auth-key-map", auth_key_map_json .parse() .expect("Failed to parse x-auth-key-map"), ); 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_cashtocode_metadata", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-5749778536867375453
clm
function_body
// connector-service/backend/grpc-server/tests/cashtocode_payment_flows_test.rs // Function: create_authorize_request { PaymentServiceAuthorizeRequest { amount: TEST_AMOUNT, minor_amount: TEST_AMOUNT, currency: i32::from(Currency::Eur), payment_method: Some(PaymentMethod { payment_method: Some(payment_method::PaymentMethod::Reward( RewardPaymentMethodType { reward_type: i32::from(RewardType::Classicreward), }, )), }), customer_id: Some("cust_1233".to_string()), return_url: Some("https://hyperswitch.io/connector-service".to_string()), webhook_url: Some("https://hyperswitch.io/connector-service".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!("cashtocode_test_{}", get_timestamp()))), }), enrolled_for_3ds: false, request_incremental_authorization: false, capture_method: Some(i32::from(capture_method)), ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_authorize_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-505470372427150651
clm
function_body
// connector-service/backend/grpc-server/tests/cashtocode_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-5207450738205396407
clm
function_body
// connector-service/backend/grpc-server/tests/cashtocode_payment_flows_test.rs // Function: test_payment_authorization { 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_cashtocode_metadata(&mut grpc_request); // Send the request let response = client .authorize(grpc_request) .await .expect("gRPC authorize call failed") .into_inner(); 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", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4368250539696784748
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: add_braintree_metadata { let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load braintree 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 braintree"), }; 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-api-secret", api_secret.parse().expect("Failed to parse x-api-secret"), ); 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"), ); request.metadata_mut().append( "x-tenant-id", "default".parse().expect("Failed to parse x-tenant-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_braintree_metadata", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_5249163666486775378
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: extract_transaction_id { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-1649111988899586318
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: create_payment_authorize_request { 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("merchant_account_id".to_string(), "Anand".to_string()); PaymentServiceAuthorizeRequest { amount: TEST_AMOUNT, minor_amount: TEST_AMOUNT, currency: i32::from(Currency::Usd), 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!("braintree_test_{}", get_timestamp()))), }), enrolled_for_3ds: false, request_incremental_authorization: false, capture_method: Some(i32::from(capture_method)), 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_2023236060927742104
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: create_payment_sync_request { PaymentServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), request_ref_id: None, // all_keys_required: None, 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-609664495611935462
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: create_payment_capture_request { 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, request_ref_id: None, ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_capture_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-242040733824587851
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: create_payment_void_request { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-9098000203727082743
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: create_refund_request { 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, browser_info: None, merchant_account_id: Some("Anand".to_string()), 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1568689912034477787
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: create_refund_sync_request { let mut refund_metadata = HashMap::new(); refund_metadata.insert("merchant_account_id".to_string(), "Anand".to_string()); refund_metadata.insert("merchant_config_currency".to_string(), "USD".to_string()); refund_metadata.insert("currency".to_string(), "USD".to_string()); 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, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_sync_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-9021531817992655649
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-7172641667460322615
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: 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_braintree_metadata(&mut grpc_request); // Send the request let response = client .authorize(grpc_request) .await .expect("gRPC authorize call failed") .into_inner(); 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 or Charged state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authorization_auto_capture", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4410504444598460233
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: test_payment_authorization_manual_capture { grpc_test!(client, PaymentServiceClient<Channel>, { // Add delay of 4 seconds tokio::time::sleep(std::time::Duration::from_secs(4)).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_braintree_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC authorize call failed") .into_inner(); // Verify payment status assert!( auth_response.status == i32::from(PaymentStatus::AuthenticationPending) || auth_response.status == i32::from(PaymentStatus::Pending) || auth_response.status == i32::from(PaymentStatus::Authorized), "Payment should be in AuthenticationPending or Pending state" ); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Create capture request let capture_request = create_payment_capture_request(&transaction_id); // Add metadata headers for capture request - make sure they include the terminal_id let mut capture_grpc_request = Request::new(capture_request); add_braintree_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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_287231178100684068
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: test_payment_sync_auto_capture { grpc_test!(client, PaymentServiceClient<Channel>, { // Add delay of 8 seconds tokio::time::sleep(std::time::Duration::from_secs(8)).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_braintree_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); // 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_braintree_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::Charged), "Payment should be in Charged state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_sync_auto_capture", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-8798869488969441409
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: test_payment_void { grpc_test!(client, PaymentServiceClient<Channel>, { // Add delay of 12 seconds tokio::time::sleep(std::time::Duration::from_secs(12)).await; // 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_braintree_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 assert!( auth_response.status == i32::from(PaymentStatus::Authorized), "Payment should be in AUTHORIZED state before voiding" ); // 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_braintree_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.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); let mut sync_grpc_request = Request::new(sync_request); add_braintree_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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1514822121782666536
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: test_refund { grpc_test!(client, PaymentServiceClient<Channel>, { // Add delay of 16 seconds tokio::time::sleep(std::time::Duration::from_secs(16)).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_braintree_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); assert!( response.status == i32::from(PaymentStatus::Charged), "Payment should be in Charged state" ); // 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_braintree_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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_209798851592180554
clm
function_body
// connector-service/backend/grpc-server/tests/braintree_payment_flows_test.rs // Function: test_refund_sync { grpc_test!(client, PaymentServiceClient<Channel>, { grpc_test!(refund_client, RefundServiceClient<Channel>, { // Add delay of 20 seconds tokio::time::sleep(std::time::Duration::from_secs(20)).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_braintree_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); assert!( response.status == i32::from(PaymentStatus::Charged), "Payment should be in Charged state" ); // 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_braintree_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); // 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_braintree_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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-5308355380939708741
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: add_payload_metadata { // Get API credentials using the common credential loading utility let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load Payload credentials"); let auth_key_map_json = match auth { domain_types::router_data::ConnectorAuthType::CurrencyAuthKey { auth_key_map } => { // Convert the auth_key_map to JSON string format expected by the metadata serde_json::to_string(&auth_key_map).expect("Failed to serialize auth_key_map") } _ => panic!("Expected CurrencyAuthKey auth type for Payload"), }; 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-auth-key-map", auth_key_map_json .parse() .expect("Failed to parse x-auth-key-map"), ); 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_payload_metadata", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_3213325258493535314
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: create_authorize_request { 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), card_type: None, card_issuing_country_alpha2: None, bank_code: None, nick_name: None, }); // Generate random billing address to avoid duplicates let mut rng = rand::thread_rng(); let random_street_num = rng.gen_range(100..9999); let random_zip_suffix = rng.gen_range(1000..9999); let address = PaymentAddress { billing_address: Some(Address { first_name: Some("John".to_string().into()), last_name: Some("Doe".to_string().into()), email: Some(TEST_EMAIL.to_string().into()), line1: Some(format!("{} Main St", random_street_num).into()), city: Some("San Francisco".to_string().into()), state: Some("CA".to_string().into()), zip_code: Some(format!("{}", random_zip_suffix).into()), country_alpha2_code: Some(i32::from(CountryAlpha2::Us)), ..Default::default() }), shipping_address: None, }; // Use random amount to avoid duplicates let mut rng = rand::thread_rng(); let unique_amount = rng.gen_range(1000..10000); // Amount between $10.00 and $100.00 PaymentServiceAuthorizeRequest { amount: unique_amount, minor_amount: unique_amount, currency: i32::from(Currency::Usd), payment_method: Some(PaymentMethod { payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType { card_type: Some(card_details), })), }), return_url: Some("https://example.com/return".to_string()), webhook_url: Some("https://example.com/webhook".to_string()), email: Some(TEST_EMAIL.to_string().into()), address: Some(address), auth_type: i32::from(AuthenticationType::NoThreeDs), request_ref_id: Some(Identifier { id_type: Some(IdType::Id(generate_unique_id("payload_test"))), }), enrolled_for_3ds: false, request_incremental_authorization: false, capture_method: Some(i32::from(capture_method)), ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_authorize_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-8384514553253328096
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: create_payment_sync_request { PaymentServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), request_ref_id: Some(Identifier { id_type: Some(IdType::Id(generate_unique_id("payload_sync"))), }), capture_method: None, handle_response: None, 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-8172667606684087738
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: create_payment_capture_request { PaymentServiceCaptureRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), amount_to_capture: amount, currency: i32::from(Currency::Usd), multiple_capture_data: None, request_ref_id: None, ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_capture_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-58588040400506970
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: create_payment_void_request { 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(generate_unique_id("payload_void"))), }), all_keys_required: None, browser_info: None, amount: Some(amount), currency: Some(i32::from(Currency::Usd)), ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_void_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-6115906042004846694
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: create_refund_request { PaymentServiceRefundRequest { request_ref_id: Some(Identifier { id_type: Some(IdType::Id(generate_unique_id("refund"))), }), transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), currency: i32::from(Currency::Usd), payment_amount: amount, refund_amount: amount, minor_payment_amount: amount, minor_refund_amount: amount, ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-1133314818626867876
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: extract_transaction_id { response .transaction_id .as_ref() .and_then(|id| id.id_type.as_ref()) .and_then(|id_type| match id_type { IdType::Id(connector_txn_id) => Some(connector_txn_id.clone()), _ => None, }) .expect("Failed to extract connector transaction ID from response") }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_transaction_id", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-7745852985257694433
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: create_repeat_payment_request { // Use random amount to avoid duplicates let mut rng = rand::thread_rng(); let unique_amount = rng.gen_range(1000..10000); // Amount between $10.00 and $100.00 let mandate_reference = MandateReference { mandate_id: Some(mandate_id.to_string()), payment_method_id: None, }; let mut metadata = HashMap::new(); metadata.insert("order_type".to_string(), "recurring".to_string()); metadata.insert( "customer_note".to_string(), "Recurring payment using saved payment method".to_string(), ); PaymentServiceRepeatEverythingRequest { request_ref_id: Some(Identifier { id_type: Some(IdType::Id(generate_unique_id("repeat"))), }), mandate_reference: Some(mandate_reference), amount: unique_amount, currency: i32::from(Currency::Usd), minor_amount: unique_amount, merchant_order_reference_id: Some(generate_unique_id("repeat_order")), metadata, webhook_url: None, capture_method: None, email: Some(Secret::new(TEST_EMAIL.to_string())), 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_8924417070030496974
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: create_register_request_with_prefix { 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), card_type: None, card_issuing_country_alpha2: None, bank_code: None, nick_name: None, }); // Use random values to create unique data to avoid duplicate detection let mut rng = rand::thread_rng(); let random_street_num = rng.gen_range(1000..9999); let unique_zip = format!("{}", rng.gen_range(10000..99999)); let random_id = rng.gen_range(1000..9999); let unique_email = format!("customer{}@example.com", random_id); let unique_first_name = format!("John{}", random_id); PaymentServiceRegisterRequest { minor_amount: Some(0), // Setup mandate with 0 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(format!("{} Doe", unique_first_name)), email: Some(unique_email.clone().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(unique_first_name.into()), last_name: Some("Doe".to_string().into()), line1: Some(format!("{} Market St", random_street_num).into()), line2: None, line3: None, city: Some("San Francisco".to_string().into()), state: Some("CA".to_string().into()), zip_code: Some(unique_zip.into()), country_alpha2_code: Some(i32::from(CountryAlpha2::Us)), phone_number: None, phone_country_code: None, email: Some(unique_email.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(generate_unique_id(prefix))), }), metadata: HashMap::new(), ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_register_request_with_prefix", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_5691341204548716063
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: 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, "Health check should return Serving status" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_health", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-3992119848846219218
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: test_authorize_psync_void { grpc_test!(client, PaymentServiceClient<Channel>, { // Wait 30 seconds before making API call to avoid parallel test conflicts tokio::time::sleep(tokio::time::Duration::from_secs(30)).await; // Step 1: Authorize with manual capture let request = create_authorize_request(CaptureMethod::Manual); let amount = request.minor_amount; // Capture amount from request let mut grpc_request = Request::new(request); add_payload_metadata(&mut grpc_request); let auth_response = client .authorize(grpc_request) .await .expect("gRPC authorize call failed") .into_inner(); let transaction_id = extract_transaction_id(&auth_response); assert_eq!( auth_response.status, i32::from(PaymentStatus::Authorized), "Payment should be in Authorized state" ); // Step 2: PSync let sync_request = create_payment_sync_request(&transaction_id, amount); let mut sync_grpc_request = Request::new(sync_request); add_payload_metadata(&mut sync_grpc_request); let sync_response = client .get(sync_grpc_request) .await .expect("gRPC sync call failed") .into_inner(); assert!( sync_response.transaction_id.is_some(), "Sync response should contain transaction ID" ); // Step 3: Void let void_request = create_payment_void_request(&transaction_id, amount); let mut void_grpc_request = Request::new(void_request); add_payload_metadata(&mut void_grpc_request); let void_response = client .void(void_grpc_request) .await .expect("gRPC void call failed") .into_inner(); assert_eq!( 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_authorize_psync_void", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1450055329780156559
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: test_authorize_capture_refund_rsync { grpc_test!(client, PaymentServiceClient<Channel>, { // Wait 30 seconds before making API call to avoid parallel test conflicts tokio::time::sleep(tokio::time::Duration::from_secs(30)).await; // Step 1: Authorize with manual capture let request = create_authorize_request(CaptureMethod::Manual); let amount = request.minor_amount; // Capture amount from request let mut grpc_request = Request::new(request); add_payload_metadata(&mut grpc_request); let auth_response = client .authorize(grpc_request) .await .expect("gRPC authorize call failed") .into_inner(); let transaction_id = extract_transaction_id(&auth_response); assert_eq!( auth_response.status, i32::from(PaymentStatus::Authorized), "Payment should be in Authorized state" ); // Step 2: Capture let capture_request = create_payment_capture_request(&transaction_id, amount); let mut capture_grpc_request = Request::new(capture_request); add_payload_metadata(&mut capture_grpc_request); let capture_response = client .capture(capture_grpc_request) .await .expect("gRPC capture call failed") .into_inner(); assert_eq!( capture_response.status, i32::from(PaymentStatus::Charged), "Payment should be in Charged state after capture" ); // Step 3: Refund let refund_request = create_refund_request(&transaction_id, amount); let mut refund_grpc_request = Request::new(refund_request); add_payload_metadata(&mut refund_grpc_request); let refund_response = client .refund(refund_grpc_request) .await .expect("gRPC refund call failed") .into_inner(); let refund_id = refund_response.refund_id.clone(); assert!( refund_response.status == i32::from(RefundStatus::RefundSuccess) || refund_response.status == i32::from(RefundStatus::RefundPending), "Refund should be in RefundSuccess or RefundPending state" ); // Step 4: RSync (Refund Sync) let rsync_request = PaymentServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(refund_id)), }), request_ref_id: Some(Identifier { id_type: Some(IdType::Id(generate_unique_id("payload_rsync"))), }), capture_method: None, handle_response: None, amount, currency: i32::from(Currency::Usd), state: None, }; let mut rsync_grpc_request = Request::new(rsync_request); add_payload_metadata(&mut rsync_grpc_request); let rsync_response = client .get(rsync_grpc_request) .await .expect("gRPC refund sync call failed") .into_inner(); assert!( rsync_response.transaction_id.is_some(), "Refund sync response should contain transaction ID" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_authorize_capture_refund_rsync", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-533467600418922472
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: test_setup_mandate { grpc_test!(client, PaymentServiceClient<Channel>, { // Wait 30 seconds before making API call to avoid parallel test conflicts tokio::time::sleep(tokio::time::Duration::from_secs(30)).await; // Create setup mandate request (zero amount payment to save card) let request = create_register_request(); let mut grpc_request = Request::new(request); add_payload_metadata(&mut grpc_request); let response = client .register(grpc_request) .await .expect("gRPC register call failed") .into_inner(); // Verify we got a mandate reference assert!( response.mandate_reference.is_some(), "Mandate reference should be present" ); if let Some(mandate_ref) = &response.mandate_reference { assert!( mandate_ref.mandate_id.is_some() || mandate_ref.payment_method_id.is_some(), "Mandate ID or payment method ID should be present" ); if let Some(mandate_id) = &mandate_ref.mandate_id { assert!(!mandate_id.is_empty(), "Mandate ID should not be empty"); } if let Some(pm_id) = &mandate_ref.payment_method_id { assert!(!pm_id.is_empty(), "Payment method ID should not be empty"); } } // Verify status is success assert_eq!( response.status, i32::from(PaymentStatus::Charged), "Setup mandate should be in Charged/Success state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_setup_mandate", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_6290436363109343272
clm
function_body
// connector-service/backend/grpc-server/tests/payload_payment_flows_test.rs // Function: test_repeat_payment { grpc_test!(client, PaymentServiceClient<Channel>, { // NOTE: This test may fail with "duplicate transaction" error if run too soon // after other tests that use the same test card. Payload has duplicate detection. tokio::time::sleep(tokio::time::Duration::from_secs(60)).await; let register_request = create_register_request_with_prefix("payload_repeat_test"); let mut register_grpc_request = Request::new(register_request); add_payload_metadata(&mut register_grpc_request); let register_response = client .register(register_grpc_request) .await .expect("gRPC register call failed") .into_inner(); if register_response.mandate_reference.is_none() { panic!( "Mandate reference should be present. Status: {}, Error: {:?}", register_response.status, register_response.error_message ); } let mandate_ref = register_response .mandate_reference .as_ref() .expect("Mandate reference should be present"); let mandate_id = mandate_ref .mandate_id .as_ref() .expect("mandate_id should be present"); tokio::time::sleep(tokio::time::Duration::from_secs(2)).await; let repeat_request = create_repeat_payment_request(mandate_id); let mut repeat_grpc_request = Request::new(repeat_request); add_payload_metadata(&mut repeat_grpc_request); let repeat_response = client .repeat_everything(repeat_grpc_request) .await .expect("gRPC repeat_everything call failed") .into_inner(); assert!( repeat_response.transaction_id.is_some(), "Transaction ID should be present in repeat payment response" ); assert_eq!( repeat_response.status, i32::from(PaymentStatus::Charged), "Repeat payment should be in Charged state with automatic capture" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_repeat_payment", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_3275951328017121463
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: random_name { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4239063805288451782
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: add_authorizenet_metadata { // Get API credentials using the common credential loading utility let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load Authorize.Net 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 Authorize.Net"), }; 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")); // Add merchant ID which is required by the server request.metadata_mut().append( "x-merchant-id", "test_merchant" .parse() .expect("Failed to parse x-merchant-id"), ); // 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", generate_unique_request_ref_id("req") .parse() .expect("Failed to parse x-request-id"), ); // Add connector request reference ID which is required for our error handling request.metadata_mut().append( "x-connector-request-reference-id", generate_unique_request_ref_id("conn_ref") .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_authorizenet_metadata", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_2377990255254815187
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: extract_transaction_id { // First try to get the transaction ID from transaction_id field match &response.transaction_id { Some(id) => match &id.id_type { Some(id_type) => match id_type { IdType::Id(id) => id.clone(), IdType::EncodedData(id) => id.clone(), _ => format!("unknown_id_type_{}", get_timestamp()), }, None => format!("no_id_type_{}", get_timestamp()), }, None => { // Fallback to response_ref_id if transaction_id is not available if let Some(ref_id) = &response.response_ref_id { match &ref_id.id_type { Some(id_type) => match id_type { IdType::Id(id) => id.clone(), IdType::EncodedData(id) => id.clone(), _ => format!("unknown_ref_id_{}", get_timestamp()), }, None => format!("no_ref_id_type_{}", get_timestamp()), } } else { format!("no_transaction_id_{}", get_timestamp()) } } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_transaction_id", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7059764065886482740
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: create_repeat_payment_request { let request_ref_id = Identifier { id_type: Some(IdType::Id(generate_unique_request_ref_id("repeat_req"))), }; 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(request_ref_id), mandate_reference: Some(mandate_reference), amount: REPEAT_AMOUNT, currency: i32::from(Currency::Usd), minor_amount: REPEAT_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, recurring_mandate_payment_data: None, address: None, connector_customer_id: None, description: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-3595823742652080262
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: test_repeat_everything { grpc_test!(client, PaymentServiceClient<Channel>, { // First, create a mandate using register let register_request = create_register_request(); let mut register_grpc_request = Request::new(register_request); add_authorizenet_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_authorizenet_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" ); // // Verify no error occurred // assert!( // repeat_response.error_message.is_none() // || repeat_response.error_message.as_ref().unwrap().is_empty(), // "No error message should be present for successful repeat payment" // ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_repeat_everything", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1324472180373773573
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: create_payment_authorize_request { // Initialize with all required fields let mut request = PaymentServiceAuthorizeRequest::default(); 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 // 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(2_i32), // Mastercard network for 5123456789012346 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), })), }); request.customer_id = Some("TEST_CONNECTOR".to_string()); // Set the customer information with unique email request.email = Some(generate_unique_email().into()); // 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(billing_first_name.into()), last_name: Some(billing_last_name.into()), line1: Some("14 Main Street".to_string().into()), line2: None, line3: None, city: Some("Pecan Springs".to_string().into()), state: Some("TX".to_string().into()), zip_code: Some("44628".to_string().into()), 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()), referer: None, ip_address: None, os_type: None, os_version: None, device_model: None, accept_language: None, time_zone_offset_minutes: 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 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)); } // Set the connector metadata (Base64 encoded) let mut metadata = HashMap::new(); metadata.insert("metadata".to_string(), BASE64_METADATA.to_string()); 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-8872882326157319567
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: create_payment_get_request { let transaction_id_obj = Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }; let request_ref_id = Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }; PaymentServiceGetRequest { transaction_id: Some(transaction_id_obj), request_ref_id: Some(request_ref_id), capture_method: None, handle_response: 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_get_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-6510962970468929658
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: create_payment_capture_request { let request_ref_id = Identifier { id_type: Some(IdType::Id(generate_unique_request_ref_id("capture"))), }; let transaction_id_obj = Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }; PaymentServiceCaptureRequest { request_ref_id: Some(request_ref_id), transaction_id: Some(transaction_id_obj), amount_to_capture: TEST_AMOUNT, currency: i32::from(Currency::Usd), multiple_capture_data: None, connector_metadata: HashMap::new(), 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7619705771293709973
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: create_void_request { let request_ref_id = Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }; let transaction_id_obj = Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }; PaymentServiceVoidRequest { transaction_id: Some(transaction_id_obj), request_ref_id: Some(request_ref_id), cancellation_reason: 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_void_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-5521100604812588834
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: create_refund_request { let request_ref_id = Identifier { id_type: Some(IdType::Id(generate_unique_request_ref_id("refund"))), }; let transaction_id_obj = Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }; // Create refund metadata with credit card information as required by Authorize.net let mut refund_metadata = HashMap::new(); refund_metadata.insert( "refund_metadata".to_string(), format!( "{{\"creditCard\":{{\"cardNumber\":\"{TEST_CARD_NUMBER}\",\"expirationDate\":\"2025-12\"}}}}", ), ); PaymentServiceRefundRequest { request_ref_id: Some(request_ref_id), refund_id: generate_unique_request_ref_id("refund_id"), transaction_id: Some(transaction_id_obj), currency: i32::from(Currency::Usd), payment_amount: TEST_AMOUNT, refund_amount: TEST_AMOUNT, minor_payment_amount: TEST_AMOUNT, minor_refund_amount: TEST_AMOUNT, reason: Some("Test refund".to_string()), webhook_url: None, merchant_account_id: None, capture_method: None, metadata: HashMap::new(), refund_metadata, browser_info: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7813245277961446165
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: create_refund_get_request { let request_ref_id = Identifier { id_type: Some(IdType::Id(generate_unique_request_ref_id("refund_get"))), }; let transaction_id_obj = Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }; RefundServiceGetRequest { request_ref_id: Some(request_ref_id), transaction_id: Some(transaction_id_obj), refund_id: refund_id.to_string(), browser_info: None, refund_reason: 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_get_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4308252892202445748
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: create_register_request { let mut request = PaymentServiceRegisterRequest::default(); // Set amounts matching your JSON (3000 minor units) request.minor_amount = Some(TEST_AMOUNT); request.currency = i32::from(Currency::Usd); // Set up card payment method with Visa network as in your JSON 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), 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 customer information with unique email request.customer_name = Some(TEST_CARD_HOLDER.to_string()); request.email = Some(generate_unique_email().into()); // Add customer acceptance as required by the server (matching your JSON: "acceptance_type": "OFFLINE") request.customer_acceptance = Some(CustomerAcceptance { acceptance_type: i32::from(AcceptanceType::Offline), accepted_at: 0, // You can set this to current timestamp if needed online_mandate_details: None, }); // Add billing address matching your JSON format request.address = Some(PaymentAddress { billing_address: Some(Address { first_name: Some("Test".to_string().into()), last_name: Some("Customer001".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(generate_unique_email().into()), }), shipping_address: None, }); // Set auth type as NO_THREE_DS request.auth_type = i32::from(AuthenticationType::NoThreeDs); // Set setup_future_usage to OFF_SESSION (matching your JSON: "setup_future_usage": "OFF_SESSION") request.setup_future_usage = Some(i32::from(FutureUsage::OffSession)); // Set 3DS enrollment to false request.enrolled_for_3ds = false; // Set request reference ID with unique UUID (this will be unique every time) request.request_ref_id = Some(Identifier { id_type: Some(IdType::Id(generate_unique_request_ref_id("mandate"))), }); // Set empty connector metadata request.metadata = HashMap::new(); request }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_register_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-5742062467992903009
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-531385689864037627
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: 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); // println!("Auth request for auto capture: {:?}", request); // Add metadata headers let mut grpc_request = Request::new(request); add_authorizenet_metadata(&mut grpc_request); // Send the request let response = client .authorize(grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // println!("Payment authorize response for auto: {:?}", response); // Verify the response - transaction_id may not be present for failed or pending payments let successful_statuses = [ i32::from(PaymentStatus::Charged), i32::from(PaymentStatus::Authorized), ]; if successful_statuses.contains(&response.status) { assert!( response.transaction_id.is_some(), "Transaction ID should be present for successful payments, but status was: {}", response.status ); } // Extract the transaction ID let _transaction_id = extract_transaction_id(&response); // Verify payment status - allow CHARGED, PENDING, or FAILURE (common in sandbox) let acceptable_statuses = [ i32::from(PaymentStatus::Charged), i32::from(PaymentStatus::Pending), ]; assert!( acceptable_statuses.contains(&response.status), "Payment should be in CHARGED, PENDING, or FAILURE state (sandbox) but was: {}", 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_3902405266844716137
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: 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); // println!("Auth request for manual capture: {:?}", auth_request); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_authorizenet_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(); // Transaction_id may not be present for failed or pending payments let successful_statuses = [ i32::from(PaymentStatus::Charged), i32::from(PaymentStatus::Authorized), i32::from(PaymentStatus::Pending), ]; // println!( // "Payment authorize response: {:?}", // auth_response // ); if successful_statuses.contains(&auth_response.status) { assert!( auth_response.transaction_id.is_some(), "Transaction ID should be present for successful payments, but status was: {}", auth_response.status ); } // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Verify payment status is authorized (for manual capture) - allow PENDING or FAILURE in sandbox let acceptable_statuses = [ i32::from(PaymentStatus::Authorized), i32::from(PaymentStatus::Pending), i32::from(PaymentStatus::Charged), // i32::from(PaymentStatus::Failure), ]; // println!("print acceptable statuses: {:?}", acceptable_statuses); assert!( acceptable_statuses.contains(&auth_response.status), "Payment should be in AUTHORIZED, PENDING, or FAILURE state (sandbox) but was: {}", auth_response.status ); // 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_authorizenet_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 - allow PENDING or FAILURE in sandbox let acceptable_statuses = [ i32::from(PaymentStatus::Charged), i32::from(PaymentStatus::Pending), // i32::from(PaymentStatus::Failure), ]; assert!( acceptable_statuses.contains(&capture_response.status), "Payment should be in CHARGED, PENDING, or FAILURE state after capture (sandbox) but was: {}", capture_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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1665935822927684733
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: 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_authorizenet_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 - allow PENDING or FAILURE in sandbox let acceptable_statuses = [ i32::from(PaymentStatus::Authorized), i32::from(PaymentStatus::Pending), // i32::from(PaymentStatus::Failure), ]; assert!( acceptable_statuses.contains(&auth_response.status), "Payment should be in AUTHORIZED, PENDING, or FAILURE state (sandbox) but was: {}", auth_response.status ); tokio::time::sleep(tokio::time::Duration::from_secs(2)).await; // Create get request let get_request = create_payment_get_request(&_transaction_id); // Add metadata headers for get request let mut get_grpc_request = Request::new(get_request); add_authorizenet_metadata(&mut get_grpc_request); // Send the get request let get_response = client .get(get_grpc_request) .await .expect("gRPC payment_get call failed") .into_inner(); // Verify the sync response // Verify the payment status matches what we expect - allow PENDING or FAILURE in sandbox let acceptable_statuses = [ i32::from(PaymentStatus::Authorized), i32::from(PaymentStatus::Pending), i32::from(PaymentStatus::Charged), // i32::from(PaymentStatus::Failure), ]; assert!( acceptable_statuses.contains(&get_response.status), "Payment get should return AUTHORIZED, PENDING, or FAILURE state (sandbox) but was: {}", get_response.status ); // Verify we have transaction ID in the response assert!( get_response.transaction_id.is_some(), "Transaction ID should be present in get response" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_sync", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-555396209231801522
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: test_void { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment to void 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_authorizenet_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 or handle other states - allow PENDING or FAILURE in sandbox let acceptable_statuses = [ i32::from(PaymentStatus::Authorized), i32::from(PaymentStatus::Pending), i32::from(PaymentStatus::Voided), // i32::from(PaymentStatus::Failure), ]; // println!( // "Auth response: {:?}", // auth_response // ); assert!( acceptable_statuses.contains(&auth_response.status), "Payment should be in AUTHORIZED, PENDING, or FAILURE (sandbox) but was: {}", auth_response.status ); // Skip void test if payment is not in AUTHORIZED state (but allow test to continue if PENDING) if auth_response.status != i32::from(PaymentStatus::Authorized) && auth_response.status != i32::from(PaymentStatus::Pending) { return; } // Allow some time for the authorization to be processed allow_processing_time(); // Additional async delay when running with other tests to avoid conflicts tokio::time::sleep(tokio::time::Duration::from_secs(2)).await; // println!("transaction_id: {}", transaction_id); // Create void request let void_request = create_void_request(&transaction_id); // println!("Void request: {:?}", void_request); // Add metadata headers for void request let mut void_grpc_request = Request::new(void_request); add_authorizenet_metadata(&mut void_grpc_request); // println!("Void grpc request: {:?}", void_grpc_request); // Send the void request let void_response = client .void(void_grpc_request) .await .expect("gRPC void_payment call failed") .into_inner(); // Accept VOIDED status let acceptable_statuses = [i32::from(PaymentStatus::Voided)]; // println!("Void response: {:?}", void_response); assert!( acceptable_statuses.contains(&void_response.status), "Payment should be in VOIDED state but was: {}", void_response.status ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_void", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7781258454999928375
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: test_refund { grpc_test!(client, PaymentServiceClient<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_authorizenet_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 or handle other states - allow PENDING or FAILURE in sandbox let acceptable_statuses = [ i32::from(PaymentStatus::Charged), i32::from(PaymentStatus::Pending), ]; assert!( acceptable_statuses.contains(&auth_response.status), "Payment should be in CHARGED, PENDING, or FAILURE state (sandbox) but was: {}", auth_response.status ); // Skip refund test if payment is not in CHARGED state (but allow test to continue if PENDING) if auth_response.status != i32::from(PaymentStatus::Charged) && auth_response.status != i32::from(PaymentStatus::Pending) { return; } // Wait a bit to ensure the payment is fully processed tokio::time::sleep(tokio::time::Duration::from_secs(3)).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_authorizenet_metadata(&mut refund_grpc_request); // Send the refund request let refund_result = client.refund(refund_grpc_request).await; // Check if we have a successful refund OR any expected error (including gRPC errors) let is_success_status = refund_result.as_ref().is_ok_and(|response| { response.get_ref().status == i32::from(RefundStatus::RefundSuccess) }); let has_expected_error = refund_result.as_ref().is_ok_and(|response| { let error_msg = response.get_ref().error_message(); error_msg.contains( "The referenced transaction does not meet the criteria for issuing a credit.", ) || error_msg.contains("credit") || error_msg.contains("refund") || error_msg.contains("transaction") || response.get_ref().status == i32::from(RefundStatus::RefundFailure) }); let has_grpc_error = refund_result.is_err(); assert!( is_success_status || has_expected_error || has_grpc_error, "Refund should either succeed, have expected error, or gRPC error (common in sandbox). Got: {refund_result:?}" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_refund", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-563118087015620244
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: 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_authorizenet_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 composite ID format (profile_id-payment_profile_id) if let Some(mandate_id) = &mandate_ref.mandate_id { assert!( mandate_id.contains('-') || !mandate_id.is_empty(), "Mandate ID should be either a composite ID or a profile ID" ); } } // 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_3097280820812074576
clm
function_body
// connector-service/backend/grpc-server/tests/authorizedotnet_payment_flows_test.rs // Function: test_authorize_with_setup_future_usage { grpc_test!(client, PaymentServiceClient<Channel>, { // Create an authorization request with setup_future_usage let mut auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic); // Add setup_future_usage to trigger profile creation auth_request.setup_future_usage = Some(i32::from(FutureUsage::OnSession)); // Add metadata headers let mut auth_grpc_request = Request::new(auth_request); add_authorizenet_metadata(&mut auth_grpc_request); // Send the authorization request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC authorize with setup_future_usage call failed") .into_inner(); // Verify the response - transaction_id may not be present for failed or pending payments let successful_statuses = [ i32::from(PaymentStatus::Charged), i32::from(PaymentStatus::Authorized), ]; if successful_statuses.contains(&auth_response.status) { assert!( auth_response.transaction_id.is_some(), "Transaction ID should be present for successful payments, but status was: {}", auth_response.status ); } // Verify payment status - allow PENDING or FAILURE in sandbox let acceptable_statuses = [ i32::from(PaymentStatus::Charged), i32::from(PaymentStatus::Pending), i32::from(PaymentStatus::Authorized), ]; assert!( acceptable_statuses.contains(&auth_response.status), "Payment should be in CHARGED, PENDING, or FAILURE state (sandbox) but was: {}", auth_response.status ); // When setup_future_usage is set, a customer profile is created // The mandate can be used in subsequent transactions }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_authorize_with_setup_future_usage", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-1433493197032138790
clm
function_body
// connector-service/backend/grpc-server/tests/test_currency.rs // Function: test_zero_decimal_currencies { // Test currencies that should have 0 decimal places assert_eq!( Currency::JPY .number_of_digits_after_decimal_point() .unwrap(), 0 ); assert_eq!( Currency::KRW .number_of_digits_after_decimal_point() .unwrap(), 0 ); assert_eq!( Currency::VND .number_of_digits_after_decimal_point() .unwrap(), 0 ); assert_eq!( Currency::BIF .number_of_digits_after_decimal_point() .unwrap(), 0 ); assert_eq!( Currency::CLP .number_of_digits_after_decimal_point() .unwrap(), 0 ); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_zero_decimal_currencies", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_8101093869943964826
clm
function_body
// connector-service/backend/grpc-server/tests/test_currency.rs // Function: test_two_decimal_currencies { // Test currencies that should have 2 decimal places assert_eq!( Currency::USD .number_of_digits_after_decimal_point() .unwrap(), 2 ); assert_eq!( Currency::EUR .number_of_digits_after_decimal_point() .unwrap(), 2 ); assert_eq!( Currency::GBP .number_of_digits_after_decimal_point() .unwrap(), 2 ); assert_eq!( Currency::CAD .number_of_digits_after_decimal_point() .unwrap(), 2 ); assert_eq!( Currency::AUD .number_of_digits_after_decimal_point() .unwrap(), 2 ); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_two_decimal_currencies", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-8910612875394135112
clm
function_body
// connector-service/backend/grpc-server/tests/test_currency.rs // Function: test_three_decimal_currencies { // Test currencies that should have 3 decimal places assert_eq!( Currency::BHD .number_of_digits_after_decimal_point() .unwrap(), 3 ); assert_eq!( Currency::JOD .number_of_digits_after_decimal_point() .unwrap(), 3 ); assert_eq!( Currency::KWD .number_of_digits_after_decimal_point() .unwrap(), 3 ); assert_eq!( Currency::OMR .number_of_digits_after_decimal_point() .unwrap(), 3 ); assert_eq!( Currency::TND .number_of_digits_after_decimal_point() .unwrap(), 3 ); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_three_decimal_currencies", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_2268099515734285423
clm
function_body
// connector-service/backend/grpc-server/tests/test_currency.rs // Function: test_four_decimal_currencies { // Test currencies that should have 4 decimal places assert_eq!( Currency::CLF .number_of_digits_after_decimal_point() .unwrap(), 4 ); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_four_decimal_currencies", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1768227964673979343
clm
function_body
// connector-service/backend/grpc-server/tests/test_currency.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1270060618791218265
clm
function_body
// connector-service/backend/grpc-server/tests/test_currency.rs // Function: _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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_5749166719857765785
clm
function_body
// connector-service/backend/grpc-server/tests/test_currency.rs // Function: _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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1430823553091514736
clm
function_body
// connector-service/backend/grpc-server/tests/common.rs // Function: server_and_client_stub { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4517455844453642043
clm
function_body
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs // Function: get_creds_file_path { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-5490418293903000641
clm
function_body
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs // Function: load_connector_metadata { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_234538463359408036
clm
function_body
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs // Function: load_from_json { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-5707773763803755018
clm
function_body
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs // Function: load_credentials_individually { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_3726245327309402691
clm
function_body
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs // Function: parse_single_connector { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-8407269880674003498
clm
function_body
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs // Function: parse_connector_credentials { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-3278319753363087812
clm
function_body
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs // Function: parse_connector_account_details { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-6421449900676208475
clm
function_body
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs // Function: parse_currency_auth_key_details { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-3398576078936142422
clm
function_body
// connector-service/backend/grpc-server/tests/utils/credential_utils.rs // Function: convert_to_auth_type { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_8037225562947343480
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs // Function: add_dlocal_metadata { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_8530497804729948052
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs // Function: extract_transaction_id { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-7004692653611065816
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs // Function: create_payment_authorize_request { // 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_537690575096248511
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs // Function: create_payment_sync_request { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_2593228449678822534
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs // Function: create_payment_capture_request { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_580218554360138093
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs // Function: create_refund_request { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1269185978118303654
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs // Function: create_refund_sync_request { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }