id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
connector-service_fn_grpc-server_-1195284913643216819
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-9023330362309175828
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2197385030546999586
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_4054078324515054841
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1846606794386089532
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_8619828451467589771
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-4819681515814303589
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-8828684149653912756
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1819545801148407365
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-1188403364202903403
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-8002912689017333135
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-8270919732520877127
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7933279977396257378
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_221061400862828105
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_6587451462553560
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_9051257252490488269
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-1954193537915659751
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-3066266767033294047
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_5551554661721760779
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-7532320274900399331
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1024572921489789549
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_5056199700254575243
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7473656802158035898
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-7003069592166008417
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_4847658437013322577
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5276036055561152114
clm
function
// connector-service/backend/grpc-server/tests/beta_tests/authorizedotnet_webhook_test.rs async fn 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1169013752174622920
clm
function
// connector-service/backend/grpc-server/src/request.rs pub fn from_grpc_request( request: tonic::Request<T>, config: Arc<configs::Config>, ) -> Result<Self, tonic::Status> { 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": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-4638357111146167043
clm
function
// connector-service/backend/grpc-server/src/error.rs fn switch(&self) -> ApplicationErrorResponse { 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-4393861171365267638
clm
function
// connector-service/backend/grpc-server/src/error.rs fn into_grpc_status(self) -> 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7986719775498184719
clm
function
// connector-service/backend/grpc-server/src/error.rs pub fn new( status: grpc_api_types::payments::PaymentStatus, error_message: Option<String>, error_code: Option<String>, status_code: Option<u32>, ) -> Self { 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": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_3131108957424278738
clm
function
// connector-service/backend/grpc-server/src/error.rs fn from(error: PaymentAuthorizationError) -> Self { 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": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-8244970675214033374
clm
function
// connector-service/backend/grpc-server/src/configs.rs fn default_lineage_header() -> String { consts::X_LINEAGE_IDS.to_string() }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "default_lineage_header", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_3968942359404451408
clm
function
// connector-service/backend/grpc-server/src/configs.rs fn default_lineage_prefix() -> String { consts::LINEAGE_FIELD_PREFIX.to_string() }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "default_lineage_prefix", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5178415969516707214
clm
function
// connector-service/backend/grpc-server/src/configs.rs pub fn validate(&self) -> Result<(), config::ConfigError> { 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": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-3501582698624187340
clm
function
// connector-service/backend/grpc-server/src/configs.rs pub fn new() -> Result<Self, config::ConfigError> { Self::new_with_config_path(None) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "new", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-3725551289089815187
clm
function
// connector-service/backend/grpc-server/src/configs.rs pub fn new_with_config_path( explicit_config_path: Option<PathBuf>, ) -> Result<Self, config::ConfigError> { 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": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5479896815067414845
clm
function
// connector-service/backend/grpc-server/src/configs.rs pub fn builder( environment: &consts::Env, ) -> Result<config::ConfigBuilder<config::builder::DefaultState>, config::ConfigError> { 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": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-7800825469119508484
clm
function
// connector-service/backend/grpc-server/src/configs.rs pub fn config_path( environment: &consts::Env, explicit_config_path: Option<PathBuf>, ) -> PathBuf { 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": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1717037988323564786
clm
function
// connector-service/backend/grpc-server/src/configs.rs pub async fn tcp_listener(&self) -> Result<tokio::net::TcpListener, ConfigurationError> { 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": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-820437466479820270
clm
function
// connector-service/backend/grpc-server/src/configs.rs pub fn workspace_path() -> PathBuf { if let Ok(manifest_dir) = std::env::var("CARGO_MANIFEST_DIR") { let mut path = PathBuf::from(manifest_dir); path.pop(); path.pop(); path } else { PathBuf::from(".") } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "workspace_path", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5507837353711763143
clm
function
// connector-service/backend/grpc-server/src/main.rs async fn main() -> Result<(), Box<dyn std::error::Error>> { #[cfg(debug_assertions)] verify_other_config_files(); #[allow(clippy::expect_used)] let config = configs::Config::new().expect("Failed while parsing config"); let _guard = logger::setup( &config.log, grpc_server::service_name!(), [grpc_server::service_name!(), "grpc_server", "tower_http"], ); let metrics_server = app::metrics_server_builder(config.clone()); let server = app::server_builder(config); #[allow(clippy::expect_used)] tokio::try_join!(metrics_server, server)?; Ok(()) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "main", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_697788479093399678
clm
function
// connector-service/backend/grpc-server/src/main.rs fn verify_other_config_files() { use std::path::PathBuf; use crate::configs; let config_file_names = vec!["production.toml", "sandbox.toml"]; let mut config_path = PathBuf::new(); config_path.push(configs::workspace_path()); let config_directory: String = "config".into(); config_path.push(config_directory); for config_file_name in config_file_names { config_path.push(config_file_name); #[allow(clippy::panic)] let _ = configs::Config::new_with_config_path(Some(config_path.clone())) .unwrap_or_else(|_| panic!("Update {config_file_name} with the default config values")); config_path.pop(); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "verify_other_config_files", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_6289209603787135910
clm
function
// connector-service/backend/grpc-server/src/app.rs pub async fn server_builder(config: configs::Config) -> Result<(), ConfigurationError> { let server_config = config.server.clone(); let socket_addr = net::SocketAddr::new(server_config.host.parse()?, server_config.port); // Signal handler let (tx, rx) = oneshot::channel(); #[allow(clippy::expect_used)] tokio::spawn(async move { let mut sig_int = signal(SignalKind::interrupt()).expect("Failed to initialize SIGINT signal handler"); let mut sig_term = signal(SignalKind::terminate()).expect("Failed to initialize SIGTERM signal handler"); let mut sig_quit = signal(SignalKind::quit()).expect("Failed to initialize QUIT signal handler"); let mut sig_hup = signal(SignalKind::hangup()).expect("Failed to initialize SIGHUP signal handler"); tokio::select! { _ = sig_int.recv() => { logger::info!("Received SIGINT"); tx.send(()).expect("Failed to send SIGINT signal"); } _ = sig_term.recv() => { logger::info!("Received SIGTERM"); tx.send(()).expect("Failed to send SIGTERM signal"); } _ = sig_quit.recv() => { logger::info!("Received QUIT"); tx.send(()).expect("Failed to send QUIT signal"); } _ = sig_hup.recv() => { logger::info!("Received SIGHUP"); tx.send(()).expect("Failed to send SIGHUP signal"); } } }); #[allow(clippy::expect_used)] let shutdown_signal = async { rx.await.expect("Failed to receive shutdown signal"); logger::info!("Shutdown signal received"); }; let service = Service::new(Arc::new(config)); logger::info!(host = %server_config.host, port = %server_config.port, r#type = ?server_config.type_, "starting connector service"); match server_config.type_ { configs::ServiceType::Grpc => { service .await .grpc_server(socket_addr, shutdown_signal) .await? } configs::ServiceType::Http => { service .await .http_server(socket_addr, shutdown_signal) .await? } } Ok(()) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "server_builder", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-7385361255211914550
clm
function
// connector-service/backend/grpc-server/src/app.rs pub async fn new(config: Arc<configs::Config>) -> Self { // Initialize the global EventPublisher - fail fast on startup if config.events.enabled { common_utils::init_event_publisher(&config.events) .expect("Failed to initialize global EventPublisher during startup"); logger::info!("Global EventPublisher initialized successfully"); } else { logger::info!("EventPublisher disabled in configuration"); } Self { health_check_service: crate::server::health_check::HealthCheck, payments_service: crate::server::payments::Payments { config: Arc::clone(&config), }, refunds_service: crate::server::refunds::Refunds { config: Arc::clone(&config), }, disputes_service: crate::server::disputes::Disputes { config }, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "new", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1459415815262552632
clm
function
// connector-service/backend/grpc-server/src/app.rs pub async fn http_server( self, socket: net::SocketAddr, shutdown_signal: impl Future<Output = ()> + Send + 'static, ) -> Result<(), ConfigurationError> { let logging_layer = tower_trace::TraceLayer::new_for_http() .make_span_with(|request: &Request<_>| utils::record_fields_from_header(request)) .on_request(tower_trace::DefaultOnRequest::new().level(tracing::Level::INFO)) .on_response( tower_trace::DefaultOnResponse::new() .level(tracing::Level::INFO) .latency_unit(tower_http::LatencyUnit::Micros), ) .on_failure( tower_trace::DefaultOnFailure::new() .latency_unit(tower_http::LatencyUnit::Micros) .level(tracing::Level::ERROR), ); let request_id_layer = tower_http::request_id::SetRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), MakeRequestUuid, ); let propagate_request_id_layer = tower_http::request_id::PropagateRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), ); let router = axum::Router::new() .route("/health", axum::routing::get(|| async { "health is good" })) .merge(payment_service_handler(self.payments_service)) .merge(refund_service_handler(self.refunds_service)) .merge(dispute_service_handler(self.disputes_service)) .layer(logging_layer) .layer(request_id_layer) .layer(propagate_request_id_layer); let listener = tokio::net::TcpListener::bind(socket).await?; axum::serve(listener, router.into_make_service()) .with_graceful_shutdown(shutdown_signal) .await?; Ok(()) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "http_server", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-4334339212374080029
clm
function
// connector-service/backend/grpc-server/src/app.rs pub async fn grpc_server( self, socket: net::SocketAddr, shutdown_signal: impl Future<Output = ()>, ) -> Result<(), ConfigurationError> { let reflection_service = tonic_reflection::server::Builder::configure() .register_encoded_file_descriptor_set(grpc_api_types::FILE_DESCRIPTOR_SET) .build_v1()?; let logging_layer = tower_trace::TraceLayer::new_for_http() .make_span_with(|request: &http::request::Request<_>| { utils::record_fields_from_header(request) }) .on_request(tower_trace::DefaultOnRequest::new().level(tracing::Level::INFO)) .on_response( tower_trace::DefaultOnResponse::new() .level(tracing::Level::INFO) .latency_unit(tower_http::LatencyUnit::Micros), ) .on_failure( tower_trace::DefaultOnFailure::new() .latency_unit(tower_http::LatencyUnit::Micros) .level(tracing::Level::ERROR), ); let metrics_layer = metrics::GrpcMetricsLayer::new(); let request_id_layer = tower_http::request_id::SetRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), MakeRequestUuid, ); let propagate_request_id_layer = tower_http::request_id::PropagateRequestIdLayer::new( http::HeaderName::from_static(consts::X_REQUEST_ID), ); Server::builder() .layer(logging_layer) .layer(request_id_layer) .layer(propagate_request_id_layer) .layer(metrics_layer) .add_service(reflection_service) .add_service(health_server::HealthServer::new(self.health_check_service)) .add_service(payment_service_server::PaymentServiceServer::new( self.payments_service.clone(), )) .add_service(refund_service_server::RefundServiceServer::new( self.refunds_service, )) .add_service(dispute_service_server::DisputeServiceServer::new( self.disputes_service, )) .serve_with_shutdown(socket, shutdown_signal) .await?; Ok(()) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "grpc_server", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-951835017135363923
clm
function
// connector-service/backend/grpc-server/src/app.rs pub async fn metrics_server_builder(config: configs::Config) -> Result<(), ConfigurationError> { let listener = config.metrics.tcp_listener().await?; let router = axum::Router::new().route( "/metrics", axum::routing::get(|| async { let output = metrics::metrics_handler().await; match output { Ok(metrics) => Ok(metrics), Err(error) => { tracing::error!(?error, "Error fetching metrics"); Err(( http::StatusCode::INTERNAL_SERVER_ERROR, "Error fetching metrics".to_string(), )) } } }), ); axum::serve(listener, router.into_make_service()) .with_graceful_shutdown(async { let output = tokio::signal::ctrl_c().await; tracing::error!(?output, "shutting down"); }) .await?; Ok(()) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "metrics_server_builder", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5374375827544403861
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub fn flow_marker_to_flow_name<F>() -> FlowName where F: 'static, { let type_id = std::any::TypeId::of::<F>(); if type_id == std::any::TypeId::of::<Authorize>() { FlowName::Authorize } else if type_id == std::any::TypeId::of::<PSync>() { FlowName::Psync } else if type_id == std::any::TypeId::of::<RSync>() { FlowName::Rsync } else if type_id == std::any::TypeId::of::<Void>() { FlowName::Void } else if type_id == std::any::TypeId::of::<VoidPC>() { FlowName::VoidPostCapture } else if type_id == std::any::TypeId::of::<Refund>() { FlowName::Refund } else if type_id == std::any::TypeId::of::<Capture>() { FlowName::Capture } else if type_id == std::any::TypeId::of::<SetupMandate>() { FlowName::SetupMandate } else if type_id == std::any::TypeId::of::<RepeatPayment>() { FlowName::RepeatPayment } else if type_id == std::any::TypeId::of::<CreateOrder>() { FlowName::CreateOrder } else if type_id == std::any::TypeId::of::<CreateSessionToken>() { FlowName::CreateSessionToken } else if type_id == std::any::TypeId::of::<Accept>() { FlowName::AcceptDispute } else if type_id == std::any::TypeId::of::<DefendDispute>() { FlowName::DefendDispute } else if type_id == std::any::TypeId::of::<SubmitEvidence>() { FlowName::SubmitEvidence } else if type_id == std::any::TypeId::of::<PaymentMethodToken>() { FlowName::PaymentMethodToken } else if type_id == std::any::TypeId::of::<PreAuthenticate>() { FlowName::PreAuthenticate } else if type_id == std::any::TypeId::of::<Authenticate>() { FlowName::Authenticate } else if type_id == std::any::TypeId::of::<PostAuthenticate>() { FlowName::PostAuthenticate } else { tracing::warn!("Unknown flow marker type: {}", std::any::type_name::<F>()); FlowName::Unknown } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "flow_marker_to_flow_name", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-6909641310110877439
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub fn extract_lineage_fields_from_metadata( metadata: &metadata::MetadataMap, config: &configs::LineageConfig, ) -> LineageIds<'static> { if !config.enabled { return LineageIds::empty(&config.field_prefix).to_owned(); } metadata .get(&config.header_name) .and_then(|value| value.to_str().ok()) .map(|header_value| LineageIds::new(&config.field_prefix, header_value)) .transpose() .inspect(|value| { tracing::info!( parsed_fields = ?value, "Successfully parsed lineage header" ) }) .inspect_err(|err| { tracing::warn!( error = %err, "Failed to parse lineage header, continuing without lineage fields" ) }) .ok() .flatten() .unwrap_or_else(|| LineageIds::empty(&config.field_prefix)) .to_owned() }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "extract_lineage_fields_from_metadata", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_9127893895694593621
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub fn record_fields_from_header<B: hyper::body::Body>(request: &Request<B>) -> tracing::Span { let url_path = request.uri().path(); let span = tracing::debug_span!( "request", uri = %url_path, version = ?request.version(), tenant_id = tracing::field::Empty, request_id = tracing::field::Empty, ); request .headers() .get(consts::X_TENANT_ID) .and_then(|value| value.to_str().ok()) .map(|tenant_id| span.record("tenant_id", tenant_id)); request .headers() .get(consts::X_REQUEST_ID) .and_then(|value| value.to_str().ok()) .map(|request_id| span.record("request_id", request_id)); span }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "record_fields_from_header", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-294474479787911615
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub fn get_metadata_payload( metadata: &metadata::MetadataMap, server_config: Arc<configs::Config>, ) -> CustomResult<MetadataPayload, ApplicationErrorResponse> { let connector = connector_from_metadata(metadata)?; let merchant_id = merchant_id_from_metadata(metadata)?; let tenant_id = tenant_id_from_metadata(metadata)?; let request_id = request_id_from_metadata(metadata)?; let lineage_ids = extract_lineage_fields_from_metadata(metadata, &server_config.lineage); let connector_auth_type = auth_from_metadata(metadata)?; let reference_id = reference_id_from_metadata(metadata)?; let shadow_mode = shadow_mode_from_metadata(metadata); Ok(MetadataPayload { tenant_id, request_id, merchant_id, connector, lineage_ids, connector_auth_type, reference_id, shadow_mode, }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_metadata_payload", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_428821496449645434
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub fn connector_from_metadata( metadata: &metadata::MetadataMap, ) -> CustomResult<connector_types::ConnectorEnum, ApplicationErrorResponse> { parse_metadata(metadata, consts::X_CONNECTOR_NAME).and_then(|inner| { connector_types::ConnectorEnum::from_str(inner).map_err(|e| { Report::new(ApplicationErrorResponse::BadRequest(ApiError { sub_code: "INVALID_CONNECTOR".to_string(), error_identifier: 400, error_message: format!("Invalid connector: {e}"), error_object: None, })) }) }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "connector_from_metadata", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7616680197003847023
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub fn merchant_id_from_metadata( metadata: &metadata::MetadataMap, ) -> CustomResult<String, ApplicationErrorResponse> { parse_metadata(metadata, consts::X_MERCHANT_ID) .map(|inner| inner.to_string()) .map_err(|e| { Report::new(ApplicationErrorResponse::BadRequest(ApiError { sub_code: "MISSING_MERCHANT_ID".to_string(), error_identifier: 400, error_message: format!("Missing merchant ID in request metadata: {e}"), error_object: None, })) }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "merchant_id_from_metadata", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2951952758979057258
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub fn request_id_from_metadata( metadata: &metadata::MetadataMap, ) -> CustomResult<String, ApplicationErrorResponse> { parse_metadata(metadata, consts::X_REQUEST_ID) .map(|inner| inner.to_string()) .map_err(|e| { Report::new(ApplicationErrorResponse::BadRequest(ApiError { sub_code: "MISSING_REQUEST_ID".to_string(), error_identifier: 400, error_message: format!("Missing request ID in request metadata: {e}"), error_object: None, })) }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "request_id_from_metadata", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-4570867008774434432
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub fn tenant_id_from_metadata( metadata: &metadata::MetadataMap, ) -> CustomResult<String, ApplicationErrorResponse> { parse_metadata(metadata, consts::X_TENANT_ID) .map(|s| s.to_string()) .or_else(|_| Ok("DefaultTenantId".to_string())) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "tenant_id_from_metadata", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1864771708533873096
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub fn reference_id_from_metadata( metadata: &metadata::MetadataMap, ) -> CustomResult<Option<String>, ApplicationErrorResponse> { parse_optional_metadata(metadata, consts::X_REFERENCE_ID).map(|s| s.map(|s| s.to_string())) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "reference_id_from_metadata", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-356012050329656718
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub fn shadow_mode_from_metadata(metadata: &metadata::MetadataMap) -> bool { parse_optional_metadata(metadata, X_SHADOW_MODE) .ok() .flatten() .map(|value| value.to_lowercase() == "true") .unwrap_or(false) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "shadow_mode_from_metadata", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7752344221358907922
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub fn auth_from_metadata( metadata: &metadata::MetadataMap, ) -> CustomResult<ConnectorAuthType, ApplicationErrorResponse> { let auth = parse_metadata(metadata, X_AUTH)?; #[allow(clippy::wildcard_in_or_patterns)] match auth { "header-key" => Ok(ConnectorAuthType::HeaderKey { api_key: parse_metadata(metadata, X_API_KEY)?.to_string().into(), }), "body-key" => Ok(ConnectorAuthType::BodyKey { api_key: parse_metadata(metadata, X_API_KEY)?.to_string().into(), key1: parse_metadata(metadata, X_KEY1)?.to_string().into(), }), "signature-key" => Ok(ConnectorAuthType::SignatureKey { api_key: parse_metadata(metadata, X_API_KEY)?.to_string().into(), key1: parse_metadata(metadata, X_KEY1)?.to_string().into(), api_secret: parse_metadata(metadata, X_API_SECRET)?.to_string().into(), }), "multi-auth-key" => Ok(ConnectorAuthType::MultiAuthKey { api_key: parse_metadata(metadata, X_API_KEY)?.to_string().into(), key1: parse_metadata(metadata, X_KEY1)?.to_string().into(), key2: parse_metadata(metadata, X_KEY2)?.to_string().into(), api_secret: parse_metadata(metadata, X_API_SECRET)?.to_string().into(), }), "no-key" => Ok(ConnectorAuthType::NoKey), "temporary-auth" => Ok(ConnectorAuthType::TemporaryAuth), "currency-auth-key" => { let auth_key_map_str = parse_metadata(metadata, X_AUTH_KEY_MAP)?; let auth_key_map: HashMap< common_enums::enums::Currency, common_utils::pii::SecretSerdeValue, > = serde_json::from_str(auth_key_map_str).change_context( ApplicationErrorResponse::BadRequest(ApiError { sub_code: "INVALID_AUTH_KEY_MAP".to_string(), error_identifier: 400, error_message: "Invalid auth-key-map format".to_string(), error_object: None, }), )?; Ok(ConnectorAuthType::CurrencyAuthKey { auth_key_map }) } "certificate-auth" | _ => Err(Report::new(ApplicationErrorResponse::BadRequest( ApiError { sub_code: "INVALID_AUTH_TYPE".to_string(), error_identifier: 400, error_message: format!("Invalid auth type: {auth}"), error_object: None, }, ))), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "auth_from_metadata", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_8474006838814552387
clm
function
// connector-service/backend/grpc-server/src/utils.rs fn parse_metadata<'a>( metadata: &'a metadata::MetadataMap, key: &str, ) -> CustomResult<&'a str, ApplicationErrorResponse> { metadata .get(key) .ok_or_else(|| { Report::new(ApplicationErrorResponse::BadRequest(ApiError { sub_code: "MISSING_METADATA".to_string(), error_identifier: 400, error_message: format!("Missing {key} in request metadata"), error_object: None, })) }) .and_then(|value| { value.to_str().map_err(|e| { Report::new(ApplicationErrorResponse::BadRequest(ApiError { sub_code: "INVALID_METADATA".to_string(), error_identifier: 400, error_message: format!("Invalid {key} in request metadata: {e}"), error_object: None, })) }) }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "parse_metadata", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7781144718467377355
clm
function
// connector-service/backend/grpc-server/src/utils.rs fn parse_optional_metadata<'a>( metadata: &'a metadata::MetadataMap, key: &str, ) -> CustomResult<Option<&'a str>, ApplicationErrorResponse> { metadata .get(key) .map(|value| value.to_str()) .transpose() .map_err(|e| { Report::new(ApplicationErrorResponse::BadRequest(ApiError { sub_code: "INVALID_METADATA".to_string(), error_identifier: 400, error_message: format!("Invalid {key} in request metadata: {e}"), error_object: None, })) }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "parse_optional_metadata", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_3845593455049650327
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub fn log_before_initialization<T>( request_data: &RequestData<T>, service_name: &str, ) -> CustomResult<(), ApplicationErrorResponse> where T: serde::Serialize, { let metadata_payload = &request_data.extracted_metadata; let MetadataPayload { connector, merchant_id, tenant_id, request_id, .. } = metadata_payload; let current_span = tracing::Span::current(); let req_body_json = match hyperswitch_masking::masked_serialize(&request_data.payload) { Ok(masked_value) => masked_value.to_string(), Err(e) => { tracing::error!("Masked serialization error: {:?}", e); "<masked serialization error>".to_string() } }; current_span.record("service_name", service_name); current_span.record("request_body", req_body_json); current_span.record("gateway", connector.to_string()); current_span.record("merchant_id", merchant_id); current_span.record("tenant_id", tenant_id); current_span.record("request_id", request_id); tracing::info!("Golden Log Line (incoming)"); Ok(()) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "log_before_initialization", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-1382139200920325231
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub fn log_after_initialization<T>(result: &Result<tonic::Response<T>, tonic::Status>) where T: serde::Serialize + std::fmt::Debug, { let current_span = tracing::Span::current(); // let duration = start_time.elapsed().as_millis(); // current_span.record("response_time", duration); match &result { Ok(response) => { current_span.record("response_body", tracing::field::debug(response.get_ref())); let res_ref = response.get_ref(); // Try converting to JSON Value if let Ok(serde_json::Value::Object(map)) = serde_json::to_value(res_ref) { if let Some(status_val) = map.get("status") { let status_num_opt = status_val.as_number(); let status_u32_opt: Option<u32> = status_num_opt .and_then(|n| n.as_u64()) .and_then(|n| u32::try_from(n).ok()); let status_str = if let Some(s) = status_u32_opt { common_enums::AttemptStatus::try_from(s) .unwrap_or(common_enums::AttemptStatus::Unknown) .to_string() } else { common_enums::AttemptStatus::Unknown.to_string() }; current_span.record("flow_specific_fields.status", status_str); } } else { tracing::warn!("Could not serialize response to JSON to extract status"); } } Err(status) => { current_span.record("error_message", status.message()); current_span.record("status_code", status.code().to_string()); } } tracing::info!("Golden Log Line (incoming)"); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "log_after_initialization", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5489667756637080977
clm
function
// connector-service/backend/grpc-server/src/utils.rs pub async fn grpc_logging_wrapper<T, F, Fut, R>( request: tonic::Request<T>, service_name: &str, config: Arc<configs::Config>, flow_name: FlowName, handler: F, ) -> Result<tonic::Response<R>, tonic::Status> where T: serde::Serialize + std::fmt::Debug + Send + 'static + hyperswitch_masking::ErasedMaskSerialize, F: FnOnce(RequestData<T>) -> Fut + Send, Fut: std::future::Future<Output = Result<tonic::Response<R>, tonic::Status>> + Send, R: serde::Serialize + std::fmt::Debug + hyperswitch_masking::ErasedMaskSerialize, { let current_span = tracing::Span::current(); let start_time = tokio::time::Instant::now(); let masked_request_data = MaskedSerdeValue::from_masked_optional(request.get_ref(), "grpc_request"); let mut event_metadata_payload = None; let mut event_headers = HashMap::new(); let grpc_response = async { let request_data = RequestData::from_grpc_request(request, config.clone())?; log_before_initialization(&request_data, service_name).into_grpc_status()?; event_headers = request_data.masked_metadata.get_all_masked(); event_metadata_payload = Some(request_data.extracted_metadata.clone()); let result = handler(request_data).await; let duration = start_time.elapsed().as_millis(); current_span.record("response_time", duration); log_after_initialization(&result); result } .await; create_and_emit_grpc_event( masked_request_data, &grpc_response, start_time, flow_name, &config, event_metadata_payload.as_ref(), event_headers, ); grpc_response }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "grpc_logging_wrapper", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-4177316352647460377
clm
function
// connector-service/backend/grpc-server/src/utils.rs fn create_and_emit_grpc_event<R>( masked_request_data: Option<MaskedSerdeValue>, grpc_response: &Result<tonic::Response<R>, tonic::Status>, start_time: tokio::time::Instant, flow_name: FlowName, config: &configs::Config, metadata_payload: Option<&MetadataPayload>, masked_headers: HashMap<String, String>, ) where R: serde::Serialize, { let mut grpc_event = Event { request_id: metadata_payload.map_or("unknown".to_string(), |md| md.request_id.clone()), timestamp: chrono::Utc::now().timestamp().into(), flow_type: flow_name, connector: metadata_payload.map_or("unknown".to_string(), |md| md.connector.to_string()), url: None, stage: EventStage::GrpcRequest, latency_ms: Some(u64::try_from(start_time.elapsed().as_millis()).unwrap_or(u64::MAX)), status_code: None, request_data: masked_request_data, response_data: None, headers: masked_headers, additional_fields: HashMap::new(), lineage_ids: metadata_payload .map_or_else(|| LineageIds::empty(""), |md| md.lineage_ids.clone()), }; grpc_event .add_reference_id(metadata_payload.and_then(|metadata| metadata.reference_id.as_deref())); match grpc_response { Ok(response) => grpc_event.set_grpc_success_response(response.get_ref()), Err(error) => grpc_event.set_grpc_error_response(error), } common_utils::emit_event_with_config(grpc_event, &config.events); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "create_and_emit_grpc_event", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-847382602327067089
clm
function
// connector-service/backend/grpc-server/src/logger/config.rs pub fn into_level(&self) -> tracing::Level { self.0 }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "into_level", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7081623782602058468
clm
function
// connector-service/backend/grpc-server/src/logger/config.rs fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { use std::str::FromStr as _; let s = String::deserialize(deserializer)?; tracing::Level::from_str(&s) .map(Level) .map_err(serde::de::Error::custom) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "deserialize", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_3346182125838728549
clm
function
// connector-service/backend/grpc-server/src/logger/formatter.rs fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let repr = match self { Self::EnterSpan => "START", Self::ExitSpan => "END", Self::Event => "EVENT", }; write!(f, "{repr}") }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "fmt", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7420138730788859806
clm
function
// connector-service/backend/grpc-server/src/logger/formatter.rs pub fn new(service: &str, dst_writer: W) -> Self { Self::new_with_implicit_entries(service, dst_writer, HashMap::new()) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "new", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-3830295597616003397
clm
function
// connector-service/backend/grpc-server/src/logger/formatter.rs pub fn new_with_implicit_entries( service: &str, dst_writer: W, mut default_fields: HashMap<String, Value>, ) -> Self { let pid = std::process::id(); let hostname = gethostname::gethostname().to_string_lossy().into_owned(); let service = service.to_string(); default_fields.retain(|key, value| { if !IMPLICIT_KEYS.contains(key.as_str()) { true } else { #[allow(clippy::print_stderr)] { eprintln!( "Attempting to log a reserved entry. It won't be added to the logs. key: {:?}, value: {:?}", key, value); } false } }); Self { dst_writer, pid, hostname, service, default_fields, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "new_with_implicit_entries", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5413640562320834654
clm
function
// connector-service/backend/grpc-server/src/logger/formatter.rs fn common_serialize<S>( &self, map_serializer: &mut impl SerializeMap<Error = serde_json::Error>, metadata: &Metadata<'_>, span: Option<&SpanRef<'_, S>>, storage: &Storage<'_>, name: &str, ) -> Result<(), std::io::Error> where S: Subscriber + for<'a> LookupSpan<'a>, { let is_extra = |s: &str| !IMPLICIT_KEYS.contains(s); map_serializer.serialize_entry(HOSTNAME, &self.hostname)?; map_serializer.serialize_entry(PID, &self.pid)?; map_serializer.serialize_entry(LEVEL, &format_args!("{}", metadata.level()))?; map_serializer.serialize_entry(TARGET, metadata.target())?; map_serializer.serialize_entry(SERVICE, &self.service)?; map_serializer.serialize_entry(LINE, &metadata.line())?; map_serializer.serialize_entry(FILE, &metadata.file())?; map_serializer.serialize_entry(FN, name)?; map_serializer .serialize_entry(FULL_NAME, &format_args!("{}::{}", metadata.target(), name))?; if let Ok(time) = &time::OffsetDateTime::now_utc().format(&Iso8601::DEFAULT) { map_serializer.serialize_entry(TIME, time)?; } // Write down implicit default entries. for (key, value) in self.default_fields.iter() { map_serializer.serialize_entry(key, value)?; } let mut explicit_entries_set: HashSet<&str> = HashSet::default(); // Write down explicit event's entries. for (key, value) in storage.values.iter() { map_serializer.serialize_entry(key, value)?; explicit_entries_set.insert(key); } // Write down entries from the span, if it exists. if let Some(span) = &span { let extensions = span.extensions(); if let Some(visitor) = extensions.get::<Storage<'_>>() { for (key, value) in &visitor.values { if is_extra(key) && !explicit_entries_set.contains(key) { map_serializer.serialize_entry(key, value)?; } else { #[allow(clippy::print_stderr)] { eprintln!( "Attempting to log a reserved entry. It won't be added to the logs. key: {key:?}, value: {value:?}" ); } } } } } Ok(()) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "common_serialize", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-3620697090889991436
clm
function
// connector-service/backend/grpc-server/src/logger/formatter.rs fn flush(&self, mut buffer: Vec<u8>) -> Result<(), std::io::Error> { buffer.write_all(b"\n")?; self.dst_writer.make_writer().write_all(&buffer) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "flush", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2789373339398203576
clm
function
// connector-service/backend/grpc-server/src/logger/formatter.rs fn span_serialize<S>( &self, span: &SpanRef<'_, S>, ty: RecordType, ) -> Result<Vec<u8>, std::io::Error> where S: Subscriber + for<'a> LookupSpan<'a>, { let mut buffer = Vec::new(); let mut serializer = serde_json::Serializer::new(&mut buffer); let mut map_serializer = serializer.serialize_map(None)?; let message = Self::span_message(span, ty); let mut storage = Storage::default(); storage.record_value(MESSAGE, message.into()); self.common_serialize( &mut map_serializer, span.metadata(), Some(span), &storage, span.name(), )?; map_serializer.end()?; Ok(buffer) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "span_serialize", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2536802501550453707
clm
function
// connector-service/backend/grpc-server/src/logger/formatter.rs pub fn event_serialize<S>( &self, span: &Option<&SpanRef<'_, S>>, event: &Event<'_>, ) -> std::io::Result<Vec<u8>> where S: Subscriber + for<'a> LookupSpan<'a>, { let mut buffer = Vec::new(); let mut serializer = serde_json::Serializer::new(&mut buffer); let mut map_serializer = serializer.serialize_map(None)?; let mut storage = Storage::default(); event.record(&mut storage); let name = span.map_or("?", SpanRef::name); Self::event_message(span, event, &mut storage); self.common_serialize(&mut map_serializer, event.metadata(), *span, &storage, name)?; map_serializer.end()?; Ok(buffer) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "event_serialize", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_8501785301368143137
clm
function
// connector-service/backend/grpc-server/src/logger/formatter.rs fn span_message<S>(span: &SpanRef<'_, S>, ty: RecordType) -> String where S: Subscriber + for<'a> LookupSpan<'a>, { format!("[{} - {}]", span.metadata().name().to_uppercase(), ty) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "span_message", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_4561409223824187208
clm
function
// connector-service/backend/grpc-server/src/logger/formatter.rs fn event_message<S>( span: &Option<&SpanRef<'_, S>>, event: &Event<'_>, storage: &mut Storage<'_>, ) where S: Subscriber + for<'a> LookupSpan<'a>, { let message = storage .values .entry(MESSAGE) .or_insert_with(|| event.metadata().target().into()); // Prepend the span name to the message if span exists. if let (Some(span), Value::String(a)) = (span, message) { *a = format!("{} {}", Self::span_message(span, RecordType::Event), a,); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "event_message", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-8507220926345532004
clm
function
// connector-service/backend/grpc-server/src/logger/formatter.rs fn on_event(&self, event: &Event<'_>, ctx: Context<'_, S>) { // Event could have no span. let span = ctx.lookup_current(); let result: std::io::Result<Vec<u8>> = self.event_serialize(&span.as_ref(), event); if let Ok(formatted) = result { let _ = self.flush(formatted); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "on_event", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_3101933580739936863
clm
function
// connector-service/backend/grpc-server/src/logger/formatter.rs fn on_enter(&self, id: &tracing::Id, ctx: Context<'_, S>) { let span = ctx.span(id).expect("No span"); if let Ok(serialized) = self.span_serialize(&span, RecordType::EnterSpan) { let _ = self.flush(serialized); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "on_enter", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_2863772409473158122
clm
function
// connector-service/backend/grpc-server/src/logger/formatter.rs fn on_close(&self, id: tracing::Id, ctx: Context<'_, S>) { let span = ctx.span(&id).expect("No span"); if let Ok(serialized) = self.span_serialize(&span, RecordType::ExitSpan) { let _ = self.flush(serialized); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "on_close", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-7401143105231038142
clm
function
// connector-service/backend/grpc-server/src/logger/storage.rs pub fn new() -> Self { Self::default() }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "new", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-4940289520477183831
clm
function
// connector-service/backend/grpc-server/src/logger/storage.rs pub fn record_value(&mut self, key: &'a str, value: serde_json::Value) { if super::formatter::IMPLICIT_KEYS.contains(key) { #[allow(clippy::print_stderr)] { eprintln!("{key} is a reserved entry. Skipping it. value: {value}"); } } else { self.values.insert(key, value); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "record_value", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7873777859990616780
clm
function
// connector-service/backend/grpc-server/src/logger/storage.rs fn default() -> Self { Self { values: HashMap::new(), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "default", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-5629544826720055472
clm
function
// connector-service/backend/grpc-server/src/logger/storage.rs fn record_i64(&mut self, field: &Field, value: i64) { self.record_value(field.name(), serde_json::Value::from(value)); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "record_i64", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1572011004349697856
clm
function
// connector-service/backend/grpc-server/src/logger/storage.rs fn record_u64(&mut self, field: &Field, value: u64) { self.record_value(field.name(), serde_json::Value::from(value)); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "record_u64", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_5459081000809246477
clm
function
// connector-service/backend/grpc-server/src/logger/storage.rs fn record_f64(&mut self, field: &Field, value: f64) { self.record_value(field.name(), serde_json::Value::from(value)); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "record_f64", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-9207627977966999090
clm
function
// connector-service/backend/grpc-server/src/logger/storage.rs fn record_bool(&mut self, field: &Field, value: bool) { self.record_value(field.name(), serde_json::Value::from(value)); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "record_bool", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-2281418163181108870
clm
function
// connector-service/backend/grpc-server/src/logger/storage.rs fn record_str(&mut self, field: &Field, value: &str) { self.record_value(field.name(), serde_json::Value::from(value)); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "record_str", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-8698230775447774764
clm
function
// connector-service/backend/grpc-server/src/logger/storage.rs fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) { match field.name() { // Skip fields which are already handled name if name.starts_with("log.") => (), name if name.starts_with("r#") => { self.record_value(&name[2..], serde_json::Value::from(format!("{value:?}"))); } name => { self.record_value(name, serde_json::Value::from(format!("{value:?}"))); } }; }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "record_debug", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_6754094979629940676
clm
function
// connector-service/backend/grpc-server/src/logger/storage.rs fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) { let span = ctx.span(id).expect("No span"); let mut visitor = if let Some(parent_span) = span.parent() { let mut extensions = parent_span.extensions_mut(); extensions .get_mut::<Storage<'_>>() .map(|v| v.to_owned()) .unwrap_or_default() } else { Storage::default() }; let mut extensions = span.extensions_mut(); attrs.record(&mut visitor); extensions.insert(visitor); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "on_new_span", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_5046648895714353419
clm
function
// connector-service/backend/grpc-server/src/logger/storage.rs fn on_record(&self, span: &Id, values: &Record<'_>, ctx: Context<'_, S>) { let span = ctx.span(span).expect("No span"); let mut extensions = span.extensions_mut(); let visitor = extensions .get_mut::<Storage<'_>>() .expect("The span does not have storage"); values.record(visitor); }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "on_record", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_5213610293517403766
clm
function
// connector-service/backend/grpc-server/src/logger/storage.rs fn on_enter(&self, span: &Id, ctx: Context<'_, S>) { let span = ctx.span(span).expect("No span"); let mut extensions = span.extensions_mut(); if extensions.get_mut::<Instant>().is_none() { extensions.insert(Instant::now()); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "on_enter", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_6827489759571336852
clm
function
// connector-service/backend/grpc-server/src/logger/storage.rs fn on_close(&self, span: Id, ctx: Context<'_, S>) { let span = ctx.span(&span).expect("No span"); let elapsed_milliseconds = { let extensions = span.extensions(); extensions .get::<Instant>() .map(|i| i.elapsed().as_millis()) .unwrap_or(0) }; let mut extensions_mut = span.extensions_mut(); let visitor = extensions_mut .get_mut::<Storage<'_>>() .expect("No visitor in extensions"); if let Ok(elapsed) = serde_json::to_value(elapsed_milliseconds) { visitor.record_value("elapsed_milliseconds", elapsed); } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "on_close", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_4655584661241494246
clm
function
// connector-service/backend/grpc-server/src/logger/setup.rs pub fn setup( config: &config::Log, service_name: &str, crates_to_filter: impl AsRef<[&'static str]>, ) -> Result<TelemetryGuard, log_utils::LoggerError> { let static_top_level_fields = HashMap::from_iter([ ("service".to_string(), serde_json::json!(service_name)), ( "build_version".to_string(), serde_json::json!(crate::version!()), ), ]); let console_config = if config.console.enabled { let console_filter_directive = config .console .filtering_directive .clone() .unwrap_or_else(|| { get_envfilter_directive( tracing::Level::WARN, config.console.level.into_level(), crates_to_filter.as_ref(), ) }); let log_format = match config.console.log_format { config::LogFormat::Default => log_utils::ConsoleLogFormat::HumanReadable, config::LogFormat::Json => { // Disable color or emphasis related ANSI escape codes for JSON formats error_stack::Report::set_color_mode(error_stack::fmt::ColorMode::None); log_utils::ConsoleLogFormat::CompactJson } }; Some(log_utils::ConsoleLoggingConfig { level: config.console.level.into_level(), log_format, filtering_directive: Some(console_filter_directive), print_filtering_directive: log_utils::DirectivePrintTarget::Stderr, }) } else { None }; let logger_config = log_utils::LoggerConfig { static_top_level_fields: static_top_level_fields.clone(), top_level_keys: HashSet::new(), persistent_keys: HashSet::new(), log_span_lifecycles: true, additional_fields_placement: log_utils::AdditionalFieldsPlacement::TopLevel, file_config: None, console_config, global_filtering_directive: None, }; let logging_components = log_utils::build_logging_components(logger_config)?; let mut subscriber_layers = Vec::new(); subscriber_layers.push(logging_components.storage_layer.boxed()); if let Some(console_layer) = logging_components.console_log_layer { subscriber_layers.push(console_layer); } #[allow(unused_mut)] let mut kafka_logging_enabled = false; // Add Kafka layer if configured #[cfg(feature = "kafka")] if let Some(kafka_config) = &config.kafka { if kafka_config.enabled { // Initialize kafka metrics if the feature is enabled. // This will cause the application to panic at startup if metric registration fails. tracing_kafka::init(); let kafka_filter_directive = kafka_config.filtering_directive.clone().unwrap_or_else(|| { get_envfilter_directive( tracing::Level::WARN, kafka_config.level.into_level(), crates_to_filter.as_ref(), ) }); let brokers: Vec<&str> = kafka_config.brokers.iter().map(|s| s.as_str()).collect(); let mut builder = KafkaLayer::builder() .brokers(&brokers) .topic(&kafka_config.topic) .static_fields(static_top_level_fields.clone()); // Add batch_size if configured if let Some(batch_size) = kafka_config.batch_size { builder = builder.batch_size(batch_size); } // Add flush_interval_ms if configured if let Some(flush_interval_ms) = kafka_config.flush_interval_ms { builder = builder.linger_ms(flush_interval_ms); } // Add buffer_limit if configured if let Some(buffer_limit) = kafka_config.buffer_limit { builder = builder.queue_buffering_max_messages(buffer_limit); } let kafka_layer = match builder.build() { Ok(layer) => { // Create filter with infinite feedback loop prevention let kafka_filter_directive = format!( "{kafka_filter_directive},rdkafka=off,librdkafka=off,kafka=off,kafka_writer=off,tracing_kafka=off", ); let kafka_filter = tracing_subscriber::EnvFilter::builder() .with_default_directive(kafka_config.level.into_level().into()) .parse_lossy(kafka_filter_directive); Some(layer.with_filter(kafka_filter)) } Err(e) => { tracing::warn!(error = ?e, "Failed to enable Kafka logging"); // Continue without Kafka None } }; if let Some(layer) = kafka_layer { subscriber_layers.push(layer.boxed()); kafka_logging_enabled = true; tracing::info!(topic = %kafka_config.topic, "Kafka logging enabled"); } } } tracing_subscriber::registry() .with(subscriber_layers) .init(); tracing::info!( service_name, build_version = crate::version!(), kafka_logging_enabled, "Logging subsystem initialized" ); // Returning the TelemetryGuard for logs to be printed and metrics to be collected until it is // dropped Ok(TelemetryGuard { _log_guards: logging_components.guards, }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "setup", "is_async": false, "is_pub": true, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-3157941024589326988
clm
function
// connector-service/backend/grpc-server/src/logger/setup.rs fn get_envfilter_directive( default_log_level: tracing::Level, filter_log_level: tracing::Level, crates_to_filter: impl AsRef<[&'static str]>, ) -> String { let mut explicitly_handled_targets = build_info::cargo_workspace_members!(); explicitly_handled_targets.extend(build_info::framework_libs_workspace_members()); explicitly_handled_targets.extend(crates_to_filter.as_ref()); // +1 for the default log level added as a directive let num_directives = explicitly_handled_targets.len() + 1; explicitly_handled_targets .into_iter() .map(|crate_name| crate_name.replace('-', "_")) .zip(std::iter::repeat(filter_log_level)) .fold( { let mut directives = Vec::with_capacity(num_directives); directives.push(default_log_level.to_string()); directives }, |mut directives, (target, level)| { directives.push(format!("{target}={level}")); directives }, ) .join(",") }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_envfilter_directive", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1142864864411545878
clm
function
// connector-service/backend/grpc-server/src/server/refunds.rs async fn get( &self, request: tonic::Request<RefundServiceGetRequest>, ) -> Result<tonic::Response<RefundResponse>, tonic::Status> { let service_name = request .extensions() .get::<String>() .cloned() .unwrap_or_else(|| "RefundService".to_string()); utils::grpc_logging_wrapper( request, &service_name, self.config.clone(), common_utils::events::FlowName::Rsync, |request_data| async move { self.internal_get(request_data).await }, ) .await }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_4320284921816181955
clm
function
// connector-service/backend/grpc-server/src/server/refunds.rs async fn transform( &self, request: tonic::Request<RefundServiceTransformRequest>, ) -> Result<tonic::Response<RefundServiceTransformResponse>, tonic::Status> { let service_name = request .extensions() .get::<String>() .cloned() .unwrap_or_else(|| "RefundService".to_string()); utils::grpc_logging_wrapper( request, &service_name, self.config.clone(), common_utils::events::FlowName::IncomingWebhook, |request_data| async move { let payload = request_data.payload; let connector = request_data.extracted_metadata.connector; let connector_auth_details = request_data.extracted_metadata.connector_auth_type; let request_details = payload .request_details .map(domain_types::connector_types::RequestDetails::foreign_try_from) .ok_or_else(|| { tonic::Status::invalid_argument("missing request_details in the payload") })? .map_err(|e| e.into_grpc_status())?; let webhook_secrets = payload .webhook_secrets .map(|details| { domain_types::connector_types::ConnectorWebhookSecrets::foreign_try_from( details, ) .map_err(|e| e.into_grpc_status()) }) .transpose()?; // Get connector data let connector_data = ConnectorData::get_connector_by_name(&connector); let source_verified = connector_data .connector .verify_webhook_source( request_details.clone(), webhook_secrets.clone(), Some(connector_auth_details.clone()), ) .switch() .map_err(|e| e.into_grpc_status())?; let content = get_refunds_webhook_content( connector_data, request_details, webhook_secrets, Some(connector_auth_details), ) .await .map_err(|e| e.into_grpc_status())?; let response = RefundServiceTransformResponse { event_type: WebhookEventType::WebhookRefundSuccess.into(), content: Some(content), source_verified, response_ref_id: None, }; Ok(tonic::Response::new(response)) }, ) .await }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "transform", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_1572383730327193971
clm
function
// connector-service/backend/grpc-server/src/server/refunds.rs async fn get_refunds_webhook_content( connector_data: ConnectorData<DefaultPCIHolder>, request_details: domain_types::connector_types::RequestDetails, webhook_secrets: Option<domain_types::connector_types::ConnectorWebhookSecrets>, connector_auth_details: Option<ConnectorAuthType>, ) -> CustomResult<WebhookResponseContent, ApplicationErrorResponse> { let webhook_details = connector_data .connector .process_refund_webhook(request_details, webhook_secrets, connector_auth_details) .switch()?; // Generate response let response = RefundResponse::foreign_try_from(webhook_details).change_context( ApplicationErrorResponse::InternalServerError(ApiError { sub_code: "RESPONSE_CONSTRUCTION_ERROR".to_string(), error_identifier: 500, error_message: "Error while constructing response".to_string(), error_object: None, }), )?; Ok(WebhookResponseContent { content: Some( grpc_api_types::payments::webhook_response_content::Content::RefundsResponse(response), ), }) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "get_refunds_webhook_content", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_6439808608052564307
clm
function
// connector-service/backend/grpc-server/src/server/payments.rs fn to_token_data(&self) -> TokenData { self.to_token_data_with_vault(VaultConnectors::VGS) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "to_token_data", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_7547660236758709169
clm
function
// connector-service/backend/grpc-server/src/server/payments.rs fn to_token_data_with_vault(&self, vault_connector: VaultConnectors) -> TokenData { let card_data = CardTokenData { card_number: self .card_number .as_ref() .map(|cn| cn.to_string()) .unwrap_or_default(), cvv: self .card_cvc .as_ref() .map(|cvc| cvc.clone().expose().to_string()) .unwrap_or_default(), exp_month: self .card_exp_month .as_ref() .map(|em| em.clone().expose().to_string()) .unwrap_or_default(), exp_year: self .card_exp_year .as_ref() .map(|ey| ey.clone().expose().to_string()) .unwrap_or_default(), }; let card_json = serde_json::to_value(card_data).unwrap_or(serde_json::Value::Null); TokenData { specific_token_data: SecretSerdeValue::new(card_json), vault_connector, } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "to_token_data_with_vault", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_-3384819770676488938
clm
function
// connector-service/backend/grpc-server/src/server/payments.rs async fn process_authorization_internal< T: PaymentMethodDataTypes + Default + Eq + Debug + Send + serde::Serialize + serde::de::DeserializeOwned + Clone + Sync + domain_types::types::CardConversionHelper<T> + 'static, >( &self, payload: PaymentServiceAuthorizeRequest, connector: domain_types::connector_types::ConnectorEnum, connector_auth_details: ConnectorAuthType, metadata: &MaskedMetadata, metadata_payload: &utils::MetadataPayload, service_name: &str, request_id: &str, token_data: Option<TokenData>, ) -> Result<PaymentServiceAuthorizeResponse, PaymentAuthorizationError> { //get connector data let connector_data = ConnectorData::get_connector_by_name(&connector); // Get connector integration let connector_integration: BoxedConnectorIntegrationV2< '_, Authorize, PaymentFlowData, PaymentsAuthorizeData<T>, PaymentsResponseData, > = connector_data.connector.get_connector_integration_v2(); // Create common request data let payment_flow_data = PaymentFlowData::foreign_try_from(( payload.clone(), self.config.connectors.clone(), metadata, )) .map_err(|err| { tracing::error!("Failed to process payment flow data: {:?}", err); PaymentAuthorizationError::new( grpc_api_types::payments::PaymentStatus::Pending, Some("Failed to process payment flow data".to_string()), Some("PAYMENT_FLOW_ERROR".to_string()), None, ) })?; let lineage_ids = &metadata_payload.lineage_ids; let reference_id = &metadata_payload.reference_id; let should_do_order_create = connector_data.connector.should_do_order_create(); let payment_flow_data = if should_do_order_create { let event_params = EventParams { _connector_name: &connector.to_string(), _service_name: service_name, request_id, lineage_ids, reference_id, shadow_mode: metadata_payload.shadow_mode, }; let order_id = Box::pin(self.handle_order_creation( connector_data.clone(), &payment_flow_data, connector_auth_details.clone(), &payload, &connector.to_string(), service_name, event_params, )) .await?; tracing::info!("Order created successfully with order_id: {}", order_id); payment_flow_data.set_order_reference_id(Some(order_id)) } else { payment_flow_data }; let should_do_session_token = connector_data.connector.should_do_session_token(); let payment_flow_data = if should_do_session_token { let event_params = EventParams { _connector_name: &connector.to_string(), _service_name: service_name, request_id, lineage_ids, reference_id, shadow_mode: metadata_payload.shadow_mode, }; let payment_session_data = Box::pin(self.handle_session_token( connector_data.clone(), &payment_flow_data, connector_auth_details.clone(), &payload, &connector.to_string(), service_name, event_params, )) .await?; tracing::info!( "Session Token created successfully with session_id: {}", payment_session_data.session_token ); payment_flow_data.set_session_token_id(Some(payment_session_data.session_token)) } else { payment_flow_data }; // Extract access token from Hyperswitch request let cached_access_token = payload .state .as_ref() .and_then(|state| state.access_token.as_ref()) .map(|access| (access.token.clone(), access.expires_in_seconds)); // Check if connector supports access tokens let should_do_access_token = connector_data.connector.should_do_access_token(); // Conditional token generation - ONLY if not provided in request let payment_flow_data = if should_do_access_token { let access_token_data = match cached_access_token { Some((token, expires_in)) => { // If provided cached token - use it, don't generate new one tracing::info!("Using cached access token from Hyperswitch"); Some(AccessTokenResponseData { access_token: token, token_type: None, expires_in, }) } None => { // No cached token - generate fresh one tracing::info!("No cached access token found, generating new token"); let event_params = EventParams { _connector_name: &connector.to_string(), _service_name: service_name, request_id, lineage_ids, reference_id, shadow_mode: metadata_payload.shadow_mode, }; let access_token_data = Box::pin(self.handle_access_token( connector_data.clone(), &payment_flow_data, connector_auth_details.clone(), &connector.to_string(), service_name, event_params, )) .await?; tracing::info!( "Access token created successfully with expiry: {:?}", access_token_data.expires_in ); Some(access_token_data) } }; // Store in flow data for connector API calls payment_flow_data.set_access_token(access_token_data) } else { // Connector doesn't support access tokens payment_flow_data }; // Extract connector customer ID (if provided by Hyperswitch) let cached_connector_customer_id = payload.connector_customer_id.clone(); // Check if connector supports customer creation let should_create_connector_customer = connector_data.connector.should_create_connector_customer(); // Conditional customer creation - ONLY if connector needs it AND no existing customer ID let payment_flow_data = if should_create_connector_customer { match cached_connector_customer_id { Some(_customer_id) => payment_flow_data, None => { let event_params = EventParams { _connector_name: &connector.to_string(), _service_name: service_name, request_id, lineage_ids, reference_id, shadow_mode: metadata_payload.shadow_mode, }; let connector_customer_response = Box::pin(self.handle_connector_customer( connector_data.clone(), &payment_flow_data, connector_auth_details.clone(), &payload, &connector.to_string(), service_name, event_params, )) .await?; payment_flow_data.set_connector_customer_id(Some( connector_customer_response.connector_customer_id, )) } } } else { // Connector doesn't support customer creation payment_flow_data }; let should_do_payment_method_token = connector_data.connector.should_do_payment_method_token(); let payment_flow_data = if should_do_payment_method_token { let event_params = EventParams { _connector_name: &connector.to_string(), _service_name: service_name, request_id, lineage_ids, reference_id, shadow_mode: metadata_payload.shadow_mode, }; let payment_method_token_data = self .handle_payment_session_token( connector_data.clone(), &payment_flow_data, connector_auth_details.clone(), event_params, &payload, &connector.to_string(), service_name, ) .await?; tracing::info!("Payment Method Token created successfully"); payment_flow_data.set_payment_method_token(Some(payment_method_token_data.token)) } else { payment_flow_data }; // This duplicate session token check has been removed - the session token handling is already done above // Create connector request data let payment_authorize_data = PaymentsAuthorizeData::foreign_try_from(payload.clone()) .map_err(|err| { tracing::error!("Failed to process payment authorize data: {:?}", err); PaymentAuthorizationError::new( grpc_api_types::payments::PaymentStatus::Pending, Some("Failed to process payment authorize data".to_string()), Some("PAYMENT_AUTHORIZE_DATA_ERROR".to_string()), None, ) })? // Set session token from payment flow data if available .set_session_token(payment_flow_data.session_token.clone()); // Construct router data let router_data = RouterDataV2::< Authorize, PaymentFlowData, PaymentsAuthorizeData<T>, PaymentsResponseData, > { flow: std::marker::PhantomData, resource_common_data: payment_flow_data.clone(), connector_auth_type: connector_auth_details.clone(), request: payment_authorize_data, response: Err(ErrorResponse::default()), }; // Execute connector processing let event_params = EventProcessingParams { connector_name: &connector.to_string(), service_name, flow_name: FlowName::Authorize, event_config: &self.config.events, request_id, lineage_ids, reference_id, shadow_mode: metadata_payload.shadow_mode, }; // Execute connector processing let response = external_services::service::execute_connector_processing_step( &self.config.proxy, connector_integration, router_data, None, event_params, token_data, common_enums::CallConnectorAction::Trigger, ) .await; // Generate response - pass both success and error cases let authorize_response = match response { Ok(success_response) => domain_types::types::generate_payment_authorize_response( success_response, ) .map_err(|err| { tracing::error!("Failed to generate authorize response: {:?}", err); PaymentAuthorizationError::new( grpc_api_types::payments::PaymentStatus::Pending, Some("Failed to generate authorize response".to_string()), Some("RESPONSE_GENERATION_ERROR".to_string()), None, ) })?, Err(error_report) => { // Convert error to RouterDataV2 with error response let error_router_data = RouterDataV2 { flow: std::marker::PhantomData, resource_common_data: payment_flow_data, connector_auth_type: connector_auth_details, request: PaymentsAuthorizeData::foreign_try_from(payload.clone()).map_err( |err| { tracing::error!( "Failed to process payment authorize data in error path: {:?}", err ); PaymentAuthorizationError::new( grpc_api_types::payments::PaymentStatus::Pending, Some( "Failed to process payment authorize data in error path" .to_string(), ), Some("PAYMENT_AUTHORIZE_DATA_ERROR".to_string()), None, ) }, )?, response: Err(ErrorResponse { status_code: 400, code: "CONNECTOR_ERROR".to_string(), message: format!("{error_report}"), reason: None, attempt_status: Some(common_enums::AttemptStatus::Failure), connector_transaction_id: None, network_decline_code: None, network_advice_code: None, network_error_message: None, }), }; domain_types::types::generate_payment_authorize_response::<T>(error_router_data) .map_err(|err| { tracing::error!( "Failed to generate authorize response for connector error: {:?}", err ); PaymentAuthorizationError::new( grpc_api_types::payments::PaymentStatus::Pending, Some(format!("Connector error: {error_report}")), Some("CONNECTOR_ERROR".to_string()), None, ) })? } }; Ok(authorize_response) }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "process_authorization_internal", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_fn_grpc-server_4645052546479072000
clm
function
// connector-service/backend/grpc-server/src/server/payments.rs async fn handle_order_creation< T: PaymentMethodDataTypes + Default + Eq + Debug + Send + serde::Serialize + serde::de::DeserializeOwned + Clone + Sync + domain_types::types::CardConversionHelper<T>, >( &self, connector_data: ConnectorData<T>, payment_flow_data: &PaymentFlowData, connector_auth_details: ConnectorAuthType, payload: &PaymentServiceAuthorizeRequest, connector_name: &str, service_name: &str, event_params: EventParams<'_>, ) -> Result<String, PaymentAuthorizationError> { // Get connector integration let connector_integration: BoxedConnectorIntegrationV2< '_, CreateOrder, PaymentFlowData, PaymentCreateOrderData, PaymentCreateOrderResponse, > = connector_data.connector.get_connector_integration_v2(); let currency = common_enums::Currency::foreign_try_from(payload.currency()).map_err(|e| { PaymentAuthorizationError::new( grpc_api_types::payments::PaymentStatus::Pending, Some(format!("Currency conversion failed: {e}")), Some("CURRENCY_ERROR".to_string()), None, ) })?; let order_create_data = PaymentCreateOrderData { amount: common_utils::types::MinorUnit::new(payload.minor_amount), currency, integrity_object: None, metadata: if payload.metadata.is_empty() { None } else { Some(serde_json::to_value(payload.metadata.clone()).unwrap_or_default()) }, webhook_url: payload.webhook_url.clone(), }; let order_router_data = RouterDataV2::< CreateOrder, PaymentFlowData, PaymentCreateOrderData, PaymentCreateOrderResponse, > { flow: std::marker::PhantomData, resource_common_data: payment_flow_data.clone(), connector_auth_type: connector_auth_details, request: order_create_data, response: Err(ErrorResponse::default()), }; // Create event processing parameters let external_event_params = EventProcessingParams { connector_name, service_name, flow_name: FlowName::CreateOrder, event_config: &self.config.events, request_id: event_params.request_id, lineage_ids: event_params.lineage_ids, reference_id: event_params.reference_id, shadow_mode: event_params.shadow_mode, }; // Execute connector processing let response = Box::pin( external_services::service::execute_connector_processing_step( &self.config.proxy, connector_integration, order_router_data, None, external_event_params, None, common_enums::CallConnectorAction::Trigger, ), ) .await .map_err( |e: error_stack::Report<domain_types::errors::ConnectorError>| { PaymentAuthorizationError::new( grpc_api_types::payments::PaymentStatus::Pending, Some(format!("Order creation failed: {e}")), Some("ORDER_CREATION_ERROR".to_string()), None, ) }, )?; match response.response { Ok(PaymentCreateOrderResponse { order_id, .. }) => Ok(order_id), Err(e) => Err(PaymentAuthorizationError::new( grpc_api_types::payments::PaymentStatus::Pending, Some(e.message.clone()), Some(e.code.clone()), Some(e.status_code.into()), )), } }
{ "chunk": null, "crate": "grpc-server", "enum_name": null, "file_size": null, "for_type": null, "function_name": "handle_order_creation", "is_async": false, "is_pub": false, "lines": null, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }