id stringlengths 20 153 | type stringclasses 1
value | granularity stringclasses 14
values | content stringlengths 16 84.3k | metadata dict |
|---|---|---|---|---|
connector-service_body_grpc-server_7718810210258698677 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
// Function: create_payment_void_request
{
PaymentServiceVoidRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
cancellation_reason: Some("Customer requested cancellation".to_string()),
request_ref_id: None,
all_keys_required: None,
browser_info: None,
amount: None,
currency: None,
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_void_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-1920577028512035934 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
// Function: test_health
{
grpc_test!(client, HealthClient<Channel>, {
let response = client
.check(Request::new(HealthCheckRequest {
service: "connector_service".to_string(),
}))
.await
.expect("Failed to call health check")
.into_inner();
assert_eq!(
response.status(),
grpc_api_types::health_check::health_check_response::ServingStatus::Serving
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_health",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-4618166132756716006 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
// Function: test_payment_authorization_auto_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request
let request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_dlocal_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Verify the response
assert!(
response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let _transaction_id = extract_transaction_id(&response);
// Verify payment status - in sandbox, payments may be rejected
let acceptable_statuses = [i32::from(PaymentStatus::Charged)];
assert!(
acceptable_statuses.contains(&response.status),
"Payment should be in CHARGED state (sandbox). Got status: {}",
response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_auto_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-865282097424566206 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
// Function: test_payment_authorization_manual_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_dlocal_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
assert!(
auth_response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let _transaction_id = extract_transaction_id(&auth_response);
// Verify payment status - in sandbox, payments may be rejected
let acceptable_auth_statuses = [i32::from(PaymentStatus::Authorized)];
assert!(
acceptable_auth_statuses.contains(&auth_response.status),
"Payment should be in AUTHORIZED state (sandbox). Got status: {}",
auth_response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_manual_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_9068228309996836759 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
// Function: test_payment_sync
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to sync
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_dlocal_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Add 5-second delay before sync request
sleep(Duration::from_secs(5)).await;
// Create sync request
let sync_request = create_payment_sync_request(&transaction_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_dlocal_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// Verify the sync response - in sandbox, payments may be rejected
let acceptable_sync_statuses = [i32::from(PaymentStatus::Authorized)];
assert!(
acceptable_sync_statuses.contains(&sync_response.status),
"Payment should be in AUTHORIZED state (sandbox). Got status: {}",
sync_response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_sync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-2099337265614418177 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
// Function: test_payment_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_dlocal_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
assert!(
auth_response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status - in sandbox, payments may be rejected
let acceptable_capture_auth_statuses = [i32::from(PaymentStatus::Authorized)];
assert!(
acceptable_capture_auth_statuses.contains(&auth_response.status),
"Payment should be in AUTHORIZED state (sandbox). Got status: {}",
auth_response.status
);
// Add 5-second delay before capture request
sleep(Duration::from_secs(5)).await;
// Create capture request
let capture_request = create_payment_capture_request(&transaction_id);
// Add metadata headers for capture request
let mut capture_grpc_request = Request::new(capture_request);
add_dlocal_metadata(&mut capture_grpc_request);
// Send the capture request
let capture_response = client
.capture(capture_grpc_request)
.await
.expect("gRPC payment_capture call failed")
.into_inner();
// Verify payment status after capture - in sandbox, may still be rejected
let acceptable_capture_statuses = [i32::from(PaymentStatus::Charged)];
assert!(
acceptable_capture_statuses.contains(&capture_response.status),
"Payment should be in CHARGED state (sandbox). Got status: {}",
capture_response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_2665088033369565649 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
// Function: test_refund
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to refund
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_dlocal_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status - in sandbox, payments may be rejected
let acceptable_payment_statuses = [i32::from(PaymentStatus::Charged)];
assert!(
acceptable_payment_statuses.contains(&auth_response.status),
"Payment should be in CHARGED state (sandbox). Got status: {}",
auth_response.status
);
// Add 5-second delay before refund request
sleep(Duration::from_secs(5)).await;
// Create refund request
let refund_request = create_refund_request(&transaction_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_dlocal_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
// Extract the refund ID
let refund_id = refund_response.refund_id.clone();
// Verify the refund response
assert!(!refund_id.is_empty(), "Refund ID should not be empty");
assert!(
refund_response.status == i32::from(RefundStatus::RefundSuccess),
"Refund should be in SUCCESS state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_7913222816220234402 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
// Function: test_refund_sync
{
grpc_test!(client, PaymentServiceClient<Channel>, {
grpc_test!(refund_client, RefundServiceClient<Channel>, {
// First create a payment
let auth_request =
create_payment_authorize_request(common_enums::CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_dlocal_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Add 5-second delay before refund request
sleep(Duration::from_secs(5)).await;
// Create refund request
let refund_request = create_refund_request(&transaction_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_dlocal_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
// Extract the refund ID
let refund_id = refund_response.refund_id.clone();
// Verify the refund response
assert!(!refund_id.is_empty(), "Refund ID should not be empty");
// Add 5-second delay before refund sync request
sleep(Duration::from_secs(5)).await;
// Create refund sync request
let refund_sync_request = create_refund_sync_request(&transaction_id, &refund_id);
// Add metadata headers for refund sync request
let mut refund_sync_grpc_request = Request::new(refund_sync_request);
add_dlocal_metadata(&mut refund_sync_grpc_request);
// Send the refund sync request
let refund_sync_response = refund_client
.get(refund_sync_grpc_request)
.await
.expect("gRPC refund_sync call failed")
.into_inner();
// Verify the refund sync response
assert!(
refund_sync_response.status == i32::from(RefundStatus::RefundSuccess),
"Refund should be in SUCCESS state"
);
});
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund_sync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_271339099011406746 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/dlocal_payment_flows_test.rs
// Function: test_payment_void
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment with manual capture (so it stays in authorized state)
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_dlocal_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status - in sandbox, payments may be rejected
let acceptable_void_auth_statuses = [i32::from(PaymentStatus::Authorized)];
assert!(
acceptable_void_auth_statuses.contains(&auth_response.status),
"Payment should be in AUTHORIZED state (sandbox). Got status: {}",
auth_response.status
);
// Add 5-second delay before void request
sleep(Duration::from_secs(5)).await;
// Create void request
let void_request = create_payment_void_request(&transaction_id);
// Add metadata headers for void request
let mut void_grpc_request = Request::new(void_request);
add_dlocal_metadata(&mut void_grpc_request);
// Send the void request
let void_response = client
.void(void_grpc_request)
.await
.expect("gRPC payment_void call failed")
.into_inner();
// Verify the void response - in sandbox, may have different statuses
let acceptable_void_statuses = [i32::from(PaymentStatus::Voided)];
assert!(
acceptable_void_statuses.contains(&void_response.status),
"Payment should be in VOIDED state (sandbox). Got status: {}",
void_response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_void",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_5203756819315463270 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: add_nexinets_metadata
{
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load nexinets credentials");
let (api_key, key1) = match auth {
domain_types::router_data::ConnectorAuthType::BodyKey { api_key, key1 } => {
(api_key.expose(), key1.expose())
}
_ => panic!("Expected BodyKey auth type for nexinets"),
};
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request
.metadata_mut()
.append("x-auth", AUTH_TYPE.parse().expect("Failed to parse x-auth"));
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
request
.metadata_mut()
.append("x-key1", key1.parse().expect("Failed to parse x-key1"));
request.metadata_mut().append(
"x-merchant-id",
MERCHANT_ID.parse().expect("Failed to parse x-merchant-id"),
);
request.metadata_mut().append(
"x-request-id",
format!("test_request_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_nexinets_metadata",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-8143901725655754752 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: extract_transaction_id
{
match &response.transaction_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector transaction ID"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_transaction_id",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-7324568418767787954 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: extract_request_ref_id
{
match &response.response_ref_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector response_ref_id"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_request_ref_id",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-3349245867297723084 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: create_payment_authorize_request
{
let card_details = card_payment_method_type::CardType::Credit(CardDetails {
card_number: Some(CardNumber::from_str(TEST_CARD_NUMBER).unwrap()),
card_exp_month: Some(Secret::new(TEST_CARD_EXP_MONTH.to_string())),
card_exp_year: Some(Secret::new(TEST_CARD_EXP_YEAR.to_string())),
card_cvc: Some(Secret::new(TEST_CARD_CVC.to_string())),
card_holder_name: Some(Secret::new(TEST_CARD_HOLDER.to_string())),
card_network: Some(1),
card_issuer: None,
card_type: None,
card_issuing_country_alpha2: None,
bank_code: None,
nick_name: None,
});
PaymentServiceAuthorizeRequest {
amount: TEST_AMOUNT,
minor_amount: TEST_AMOUNT,
currency: i32::from(Currency::Eur),
payment_method: Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType {
card_type: Some(card_details),
})),
}),
return_url: Some("https://duck.com".to_string()),
email: Some(TEST_EMAIL.to_string().into()),
address: Some(grpc_api_types::payments::PaymentAddress::default()),
auth_type: i32::from(AuthenticationType::NoThreeDs),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("nexinets_test_{}", get_timestamp()))),
}),
enrolled_for_3ds: false,
request_incremental_authorization: false,
capture_method: Some(i32::from(capture_method)),
// payment_method_type: Some(i32::from(PaymentMethodType::Credit)),
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_authorize_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_7750518949056343709 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: create_payment_sync_request
{
PaymentServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(request_ref_id.to_string())),
}),
// all_keys_required: None,
capture_method: None,
amount: TEST_AMOUNT,
currency: i32::from(Currency::Eur),
handle_response: None,
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_sync_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_1921466990052191499 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: create_payment_capture_request
{
PaymentServiceCaptureRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
amount_to_capture: TEST_AMOUNT,
currency: i32::from(Currency::Eur),
multiple_capture_data: None,
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(request_ref_id.to_string())),
}),
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_capture_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-3675490571471844015 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: create_refund_request
{
// Create connector metadata as a proper JSON object
let mut connector_metadata = HashMap::new();
connector_metadata.insert("order_id".to_string(), request_ref_id);
let connector_metadata_json =
serde_json::to_string(&connector_metadata).expect("Failed to serialize connector metadata");
let mut metadata = HashMap::new();
metadata.insert("connector_metadata".to_string(), connector_metadata_json);
PaymentServiceRefundRequest {
refund_id: format!("refund_{}", get_timestamp()),
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
currency: i32::from(Currency::Eur),
payment_amount: TEST_AMOUNT,
refund_amount: TEST_AMOUNT,
minor_payment_amount: TEST_AMOUNT,
minor_refund_amount: TEST_AMOUNT,
reason: None,
webhook_url: None,
browser_info: None,
merchant_account_id: None,
capture_method: None,
request_ref_id: None,
metadata,
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-783794505401645596 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: create_refund_sync_request
{
RefundServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
refund_id: refund_id.to_string(),
refund_reason: None,
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(request_ref_id.to_string())),
}),
browser_info: None,
refund_metadata: HashMap::new(),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_sync_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-2494081581764821774 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: visit_3ds_authentication_url
{
// Get the key1 value from auth credentials for the URL
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load nexinets credentials");
let key1 = match auth {
domain_types::router_data::ConnectorAuthType::BodyKey { key1, .. } => key1.expose(),
_ => panic!("Expected BodyKey auth type for nexinets"),
};
// Construct the 3DS authentication URL with correct format
let url = format!("https://pptest.payengine.de/three-ds-v2-order/{key1}/{request_ref_id}",);
// Create reqwest client with timeout and proper TLS configuration
let client = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(30))
.danger_accept_invalid_certs(false) // Keep TLS verification enabled
.user_agent("nexinets-test-client/1.0")
.build()?;
// Send GET request
let response = client.get(&url).send().await?;
// Read response body for additional debugging (optional)
let body = response.text().await?;
// Log first 200 characters of response for debugging (if not empty)
if !body.is_empty() {
let _preview = if body.len() > 200 {
&body[..200]
} else {
&body
};
}
Ok(())
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "visit_3ds_authentication_url",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-8975909391053314531 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: test_health
{
grpc_test!(client, HealthClient<Channel>, {
let response = client
.check(Request::new(HealthCheckRequest {
service: "connector_service".to_string(),
}))
.await
.expect("Failed to call health check")
.into_inner();
assert_eq!(
response.status(),
grpc_api_types::health_check::health_check_response::ServingStatus::Serving
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_health",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_2573844904315562311 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: test_payment_authorization_auto_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request
let request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_nexinets_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Verify the response
assert!(
response.transaction_id.is_some(),
"Resource ID should be present"
);
assert!(
response.status == i32::from(PaymentStatus::AuthenticationPending)
|| response.status == i32::from(PaymentStatus::Pending)
|| response.status == i32::from(PaymentStatus::Charged),
"Payment should be in AuthenticationPending or Pending state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_auto_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-6349149238852943944 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: test_payment_authorization_manual_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Add delay of 2 seconds
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_nexinets_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Extract the request ref ID which is Order_id for nexinets
let request_ref_id = extract_request_ref_id(&auth_response);
let mut final_payment_status = auth_response.status;
// Check if payment requires 3DS authentication
if auth_response.status == i32::from(PaymentStatus::AuthenticationPending) {
// Visit the 3DS authentication URL to simulate user completing authentication
let _ = visit_3ds_authentication_url(&request_ref_id).await;
// Wait a moment for the authentication state to be updated
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
// Sync the payment to get updated status after 3DS authentication
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
let mut sync_grpc_request = Request::new(sync_request);
add_nexinets_metadata(&mut sync_grpc_request);
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
final_payment_status = sync_response.status;
// Note: Simply visiting the 3DS URL doesn't complete the authentication
// The payment may still be in AuthenticationPending state
// In a real scenario, the user would interact with the 3DS page
// For testing purposes, we'll accept either AuthenticationPending or Authorized
assert!(
final_payment_status == i32::from(PaymentStatus::Authorized)
|| final_payment_status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AUTHORIZED or still AUTHENTICATION_PENDING state after visiting 3DS URL. Current status: {final_payment_status}",
);
} else {
// Verify payment status is authorized (for manual capture without 3DS)
assert!(
auth_response.status == i32::from(PaymentStatus::Authorized),
"Payment should be in AUTHORIZED state with manual capture"
);
}
// Only proceed with capture if payment is in Authorized state
// If still in AuthenticationPending, skip capture as it requires user
// interaction
if final_payment_status == i32::from(PaymentStatus::Authorized) {
// Create capture request (which already includes proper connector metadata)
let capture_request = create_payment_capture_request(&transaction_id, &request_ref_id);
// Add metadata headers for capture request
let mut capture_grpc_request = Request::new(capture_request);
add_nexinets_metadata(&mut capture_grpc_request);
// Send the capture request
let capture_response = client
.capture(capture_grpc_request)
.await
.expect("gRPC payment_capture call failed")
.into_inner();
// Verify payment status is charged after capture
assert!(
capture_response.status == i32::from(PaymentStatus::Charged),
"Payment should be in CHARGED state after capture"
);
}
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_manual_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-7562603936132445620 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: test_payment_sync
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Add delay of 4 seconds
tokio::time::sleep(std::time::Duration::from_secs(4)).await;
// First create a payment to sync
let auth_request = create_payment_authorize_request(CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_nexinets_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Extract the request ref ID which is Order_id for nexinets
let request_ref_id = extract_request_ref_id(&auth_response);
// Check if payment requires 3DS authentication
if auth_response.status == i32::from(PaymentStatus::AuthenticationPending) {
let _ = visit_3ds_authentication_url(&request_ref_id).await;
// Wait a moment for the authentication state to be updated
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
}
// Create sync request
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_nexinets_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// For testing purposes, we'll accept AuthenticationPending or Authorized
assert!(
sync_response.status == i32::from(PaymentStatus::Authorized)
|| sync_response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AUTHORIZED or AUTHENTICATION_PENDING state. Current status: {}",
sync_response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_sync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_8168760420965969864 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: test_refund
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Add delay of 6 seconds
tokio::time::sleep(std::time::Duration::from_secs(6)).await;
// Create the payment authorization request
let request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_nexinets_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&response);
// Extract the request ref ID which is Order_id for nexinets
let request_ref_id = extract_request_ref_id(&response);
// Check if payment requires 3DS authentication
if response.status == i32::from(PaymentStatus::AuthenticationPending) {
let _ = visit_3ds_authentication_url(&request_ref_id).await;
// Wait a moment for the authentication state to be updated
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
// Sync the payment to get updated status after 3DS authentication
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
let mut sync_grpc_request = Request::new(sync_request);
add_nexinets_metadata(&mut sync_grpc_request);
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
assert!(
sync_response.status == i32::from(PaymentStatus::Charged)
|| sync_response.status == i32::from(PaymentStatus::Authorized)
|| sync_response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in CHARGED, AUTHORIZED, or AUTHENTICATION_PENDING state after 3DS URL visit. Current status: {}",
sync_response.status
);
} else {
assert!(
response.status == i32::from(PaymentStatus::AuthenticationPending)
|| response.status == i32::from(PaymentStatus::Pending)
|| response.status == i32::from(PaymentStatus::Charged),
"Payment should be in AuthenticationPending or Pending state"
);
}
// Wait a bit longer to ensure the payment is fully processed
tokio::time::sleep(tokio::time::Duration::from_secs(12)).await;
// Only attempt refund if payment is in a refundable state
// Check final payment status to determine if refund is possible
let final_sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
let mut final_sync_grpc_request = Request::new(final_sync_request);
add_nexinets_metadata(&mut final_sync_grpc_request);
let final_sync_response = client
.get(final_sync_grpc_request)
.await
.expect("gRPC final payment_sync call failed")
.into_inner();
if final_sync_response.status == i32::from(PaymentStatus::Charged)
|| final_sync_response.status == i32::from(PaymentStatus::Authorized)
{
// Create refund request
let refund_request = create_refund_request(&transaction_id, &request_ref_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_nexinets_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
// Verify the refund response
assert!(
refund_response.status == i32::from(RefundStatus::RefundSuccess),
"Refund should be in RefundSuccess state"
);
}
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_7650594654503475134 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/nexinets_payment_flows_test.rs
// Function: test_refund_sync
{
grpc_test!(client, PaymentServiceClient<Channel>, {
grpc_test!(refund_client, RefundServiceClient<Channel>, {
// Add delay of 8 seconds
tokio::time::sleep(std::time::Duration::from_secs(8)).await;
// First create a payment
let auth_request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_nexinets_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Extract the request ref ID which is Order_id for nexinets
let request_ref_id = extract_request_ref_id(&auth_response);
// Check if payment requires 3DS authentication
if auth_response.status == i32::from(PaymentStatus::AuthenticationPending) {
let _ = visit_3ds_authentication_url(&request_ref_id).await;
// Wait a moment for the authentication state to be updated
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
} else {
// Wait for payment to process
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
}
// Create sync request to check payment status
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_nexinets_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
assert!(
sync_response.status == i32::from(PaymentStatus::Charged)
|| sync_response.status == i32::from(PaymentStatus::Authorized)
|| sync_response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in CHARGED, AUTHORIZED, or AUTHENTICATION_PENDING state. Current status: {}",
sync_response.status
);
// Only attempt refund if payment is in a refundable state
if sync_response.status == i32::from(PaymentStatus::Charged)
|| sync_response.status == i32::from(PaymentStatus::Authorized)
{
// Create refund request
let refund_request = create_refund_request(&transaction_id, &request_ref_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_nexinets_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
// Verify the refund response
assert!(
refund_response.status == i32::from(RefundStatus::RefundSuccess),
"Refund should be in RefundSuccess state"
);
let refund_id = extract_refund_id(&refund_response);
// Wait a bit longer to ensure the refund is fully processed
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
// Create refund sync request with our mock ID
let refund_sync_request =
create_refund_sync_request(&transaction_id, refund_id, &request_ref_id);
// Add metadata headers for refund sync request
let mut refund_sync_grpc_request = Request::new(refund_sync_request);
add_nexinets_metadata(&mut refund_sync_grpc_request);
// Send the refund sync request
let refund_sync_response = refund_client
.get(refund_sync_grpc_request)
.await
.expect("gRPC refund sync call failed")
.into_inner();
// Verify the refund sync response
assert!(
refund_sync_response.status == i32::from(RefundStatus::RefundSuccess),
"Refund Sync should be in RefundSuccess state"
);
}
});
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund_sync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_8361750996602241665 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: add_aci_metadata
{
// Get API credentials using the common credential loading utility
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load ACI credentials");
let (api_key, key1) = match auth {
domain_types::router_data::ConnectorAuthType::BodyKey { api_key, key1 } => {
(api_key.expose(), key1.expose())
}
_ => panic!("Expected BodyKey auth type for ACI"),
};
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request.metadata_mut().append(
"x-auth",
"body-key".parse().expect("Failed to parse x-auth"),
);
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
request
.metadata_mut()
.append("x-key1", key1.parse().expect("Failed to parse x-key1"));
request.metadata_mut().append(
"x-merchant-id",
"test_merchant"
.parse()
.expect("Failed to parse x-merchant-id"),
);
request.metadata_mut().append(
"x-tenant-id",
"default".parse().expect("Failed to parse x-tenant-id"),
);
request.metadata_mut().append(
"x-request-id",
format!("test_request_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
request.metadata_mut().append(
"x-connector-request-reference-id",
format!("conn_ref_{}", get_timestamp())
.parse()
.expect("Failed to parse x-connector-request-reference-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_aci_metadata",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-6353093418592794739 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: extract_transaction_id
{
match &response.transaction_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector transaction ID"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_transaction_id",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-5349812120216172950 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: create_payment_authorize_request
{
// Initialize with all required fields
let mut request = PaymentServiceAuthorizeRequest::default();
// Set request reference ID
request.request_ref_id = Some(Identifier {
id_type: Some(IdType::Id(format!("aci_test_{}", get_timestamp()))),
});
// Set the basic payment details
request.amount = TEST_AMOUNT;
request.minor_amount = TEST_AMOUNT;
request.currency = i32::from(Currency::Usd);
// Set up card payment method using the correct structure
let card_details = card_payment_method_type::CardType::Credit(CardDetails {
card_number: Some(CardNumber::from_str(TEST_CARD_NUMBER).unwrap()),
card_exp_month: Some(Secret::new(TEST_CARD_EXP_MONTH.to_string())),
card_exp_year: Some(Secret::new(TEST_CARD_EXP_YEAR.to_string())),
card_cvc: Some(Secret::new(TEST_CARD_CVC.to_string())),
card_holder_name: Some(Secret::new(TEST_CARD_HOLDER.to_string())),
card_issuer: None,
card_network: Some(1_i32), // Default to Visa network
card_type: None,
card_issuing_country_alpha2: None,
bank_code: None,
nick_name: None,
});
request.payment_method = Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType {
card_type: Some(card_details),
})),
});
// Set connector customer ID
request.customer_id = Some("TEST_CONNECTOR".to_string());
// Set the customer information with static email (can be made dynamic)
request.email = Some(TEST_EMAIL.to_string().into());
// Set up address structure
request.address = Some(PaymentAddress {
billing_address: Some(Address {
first_name: Some("Test".to_string().into()),
last_name: Some("User".to_string().into()),
line1: Some("123 Test Street".to_string().into()),
line2: None,
line3: None,
city: Some("Test City".to_string().into()),
state: Some("NY".to_string().into()),
zip_code: Some("10001".to_string().into()),
country_alpha2_code: Some(i32::from(CountryAlpha2::Us)),
phone_number: None,
phone_country_code: None,
email: None,
}),
shipping_address: None,
});
// Set up browser information
let browser_info = BrowserInformation {
color_depth: None,
java_enabled: Some(false),
screen_height: Some(1080),
screen_width: Some(1920),
user_agent: Some("Mozilla/5.0 (compatible; TestAgent/1.0)".to_string()),
accept_header: Some(
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8".to_string(),
),
java_script_enabled: Some(false),
language: Some("en-US".to_string()),
ip_address: None,
os_type: None,
os_version: None,
device_model: None,
accept_language: None,
time_zone_offset_minutes: None,
referer: None,
};
request.browser_info = Some(browser_info);
// Set return URL
request.return_url = Some("https://example.com/return".to_string());
// Set the transaction details
request.auth_type = i32::from(AuthenticationType::NoThreeDs);
request.request_incremental_authorization = true;
request.enrolled_for_3ds = true;
// Set capture method with proper conversion
if let common_enums::CaptureMethod::Manual = capture_method {
request.capture_method = Some(i32::from(CaptureMethod::Manual));
} else {
request.capture_method = Some(i32::from(CaptureMethod::Automatic));
}
// Set connector metadata (empty for generic template)
request.metadata = HashMap::new();
request
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_authorize_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-867160144935410371 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: create_payment_sync_request
{
PaymentServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("aci_sync_{}", get_timestamp()))),
}),
capture_method: Some(i32::from(CaptureMethod::Automatic)),
handle_response: None,
amount: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_sync_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-1023234141265144615 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: create_payment_capture_request
{
PaymentServiceCaptureRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
amount_to_capture: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
multiple_capture_data: None,
connector_metadata: HashMap::new(),
request_ref_id: None,
browser_info: None,
capture_method: None,
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_capture_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_8755601822934380549 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: create_refund_request
{
PaymentServiceRefundRequest {
refund_id: format!("refund_{}", get_timestamp()),
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
currency: i32::from(Currency::Usd),
payment_amount: TEST_AMOUNT,
refund_amount: TEST_AMOUNT,
minor_payment_amount: TEST_AMOUNT,
minor_refund_amount: TEST_AMOUNT,
reason: None,
webhook_url: None,
metadata: HashMap::new(),
refund_metadata: HashMap::new(),
browser_info: None,
merchant_account_id: None,
capture_method: None,
request_ref_id: None,
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_7024445772183144600 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: create_payment_void_request
{
PaymentServiceVoidRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
cancellation_reason: Some("Customer requested cancellation".to_string()),
request_ref_id: None,
all_keys_required: None,
browser_info: None,
amount: None,
currency: None,
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_void_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_2170273383780895929 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: create_register_request
{
let card_details = card_payment_method_type::CardType::Credit(CardDetails {
card_number: Some(CardNumber::from_str(TEST_CARD_NUMBER).unwrap()),
card_exp_month: Some(Secret::new(TEST_CARD_EXP_MONTH.to_string())),
card_exp_year: Some(Secret::new(TEST_CARD_EXP_YEAR.to_string())),
card_cvc: Some(Secret::new(TEST_CARD_CVC.to_string())),
card_holder_name: Some(Secret::new(TEST_CARD_HOLDER.to_string())),
card_issuer: None,
card_network: Some(1_i32), // Visa network
card_type: None,
card_issuing_country_alpha2: None,
bank_code: None,
nick_name: None,
});
PaymentServiceRegisterRequest {
minor_amount: Some(TEST_AMOUNT),
currency: i32::from(Currency::Usd),
payment_method: Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType {
card_type: Some(card_details),
})),
}),
customer_name: Some(TEST_CARD_HOLDER.to_string()),
email: Some(TEST_EMAIL.to_string().into()),
customer_acceptance: Some(CustomerAcceptance {
acceptance_type: i32::from(AcceptanceType::Offline),
accepted_at: 0,
online_mandate_details: None,
}),
address: Some(PaymentAddress {
billing_address: Some(Address {
first_name: Some("Test".to_string().into()),
last_name: Some("Customer".to_string().into()),
line1: Some("123 Test St".to_string().into()),
line2: None,
line3: None,
city: Some("Test City".to_string().into()),
state: Some("NY".to_string().into()),
zip_code: Some("10001".to_string().into()),
country_alpha2_code: Some(i32::from(CountryAlpha2::Us)),
phone_number: None,
phone_country_code: None,
email: Some(TEST_EMAIL.to_string().into()),
}),
shipping_address: None,
}),
auth_type: i32::from(AuthenticationType::NoThreeDs),
setup_future_usage: Some(i32::from(FutureUsage::OffSession)),
enrolled_for_3ds: false,
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("mandate_{}", get_timestamp()))),
}),
metadata: HashMap::new(),
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_register_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-317732705414966404 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: create_repeat_payment_request
{
let mandate_reference = MandateReference {
mandate_id: Some(mandate_id.to_string()),
payment_method_id: None,
};
// Create metadata matching your JSON format
let mut metadata = HashMap::new();
metadata.insert("order_type".to_string(), "recurring".to_string());
metadata.insert(
"customer_note".to_string(),
"Monthly subscription payment".to_string(),
);
PaymentServiceRepeatEverythingRequest {
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("mandate_{}", get_timestamp()))),
}),
mandate_reference: Some(mandate_reference),
amount: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
minor_amount: TEST_AMOUNT,
merchant_order_reference_id: Some(format!("repeat_order_{}", get_timestamp())),
metadata,
webhook_url: Some("https://your-webhook-url.com/payments/webhook".to_string()),
capture_method: None,
email: None,
browser_info: None,
test_mode: None,
payment_method_type: None,
merchant_account_metadata: HashMap::new(),
state: None,
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_repeat_payment_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_5653901729355680281 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: test_health
{
grpc_test!(client, HealthClient<Channel>, {
let response = client
.check(Request::new(HealthCheckRequest {
service: "connector_service".to_string(),
}))
.await
.expect("Failed to call health check")
.into_inner();
assert_eq!(
response.status(),
grpc_api_types::health_check::health_check_response::ServingStatus::Serving
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_health",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-5925368234883700383 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: test_payment_authorization_auto_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request
let request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_aci_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Verify the response
assert!(
response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let _transaction_id = extract_transaction_id(&response);
// Verify payment status
assert_eq!(
response.status,
i32::from(PaymentStatus::Charged),
"Payment should be in CHARGED state for automatic capture"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_auto_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_7058534996290360287 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: test_payment_authorization_manual_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_aci_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
assert!(
auth_response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let _transaction_id = extract_transaction_id(&auth_response);
// Verify payment status is authorized (for manual capture)
assert_eq!(
auth_response.status,
i32::from(PaymentStatus::Authorized),
"Payment should be in AUTHORIZED state with manual capture"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_manual_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-8371798294911903448 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: test_payment_sync
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to sync
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_aci_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Create sync request
let sync_request = create_payment_sync_request(&transaction_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_aci_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// Verify the sync response - allow both AUTHORIZED and PENDING states
let acceptable_sync_statuses = [
i32::from(PaymentStatus::Authorized),
i32::from(PaymentStatus::Charged),
];
assert!(
acceptable_sync_statuses.contains(&sync_response.status),
"Payment should be in AUTHORIZED or CHARGED state, but was: {}",
sync_response.status
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_sync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_1782508465075671306 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: test_payment_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_aci_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
assert!(
auth_response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status is authorized (for manual capture)
assert!(
auth_response.status == i32::from(PaymentStatus::Authorized),
"Payment should be in AUTHORIZED state with manual capture"
);
// Create capture request
let capture_request = create_payment_capture_request(&transaction_id);
// Add metadata headers for capture request
let mut capture_grpc_request = Request::new(capture_request);
add_aci_metadata(&mut capture_grpc_request);
// Send the capture request
let capture_response = client
.capture(capture_grpc_request)
.await
.expect("gRPC payment_capture call failed")
.into_inner();
// Verify payment status is charged after capture
assert!(
capture_response.status == i32::from(PaymentStatus::Charged),
"Payment should be in CHARGED state after capture"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-5471520689611595850 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: test_refund
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to refund
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_aci_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status - allow both CHARGED and PENDING states
let acceptable_payment_statuses = [i32::from(PaymentStatus::Charged)];
assert!(
acceptable_payment_statuses.contains(&auth_response.status),
"Payment should be in CHARGED state before attempting refund, but was: {}",
auth_response.status
);
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
// Create refund request
let refund_request = create_refund_request(&transaction_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_aci_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
// Extract the refund ID
let refund_id = refund_response.refund_id.clone();
// Verify the refund response
assert!(!refund_id.is_empty(), "Refund ID should not be empty");
assert!(
refund_response.status == i32::from(RefundStatus::RefundSuccess)
|| refund_response.status == i32::from(RefundStatus::RefundPending),
"Refund should be in SUCCESS or PENDING state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_5205300293550621183 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: test_payment_void
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment with manual capture (so it stays in authorized state)
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_aci_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment is in authorized state
assert!(
auth_response.status == i32::from(PaymentStatus::Authorized),
"Payment should be in AUTHORIZED state before void"
);
// Create void request
let void_request = create_payment_void_request(&transaction_id);
// Add metadata headers for void request
let mut void_grpc_request = Request::new(void_request);
add_aci_metadata(&mut void_grpc_request);
// Send the void request
let void_response = client
.void(void_grpc_request)
.await
.expect("gRPC payment_void call failed")
.into_inner();
// Verify the void response
assert!(
void_response.status == i32::from(PaymentStatus::Voided),
"Payment should be in VOIDED state after void"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_void",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-2168281538200383900 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: test_register
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the register request
let request = create_register_request();
// Add metadata headers
let mut grpc_request = Request::new(request);
add_aci_metadata(&mut grpc_request);
// Send the request
let response = client
.register(grpc_request)
.await
.expect("gRPC register call failed")
.into_inner();
// Verify the response
assert!(
response.registration_id.is_some(),
"Registration ID should be present"
);
// Check if we have a mandate reference
assert!(
response.mandate_reference.is_some(),
"Mandate reference should be present"
);
// Verify the mandate reference has the expected structure
if let Some(mandate_ref) = &response.mandate_reference {
assert!(
mandate_ref.mandate_id.is_some(),
"Mandate ID should be present"
);
// Verify the mandate ID is not empty
if let Some(mandate_id) = &mandate_ref.mandate_id {
assert!(!mandate_id.is_empty(), "Mandate ID should not be empty");
}
}
// Verify no error occurred
assert!(
response.error_message.is_none() || response.error_message.as_ref().unwrap().is_empty(),
"No error message should be present for successful register"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_register",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_6132595416930104492 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/aci_payment_flows_test.rs
// Function: test_repeat_everything
{
grpc_test!(client, PaymentServiceClient<Channel>, {
tokio::time::sleep(std::time::Duration::from_secs(4)).await;
// First, create a mandate using register
let register_request = create_register_request();
let mut register_grpc_request = Request::new(register_request);
add_aci_metadata(&mut register_grpc_request);
let register_response = client
.register(register_grpc_request)
.await
.expect("gRPC register call failed")
.into_inner();
// Verify we got a mandate reference
assert!(
register_response.mandate_reference.is_some(),
"Mandate reference should be present"
);
let mandate_id = register_response
.mandate_reference
.as_ref()
.unwrap()
.mandate_id
.as_ref()
.expect("Mandate ID should be present");
// Now perform a repeat payment using the mandate
let repeat_request = create_repeat_payment_request(mandate_id);
let mut repeat_grpc_request = Request::new(repeat_request);
add_aci_metadata(&mut repeat_grpc_request);
// Send the repeat payment request
let repeat_response = client
.repeat_everything(repeat_grpc_request)
.await
.expect("gRPC repeat_everything call failed")
.into_inner();
// Verify the response
assert!(
repeat_response.transaction_id.is_some(),
"Transaction ID should be present"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_repeat_everything",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-5781097228737042236 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/cryptopay_payment_flows_test.rs
// Function: add_cryptopay_metadata
{
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load cryptopay credentials");
let (api_key, key1) = match auth {
domain_types::router_data::ConnectorAuthType::BodyKey { api_key, key1 } => {
(api_key.expose(), key1.expose())
}
_ => panic!("Expected BodyKey auth type for cryptopay"),
};
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request
.metadata_mut()
.append("x-auth", AUTH_TYPE.parse().expect("Failed to parse x-auth"));
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
request
.metadata_mut()
.append("x-key1", key1.parse().expect("Failed to parse x-key1"));
request.metadata_mut().append(
"x-merchant-id",
MERCHANT_ID.parse().expect("Failed to parse x-merchant-id"),
);
request.metadata_mut().append(
"x-request-id",
format!("test_request_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_cryptopay_metadata",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_2679368741617297680 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/cryptopay_payment_flows_test.rs
// Function: extract_request_ref_id
{
match &response.response_ref_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector response_ref_id"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_request_ref_id",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-4983914962124537193 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/cryptopay_payment_flows_test.rs
// Function: create_authorize_request
{
PaymentServiceAuthorizeRequest {
amount: TEST_AMOUNT,
minor_amount: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
payment_method: Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Crypto(
CryptoCurrencyPaymentMethodType {
crypto_currency: Some(CryptoCurrency {
pay_currency: Some(TEST_PAY_CURRENCY.to_string()),
network: Some(TEST_NETWORK.to_string()),
}),
},
)),
}),
return_url: Some(
"https://hyperswitch.io/connector-service/authnet_webhook_grpcurl".to_string(),
),
webhook_url: Some(
"https://hyperswitch.io/connector-service/authnet_webhook_grpcurl".to_string(),
),
email: Some(TEST_EMAIL.to_string().into()),
address: Some(grpc_api_types::payments::PaymentAddress::default()),
auth_type: i32::from(AuthenticationType::NoThreeDs),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("cryptopay_test_{}", get_timestamp()))),
}),
enrolled_for_3ds: false,
request_incremental_authorization: false,
capture_method: Some(i32::from(capture_method)),
// payment_method_type: Some(i32::from(PaymentMethodType::Credit)),
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_authorize_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_4930655635886646064 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/cryptopay_payment_flows_test.rs
// Function: create_payment_sync_request
{
PaymentServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id("not_required".to_string())),
}),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(request_ref_id.to_string())),
}),
capture_method: None,
handle_response: None,
amount: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_sync_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-57979169531772516 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/cryptopay_payment_flows_test.rs
// Function: test_health
{
grpc_test!(client, HealthClient<Channel>, {
let response = client
.check(Request::new(HealthCheckRequest {
service: "connector_service".to_string(),
}))
.await
.expect("Failed to call health check")
.into_inner();
assert_eq!(
response.status(),
grpc_api_types::health_check::health_check_response::ServingStatus::Serving
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_health",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_8114262160946874902 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/cryptopay_payment_flows_test.rs
// Function: test_payment_authorization_and_psync
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request
let request = create_authorize_request(CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_cryptopay_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC authorize call failed")
.into_inner();
// Add comprehensive logging for debugging
println!("=== CRYPTOPAY PAYMENT RESPONSE DEBUG ===");
println!("Response: {:#?}", response);
println!("Status: {}", response.status);
println!("Error code: {:?}", response.error_code);
println!("Error message: {:?}", response.error_message);
println!("Status code: {:?}", response.status_code);
println!("=== END DEBUG ===");
// Check for different possible statuses that Cryptopay might return
// Status 21 = Failure, which indicates auth/credential issues
if response.status == 21 {
// This is a failure status - likely auth/credential issues
assert_eq!(response.status, 21, "Expected failure status due to auth issues");
println!("Cryptopay authentication/credential issue detected - test expecting failure");
return; // Exit early since we can't proceed with sync test
}
let acceptable_statuses = [
i32::from(PaymentStatus::AuthenticationPending),
i32::from(PaymentStatus::Pending),
i32::from(PaymentStatus::Charged),
];
assert!(
acceptable_statuses.contains(&response.status),
"Payment should be in AuthenticationPending, Pending, or Charged state, but was: {}",
response.status
);
let request_ref_id = extract_request_ref_id(&response);
// Create sync request
let sync_request = create_payment_sync_request(&request_ref_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_cryptopay_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// Verify the sync response
assert!(
sync_response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AuthenticationPending state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_and_psync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_5872467265881890296 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: add_noon_metadata
{
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load noon credentials");
let (api_key, key1, api_secret) = match auth {
domain_types::router_data::ConnectorAuthType::SignatureKey {
api_key,
key1,
api_secret,
} => (api_key.expose(), key1.expose(), api_secret.expose()),
_ => panic!("Expected SignatureKey auth type for noon"),
};
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request
.metadata_mut()
.append("x-auth", AUTH_TYPE.parse().expect("Failed to parse x-auth"));
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
request
.metadata_mut()
.append("x-key1", key1.parse().expect("Failed to parse x-key1"));
// Add merchant ID which is required by the server
request.metadata_mut().append(
"x-merchant-id",
"12abc123-f8a3-99b8-9ef8-b31180358hh4"
.parse()
.expect("Failed to parse x-merchant-id"),
);
request.metadata_mut().append(
"x-api-secret",
api_secret.parse().expect("Failed to parse x-api-secret"),
);
// Add tenant ID which is required by the server
request.metadata_mut().append(
"x-tenant-id",
"default".parse().expect("Failed to parse x-tenant-id"),
);
// Add request ID which is required by the server
request.metadata_mut().append(
"x-request-id",
format!("noon_req_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_noon_metadata",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-146625334556709608 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: extract_transaction_id
{
match &response.transaction_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector transaction ID"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_transaction_id",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_7555674274079742481 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: extract_request_ref_id
{
match &response.response_ref_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector response_ref_id"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_request_ref_id",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-8164854619557722318 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: create_payment_authorize_request
{
let card_details = card_payment_method_type::CardType::Credit(CardDetails {
card_number: Some(CardNumber::from_str(TEST_CARD_NUMBER).unwrap()),
card_exp_month: Some(Secret::new(TEST_CARD_EXP_MONTH.to_string())),
card_exp_year: Some(Secret::new(TEST_CARD_EXP_YEAR.to_string())),
card_cvc: Some(Secret::new(TEST_CARD_CVC.to_string())),
card_holder_name: Some(Secret::new(TEST_CARD_HOLDER.to_string())),
card_network: Some(1),
card_issuer: None,
card_type: None,
card_issuing_country_alpha2: None,
bank_code: None,
nick_name: None,
});
let mut metadata = HashMap::new();
metadata.insert(
"description".to_string(),
"Its my first payment request".to_string(),
);
PaymentServiceAuthorizeRequest {
amount: TEST_AMOUNT,
minor_amount: TEST_AMOUNT,
currency: i32::from(Currency::Aed),
payment_method: Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType {
card_type: Some(card_details),
})),
}),
return_url: Some("https://duck.com".to_string()),
email: Some(TEST_EMAIL.to_string().into()),
address: Some(grpc_api_types::payments::PaymentAddress::default()),
auth_type: i32::from(AuthenticationType::NoThreeDs),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("noon_test_{}", get_timestamp()))),
}),
enrolled_for_3ds: false,
request_incremental_authorization: false,
capture_method: Some(i32::from(capture_method)),
order_category: Some("PAY".to_string()),
metadata,
// payment_method_type: Some(i32::from(PaymentMethodType::Credit)),
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_authorize_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_8826172285940183611 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: create_payment_sync_request
{
PaymentServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(request_ref_id.to_string())),
}),
// all_keys_required: None,
capture_method: None,
handle_response: None,
amount: TEST_AMOUNT,
currency: i32::from(Currency::Aed),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_sync_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-6457728065766127221 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: create_payment_capture_request
{
PaymentServiceCaptureRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
amount_to_capture: TEST_AMOUNT,
currency: i32::from(Currency::Aed),
multiple_capture_data: None,
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("capture_ref_{}", get_timestamp()))),
}),
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_capture_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_4152489787873224962 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: create_payment_void_request
{
PaymentServiceVoidRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
cancellation_reason: None,
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("void_ref_{}", get_timestamp()))),
}),
all_keys_required: None,
browser_info: None,
amount: None,
currency: None,
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_void_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-8629193561626734012 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: create_refund_request
{
PaymentServiceRefundRequest {
refund_id: format!("refund_{}", get_timestamp()),
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
currency: i32::from(Currency::Aed),
payment_amount: TEST_AMOUNT,
refund_amount: TEST_AMOUNT,
minor_payment_amount: TEST_AMOUNT,
minor_refund_amount: TEST_AMOUNT,
reason: None,
webhook_url: None,
browser_info: None,
merchant_account_id: None,
capture_method: None,
request_ref_id: None,
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_1791230683314187804 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: create_refund_sync_request
{
RefundServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
refund_id: refund_id.to_string(),
refund_reason: None,
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("rsync_ref_{}", get_timestamp()))),
}),
browser_info: None,
refund_metadata: HashMap::new(),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_sync_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-2605752462423009826 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: test_health
{
grpc_test!(client, HealthClient<Channel>, {
let response = client
.check(Request::new(HealthCheckRequest {
service: "connector_service".to_string(),
}))
.await
.expect("Failed to call health check")
.into_inner();
assert_eq!(
response.status(),
grpc_api_types::health_check::health_check_response::ServingStatus::Serving
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_health",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-4719570876155636254 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: test_payment_authorization_auto_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request
let request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_noon_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Verify the response
assert!(
response.transaction_id.is_some(),
"Resource ID should be present"
);
assert!(
response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AuthenticationPending state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_auto_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_9183401992826346460 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: test_payment_authorization_manual_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_noon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
assert!(
auth_response.transaction_id.is_some(),
"Transaction ID should be present"
);
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status is authorized
if auth_response.status == i32::from(PaymentStatus::Authorized) {
// Create capture request
let capture_request = create_payment_capture_request(&transaction_id);
// Add metadata headers for capture request
let mut capture_grpc_request = Request::new(capture_request);
add_noon_metadata(&mut capture_grpc_request);
// Send the capture request
let capture_response = client
.capture(capture_grpc_request)
.await
.expect("gRPC payment_capture call failed")
.into_inner();
// Verify payment status is charged after capture
assert!(
capture_response.status == i32::from(PaymentStatus::Charged),
"Payment should be in CHARGED state after capture"
);
}
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_manual_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_7089941731956718787 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: test_payment_void
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment with manual capture to void
let auth_request = create_payment_authorize_request(CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_noon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Extract the request ref ID
let request_ref_id = extract_request_ref_id(&auth_response);
// After authentication, sync the payment to get updated status
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
let mut sync_grpc_request = Request::new(sync_request);
add_noon_metadata(&mut sync_grpc_request);
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
std::thread::sleep(std::time::Duration::from_secs(1));
// Verify payment status is authorized
if sync_response.status == i32::from(PaymentStatus::Authorized) {
// Create void request with a unique reference ID
let void_request = create_payment_void_request(&transaction_id);
// Add metadata headers for void request
let mut void_grpc_request = Request::new(void_request);
add_noon_metadata(&mut void_grpc_request);
// Send the void request
let void_response = client
.void(void_grpc_request)
.await
.expect("gRPC void_payment call failed")
.into_inner();
// Verify the void response
assert!(
void_response.transaction_id.is_some(),
"Transaction ID should be present in void response"
);
assert!(
void_response.status == i32::from(PaymentStatus::Voided),
"Payment should be in VOIDED state after void"
);
// Verify the payment status with a sync operation
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
let mut sync_grpc_request = Request::new(sync_request);
add_noon_metadata(&mut sync_grpc_request);
// Send the sync request to verify void status
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// Verify the payment is properly voided
assert!(
sync_response.status == i32::from(PaymentStatus::Voided),
"Payment should be in VOIDED state after void sync"
);
}
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_void",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_5396101851851836151 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: test_payment_sync
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to sync
let auth_request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_noon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Extract the request ref ID
let request_ref_id = extract_request_ref_id(&auth_response);
// Wait longer for the transaction to be processed - some async processing may happen
std::thread::sleep(std::time::Duration::from_secs(2));
// Create sync request with the specific transaction ID
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_noon_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("Payment sync request failed")
.into_inner();
// Verify the sync response - could be charged, authorized, or pending for automatic capture
assert!(
sync_response.status == i32::from(PaymentStatus::AuthenticationPending)
|| sync_response.status == i32::from(PaymentStatus::Charged),
"Payment should be in AUTHENTICATIONPENDING or CHARGED state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_sync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_9016381403424127332 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: test_refund
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment with automatic capture
let auth_request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_noon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Extract the request ref ID
let request_ref_id = extract_request_ref_id(&auth_response);
// Verify payment status is authorized (for manual capture)
assert!(
auth_response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AUTHENTICATIONPENDING state with auto capture"
);
// Create sync request with the specific transaction ID
let sync_request = create_payment_sync_request(&transaction_id, &request_ref_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_noon_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("Payment sync request failed")
.into_inner();
// Allow more time for the capture to be processed - increase wait time
std::thread::sleep(std::time::Duration::from_secs(1));
if sync_response.status == i32::from(PaymentStatus::Authorized) {
// Create refund request with a unique refund_id that includes timestamp
let refund_request = create_refund_request(&transaction_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_noon_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("Refund request failed")
.into_inner();
// Extract the refund ID
let _refund_id = refund_response.refund_id.clone();
// Verify the refund status
assert!(
refund_response.status == i32::from(RefundStatus::RefundSuccess)
|| refund_response.status == i32::from(RefundStatus::RefundPending),
"Refund should be in SUCCESS or PENDING state"
);
}
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_3275927551467653273 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/noon_payment_flows_test.rs
// Function: test_refund_sync
{
grpc_test!(client, PaymentServiceClient<Channel>, {
grpc_test!(refund_client, RefundServiceClient<Channel>, {
// First create a payment with manual capture (same as the script)
let auth_request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_noon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status is authorized (for manual capture)
assert!(
auth_response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AUTHENTICATIONPENDING state with auto capture"
);
// Create refund request
let refund_request = create_refund_request(&transaction_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_noon_metadata(&mut refund_grpc_request);
// Send the refund request and expect a successful response
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
if refund_response.status == i32::from(RefundStatus::RefundSuccess) {
// Extract the request ref ID
let request_ref_id = extract_request_ref_id(&auth_response);
// Allow more time for the refund to be processed
std::thread::sleep(std::time::Duration::from_secs(4));
// Create refund sync request
let refund_sync_request =
create_refund_sync_request(&transaction_id, &request_ref_id);
// Add metadata headers for refund sync request
let mut refund_sync_grpc_request = Request::new(refund_sync_request);
add_noon_metadata(&mut refund_sync_grpc_request);
// Send the refund sync request and expect a successful response
let response = refund_client
.get(refund_sync_grpc_request)
.await
.expect("gRPC refund_sync call failed");
let refund_sync_response = response.into_inner();
// Verify the refund sync status
assert!(
refund_sync_response.status == i32::from(RefundStatus::RefundSuccess)
|| refund_sync_response.status == i32::from(RefundStatus::RefundPending),
"Refund sync should be in SUCCESS or PENDING state"
);
}
});
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund_sync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_3970691218555679357 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
// Function: add_bluecode_metadata
{
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load bluecode credentials");
let api_key = match auth {
domain_types::router_data::ConnectorAuthType::HeaderKey { api_key } => api_key.expose(),
_ => panic!("Expected HeaderKey auth type for bluecode"),
};
// Get the shop_name from metadata
let metadata = utils::credential_utils::load_connector_metadata(CONNECTOR_NAME)
.expect("Failed to load bluecode metadata");
let shop_name = metadata
.get("shop_name")
.expect("shop_name not found in bluecode metadata")
.clone();
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request.metadata_mut().append(
"x-auth",
"header-key".parse().expect("Failed to parse x-auth"),
);
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
// Add the terminal_id in the metadata JSON
// This metadata must be in the proper format that the connector expects
let metadata_json = format!(r#"{{"shop_name":"{shop_name}"}}"#);
request.metadata_mut().append(
"x-metadata",
metadata_json.parse().expect("Failed to parse x-metadata"),
);
request.metadata_mut().append(
"x-tenant-id",
"default".parse().expect("Failed to parse x-tenant-id"),
);
// Add request ID which is required by the server
request.metadata_mut().append(
"x-request-id",
format!("mifinity_req_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
request.metadata_mut().append(
"x-merchant-id",
"12abc123-f8a3-99b8-9ef8-b31180358hh4"
.parse()
.expect("Failed to parse x-merchant-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_bluecode_metadata",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_6336146637317658246 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
// Function: extract_transaction_id
{
match &response.transaction_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector transaction ID"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_transaction_id",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_3611113021516572301 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
// Function: generate_unique_request_ref_id
{
format!(
"{}_{}",
prefix,
&uuid::Uuid::new_v4().simple().to_string()[..8]
)
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_unique_request_ref_id",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_6767914616292971212 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
// Function: random_name
{
rand::thread_rng()
.sample_iter(&Alphanumeric)
.take(8)
.map(char::from)
.collect()
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "random_name",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-4164371956302311382 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
// Function: create_payment_authorize_request
{
// Initialize with all required fields
let mut request = PaymentServiceAuthorizeRequest {
payment_method: Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Wallet(
WalletPaymentMethodType {
wallet_type: Some(wallet_payment_method_type::WalletType::Bluecode(
Bluecode {},
)),
},
)),
}),
..Default::default()
};
if let common_enums::CaptureMethod::Manual = capture_method {
request.capture_method = Some(i32::from(CaptureMethod::Manual));
// request.request_incremental_authorization = true;
} else {
request.capture_method = Some(i32::from(CaptureMethod::Automatic));
}
let mut request_ref_id = Identifier::default();
request_ref_id.id_type = Some(IdType::Id(
generate_unique_request_ref_id("req_"), // Using timestamp to make unique
));
request.request_ref_id = Some(request_ref_id);
// Set the basic payment details matching working grpcurl
request.amount = TEST_AMOUNT;
request.minor_amount = TEST_AMOUNT;
request.currency = 146; // Currency value from working grpcurl
request.email = Some(Secret::new(generate_unique_email()));
// Generate random names for billing to prevent duplicate transaction errors
let billing_first_name = random_name();
let billing_last_name = random_name();
// Minimal address structure matching working grpcurl
request.address = Some(PaymentAddress {
billing_address: Some(Address {
first_name: Some(Secret::new(billing_first_name)),
last_name: Some(Secret::new(billing_last_name)),
line1: Some(Secret::new("14 Main Street".to_string())),
line2: None,
line3: None,
city: Some(Secret::new("Pecan Springs".to_string())),
state: Some(Secret::new("TX".to_string())),
zip_code: Some(Secret::new("44628".to_string())),
country_alpha2_code: Some(i32::from(CountryAlpha2::Us)),
phone_number: None,
phone_country_code: None,
email: None,
}),
shipping_address: None, // Minimal address - no shipping for working grpcurl
});
let browser_info = BrowserInformation {
color_depth: None,
java_enabled: Some(false),
screen_height: Some(1080),
screen_width: Some(1920),
user_agent: Some("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)".to_string()),
accept_header: Some(
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8".to_string(),
),
java_script_enabled: Some(false),
language: Some("en-US".to_string()),
ip_address: None,
os_type: None,
os_version: None,
device_model: None,
accept_language: None,
time_zone_offset_minutes: None,
referer: None,
};
request.browser_info = Some(browser_info);
request.return_url = Some("www.google.com".to_string());
// Set the transaction details
request.auth_type = i32::from(AuthenticationType::NoThreeDs);
request.request_incremental_authorization = true;
request.enrolled_for_3ds = true;
// Set capture method
// request.capture_method = Some(i32::from(CaptureMethod::from(capture_method)));
// Get shop_name for metadata
let metadata = utils::credential_utils::load_connector_metadata(CONNECTOR_NAME)
.expect("Failed to load bluecode metadata");
let shop_name = metadata
.get("shop_name")
.expect("shop_name not found in bluecode metadata")
.clone();
// Create connector metadata as a proper JSON object
let mut connector_metadata = HashMap::new();
connector_metadata.insert("shop_name".to_string(), shop_name);
let connector_metadata_json =
serde_json::to_string(&connector_metadata).expect("Failed to serialize connector metadata");
let mut metadata = HashMap::new();
metadata.insert("connector_meta_data".to_string(), connector_metadata_json);
request.metadata = metadata;
request
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_authorize_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_2312538677176562114 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
// Function: create_payment_sync_request
{
PaymentServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("fiserv_sync_{}", get_timestamp()))),
}),
capture_method: None,
handle_response: None,
// all_keys_required: None,
amount: TEST_AMOUNT,
currency: 146, // Currency value from working grpcurl
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_sync_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_7375937921555173362 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
// Function: test_health
{
grpc_test!(client, HealthClient<Channel>, {
let response = client
.check(Request::new(HealthCheckRequest {
service: "connector_service".to_string(),
}))
.await
.expect("Failed to call health check")
.into_inner();
assert_eq!(
response.status(),
grpc_api_types::health_check::health_check_response::ServingStatus::Serving
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_health",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_2967270299160390869 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
// Function: test_payment_authorization_auto_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request
let request = create_payment_authorize_request(common_enums::CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_bluecode_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Debug print has been removed
// Verify the response
assert!(
response.transaction_id.is_some(),
"Resource ID should be present"
);
// Extract the transaction ID
let _transaction_id = extract_transaction_id(&response);
// Verify payment status
assert!(
response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AuthenticationPending state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_auto_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-5085792768409566150 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/bluecode_payment_flows_test.rs
// Function: test_payment_sync
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to sync
let auth_request = create_payment_authorize_request(common_enums::CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_bluecode_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Create sync request
let sync_request = create_payment_sync_request(&transaction_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_bluecode_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// Verify the sync response
assert!(
sync_response.status == i32::from(PaymentStatus::AuthenticationPending),
"Payment should be in AuthenticationPending state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_sync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-6797754970414355765 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs
// Function: add_fiserv_metadata
{
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load fiserv credentials");
let (api_key, key1, api_secret) = match auth {
domain_types::router_data::ConnectorAuthType::SignatureKey {
api_key,
key1,
api_secret,
} => (api_key.expose(), key1.expose(), api_secret.expose()),
_ => panic!("Expected SignatureKey auth type for fiserv"),
};
// Get the terminal_id from metadata
let metadata = utils::credential_utils::load_connector_metadata(CONNECTOR_NAME)
.expect("Failed to load fiserv metadata");
let terminal_id = metadata
.get("terminal_id")
.expect("terminal_id not found in fiserv metadata")
.clone();
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request.metadata_mut().append(
"x-auth",
"signature-key".parse().expect("Failed to parse x-auth"),
);
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
request
.metadata_mut()
.append("x-key1", key1.parse().expect("Failed to parse x-key1"));
request.metadata_mut().append(
"x-api-secret",
api_secret.parse().expect("Failed to parse x-api-secret"),
);
// Add the terminal_id in the metadata JSON
// This metadata must be in the proper format that the connector expects
let metadata_json = format!(r#"{{"terminal_id":"{terminal_id}"}}"#);
// For capture operations, the connector looks for terminal_id in connector_metadata
let base64_metadata = general_purpose::STANDARD.encode(metadata_json.as_bytes());
request.metadata_mut().append(
"x-metadata",
metadata_json.parse().expect("Failed to parse x-metadata"),
);
// Also add connector-metadata-id explicitly to handle capture operation
request.metadata_mut().append(
"connector-metadata-id",
metadata_json
.parse()
.expect("Failed to parse connector-metadata-id"),
);
// Add base64-encoded metadata as x-connector-metadata
request.metadata_mut().append(
"x-connector-metadata",
base64_metadata
.parse()
.expect("Failed to parse x-connector-metadata"),
);
request.metadata_mut().append(
"x-merchant-id",
"test_merchant"
.parse()
.expect("Failed to parse x-merchant-id"),
);
request.metadata_mut().append(
"x-tenant-id",
"default".parse().expect("Failed to parse x-tenant-id"),
);
request.metadata_mut().append(
"x-request-id",
format!("test_request_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
request.metadata_mut().append(
"x-connector-request-reference-id",
format!("conn_ref_{}", get_timestamp())
.parse()
.expect("Failed to parse x-connector-request-reference-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_fiserv_metadata",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_1123401055517435843 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs
// Function: extract_transaction_id
{
match &response.transaction_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector transaction ID"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_transaction_id",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-7904799952799662988 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs
// Function: create_payment_authorize_request
{
// Get terminal_id for metadata
let metadata = utils::credential_utils::load_connector_metadata(CONNECTOR_NAME)
.expect("Failed to load fiserv metadata");
let terminal_id = metadata
.get("terminal_id")
.expect("terminal_id not found in fiserv metadata")
.clone();
// Create connector metadata as a proper JSON object
let mut connector_metadata = HashMap::new();
connector_metadata.insert("terminal_id".to_string(), terminal_id);
let connector_metadata_json =
serde_json::to_string(&connector_metadata).expect("Failed to serialize connector metadata");
let mut metadata = HashMap::new();
metadata.insert("connector_meta_data".to_string(), connector_metadata_json);
let card_details = card_payment_method_type::CardType::Credit(CardDetails {
card_number: Some(CardNumber::from_str(TEST_CARD_NUMBER).unwrap()),
card_exp_month: Some(Secret::new(TEST_CARD_EXP_MONTH.to_string())),
card_exp_year: Some(Secret::new(TEST_CARD_EXP_YEAR.to_string())),
card_cvc: Some(Secret::new(TEST_CARD_CVC.to_string())),
card_holder_name: Some(Secret::new(TEST_CARD_HOLDER.to_string())),
card_issuer: None,
card_network: None,
card_type: None,
card_issuing_country_alpha2: None,
bank_code: None,
nick_name: None,
});
// Initialize with all required fields
PaymentServiceAuthorizeRequest {
amount: TEST_AMOUNT,
minor_amount: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
payment_method: Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType {
card_type: Some(card_details),
})),
}), //i32::from(payment_method::PaymentMethod::Card),
email: Some(TEST_EMAIL.to_string().into()),
address: Some(grpc_api_types::payments::PaymentAddress::default()),
auth_type: i32::from(AuthenticationType::NoThreeDs),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("fiserv_test_{}", get_timestamp()))),
}), //format!("fiserv_test_{}", get_timestamp()),
enrolled_for_3ds: false,
request_incremental_authorization: false,
capture_method: Some(i32::from(capture_method)),
// payment_method_type: Some(i32::from(PaymentMethodType::Credit)),
metadata,
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_authorize_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_2416189768758207098 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs
// Function: create_payment_sync_request
{
PaymentServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("fiserv_sync_{}", get_timestamp()))),
}),
// all_keys_required: None,
capture_method: None,
handle_response: None,
amount: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_sync_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-2145130524951428854 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs
// Function: create_payment_capture_request
{
let metadata = utils::credential_utils::load_connector_metadata(CONNECTOR_NAME)
.expect("Failed to load fiserv metadata");
let terminal_id = metadata
.get("terminal_id")
.expect("terminal_id not found in fiserv metadata")
.clone();
// Create connector metadata as a proper JSON object
let mut connector_metadata = HashMap::new();
connector_metadata.insert("terminal_id".to_string(), terminal_id);
let connector_metadata_json =
serde_json::to_string(&connector_metadata).expect("Failed to serialize connector metadata");
let mut connector_metadata = HashMap::new();
connector_metadata.insert("connector_metadata".to_string(), connector_metadata_json);
PaymentServiceCaptureRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
amount_to_capture: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
multiple_capture_data: None,
connector_metadata,
request_ref_id: None, // all_keys_required: None,
browser_info: None,
capture_method: None,
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_capture_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-8871171629052657541 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs
// Function: create_refund_request
{
let metadata = utils::credential_utils::load_connector_metadata(CONNECTOR_NAME)
.expect("Failed to load fiserv metadata");
let terminal_id = metadata
.get("terminal_id")
.expect("terminal_id not found in fiserv metadata")
.clone();
// Create connector metadata as a proper JSON object
let mut connector_metadata = HashMap::new();
connector_metadata.insert("terminal_id".to_string(), terminal_id);
let connector_metadata_json =
serde_json::to_string(&connector_metadata).expect("Failed to serialize connector metadata");
let mut metadata = HashMap::new();
metadata.insert("connector_metadata".to_string(), connector_metadata_json);
PaymentServiceRefundRequest {
refund_id: format!("refund_{}", get_timestamp()),
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
currency: i32::from(Currency::Usd),
payment_amount: TEST_AMOUNT,
refund_amount: TEST_AMOUNT,
minor_payment_amount: TEST_AMOUNT,
minor_refund_amount: TEST_AMOUNT,
// connector_refund_id: None,
reason: None,
webhook_url: None,
metadata: metadata.clone(), // Add terminal_id for the main connector_metadata field
refund_metadata: metadata, // Add terminal_id for refund
browser_info: None,
merchant_account_id: None,
capture_method: None,
request_ref_id: None, // all_keys_required: None,
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_4359955422860675838 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs
// Function: create_refund_sync_request
{
RefundServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
refund_id: refund_id.to_string(),
refund_reason: None,
request_ref_id: None, // all_keys_required: None,
browser_info: None,
refund_metadata: HashMap::new(),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_sync_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_423687309422834336 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs
// Function: test_health
{
grpc_test!(client, HealthClient<Channel>, {
let response = client
.check(Request::new(HealthCheckRequest {
service: "connector_service".to_string(),
}))
.await
.expect("Failed to call health check")
.into_inner();
assert_eq!(
response.status(),
grpc_api_types::health_check::health_check_response::ServingStatus::Serving
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_health",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_8872365188974249132 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs
// Function: test_payment_authorization_auto_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request
let request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_fiserv_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Debug print has been removed
// Verify the response
assert!(
response.transaction_id.is_some(),
"Resource ID should be present"
);
// Extract the transaction ID
let _transaction_id = extract_transaction_id(&response);
// Verify payment status
assert!(
response.status == i32::from(PaymentStatus::Charged),
"Payment should be in CHARGED state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_auto_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_608751216830662025 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs
// Function: test_payment_authorization_manual_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_fiserv_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
assert!(
auth_response.transaction_id.is_some(),
"Resource ID should be present"
);
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status is authorized (for manual capture)
assert!(
auth_response.status == i32::from(PaymentStatus::Authorized),
"Payment should be in AUTHORIZED state with manual capture"
);
// Create capture request (which already includes proper connector metadata)
let capture_request = create_payment_capture_request(&transaction_id);
// Add metadata headers for capture request
let mut capture_grpc_request = Request::new(capture_request);
add_fiserv_metadata(&mut capture_grpc_request);
// Send the capture request
let capture_result = client.capture(capture_grpc_request).await;
// Add debugging for capture failure
let capture_response = match capture_result {
Ok(response) => response.into_inner(),
Err(status) => {
println!("=== FISERV CAPTURE DEBUG ===");
println!("Capture failed with status: {:?}", status);
println!("Error code: {:?}", status.code());
println!("Error message: {:?}", status.message());
println!("Metadata: {:?}", status.metadata());
println!("=== END DEBUG ===");
panic!("gRPC payment_capture call failed: {}", status);
}
};
// Verify payment status is charged after capture
assert!(
capture_response.status == i32::from(PaymentStatus::Charged),
"Payment should be in CHARGED state after capture"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_manual_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_344110033113799881 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs
// Function: test_payment_sync
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to sync
let auth_request = create_payment_authorize_request(CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_fiserv_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Create sync request
let sync_request = create_payment_sync_request(&transaction_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_fiserv_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// Verify the sync response
assert!(
sync_response.status == i32::from(PaymentStatus::Authorized),
"Payment should be in Authorized state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_sync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-2500157299759679036 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs
// Function: test_refund
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment
let auth_request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_fiserv_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status
assert!(
auth_response.status == i32::from(PaymentStatus::Charged)
|| auth_response.status == i32::from(PaymentStatus::Authorized),
"Payment should be in CHARGED or AUTHORIZED state before attempting refund"
);
// Make sure the payment is fully processed by checking its status via sync
let sync_request = create_payment_sync_request(&transaction_id);
let mut sync_grpc_request = Request::new(sync_request);
add_fiserv_metadata(&mut sync_grpc_request);
// Wait a bit longer to ensure the payment is fully processed
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
// Send the sync request to verify payment status
let _sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// Create refund request
let refund_request = create_refund_request(&transaction_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_fiserv_metadata(&mut refund_grpc_request);
// Send the refund request and handle both success and error cases
let refund_result = client.refund(refund_grpc_request).await;
match refund_result {
Ok(response) => {
let refund_response = response.into_inner();
// Extract the refund ID
let _refund_id = refund_response.refund_id.clone();
// Verify the refund status
assert!(
refund_response.status == i32::from(RefundStatus::RefundSuccess)
|| refund_response.status == i32::from(RefundStatus::RefundPending),
"Refund should be in SUCCESS or PENDING state"
);
}
Err(status) => {
// If the refund fails, it could be due to timing issues or payment not being in the right state
// This is acceptable for our test scenario - we're testing the connector functionality
// Verify the error message is reasonable
assert!(
status.message().contains("processing error")
|| status.message().contains("not found")
|| status.message().contains("payment state"),
"Error should be related to processing or payment state issues"
);
}
}
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-3623264078452725780 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/fiserv_payment_flows_test.rs
// Function: test_refund_sync
{
grpc_test!(client, PaymentServiceClient<Channel>, {
grpc_test!(refund_client, RefundServiceClient<Channel>, {
// Run a standalone test specifically for refund sync
// We'll directly test the payment sync functionality since the payment sync test already passes
// And use a mock refund ID for testing the refund sync functionality
// First create a payment
let auth_request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_fiserv_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID with debugging
let transaction_id = match &auth_response.transaction_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
IdType::NoResponseIdMarker(_) => {
println!("=== FISERV REFUND SYNC DEBUG ===");
println!("NoResponseIdMarker detected in refund sync test");
println!("Auth response: {:?}", auth_response);
println!("=== END DEBUG ===");
panic!("NoResponseIdMarker found - authentication issue");
}
IdType::EncodedData(_) => {
println!("EncodedData found instead of transaction ID");
panic!("Unexpected EncodedData in transaction ID");
}
},
None => panic!("Resource ID is None"),
};
// Wait for payment to process
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
// Create sync request to check payment status
let sync_request = create_payment_sync_request(&transaction_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_fiserv_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// Verify payment is in a good state
assert!(
sync_response.status == i32::from(PaymentStatus::Charged)
|| sync_response.status == i32::from(PaymentStatus::Authorized),
"Payment should be in CHARGED or AUTHORIZED state"
);
// Use a mock refund ID for sync testing
// The format mimics what would come from a real Fiserv refund
let mock_refund_id = format!("refund_sync_test_{}", get_timestamp());
// Create refund sync request with our mock ID
let refund_sync_request = create_refund_sync_request(&transaction_id, &mock_refund_id);
// Add metadata headers for refund sync request
let mut refund_sync_grpc_request = Request::new(refund_sync_request);
add_fiserv_metadata(&mut refund_sync_grpc_request);
// Send the refund sync request and expect a not found response or pending status
let refund_sync_result = refund_client.get(refund_sync_grpc_request).await; //client.refund(refund_sync_grpc_request).await;
// For a mock refund ID, we expect either a failure (not found) or a pending status
// Both outcomes are valid for this test scenario
match refund_sync_result {
Ok(response) => {
// If we got a response, it should be in a pending state
let status = response.into_inner().status;
assert_eq!(
status,
i32::from(RefundStatus::RefundPending),
"If response received, refund should be in PENDING state for a mock ID"
);
}
Err(status) => {
// An error is also acceptable if the mock ID isn't found
assert!(
status.message().contains("not found")
|| status.message().contains("processing error"),
"Error should indicate refund not found or processing error"
);
}
}
});
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund_sync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_6516804850073880728 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs
// Function: add_elavon_metadata
{
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load elavon credentials");
let (api_key, api_user, api_secret) = match auth {
domain_types::router_data::ConnectorAuthType::SignatureKey {
api_key,
key1,
api_secret,
} => (api_key.expose(), key1.expose(), api_secret.expose()),
_ => panic!("Expected SignatureKey auth type for elavon"),
};
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request.metadata_mut().append(
"x-auth",
"signature-key".parse().expect("Failed to parse x-auth"),
);
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
request
.metadata_mut()
.append("x-key1", api_user.parse().expect("Failed to parse x-key1"));
request.metadata_mut().append(
"x-api-secret",
api_secret.parse().expect("Failed to parse x-api-secret"),
);
request.metadata_mut().append(
"x-merchant-id",
"test_merchant"
.parse()
.expect("Failed to parse x-merchant-id"),
);
request.metadata_mut().append(
"x-tenant-id",
"default".parse().expect("Failed to parse x-tenant-id"),
);
request.metadata_mut().append(
"x-request-id",
format!("test_request_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
request.metadata_mut().append(
"x-connector-request-reference-id",
format!("conn_ref_{}", get_timestamp())
.parse()
.expect("Failed to parse x-connector-request-reference-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_elavon_metadata",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_7868847288157542993 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs
// Function: extract_transaction_id
{
match &response.transaction_id {
Some(id) => match id.id_type.as_ref().unwrap() {
IdType::Id(id) => id.clone(),
_ => panic!("Expected connector transaction ID"),
},
None => panic!("Resource ID is None"),
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_transaction_id",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-7324019789287014184 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs
// Function: create_payment_authorize_request
{
// Initialize with all required fields to avoid field_reassign_with_default warning
let card_details = card_payment_method_type::CardType::Credit(CardDetails {
card_number: Some(CardNumber::from_str(TEST_CARD_NUMBER).unwrap()),
card_exp_month: Some(Secret::new(TEST_CARD_EXP_MONTH.to_string())),
card_exp_year: Some(Secret::new(TEST_CARD_EXP_YEAR.to_string())),
card_cvc: Some(Secret::new(TEST_CARD_CVC.to_string())),
card_holder_name: Some(Secret::new(TEST_CARD_HOLDER.to_string())),
card_issuer: None,
card_network: None,
card_type: None,
card_issuing_country_alpha2: None,
bank_code: None,
nick_name: None,
});
PaymentServiceAuthorizeRequest {
amount: TEST_AMOUNT,
minor_amount: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
payment_method: Some(PaymentMethod {
payment_method: Some(payment_method::PaymentMethod::Card(CardPaymentMethodType {
card_type: Some(card_details),
})),
}),
// payment_method_data: Some(grpc_api_types::payments::PaymentMethodData {
// data: Some(grpc_api_types::payments::payment_method_data::Data::Card(
// grpc_api_types::payments::Card {
// card_number: TEST_CARD_NUMBER.to_string(),
// card_exp_month: TEST_CARD_EXP_MONTH.to_string(),
// card_exp_year: TEST_CARD_EXP_YEAR.to_string(),
// card_cvc: TEST_CARD_CVC.to_string(),
// card_holder_name: Some(TEST_CARD_HOLDER.to_string()),
// card_issuer: None,
// card_network: None,
// card_type: None,
// card_issuing_country: None,
// bank_code: None,
// nick_name: None,
// },
// )),
// }),
email: Some(TEST_EMAIL.to_string().into()),
address: Some(grpc_api_types::payments::PaymentAddress::default()),
auth_type: i32::from(AuthenticationType::NoThreeDs),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("elavon_test_{}", get_timestamp()))),
}),
enrolled_for_3ds: false,
request_incremental_authorization: false,
capture_method: Some(i32::from(capture_method)),
// payment_method_type: Some(i32::from(PaymentMethodType::Credit)),
// all_keys_required: Some(false),
..Default::default()
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_authorize_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_3948348151509357772 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs
// Function: test_payment_authorization_auto_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request
let request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers
let mut grpc_request = Request::new(request);
add_elavon_metadata(&mut grpc_request);
// Send the request
let response = client
.authorize(grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Add comprehensive logging for debugging
println!("=== ELAVON PAYMENT RESPONSE DEBUG ===");
println!("Response: {:#?}", response);
println!("Status: {}", response.status);
println!("Error code: {:?}", response.error_code);
println!("Error message: {:?}", response.error_message);
println!("Status code: {:?}", response.status_code);
println!("Transaction ID: {:?}", response.transaction_id);
println!("=== END DEBUG ===");
// Check if we have a valid transaction ID or if it's a NoResponseIdMarker (auth issue)
if let Some(ref tx_id) = response.transaction_id {
if let Some(ref id_type) = tx_id.id_type {
match id_type {
IdType::NoResponseIdMarker(_) => {
println!("Elavon authentication/credential issue detected - NoResponseIdMarker");
return; // Exit early since we can't proceed with invalid credentials
}
IdType::Id(_) => {
// Valid transaction ID, continue with test
}
IdType::EncodedData(_) => {
// Handle encoded data case
println!("Elavon returned encoded data");
}
}
}
}
// Verify the response
assert!(
response.transaction_id.is_some(),
"Resource ID should be present"
);
// Extract the transaction ID (using underscore prefix since it's used for assertions only)
let _transaction_id = extract_transaction_id(&response);
// Verify payment status
assert_eq!(
response.status,
i32::from(PaymentStatus::Charged),
"Payment should be in CHARGED state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_auto_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-3412244664542018374 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs
// Function: test_health
{
grpc_test!(client, HealthClient<Channel>, {
let response = client
.check(Request::new(HealthCheckRequest {
service: "connector_service".to_string(),
}))
.await
.expect("Failed to call health check")
.into_inner();
assert_eq!(
response.status(),
grpc_api_types::health_check::health_check_response::ServingStatus::Serving
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_health",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_6655362038704610287 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs
// Function: create_payment_sync_request
{
PaymentServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
request_ref_id: Some(Identifier {
id_type: Some(IdType::Id(format!("elavon_sync_{}", get_timestamp()))),
}), // Some(format!("elavon_sync_{}", get_timestamp())),
// all_keys_required: Some(false),
capture_method: None,
handle_response: None,
amount: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_sync_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_6888726934277155481 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs
// Function: test_payment_sync
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to sync
let auth_request = create_payment_authorize_request(CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_elavon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Create sync request
let sync_request = create_payment_sync_request(&transaction_id);
// Add metadata headers for sync request
let mut sync_grpc_request = Request::new(sync_request);
add_elavon_metadata(&mut sync_grpc_request);
// Send the sync request
let sync_response = client
.get(sync_grpc_request)
.await
.expect("gRPC payment_sync call failed")
.into_inner();
// Verify the sync response
assert!(
sync_response.status == i32::from(PaymentStatus::Authorized),
"Payment should be in Authorized state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_sync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-3721487556865058272 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs
// Function: create_payment_capture_request
{
PaymentServiceCaptureRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
amount_to_capture: TEST_AMOUNT,
currency: i32::from(Currency::Usd),
multiple_capture_data: None,
connector_metadata: HashMap::new(),
request_ref_id: None,
browser_info: None,
capture_method: None,
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_payment_capture_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-4961759628151044124 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs
// Function: test_payment_authorization_manual_capture
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// Create the payment authorization request with manual capture
let auth_request = create_payment_authorize_request(CaptureMethod::Manual);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_elavon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
assert!(
auth_response.transaction_id.is_some(),
"Resource ID should be present"
);
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Verify payment status
// Note: Even though we set capture_method to Manual, Elavon might still auto-capture
// the payment depending on the configuration, so we accept both Authorized and Charged states
assert!(
auth_response.status == i32::from(PaymentStatus::Authorized),
"Payment should be in AUTHORIZED state"
);
// Create capture request
let capture_request = create_payment_capture_request(&transaction_id);
// Add metadata headers for capture request
let mut capture_grpc_request = Request::new(capture_request);
add_elavon_metadata(&mut capture_grpc_request);
// Send the capture request
let capture_response = client
.capture(capture_grpc_request)
.await
.expect("gRPC payment_capture call failed")
.into_inner();
// Note: If the payment was already auto-captured, the capture request might fail
// with an error like "Invalid Transaction ID: The transaction ID is invalid for this transaction type"
// In this case, we'll accept either a CHARGED status
assert!(
capture_response.status == i32::from(PaymentStatus::Charged),
"Payment should be in CHARGED state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payment_authorization_manual_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_2374898520195055906 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs
// Function: create_refund_request
{
PaymentServiceRefundRequest {
refund_id: format!("refund_{}", get_timestamp()),
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
currency: i32::from(Currency::Usd),
payment_amount: TEST_AMOUNT,
refund_amount: TEST_AMOUNT,
minor_payment_amount: TEST_AMOUNT,
minor_refund_amount: TEST_AMOUNT,
// connector_refund_id: None,
reason: None,
webhook_url: None,
metadata: HashMap::new(),
refund_metadata: HashMap::new(),
browser_info: None,
merchant_account_id: None,
capture_method: None,
request_ref_id: None, // all_keys_required: Some(false),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-5108748663893851969 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs
// Function: create_refund_sync_request
{
RefundServiceGetRequest {
transaction_id: Some(Identifier {
id_type: Some(IdType::Id(transaction_id.to_string())),
}),
refund_id: refund_id.to_string(),
refund_reason: None,
browser_info: None,
request_ref_id: None, // all_keys_required: None,
refund_metadata: HashMap::new(),
state: None,
}
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_refund_sync_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-6874223455902090955 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs
// Function: test_refund
{
grpc_test!(client, PaymentServiceClient<Channel>, {
// First create a payment to refund
let auth_request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_elavon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Create refund request
let refund_request = create_refund_request(&transaction_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_elavon_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
// Extract the refund ID
let refund_id = refund_response.refund_id.clone();
// Verify the refund response
assert!(!refund_id.is_empty(), "Refund ID should not be empty");
assert!(
refund_response.status == i32::from(RefundStatus::RefundSuccess),
"Refund should be in SUCCESS state"
);
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-5532278473075429871 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/elavon_payment_flows_test.rs
// Function: test_refund_sync
{
grpc_test!(client, PaymentServiceClient<Channel>, {
grpc_test!(refund_client, RefundServiceClient<Channel>, {
let auth_request = create_payment_authorize_request(CaptureMethod::Automatic);
// Add metadata headers for auth request
let mut auth_grpc_request = Request::new(auth_request);
add_elavon_metadata(&mut auth_grpc_request);
// Send the auth request
let auth_response = client
.authorize(auth_grpc_request)
.await
.expect("gRPC payment_authorize call failed")
.into_inner();
// Extract the transaction ID
let transaction_id = extract_transaction_id(&auth_response);
// Create refund request
let refund_request = create_refund_request(&transaction_id);
// Add metadata headers for refund request
let mut refund_grpc_request = Request::new(refund_request);
add_elavon_metadata(&mut refund_grpc_request);
// Send the refund request
let refund_response = client
.refund(refund_grpc_request)
.await
.expect("gRPC refund call failed")
.into_inner();
// Extract the refund ID
let refund_id = refund_response.refund_id.clone();
// Verify the refund response
assert!(!refund_id.is_empty(), "Refund ID should not be empty");
// Create refund sync request
let refund_sync_request = create_refund_sync_request(&transaction_id, &refund_id);
// Add metadata headers for refund sync request
let mut refund_sync_grpc_request = Request::new(refund_sync_request);
add_elavon_metadata(&mut refund_sync_grpc_request);
// Send the refund sync request
let refund_sync_response = refund_client
.get(refund_sync_grpc_request)
.await
.expect("gRPC refund_sync call failed")
.into_inner();
// Verify the refund sync response
assert!(
refund_sync_response.status == i32::from(RefundStatus::RefundPending)
|| refund_sync_response.status == i32::from(RefundStatus::RefundSuccess),
"Refund should be in PENDING or SUCCESS state"
);
});
// First create a payment to refund
});
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_refund_sync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_grpc-server_-6895945706975471610 | clm | function_body | // connector-service/backend/grpc-server/tests/beta_tests/rapyd_payment_flows_test.rs
// Function: add_rapyd_metadata
{
let auth = utils::credential_utils::load_connector_auth(CONNECTOR_NAME)
.expect("Failed to load rapyd credentials");
let (api_key, key1) = match auth {
domain_types::router_data::ConnectorAuthType::BodyKey { api_key, key1 } => {
(api_key.expose(), key1.expose())
}
_ => panic!("Expected BodyKey auth type for rapyd"),
};
request.metadata_mut().append(
"x-connector",
CONNECTOR_NAME.parse().expect("Failed to parse x-connector"),
);
request.metadata_mut().append(
"x-auth",
"body-key".parse().expect("Failed to parse x-auth"),
);
request.metadata_mut().append(
"x-api-key",
api_key.parse().expect("Failed to parse x-api-key"),
);
request
.metadata_mut()
.append("x-key1", key1.parse().expect("Failed to parse x-key1"));
request.metadata_mut().append(
"x-merchant-id",
"test_merchant"
.parse()
.expect("Failed to parse x-merchant-id"),
);
request.metadata_mut().append(
"x-tenant-id",
"default".parse().expect("Failed to parse x-tenant-id"),
);
request.metadata_mut().append(
"x-request-id",
format!("test_request_{}", get_timestamp())
.parse()
.expect("Failed to parse x-request-id"),
);
}
| {
"chunk": null,
"crate": "grpc-server",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "add_rapyd_metadata",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.