id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
connector-service_body_grpc-server_6474833224344867286
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs // Function: extract_transaction_id { match &response.transaction_id { Some(id) => match id.id_type.as_ref().unwrap() { IdType::Id(id) => id.clone(), _ => panic!("Expected connector transaction ID"), }, None => panic!("Resource ID is None"), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_transaction_id", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_6808827162032027004
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs // Function: create_payment_authorize_request { // Initialize with all required fields let mut request = PaymentServiceAuthorizeRequest::default(); // Set request reference ID let mut request_ref_id = Identifier::default(); request_ref_id.id_type = Some(IdType::Id(format!("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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-8967050789992120169
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs // Function: create_payment_sync_request { PaymentServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), request_ref_id: Some(Identifier { id_type: Some(IdType::Id(format!("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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-2650470818879392351
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs // Function: create_payment_capture_request { PaymentServiceCaptureRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), amount_to_capture: TEST_AMOUNT, currency: i32::from(Currency::Usd), multiple_capture_data: None, connector_metadata: HashMap::new(), request_ref_id: None, browser_info: None, capture_method: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_capture_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-2922098871816672469
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs // Function: create_refund_request { PaymentServiceRefundRequest { refund_id: format!("refund_{}", get_timestamp()), transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), currency: i32::from(Currency::Usd), payment_amount: TEST_AMOUNT, refund_amount: TEST_AMOUNT, minor_payment_amount: TEST_AMOUNT, minor_refund_amount: TEST_AMOUNT, reason: None, webhook_url: None, metadata: HashMap::new(), refund_metadata: HashMap::new(), browser_info: None, merchant_account_id: None, capture_method: None, request_ref_id: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1422767740851790086
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs // Function: create_payment_void_request { PaymentServiceVoidRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), cancellation_reason: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-911773784498730869
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs // Function: test_health { grpc_test!(client, HealthClient<Channel>, { let response = client .check(Request::new(HealthCheckRequest { service: "connector_service".to_string(), })) .await .expect("Failed to call health check") .into_inner(); assert_eq!( response.status(), grpc_api_types::health_check::health_check_response::ServingStatus::Serving ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_health", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_4222945509478044210
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs // Function: test_payment_authorization_auto_capture { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request let request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic); // 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-229242072854148878
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs // Function: test_payment_authorization_manual_capture { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request with manual capture let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual); // 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_5613932586531979458
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs // Function: test_payment_sync { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment to sync let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); add_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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-5231900633774868630
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_3525038909911381947
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-5164936181117676341
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-6856345926885329107
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: add_placetopay_metadata { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-2366563515290863855
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: extract_transaction_id { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_193363765930568766
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: create_payment_authorize_request { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7085890960054428617
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: create_payment_sync_request { PaymentServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), request_ref_id: Some(Identifier { id_type: Some(IdType::Id(format!("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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_4583330475245050269
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: create_payment_capture_request { PaymentServiceCaptureRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), amount_to_capture: TEST_AMOUNT, currency: i32::from(Currency::Usd), multiple_capture_data: None, connector_metadata: HashMap::new(), request_ref_id: None, browser_info: None, capture_method: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_capture_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_4411501932134629534
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: create_refund_request { PaymentServiceRefundRequest { refund_id: format!("refund_{}", get_timestamp()), transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), currency: i32::from(Currency::Usd), payment_amount: TEST_AMOUNT, refund_amount: TEST_AMOUNT, minor_payment_amount: TEST_AMOUNT, minor_refund_amount: TEST_AMOUNT, reason: None, webhook_url: None, metadata: HashMap::new(), refund_metadata: HashMap::new(), browser_info: None, merchant_account_id: None, capture_method: None, request_ref_id: None, state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-2281399057436696272
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: create_refund_sync_request { RefundServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), refund_id: refund_id.to_string(), refund_reason: None, browser_info: None, request_ref_id: None, refund_metadata: HashMap::new(), state: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_refund_sync_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_6453156545465505913
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: create_payment_void_request { PaymentServiceVoidRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), cancellation_reason: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-1923340524500855355
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: test_health { grpc_test!(client, HealthClient<Channel>, { let response = client .check(Request::new(HealthCheckRequest { service: "connector_service".to_string(), })) .await .expect("Failed to call health check") .into_inner(); assert_eq!( response.status(), grpc_api_types::health_check::health_check_response::ServingStatus::Serving ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_health", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-6173925382064794975
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_726191333064768993
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_6078995008677066830
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4077416541843397713
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-7620005355061820253
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4571690759108519791
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-8547286777163590743
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/placetopay_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-2338717047285818765
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: build_adyen_webhook_json_body { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-810982133086268311
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: process_webhook_and_get_response { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_3276088978534043417
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_6294348842367217897
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-6561497775619879683
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-643706451557912285
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7011379223113711137
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_2452759132279295282
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_8759111116500764547
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1763610019422898052
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_2290693391100849548
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-5822541887480379236
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_3642135410451944204
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_5552120373384158439
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/adyen_dispute_webhook_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_4706076031612857411
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: add_checkout_metadata { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_5820732395734419377
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: extract_transaction_id { match &response.transaction_id { Some(id) => match id.id_type.as_ref().unwrap() { IdType::Id(id) => id.clone(), _ => panic!("Expected connector transaction ID"), }, None => panic!("Resource ID is None"), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_transaction_id", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_4595777573539780981
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: create_payment_authorize_request { // 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_5336258093730585690
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: create_payment_sync_request { PaymentServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), request_ref_id: Some(Identifier { id_type: Some(IdType::Id(format!("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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_8240227680250458399
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: create_payment_capture_request { PaymentServiceCaptureRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), amount_to_capture: TEST_AMOUNT, currency: i32::from(Currency::Usd), multiple_capture_data: None, 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-2140092786085460549
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: create_refund_request { PaymentServiceRefundRequest { refund_id: format!("refund_{}", get_timestamp()), transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), currency: i32::from(Currency::Usd), payment_amount: TEST_AMOUNT, refund_amount: TEST_AMOUNT, minor_payment_amount: TEST_AMOUNT, minor_refund_amount: TEST_AMOUNT, reason: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_137174863991672591
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: create_refund_sync_request { RefundServiceGetRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), refund_id: refund_id.to_string(), refund_reason: None, 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_8298773930503719867
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: create_payment_void_request { PaymentServiceVoidRequest { transaction_id: Some(Identifier { id_type: Some(IdType::Id(transaction_id.to_string())), }), cancellation_reason: None, request_ref_id: Some(Identifier { id_type: Some(IdType::Id(format!("void_ref_{}", get_timestamp()))), }), all_keys_required: None, browser_info: None, amount: None, currency: None, ..Default::default() } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_payment_void_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7801870842629390671
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: test_health { grpc_test!(client, HealthClient<Channel>, { let response = client .check(Request::new(HealthCheckRequest { service: "connector_service".to_string(), })) .await .expect("Failed to call health check") .into_inner(); assert_eq!( response.status(), grpc_api_types::health_check::health_check_response::ServingStatus::Serving ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_health", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-28809517737214015
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: test_payment_authorization_auto_capture { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request let request = create_payment_authorize_request(CaptureMethod::Automatic); // Add metadata headers let mut grpc_request = Request::new(request); add_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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1187973394456150249
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: test_payment_authorization_manual_capture { grpc_test!(client, PaymentServiceClient<Channel>, { // Create the payment authorization request with manual capture let auth_request = create_payment_authorize_request(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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7717901774637479810
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: test_payment_sync { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment to sync let auth_request = create_payment_authorize_request(CaptureMethod::Automatic); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_5695693638899768234
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1049752648820201524
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-115467468143069565
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/checkout_payment_flows_test.rs // Function: test_payment_void { grpc_test!(client, PaymentServiceClient<Channel>, { // First create a payment with manual capture to void let auth_request = create_payment_authorize_request(CaptureMethod::Manual); // Add metadata headers for auth request let mut auth_grpc_request = Request::new(auth_request); 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_703477179468502883
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: build_authorizedotnet_payment_profile_webhook_json_body { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_5879050093636716450
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: build_authorizedotnet_customer_webhook_json_body { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-2377574083274192817
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: build_authorizedotnet_webhook_json_body { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-2956507259936022522
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: generate_webhook_signature { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_8305648893872008640
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: process_webhook_request { 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-8454518852040019216
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: 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": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-1195284913643216819
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_authorization_declined { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.authorization.created"; let response_code = 2; // Declined let transaction_id = "60123456790"; let message_text = Some("This transaction has been declined."); let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, None, Some("REF124"), None, message_text, ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment authorization declined webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authorization_declined", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-9023330362309175828
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_authorization_held { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.authorization.created"; let response_code = 4; // Held for review let transaction_id = "60123456791"; let message_text = Some("This transaction is being held for review."); let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, Some(75.25), Some("REF125"), None, message_text, ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment authorization held webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authorization_held", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-2197385030546999586
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_authcapture_approved { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.authcapture.created"; let response_code = 1; // Approved let transaction_id = "60123456792"; let amount = Some(200.00); let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, amount, Some("REF126"), Some("XYZ789"), Some("This transaction has been approved."), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment authcapture approved webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authcapture_approved", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_4054078324515054841
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_authcapture_declined { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.authcapture.created"; let response_code = 2; // Declined let transaction_id = "60123456793"; let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, None, Some("REF127"), None, Some("This transaction has been declined."), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment authcapture declined webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authcapture_declined", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1846606794386089532
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_authcapture_held { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.authcapture.created"; let response_code = 4; // Held for review let transaction_id = "60123456794"; let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, Some(150.75), Some("REF128"), None, Some("This transaction is being held for review."), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment authcapture held webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_authcapture_held", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_8619828451467589771
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_capture_approved { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.capture.created"; let response_code = 1; // Approved let transaction_id = "60123456795"; let amount = Some(100.00); let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, amount, Some("REF129"), None, Some("This transaction has been captured."), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment capture approved webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_capture_approved", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4819681515814303589
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_capture_declined { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.capture.created"; let response_code = 2; // Declined let transaction_id = "60123456796"; let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, None, Some("REF130"), None, Some("This capture has been declined."), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment capture declined webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_capture_declined", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-8828684149653912756
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_void_approved { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.void.created"; let response_code = 1; // Approved let transaction_id = "60123456797"; let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, None, Some("REF131"), None, Some("This transaction has been voided."), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment void approved webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_void_approved", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1819545801148407365
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_void_failed { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.void.created"; let response_code = 2; // Failed let transaction_id = "60123456798"; let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, None, Some("REF132"), None, Some("This void has failed."), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment void failed webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_void_failed", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-1188403364202903403
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_prior_auth_capture_approved { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.priorAuthCapture.created"; let response_code = 1; // Approved let transaction_id = "60123456799"; let amount = Some(85.50); let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, amount, Some("REF133"), None, Some("This prior authorization capture has been approved."), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment prior auth capture approved webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_prior_auth_capture_approved", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-8002912689017333135
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_prior_auth_capture_declined { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.priorAuthCapture.created"; let response_code = 2; // Declined let transaction_id = "60123456800"; let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, None, Some("REF134"), None, Some("This prior authorization capture has been declined."), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment prior auth capture declined webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_prior_auth_capture_declined", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-8270919732520877127
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_refund_approved { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.refund.created"; let response_code = 1; // Approved let transaction_id = "60123456801"; let amount = Some(50.25); let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, amount, Some("REF135"), None, Some("This refund has been approved."), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment refund approved webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_refund_approved", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7933279977396257378
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_refund_declined { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.refund.created"; let response_code = 2; // Declined let transaction_id = "60123456802"; let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, None, Some("REF136"), None, Some("This refund has been declined."), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment refund declined webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_refund_declined", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_221061400862828105
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_payment_refund_held { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.refund.created"; let response_code = 4; // Held for review let transaction_id = "60123456803"; let amount = Some(25.00); let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, amount, Some("REF137"), None, Some("This refund is being held for review."), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Payment refund held webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_payment_refund_held", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_6587451462553560
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_webhook_signature_verification_valid { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.authorization.created"; let response_code = 1; let transaction_id = "60123456804"; let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, Some(100.0), Some("REF138"), Some("ABC123"), Some("Valid signature test."), ); // This should succeed with valid signature let result = process_webhook_request(&mut client, json_body, true).await; assert!(result.is_ok(), "Valid signature should be accepted"); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_webhook_signature_verification_valid", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_9051257252490488269
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_webhook_missing_signature { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.authorization.created"; let response_code = 1; let transaction_id = "60123456806"; let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, Some(100.0), Some("REF140"), Some("ABC123"), Some("Missing signature test."), ); // Process without signature - the gRPC server requires signatures even when verification is not mandatory let result = process_webhook_request(&mut client, json_body, false).await; // The gRPC server returns "Signature not found" when no signature is provided // This is expected behavior even though verification is not mandatory for Authorize.Net match result { Ok(_) => { // If it succeeds, that's fine - the system handled missing signature gracefully } Err(e) => { // Expect signature not found error assert!( e.contains("Signature not found for incoming webhook"), "Expected 'Signature not found' error but got: {e}" ); } } }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_webhook_missing_signature", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-1954193537915659751
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_webhook_malformed_body { grpc_test!(client, PaymentServiceClient<Channel>, { let malformed_json = json!({ "invalid": "structure", "missing": "required_fields" }); let request_body_bytes = serde_json::to_vec(&malformed_json).expect("Failed to serialize malformed json"); 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/authorizedotnet".to_string()), query_params: None, body: request_body_bytes, }), webhook_secrets: None, state: None, }); let auth = utils::credential_utils::load_connector_auth("authorizedotnet") .expect("Failed to load authorizedotnet credentials"); let api_key = match auth { domain_types::router_data::ConnectorAuthType::BodyKey { api_key, .. } => { api_key.expose() } _ => panic!("Expected BodyKey auth type for authorizedotnet"), }; // Get transaction_key from metadata let metadata = utils::credential_utils::load_connector_metadata("authorizedotnet") .expect("Failed to load authorizedotnet metadata"); let transaction_key = metadata .get("transaction_key") .expect("transaction_key not found in authorizedotnet metadata") .clone(); request.metadata_mut().append( "x-connector", "authorizedotnet" .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-transaction-key", transaction_key .parse() .expect("Failed to parse x-transaction-key"), ); // This should fail due to malformed body let response = client.transform(request).await; // We expect this to fail or return an error response match response { Ok(_resp) => { // If it succeeds, the response should indicate parsing failure // We'll accept this as the system handled it gracefully } Err(_) => { // This is expected - malformed body should cause failure } } }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_webhook_malformed_body", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-3066266767033294047
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_customer_created_approved { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.customer.created"; let customer_profile_id = "394"; let payment_profile_id = "694"; let json_body = build_authorizedotnet_customer_webhook_json_body( event_type, customer_profile_id, payment_profile_id, Some("cust457"), Some("Profile created by Subscription: 1447"), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Customer created webhook should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_customer_created_approved", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_5551554661721760779
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_customer_created_with_different_customer_id { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.customer.created"; let customer_profile_id = "395"; let payment_profile_id = "695"; let json_body = build_authorizedotnet_customer_webhook_json_body( event_type, customer_profile_id, payment_profile_id, Some("cust458"), Some("Profile created for mandate setup"), ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Customer creation webhook with different ID should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_customer_created_with_different_customer_id", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-7532320274900399331
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_customer_payment_profile_created_individual { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.customer.paymentProfile.created"; let customer_profile_id = 394; let payment_profile_id = "694"; let customer_type = "individual"; let json_body = build_authorizedotnet_payment_profile_webhook_json_body( event_type, customer_profile_id, payment_profile_id, customer_type, ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Customer payment profile created webhook for individual should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_customer_payment_profile_created_individual", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1024572921489789549
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_customer_payment_profile_created_business { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.customer.paymentProfile.created"; let customer_profile_id = 395; let payment_profile_id = "695"; let customer_type = "business"; let json_body = build_authorizedotnet_payment_profile_webhook_json_body( event_type, customer_profile_id, payment_profile_id, customer_type, ); // Test that webhook processing succeeds let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Customer payment profile created webhook for business should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_customer_payment_profile_created_business", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_5056199700254575243
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_webhook_unknown_event_type { grpc_test!(client, PaymentServiceClient<Channel>, { let unknown_event_type = "net.authorize.unknown.event.type"; let response_code = 1; let transaction_id = "60123456807"; let json_body = build_authorizedotnet_webhook_json_body( unknown_event_type, response_code, transaction_id, Some(100.0), Some("REF141"), Some("ABC123"), Some("Unknown event type test."), ); let result = process_webhook_request(&mut client, json_body, true).await; // The system should handle unknown event types gracefully // This could either succeed with a default handling or fail gracefully match result { Ok(()) => { // System handled unknown event type gracefully } Err(_) => { // System appropriately rejected unknown event type } } }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_webhook_unknown_event_type", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7473656802158035898
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_webhook_source_verification_valid_signature { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.authorization.created"; let response_code = 1; let transaction_id = "60123456808"; let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, Some(100.0), Some("REF142"), Some("ABC123"), Some("Valid signature verification test."), ); // Test with valid signature - the helper function already generates correct signatures let result = process_webhook_request(&mut client, json_body, true).await; assert!( result.is_ok(), "Webhook with valid signature should be processed successfully" ); }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_webhook_source_verification_valid_signature", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-7003069592166008417
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_webhook_source_verification_invalid_signature { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.authorization.created"; let response_code = 1; let transaction_id = "60123456809"; let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, Some(100.0), Some("REF143"), Some("ABC123"), Some("Invalid signature verification test."), ); 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(); // Add an invalid signature headers.insert( "X-ANET-Signature".to_string(), "sha512=invalidhexsignature".to_string(), ); // 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(); 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, }); 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"), ); // This should still process the webhook but with source_verified = false let response = client.transform(request).await; assert!( response.is_ok(), "Webhook with invalid signature should still be processed" ); // Note: The response should have source_verified = false, but UCS continues processing }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_webhook_source_verification_invalid_signature", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_4847658437013322577
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_webhook_source_verification_missing_signature { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.authorization.created"; let response_code = 1; let transaction_id = "60123456810"; let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, Some(100.0), Some("REF144"), Some("ABC123"), Some("Missing signature verification test."), ); let request_body_bytes = serde_json::to_vec(&json_body).expect("Failed to serialize json_body to Vec<u8>"); // Don't add any signature header let 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(); 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, }); 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"), ); // This should still process the webhook but with source_verified = false let response = client.transform(request).await; assert!( response.is_ok(), "Webhook without signature should still be processed" ); // Note: The response should have source_verified = false, but UCS continues processing }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_webhook_source_verification_missing_signature", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-5276036055561152114
clm
function_body
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs // Function: test_webhook_source_verification_no_secret_provided { grpc_test!(client, PaymentServiceClient<Channel>, { let event_type = "net.authorize.payment.authorization.created"; let response_code = 1; let transaction_id = "60123456811"; let json_body = build_authorizedotnet_webhook_json_body( event_type, response_code, transaction_id, Some(100.0), Some("REF145"), Some("ABC123"), Some("No secret provided verification test."), ); 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(); headers.insert( "X-ANET-Signature".to_string(), "sha512=somesignature".to_string(), ); // Don't provide webhook secrets (None) let webhook_secrets = 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, }); 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"), ); // This should process the webhook with source_verified = false (no secret to verify against) let response = client.transform(request).await; assert!( response.is_ok(), "Webhook without webhook secret should still be processed" ); // Note: The response should have source_verified = false, but UCS continues processing }); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "test_webhook_source_verification_no_secret_provided", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1169013752174622920
clm
function_body
// connector-service/backend/grpc-server/src/request.rs // Function: from_grpc_request { let (metadata, extensions, payload) = request.into_parts(); // Construct MetadataPayload from raw metadata (existing functions need it) let metadata_payload = get_metadata_payload(&metadata, config.clone()).into_grpc_status()?; // Pass tonic metadata and config to MaskedMetadata let masked_metadata = MaskedMetadata::new(metadata, config.unmasked_headers.clone()); Ok(Self { payload, extracted_metadata: metadata_payload, masked_metadata, extensions, }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from_grpc_request", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4638357111146167043
clm
function_body
// connector-service/backend/grpc-server/src/error.rs // Function: switch { match self { Self::HeaderMapConstructionFailed | Self::InvalidProxyConfiguration | Self::ClientConstructionFailed | Self::CertificateDecodeFailed | Self::BodySerializationFailed | Self::UnexpectedState | Self::UrlEncodingFailed | Self::RequestNotSent(_) | Self::ResponseDecodingFailed | Self::InternalServerErrorReceived | Self::BadGatewayReceived | Self::ServiceUnavailableReceived | Self::UrlParsingFailed | Self::UnexpectedServerResponse => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "INTERNAL_SERVER_ERROR".to_string(), error_identifier: 500, error_message: self.to_string(), error_object: None, }) } Self::RequestTimeoutReceived | Self::GatewayTimeoutReceived => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "REQUEST_TIMEOUT".to_string(), error_identifier: 504, error_message: self.to_string(), error_object: None, }) } Self::ConnectionClosedIncompleteMessage => { ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "INTERNAL_SERVER_ERROR".to_string(), error_identifier: 500, error_message: self.to_string(), error_object: None, }) } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "switch", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-4393861171365267638
clm
function_body
// connector-service/backend/grpc-server/src/error.rs // Function: into_grpc_status { logger::error!(error=?self); match self.current_context() { ApplicationErrorResponse::Unauthorized(api_error) => { Status::unauthenticated(&api_error.error_message) } ApplicationErrorResponse::ForbiddenCommonResource(api_error) | ApplicationErrorResponse::ForbiddenPrivateResource(api_error) => { Status::permission_denied(&api_error.error_message) } ApplicationErrorResponse::Conflict(api_error) | ApplicationErrorResponse::Gone(api_error) | ApplicationErrorResponse::Unprocessable(api_error) | ApplicationErrorResponse::InternalServerError(api_error) | ApplicationErrorResponse::MethodNotAllowed(api_error) | ApplicationErrorResponse::DomainError(api_error) => { Status::internal(&api_error.error_message) } ApplicationErrorResponse::NotImplemented(api_error) => { Status::unimplemented(&api_error.error_message) } ApplicationErrorResponse::NotFound(api_error) => { Status::not_found(&api_error.error_message) } ApplicationErrorResponse::BadRequest(api_error) => { Status::invalid_argument(&api_error.error_message) } } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "into_grpc_status", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_7986719775498184719
clm
function_body
// connector-service/backend/grpc-server/src/error.rs // Function: new { Self { status, error_message, error_code, status_code, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "new", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_3131108957424278738
clm
function_body
// connector-service/backend/grpc-server/src/error.rs // Function: from { Self { transaction_id: None, redirection_data: None, network_txn_id: None, response_ref_id: None, incremental_authorization_allowed: None, status: error.status.into(), error_message: error.error_message, error_code: error.error_code, status_code: error.status_code.unwrap_or(500), response_headers: std::collections::HashMap::new(), connector_metadata: std::collections::HashMap::new(), raw_connector_response: None, raw_connector_request: None, state: None, mandate_reference: None, minor_amount_capturable: None, minor_captured_amount: None, captured_amount: None, connector_response: None, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "from", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-5178415969516707214
clm
function_body
// connector-service/backend/grpc-server/src/configs.rs // Function: validate { let Self { environment } = self; match environment { consts::Env::Development | consts::Env::Production | consts::Env::Sandbox => Ok(()), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "validate", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-3725551289089815187
clm
function_body
// connector-service/backend/grpc-server/src/configs.rs // Function: new_with_config_path { let env = consts::Env::current_env(); let config_path = Self::config_path(&env, explicit_config_path); let config = Self::builder(&env)? .add_source(config::File::from(config_path).required(false)) .add_source( config::Environment::with_prefix(consts::ENV_PREFIX) .try_parsing(true) .separator("__") .list_separator(",") .with_list_parse_key("proxy.bypass_proxy_urls") .with_list_parse_key("redis.cluster_urls") .with_list_parse_key("database.tenants") .with_list_parse_key("log.kafka.brokers") .with_list_parse_key("events.brokers") .with_list_parse_key("unmasked_headers.keys"), ) .build()?; #[allow(clippy::print_stderr)] let config: Self = serde_path_to_error::deserialize(config).map_err(|error| { eprintln!("Unable to deserialize application configuration: {error}"); error.into_inner() })?; // Validate the environment field config.common.validate()?; Ok(config) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "new_with_config_path", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-5479896815067414845
clm
function_body
// connector-service/backend/grpc-server/src/configs.rs // Function: builder { config::Config::builder() // Here, it should be `set_override()` not `set_default()`. // "env" can't be altered by config field. // Should be single source of truth. .set_override("env", environment.to_string()) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "builder", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_-7800825469119508484
clm
function_body
// connector-service/backend/grpc-server/src/configs.rs // Function: config_path { let mut config_path = PathBuf::new(); if let Some(explicit_config_path_val) = explicit_config_path { config_path.push(explicit_config_path_val); } else { let config_directory: String = "config".into(); let config_file_name = environment.config_path(); config_path.push(workspace_path()); config_path.push(config_directory); config_path.push(config_file_name); } config_path }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "config_path", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_body_grpc-server_1717037988323564786
clm
function_body
// connector-service/backend/grpc-server/src/configs.rs // Function: tcp_listener { let loc = format!("{}:{}", self.host, self.port); tracing::info!(loc = %loc, "binding the server"); Ok(tokio::net::TcpListener::bind(loc).await?) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "tcp_listener", "is_async": null, "is_pub": null, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }