id stringlengths 11 116 | type stringclasses 1 value | granularity stringclasses 4 values | content stringlengths 16 477k | metadata dict |
|---|---|---|---|---|
fn_clm_router_default_-9103076271061947159 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/utils
// Implementation of TokenType for Default
fn default() -> Self {
let data = types::PaymentMethodTokenizationData {
payment_method_data: types::domain::PaymentMethodData::Card(CCardType::default().0),
browser_info: None,
amount: Some(100),
currency: enums::Currency::USD,
split_payments: None,
mandate_id: None,
setup_future_usage: None,
customer_acceptance: None,
setup_mandate_details: None,
};
Self(data)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7709,
"total_crates": null
} |
fn_clm_router_make_payment_-9103076271061947159 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/utils
/// For initiating payments when `CaptureMethod` is set to `Automatic`
/// This does complete the transaction without user intervention to Capture the payment
async fn make_payment(
&self,
payment_data: Option<types::PaymentsAuthorizeData>,
payment_info: Option<PaymentInfo>,
) -> Result<types::PaymentsAuthorizeRouterData, Report<ConnectorError>> {
let integration = self.get_data().connector.get_connector_integration();
let request = self.generate_data(
types::PaymentsAuthorizeData {
confirm: true,
capture_method: Some(diesel_models::enums::CaptureMethod::Automatic),
..(payment_data.unwrap_or(PaymentAuthorizeType::default().0))
},
payment_info,
);
Box::pin(call_connector(request, integration)).await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2057,
"total_crates": null
} |
fn_clm_router_get_connector_transaction_id_-9103076271061947159 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/utils
pub fn get_connector_transaction_id(
response: Result<types::PaymentsResponseData, types::ErrorResponse>,
) -> Option<String> {
match response {
Ok(types::PaymentsResponseData::TransactionResponse { resource_id, .. }) => {
resource_id.get_connector_transaction_id().ok()
}
Ok(types::PaymentsResponseData::SessionResponse { .. }) => None,
Ok(types::PaymentsResponseData::SessionTokenResponse { .. }) => None,
Ok(types::PaymentsResponseData::TokenizationResponse { .. }) => None,
Ok(types::PaymentsResponseData::TransactionUnresolvedResponse { .. }) => None,
Ok(types::PaymentsResponseData::PreProcessingResponse { .. }) => None,
Ok(types::PaymentsResponseData::ConnectorCustomerResponse(..)) => None,
Ok(types::PaymentsResponseData::ThreeDSEnrollmentResponse { .. }) => None,
Ok(types::PaymentsResponseData::MultipleCaptureResponse { .. }) => None,
Ok(types::PaymentsResponseData::IncrementalAuthorizationResponse { .. }) => None,
Ok(types::PaymentsResponseData::PostProcessingResponse { .. }) => None,
Ok(types::PaymentsResponseData::PaymentResourceUpdateResponse { .. }) => None,
Ok(types::PaymentsResponseData::PaymentsCreateOrderResponse { .. }) => None,
Err(_) => None,
}
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 1265,
"total_crates": null
} |
fn_clm_router_make_payment_and_refund_-9103076271061947159 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/utils
async fn make_payment_and_refund(
&self,
authorize_data: Option<types::PaymentsAuthorizeData>,
refund_data: Option<types::RefundsData>,
payment_info: Option<PaymentInfo>,
) -> Result<types::RefundExecuteRouterData, Report<ConnectorError>> {
//make a successful payment
let response = self
.make_payment(authorize_data, payment_info.clone())
.await
.unwrap();
//try refund for previous payment
let transaction_id = get_connector_transaction_id(response.response).unwrap();
tokio::time::sleep(Duration::from_secs(self.get_request_interval())).await; // to avoid 404 error
Ok(self
.refund_payment(transaction_id, refund_data, payment_info)
.await
.unwrap())
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 1223,
"total_crates": null
} |
fn_clm_router_capture_payment_and_refund_-9103076271061947159 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/utils
async fn capture_payment_and_refund(
&self,
authorize_data: Option<types::PaymentsAuthorizeData>,
capture_data: Option<types::PaymentsCaptureData>,
refund_data: Option<types::RefundsData>,
payment_info: Option<PaymentInfo>,
) -> Result<types::RefundExecuteRouterData, Report<ConnectorError>> {
//make a successful payment
let response = self
.authorize_and_capture_payment(authorize_data, capture_data, payment_info.clone())
.await
.unwrap();
let txn_id = self.get_connector_transaction_id_from_capture_data(response);
//try refund for previous payment
tokio::time::sleep(Duration::from_secs(self.get_request_interval())).await; // to avoid 404 error
Ok(self
.refund_payment(txn_id.unwrap(), refund_data, payment_info)
.await
.unwrap())
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 884,
"total_crates": null
} |
fn_clm_router_get_default_payment_info_-6979959926697031484 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/checkbook
fn get_default_payment_info() -> Option<utils::PaymentInfo> {
Some(utils::PaymentInfo {
address: Some(types::PaymentAddress::new(
None,
None,
Some(Address {
address: Some(AddressDetails {
first_name: Some(Secret::new("John".to_string())),
last_name: Some(Secret::new("Doe".to_string())),
..Default::default()
}),
phone: None,
email: Some(Email::from_str("abc@gmail.com").unwrap()),
}),
None,
)),
..Default::default()
})
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7294,
"total_crates": null
} |
fn_clm_router_payment_method_details_-6979959926697031484 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/checkbook
fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
None
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 4398,
"total_crates": null
} |
fn_clm_router_get_name_-6979959926697031484 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/checkbook
// Implementation of CheckbookTest for utils::Connector
fn get_name(&self) -> String {
"checkbook".to_string()
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 46,
"total_crates": null
} |
fn_clm_router_get_data_-6979959926697031484 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/checkbook
// Implementation of CheckbookTest for utils::Connector
fn get_data(&self) -> api::ConnectorData {
use router::connector::Checkbook;
utils::construct_connector_data_old(
Box::new(Checkbook::new()),
types::Connector::Checkbook,
api::GetToken::Connector,
None,
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 41,
"total_crates": null
} |
fn_clm_router_get_auth_token_-6979959926697031484 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/checkbook
// Implementation of CheckbookTest for utils::Connector
fn get_auth_token(&self) -> types::ConnectorAuthType {
types::ConnectorAuthType::BodyKey {
key1: Secret::new("dummy_publishable_key".to_string()),
api_key: Secret::new("dummy_secret_key".to_string()),
}
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 34,
"total_crates": null
} |
fn_clm_router_get_default_payment_info_-5625605200273551665 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/santander
fn get_default_payment_info() -> Option<utils::PaymentInfo> {
None
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7278,
"total_crates": null
} |
fn_clm_router_payment_method_details_-5625605200273551665 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/santander
fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
None
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 4398,
"total_crates": null
} |
fn_clm_router_get_name_-5625605200273551665 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/santander
// Implementation of SantanderTest for utils::Connector
fn get_name(&self) -> String {
"santander".to_string()
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 46,
"total_crates": null
} |
fn_clm_router_get_data_-5625605200273551665 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/santander
// Implementation of SantanderTest for utils::Connector
fn get_data(&self) -> api::ConnectorData {
use router::connector::Santander;
utils::construct_connector_data_old(
Box::new(Santander::new()),
types::Connector::DummyConnector1,
api::GetToken::Connector,
None,
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 41,
"total_crates": null
} |
fn_clm_router_get_auth_token_-5625605200273551665 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/santander
// Implementation of SantanderTest for utils::Connector
fn get_auth_token(&self) -> types::ConnectorAuthType {
utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new()
.santander
.expect("Missing connector authentication configuration")
.into(),
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
} |
fn_clm_router_get_default_payment_info_7005943722676886892 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/tokenio
fn get_default_payment_info() -> Option<utils::PaymentInfo> {
None
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7278,
"total_crates": null
} |
fn_clm_router_payment_method_details_7005943722676886892 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/tokenio
fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
None
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 4398,
"total_crates": null
} |
fn_clm_router_get_name_7005943722676886892 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/tokenio
// Implementation of TokenioTest for utils::Connector
fn get_name(&self) -> String {
"tokenio".to_string()
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 46,
"total_crates": null
} |
fn_clm_router_get_data_7005943722676886892 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/tokenio
// Implementation of TokenioTest for utils::Connector
fn get_data(&self) -> api::ConnectorData {
use router::connector::Tokenio;
utils::construct_connector_data_old(
Box::new(Tokenio::new()),
types::Connector::Plaid,
api::GetToken::Connector,
None,
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 41,
"total_crates": null
} |
fn_clm_router_get_auth_token_7005943722676886892 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/tokenio
// Implementation of TokenioTest for utils::Connector
fn get_auth_token(&self) -> types::ConnectorAuthType {
utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new()
.tokenio
.expect("Missing connector authentication configuration")
.into(),
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
} |
fn_clm_router_get_default_payment_info_-7611374552554252698 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/vgs
fn get_default_payment_info() -> Option<utils::PaymentInfo> {
None
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7278,
"total_crates": null
} |
fn_clm_router_payment_method_details_-7611374552554252698 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/vgs
fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
None
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 4398,
"total_crates": null
} |
fn_clm_router_get_name_-7611374552554252698 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/vgs
// Implementation of VgsTest for utils::Connector
fn get_name(&self) -> String {
"vgs".to_string()
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 46,
"total_crates": null
} |
fn_clm_router_get_data_-7611374552554252698 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/vgs
// Implementation of VgsTest for utils::Connector
fn get_data(&self) -> types::api::ConnectorData {
use router::connector::Vgs;
utils::construct_connector_data_old(
Box::new(&Vgs),
types::Connector::Vgs,
types::api::GetToken::Connector,
None,
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 39,
"total_crates": null
} |
fn_clm_router_get_auth_token_-7611374552554252698 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/vgs
// Implementation of VgsTest for utils::Connector
fn get_auth_token(&self) -> types::ConnectorAuthType {
utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new()
.vgs
.expect("Missing connector authentication configuration")
.into(),
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
} |
fn_clm_router_get_default_payment_info_-7516733667145960267 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/bamboraapac
fn get_default_payment_info() -> Option<utils::PaymentInfo> {
None
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7278,
"total_crates": null
} |
fn_clm_router_payment_method_details_-7516733667145960267 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/bamboraapac
fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
None
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 4398,
"total_crates": null
} |
fn_clm_router_get_name_-7516733667145960267 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/bamboraapac
// Implementation of BamboraapacTest for utils::Connector
fn get_name(&self) -> String {
"bamboraapac".to_string()
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 46,
"total_crates": null
} |
fn_clm_router_get_data_-7516733667145960267 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/bamboraapac
// Implementation of BamboraapacTest for utils::Connector
fn get_data(&self) -> api::ConnectorData {
use router::connector::Adyen;
utils::construct_connector_data_old(
Box::new(Adyen::new()),
types::Connector::Adyen,
api::GetToken::Connector,
None,
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 41,
"total_crates": null
} |
fn_clm_router_get_auth_token_-7516733667145960267 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/bamboraapac
// Implementation of BamboraapacTest for utils::Connector
fn get_auth_token(&self) -> types::ConnectorAuthType {
utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new()
.bamboraapac
.expect("Missing connector authentication configuration")
.into(),
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
} |
fn_clm_router_get_name_-4760083359864870817 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/gpayments
// Implementation of GpaymentsTest for utils::Connector
fn get_name(&self) -> String {
"gpayments".to_string()
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 46,
"total_crates": null
} |
fn_clm_router_get_data_-4760083359864870817 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/gpayments
// Implementation of GpaymentsTest for utils::Connector
fn get_data(&self) -> types::api::ConnectorData {
use router::connector::Gpayments;
utils::construct_connector_data_old(
Box::new(Gpayments::new()),
types::Connector::Threedsecureio,
// Added as Dummy connector as template code is added for future usage
types::api::GetToken::Connector,
None,
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 41,
"total_crates": null
} |
fn_clm_router_get_auth_token_-4760083359864870817 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/gpayments
// Implementation of GpaymentsTest for utils::Connector
fn get_auth_token(&self) -> types::ConnectorAuthType {
utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new()
.gpayments
.expect("Missing connector authentication configuration")
.into(),
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
} |
fn_clm_router_get_default_payment_info_2891022173129869587 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/moneris
fn get_default_payment_info() -> Option<utils::PaymentInfo> {
None
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7278,
"total_crates": null
} |
fn_clm_router_payment_method_details_2891022173129869587 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/moneris
fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
None
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 4398,
"total_crates": null
} |
fn_clm_router_get_name_2891022173129869587 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/moneris
// Implementation of MonerisTest for utils::Connector
fn get_name(&self) -> String {
"moneris".to_string()
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 46,
"total_crates": null
} |
fn_clm_router_get_data_2891022173129869587 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/moneris
// Implementation of MonerisTest for utils::Connector
fn get_data(&self) -> api::ConnectorData {
use router::connector::Moneris;
utils::construct_connector_data_old(
Box::new(Moneris::new()),
types::Connector::Moneris,
api::GetToken::Connector,
None,
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 41,
"total_crates": null
} |
fn_clm_router_get_auth_token_2891022173129869587 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/moneris
// Implementation of MonerisTest for utils::Connector
fn get_auth_token(&self) -> types::ConnectorAuthType {
utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new()
.moneris
.expect("Missing connector authentication configuration")
.into(),
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
} |
fn_clm_router_get_default_payment_info_-5847000494883091526 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/nexixpay
fn get_default_payment_info() -> Option<utils::PaymentInfo> {
None
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7278,
"total_crates": null
} |
fn_clm_router_payment_method_details_-5847000494883091526 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/nexixpay
fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
None
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 4398,
"total_crates": null
} |
fn_clm_router_get_name_-5847000494883091526 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/nexixpay
// Implementation of NexixpayTest for utils::Connector
fn get_name(&self) -> String {
"nexixpay".to_string()
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 46,
"total_crates": null
} |
fn_clm_router_get_data_-5847000494883091526 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/nexixpay
// Implementation of NexixpayTest for utils::Connector
fn get_data(&self) -> api::ConnectorData {
use router::connector::Nexixpay;
utils::construct_connector_data_old(
Box::new(Nexixpay::new()),
types::Connector::Plaid,
api::GetToken::Connector,
None,
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 41,
"total_crates": null
} |
fn_clm_router_get_auth_token_-5847000494883091526 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/tests/connectors/nexixpay
// Implementation of NexixpayTest for utils::Connector
fn get_auth_token(&self) -> types::ConnectorAuthType {
utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new()
.nexixpay
.expect("Missing connector authentication configuration")
.into(),
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
} |
fn_clm_router_test_profile_id_unavailable_initialization_-6602653706042501018 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/consts
fn test_profile_id_unavailable_initialization() {
// Just access the lazy static to ensure it doesn't panic during initialization
let _profile_id = super::PROFILE_ID_UNAVAILABLE.clone();
// If we get here without panicking, the test passes
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2,
"total_crates": null
} |
fn_clm_router_default_-4983504080864141457 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/types
// Implementation of PollConfig for Default
fn default() -> Self {
Self {
delay_in_secs: consts::DEFAULT_POLL_DELAY_IN_SECS,
frequency: consts::DEFAULT_POLL_FREQUENCY,
}
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7703,
"total_crates": null
} |
fn_clm_router_from_-4983504080864141457 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/types
// Implementation of MerchantRecipientData for From<api_models::admin::MerchantRecipientData>
fn from(value: api_models::admin::MerchantRecipientData) -> Self {
match value {
api_models::admin::MerchantRecipientData::ConnectorRecipientId(id) => {
Self::ConnectorRecipientId(id)
}
api_models::admin::MerchantRecipientData::WalletId(id) => Self::WalletId(id),
api_models::admin::MerchantRecipientData::AccountData(data) => {
Self::AccountData(data.into())
}
}
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2608,
"total_crates": null
} |
fn_clm_router_foreign_try_from_-4983504080864141457 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/types
// Implementation of domain::MerchantConnectorAccountFeatureMetadata for ForeignTryFrom<&api_models::admin::MerchantConnectorAccountFeatureMetadata>
fn foreign_try_from(
feature_metadata: &api_models::admin::MerchantConnectorAccountFeatureMetadata,
) -> Result<Self, Self::Error> {
let revenue_recovery = feature_metadata
.revenue_recovery
.as_ref()
.map(|revenue_recovery_metadata| {
domain::AccountReferenceMap::new(
revenue_recovery_metadata.billing_account_reference.clone(),
)
.map(|mca_reference| domain::RevenueRecoveryMetadata {
max_retry_count: revenue_recovery_metadata.max_retry_count,
billing_connector_retry_threshold: revenue_recovery_metadata
.billing_connector_retry_threshold,
mca_reference,
})
})
.transpose()?;
Ok(Self { revenue_recovery })
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 440,
"total_crates": null
} |
fn_clm_router_foreign_from_-4983504080864141457 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/types
// Implementation of api_models::admin::MerchantConnectorAccountFeatureMetadata for ForeignFrom<&domain::MerchantConnectorAccountFeatureMetadata>
fn foreign_from(item: &domain::MerchantConnectorAccountFeatureMetadata) -> Self {
let revenue_recovery = item
.revenue_recovery
.as_ref()
.map(
|revenue_recovery_metadata| api_models::admin::RevenueRecoveryMetadata {
max_retry_count: revenue_recovery_metadata.max_retry_count,
billing_connector_retry_threshold: revenue_recovery_metadata
.billing_connector_retry_threshold,
billing_account_reference: revenue_recovery_metadata
.mca_reference
.recovery_to_billing
.clone(),
},
);
Self { revenue_recovery }
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 218,
"total_crates": null
} |
fn_clm_router_get_poll_config_key_-4983504080864141457 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/types
// Inherent implementation for PollConfig
pub fn get_poll_config_key(connector: String) -> String {
format!("poll_config_external_three_ds_{connector}")
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 27,
"total_crates": null
} |
fn_clm_router_default_4378672741472029594 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events
// Implementation of EventsHandler for Default
fn default() -> Self {
Self::Logs(event_logger::EventLogger {})
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7705,
"total_crates": null
} |
fn_clm_router_validate_4378672741472029594 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events
// Inherent implementation for EventsConfig
pub fn validate(&self) -> Result<(), ApplicationError> {
match self {
Self::Kafka { kafka } => kafka.validate(),
Self::Logs => Ok(()),
}
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 221,
"total_crates": null
} |
fn_clm_router_log_event_4378672741472029594 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events
// Inherent implementation for EventsHandler
pub fn log_event<T: KafkaMessage>(&self, event: &T) {
match self {
Self::Kafka(kafka) => kafka.log_event(event).unwrap_or_else(|e| {
logger::error!("Failed to log event: {:?}", e);
}),
Self::Logs(logger) => logger.log_event(event),
};
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 165,
"total_crates": null
} |
fn_clm_router_get_event_handler_4378672741472029594 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events
// Inherent implementation for EventsConfig
pub async fn get_event_handler(&self) -> StorageResult<EventsHandler> {
Ok(match self {
Self::Kafka { kafka } => EventsHandler::Kafka(
KafkaProducer::create(kafka)
.await
.change_context(StorageError::InitializationError)?,
),
Self::Logs => EventsHandler::Logs(event_logger::EventLogger::default()),
})
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 37,
"total_crates": null
} |
fn_clm_router_log_connector_event_4378672741472029594 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events
// Implementation of EventsHandler for events_interfaces::EventHandlerInterface
fn log_connector_event(&self, event: &events_interfaces::connector_api_logs::ConnectorEvent) {
self.log_event(event);
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 25,
"total_crates": null
} |
fn_clm_router_mk_app_8503377789184415046 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/lib
pub fn mk_app(
state: AppState,
request_body_limit: usize,
) -> actix_web::App<
impl ServiceFactory<
ServiceRequest,
Config = (),
Response = actix_web::dev::ServiceResponse<impl MessageBody>,
Error = actix_web::Error,
InitError = (),
>,
> {
let mut server_app = get_application_builder(request_body_limit, state.conf.cors.clone());
#[cfg(feature = "dummy_connector")]
{
use routes::DummyConnector;
server_app = server_app.service(DummyConnector::server(state.clone()));
}
#[cfg(any(feature = "olap", feature = "oltp"))]
{
#[cfg(feature = "olap")]
{
// This is a more specific route as compared to `MerchantConnectorAccount`
// so it is registered before `MerchantConnectorAccount`.
#[cfg(feature = "v1")]
{
server_app = server_app
.service(routes::ProfileNew::server(state.clone()))
.service(routes::Forex::server(state.clone()))
.service(routes::ProfileAcquirer::server(state.clone()));
}
server_app = server_app.service(routes::Profile::server(state.clone()));
}
server_app = server_app
.service(routes::Payments::server(state.clone()))
.service(routes::Customers::server(state.clone()))
.service(routes::Configs::server(state.clone()))
.service(routes::MerchantConnectorAccount::server(state.clone()))
.service(routes::RelayWebhooks::server(state.clone()))
.service(routes::Webhooks::server(state.clone()))
.service(routes::Hypersense::server(state.clone()))
.service(routes::Relay::server(state.clone()))
.service(routes::ThreeDsDecisionRule::server(state.clone()));
#[cfg(feature = "oltp")]
{
server_app = server_app.service(routes::PaymentMethods::server(state.clone()));
}
#[cfg(all(feature = "v2", feature = "oltp"))]
{
server_app = server_app
.service(routes::PaymentMethodSession::server(state.clone()))
.service(routes::Refunds::server(state.clone()));
}
#[cfg(all(feature = "v2", feature = "oltp", feature = "tokenization_v2"))]
{
server_app = server_app.service(routes::Tokenization::server(state.clone()));
}
#[cfg(feature = "v1")]
{
server_app = server_app
.service(routes::Refunds::server(state.clone()))
.service(routes::Mandates::server(state.clone()))
.service(routes::Authentication::server(state.clone()));
}
}
#[cfg(all(feature = "oltp", any(feature = "v1", feature = "v2"),))]
{
server_app = server_app.service(routes::EphemeralKey::server(state.clone()))
}
#[cfg(all(feature = "oltp", feature = "v1"))]
{
server_app = server_app.service(routes::Poll::server(state.clone()))
}
#[cfg(feature = "olap")]
{
server_app = server_app
.service(routes::Organization::server(state.clone()))
.service(routes::MerchantAccount::server(state.clone()))
.service(routes::User::server(state.clone()))
.service(routes::ApiKeys::server(state.clone()))
.service(routes::Routing::server(state.clone()))
.service(routes::Chat::server(state.clone()));
#[cfg(all(feature = "olap", any(feature = "v1", feature = "v2")))]
{
server_app = server_app.service(routes::Verify::server(state.clone()));
}
#[cfg(feature = "v1")]
{
server_app = server_app
.service(routes::Files::server(state.clone()))
.service(routes::Disputes::server(state.clone()))
.service(routes::Blocklist::server(state.clone()))
.service(routes::Subscription::server(state.clone()))
.service(routes::Gsm::server(state.clone()))
.service(routes::ApplePayCertificatesMigration::server(state.clone()))
.service(routes::PaymentLink::server(state.clone()))
.service(routes::ConnectorOnboarding::server(state.clone()))
.service(routes::Analytics::server(state.clone()))
.service(routes::WebhookEvents::server(state.clone()))
.service(routes::FeatureMatrix::server(state.clone()));
}
#[cfg(feature = "v2")]
{
server_app = server_app
.service(routes::UserDeprecated::server(state.clone()))
.service(routes::ProcessTrackerDeprecated::server(state.clone()))
.service(routes::ProcessTracker::server(state.clone()))
.service(routes::Gsm::server(state.clone()))
.service(routes::RecoveryDataBackfill::server(state.clone()));
}
}
#[cfg(all(feature = "payouts", feature = "v1"))]
{
server_app = server_app
.service(routes::Payouts::server(state.clone()))
.service(routes::PayoutLink::server(state.clone()));
}
#[cfg(all(feature = "stripe", feature = "v1"))]
{
server_app = server_app
.service(routes::StripeApis::server(state.clone()))
.service(routes::Cards::server(state.clone()));
}
#[cfg(all(feature = "oltp", feature = "v2"))]
{
server_app = server_app.service(routes::Proxy::server(state.clone()));
}
#[cfg(all(feature = "recon", feature = "v1"))]
{
server_app = server_app.service(routes::Recon::server(state.clone()));
}
server_app = server_app.service(routes::Cache::server(state.clone()));
server_app = server_app.service(routes::Health::server(state.clone()));
server_app
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 344,
"total_crates": null
} |
fn_clm_router_start_server_8503377789184415046 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/lib
pub async fn start_server(conf: settings::Settings<SecuredSecret>) -> ApplicationResult<Server> {
logger::debug!(startup_config=?conf);
let server = conf.server.clone();
let (tx, rx) = oneshot::channel();
let api_client = Box::new(services::ProxyClient::new(&conf.proxy).map_err(|error| {
errors::ApplicationError::ApiClientError(error.current_context().clone())
})?);
let state = Box::pin(AppState::new(conf, tx, api_client)).await;
let request_body_limit = server.request_body_limit;
let server_builder =
actix_web::HttpServer::new(move || mk_app(state.clone(), request_body_limit))
.bind((server.host.as_str(), server.port))?
.workers(server.workers)
.shutdown_timeout(server.shutdown_timeout);
#[cfg(feature = "tls")]
let server = match server.tls {
None => server_builder.run(),
Some(tls_conf) => {
let cert_file =
&mut std::io::BufReader::new(std::fs::File::open(tls_conf.certificate).map_err(
|err| errors::ApplicationError::InvalidConfigurationValueError(err.to_string()),
)?);
let key_file =
&mut std::io::BufReader::new(std::fs::File::open(tls_conf.private_key).map_err(
|err| errors::ApplicationError::InvalidConfigurationValueError(err.to_string()),
)?);
let cert_chain = rustls_pemfile::certs(cert_file)
.collect::<Result<Vec<_>, _>>()
.map_err(|err| {
errors::ApplicationError::InvalidConfigurationValueError(err.to_string())
})?;
let mut keys = rustls_pemfile::pkcs8_private_keys(key_file)
.map(|key| key.map(rustls::pki_types::PrivateKeyDer::Pkcs8))
.collect::<Result<Vec<_>, _>>()
.map_err(|err| {
errors::ApplicationError::InvalidConfigurationValueError(err.to_string())
})?;
// exit if no keys could be parsed
if keys.is_empty() {
return Err(errors::ApplicationError::InvalidConfigurationValueError(
"Could not locate PKCS8 private keys.".into(),
));
}
let config_builder = rustls::ServerConfig::builder().with_no_client_auth();
let config = config_builder
.with_single_cert(cert_chain, keys.remove(0))
.map_err(|err| {
errors::ApplicationError::InvalidConfigurationValueError(err.to_string())
})?;
server_builder
.bind_rustls_0_22(
(tls_conf.host.unwrap_or(server.host).as_str(), tls_conf.port),
config,
)?
.run()
}
};
#[cfg(not(feature = "tls"))]
let server = server_builder.run();
let _task_handle = tokio::spawn(receiver_for_error(rx, server.handle()).in_current_span());
Ok(server)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 157,
"total_crates": null
} |
fn_clm_router_get_application_builder_8503377789184415046 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/lib
pub fn get_application_builder(
request_body_limit: usize,
cors: settings::CorsSettings,
) -> actix_web::App<
impl ServiceFactory<
ServiceRequest,
Config = (),
Response = actix_web::dev::ServiceResponse<impl MessageBody>,
Error = actix_web::Error,
InitError = (),
>,
> {
let json_cfg = actix_web::web::JsonConfig::default()
.limit(request_body_limit)
.content_type_required(true)
.error_handler(utils::error_parser::custom_json_error_handler);
actix_web::App::new()
.app_data(json_cfg)
.wrap(ErrorHandlers::new().handler(
StatusCode::NOT_FOUND,
errors::error_handlers::custom_error_handlers,
))
.wrap(ErrorHandlers::new().handler(
StatusCode::METHOD_NOT_ALLOWED,
errors::error_handlers::custom_error_handlers,
))
.wrap(middleware::default_response_headers())
.wrap(middleware::RequestId)
.wrap(cors::cors(cors))
// this middleware works only for Http1.1 requests
.wrap(middleware::Http400RequestDetailsLogger)
.wrap(middleware::AddAcceptLanguageHeader)
.wrap(middleware::RequestResponseMetrics)
.wrap(middleware::LogSpanInitializer)
.wrap(router_env::tracing_actix_web::TracingLogger::default())
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 59,
"total_crates": null
} |
fn_clm_router_receiver_for_error_8503377789184415046 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/lib
pub async fn receiver_for_error(rx: oneshot::Receiver<()>, mut server: impl Stop) {
match rx.await {
Ok(_) => {
logger::error!("The redis server failed ");
server.stop_server().await;
}
Err(err) => {
logger::error!("Channel receiver error: {err}");
}
}
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 18,
"total_crates": null
} |
fn_clm_router_stop_server_8503377789184415046 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/lib
// Implementation of mpsc::Sender<()> for Stop
async fn stop_server(&mut self) {
let _ = self.send(()).await.map_err(|err| logger::error!("{err}"));
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 15,
"total_crates": null
} |
fn_clm_router_cors_-2810319655556865958 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/cors
pub fn cors(config: settings::CorsSettings) -> actix_cors::Cors {
let allowed_methods = config.allowed_methods.iter().map(|s| s.as_str());
let mut cors = actix_cors::Cors::default()
.allowed_methods(allowed_methods)
.allow_any_header()
.expose_any_header()
.max_age(config.max_age);
if config.wildcard_origin {
cors = cors.allow_any_origin()
} else {
for origin in &config.origins {
cors = cors.allowed_origin(origin);
}
// Only allow this in case if it's not wildcard origins. ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
cors = cors.supports_credentials();
}
cors
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 35,
"total_crates": null
} |
fn_clm_router_get_cache_store_6105157504587813826 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/services
pub async fn get_cache_store(
config: &Settings,
shut_down_signal: oneshot::Sender<()>,
_test_transaction: bool,
) -> StorageResult<Arc<RedisStore>> {
RouterStore::<StoreType>::cache_store(&config.redis, shut_down_signal).await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 51,
"total_crates": null
} |
fn_clm_router_get_store_6105157504587813826 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/services
pub async fn get_store(
config: &Settings,
tenant: &dyn TenantConfig,
cache_store: Arc<RedisStore>,
test_transaction: bool,
) -> StorageResult<Store> {
let master_config = config.master_database.clone().into_inner();
#[cfg(feature = "olap")]
let replica_config = config.replica_database.clone().into_inner();
#[allow(clippy::expect_used)]
let master_enc_key = hex::decode(config.secrets.get_inner().master_enc_key.clone().expose())
.map(StrongSecret::new)
.expect("Failed to decode master key from hex");
#[cfg(not(feature = "olap"))]
let conf = master_config.into();
#[cfg(feature = "olap")]
// this would get abstracted, for all cases
#[allow(clippy::useless_conversion)]
let conf = (master_config.into(), replica_config.into());
let store: RouterStore<StoreType> = if test_transaction {
RouterStore::test_store(conf, tenant, &config.redis, master_enc_key).await?
} else {
RouterStore::from_config(
conf,
tenant,
master_enc_key,
cache_store,
storage_impl::redis::cache::IMC_INVALIDATION_CHANNEL,
)
.await?
};
#[cfg(feature = "kv_store")]
let store = KVRouterStore::from_store(
store,
config.drainer.stream_name.clone(),
config.drainer.num_partitions,
config.kv_config.ttl,
config.kv_config.soft_kill,
);
Ok(store)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 48,
"total_crates": null
} |
fn_clm_router_generate_aes256_key_6105157504587813826 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/services
pub fn generate_aes256_key() -> errors::CustomResult<[u8; 32], common_utils::errors::CryptoError> {
use ring::rand::SecureRandom;
let rng = ring::rand::SystemRandom::new();
let mut key: [u8; 256 / 8] = [0_u8; 256 / 8];
rng.fill(&mut key)
.change_context(common_utils::errors::CryptoError::EncodingFailed)?;
Ok(key)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 37,
"total_crates": null
} |
fn_clm_router_get_cache_store_-8177641363930189553 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db
// Implementation of MockDb for GlobalStorageInterface
fn get_cache_store(&self) -> Box<dyn RedisConnInterface + Send + Sync + 'static> {
Box::new(self.clone())
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 51,
"total_crates": null
} |
fn_clm_router_get_request_id_-8177641363930189553 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db
// Implementation of Store for RequestIdStore
fn get_request_id(&self) -> Option<String> {
self.request_id.clone()
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 37,
"total_crates": null
} |
fn_clm_router_get_and_deserialize_key_-8177641363930189553 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db
pub async fn get_and_deserialize_key<T>(
db: &dyn StorageInterface,
key: &str,
type_name: &'static str,
) -> CustomResult<T, RedisError>
where
T: serde::de::DeserializeOwned,
{
use common_utils::ext_traits::ByteSliceExt;
let bytes = db.get_key(key).await?;
bytes
.parse_struct(type_name)
.change_context(RedisError::JsonDeserializationFailed)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 34,
"total_crates": null
} |
fn_clm_router_find_fraud_check_by_payment_id_if_present_-8177641363930189553 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db
// Implementation of KafkaStore for FraudCheckInterface
async fn find_fraud_check_by_payment_id_if_present(
&self,
payment_id: id_type::PaymentId,
merchant_id: id_type::MerchantId,
) -> CustomResult<Option<FraudCheck>, StorageError> {
let frm = self
.diesel_store
.find_fraud_check_by_payment_id_if_present(payment_id, merchant_id)
.await?;
if let Some(fraud_check) = frm.clone() {
if let Err(er) = self
.kafka_producer
.log_fraud_check(&fraud_check, None, self.tenant_id.clone())
.await
{
logger::error!(message="Failed to log analytics event for frm {frm:?}", error_message=?er);
}
}
Ok(frm)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 28,
"total_crates": null
} |
fn_clm_router_find_organization_by_org_id_-8177641363930189553 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db
// Implementation of KafkaStore for OrganizationInterface
async fn find_organization_by_org_id(
&self,
org_id: &id_type::OrganizationId,
) -> CustomResult<Organization, StorageError> {
self.diesel_store.find_organization_by_org_id(org_id).await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 28,
"total_crates": null
} |
fn_clm_router_call_-8106652756386772866 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/middleware
// Implementation of RequestResponseMetricsMiddleware<S> for actix_web::dev::Service<actix_web::dev::ServiceRequest>
fn call(&self, req: actix_web::dev::ServiceRequest) -> Self::Future {
use std::borrow::Cow;
let svc = self.service.clone();
let request_path = req
.match_pattern()
.map(Cow::<'static, str>::from)
.unwrap_or_else(|| "UNKNOWN".into());
let request_method = Cow::<'static, str>::from(req.method().as_str().to_owned());
Box::pin(async move {
let mut attributes =
router_env::metric_attributes!(("path", request_path), ("method", request_method))
.to_vec();
let response_fut = svc.call(req);
metrics::REQUESTS_RECEIVED.add(1, &attributes);
let (response_result, request_duration) =
common_utils::metrics::utils::time_future(response_fut).await;
let response = response_result?;
attributes.extend_from_slice(router_env::metric_attributes!((
"status_code",
i64::from(response.status().as_u16())
)));
metrics::REQUEST_TIME.record(request_duration.as_secs_f64(), &attributes);
Ok(response)
})
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 45,
"total_crates": null
} |
fn_clm_router_get_request_details_from_value_-8106652756386772866 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/middleware
fn get_request_details_from_value(json_value: &serde_json::Value, parent_key: &str) -> String {
match json_value {
serde_json::Value::Null => format!("{parent_key}: null"),
serde_json::Value::Bool(b) => format!("{parent_key}: {b}"),
serde_json::Value::Number(num) => format!("{}: {}", parent_key, num.to_string().len()),
serde_json::Value::String(s) => format!("{}: {}", parent_key, s.len()),
serde_json::Value::Array(arr) => {
let mut result = String::new();
for (index, value) in arr.iter().enumerate() {
let child_key = format!("{parent_key}[{index}]");
result.push_str(&get_request_details_from_value(value, &child_key));
if index < arr.len() - 1 {
result.push_str(", ");
}
}
result
}
serde_json::Value::Object(obj) => {
let mut result = String::new();
for (index, (key, value)) in obj.iter().enumerate() {
let child_key = format!("{parent_key}[{key}]");
result.push_str(&get_request_details_from_value(value, &child_key));
if index < obj.len() - 1 {
result.push_str(", ");
}
}
result
}
}
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 34,
"total_crates": null
} |
fn_clm_router_default_response_headers_-8106652756386772866 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/middleware
/// Middleware for attaching default response headers. Headers with the same key already set in a
/// response will not be overwritten.
pub fn default_response_headers() -> actix_web::middleware::DefaultHeaders {
use actix_web::http::header;
let default_headers_middleware = actix_web::middleware::DefaultHeaders::new();
#[cfg(feature = "vergen")]
let default_headers_middleware =
default_headers_middleware.add(("x-hyperswitch-version", router_env::git_tag!()));
default_headers_middleware
// Max age of 1 year in seconds, equal to `60 * 60 * 24 * 365` seconds.
.add((header::STRICT_TRANSPORT_SECURITY, "max-age=31536000"))
.add((header::VIA, "HyperSwitch"))
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 21,
"total_crates": null
} |
fn_clm_router_new_transform_-8106652756386772866 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/middleware
// Implementation of RequestResponseMetrics for actix_web::dev::Transform<S, actix_web::dev::ServiceRequest>
fn new_transform(&self, service: S) -> Self::Future {
std::future::ready(Ok(RequestResponseMetricsMiddleware {
service: std::rc::Rc::new(service),
}))
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 12,
"total_crates": null
} |
fn_clm_router_server_7251656784881985287 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/analytics
// Inherent implementation for Analytics
pub fn server(state: AppState) -> Scope {
web::scope("/analytics")
.app_data(web::Data::new(state))
.service(
web::scope("/v1")
.service(
web::resource("metrics/payments")
.route(web::post().to(get_merchant_payment_metrics)),
)
.service(
web::resource("metrics/routing")
.route(web::post().to(get_merchant_payment_metrics)),
)
.service(
web::resource("metrics/refunds")
.route(web::post().to(get_merchant_refund_metrics)),
)
.service(
web::resource("filters/payments")
.route(web::post().to(get_merchant_payment_filters)),
)
.service(
web::resource("filters/routing")
.route(web::post().to(get_merchant_payment_filters)),
)
.service(
web::resource("filters/frm").route(web::post().to(get_frm_filters)),
)
.service(
web::resource("filters/refunds")
.route(web::post().to(get_merchant_refund_filters)),
)
.service(web::resource("{domain}/info").route(web::get().to(get_info)))
.service(
web::resource("report/dispute")
.route(web::post().to(generate_merchant_dispute_report)),
)
.service(
web::resource("report/refunds")
.route(web::post().to(generate_merchant_refund_report)),
)
.service(
web::resource("report/payments")
.route(web::post().to(generate_merchant_payment_report)),
)
.service(
web::resource("report/authentications")
.route(web::post().to(generate_merchant_authentication_report)),
)
.service(
web::resource("metrics/sdk_events")
.route(web::post().to(get_sdk_event_metrics)),
)
.service(
web::resource("metrics/active_payments")
.route(web::post().to(get_active_payments_metrics)),
)
.service(
web::resource("filters/sdk_events")
.route(web::post().to(get_sdk_event_filters)),
)
.service(
web::resource("metrics/auth_events")
.route(web::post().to(get_merchant_auth_event_metrics)),
)
.service(
web::resource("filters/auth_events")
.route(web::post().to(get_merchant_auth_events_filters)),
)
.service(
web::resource("metrics/frm").route(web::post().to(get_frm_metrics)),
)
.service(
web::resource("api_event_logs")
.route(web::get().to(get_profile_api_events)),
)
.service(
web::resource("sdk_event_logs")
.route(web::post().to(get_profile_sdk_events)),
)
.service(
web::resource("connector_event_logs")
.route(web::get().to(get_profile_connector_events)),
)
.service(
web::resource("routing_event_logs")
.route(web::get().to(get_profile_routing_events)),
)
.service(
web::resource("outgoing_webhook_event_logs")
.route(web::get().to(get_profile_outgoing_webhook_events)),
)
.service(
web::resource("metrics/api_events")
.route(web::post().to(get_merchant_api_events_metrics)),
)
.service(
web::resource("filters/api_events")
.route(web::post().to(get_merchant_api_event_filters)),
)
.service(
web::resource("search")
.route(web::post().to(get_global_search_results)),
)
.service(
web::resource("search/{domain}")
.route(web::post().to(get_search_results)),
)
.service(
web::resource("metrics/disputes")
.route(web::post().to(get_merchant_dispute_metrics)),
)
.service(
web::resource("filters/disputes")
.route(web::post().to(get_merchant_dispute_filters)),
)
.service(
web::resource("metrics/sankey")
.route(web::post().to(get_merchant_sankey)),
)
.service(
web::resource("metrics/auth_events/sankey")
.route(web::post().to(get_merchant_auth_event_sankey)),
)
.service(
web::scope("/merchant")
.service(
web::resource("metrics/payments")
.route(web::post().to(get_merchant_payment_metrics)),
)
.service(
web::resource("metrics/routing")
.route(web::post().to(get_merchant_payment_metrics)),
)
.service(
web::resource("metrics/refunds")
.route(web::post().to(get_merchant_refund_metrics)),
)
.service(
web::resource("metrics/auth_events")
.route(web::post().to(get_merchant_auth_event_metrics)),
)
.service(
web::resource("filters/payments")
.route(web::post().to(get_merchant_payment_filters)),
)
.service(
web::resource("filters/routing")
.route(web::post().to(get_merchant_payment_filters)),
)
.service(
web::resource("filters/refunds")
.route(web::post().to(get_merchant_refund_filters)),
)
.service(
web::resource("filters/auth_events")
.route(web::post().to(get_merchant_auth_events_filters)),
)
.service(
web::resource("{domain}/info").route(web::get().to(get_info)),
)
.service(
web::resource("report/dispute")
.route(web::post().to(generate_merchant_dispute_report)),
)
.service(
web::resource("report/refunds")
.route(web::post().to(generate_merchant_refund_report)),
)
.service(
web::resource("report/payments")
.route(web::post().to(generate_merchant_payment_report)),
)
.service(
web::resource("report/authentications").route(
web::post().to(generate_merchant_authentication_report),
),
)
.service(
web::resource("metrics/api_events")
.route(web::post().to(get_merchant_api_events_metrics)),
)
.service(
web::resource("filters/api_events")
.route(web::post().to(get_merchant_api_event_filters)),
)
.service(
web::resource("metrics/disputes")
.route(web::post().to(get_merchant_dispute_metrics)),
)
.service(
web::resource("filters/disputes")
.route(web::post().to(get_merchant_dispute_filters)),
)
.service(
web::resource("metrics/sankey")
.route(web::post().to(get_merchant_sankey)),
)
.service(
web::resource("metrics/auth_events/sankey")
.route(web::post().to(get_merchant_auth_event_sankey)),
),
)
.service(
web::scope("/org")
.service(
web::resource("{domain}/info").route(web::get().to(get_info)),
)
.service(
web::resource("metrics/payments")
.route(web::post().to(get_org_payment_metrics)),
)
.service(
web::resource("filters/payments")
.route(web::post().to(get_org_payment_filters)),
)
.service(
web::resource("metrics/routing")
.route(web::post().to(get_org_payment_metrics)),
)
.service(
web::resource("filters/routing")
.route(web::post().to(get_org_payment_filters)),
)
.service(
web::resource("metrics/refunds")
.route(web::post().to(get_org_refund_metrics)),
)
.service(
web::resource("filters/refunds")
.route(web::post().to(get_org_refund_filters)),
)
.service(
web::resource("metrics/disputes")
.route(web::post().to(get_org_dispute_metrics)),
)
.service(
web::resource("metrics/auth_events")
.route(web::post().to(get_org_auth_event_metrics)),
)
.service(
web::resource("filters/disputes")
.route(web::post().to(get_org_dispute_filters)),
)
.service(
web::resource("filters/auth_events")
.route(web::post().to(get_org_auth_events_filters)),
)
.service(
web::resource("report/dispute")
.route(web::post().to(generate_org_dispute_report)),
)
.service(
web::resource("report/refunds")
.route(web::post().to(generate_org_refund_report)),
)
.service(
web::resource("report/payments")
.route(web::post().to(generate_org_payment_report)),
)
.service(
web::resource("report/authentications")
.route(web::post().to(generate_org_authentication_report)),
)
.service(
web::resource("metrics/sankey")
.route(web::post().to(get_org_sankey)),
)
.service(
web::resource("metrics/auth_events/sankey")
.route(web::post().to(get_org_auth_event_sankey)),
),
)
.service(
web::scope("/profile")
.service(
web::resource("{domain}/info").route(web::get().to(get_info)),
)
.service(
web::resource("metrics/payments")
.route(web::post().to(get_profile_payment_metrics)),
)
.service(
web::resource("filters/payments")
.route(web::post().to(get_profile_payment_filters)),
)
.service(
web::resource("metrics/routing")
.route(web::post().to(get_profile_payment_metrics)),
)
.service(
web::resource("filters/routing")
.route(web::post().to(get_profile_payment_filters)),
)
.service(
web::resource("metrics/refunds")
.route(web::post().to(get_profile_refund_metrics)),
)
.service(
web::resource("filters/refunds")
.route(web::post().to(get_profile_refund_filters)),
)
.service(
web::resource("metrics/disputes")
.route(web::post().to(get_profile_dispute_metrics)),
)
.service(
web::resource("metrics/auth_events")
.route(web::post().to(get_profile_auth_event_metrics)),
)
.service(
web::resource("filters/disputes")
.route(web::post().to(get_profile_dispute_filters)),
)
.service(
web::resource("filters/auth_events")
.route(web::post().to(get_profile_auth_events_filters)),
)
.service(
web::resource("connector_event_logs")
.route(web::get().to(get_profile_connector_events)),
)
.service(
web::resource("routing_event_logs")
.route(web::get().to(get_profile_routing_events)),
)
.service(
web::resource("outgoing_webhook_event_logs")
.route(web::get().to(get_profile_outgoing_webhook_events)),
)
.service(
web::resource("report/dispute")
.route(web::post().to(generate_profile_dispute_report)),
)
.service(
web::resource("report/refunds")
.route(web::post().to(generate_profile_refund_report)),
)
.service(
web::resource("report/payments")
.route(web::post().to(generate_profile_payment_report)),
)
.service(
web::resource("report/authentications").route(
web::post().to(generate_profile_authentication_report),
),
)
.service(
web::resource("api_event_logs")
.route(web::get().to(get_profile_api_events)),
)
.service(
web::resource("sdk_event_logs")
.route(web::post().to(get_profile_sdk_events)),
)
.service(
web::resource("metrics/sankey")
.route(web::post().to(get_profile_sankey)),
)
.service(
web::resource("metrics/auth_events/sankey")
.route(web::post().to(get_profile_auth_event_sankey)),
),
),
)
.service(
web::scope("/v2")
.service(
web::resource("/metrics/payments")
.route(web::post().to(get_merchant_payment_intent_metrics)),
)
.service(
web::resource("/filters/payments")
.route(web::post().to(get_payment_intents_filters)),
)
.service(
web::scope("/merchant")
.service(
web::resource("/metrics/payments")
.route(web::post().to(get_merchant_payment_intent_metrics)),
)
.service(
web::resource("/filters/payments")
.route(web::post().to(get_payment_intents_filters)),
),
)
.service(
web::scope("/org").service(
web::resource("/metrics/payments")
.route(web::post().to(get_org_payment_intent_metrics)),
),
)
.service(
web::scope("/profile").service(
web::resource("/metrics/payments")
.route(web::post().to(get_profile_payment_intent_metrics)),
),
),
)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 1192,
"total_crates": null
} |
fn_clm_router_get_global_search_results_7251656784881985287 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/analytics
pub async fn get_global_search_results(
state: web::Data<AppState>,
req: actix_web::HttpRequest,
json_payload: web::Json<GetGlobalSearchRequest>,
) -> impl Responder {
let flow = AnalyticsFlow::GetGlobalSearchResults;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
json_payload.into_inner(),
|state, auth: UserFromToken, req, _| async move {
let role_id = auth.role_id;
let role_info = RoleInfo::from_role_id_org_id_tenant_id(
&state,
&role_id,
&auth.org_id,
auth.tenant_id.as_ref().unwrap_or(&state.tenant.tenant_id),
)
.await
.change_context(UserErrors::InternalServerError)
.change_context(OpenSearchError::UnknownError)?;
let permission_groups = role_info.get_permission_groups();
if !permission_groups.contains(&common_enums::PermissionGroup::OperationsView) {
return Err(OpenSearchError::AccessForbiddenError)?;
}
let user_roles: HashSet<UserRole> = match role_info.get_entity_type() {
EntityType::Tenant => state
.global_store
.list_user_roles_by_user_id(ListUserRolesByUserIdPayload {
user_id: &auth.user_id,
tenant_id: auth.tenant_id.as_ref().unwrap_or(&state.tenant.tenant_id),
org_id: None,
merchant_id: None,
profile_id: None,
entity_id: None,
version: None,
status: None,
limit: None,
})
.await
.change_context(UserErrors::InternalServerError)
.change_context(OpenSearchError::UnknownError)?
.into_iter()
.collect(),
EntityType::Organization | EntityType::Merchant | EntityType::Profile => state
.global_store
.list_user_roles_by_user_id(ListUserRolesByUserIdPayload {
user_id: &auth.user_id,
tenant_id: auth.tenant_id.as_ref().unwrap_or(&state.tenant.tenant_id),
org_id: Some(&auth.org_id),
merchant_id: None,
profile_id: None,
entity_id: None,
version: None,
status: None,
limit: None,
})
.await
.change_context(UserErrors::InternalServerError)
.change_context(OpenSearchError::UnknownError)?
.into_iter()
.collect(),
};
let state = Arc::new(state);
let role_info_map: HashMap<String, RoleInfo> = user_roles
.iter()
.map(|user_role| {
let state = Arc::clone(&state);
let role_id = user_role.role_id.clone();
let org_id = user_role.org_id.clone().unwrap_or_default();
let tenant_id = &user_role.tenant_id;
async move {
RoleInfo::from_role_id_org_id_tenant_id(
&state, &role_id, &org_id, tenant_id,
)
.await
.change_context(UserErrors::InternalServerError)
.change_context(OpenSearchError::UnknownError)
.map(|role_info| (role_id, role_info))
}
})
.collect::<FuturesUnordered<_>>()
.collect::<Vec<_>>()
.await
.into_iter()
.collect::<Result<HashMap<_, _>, _>>()?;
let filtered_user_roles: Vec<&UserRole> = user_roles
.iter()
.filter(|user_role| {
let user_role_id = &user_role.role_id;
if let Some(role_info) = role_info_map.get(user_role_id) {
let permissions = role_info.get_permission_groups();
permissions.contains(&common_enums::PermissionGroup::OperationsView)
} else {
false
}
})
.collect();
let search_params: Vec<AuthInfo> = filtered_user_roles
.iter()
.filter_map(|user_role| {
user_role
.get_entity_id_and_type()
.and_then(|(_, entity_type)| match entity_type {
EntityType::Profile => Some(AuthInfo::ProfileLevel {
org_id: user_role.org_id.clone()?,
merchant_id: user_role.merchant_id.clone()?,
profile_ids: vec![user_role.profile_id.clone()?],
}),
EntityType::Merchant => Some(AuthInfo::MerchantLevel {
org_id: user_role.org_id.clone()?,
merchant_ids: vec![user_role.merchant_id.clone()?],
}),
EntityType::Organization => Some(AuthInfo::OrgLevel {
org_id: user_role.org_id.clone()?,
}),
EntityType::Tenant => Some(AuthInfo::OrgLevel {
org_id: auth.org_id.clone(),
}),
})
})
.collect();
analytics::search::msearch_results(
state
.opensearch_client
.as_ref()
.ok_or_else(|| error_stack::report!(OpenSearchError::NotEnabled))?,
req,
search_params,
SEARCH_INDEXES.to_vec(),
)
.await
.map(ApplicationResponse::Json)
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
},
api_locking::LockAction::NotApplicable,
))
.await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 128,
"total_crates": null
} |
fn_clm_router_get_search_results_7251656784881985287 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/analytics
pub async fn get_search_results(
state: web::Data<AppState>,
req: actix_web::HttpRequest,
json_payload: web::Json<GetSearchRequest>,
index: web::Path<SearchIndex>,
) -> impl Responder {
let index = index.into_inner();
let flow = AnalyticsFlow::GetSearchResults;
let indexed_req = GetSearchRequestWithIndex {
search_req: json_payload.into_inner(),
index,
};
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
indexed_req,
|state, auth: UserFromToken, req, _| async move {
let role_id = auth.role_id;
let role_info = RoleInfo::from_role_id_org_id_tenant_id(
&state,
&role_id,
&auth.org_id,
auth.tenant_id.as_ref().unwrap_or(&state.tenant.tenant_id),
)
.await
.change_context(UserErrors::InternalServerError)
.change_context(OpenSearchError::UnknownError)?;
let permission_groups = role_info.get_permission_groups();
if !permission_groups.contains(&common_enums::PermissionGroup::OperationsView) {
return Err(OpenSearchError::AccessForbiddenError)?;
}
let user_roles: HashSet<UserRole> = match role_info.get_entity_type() {
EntityType::Tenant => state
.global_store
.list_user_roles_by_user_id(ListUserRolesByUserIdPayload {
user_id: &auth.user_id,
tenant_id: auth.tenant_id.as_ref().unwrap_or(&state.tenant.tenant_id),
org_id: None,
merchant_id: None,
profile_id: None,
entity_id: None,
version: None,
status: None,
limit: None,
})
.await
.change_context(UserErrors::InternalServerError)
.change_context(OpenSearchError::UnknownError)?
.into_iter()
.collect(),
EntityType::Organization | EntityType::Merchant | EntityType::Profile => state
.global_store
.list_user_roles_by_user_id(ListUserRolesByUserIdPayload {
user_id: &auth.user_id,
tenant_id: auth.tenant_id.as_ref().unwrap_or(&state.tenant.tenant_id),
org_id: Some(&auth.org_id),
merchant_id: None,
profile_id: None,
entity_id: None,
version: None,
status: None,
limit: None,
})
.await
.change_context(UserErrors::InternalServerError)
.change_context(OpenSearchError::UnknownError)?
.into_iter()
.collect(),
};
let state = Arc::new(state);
let role_info_map: HashMap<String, RoleInfo> = user_roles
.iter()
.map(|user_role| {
let state = Arc::clone(&state);
let role_id = user_role.role_id.clone();
let org_id = user_role.org_id.clone().unwrap_or_default();
let tenant_id = &user_role.tenant_id;
async move {
RoleInfo::from_role_id_org_id_tenant_id(
&state, &role_id, &org_id, tenant_id,
)
.await
.change_context(UserErrors::InternalServerError)
.change_context(OpenSearchError::UnknownError)
.map(|role_info| (role_id, role_info))
}
})
.collect::<FuturesUnordered<_>>()
.collect::<Vec<_>>()
.await
.into_iter()
.collect::<Result<HashMap<_, _>, _>>()?;
let filtered_user_roles: Vec<&UserRole> = user_roles
.iter()
.filter(|user_role| {
let user_role_id = &user_role.role_id;
if let Some(role_info) = role_info_map.get(user_role_id) {
let permissions = role_info.get_permission_groups();
permissions.contains(&common_enums::PermissionGroup::OperationsView)
} else {
false
}
})
.collect();
let search_params: Vec<AuthInfo> = filtered_user_roles
.iter()
.filter_map(|user_role| {
user_role
.get_entity_id_and_type()
.and_then(|(_, entity_type)| match entity_type {
EntityType::Profile => Some(AuthInfo::ProfileLevel {
org_id: user_role.org_id.clone()?,
merchant_id: user_role.merchant_id.clone()?,
profile_ids: vec![user_role.profile_id.clone()?],
}),
EntityType::Merchant => Some(AuthInfo::MerchantLevel {
org_id: user_role.org_id.clone()?,
merchant_ids: vec![user_role.merchant_id.clone()?],
}),
EntityType::Organization => Some(AuthInfo::OrgLevel {
org_id: user_role.org_id.clone()?,
}),
EntityType::Tenant => Some(AuthInfo::OrgLevel {
org_id: auth.org_id.clone(),
}),
})
})
.collect();
analytics::search::search_results(
state
.opensearch_client
.as_ref()
.ok_or_else(|| error_stack::report!(OpenSearchError::NotEnabled))?,
req,
search_params,
)
.await
.map(ApplicationResponse::Json)
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,
},
api_locking::LockAction::NotApplicable,
))
.await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 128,
"total_crates": null
} |
fn_clm_router_generate_profile_refund_report_7251656784881985287 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/analytics
pub async fn generate_profile_refund_report(
state: web::Data<AppState>,
req: actix_web::HttpRequest,
json_payload: web::Json<ReportRequest>,
) -> impl Responder {
let flow = AnalyticsFlow::GenerateRefundReport;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
json_payload.into_inner(),
|state, (auth, user_id): auth::AuthenticationDataWithUserId, payload, _| async move {
let user = UserInterface::find_user_by_id(&*state.global_store, &user_id)
.await
.change_context(AnalyticsError::UnknownError)?;
let user_email = UserEmail::from_pii_email(user.email)
.change_context(AnalyticsError::UnknownError)?
.get_secret();
let org_id = auth.merchant_account.get_org_id();
let merchant_id = auth.merchant_account.get_id();
let profile_id = auth
.profile_id
.ok_or(report!(UserErrors::JwtProfileIdMissing))
.change_context(AnalyticsError::AccessForbiddenError)?;
let lambda_req = GenerateReportRequest {
request: payload,
merchant_id: Some(merchant_id.clone()),
auth: AuthInfo::ProfileLevel {
org_id: org_id.clone(),
merchant_id: merchant_id.clone(),
profile_ids: vec![profile_id.clone()],
},
email: user_email,
};
let json_bytes =
serde_json::to_vec(&lambda_req).map_err(|_| AnalyticsError::UnknownError)?;
invoke_lambda(
&state.conf.report_download_config.refund_function,
&state.conf.report_download_config.region,
&json_bytes,
)
.await
.map(ApplicationResponse::Json)
},
&auth::JWTAuth {
permission: Permission::ProfileReportRead,
},
api_locking::LockAction::NotApplicable,
))
.await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 50,
"total_crates": null
} |
fn_clm_router_generate_profile_dispute_report_7251656784881985287 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/analytics
pub async fn generate_profile_dispute_report(
state: web::Data<AppState>,
req: actix_web::HttpRequest,
json_payload: web::Json<ReportRequest>,
) -> impl Responder {
let flow = AnalyticsFlow::GenerateDisputeReport;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
json_payload.into_inner(),
|state, (auth, user_id): auth::AuthenticationDataWithUserId, payload, _| async move {
let user = UserInterface::find_user_by_id(&*state.global_store, &user_id)
.await
.change_context(AnalyticsError::UnknownError)?;
let user_email = UserEmail::from_pii_email(user.email)
.change_context(AnalyticsError::UnknownError)?
.get_secret();
let org_id = auth.merchant_account.get_org_id();
let merchant_id = auth.merchant_account.get_id();
let profile_id = auth
.profile_id
.ok_or(report!(UserErrors::JwtProfileIdMissing))
.change_context(AnalyticsError::AccessForbiddenError)?;
let lambda_req = GenerateReportRequest {
request: payload,
merchant_id: Some(merchant_id.clone()),
auth: AuthInfo::ProfileLevel {
org_id: org_id.clone(),
merchant_id: merchant_id.clone(),
profile_ids: vec![profile_id.clone()],
},
email: user_email,
};
let json_bytes =
serde_json::to_vec(&lambda_req).map_err(|_| AnalyticsError::UnknownError)?;
invoke_lambda(
&state.conf.report_download_config.dispute_function,
&state.conf.report_download_config.region,
&json_bytes,
)
.await
.map(ApplicationResponse::Json)
},
&auth::JWTAuth {
permission: Permission::ProfileReportRead,
},
api_locking::LockAction::NotApplicable,
))
.await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 50,
"total_crates": null
} |
fn_clm_router_request_validator_4508620824829114635 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/analytics_validator
pub async fn request_validator(
req_type: AnalyticsRequest,
state: &crate::routes::SessionState,
) -> CustomResult<Option<ExchangeRates>, AnalyticsError> {
let forex_enabled = state.conf.analytics.get_inner().get_forex_enabled();
let require_forex_functionality = req_type.requires_forex_functionality();
let ex_rates = if forex_enabled && require_forex_functionality {
logger::info!("Fetching forex exchange rates");
Some(get_forex_exchange_rates(state.clone()).await?)
} else {
None
};
Ok(ex_rates)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 47,
"total_crates": null
} |
fn_clm_router_pg_connection_read_-6794934612961105234 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/connection
pub async fn pg_connection_read<T: storage_impl::DatabaseStore>(
store: &T,
) -> errors::CustomResult<
PooledConnection<'_, async_bb8_diesel::ConnectionManager<PgConnection>>,
storage_errors::StorageError,
> {
// If only OLAP is enabled get replica pool.
#[cfg(all(feature = "olap", not(feature = "oltp")))]
let pool = store.get_replica_pool();
// If either one of these are true we need to get master pool.
// 1. Only OLTP is enabled.
// 2. Both OLAP and OLTP is enabled.
// 3. Both OLAP and OLTP is disabled.
#[cfg(any(
all(not(feature = "olap"), feature = "oltp"),
all(feature = "olap", feature = "oltp"),
all(not(feature = "olap"), not(feature = "oltp"))
))]
let pool = store.get_master_pool();
pool.get()
.await
.change_context(storage_errors::StorageError::DatabaseConnectionError)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 69,
"total_crates": null
} |
fn_clm_router_pg_connection_write_-6794934612961105234 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/connection
pub async fn pg_connection_write<T: storage_impl::DatabaseStore>(
store: &T,
) -> errors::CustomResult<
PooledConnection<'_, async_bb8_diesel::ConnectionManager<PgConnection>>,
storage_errors::StorageError,
> {
// Since all writes should happen to master DB only choose master DB.
let pool = store.get_master_pool();
pool.get()
.await
.change_context(storage_errors::StorageError::DatabaseConnectionError)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 37,
"total_crates": null
} |
fn_clm_router_pg_accounts_connection_read_-6794934612961105234 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/connection
pub async fn pg_accounts_connection_read<T: storage_impl::DatabaseStore>(
store: &T,
) -> errors::CustomResult<
PooledConnection<'_, async_bb8_diesel::ConnectionManager<PgConnection>>,
storage_errors::StorageError,
> {
// If only OLAP is enabled get replica pool.
#[cfg(all(feature = "olap", not(feature = "oltp")))]
let pool = store.get_accounts_replica_pool();
// If either one of these are true we need to get master pool.
// 1. Only OLTP is enabled.
// 2. Both OLAP and OLTP is enabled.
// 3. Both OLAP and OLTP is disabled.
#[cfg(any(
all(not(feature = "olap"), feature = "oltp"),
all(feature = "olap", feature = "oltp"),
all(not(feature = "olap"), not(feature = "oltp"))
))]
let pool = store.get_accounts_master_pool();
pool.get()
.await
.change_context(storage_errors::StorageError::DatabaseConnectionError)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 18,
"total_crates": null
} |
fn_clm_router_pg_accounts_connection_write_-6794934612961105234 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/connection
pub async fn pg_accounts_connection_write<T: storage_impl::DatabaseStore>(
store: &T,
) -> errors::CustomResult<
PooledConnection<'_, async_bb8_diesel::ConnectionManager<PgConnection>>,
storage_errors::StorageError,
> {
// Since all writes should happen to master DB only choose master DB.
let pool = store.get_accounts_master_pool();
pool.get()
.await
.change_context(storage_errors::StorageError::DatabaseConnectionError)
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 16,
"total_crates": null
} |
fn_clm_router_redis_connection_-6794934612961105234 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/connection
pub async fn redis_connection(
conf: &crate::configs::Settings,
) -> redis_interface::RedisConnectionPool {
redis_interface::RedisConnectionPool::new(&conf.redis)
.await
.expect("Failed to create Redis Connection Pool")
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 15,
"total_crates": null
} |
fn_clm_router_generate_id_-8258380469248673085 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/utils
pub fn generate_id(length: usize, prefix: &str) -> String {
format!("{}_{}", prefix, nanoid!(length, &consts::ALPHABETS))
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 118,
"total_crates": null
} |
fn_clm_router_get_domain_address_-8258380469248673085 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/utils
// Implementation of api_models::customers::CustomerUpdateRequest for CustomerAddress
async fn get_domain_address(
&self,
state: &SessionState,
address_details: payments::AddressDetails,
merchant_id: &id_type::MerchantId,
customer_id: &id_type::CustomerId,
key: &[u8],
storage_scheme: storage::enums::MerchantStorageScheme,
) -> CustomResult<domain::CustomerAddress, common_utils::errors::CryptoError> {
let encrypted_data = crypto_operation(
&state.into(),
type_name!(storage::Address),
CryptoOperation::BatchEncrypt(domain::FromRequestEncryptableAddress::to_encryptable(
domain::FromRequestEncryptableAddress {
line1: address_details.line1.clone(),
line2: address_details.line2.clone(),
line3: address_details.line3.clone(),
state: address_details.state.clone(),
first_name: address_details.first_name.clone(),
last_name: address_details.last_name.clone(),
zip: address_details.zip.clone(),
phone_number: self.phone.clone(),
email: self
.email
.as_ref()
.map(|a| a.clone().expose().switch_strategy()),
origin_zip: address_details.origin_zip.clone(),
},
)),
Identifier::Merchant(merchant_id.to_owned()),
key,
)
.await
.and_then(|val| val.try_into_batchoperation())?;
let encryptable_address =
domain::FromRequestEncryptableAddress::from_encryptable(encrypted_data)
.change_context(common_utils::errors::CryptoError::EncodingFailed)?;
let address = domain::Address {
city: address_details.city,
country: address_details.country,
line1: encryptable_address.line1,
line2: encryptable_address.line2,
line3: encryptable_address.line3,
zip: encryptable_address.zip,
state: encryptable_address.state,
first_name: encryptable_address.first_name,
last_name: encryptable_address.last_name,
phone_number: encryptable_address.phone_number,
country_code: self.phone_country_code.clone(),
merchant_id: merchant_id.to_owned(),
address_id: generate_id(consts::ID_LENGTH, "add"),
created_at: common_utils::date_time::now(),
modified_at: common_utils::date_time::now(),
updated_by: storage_scheme.to_string(),
email: encryptable_address.email.map(|email| {
let encryptable: Encryptable<masking::Secret<String, pii::EmailStrategy>> =
Encryptable::new(
email.clone().into_inner().switch_strategy(),
email.into_encrypted(),
);
encryptable
}),
origin_zip: encryptable_address.origin_zip,
};
Ok(domain::CustomerAddress {
address,
customer_id: customer_id.to_owned(),
})
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 94,
"total_crates": null
} |
fn_clm_router_handle_json_response_deserialization_failure_-8258380469248673085 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/utils
pub fn handle_json_response_deserialization_failure(
res: types::Response,
connector: &'static str,
) -> CustomResult<types::ErrorResponse, errors::ConnectorError> {
metrics::RESPONSE_DESERIALIZATION_FAILURE
.add(1, router_env::metric_attributes!(("connector", connector)));
let response_data = String::from_utf8(res.response.to_vec())
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
// check for whether the response is in json format
match serde_json::from_str::<Value>(&response_data) {
// in case of unexpected response but in json format
Ok(_) => Err(errors::ConnectorError::ResponseDeserializationFailed)?,
// in case of unexpected response but in html or string format
Err(error_msg) => {
logger::error!(deserialization_error=?error_msg);
logger::error!("UNEXPECTED RESPONSE FROM CONNECTOR: {}", response_data);
Ok(types::ErrorResponse {
status_code: res.status_code,
code: consts::NO_ERROR_CODE.to_string(),
message: consts::UNSUPPORTED_ERROR_MESSAGE.to_string(),
reason: Some(response_data),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
}
}
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 76,
"total_crates": null
} |
fn_clm_router_get_address_update_-8258380469248673085 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/utils
// Implementation of api_models::customers::CustomerUpdateRequest for CustomerAddress
async fn get_address_update(
&self,
state: &SessionState,
address_details: payments::AddressDetails,
key: &[u8],
storage_scheme: storage::enums::MerchantStorageScheme,
merchant_id: id_type::MerchantId,
) -> CustomResult<storage::AddressUpdate, common_utils::errors::CryptoError> {
let encrypted_data = crypto_operation(
&state.into(),
type_name!(storage::Address),
CryptoOperation::BatchEncrypt(domain::FromRequestEncryptableAddress::to_encryptable(
domain::FromRequestEncryptableAddress {
line1: address_details.line1.clone(),
line2: address_details.line2.clone(),
line3: address_details.line3.clone(),
state: address_details.state.clone(),
first_name: address_details.first_name.clone(),
last_name: address_details.last_name.clone(),
zip: address_details.zip.clone(),
phone_number: self.phone.clone(),
email: self
.email
.as_ref()
.map(|a| a.clone().expose().switch_strategy()),
origin_zip: address_details.origin_zip.clone(),
},
)),
Identifier::Merchant(merchant_id.to_owned()),
key,
)
.await
.and_then(|val| val.try_into_batchoperation())?;
let encryptable_address =
domain::FromRequestEncryptableAddress::from_encryptable(encrypted_data)
.change_context(common_utils::errors::CryptoError::EncodingFailed)?;
Ok(storage::AddressUpdate::Update {
city: address_details.city,
country: address_details.country,
line1: encryptable_address.line1,
line2: encryptable_address.line2,
line3: encryptable_address.line3,
zip: encryptable_address.zip,
state: encryptable_address.state,
first_name: encryptable_address.first_name,
last_name: encryptable_address.last_name,
phone_number: encryptable_address.phone_number,
country_code: self.phone_country_code.clone(),
updated_by: storage_scheme.to_string(),
email: encryptable_address.email.map(|email| {
let encryptable: Encryptable<masking::Secret<String, pii::EmailStrategy>> =
Encryptable::new(
email.clone().into_inner().switch_strategy(),
email.into_encrypted(),
);
encryptable
}),
origin_zip: encryptable_address.origin_zip,
})
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 75,
"total_crates": null
} |
fn_clm_router_find_payment_intent_from_payment_id_type_-8258380469248673085 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/utils
pub async fn find_payment_intent_from_payment_id_type(
state: &SessionState,
payment_id_type: payments::PaymentIdType,
merchant_context: &domain::MerchantContext,
) -> CustomResult<PaymentIntent, errors::ApiErrorResponse> {
let key_manager_state: KeyManagerState = state.into();
let db = &*state.store;
match payment_id_type {
payments::PaymentIdType::PaymentIntentId(payment_id) => db
.find_payment_intent_by_payment_id_merchant_id(
&key_manager_state,
&payment_id,
merchant_context.get_merchant_account().get_id(),
merchant_context.get_merchant_key_store(),
merchant_context.get_merchant_account().storage_scheme,
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound),
payments::PaymentIdType::ConnectorTransactionId(connector_transaction_id) => {
let attempt = db
.find_payment_attempt_by_merchant_id_connector_txn_id(
merchant_context.get_merchant_account().get_id(),
&connector_transaction_id,
merchant_context.get_merchant_account().storage_scheme,
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
db.find_payment_intent_by_payment_id_merchant_id(
&key_manager_state,
&attempt.payment_id,
merchant_context.get_merchant_account().get_id(),
merchant_context.get_merchant_key_store(),
merchant_context.get_merchant_account().storage_scheme,
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)
}
payments::PaymentIdType::PaymentAttemptId(attempt_id) => {
let attempt = db
.find_payment_attempt_by_attempt_id_merchant_id(
&attempt_id,
merchant_context.get_merchant_account().get_id(),
merchant_context.get_merchant_account().storage_scheme,
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
db.find_payment_intent_by_payment_id_merchant_id(
&key_manager_state,
&attempt.payment_id,
merchant_context.get_merchant_account().get_id(),
merchant_context.get_merchant_key_store(),
merchant_context.get_merchant_account().storage_scheme,
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)
}
payments::PaymentIdType::PreprocessingId(_) => {
Err(errors::ApiErrorResponse::PaymentNotFound)?
}
}
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 71,
"total_crates": null
} |
fn_clm_router_compatibility_api_wrap_7116008476229996194 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/compatibility/wrap
pub async fn compatibility_api_wrap<'a, 'b, U, T, Q, F, Fut, S, E, E2>(
flow: impl router_env::types::FlowMetric,
state: Arc<AppState>,
request: &'a HttpRequest,
payload: T,
func: F,
api_authentication: &dyn auth::AuthenticateAndFetch<U, SessionState>,
lock_action: api_locking::LockAction,
) -> HttpResponse
where
F: Fn(SessionState, U, T, ReqState) -> Fut,
Fut: Future<Output = CustomResult<api::ApplicationResponse<Q>, E2>>,
E2: ErrorSwitch<E> + std::error::Error + Send + Sync + 'static,
Q: Serialize + std::fmt::Debug + 'a + ApiEventMetric,
S: TryFrom<Q> + Serialize,
E: Serialize + error_stack::Context + actix_web::ResponseError + Clone,
error_stack::Report<E>: services::EmbedError,
errors::ApiErrorResponse: ErrorSwitch<E>,
T: std::fmt::Debug + Serialize + ApiEventMetric,
{
let request_method = request.method().as_str();
let url_path = request.path();
tracing::Span::current().record("request_method", request_method);
tracing::Span::current().record("request_url_path", url_path);
let start_instant = Instant::now();
logger::info!(tag = ?Tag::BeginRequest, payload = ?payload);
let server_wrap_util_res = api::server_wrap_util(
&flow,
state.clone().into(),
request.headers(),
request,
payload,
func,
api_authentication,
lock_action,
)
.await
.map(|response| {
logger::info!(api_response =? response);
response
});
let res = match server_wrap_util_res {
Ok(api::ApplicationResponse::Json(response)) => {
let response = S::try_from(response);
match response {
Ok(response) => match serde_json::to_string(&response) {
Ok(res) => api::http_response_json(res),
Err(_) => api::http_response_err(
r#"{
"error": {
"message": "Error serializing response from connector"
}
}"#,
),
},
Err(_) => api::http_response_err(
r#"{
"error": {
"message": "Error converting juspay response to stripe response"
}
}"#,
),
}
}
Ok(api::ApplicationResponse::JsonWithHeaders((response, headers))) => {
let response = S::try_from(response);
match response {
Ok(response) => match serde_json::to_string(&response) {
Ok(res) => api::http_response_json_with_headers(res, headers, None, None),
Err(_) => api::http_response_err(
r#"{
"error": {
"message": "Error serializing response from connector"
}
}"#,
),
},
Err(_) => api::http_response_err(
r#"{
"error": {
"message": "Error converting juspay response to stripe response"
}
}"#,
),
}
}
Ok(api::ApplicationResponse::StatusOk) => api::http_response_ok(),
Ok(api::ApplicationResponse::TextPlain(text)) => api::http_response_plaintext(text),
Ok(api::ApplicationResponse::FileData((file_data, content_type))) => {
api::http_response_file_data(file_data, content_type)
}
Ok(api::ApplicationResponse::JsonForRedirection(response)) => {
match serde_json::to_string(&response) {
Ok(res) => api::http_redirect_response(res, response),
Err(_) => api::http_response_err(
r#"{
"error": {
"message": "Error serializing response from connector"
}
}"#,
),
}
}
Ok(api::ApplicationResponse::Form(redirection_data)) => {
let config = state.conf();
api::build_redirection_form(
&redirection_data.redirect_form,
redirection_data.payment_method_data,
redirection_data.amount,
redirection_data.currency,
config,
)
.respond_to(request)
.map_into_boxed_body()
}
Ok(api::ApplicationResponse::GenericLinkForm(boxed_generic_link_data)) => {
let link_type = (boxed_generic_link_data).data.to_string();
match services::generic_link_response::build_generic_link_html(
boxed_generic_link_data.data,
boxed_generic_link_data.locale,
) {
Ok(rendered_html) => api::http_response_html_data(rendered_html, None),
Err(_) => {
api::http_response_err(format!("Error while rendering {link_type} HTML page"))
}
}
}
Ok(api::ApplicationResponse::PaymentLinkForm(boxed_payment_link_data)) => {
match *boxed_payment_link_data {
api::PaymentLinkAction::PaymentLinkFormData(payment_link_data) => {
match api::build_payment_link_html(payment_link_data) {
Ok(rendered_html) => api::http_response_html_data(rendered_html, None),
Err(_) => api::http_response_err(
r#"{
"error": {
"message": "Error while rendering payment link html page"
}
}"#,
),
}
}
api::PaymentLinkAction::PaymentLinkStatus(payment_link_data) => {
match api::get_payment_link_status(payment_link_data) {
Ok(rendered_html) => api::http_response_html_data(rendered_html, None),
Err(_) => api::http_response_err(
r#"{
"error": {
"message": "Error while rendering payment link status page"
}
}"#,
),
}
}
}
}
Err(error) => api::log_and_return_error_response(error),
};
let response_code = res.status().as_u16();
let end_instant = Instant::now();
let request_duration = end_instant.saturating_duration_since(start_instant);
logger::info!(
tag = ?Tag::EndRequest,
status_code = response_code,
time_taken_ms = request_duration.as_millis(),
);
res
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 106,
"total_crates": null
} |
fn_clm_router_server_1419916206235463660 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/compatibility/stripe
// Inherent implementation for StripeApis
pub fn server(state: routes::AppState) -> Scope {
let max_depth = 10;
let strict = false;
web::scope("/vs/v1")
.app_data(web::Data::new(serde_qs::Config::new(max_depth, strict)))
.service(app::SetupIntents::server(state.clone()))
.service(app::PaymentIntents::server(state.clone()))
.service(app::Refunds::server(state.clone()))
.service(app::Customers::server(state.clone()))
.service(app::Webhooks::server(state.clone()))
.service(app::Mandates::server(state))
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 246,
"total_crates": null
} |
fn_clm_router_payment_intents_create_-8118575186235229257 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/compatibility/stripe/payment_intents
pub async fn payment_intents_create(
state: web::Data<routes::AppState>,
qs_config: web::Data<serde_qs::Config>,
req: HttpRequest,
form_payload: web::Bytes,
) -> HttpResponse {
let payload: types::StripePaymentIntentRequest = match qs_config
.deserialize_bytes(&form_payload)
.map_err(|err| report!(errors::StripeErrorCode::from(err)))
{
Ok(p) => p,
Err(err) => return api::log_and_return_error_response(err),
};
tracing::Span::current().record(
"payment_id",
payload
.id
.as_ref()
.map(|payment_id| payment_id.get_string_repr())
.unwrap_or_default(),
);
logger::info!(tag = ?Tag::CompatibilityLayerRequest, payload = ?payload);
let mut create_payment_req: payment_types::PaymentsRequest = match payload.try_into() {
Ok(req) => req,
Err(err) => return api::log_and_return_error_response(err),
};
if let Err(err) = get_or_generate_payment_id(&mut create_payment_req) {
return api::log_and_return_error_response(err);
}
let flow = Flow::PaymentsCreate;
let locking_action = create_payment_req.get_locking_input(flow.clone());
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
_,
_,
types::StripePaymentIntentResponse,
errors::StripeErrorCode,
_,
>(
flow,
state.into_inner(),
&req,
create_payment_req,
|state, auth: auth::AuthenticationData, req, req_state| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
let eligible_connectors = req.connector.clone();
payments::payments_core::<
api_types::Authorize,
api_types::PaymentsResponse,
_,
_,
_,
payments::PaymentData<api_types::Authorize>,
>(
state,
req_state,
merchant_context,
None,
payments::PaymentCreate,
req,
api::AuthFlow::Merchant,
payments::CallConnectorAction::Trigger,
eligible_connectors,
hyperswitch_domain_models::payments::HeaderPayload::default(),
)
},
&auth::HeaderAuth(auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
}),
locking_action,
))
.await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 56,
"total_crates": null
} |
fn_clm_router_payment_intents_confirm_-8118575186235229257 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/compatibility/stripe/payment_intents
pub async fn payment_intents_confirm(
state: web::Data<routes::AppState>,
qs_config: web::Data<serde_qs::Config>,
req: HttpRequest,
form_payload: web::Bytes,
path: web::Path<common_utils::id_type::PaymentId>,
) -> HttpResponse {
let payment_id = path.into_inner();
let stripe_payload: types::StripePaymentIntentRequest = match qs_config
.deserialize_bytes(&form_payload)
{
Ok(p) => p,
Err(err) => {
return api::log_and_return_error_response(report!(errors::StripeErrorCode::from(err)))
}
};
tracing::Span::current().record(
"payment_id",
stripe_payload.id.as_ref().map(|id| id.get_string_repr()),
);
logger::info!(tag = ?Tag::CompatibilityLayerRequest, payload = ?stripe_payload);
let mut payload: payment_types::PaymentsRequest = match stripe_payload.try_into() {
Ok(req) => req,
Err(err) => return api::log_and_return_error_response(err),
};
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(payment_id));
payload.confirm = Some(true);
let api_auth = auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
};
let (auth_type, auth_flow) =
match auth::check_client_secret_and_get_auth(req.headers(), &payload, api_auth) {
Ok(auth) => auth,
Err(err) => return api::log_and_return_error_response(err),
};
let flow = Flow::PaymentsConfirm;
let locking_action = payload.get_locking_input(flow.clone());
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
_,
_,
types::StripePaymentIntentResponse,
errors::StripeErrorCode,
_,
>(
flow,
state.into_inner(),
&req,
payload,
|state, auth, req, req_state| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
let eligible_connectors = req.connector.clone();
payments::payments_core::<
api_types::Authorize,
api_types::PaymentsResponse,
_,
_,
_,
payments::PaymentData<api_types::Authorize>,
>(
state,
req_state,
merchant_context,
None,
payments::PaymentConfirm,
req,
auth_flow,
payments::CallConnectorAction::Trigger,
eligible_connectors,
hyperswitch_domain_models::payments::HeaderPayload::default(),
)
},
&*auth_type,
locking_action,
))
.await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 56,
"total_crates": null
} |
fn_clm_router_payment_intents_retrieve_with_gateway_creds_-8118575186235229257 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/compatibility/stripe/payment_intents
pub async fn payment_intents_retrieve_with_gateway_creds(
state: web::Data<routes::AppState>,
qs_config: web::Data<serde_qs::Config>,
req: HttpRequest,
form_payload: web::Bytes,
) -> HttpResponse {
let json_payload: payment_types::PaymentRetrieveBodyWithCredentials = match qs_config
.deserialize_bytes(&form_payload)
.map_err(|err| report!(errors::StripeErrorCode::from(err)))
{
Ok(p) => p,
Err(err) => return api::log_and_return_error_response(err),
};
let payload = payment_types::PaymentsRetrieveRequest {
resource_id: payment_types::PaymentIdType::PaymentIntentId(json_payload.payment_id),
merchant_id: json_payload.merchant_id.clone(),
force_sync: json_payload.force_sync.unwrap_or(false),
merchant_connector_details: json_payload.merchant_connector_details.clone(),
..Default::default()
};
let api_auth = auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
};
let (auth_type, _auth_flow) = match auth::get_auth_type_and_flow(req.headers(), api_auth) {
Ok(auth) => auth,
Err(err) => return api::log_and_return_error_response(report!(err)),
};
let flow = match json_payload.force_sync {
Some(true) => Flow::PaymentsRetrieveForceSync,
_ => Flow::PaymentsRetrieve,
};
tracing::Span::current().record("flow", flow.to_string());
let locking_action = payload.get_locking_input(flow.clone());
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
_,
_,
types::StripePaymentIntentResponse,
errors::StripeErrorCode,
_,
>(
flow,
state.into_inner(),
&req,
payload,
|state, auth, req, req_state| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
payments::payments_core::<
api_types::PSync,
payment_types::PaymentsResponse,
_,
_,
_,
payments::PaymentData<api_types::PSync>,
>(
state,
req_state,
merchant_context,
None,
payments::PaymentStatus,
req,
api::AuthFlow::Merchant,
payments::CallConnectorAction::Trigger,
None,
hyperswitch_domain_models::payments::HeaderPayload::default(),
)
},
&*auth_type,
locking_action,
))
.await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 54,
"total_crates": null
} |
fn_clm_router_payment_intents_update_-8118575186235229257 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/compatibility/stripe/payment_intents
pub async fn payment_intents_update(
state: web::Data<routes::AppState>,
qs_config: web::Data<serde_qs::Config>,
req: HttpRequest,
form_payload: web::Bytes,
path: web::Path<common_utils::id_type::PaymentId>,
) -> HttpResponse {
let payment_id = path.into_inner();
let stripe_payload: types::StripePaymentIntentRequest = match qs_config
.deserialize_bytes(&form_payload)
{
Ok(p) => p,
Err(err) => {
return api::log_and_return_error_response(report!(errors::StripeErrorCode::from(err)))
}
};
let mut payload: payment_types::PaymentsRequest = match stripe_payload.try_into() {
Ok(req) => req,
Err(err) => return api::log_and_return_error_response(err),
};
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(payment_id));
let api_auth = auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
};
let (auth_type, auth_flow) = match auth::get_auth_type_and_flow(req.headers(), api_auth) {
Ok(auth) => auth,
Err(err) => return api::log_and_return_error_response(report!(err)),
};
let flow = Flow::PaymentsUpdate;
let locking_action = payload.get_locking_input(flow.clone());
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
_,
_,
types::StripePaymentIntentResponse,
errors::StripeErrorCode,
_,
>(
flow,
state.into_inner(),
&req,
payload,
|state, auth, req, req_state| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
let eligible_connectors = req.connector.clone();
payments::payments_core::<
api_types::Authorize,
api_types::PaymentsResponse,
_,
_,
_,
payments::PaymentData<api_types::Authorize>,
>(
state,
req_state,
merchant_context,
None,
payments::PaymentUpdate,
req,
auth_flow,
payments::CallConnectorAction::Trigger,
eligible_connectors,
hyperswitch_domain_models::payments::HeaderPayload::default(),
)
},
&*auth_type,
locking_action,
))
.await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 46,
"total_crates": null
} |
fn_clm_router_payment_intents_cancel_-8118575186235229257 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/compatibility/stripe/payment_intents
pub async fn payment_intents_cancel(
state: web::Data<routes::AppState>,
qs_config: web::Data<serde_qs::Config>,
req: HttpRequest,
form_payload: web::Bytes,
path: web::Path<common_utils::id_type::PaymentId>,
) -> HttpResponse {
let payment_id = path.into_inner();
let stripe_payload: types::StripePaymentCancelRequest = match qs_config
.deserialize_bytes(&form_payload)
{
Ok(p) => p,
Err(err) => {
return api::log_and_return_error_response(report!(errors::StripeErrorCode::from(err)))
}
};
tracing::Span::current().record("payment_id", payment_id.get_string_repr());
logger::info!(tag = ?Tag::CompatibilityLayerRequest, payload = ?stripe_payload);
let mut payload: payment_types::PaymentsCancelRequest = stripe_payload.into();
payload.payment_id = payment_id;
let api_auth = auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
};
let (auth_type, auth_flow) = match auth::get_auth_type_and_flow(req.headers(), api_auth) {
Ok(auth) => auth,
Err(err) => return api::log_and_return_error_response(report!(err)),
};
let flow = Flow::PaymentsCancel;
let locking_action = payload.get_locking_input(flow.clone());
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
_,
_,
types::StripePaymentIntentResponse,
errors::StripeErrorCode,
_,
>(
flow,
state.into_inner(),
&req,
payload,
|state, auth, req, req_state| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
payments::payments_core::<
api_types::Void,
api_types::PaymentsResponse,
_,
_,
_,
payments::PaymentData<api_types::Void>,
>(
state,
req_state,
merchant_context,
None,
payments::PaymentCancel,
req,
auth_flow,
payments::CallConnectorAction::Trigger,
None,
hyperswitch_domain_models::payments::HeaderPayload::default(),
)
},
&*auth_type,
locking_action,
))
.await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 46,
"total_crates": null
} |
fn_clm_router_refund_create_-4653660248129944042 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/compatibility/stripe/refunds
pub async fn refund_create(
state: web::Data<routes::AppState>,
qs_config: web::Data<serde_qs::Config>,
req: HttpRequest,
form_payload: web::Bytes,
) -> HttpResponse {
let payload: types::StripeCreateRefundRequest = match qs_config
.deserialize_bytes(&form_payload)
.map_err(|err| report!(errors::StripeErrorCode::from(err)))
{
Ok(p) => p,
Err(err) => return api::log_and_return_error_response(err),
};
tracing::Span::current().record("payment_id", payload.payment_intent.get_string_repr());
logger::info!(tag = ?Tag::CompatibilityLayerRequest, payload = ?payload);
let create_refund_req: refund_types::RefundRequest = payload.into();
let flow = Flow::RefundsCreate;
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
_,
_,
types::StripeRefundResponse,
errors::StripeErrorCode,
_,
>(
flow,
state.into_inner(),
&req,
create_refund_req,
|state, auth: auth::AuthenticationData, req, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
refunds::refund_create_core(state, merchant_context, None, req)
},
&auth::HeaderAuth(auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
}),
api_locking::LockAction::NotApplicable,
))
.await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 38,
"total_crates": null
} |
fn_clm_router_refund_retrieve_with_gateway_creds_-4653660248129944042 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/compatibility/stripe/refunds
pub async fn refund_retrieve_with_gateway_creds(
state: web::Data<routes::AppState>,
qs_config: web::Data<serde_qs::Config>,
req: HttpRequest,
form_payload: web::Bytes,
) -> HttpResponse {
let refund_request: refund_types::RefundsRetrieveRequest = match qs_config
.deserialize_bytes(&form_payload)
.map_err(|err| report!(errors::StripeErrorCode::from(err)))
{
Ok(payload) => payload,
Err(err) => return api::log_and_return_error_response(err),
};
let flow = match refund_request.force_sync {
Some(true) => Flow::RefundsRetrieveForceSync,
_ => Flow::RefundsRetrieve,
};
tracing::Span::current().record("flow", flow.to_string());
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
_,
_,
types::StripeRefundResponse,
errors::StripeErrorCode,
_,
>(
flow,
state.into_inner(),
&req,
refund_request,
|state, auth: auth::AuthenticationData, refund_request, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
refunds::refund_response_wrapper(
state,
merchant_context,
None,
refund_request,
refunds::refund_retrieve_core_with_refund_id,
)
},
&auth::HeaderAuth(auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
}),
api_locking::LockAction::NotApplicable,
))
.await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 36,
"total_crates": null
} |
fn_clm_router_refund_update_-4653660248129944042 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/compatibility/stripe/refunds
pub async fn refund_update(
state: web::Data<routes::AppState>,
req: HttpRequest,
path: web::Path<String>,
form_payload: web::Form<types::StripeUpdateRefundRequest>,
) -> HttpResponse {
let mut payload = form_payload.into_inner();
payload.refund_id = path.into_inner();
let create_refund_update_req: refund_types::RefundUpdateRequest = payload.into();
let flow = Flow::RefundsUpdate;
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
_,
_,
types::StripeRefundResponse,
errors::StripeErrorCode,
_,
>(
flow,
state.into_inner(),
&req,
create_refund_update_req,
|state, auth: auth::AuthenticationData, req, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
refunds::refund_update_core(state, merchant_context, req)
},
&auth::HeaderAuth(auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
}),
api_locking::LockAction::NotApplicable,
))
.await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 30,
"total_crates": null
} |
fn_clm_router_refund_retrieve_-4653660248129944042 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/compatibility/stripe/refunds
pub async fn refund_retrieve(
state: web::Data<routes::AppState>,
req: HttpRequest,
path: web::Path<String>,
) -> HttpResponse {
let refund_request = refund_types::RefundsRetrieveRequest {
refund_id: path.into_inner(),
force_sync: Some(true),
merchant_connector_details: None,
};
let flow = Flow::RefundsRetrieveForceSync;
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
_,
_,
types::StripeRefundResponse,
errors::StripeErrorCode,
_,
>(
flow,
state.into_inner(),
&req,
refund_request,
|state, auth: auth::AuthenticationData, refund_request, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
refunds::refund_response_wrapper(
state,
merchant_context,
None,
refund_request,
refunds::refund_retrieve_core_with_refund_id,
)
},
&auth::HeaderAuth(auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
}),
api_locking::LockAction::NotApplicable,
))
.await
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_router_from_-846307319803188573 | clm | function | // Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/compatibility/stripe/webhooks
// Implementation of StripeWebhookObject for From<api::OutgoingWebhookContent>
fn from(value: api::OutgoingWebhookContent) -> Self {
match value {
api::OutgoingWebhookContent::PaymentDetails(payment) => {
Self::PaymentIntent(Box::new((*payment).into()))
}
api::OutgoingWebhookContent::RefundDetails(refund) => Self::Refund((*refund).into()),
api::OutgoingWebhookContent::DisputeDetails(dispute) => {
Self::Dispute((*dispute).into())
}
api::OutgoingWebhookContent::MandateDetails(mandate) => {
Self::Mandate((*mandate).into())
}
#[cfg(feature = "payouts")]
api::OutgoingWebhookContent::PayoutDetails(payout) => Self::Payout((*payout).into()),
}
}
| {
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2622,
"total_crates": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.