id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
connector-service_fn_grpc-server_7375937921555173362
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs async fn test_health() { grpc_test!(client, HealthClient<Channel>, { let response = client .check(Request::new(HealthCheckRequest { service: "connector_service".to_string(), })) .await .expect("Failed to call health check") .into_inner(); assert_eq!( response.status(), grpc_api_types::health_check::health_check_response::ServingStatus::Serving ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_health", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_2967270299160390869
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs async fn test_payment_authorization_auto_capture() { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request let request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic); // Add metadata headers let mut grpc_request = Request::new(request); add_bluecode_metadata(&mut grpc_request); // Send the request let response = client .authorize(grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Debug print has been removed // Verify the response assert!( response.transaction_id.is_some(), "Resource ID should be present" ); // Extract the transaction ID let _transaction_id = extract_transaction_id(&response); // Verify payment status assert!( response.status == i32::from(PaymentStatus::AuthenticationPending), "Payment should be in AuthenticationPending state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authorization_auto_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5085792768409566150
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs async fn test_payment_sync() { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment to sync let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_bluecode_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Create sync request let sync_request = create_payment_sync_request(&transaction_id); // Add metadata headers for sync request let mut sync_grpc_request = Request::new(sync_request); add_bluecode_metadata(&mut sync_grpc_request); // Send the sync request let sync_response = client .get(sync_grpc_request) .await .expect("gRPC payment_sync call failed") .into_inner(); // Verify the sync response assert!( sync_response.status == i32::from(PaymentStatus::AuthenticationPending), "Payment should be in AuthenticationPending state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_sync", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2867970346143951382
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs fn get_timestamp() -> u64 { SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_secs() }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_timestamp", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-6797754970414355765
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs fn add_fiserv_metadata<T>(request: &mut Request<T>) { let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load fiserv 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 fiserv"), }; // Get the terminal_id from metadata let metadata = utils::credential_utils::load_connector_metadata(CONNECTOR_NAME) .expect("Failed to load fiserv metadata"); let terminal_id = metadata .get("terminal_id") .expect("terminal_id not found in fiserv metadata") .clone(); 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"), ); // Add the terminal_id in the metadata JSON // This metadata must be in the proper format that the connector expects let metadata_json = format!(r#"{{"terminal_id":"{terminal_id}"}}"#); // For capture operations, the connector looks for terminal_id in connector_metadata let base64_metadata = general_purpose::STANDARD.encode(metadata_json.as_bytes()); request.metadata_mut().append( "x-metadata", metadata_json.parse().expect("Failed to parse x-metadata"), ); // Also add connector-metadata-id explicitly to handle capture operation request.metadata_mut().append( "connector-metadata-id", metadata_json .parse() .expect("Failed to parse connector-metadata-id"), ); // Add base64-encoded metadata as x-connector-metadata request.metadata_mut().append( "x-connector-metadata", base64_metadata .parse() .expect("Failed to parse x-connector-metadata"), ); request.metadata_mut().append( "x-merchant-id", "test_merchant" .parse() .expect("Failed to parse x-merchant-id"), ); request.metadata_mut().append( "x-tenant-id", "default".parse().expect("Failed to parse x-tenant-id"), ); request.metadata_mut().append( "x-request-id", format!("test_request_{}", get_timestamp()) .parse() .expect("Failed to parse x-request-id"), ); request.metadata_mut().append( "x-connector-request-reference-id", format!("conn_ref_{}", get_timestamp()) .parse() .expect("Failed to parse x-connector-request-reference-id"), ); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "add_fiserv_metadata", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1123401055517435843
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs fn extract_transaction_id(response: &PaymentServiceAuthorizeResponse) -> String { match &response.transaction_id { Some(id) => match id.id_type.as_ref().unwrap() { IdType::Id(id) => id.clone(), _ => panic!("Expected connector transaction ID"), }, None => panic!("Resource ID is None"), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_transaction_id", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-7904799952799662988
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs fn create_payment_authorize_request( capture_method: CaptureMethod, ) -> PaymentServiceAuthorizeRequest { // Get terminal_id for metadata let metadata = utils::credential_utils::load_connector_metadata(CONNECTOR_NAME) .expect("Failed to load fiserv metadata"); let terminal_id = metadata .get("terminal_id") .expect("terminal_id not found in fiserv metadata") .clone(); // Create connector metadata as a proper JSON object let mut connector_metadata = HashMap::new(); connector_metadata.insert("terminal_id".to_string(), terminal_id); let connector_metadata_json = serde_json::to_string(&connector_metadata).expect("Failed to serialize connector metadata"); let mut metadata = HashMap::new(); metadata.insert("connector_meta_data".to_string(), connector_metadata_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: None, card_type: None, card_issuing_country_alpha2: None, bank_code: None, nick_name: None, }); // Initialize with all required fields 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), })), }), //i32::from(payment_method::PaymentMethod::Card), 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!("fiserv_test_{}", get_timestamp()))), }), //format!("fiserv_test_{}", get_timestamp()), enrolled_for_3ds: false, request_incremental_authorization: false, capture_method: Some(i32::from(capture_method)), // payment_method_type: Some(i32::from(PaymentMethodType::Credit)), metadata, ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_authorize_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_2416189768758207098
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs fn create_payment_sync_request(transaction_id: &str) -> PaymentServiceGetRequest { PaymentServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), request_ref_id: Some(Identifier { id_type: Some(IdType::Id(format!("fiserv_sync_{}", get_timestamp()))), }), // 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2145130524951428854
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs fn create_payment_capture_request(transaction_id: &str) -> PaymentServiceCaptureRequest { let metadata = utils::credential_utils::load_connector_metadata(CONNECTOR_NAME) .expect("Failed to load fiserv metadata"); let terminal_id = metadata .get("terminal_id") .expect("terminal_id not found in fiserv metadata") .clone(); // Create connector metadata as a proper JSON object let mut connector_metadata = HashMap::new(); connector_metadata.insert("terminal_id".to_string(), terminal_id); let connector_metadata_json = serde_json::to_string(&connector_metadata).expect("Failed to serialize connector metadata"); let mut connector_metadata = HashMap::new(); connector_metadata.insert("connector_metadata".to_string(), connector_metadata_json); PaymentServiceCaptureRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), amount_to_capture: TEST_AMOUNT, currency: i32::from(Currency::Usd), multiple_capture_data: None, connector_metadata, request_ref_id: None, // all_keys_required: None, browser_info: None, capture_method: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_capture_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-8871171629052657541
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs fn create_refund_request(transaction_id: &str) -> PaymentServiceRefundRequest { let metadata = utils::credential_utils::load_connector_metadata(CONNECTOR_NAME) .expect("Failed to load fiserv metadata"); let terminal_id = metadata .get("terminal_id") .expect("terminal_id not found in fiserv metadata") .clone(); // Create connector metadata as a proper JSON object let mut connector_metadata = HashMap::new(); connector_metadata.insert("terminal_id".to_string(), terminal_id); let connector_metadata_json = serde_json::to_string(&connector_metadata).expect("Failed to serialize connector metadata"); let mut metadata = HashMap::new(); metadata.insert("connector_metadata".to_string(), connector_metadata_json); PaymentServiceRefundRequest { refund_id: format!("refund_{}", get_timestamp()), transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), currency: i32::from(Currency::Usd), payment_amount: TEST_AMOUNT, refund_amount: TEST_AMOUNT, minor_payment_amount: TEST_AMOUNT, minor_refund_amount: TEST_AMOUNT, // connector_refund_id: None, reason: None, webhook_url: None, metadata: metadata.clone(), // Add terminal_id for the main connector_metadata field refund_metadata: metadata, // Add terminal_id for refund browser_info: None, merchant_account_id: None, capture_method: None, request_ref_id: None, // all_keys_required: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_4359955422860675838
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs fn create_refund_sync_request(transaction_id: &str, refund_id: &str) -> RefundServiceGetRequest { RefundServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), refund_id: refund_id.to_string(), refund_reason: None, request_ref_id: None, // all_keys_required: None, browser_info: None, refund_metadata: HashMap::new(), state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_sync_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_423687309422834336
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs async fn test_health() { grpc_test!(client, HealthClient<Channel>, { let response = client .check(Request::new(HealthCheckRequest { service: "connector_service".to_string(), })) .await .expect("Failed to call health check") .into_inner(); assert_eq!( response.status(), grpc_api_types::health_check::health_check_response::ServingStatus::Serving ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_health", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_8872365188974249132
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs async fn test_payment_authorization_auto_capture() { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request let request = create_payment_authorize_request(CaptureMethod::Automatic); // Add metadata headers let mut grpc_request = Request::new(request); add_fiserv_metadata(&mut grpc_request); // Send the request let response = client .authorize(grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Debug print has been removed // Verify the response assert!( response.transaction_id.is_some(), "Resource ID should be present" ); // Extract the transaction ID let _transaction_id = extract_transaction_id(&response); // Verify payment status assert!( 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_authorization_auto_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_608751216830662025
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs async fn test_payment_authorization_manual_capture() { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request with manual capture let auth_request = create_payment_authorize_request(CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_fiserv_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(), "Resource ID should be present" ); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Verify payment status is authorized (for manual capture) assert!( auth_response.status == i32::from(PaymentStatus::Authorized), "Payment should be in AUTHORIZED state with manual capture" ); // Create capture request (which already includes proper connector metadata) 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_fiserv_metadata(&mut capture_grpc_request); // Send the capture request let capture_result = client.capture(capture_grpc_request).await; // Add debugging for capture failure let capture_response = match capture_result { Ok(response) => response.into_inner(), Err(status) => { println!("=== FISERV CAPTURE DEBUG ==="); println!("Capture failed with status: {:?}", status); println!("Error code: {:?}", status.code()); println!("Error message: {:?}", status.message()); println!("Metadata: {:?}", status.metadata()); println!("=== END DEBUG ==="); panic!("gRPC payment_capture call failed: {}", status); } }; // Verify payment status is charged after capture assert!( capture_response.status == i32::from(PaymentStatus::Charged), "Payment should be in CHARGED state after capture" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authorization_manual_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_344110033113799881
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs async fn test_payment_sync() { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment to sync let auth_request = create_payment_authorize_request(CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_fiserv_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Create sync request let sync_request = create_payment_sync_request(&transaction_id); // Add metadata headers for sync request let mut sync_grpc_request = Request::new(sync_request); add_fiserv_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::Authorized), "Payment should be in Authorized state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_sync", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2500157299759679036
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs async fn test_refund() { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment let auth_request = create_payment_authorize_request(CaptureMethod::Automatic); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_fiserv_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::Charged) || auth_response.status == i32::from(PaymentStatus::Authorized), "Payment should be in CHARGED or AUTHORIZED state before attempting refund" ); // Make sure the payment is fully processed by checking its status via sync let sync_request = create_payment_sync_request(&transaction_id); let mut sync_grpc_request = Request::new(sync_request); add_fiserv_metadata(&mut sync_grpc_request); // Wait a bit longer to ensure the payment is fully processed tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; // Send the sync request to verify payment status let _sync_response = client .get(sync_grpc_request) .await .expect("gRPC payment_sync call failed") .into_inner(); // 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_fiserv_metadata(&mut refund_grpc_request); // Send the refund request and handle both success and error cases let refund_result = client.refund(refund_grpc_request).await; match refund_result { Ok(response) => { let refund_response = response.into_inner(); // Extract the refund ID let _refund_id = refund_response.refund_id.clone(); // Verify the refund status assert!( refund_response.status == i32::from(RefundStatus::RefundSuccess) || refund_response.status == i32::from(RefundStatus::RefundPending), "Refund should be in SUCCESS or PENDING state" ); } Err(status) => { // If the refund fails, it could be due to timing issues or payment not being in the right state // This is acceptable for our test scenario - we're testing the connector functionality // Verify the error message is reasonable assert!( status.message().contains("processing error") || status.message().contains("not found") || status.message().contains("payment state"), "Error should be related to processing or payment state issues" ); } } }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_refund", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-3623264078452725780
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs async fn test_refund_sync() { grpc_test!(client, PaymentServiceClient<Channel>, { grpc_test!(refund_client, RefundServiceClient<Channel>, { // Run a standalone test specifically for refund sync // We'll directly test the payment sync functionality since the payment sync test already passes // And use a mock refund ID for testing the refund sync functionality // First create a payment let auth_request = create_payment_authorize_request(CaptureMethod::Automatic); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_fiserv_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 with debugging let transaction_id = match &auth_response.transaction_id { Some(id) => match id.id_type.as_ref().unwrap() { IdType::Id(id) => id.clone(), IdType::NoResponseIdMarker(_) => { println!("=== FISERV REFUND SYNC DEBUG ==="); println!("NoResponseIdMarker detected in refund sync test"); println!("Auth response: {:?}", auth_response); println!("=== END DEBUG ==="); panic!("NoResponseIdMarker found - authentication issue"); } IdType::EncodedData(_) => { println!("EncodedData found instead of transaction ID"); panic!("Unexpected EncodedData in transaction ID"); } }, None => panic!("Resource ID is None"), }; // Wait for payment to process tokio::time::sleep(tokio::time::Duration::from_secs(3)).await; // Create sync request to check payment status 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_fiserv_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 payment is in a good state assert!( sync_response.status == i32::from(PaymentStatus::Charged) || sync_response.status == i32::from(PaymentStatus::Authorized), "Payment should be in CHARGED or AUTHORIZED state" ); // Use a mock refund ID for sync testing // The format mimics what would come from a real Fiserv refund let mock_refund_id = format!("refund_sync_test_{}", get_timestamp()); // Create refund sync request with our mock ID let refund_sync_request = create_refund_sync_request(&transaction_id, &mock_refund_id); // Add metadata headers for refund sync request let mut refund_sync_grpc_request = Request::new(refund_sync_request); add_fiserv_metadata(&mut refund_sync_grpc_request); // Send the refund sync request and expect a not found response or pending status let refund_sync_result = refund_client.get(refund_sync_grpc_request).await; //client.refund(refund_sync_grpc_request).await; // For a mock refund ID, we expect either a failure (not found) or a pending status // Both outcomes are valid for this test scenario match refund_sync_result { Ok(response) => { // If we got a response, it should be in a pending state let status = response.into_inner().status; assert_eq!( status, i32::from(RefundStatus::RefundPending), "If response received, refund should be in PENDING state for a mock ID" ); } Err(status) => { // An error is also acceptable if the mock ID isn't found assert!( status.message().contains("not found") || status.message().contains("processing error"), "Error should indicate refund not found or processing error" ); } } }); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_refund_sync", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2130091761806558605
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs fn get_timestamp() -> u64 { SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_secs() }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_timestamp", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_6516804850073880728
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs fn add_elavon_metadata<T>(request: &mut Request<T>) { let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load elavon credentials"); let (api_key, api_user, 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 elavon"), }; 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", api_user.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"), ); 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_elavon_metadata", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7868847288157542993
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs fn extract_transaction_id(response: &PaymentServiceAuthorizeResponse) -> String { match &response.transaction_id { Some(id) => match id.id_type.as_ref().unwrap() { IdType::Id(id) => id.clone(), _ => panic!("Expected connector transaction ID"), }, None => panic!("Resource ID is None"), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_transaction_id", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-7324019789287014184
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs fn create_payment_authorize_request( capture_method: CaptureMethod, ) -> PaymentServiceAuthorizeRequest { // Initialize with all required fields to avoid field_reassign_with_default warning 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: None, card_type: None, card_issuing_country_alpha2: None, bank_code: None, nick_name: None, }); PaymentServiceAuthorizeRequest { amount: TEST_AMOUNT, minor_amount: TEST_AMOUNT, currency: i32::from(Currency::Usd), payment_method: Some(PaymentMethod { payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType { card_type: Some(card_details), })), }), // payment_method_data: Some(grpc_api_types::payments::PaymentMethodData { // data: Some(grpc_api_types::payments::payment_method_data::Data::Card( // grpc_api_types::payments::Card { // card_number: TEST_CARD_NUMBER.to_string(), // card_exp_month: TEST_CARD_EXP_MONTH.to_string(), // card_exp_year: TEST_CARD_EXP_YEAR.to_string(), // card_cvc: TEST_CARD_CVC.to_string(), // card_holder_name: Some(TEST_CARD_HOLDER.to_string()), // card_issuer: None, // card_network: None, // card_type: None, // card_issuing_country: None, // bank_code: None, // nick_name: None, // }, // )), // }), 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!("elavon_test_{}", get_timestamp()))), }), enrolled_for_3ds: false, request_incremental_authorization: false, capture_method: Some(i32::from(capture_method)), // payment_method_type: Some(i32::from(PaymentMethodType::Credit)), // all_keys_required: Some(false), ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_authorize_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_3948348151509357772
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs async fn test_payment_authorization_auto_capture() { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request let request = create_payment_authorize_request(CaptureMethod::Automatic); // Add metadata headers let mut grpc_request = Request::new(request); add_elavon_metadata(&mut grpc_request); // Send the request let response = client .authorize(grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Add comprehensive logging for debugging println!("=== ELAVON PAYMENT RESPONSE DEBUG ==="); println!("Response: {:#?}", response); println!("Status: {}", response.status); println!("Error code: {:?}", response.error_code); println!("Error message: {:?}", response.error_message); println!("Status code: {:?}", response.status_code); println!("Transaction ID: {:?}", response.transaction_id); println!("=== END DEBUG ==="); // Check if we have a valid transaction ID or if it's a NoResponseIdMarker (auth issue) if let Some(ref tx_id) = response.transaction_id { if let Some(ref id_type) = tx_id.id_type { match id_type { IdType::NoResponseIdMarker(_) => { println!("Elavon authentication/credential issue detected - NoResponseIdMarker"); return; // Exit early since we can't proceed with invalid credentials } IdType::Id(_) => { // Valid transaction ID, continue with test } IdType::EncodedData(_) => { // Handle encoded data case println!("Elavon returned encoded data"); } } } } // Verify the response assert!( response.transaction_id.is_some(), "Resource ID should be present" ); // Extract the transaction ID (using underscore prefix since it's used for assertions only) let _transaction_id = extract_transaction_id(&response); // Verify payment status assert_eq!( 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_authorization_auto_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-3412244664542018374
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs async fn test_health() { grpc_test!(client, HealthClient<Channel>, { let response = client .check(Request::new(HealthCheckRequest { service: "connector_service".to_string(), })) .await .expect("Failed to call health check") .into_inner(); assert_eq!( response.status(), grpc_api_types::health_check::health_check_response::ServingStatus::Serving ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_health", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_6655362038704610287
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs fn create_payment_sync_request(transaction_id: &str) -> PaymentServiceGetRequest { PaymentServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), request_ref_id: Some(Identifier { id_type: Some(IdType::Id(format!("elavon_sync_{}", get_timestamp()))), }), // Some(format!("elavon_sync_{}", get_timestamp())), // all_keys_required: Some(false), capture_method: None, handle_response: None, amount: TEST_AMOUNT, currency: i32::from(Currency::Usd), state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_sync_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_6888726934277155481
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs async fn test_payment_sync() { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment to sync let auth_request = create_payment_authorize_request(CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_elavon_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Create sync request let sync_request = create_payment_sync_request(&transaction_id); // Add metadata headers for sync request let mut sync_grpc_request = Request::new(sync_request); add_elavon_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::Authorized), "Payment should be in Authorized state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_sync", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-3721487556865058272
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs fn create_payment_capture_request(transaction_id: &str) -> PaymentServiceCaptureRequest { PaymentServiceCaptureRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), amount_to_capture: TEST_AMOUNT, currency: i32::from(Currency::Usd), multiple_capture_data: None, connector_metadata: HashMap::new(), request_ref_id: None, browser_info: None, capture_method: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_capture_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-4961759628151044124
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs async fn test_payment_authorization_manual_capture() { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request with manual capture let auth_request = create_payment_authorize_request(CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_elavon_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(), "Resource ID should be present" ); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Verify payment status // Note: Even though we set capture_method to Manual, Elavon might still auto-capture // the payment depending on the configuration, so we accept both Authorized and Charged states assert!( auth_response.status == i32::from(PaymentStatus::Authorized), "Payment should be in AUTHORIZED state" ); // 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_elavon_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(); // Note: If the payment was already auto-captured, the capture request might fail // with an error like "Invalid Transaction ID: The transaction ID is invalid for this transaction type" // In this case, we'll accept either a CHARGED status assert!( capture_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_authorization_manual_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_2374898520195055906
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs fn create_refund_request(transaction_id: &str) -> PaymentServiceRefundRequest { PaymentServiceRefundRequest { refund_id: format!("refund_{}", get_timestamp()), transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), currency: i32::from(Currency::Usd), payment_amount: TEST_AMOUNT, refund_amount: TEST_AMOUNT, minor_payment_amount: TEST_AMOUNT, minor_refund_amount: TEST_AMOUNT, // connector_refund_id: None, 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, // all_keys_required: Some(false), state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5108748663893851969
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs fn create_refund_sync_request(transaction_id: &str, refund_id: &str) -> RefundServiceGetRequest { RefundServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), refund_id: refund_id.to_string(), refund_reason: None, browser_info: None, request_ref_id: None, // all_keys_required: None, refund_metadata: HashMap::new(), state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_sync_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-6874223455902090955
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs async fn test_refund() { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment to refund let auth_request = create_payment_authorize_request(CaptureMethod::Automatic); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_elavon_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Create 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_elavon_metadata(&mut refund_grpc_request); // Send the refund request let refund_response = client .refund(refund_grpc_request) .await .expect("gRPC refund call failed") .into_inner(); // Extract the refund ID let refund_id = refund_response.refund_id.clone(); // Verify the refund response assert!(!refund_id.is_empty(), "Refund ID should not be empty"); assert!( refund_response.status == i32::from(RefundStatus::RefundSuccess), "Refund should be in SUCCESS state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_refund", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5532278473075429871
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs async fn test_refund_sync() { grpc_test!(client, PaymentServiceClient<Channel>, { grpc_test!(refund_client, RefundServiceClient<Channel>, { let auth_request = create_payment_authorize_request(CaptureMethod::Automatic); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_elavon_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Create 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_elavon_metadata(&mut refund_grpc_request); // Send the refund request let refund_response = client .refund(refund_grpc_request) .await .expect("gRPC refund call failed") .into_inner(); // Extract the refund ID let refund_id = refund_response.refund_id.clone(); // Verify the refund response assert!(!refund_id.is_empty(), "Refund ID should not be empty"); // 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_elavon_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::RefundPending) || refund_sync_response.status == i32::from(RefundStatus::RefundSuccess), "Refund should be in PENDING or SUCCESS state" ); }); // First create a payment to refund }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_refund_sync", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-1883970625363886061
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs fn get_timestamp() -> u64 { SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_secs() }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_timestamp", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-6895945706975471610
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs fn add_rapyd_metadata<T>(request: &mut Request<T>) { let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load rapyd 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 rapyd"), }; request.metadata_mut().append( "x-connector", CONNECTOR_NAME.parse().expect("Failed to parse x-connector"), ); request.metadata_mut().append( "x-auth", "body-key".parse().expect("Failed to parse x-auth"), ); request.metadata_mut().append( "x-api-key", api_key.parse().expect("Failed to parse x-api-key"), ); request .metadata_mut() .append("x-key1", key1.parse().expect("Failed to parse x-key1")); request.metadata_mut().append( "x-merchant-id", "test_merchant" .parse() .expect("Failed to parse x-merchant-id"), ); request.metadata_mut().append( "x-tenant-id", "default".parse().expect("Failed to parse x-tenant-id"), ); request.metadata_mut().append( "x-request-id", format!("test_request_{}", get_timestamp()) .parse() .expect("Failed to parse x-request-id"), ); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "add_rapyd_metadata", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_6474833224344867286
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs fn extract_transaction_id(response: &PaymentServiceAuthorizeResponse) -> String { match &response.transaction_id { Some(id) => match id.id_type.as_ref().unwrap() { IdType::Id(id) => id.clone(), _ => panic!("Expected connector transaction ID"), }, None => panic!("Resource ID is None"), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_transaction_id", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_6808827162032027004
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs fn create_payment_authorize_request( capture_method: common_enums::CaptureMethod, ) -> PaymentServiceAuthorizeRequest { // Initialize with all required fields let mut request = PaymentServiceAuthorizeRequest::default(); // Set request reference ID let mut request_ref_id = Identifier::default(); request_ref_id.id_type = Some(IdType::Id(format!("rapyd_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::Usd); // Set up card payment method using the correct structure let card_details = card_payment_method_type::CardType::Credit(CardDetails { card_number: Some(CardNumber::from_str(TEST_CARD_NUMBER).unwrap()), card_exp_month: Some(Secret::new(TEST_CARD_EXP_MONTH.to_string())), card_exp_year: Some(Secret::new(TEST_CARD_EXP_YEAR.to_string())), card_cvc: Some(Secret::new(TEST_CARD_CVC.to_string())), card_holder_name: Some(Secret::new(TEST_CARD_HOLDER.to_string())), card_issuer: None, card_network: Some(1_i32), // Default to Visa network card_type: None, card_issuing_country_alpha2: None, bank_code: None, nick_name: None, }); request.payment_method = Some(PaymentMethod { payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType { card_type: Some(card_details), })), }); // Set connector customer ID request.customer_id = Some("TEST_CONNECTOR".to_string()); // Set the customer information with static email (can be made dynamic) request.email = Some(TEST_EMAIL.to_string().into()); // Set up address structure request.address = Some(PaymentAddress { billing_address: Some(Address { first_name: Some("Test".to_string().into()), last_name: Some("User".to_string().into()), line1: Some("123 Test Street".to_string().into()), line2: None, line3: None, city: Some("Test City".to_string().into()), state: Some("NY".to_string().into()), zip_code: Some("10001".to_string().into()), country_alpha2_code: Some(i32::from(CountryAlpha2::Us)), phone_number: None, phone_country_code: None, email: None, }), shipping_address: None, }); // Set up browser information let browser_info = BrowserInformation { color_depth: None, java_enabled: Some(false), screen_height: Some(1080), screen_width: Some(1920), user_agent: Some("Mozilla/5.0 (compatible; TestAgent/1.0)".to_string()), accept_header: Some( "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8".to_string(), ), java_script_enabled: Some(false), language: Some("en-US".to_string()), ip_address: None, os_type: None, os_version: None, device_model: None, accept_language: None, time_zone_offset_minutes: None, referer: None, }; request.browser_info = Some(browser_info); // Set return URL request.return_url = Some("https://example.com/return".to_string()); // Set the transaction details request.auth_type = i32::from(AuthenticationType::NoThreeDs); request.request_incremental_authorization = true; request.enrolled_for_3ds = true; // Set capture method with proper conversion if let common_enums::CaptureMethod::Manual = capture_method { request.capture_method = Some(i32::from(CaptureMethod::Manual)); } else { request.capture_method = Some(i32::from(CaptureMethod::Automatic)); } // Set connector metadata (empty for generic template) request.metadata = HashMap::new(); request }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_authorize_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-8967050789992120169
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs fn create_payment_sync_request(transaction_id: &str) -> PaymentServiceGetRequest { PaymentServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), request_ref_id: Some(Identifier { id_type: Some(IdType::Id(format!("rapyd_sync_{}", get_timestamp()))), }), capture_method: None, handle_response: None, amount: TEST_AMOUNT, currency: i32::from(Currency::Usd), state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_sync_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2650470818879392351
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs fn create_payment_capture_request(transaction_id: &str) -> PaymentServiceCaptureRequest { PaymentServiceCaptureRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), amount_to_capture: TEST_AMOUNT, currency: i32::from(Currency::Usd), multiple_capture_data: None, connector_metadata: HashMap::new(), request_ref_id: None, browser_info: None, capture_method: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_capture_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2922098871816672469
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs fn create_refund_request(transaction_id: &str) -> PaymentServiceRefundRequest { PaymentServiceRefundRequest { refund_id: format!("refund_{}", get_timestamp()), transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), currency: i32::from(Currency::Usd), payment_amount: TEST_AMOUNT, refund_amount: TEST_AMOUNT, minor_payment_amount: TEST_AMOUNT, minor_refund_amount: TEST_AMOUNT, reason: None, webhook_url: None, metadata: HashMap::new(), refund_metadata: HashMap::new(), browser_info: None, merchant_account_id: None, capture_method: None, request_ref_id: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1422767740851790086
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs fn create_payment_void_request(transaction_id: &str) -> PaymentServiceVoidRequest { PaymentServiceVoidRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), cancellation_reason: Some("Customer requested cancellation".to_string()), request_ref_id: None, all_keys_required: None, browser_info: None, amount: None, currency: None, ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_void_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-911773784498730869
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs async fn test_health() { grpc_test!(client, HealthClient<Channel>, { let response = client .check(Request::new(HealthCheckRequest { service: "connector_service".to_string(), })) .await .expect("Failed to call health check") .into_inner(); assert_eq!( response.status(), grpc_api_types::health_check::health_check_response::ServingStatus::Serving ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_health", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_4222945509478044210
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs async fn test_payment_authorization_auto_capture() { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request let request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic); // Add metadata headers let mut grpc_request = Request::new(request); add_rapyd_metadata(&mut grpc_request); // Send the request let response = client .authorize(grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Verify the response assert!( response.transaction_id.is_some(), "Transaction ID should be present" ); // Extract the transaction ID let _transaction_id = extract_transaction_id(&response); // Verify payment status assert_eq!( response.status, i32::from(PaymentStatus::Charged), "Payment should be in CHARGED state for automatic capture" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authorization_auto_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-229242072854148878
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs async fn test_payment_authorization_manual_capture() { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request with manual capture let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_rapyd_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); assert!( auth_response.transaction_id.is_some(), "Transaction ID should be present" ); // Extract the transaction ID let _transaction_id = extract_transaction_id(&auth_response); // Verify payment status is authorized (for manual capture) assert_eq!( auth_response.status, i32::from(PaymentStatus::Authorized), "Payment should be in AUTHORIZED state with manual capture" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authorization_manual_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_5613932586531979458
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs async fn test_payment_sync() { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment to sync let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_rapyd_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Create sync request let sync_request = create_payment_sync_request(&transaction_id); // Add metadata headers for sync request let mut sync_grpc_request = Request::new(sync_request); add_rapyd_metadata(&mut sync_grpc_request); // Send the sync request let sync_response = client .get(sync_grpc_request) .await .expect("gRPC payment_sync call failed") .into_inner(); // Verify the sync response - allow both AUTHORIZED and PENDING states let acceptable_sync_statuses = [ i32::from(PaymentStatus::Authorized), i32::from(PaymentStatus::Pending), ]; assert!( acceptable_sync_statuses.contains(&sync_response.status), "Payment should be in AUTHORIZED or PENDING state, but was: {}", sync_response.status ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_sync", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5231900633774868630
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs async fn test_payment_capture() { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request with manual capture let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_rapyd_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); assert!( auth_response.transaction_id.is_some(), "Transaction ID should be present" ); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Verify payment status is authorized (for manual capture) assert!( auth_response.status == i32::from(PaymentStatus::Authorized), "Payment should be in AUTHORIZED state with manual capture" ); // Create capture request let capture_request = create_payment_capture_request(&transaction_id); // Add metadata headers for capture request let mut capture_grpc_request = Request::new(capture_request); add_rapyd_metadata(&mut capture_grpc_request); // Send the capture request let capture_response = client .capture(capture_grpc_request) .await .expect("gRPC payment_capture call failed") .into_inner(); // Verify payment status is charged after capture assert!( capture_response.status == i32::from(PaymentStatus::Charged), "Payment should be in CHARGED state after capture" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_3525038909911381947
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs async fn test_refund() { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment to refund let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_rapyd_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Verify payment status - allow both CHARGED and PENDING states let acceptable_payment_statuses = [ i32::from(PaymentStatus::Charged), i32::from(PaymentStatus::Pending), ]; assert!( acceptable_payment_statuses.contains(&auth_response.status), "Payment should be in CHARGED or PENDING state before attempting refund, but was: {}", auth_response.status ); // 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_rapyd_metadata(&mut refund_grpc_request); // Send the refund request let refund_response = client .refund(refund_grpc_request) .await .expect("gRPC refund call failed") .into_inner(); // Extract the refund ID let refund_id = refund_response.refund_id.clone(); // Verify the refund response assert!(!refund_id.is_empty(), "Refund ID should not be empty"); assert!( refund_response.status == i32::from(RefundStatus::RefundSuccess) || refund_response.status == i32::from(RefundStatus::RefundPending), "Refund should be in SUCCESS or PENDING state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_refund", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5164936181117676341
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs async fn test_payment_void() { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment with manual capture (so it stays in authorized state) let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_rapyd_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Verify payment is in authorized state assert!( auth_response.status == i32::from(PaymentStatus::Authorized), "Payment should be in AUTHORIZED state before void" ); // Create void request let void_request = create_payment_void_request(&transaction_id); // Add metadata headers for void request let mut void_grpc_request = Request::new(void_request); add_rapyd_metadata(&mut void_grpc_request); // Send the void request let void_response = client .void(void_grpc_request) .await .expect("gRPC payment_void call failed") .into_inner(); // Verify the void response assert!( void_response.status == i32::from(PaymentStatus::Voided), "Payment should be in VOIDED state after void" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_void", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5352875318063094044
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs fn get_timestamp() -> u64 { SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_secs() }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_timestamp", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-6856345926885329107
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs fn add_placetopay_metadata<T>(request: &mut Request<T>) { let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load placetopay 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 placetopay"), }; request.metadata_mut().append( "x-connector", CONNECTOR_NAME.parse().expect("Failed to parse x-connector"), ); request.metadata_mut().append( "x-auth", "body-key".parse().expect("Failed to parse x-auth"), ); request.metadata_mut().append( "x-api-key", api_key.parse().expect("Failed to parse x-api-key"), ); request .metadata_mut() .append("x-key1", key1.parse().expect("Failed to parse x-key1")); request.metadata_mut().append( "x-merchant-id", "test_merchant" .parse() .expect("Failed to parse x-merchant-id"), ); request.metadata_mut().append( "x-tenant-id", "default".parse().expect("Failed to parse x-tenant-id"), ); request.metadata_mut().append( "x-request-id", format!("test_request_{}", get_timestamp()) .parse() .expect("Failed to parse x-request-id"), ); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "add_placetopay_metadata", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2366563515290863855
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs fn extract_transaction_id(response: &PaymentServiceAuthorizeResponse) -> String { match &response.transaction_id { Some(id) => match id.id_type.as_ref().unwrap() { IdType::Id(id) => { if id == "NoResponseIdMarker" { panic!("Placetopay validation error - check required fields like ip_address and description"); } else { id.clone() } } _ => panic!("Expected connector 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_193363765930568766
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs fn create_payment_authorize_request( capture_method: common_enums::CaptureMethod, ) -> PaymentServiceAuthorizeRequest { 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!("placetopay_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::Usd); // Set up card payment method 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), })), }); request.customer_id = Some("TEST_CONNECTOR".to_string()); request.email = Some(TEST_EMAIL.to_string().into()); // Set up address structure request.address = Some(PaymentAddress { billing_address: Some(Address { first_name: Some("Test".to_string().into()), last_name: Some("User".to_string().into()), line1: Some("123 Test Street".to_string().into()), line2: None, line3: None, city: Some("Test City".to_string().into()), state: Some("NY".to_string().into()), zip_code: Some("10001".to_string().into()), country_alpha2_code: Some(i32::from(CountryAlpha2::Us)), phone_number: None, phone_country_code: None, email: None, }), shipping_address: None, }); // Set up browser information with required fields for Placetopay 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: Some("127.0.0.1".to_string()), // Required by Placetopay os_type: None, os_version: None, device_model: None, accept_language: None, time_zone_offset_minutes: None, referer: None, }; request.browser_info = Some(browser_info); request.return_url = Some("https://example.com/return".to_string()); // Set 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)); } else { request.capture_method = Some(i32::from(CaptureMethod::Automatic)); } // Required by Placetopay request.description = Some("Test payment for Placetopay connector".to_string()); request.metadata = HashMap::new(); request }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_authorize_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7085890960054428617
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs fn create_payment_sync_request(transaction_id: &str) -> PaymentServiceGetRequest { PaymentServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), request_ref_id: Some(Identifier { id_type: Some(IdType::Id(format!("placetopay_sync_{}", get_timestamp()))), }), capture_method: None, handle_response: None, amount: TEST_AMOUNT, currency: i32::from(Currency::Usd), state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_sync_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_4583330475245050269
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs fn create_payment_capture_request(transaction_id: &str) -> PaymentServiceCaptureRequest { PaymentServiceCaptureRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), amount_to_capture: TEST_AMOUNT, currency: i32::from(Currency::Usd), multiple_capture_data: None, connector_metadata: HashMap::new(), request_ref_id: None, browser_info: None, capture_method: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_capture_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_4411501932134629534
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs fn create_refund_request(transaction_id: &str) -> PaymentServiceRefundRequest { PaymentServiceRefundRequest { refund_id: format!("refund_{}", get_timestamp()), transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), currency: i32::from(Currency::Usd), payment_amount: TEST_AMOUNT, refund_amount: TEST_AMOUNT, minor_payment_amount: TEST_AMOUNT, minor_refund_amount: TEST_AMOUNT, reason: None, webhook_url: None, metadata: HashMap::new(), refund_metadata: HashMap::new(), browser_info: None, merchant_account_id: None, capture_method: None, request_ref_id: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2281399057436696272
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs fn create_refund_sync_request(transaction_id: &str, refund_id: &str) -> RefundServiceGetRequest { RefundServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), refund_id: refund_id.to_string(), refund_reason: None, browser_info: None, request_ref_id: None, refund_metadata: HashMap::new(), state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_sync_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_6453156545465505913
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs fn create_payment_void_request(transaction_id: &str) -> PaymentServiceVoidRequest { PaymentServiceVoidRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), cancellation_reason: Some("Customer requested cancellation".to_string()), request_ref_id: None, all_keys_required: None, browser_info: None, amount: None, currency: None, ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_void_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-1923340524500855355
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs async fn test_health() { grpc_test!(client, HealthClient<Channel>, { let response = client .check(Request::new(HealthCheckRequest { service: "connector_service".to_string(), })) .await .expect("Failed to call health check") .into_inner(); assert_eq!( response.status(), grpc_api_types::health_check::health_check_response::ServingStatus::Serving ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_health", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-6173925382064794975
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs async fn test_payment_authorization_auto_capture() { grpc_test!(client, PaymentServiceClient<Channel>, { let request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic); let mut grpc_request = Request::new(request); add_placetopay_metadata(&mut grpc_request); let response = client .authorize(grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); assert!( response.transaction_id.is_some(), "Transaction ID should be present" ); let _transaction_id = extract_transaction_id(&response); assert_eq!( response.status, i32::from(PaymentStatus::Charged), "Payment should be in CHARGED state for automatic capture" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authorization_auto_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_726191333064768993
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs async fn test_payment_authorization_manual_capture() { grpc_test!(client, PaymentServiceClient<Channel>, { let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual); let mut auth_grpc_request = Request::new(auth_request); add_placetopay_metadata(&mut auth_grpc_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" ); let _transaction_id = extract_transaction_id(&auth_response); // Placetopay auto-charges payments regardless of capture method setting let acceptable_statuses = [ i32::from(PaymentStatus::Authorized), i32::from(PaymentStatus::Charged), // Placetopay auto-charges ]; assert!( acceptable_statuses.contains(&auth_response.status), "Payment should be in AUTHORIZED or CHARGED state with manual capture, but was: {}", auth_response.status ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authorization_manual_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_6078995008677066830
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs async fn test_payment_sync() { grpc_test!(client, PaymentServiceClient<Channel>, { let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual); let mut auth_grpc_request = Request::new(auth_request); add_placetopay_metadata(&mut auth_grpc_request); let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); let transaction_id = extract_transaction_id(&auth_response); let sync_request = create_payment_sync_request(&transaction_id); let mut sync_grpc_request = Request::new(sync_request); add_placetopay_metadata(&mut sync_grpc_request); let sync_response = client .get(sync_grpc_request) .await .expect("gRPC payment_sync call failed") .into_inner(); // Placetopay auto-charges payments regardless of capture method setting let acceptable_sync_statuses = [ i32::from(PaymentStatus::Authorized), i32::from(PaymentStatus::Pending), i32::from(PaymentStatus::Charged), // Placetopay auto-charges ]; assert!( acceptable_sync_statuses.contains(&sync_response.status), "Payment should be in AUTHORIZED, PENDING, or CHARGED state, but was: {}", sync_response.status ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_sync", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-4077416541843397713
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs async fn test_payment_capture() { grpc_test!(client, PaymentServiceClient<Channel>, { let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual); let mut auth_grpc_request = Request::new(auth_request); add_placetopay_metadata(&mut auth_grpc_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" ); let transaction_id = extract_transaction_id(&auth_response); // Placetopay auto-charges payments even when manual capture is requested if auth_response.status == i32::from(PaymentStatus::Charged) { // Test passed - payment is already captured return; } // If payment is still authorized, attempt capture if auth_response.status == i32::from(PaymentStatus::Authorized) { let capture_request = create_payment_capture_request(&transaction_id); let mut capture_grpc_request = Request::new(capture_request); add_placetopay_metadata(&mut capture_grpc_request); let capture_response = client .capture(capture_grpc_request) .await .expect("gRPC payment_capture call failed") .into_inner(); assert!( capture_response.status == i32::from(PaymentStatus::Charged), "Payment should be in CHARGED state after capture" ); } else { panic!("Unexpected payment status: {}", auth_response.status); } }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-7620005355061820253
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs async fn test_refund() { grpc_test!(client, PaymentServiceClient<Channel>, { let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic); let mut auth_grpc_request = Request::new(auth_request); add_placetopay_metadata(&mut auth_grpc_request); let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); let transaction_id = extract_transaction_id(&auth_response); let acceptable_payment_statuses = [ i32::from(PaymentStatus::Charged), i32::from(PaymentStatus::Pending), ]; assert!( acceptable_payment_statuses.contains(&auth_response.status), "Payment should be in CHARGED or PENDING state before attempting refund, but was: {}", auth_response.status ); let refund_request = create_refund_request(&transaction_id); let mut refund_grpc_request = Request::new(refund_request); add_placetopay_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(); // Placetopay may not support refunds with test credentials if refund_id.is_empty() { // Skip refund test if connector doesn't support refunds properly return; } assert!( refund_response.status == i32::from(RefundStatus::RefundSuccess) || refund_response.status == i32::from(RefundStatus::RefundPending), "Refund should be in SUCCESS or PENDING state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_refund", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-4571690759108519791
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs async fn test_refund_sync() { grpc_test!(client, PaymentServiceClient<Channel>, { grpc_test!(refund_client, RefundServiceClient<Channel>, { let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic); let mut auth_grpc_request = Request::new(auth_request); add_placetopay_metadata(&mut auth_grpc_request); let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); let transaction_id = extract_transaction_id(&auth_response); let refund_request = create_refund_request(&transaction_id); let mut refund_grpc_request = Request::new(refund_request); add_placetopay_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(); // Placetopay may not support refunds with test credentials if refund_id.is_empty() { return; } let refund_sync_request = create_refund_sync_request(&transaction_id, &refund_id); let mut refund_sync_grpc_request = Request::new(refund_sync_request); add_placetopay_metadata(&mut refund_sync_grpc_request); let refund_sync_response = refund_client .get(refund_sync_grpc_request) .await .expect("gRPC refund_sync call failed") .into_inner(); assert!( refund_sync_response.status == i32::from(RefundStatus::RefundPending) || refund_sync_response.status == i32::from(RefundStatus::RefundSuccess), "Refund should be in PENDING or SUCCESS state" ); }); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_refund_sync", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-8547286777163590743
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs async fn test_payment_void() { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment with manual capture (so it stays in authorized state) let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_placetopay_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); // Placetopay auto-charges payments, making void impossible for charged payments if auth_response.status == i32::from(PaymentStatus::Charged) { // Test passed - void not applicable for auto-charged payments return; } // If payment is still authorized, void should work if auth_response.status == i32::from(PaymentStatus::Authorized) { let void_request = create_payment_void_request(&transaction_id); let mut void_grpc_request = Request::new(void_request); add_placetopay_metadata(&mut void_grpc_request); let void_response = client .void(void_grpc_request) .await .expect("gRPC payment_void call failed") .into_inner(); assert!( void_response.status == i32::from(PaymentStatus::Voided), "Payment should be in VOIDED state after void" ); } else { panic!("Unexpected payment status for void: {}", auth_response.status); } }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_void", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2338717047285818765
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs fn build_adyen_webhook_json_body( event_code: &str, reason: &str, adyen_dispute_status: Option<&str>, ) -> serde_json::Value { let mut additional_data = serde_json::Map::new(); if let Some(status) = adyen_dispute_status { additional_data.insert("disputeStatus".to_string(), json!(status)); } let psp_reference = "9915555555555555"; // Default let original_reference = "9913333333333333"; // Default let merchant_account_code = "YOUR_MERCHANT_ACCOUNT"; // Default let merchant_reference = "YOUR_REFERENCE"; // Default let payment_method = "mc"; // Default let amount_currency = "EUR"; // Default let amount_value = 1000; // Default let event_date = "2023-12-01T12:00:00Z"; // Default let success_status = "true"; json!({ "live": "false", "notificationItems": [ { "NotificationRequestItem": { "eventCode": event_code, "success": success_status, "pspReference": psp_reference, "originalReference": original_reference, "merchantAccountCode": merchant_account_code, "merchantReference": merchant_reference, "paymentMethod": payment_method, "eventDate": event_date, "additionalData": additional_data, "reason": reason, "amount": { "value": amount_value, "currency": amount_currency } } } ] }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "build_adyen_webhook_json_body", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-810982133086268311
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs async fn process_webhook_and_get_response( client: &mut PaymentServiceClient<Channel>, json_body: serde_json::Value, ) -> DisputesSyncResponse { let request_body_bytes = serde_json::to_vec(&json_body).expect("Failed to serialize json_body to Vec<u8>"); let mut request = Request::new(PaymentServiceTransformRequest { request_ref_id: Some(grpc_api_types::payments::Identifier { id_type: Some(grpc_api_types::payments::identifier::IdType::Id( "webhook_test".to_string(), )), }), request_details: Some(RequestDetails { method: grpc_api_types::payments::HttpMethod::Post.into(), headers: std::collections::HashMap::new(), uri: Some("/webhooks/adyen".to_string()), query_params: None, body: request_body_bytes, }), webhook_secrets: None, state: None, }); let auth = utils::credential_utils::load_connector_auth("adyen") .expect("Failed to load adyen 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 adyen"), }; request.metadata_mut().append( "x-connector", "adyen".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"), ); let response = client .transform(request) .await .expect("gRPC transform call failed") .into_inner(); match response.content.and_then(|c| c.content) { Some(GrpcWebhookContent::DisputesResponse(dispute_response)) => { DisputesSyncResponse { stage: dispute_response.dispute_stage, status: dispute_response.dispute_status, dispute_message: dispute_response.dispute_message, dispute_id: dispute_response.dispute_id.unwrap_or("".to_string()), // TODO need a fix connector_response_reference_id: None, // TODO need a fix } } _ => { //if the content is not a DisputesResponse, return a dummy DisputesSyncResponse DisputesSyncResponse { stage: 0, status: 0, dispute_message: None, dispute_id: "".to_string(), connector_response_reference_id: None, } } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "process_webhook_and_get_response", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_3276088978534043417
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs async fn test_notification_of_chargeback_undefended() { grpc_test!(client, PaymentServiceClient<Channel>, { let event_code = "NOTIFICATION_OF_CHARGEBACK"; let reason = "Fraudulent transaction"; let adyen_dispute_status = Some("Undefended"); let json_body = build_adyen_webhook_json_body(event_code, reason, adyen_dispute_status); let dispute_response = process_webhook_and_get_response(&mut client, json_body).await; assert_eq!( grpc_api_types::payments::DisputeStage::try_from(dispute_response.stage) .expect("Failed to convert i32 to DisputeStage"), grpc_api_types::payments::DisputeStage::PreDispute ); assert_eq!( GrpcDisputeStatus::try_from(dispute_response.status) .expect("Failed to convert i32 to DisputeStatus"), GrpcDisputeStatus::DisputeOpened ); assert_eq!(dispute_response.dispute_message, Some(reason.to_string())); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_notification_of_chargeback_undefended", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_6294348842367217897
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs async fn test_notification_of_chargeback_pending() { grpc_test!(client, PaymentServiceClient<Channel>, { let event_code = "NOTIFICATION_OF_CHARGEBACK"; let reason = "Product not received"; let adyen_dispute_status = Some("Pending"); let json_body = build_adyen_webhook_json_body(event_code, reason, adyen_dispute_status); let dispute_response = process_webhook_and_get_response(&mut client, json_body).await; assert_eq!( GrpcDisputeStage::try_from(dispute_response.stage) .expect("Failed to convert i32 to DisputeStage"), GrpcDisputeStage::PreDispute ); assert_eq!( GrpcDisputeStatus::try_from(dispute_response.status) .expect("Failed to convert i32 to DisputeStatus"), GrpcDisputeStatus::DisputeOpened ); assert_eq!(dispute_response.dispute_message, Some(reason.to_string())); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_notification_of_chargeback_pending", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-6561497775619879683
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs async fn test_chargeback_undefended() { grpc_test!(client, PaymentServiceClient<Channel>, { let event_code = "CHARGEBACK"; let reason = "Service not rendered"; let adyen_dispute_status = Some("Undefended"); let json_body = build_adyen_webhook_json_body(event_code, reason, adyen_dispute_status); let dispute_response = process_webhook_and_get_response(&mut client, json_body).await; assert_eq!( GrpcDisputeStage::try_from(dispute_response.stage) .expect("Failed to convert i32 to DisputeStage"), GrpcDisputeStage::ActiveDispute ); assert_eq!( GrpcDisputeStatus::try_from(dispute_response.status) .expect("Failed to convert i32 to DisputeStatus"), GrpcDisputeStatus::DisputeOpened ); assert_eq!(dispute_response.dispute_message, Some(reason.to_string())); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_chargeback_undefended", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-643706451557912285
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs async fn test_chargeback_pending() { grpc_test!(client, PaymentServiceClient<Channel>, { let event_code = "CHARGEBACK"; let reason = "Credit not processed"; let adyen_dispute_status = Some("Pending"); let json_body = build_adyen_webhook_json_body(event_code, reason, adyen_dispute_status); let dispute_response = process_webhook_and_get_response(&mut client, json_body).await; assert_eq!( GrpcDisputeStage::try_from(dispute_response.stage) .expect("Failed to convert i32 to DisputeStage"), GrpcDisputeStage::ActiveDispute ); assert_eq!( GrpcDisputeStatus::try_from(dispute_response.status) .expect("Failed to convert i32 to DisputeStatus"), GrpcDisputeStatus::DisputeOpened ); assert_eq!(dispute_response.dispute_message, Some(reason.to_string())); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_chargeback_pending", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7011379223113711137
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs async fn test_chargeback_lost() { grpc_test!(client, PaymentServiceClient<Channel>, { let event_code = "CHARGEBACK"; let reason = "Duplicate transaction"; let adyen_dispute_status = Some("Lost"); let json_body = build_adyen_webhook_json_body(event_code, reason, adyen_dispute_status); let dispute_response = process_webhook_and_get_response(&mut client, json_body).await; assert_eq!( GrpcDisputeStage::try_from(dispute_response.stage) .expect("Failed to convert i32 to DisputeStage"), GrpcDisputeStage::ActiveDispute ); assert_eq!( GrpcDisputeStatus::try_from(dispute_response.status) .expect("Failed to convert i32 to DisputeStatus"), GrpcDisputeStatus::DisputeLost ); assert_eq!(dispute_response.dispute_message, Some(reason.to_string())); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_chargeback_lost", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_2452759132279295282
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs async fn test_chargeback_accepted() { grpc_test!(client, PaymentServiceClient<Channel>, { let event_code = "CHARGEBACK"; let reason = "Fraudulent transaction - merchant accepted"; let adyen_dispute_status = Some("Accepted"); let json_body = build_adyen_webhook_json_body(event_code, reason, adyen_dispute_status); let dispute_response = process_webhook_and_get_response(&mut client, json_body).await; assert_eq!( GrpcDisputeStage::try_from(dispute_response.stage) .expect("Failed to convert i32 to DisputeStage"), GrpcDisputeStage::ActiveDispute ); assert_eq!( GrpcDisputeStatus::try_from(dispute_response.status) .expect("Failed to convert i32 to DisputeStatus"), GrpcDisputeStatus::DisputeAccepted ); assert_eq!(dispute_response.dispute_message, Some(reason.to_string())); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_chargeback_accepted", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_8759111116500764547
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs async fn test_chargeback_reversed_pending() { grpc_test!(client, PaymentServiceClient<Channel>, { let event_code = "CHARGEBACK_REVERSED"; let reason = "Defense successful, awaiting bank review"; let adyen_dispute_status = Some("Pending"); let json_body = build_adyen_webhook_json_body(event_code, reason, adyen_dispute_status); let dispute_response = process_webhook_and_get_response(&mut client, json_body).await; assert_eq!( GrpcDisputeStage::try_from(dispute_response.stage) .expect("Failed to convert i32 to DisputeStage"), GrpcDisputeStage::ActiveDispute ); assert_eq!( GrpcDisputeStatus::try_from(dispute_response.status) .expect("Failed to convert i32 to DisputeStatus"), GrpcDisputeStatus::DisputeChallenged ); assert_eq!(dispute_response.dispute_message, Some(reason.to_string())); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_chargeback_reversed_pending", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1763610019422898052
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs async fn test_chargeback_reversed_won() { grpc_test!(client, PaymentServiceClient<Channel>, { let event_code = "CHARGEBACK_REVERSED"; let reason = "Defense accepted by bank"; let adyen_dispute_status = Some("Won"); let json_body = build_adyen_webhook_json_body(event_code, reason, adyen_dispute_status); let dispute_response = process_webhook_and_get_response(&mut client, json_body).await; assert_eq!( GrpcDisputeStage::try_from(dispute_response.stage) .expect("Failed to convert i32 to DisputeStage"), GrpcDisputeStage::ActiveDispute ); assert_eq!( GrpcDisputeStatus::try_from(dispute_response.status) .expect("Failed to convert i32 to DisputeStatus"), GrpcDisputeStatus::DisputeWon ); assert_eq!(dispute_response.dispute_message, Some(reason.to_string())); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_chargeback_reversed_won", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_2290693391100849548
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs async fn test_second_chargeback_lost() { grpc_test!(client, PaymentServiceClient<Channel>, { let event_code = "SECOND_CHARGEBACK"; let reason = "Defense declined after initial reversal"; let adyen_dispute_status = Some("Lost"); let json_body = build_adyen_webhook_json_body(event_code, reason, adyen_dispute_status); let dispute_response = process_webhook_and_get_response(&mut client, json_body).await; assert_eq!( GrpcDisputeStage::try_from(dispute_response.stage) .expect("Failed to convert i32 to DisputeStage"), GrpcDisputeStage::PreArbitration ); assert_eq!( GrpcDisputeStatus::try_from(dispute_response.status) .expect("Failed to convert i32 to DisputeStatus"), GrpcDisputeStatus::DisputeLost ); assert_eq!(dispute_response.dispute_message, Some(reason.to_string())); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_second_chargeback_lost", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5822541887480379236
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs async fn test_prearbitration_won_with_status_won() { grpc_test!(client, PaymentServiceClient<Channel>, { let event_code = "PREARBITRATION_WON"; let reason = "Pre-arbitration won by merchant"; let adyen_dispute_status = Some("Won"); let json_body = build_adyen_webhook_json_body(event_code, reason, adyen_dispute_status); let dispute_response = process_webhook_and_get_response(&mut client, json_body).await; assert_eq!( GrpcDisputeStage::try_from(dispute_response.stage) .expect("Failed to convert i32 to DisputeStage"), GrpcDisputeStage::PreArbitration ); assert_eq!( GrpcDisputeStatus::try_from(dispute_response.status) .expect("Failed to convert i32 to DisputeStatus"), GrpcDisputeStatus::DisputeWon ); assert_eq!(dispute_response.dispute_message, Some(reason.to_string())); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_prearbitration_won_with_status_won", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_3642135410451944204
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs async fn test_prearbitration_won_with_status_pending() { grpc_test!(client, PaymentServiceClient<Channel>, { let event_code = "PREARBITRATION_WON"; let reason = "Pre-arbitration outcome pending"; let adyen_dispute_status = Some("Pending"); let json_body = build_adyen_webhook_json_body(event_code, reason, adyen_dispute_status); let dispute_response = process_webhook_and_get_response(&mut client, json_body).await; assert_eq!( GrpcDisputeStage::try_from(dispute_response.stage) .expect("Failed to convert i32 to DisputeStage"), GrpcDisputeStage::PreArbitration ); assert_eq!( GrpcDisputeStatus::try_from(dispute_response.status) .expect("Failed to convert i32 to DisputeStatus"), GrpcDisputeStatus::DisputeOpened ); assert_eq!(dispute_response.dispute_message, Some(reason.to_string())); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_prearbitration_won_with_status_pending", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_5552120373384158439
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs async fn test_prearbitration_lost() { grpc_test!(client, PaymentServiceClient<Channel>, { let event_code = "PREARBITRATION_LOST"; let reason = "Pre-arbitration lost by merchant"; let adyen_dispute_status = Some("Lost"); let json_body = build_adyen_webhook_json_body(event_code, reason, adyen_dispute_status); let dispute_response = process_webhook_and_get_response(&mut client, json_body).await; assert_eq!( GrpcDisputeStage::try_from(dispute_response.stage) .expect("Failed to convert i32 to DisputeStage"), GrpcDisputeStage::PreArbitration ); assert_eq!( GrpcDisputeStatus::try_from(dispute_response.status) .expect("Failed to convert i32 to DisputeStatus"), GrpcDisputeStatus::DisputeLost ); assert_eq!(dispute_response.dispute_message, Some(reason.to_string())); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_prearbitration_lost", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7232047093182692648
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs fn get_timestamp() -> u64 { SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_secs() }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_timestamp", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_4706076031612857411
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs fn add_checkout_metadata<T>(request: &mut Request<T>) { let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME) .expect("Failed to load checkout 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 checkout"), }; 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", "test_merchant" .parse() .expect("Failed to parse x-merchant-id"), ); request.metadata_mut().append( "x-tenant-id", "default".parse().expect("Failed to parse x-tenant-id"), ); request.metadata_mut().append( "x-request-id", format!("test_request_{}", get_timestamp()) .parse() .expect("Failed to parse x-request-id"), ); request.metadata_mut().append( "x-connector-request-reference-id", format!("conn_ref_{}", get_timestamp()) .parse() .expect("Failed to parse x-connector-request-reference-id"), ); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "add_checkout_metadata", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_5820732395734419377
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs fn extract_transaction_id(response: &PaymentServiceAuthorizeResponse) -> String { match &response.transaction_id { Some(id) => match id.id_type.as_ref().unwrap() { IdType::Id(id) => id.clone(), _ => panic!("Expected connector transaction ID"), }, None => panic!("Resource ID is None"), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_transaction_id", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_4595777573539780981
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs fn create_payment_authorize_request( capture_method: CaptureMethod, ) -> PaymentServiceAuthorizeRequest { // Select the correct card number based on capture method let card_number = match capture_method { CaptureMethod::Automatic => Some(CardNumber::from_str(AUTO_CAPTURE_CARD_NUMBER).unwrap()), CaptureMethod::Manual => Some(CardNumber::from_str(MANUAL_CAPTURE_CARD_NUMBER).unwrap()), _ => Some(CardNumber::from_str(MANUAL_CAPTURE_CARD_NUMBER).unwrap()), // Default to manual capture card }; let card_details = card_payment_method_type::CardType::Credit(CardDetails { card_number, 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: None, card_type: None, card_issuing_country_alpha2: None, bank_code: None, nick_name: None, }); // Initialize with all required fields 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), })), }), 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!("checkout_test_{}", get_timestamp()))), }), enrolled_for_3ds: false, request_incremental_authorization: false, capture_method: Some(i32::from(capture_method)), metadata: std::collections::HashMap::new(), ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_authorize_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_5336258093730585690
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs fn create_payment_sync_request(transaction_id: &str) -> PaymentServiceGetRequest { PaymentServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), request_ref_id: Some(Identifier { id_type: Some(IdType::Id(format!("checkout_sync_{}", get_timestamp()))), }), capture_method: None, handle_response: None, amount: TEST_AMOUNT, currency: i32::from(Currency::Usd), state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_sync_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_8240227680250458399
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs fn create_payment_capture_request(transaction_id: &str) -> PaymentServiceCaptureRequest { PaymentServiceCaptureRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), amount_to_capture: TEST_AMOUNT, currency: i32::from(Currency::Usd), multiple_capture_data: None, connector_metadata: std::collections::HashMap::new(), request_ref_id: None, browser_info: None, capture_method: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_capture_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2140092786085460549
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs fn create_refund_request(transaction_id: &str) -> PaymentServiceRefundRequest { PaymentServiceRefundRequest { refund_id: format!("refund_{}", get_timestamp()), transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), currency: i32::from(Currency::Usd), payment_amount: TEST_AMOUNT, refund_amount: TEST_AMOUNT, minor_payment_amount: TEST_AMOUNT, minor_refund_amount: TEST_AMOUNT, reason: Some("Test refund".to_string()), webhook_url: None, metadata: std::collections::HashMap::new(), refund_metadata: std::collections::HashMap::new(), browser_info: None, merchant_account_id: None, capture_method: None, request_ref_id: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_137174863991672591
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs fn create_refund_sync_request(transaction_id: &str, refund_id: &str) -> RefundServiceGetRequest { RefundServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), refund_id: refund_id.to_string(), refund_reason: None, request_ref_id: None, browser_info: None, refund_metadata: std::collections::HashMap::new(), state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_sync_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-1230856802125000898
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs fn allow_processing_time() { std::thread::sleep(std::time::Duration::from_secs(3)); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "allow_processing_time", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_8298773930503719867
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs fn create_payment_void_request(transaction_id: &str) -> PaymentServiceVoidRequest { PaymentServiceVoidRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), cancellation_reason: None, request_ref_id: Some(Identifier { id_type: Some(IdType::Id(format!("void_ref_{}", get_timestamp()))), }), all_keys_required: None, browser_info: None, amount: None, currency: None, ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_void_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7801870842629390671
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs async fn test_health() { grpc_test!(client, HealthClient<Channel>, { let response = client .check(Request::new(HealthCheckRequest { service: "connector_service".to_string(), })) .await .expect("Failed to call health check") .into_inner(); assert_eq!( response.status(), grpc_api_types::health_check::health_check_response::ServingStatus::Serving ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_health", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-28809517737214015
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs async fn test_payment_authorization_auto_capture() { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request let request = create_payment_authorize_request(CaptureMethod::Automatic); // Add metadata headers let mut grpc_request = Request::new(request); add_checkout_metadata(&mut grpc_request); // Send the request let response = client .authorize(grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Verify the response assert!( response.transaction_id.is_some(), "Transaction ID should be present" ); // Extract the transaction ID let transaction_id = extract_transaction_id(&response); // Verify payment status - for automatic capture, should be PENDING according to our implementation assert!( response.status == i32::from(PaymentStatus::Pending), "Payment should be in PENDING state for automatic capture before sync" ); // Wait longer for the transaction to be fully processed std::thread::sleep(std::time::Duration::from_secs(10)); // Create sync request with the transaction ID 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_checkout_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(); // After the sync, payment should be in CHARGED state based on connector_meta with Capture intent assert_eq!( sync_response.status, i32::from(PaymentStatus::Charged), "Payment should be in CHARGED state after sync with Capture intent" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authorization_auto_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1187973394456150249
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs async fn test_payment_authorization_manual_capture() { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request with manual capture let auth_request = create_payment_authorize_request(CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_checkout_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); assert!( auth_response.transaction_id.is_some(), "Transaction ID should be present" ); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Verify payment status is authorized (for manual capture, as per our implementation) assert!( auth_response.status == i32::from(PaymentStatus::Authorized), "Payment should be in AUTHORIZED state with manual capture (Authorize intent)" ); // 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_checkout_metadata(&mut capture_grpc_request); // Send the capture request let capture_response = client .capture(capture_grpc_request) .await .expect("gRPC payment_capture call failed") .into_inner(); // Verify payment status is charged after capture assert!( capture_response.status == i32::from(PaymentStatus::Charged), "Payment should be in CHARGED state after capture" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authorization_manual_capture", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7717901774637479810
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs async fn test_payment_sync() { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment to sync let auth_request = create_payment_authorize_request(CaptureMethod::Automatic); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_checkout_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); // Wait longer for the transaction to be processed - some async processing may happen std::thread::sleep(std::time::Duration::from_secs(5)); // Create sync request with the specific transaction ID 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_checkout_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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_5695693638899768234
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs async fn test_refund() { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment with manual capture (same as the script) 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_checkout_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Verify payment status is authorized (for manual capture) assert!( auth_response.status == i32::from(PaymentStatus::Authorized), "Payment should be in AUTHORIZED state with manual capture" ); // Create capture request let capture_request = create_payment_capture_request(&transaction_id); // Add metadata headers for capture request let mut capture_grpc_request = Request::new(capture_request); add_checkout_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" ); // Allow more time for the capture to be processed - increase wait time std::thread::sleep(std::time::Duration::from_secs(5)); // Create refund request with a unique refund_id that includes timestamp let refund_request = create_refund_request(&transaction_id); // Add metadata headers for refund request let mut refund_grpc_request = Request::new(refund_request); add_checkout_metadata(&mut refund_grpc_request); // Send the refund request let refund_response = client .refund(refund_grpc_request) .await .expect("Refund request failed") .into_inner(); // Extract the refund ID let _refund_id = refund_response.refund_id.clone(); // Verify the refund status assert!( refund_response.status == i32::from(RefundStatus::RefundSuccess) || refund_response.status == i32::from(RefundStatus::RefundPending), "Refund should be in SUCCESS or PENDING state" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_refund", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1049752648820201524
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs async fn test_refund_sync() { grpc_test!(client, PaymentServiceClient<Channel>, { grpc_test!(refund_client, RefundServiceClient<Channel>, { // First create a payment with manual capture (same as the script) let auth_request = create_payment_authorize_request(CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_checkout_metadata(&mut auth_grpc_request); // Send the auth request let auth_response = client .authorize(auth_grpc_request) .await .expect("gRPC payment_authorize call failed") .into_inner(); // Extract the transaction ID let transaction_id = extract_transaction_id(&auth_response); // Verify payment status is authorized (for manual capture) assert!( auth_response.status == i32::from(PaymentStatus::Authorized), "Payment should be in AUTHORIZED state with manual capture" ); // Create capture request let capture_request = create_payment_capture_request(&transaction_id); // Add metadata headers for capture request let mut capture_grpc_request = Request::new(capture_request); add_checkout_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" ); // Allow more time for the capture to be processed std::thread::sleep(std::time::Duration::from_secs(5)); // 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_checkout_metadata(&mut refund_grpc_request); // Send the refund request and expect a successful response let refund_response = client .refund(refund_grpc_request) .await .expect("gRPC refund call failed") .into_inner(); // Extract the refund ID let refund_id = refund_response.refund_id.clone(); // Allow more time for the refund to be processed std::thread::sleep(std::time::Duration::from_secs(5)); // 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_checkout_metadata(&mut refund_sync_grpc_request); // Send the refund sync request and expect a successful response let response = refund_client .get(refund_sync_grpc_request) .await .expect("gRPC refund_sync call failed"); let refund_sync_response = response.into_inner(); // Verify the refund sync status assert!( refund_sync_response.status == i32::from(RefundStatus::RefundSuccess) || refund_sync_response.status == i32::from(RefundStatus::RefundPending), "Refund sync should be in SUCCESS or PENDING state" ); }); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_refund_sync", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-115467468143069565
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs async fn test_payment_void() { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment with manual capture to void let auth_request = create_payment_authorize_request(CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_checkout_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" ); // Allow some time for the authorization to be processed allow_processing_time(); // 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_checkout_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" ); // Allow time for void to process allow_processing_time(); // 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_checkout_metadata(&mut sync_grpc_request); // Send the sync request to verify void status let sync_response = client .get(sync_grpc_request) .await .expect("gRPC payment_sync call failed") .into_inner(); // Verify the payment is properly voided assert!( sync_response.status == i32::from(PaymentStatus::Voided), "Payment should be in VOIDED state after void sync" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_void", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_703477179468502883
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs fn build_authorizedotnet_payment_profile_webhook_json_body( event_type: &str, customer_profile_id: u64, payment_profile_id: &str, customer_type: &str, ) -> serde_json::Value { let notification_id = "7201C905-B01E-4622-B807-AC2B646A3815"; // Default let event_date = "2016-03-23T06:19:09.5297562Z"; // Default let webhook_id = "6239A0BE-D8F4-4A33-8FAD-901C02EED51F"; // Default let payload = json!({ "customerProfileId": customer_profile_id, "entityName": "customerPaymentProfile", "id": payment_profile_id, "customerType": customer_type }); json!({ "notificationId": notification_id, "eventType": event_type, "eventDate": event_date, "webhookId": webhook_id, "payload": payload }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "build_authorizedotnet_payment_profile_webhook_json_body", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_5879050093636716450
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs fn build_authorizedotnet_customer_webhook_json_body( event_type: &str, customer_profile_id: &str, payment_profile_id: &str, merchant_customer_id: Option<&str>, description: Option<&str>, ) -> serde_json::Value { let notification_id = "5c3f7e00-1265-4e8e-abd0-a7d734163881"; // Default let event_date = "2016-03-23T05:23:06.5430555Z"; // Default let webhook_id = "0b90f2e8-02ae-4d1d-b2e0-1bd167e60176"; // Default let payload = json!({ "paymentProfiles": [{ "id": payment_profile_id, "customerType": "individual" }], "merchantCustomerId": merchant_customer_id.unwrap_or("cust457"), "description": description.unwrap_or("Profile created by Subscription"), "entityName": "customerProfile", "id": customer_profile_id }); json!({ "notificationId": notification_id, "eventType": event_type, "eventDate": event_date, "webhookId": webhook_id, "payload": payload }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "build_authorizedotnet_customer_webhook_json_body", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2377574083274192817
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs fn build_authorizedotnet_webhook_json_body( event_type: &str, response_code: u8, transaction_id: &str, amount: Option<f64>, merchant_reference_id: Option<&str>, auth_code: Option<&str>, message_text: Option<&str>, ) -> serde_json::Value { let notification_id = "550e8400-e29b-41d4-a716-446655440000"; // Default let event_date = "2023-12-01T12:00:00Z"; // Default let webhook_id = "webhook_123"; // Default let entity_name = "transaction"; // Default let mut payload = json!({ "responseCode": response_code, "entityName": entity_name, "id": transaction_id, }); // Add optional fields if provided if let Some(ref_id) = merchant_reference_id { payload["merchantReferenceId"] = json!(ref_id); } if let Some(auth) = auth_code { payload["authCode"] = json!(auth); } if let Some(amt) = amount { if event_type.contains("authorization") || event_type.contains("authcapture") { payload["authAmount"] = json!(amt); } else if event_type.contains("capture") || event_type.contains("refund") { payload["settleAmount"] = json!(amt); } } if let Some(msg) = message_text { payload["messageText"] = json!(msg); } // Add common fields payload["avsResponse"] = json!("Y"); payload["cvvResponse"] = json!("M"); json!({ "notificationId": notification_id, "eventType": event_type, "eventDate": event_date, "webhookId": webhook_id, "payload": payload }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "build_authorizedotnet_webhook_json_body", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2956507259936022522
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs fn generate_webhook_signature(webhook_body: &[u8], secret: &str) -> String { let crypto_algorithm = HmacSha512; let signature = crypto_algorithm .sign_message(secret.as_bytes(), webhook_body) .expect("Failed to generate signature"); // Convert bytes to hex string manually let mut hex_string = String::with_capacity(signature.len() * 2); for b in signature { write!(&mut hex_string, "{b:02x}").expect("writing to a String should never fail"); } format!("sha512={hex_string}") }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "generate_webhook_signature", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_8305648893872008640
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn process_webhook_request( client: &mut PaymentServiceClient<Channel>, json_body: serde_json::Value, include_signature: bool, ) -> Result<(), String> { let request_body_bytes = serde_json::to_vec(&json_body).expect("Failed to serialize json_body to Vec<u8>"); let mut headers = std::collections::HashMap::new(); // Get webhook_secret from metadata let metadata = utils::credential_utils::load_connector_metadata("authorizedotnet") .expect("Failed to load authorizedotnet metadata"); let webhook_secret = metadata .get("webhook_secret") .expect("webhook_secret not found in authorizedotnet metadata") .clone(); if include_signature { let signature = generate_webhook_signature(&request_body_bytes, &webhook_secret); headers.insert("X-ANET-Signature".to_string(), signature); } let webhook_secrets = Some(grpc_api_types::payments::WebhookSecrets { secret: webhook_secret.clone(), additional_secret: None, }); let mut request = Request::new(PaymentServiceTransformRequest { request_ref_id: Some(grpc_api_types::payments::Identifier { id_type: Some(grpc_api_types::payments::identifier::IdType::Id( "webhook_test".to_string(), )), }), request_details: Some(RequestDetails { method: grpc_api_types::payments::HttpMethod::Post.into(), headers, uri: Some("/webhooks/authorizedotnet".to_string()), query_params: None, body: request_body_bytes, }), webhook_secrets, state: None, }); // Use the same metadata pattern as the payment flows test let auth = utils::credential_utils::load_connector_auth("authorizedotnet") .expect("Failed to load authorizedotnet 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 authorizedotnet"), }; request.metadata_mut().append( "x-connector", "authorizedotnet" .parse() .expect("Failed to parse x-connector"), ); request.metadata_mut().append( "x-auth", "body-key".parse().expect("Failed to parse x-auth"), ); request.metadata_mut().append( "x-api-key", api_key.parse().expect("Failed to parse x-api-key"), ); request .metadata_mut() .append("x-key1", key1.parse().expect("Failed to parse x-key1")); request.metadata_mut().append( "x-merchant-id", "test_merchant" .parse() .expect("Failed to parse x-merchant-id"), ); request.metadata_mut().append( "x-tenant-id", "default".parse().expect("Failed to parse x-tenant-id"), ); request.metadata_mut().append( "x-request-id", "webhook_test_req" .parse() .expect("Failed to parse x-request-id"), ); let _response = client .transform(request) .await .map_err(|e| format!("gRPC transform call failed: {e}"))?; // Response processed successfully // If we get a response, the webhook was processed successfully Ok(()) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "process_webhook_request", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-8454518852040019216
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn test_payment_authorization_approved() { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.authorization.created"; let response_code = 1; // Approved let transaction_id = "60123456789"; let amount = Some(100.50); let auth_code = Some("ABC123"); let message_text = Some("This transaction has been approved."); let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, amount, Some("REF123"), auth_code, message_text, ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; // Check result in assertion below assert!( result.is_ok(), "Payment authorization approved webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authorization_approved", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }