text
string
file_path
string
module
string
type
string
tokens
int64
language
string
struct_name
string
type_name
string
trait_name
string
impl_type
string
function_name
string
source
string
section
string
keys
list
macro_type
string
url
string
title
string
chunk_index
int64
pub struct Checkbook { amount_converter: &'static (dyn AmountConvertor<Output = FloatMajorUnit> + Sync), }
crates/hyperswitch_connectors/src/connectors/checkbook.rs
hyperswitch_connectors
struct_definition
27
rust
Checkbook
null
null
null
null
null
null
null
null
null
null
null
impl CardDetailUpdate { pub fn apply(&self, card_data_from_locker: Card) -> CardDetail { CardDetail { card_number: card_data_from_locker.card_number, card_exp_month: self .card_exp_month .clone() .unwrap_or(card_data_from_locker.card_exp_month), card_exp_year: self .card_exp_year .clone() .unwrap_or(card_data_from_locker.card_exp_year), card_holder_name: self .card_holder_name .clone() .or(card_data_from_locker.name_on_card), nick_name: self .nick_name .clone() .or(card_data_from_locker.nick_name.map(masking::Secret::new)), card_issuing_country: None, card_network: None, card_issuer: None, card_type: None, } } }
crates/api_models/src/payment_methods.rs
api_models
impl_block
195
rust
null
CardDetailUpdate
null
impl CardDetailUpdate
null
null
null
null
null
null
null
null
pub struct ApiKey { pub key_id: common_utils::id_type::ApiKeyId, pub merchant_id: common_utils::id_type::MerchantId, pub name: String, pub description: Option<String>, pub hashed_api_key: HashedApiKey, pub prefix: String, pub created_at: PrimitiveDateTime, pub expires_at: Option<PrimitiveDateTime>, pub last_used: Option<PrimitiveDateTime>, }
crates/diesel_models/src/api_keys.rs
diesel_models
struct_definition
91
rust
ApiKey
null
null
null
null
null
null
null
null
null
null
null
File: crates/router/src/types/storage/authorization.rs pub use diesel_models::authorization::{Authorization, AuthorizationNew, AuthorizationUpdate};
crates/router/src/types/storage/authorization.rs
router
full_file
26
null
null
null
null
null
null
null
null
null
null
null
null
null
OpenAPI Block Path: components.schemas.AuthenticationConnectorDetails { "type": "object", "required": [ "authentication_connectors", "three_ds_requestor_url" ], "properties": { "authentication_connectors": { "type": "array", "items": { "$ref": "#/components/schemas/AuthenticationConnectors" }, "description": "List of authentication connectors" }, "three_ds_requestor_url": { "type": "string", "description": "URL of the (customer service) website that will be shown to the shopper in case of technical errors during the 3D Secure 2 process." }, "three_ds_requestor_app_url": { "type": "string", "description": "Merchant app declaring their URL within the CReq message so that the Authentication app can call the Merchant app after OOB authentication has occurred.", "nullable": true } } }
./hyperswitch/api-reference/v1/openapi_spec_v1.json
null
openapi_block
206
.json
null
null
null
null
null
openapi_spec
components
[ "schemas", "AuthenticationConnectorDetails" ]
null
null
null
null
pub struct SessionRoutingPmTypeInput<'a> { routing_algorithm: &'a MerchantAccountRoutingAlgorithm, backend_input: dsl_inputs::BackendInput, allowed_connectors: FxHashMap<String, api::GetToken>, profile_id: &'a common_utils::id_type::ProfileId, }
crates/router/src/core/payments/routing.rs
router
struct_definition
65
rust
SessionRoutingPmTypeInput
null
null
null
null
null
null
null
null
null
null
null
pub struct Amount { total: FloatMajorUnit, currency: String, #[serde(skip_serializing_if = "Option::is_none")] components: Option<AmountComponents>, }
crates/hyperswitch_connectors/src/connectors/authipay/transformers.rs
hyperswitch_connectors
struct_definition
39
rust
Amount
null
null
null
null
null
null
null
null
null
null
null
pub struct KafkaProducer { producer: Arc<RdKafkaProducer>, intent_analytics_topic: String, fraud_check_analytics_topic: String, attempt_analytics_topic: String, refund_analytics_topic: String, api_logs_topic: String, connector_logs_topic: String, outgoing_webhook_logs_topic: String, dispute_analytics_topic: String, audit_events_topic: String, #[cfg(feature = "payouts")] payout_analytics_topic: String, consolidated_events_topic: String, authentication_analytics_topic: String, ckh_database_name: Option<String>, routing_logs_topic: String, revenue_recovery_topic: String, }
crates/router/src/services/kafka.rs
router
struct_definition
143
rust
KafkaProducer
null
null
null
null
null
null
null
null
null
null
null
OpenAPI Block Path: components.schemas.AuthenticationEligibilityResponse { "type": "object", "required": [ "authentication_id", "next_action", "status", "connector_metadata", "profile_id" ], "properties": { "authentication_id": { "type": "string", "description": "The unique identifier for this authentication.", "example": "auth_mbabizu24mvu3mela5njyhpit4" }, "next_action": { "$ref": "#/components/schemas/NextAction" }, "status": { "$ref": "#/components/schemas/AuthenticationStatus" }, "eligibility_response_params": { "allOf": [ { "$ref": "#/components/schemas/EligibilityResponseParams" } ], "nullable": true }, "connector_metadata": { "description": "The metadata for this authentication." }, "profile_id": { "type": "string", "description": "The unique identifier for this authentication." }, "error_message": { "type": "string", "description": "The error message for this authentication.", "nullable": true }, "error_code": { "type": "string", "description": "The error code for this authentication.", "nullable": true }, "authentication_connector": { "allOf": [ { "$ref": "#/components/schemas/AuthenticationConnectors" } ], "nullable": true }, "billing": { "allOf": [ { "$ref": "#/components/schemas/Address" } ], "nullable": true }, "shipping": { "allOf": [ { "$ref": "#/components/schemas/Address" } ], "nullable": true }, "browser_information": { "allOf": [ { "$ref": "#/components/schemas/BrowserInformation" } ], "nullable": true }, "email": { "type": "string", "description": "Email", "nullable": true }, "acquirer_details": { "allOf": [ { "$ref": "#/components/schemas/AcquirerDetails" } ], "nullable": true } } }
./hyperswitch/api-reference/v1/openapi_spec_v1.json
null
openapi_block
529
.json
null
null
null
null
null
openapi_spec
components
[ "schemas", "AuthenticationEligibilityResponse" ]
null
null
null
null
impl api::ConnectorAccessToken for Nexinets {}
crates/hyperswitch_connectors/src/connectors/nexinets.rs
hyperswitch_connectors
impl_block
10
rust
null
Nexinets
api::ConnectorAccessToken for
impl api::ConnectorAccessToken for for Nexinets
null
null
null
null
null
null
null
null
event_type: enums::EventType::PaymentSucceeded, event_class: enums::EventClass::Payments, is_webhook_notified: false, primary_object_id: payment_id.into(), primary_object_type: enums::EventObjectType::PaymentDetails, created_at: common_utils::date_time::now(), merchant_id: Some(merchant_id.to_owned()), business_profile_id: Some(business_profile_id.to_owned()), primary_object_created_at: Some(common_utils::date_time::now()), idempotent_event_id: Some(event_id.into()), initial_attempt_id: Some(event_id.into()), request: None, response: None, delivery_attempt: Some(enums::WebhookDeliveryAttempt::InitialAttempt), metadata: Some(EventMetadata::Payment { payment_id: common_utils::id_type::GlobalPaymentId::try_from( std::borrow::Cow::Borrowed(payment_id), ) .unwrap(), }), is_overall_delivery_successful: Some(false), }, &merchant_key_store, ) .await .unwrap(); assert_eq!(event1.event_id, event_id); let updated_event = mockdb .update_event_by_merchant_id_event_id( key_manager_state, &merchant_id, event_id, domain::EventUpdate::UpdateResponse { is_webhook_notified: true, response: None, }, &merchant_key_store, ) .await .unwrap(); assert!(updated_event.is_webhook_notified); assert_eq!(updated_event.primary_object_id, payment_id); assert_eq!(updated_event.event_id, event_id); } #[cfg(feature = "v1")] #[allow(clippy::panic_in_result_fn)] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn test_concurrent_webhook_insertion_with_redis_lock( ) -> Result<(), Box<dyn std::error::Error>> { // Test concurrent webhook insertion with a Redis lock to prevent race conditions let conf = Settings::new()?; let tx: tokio::sync::oneshot::Sender<()> = tokio::sync::oneshot::channel().0; let app_state = Box::pin(routes::AppState::with_storage( conf, StorageImpl::PostgresqlTest, tx, Box::new(services::MockApiClient), )) .await; let tenant_id = common_utils::id_type::TenantId::try_from_string("public".to_string())?; let state = Arc::new(app_state) .get_session_state(&tenant_id, None, || {}) .map_err(|_| "failed to get session state")?; let merchant_id = common_utils::id_type::MerchantId::try_from(std::borrow::Cow::from("juspay_merchant"))?; let business_profile_id = common_utils::id_type::ProfileId::try_from(std::borrow::Cow::from("profile1"))?; let key_manager_state = &(&state).into(); let master_key = state.store.get_master_key(); let aes_key = services::generate_aes256_key()?; let merchant_key_store = state .store .insert_merchant_key_store( key_manager_state, domain::MerchantKeyStore { merchant_id: merchant_id.clone(), key: domain::types::crypto_operation( key_manager_state, type_name!(domain::MerchantKeyStore), domain::types::CryptoOperation::Encrypt(aes_key.to_vec().into()), Identifier::Merchant(merchant_id.to_owned()), master_key, ) .await? .try_into_operation()?, created_at: datetime!(2023-02-01 0:00), }, &master_key.to_vec().into(), ) .await?; let merchant_account_to_insert = MerchantAccount::from(MerchantAccountSetter { merchant_id: merchant_id.clone(), merchant_name: None, merchant_details: None, return_url: None, webhook_details: Some(WebhookDetails { webhook_version: None, webhook_username: None, webhook_password: None, webhook_url: Some(masking::Secret::new( "https://example.com/webhooks".to_string(), )), payment_created_enabled: None, payment_succeeded_enabled: Some(true), payment_failed_enabled: None, payment_statuses_enabled: None, refund_statuses_enabled: None, payout_statuses_enabled: None, }), sub_merchants_enabled: None, parent_merchant_id: None, enable_payment_response_hash: true, payment_response_hash_key: None, redirect_to_merchant_with_http_post: false, publishable_key: "pk_test_11DviC2G2fb3lAJoes1q3A2222233327".to_string(), locker_id: None, storage_scheme: enums::MerchantStorageScheme::PostgresOnly, metadata: None, routing_algorithm: None, primary_business_details: serde_json::json!({ "country": "US", "business": "default" }), intent_fulfillment_time: Some(1), created_at: common_utils::date_time::now(), modified_at: common_utils::date_time::now(), frm_routing_algorithm: None, payout_routing_algorithm: None, organization_id: generate_organization_id_of_default_length(), is_recon_enabled: true, default_profile: None, recon_status: enums::ReconStatus::NotRequested, payment_link_config: None, pm_collect_link_config: None, is_platform_account: false, merchant_account_type: common_enums::MerchantAccountType::Standard, product_type: None, version: common_enums::ApiVersion::V1, }); let merchant_account = state .store .insert_merchant( key_manager_state, merchant_account_to_insert, &merchant_key_store, ) .await?; let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(domain::Context( merchant_account, merchant_key_store.clone(), ))); let merchant_id = merchant_id.clone(); // Clone merchant_id to avoid move let business_profile_to_insert = domain::Profile::from(domain::ProfileSetter { merchant_country_code: None, profile_id: business_profile_id.clone(), merchant_id: merchant_id.clone(), profile_name: "test_concurrent_profile".to_string(), created_at: common_utils::date_time::now(), modified_at: common_utils::date_time::now(), return_url: None, enable_payment_response_hash: true, payment_response_hash_key: None, redirect_to_merchant_with_http_post: false, webhook_details: Some(WebhookDetails { webhook_version: None, webhook_username: None, webhook_password: None, webhook_url: Some(masking::Secret::new( "https://example.com/webhooks".to_string(), )), payment_created_enabled: None, payment_succeeded_enabled: Some(true), payment_failed_enabled: None, payment_statuses_enabled: None, refund_statuses_enabled: None, payout_statuses_enabled: None, }), metadata: None, routing_algorithm: None, intent_fulfillment_time: None, frm_routing_algorithm: None, payout_routing_algorithm: None, is_recon_enabled: false, applepay_verified_domains: None, payment_link_config: None, session_expiry: None, authentication_connector_details: None, payout_link_config: None, is_extended_card_info_enabled: None, extended_card_info_config: None, is_connector_agnostic_mit_enabled: None, use_billing_as_payment_method_billing: None, collect_shipping_details_from_wallet_connector: None, collect_billing_details_from_wallet_connector: None, outgoing_webhook_custom_http_headers: None, always_collect_billing_details_from_wallet_connector: None, always_collect_shipping_details_from_wallet_connector: None, tax_connector_id: None, is_tax_connector_enabled: false, dynamic_routing_algorithm: None, is_network_tokenization_enabled: false, is_auto_retries_enabled: false, max_auto_retries_enabled: None, always_request_extended_authorization: None, is_click_to_pay_enabled: false, authentication_product_ids: None, card_testing_guard_config: None, card_testing_secret_key: None, is_clear_pan_retries_enabled: false, force_3ds_challenge: false, is_debit_routing_enabled: false, merchant_business_country: None, is_iframe_redirection_enabled: None, is_pre_network_tokenization_enabled: false, merchant_category_code: None, dispute_polling_interval: None, is_manual_retry_enabled: None, }); let business_profile = state .store .insert_business_profile( key_manager_state, &merchant_key_store.clone(), business_profile_to_insert, ) .await?; // Same inputs for all threads let event_type = enums::EventType::PaymentSucceeded; let event_class = enums::EventClass::Payments; let primary_object_id = Arc::new("concurrent_payment_id".to_string()); let primary_object_type = enums::EventObjectType::PaymentDetails; let payment_id = common_utils::id_type::PaymentId::try_from(std::borrow::Cow::Borrowed( "pay_mbabizu24mvu3mela5njyhpit10", ))?; let primary_object_created_at = Some(common_utils::date_time::now()); let expected_response = api::PaymentsResponse { payment_id, status: IntentStatus::Succeeded, amount: MinorUnit::new(6540), amount_capturable: MinorUnit::new(0), amount_received: None, client_secret: None, created: None, currency: "USD".to_string(), customer_id: None, description: Some("Its my first payment request".to_string()), refunds: None, mandate_id: None, merchant_id, net_amount: MinorUnit::new(6540), connector: None, customer: None, disputes: None, attempts: None, captures: None, mandate_data: None, setup_future_usage: None, off_session: None, capture_on: None, capture_method: None, payment_method: None, payment_method_data: None, payment_token: None, shipping: None, billing: None, order_details: None, email: None, name: None, phone: None, return_url: None, authentication_type: None, statement_descriptor_name: None, statement_descriptor_suffix: None, next_action: None, cancellation_reason: None, error_code: None, error_message: None, unified_code: None, unified_message: None, payment_experience: None, payment_method_type: None, connector_label: None, business_country: None, business_label: None, business_sub_label: None, allowed_payment_method_types: None, ephemeral_key: None, manual_retry_allowed: None, connector_transaction_id: None, frm_message: None, metadata: None, connector_metadata: None, feature_metadata: None, reference_id: None, payment_link: None, profile_id: None, surcharge_details: None, attempt_count: 1, merchant_decision: None, merchant_connector_id: None, incremental_authorization_allowed: None, authorization_count: None, incremental_authorizations: None, external_authentication_details: None, external_3ds_authentication_attempted: None, expires_on: None, fingerprint: None, browser_info: None, payment_method_id: None, payment_method_status: None, updated: None, split_payments: None, frm_metadata: None, merchant_order_reference_id: None, capture_before: None, extended_authorization_applied: None, order_tax_amount: None, connector_mandate_id: None, shipping_cost: None, card_discovery: None, force_3ds_challenge: None, force_3ds_challenge_trigger: None, issuer_error_code: None, issuer_error_message: None, is_iframe_redirection_enabled: None, whole_connector_response: None, payment_channel: None, network_transaction_id: None, enable_partial_authorization: None, }; let content = api_webhooks::OutgoingWebhookContent::PaymentDetails(Box::new(expected_response)); // Run 10 concurrent webhook creations let mut handles = vec![]; for _ in 0..10 { let state_clone = state.clone(); let merchant_context_clone = merchant_context.clone(); let business_profile_clone = business_profile.clone(); let content_clone = content.clone(); let primary_object_id_clone = primary_object_id.clone(); let handle = tokio::spawn(async move { webhooks_core::create_event_and_trigger_outgoing_webhook( state_clone, merchant_context_clone, business_profile_clone, event_type, event_class, (*primary_object_id_clone).to_string(), primary_object_type, content_clone, primary_object_created_at, ) .await .map_err(|e| format!("create_event_and_trigger_outgoing_webhook failed: {e}")) }); handles.push(handle); } // Await all tasks // We give the whole batch 20 s; if they don't finish something is wrong. let results = timeout(Duration::from_secs(20), join_all(handles)) .await .map_err(|_| "tasks hung for >20 s – possible dead-lock / endless retry")?; for res in results { // Any task that panicked or returned Err will make the test fail here. let _ = res.map_err(|e| format!("task panicked: {e}"))?; } // Collect all initial-attempt events for this payment let events = state .store .list_initial_events_by_merchant_id_primary_object_id( key_manager_state, &business_profile.merchant_id, &primary_object_id.clone(), merchant_context.get_merchant_key_store(), ) .await?; assert_eq!( events.len(), 1, "Expected exactly 1 row in events table, found {}", events.len() ); Ok(()) } }
crates/router/src/db/events.rs#chunk1
router
chunk
3,150
null
null
null
null
null
null
null
null
null
null
null
null
null
impl Responder { let flow = match json_payload.force_sync { Some(true) => Flow::PaymentsRetrieveForceSync, _ => Flow::PaymentsRetrieve, }; let payment_id = path.into_inner(); tracing::Span::current().record("payment_id", payment_id.get_string_repr()); let payload = payment_types::PaymentsRetrieveRequest { resource_id: payment_types::PaymentIdType::PaymentIntentId(payment_id), merchant_id: json_payload.merchant_id.clone(), force_sync: json_payload.force_sync.unwrap_or(false), client_secret: json_payload.client_secret.clone(), expand_attempts: json_payload.expand_attempts, expand_captures: json_payload.expand_captures, all_keys_required: json_payload.all_keys_required, ..Default::default() }; let header_payload = match HeaderPayload::foreign_try_from(req.headers()) { Ok(headers) => headers, Err(err) => { return api::log_and_return_error_response(err); } }; tracing::Span::current().record("flow", flow.to_string()); let api_auth = auth::ApiKeyAuth { is_connected_allowed: false, is_platform_allowed: true, }; 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(report!(err)), }; let locking_action = payload.get_locking_input(flow.clone()); Box::pin(api::server_wrap( flow, state, &req, payload, |state, auth: auth::AuthenticationData, 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, auth.profile_id, payments::PaymentStatus, req, auth_flow, payments::CallConnectorAction::Trigger, None, header_payload.clone(), ) }, auth::auth_type( &*auth_type, &auth::JWTAuth { permission: Permission::ProfilePaymentRead, }, req.headers(), ), locking_action, )) .await }
crates/router/src/routes/payments.rs
router
impl_block
531
rust
null
Responder
null
impl Responder
null
null
null
null
null
null
null
null
impl api::PaymentAuthorize for Mifinity {}
crates/hyperswitch_connectors/src/connectors/mifinity.rs
hyperswitch_connectors
impl_block
10
rust
null
Mifinity
api::PaymentAuthorize for
impl api::PaymentAuthorize for for Mifinity
null
null
null
null
null
null
null
null
impl<const T: u8> ConnectorSpecifications for DummyConnector<T> {}
crates/hyperswitch_connectors/src/connectors/dummyconnector.rs
hyperswitch_connectors
impl_block
15
rust
null
DummyConnector
ConnectorSpecifications for
impl ConnectorSpecifications for for DummyConnector
null
null
null
null
null
null
null
null
impl api::PayoutEligibility for Adyen {}
crates/hyperswitch_connectors/src/connectors/adyen.rs
hyperswitch_connectors
impl_block
12
rust
null
Adyen
api::PayoutEligibility for
impl api::PayoutEligibility for for Adyen
null
null
null
null
null
null
null
null
pub(crate) struct OutgoingWebhookTrackingData { pub(crate) merchant_id: common_utils::id_type::MerchantId, pub(crate) business_profile_id: common_utils::id_type::ProfileId, pub(crate) event_type: enums::EventType, pub(crate) event_class: enums::EventClass, pub(crate) primary_object_id: String, pub(crate) primary_object_type: enums::EventObjectType, pub(crate) initial_attempt_id: Option<String>, }
crates/router/src/core/webhooks/types.rs
router
struct_definition
102
rust
OutgoingWebhookTrackingData
null
null
null
null
null
null
null
null
null
null
null
pub async fn get_merchant_auth_event_sankey( state: web::Data<AppState>, req: actix_web::HttpRequest, json_payload: web::Json<TimeRange>, ) -> impl Responder { let flow = AnalyticsFlow::GetSankey; let payload = json_payload.into_inner(); Box::pin(api::server_wrap( flow, state, &req, payload, |state, auth: AuthenticationData, req, _| async move { let org_id = auth.merchant_account.get_org_id(); let merchant_id = auth.merchant_account.get_id(); let auth: AuthInfo = AuthInfo::MerchantLevel { org_id: org_id.clone(), merchant_ids: vec![merchant_id.clone()], }; analytics::auth_events::get_sankey(&state.pool, &auth, req) .await .map(ApplicationResponse::Json) }, &auth::JWTAuth { permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) .await }
crates/router/src/analytics.rs
router
function_signature
232
rust
null
null
null
null
get_merchant_auth_event_sankey
null
null
null
null
null
null
null
pub struct VoidData { #[serde(rename = "id")] pub void_id: String, pub reason: Option<String>, pub inserted_at: String, pub status: FacilitapayPaymentStatus, pub transaction_kind: String, pub bank_transaction: VoidBankTransaction, }
crates/hyperswitch_connectors/src/connectors/facilitapay/responses.rs
hyperswitch_connectors
struct_definition
62
rust
VoidData
null
null
null
null
null
null
null
null
null
null
null
pub struct PaypalOrderErrorResponse { pub name: Option<String>, pub message: String, pub debug_id: Option<String>, pub details: Option<Vec<OrderErrorDetails>>, }
crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
hyperswitch_connectors
struct_definition
38
rust
PaypalOrderErrorResponse
null
null
null
null
null
null
null
null
null
null
null
pub fn server(state: AppState) -> Scope { let mut route = web::scope("/account").app_data(web::Data::new(state)); #[cfg(feature = "olap")] { use super::admin::*; route = route .service( web::resource("/connectors/verify") .route(web::post().to(super::verify_connector::payment_connector_verify)), ) .service( web::resource("/{merchant_id}/connectors") .route(web::post().to(connector_create)) .route(web::get().to(connector_list)), ) .service( web::resource("/{merchant_id}/connectors/{merchant_connector_id}") .route(web::get().to(connector_retrieve)) .route(web::post().to(connector_update)) .route(web::delete().to(connector_delete)), ); } #[cfg(feature = "oltp")] { route = route.service( web::resource("/payment_methods") .route(web::get().to(payment_methods::list_payment_method_api)), ); } route }
crates/router/src/routes/app.rs
router
function_signature
236
rust
null
null
null
null
server
null
null
null
null
null
null
null
pub async fn find_link_by_payment_link_id( conn: &PgPooledConn, payment_link_id: &str, ) -> StorageResult<Self> { generics::generic_find_one::<<Self as HasTable>::Table, _, _>( conn, dsl::payment_link_id.eq(payment_link_id.to_owned()), ) .await }
crates/diesel_models/src/query/payment_link.rs
diesel_models
function_signature
78
rust
null
null
null
null
find_link_by_payment_link_id
null
null
null
null
null
null
null
impl api::Refund for Inespay {}
crates/hyperswitch_connectors/src/connectors/inespay.rs
hyperswitch_connectors
impl_block
10
rust
null
Inespay
api::Refund for
impl api::Refund for for Inespay
null
null
null
null
null
null
null
null
impl CallbackMapperData { /// Retrieves the details of the network token webhook type from callback mapper data. pub fn get_network_token_webhook_details( &self, ) -> (id_type::MerchantId, String, id_type::CustomerId) { match self { Self::NetworkTokenWebhook { merchant_id, payment_method_id, customer_id, } => ( merchant_id.clone(), payment_method_id.clone(), customer_id.clone(), ), } } }
crates/common_types/src/callback_mapper.rs
common_types
impl_block
105
rust
null
CallbackMapperData
null
impl CallbackMapperData
null
null
null
null
null
null
null
null
impl Payment for Netcetera {}
crates/hyperswitch_connectors/src/connectors/netcetera.rs
hyperswitch_connectors
impl_block
8
rust
null
Netcetera
Payment for
impl Payment for for Netcetera
null
null
null
null
null
null
null
null
pub async fn load_recovery_attempt_from_api( data: api_models::payments::RecoveryPaymentsCreate, state: &SessionState, req_state: &ReqState, merchant_context: &domain::MerchantContext, profile: &domain::Profile, payment_intent: revenue_recovery::RecoveryPaymentIntent, payment_merchant_connector_account: domain::MerchantConnectorAccount, ) -> CustomResult< ( revenue_recovery::RecoveryPaymentAttempt, revenue_recovery::RecoveryPaymentIntent, ), errors::RevenueRecoveryError, > { let recovery_attempt = Self(revenue_recovery::RevenueRecoveryAttemptData::foreign_from( &data, )); recovery_attempt .get_payment_attempt(state, req_state, merchant_context, profile, &payment_intent) .await .transpose() .async_unwrap_or_else(|| async { recovery_attempt .record_payment_attempt( state, req_state, merchant_context, profile, &payment_intent, &data.billing_merchant_connector_id, Some(payment_merchant_connector_account), ) .await }) .await }
crates/router/src/core/webhooks/recovery_incoming.rs
router
function_signature
246
rust
null
null
null
null
load_recovery_attempt_from_api
null
null
null
null
null
null
null
pub fn new() -> &'static Self { &Self { amount_converter: &MinorUnitForConnector, } }
crates/hyperswitch_connectors/src/connectors/deutschebank.rs
hyperswitch_connectors
function_signature
27
rust
null
null
null
null
new
null
null
null
null
null
null
null
pub async fn update_by_merchant_id_authorization_id( conn: &PgPooledConn, merchant_id: common_utils::id_type::MerchantId, authorization_id: String, authorization_update: AuthorizationUpdate, ) -> StorageResult<Self> { match generics::generic_update_with_unique_predicate_get_result::< <Self as HasTable>::Table, _, _, _, >( conn, dsl::merchant_id .eq(merchant_id.to_owned()) .and(dsl::authorization_id.eq(authorization_id.to_owned())), AuthorizationUpdateInternal::from(authorization_update), ) .await { Err(error) => match error.current_context() { errors::DatabaseError::NotFound => Err(error.attach_printable( "Authorization with the given Authorization ID does not exist", )), errors::DatabaseError::NoFieldsToUpdate => { generics::generic_find_one::<<Self as HasTable>::Table, _, _>( conn, dsl::merchant_id .eq(merchant_id.to_owned()) .and(dsl::authorization_id.eq(authorization_id.to_owned())), ) .await } _ => Err(error), }, result => result, } }
crates/diesel_models/src/query/authorization.rs
diesel_models
function_signature
268
rust
null
null
null
null
update_by_merchant_id_authorization_id
null
null
null
null
null
null
null
pub trait RefundMetricAccumulator { type MetricOutput; fn add_metrics_bucket(&mut self, metrics: &RefundMetricRow); fn collect(self) -> Self::MetricOutput; }
crates/analytics/src/refunds/accumulator.rs
analytics
trait_definition
43
rust
null
null
RefundMetricAccumulator
null
null
null
null
null
null
null
null
null
pub struct GetDecisionEngineConfigRequest { pub merchant_id: String, pub algorithm: DecisionEngineDynamicAlgorithmType, }
crates/api_models/src/open_router.rs
api_models
struct_definition
26
rust
GetDecisionEngineConfigRequest
null
null
null
null
null
null
null
null
null
null
null
pub struct CommonMandateReference { pub payments: Option<PaymentsMandateReference>, pub payouts: Option<PayoutsMandateReference>, }
crates/api_models/src/payment_methods.rs
api_models
struct_definition
34
rust
CommonMandateReference
null
null
null
null
null
null
null
null
null
null
null
pub struct ForteRouterData<T> { pub amount: FloatMajorUnit, pub router_data: T, }
crates/hyperswitch_connectors/src/connectors/forte/transformers.rs
hyperswitch_connectors
struct_definition
25
rust
ForteRouterData
null
null
null
null
null
null
null
null
null
null
null
impl api::RefundExecute for Breadpay {}
crates/hyperswitch_connectors/src/connectors/breadpay.rs
hyperswitch_connectors
impl_block
10
rust
null
Breadpay
api::RefundExecute for
impl api::RefundExecute for for Breadpay
null
null
null
null
null
null
null
null
pub struct OpenRouterDecideGatewayRequest { pub payment_info: PaymentInfo, #[schema(value_type = String)] pub merchant_id: id_type::ProfileId, pub eligible_gateway_list: Option<Vec<String>>, pub ranking_algorithm: Option<RankingAlgorithm>, pub elimination_enabled: Option<bool>, }
crates/api_models/src/open_router.rs
api_models
struct_definition
66
rust
OpenRouterDecideGatewayRequest
null
null
null
null
null
null
null
null
null
null
null
pub struct PaymentCaptureRequest { payme_sale_id: String, sale_price: MinorUnit, }
crates/hyperswitch_connectors/src/connectors/payme/transformers.rs
hyperswitch_connectors
struct_definition
22
rust
PaymentCaptureRequest
null
null
null
null
null
null
null
null
null
null
null
assert_eq!( algorithm .decode_message(&secret, encoded_message.into()) .expect("Decode Failed"), message ); } #[test] fn test_gcm_aes_256_decode_message() { // Inputs taken from AES GCM test vectors provided by NIST // https://github.com/briansmith/ring/blob/95948b3977013aed16db92ae32e6b8384496a740/tests/aead_aes_256_gcm_tests.txt#L447-L452 let right_secret = hex::decode("feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308") .expect("Secret decoding"); let wrong_secret = hex::decode("feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308309") .expect("Secret decoding"); let message = // The three parts of the message are the nonce, ciphertext and tag from the test vector hex::decode( "cafebabefacedbaddecaf888\ 522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad\ b094dac5d93471bdec1a502270e3cc6c" ).expect("Message decoding"); let algorithm = super::GcmAes256; let decoded = algorithm .decode_message(&right_secret, message.clone().into()) .expect("Decoded message"); assert_eq!( decoded, hex::decode("d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255") .expect("Decoded plaintext message") ); let err_decoded = algorithm.decode_message(&wrong_secret, message.into()); assert!(err_decoded.is_err()); } #[test] fn test_md5_digest() { let message = "abcdefghijklmnopqrstuvwxyz".as_bytes(); assert_eq!( format!( "{}", hex::encode(super::Md5.generate_digest(message).expect("Digest")) ), "c3fcd3d76192e4007dfb496cca67e13b" ); } #[test] fn test_md5_verify_signature() { let right_signature = hex::decode("c3fcd3d76192e4007dfb496cca67e13b").expect("signature decoding"); let wrong_signature = hex::decode("d5550730377011948f12cc28889bee590d2a5434d6f54b87562f2dbc2657823f") .expect("Wrong signature decoding"); let secret = "".as_bytes(); let data = "abcdefghijklmnopqrstuvwxyz".as_bytes(); let right_verified = super::Md5 .verify_signature(secret, &right_signature, data) .expect("Right signature verification result"); assert!(right_verified); let wrong_verified = super::Md5 .verify_signature(secret, &wrong_signature, data) .expect("Wrong signature verification result"); assert!(!wrong_verified); } use ring::signature::{UnparsedPublicKey, RSA_PSS_2048_8192_SHA256}; #[test] fn test_rsa_pss_sha256_verify_signature() { let signer = crate::crypto::RsaPssSha256; let message = b"abcdefghijklmnopqrstuvwxyz"; let private_key_pem_bytes = std::fs::read("../../private_key.pem").expect("Failed to read private key"); let parsed_pem = pem::parse(&private_key_pem_bytes).expect("Failed to parse PEM"); let private_key_der = parsed_pem.contents(); let signature = signer .sign_message(&private_key_pem_bytes, message) .expect("Signing failed"); let key_pair = crate::crypto::RsaKeyPair::from_pkcs8(private_key_der) .expect("Failed to parse DER key"); let public_key_der = key_pair.public().as_ref().to_vec(); let public_key = UnparsedPublicKey::new(&RSA_PSS_2048_8192_SHA256, &public_key_der); assert!( public_key.verify(message, &signature).is_ok(), "Right signature should verify" ); let mut wrong_signature = signature.clone(); if let Some(byte) = wrong_signature.first_mut() { *byte ^= 0xFF; } assert!( public_key.verify(message, &wrong_signature).is_err(), "Wrong signature should not verify" ); } #[test] fn test_rsasha256_verify_signature() { use base64::Engine; use rand::rngs::OsRng; use rsa::{ pkcs8::EncodePublicKey, signature::{RandomizedSigner, SignatureEncoding}, }; use crate::consts::BASE64_ENGINE; let mut rng = OsRng; let bits = 2048; let private_key = rsa::RsaPrivateKey::new(&mut rng, bits).expect("keygen failed"); let signing_key = rsa::pkcs1v15::SigningKey::<rsa::sha2::Sha256>::new(private_key.clone()); let message = "{ This is a test message :) }".as_bytes(); let signature = signing_key.sign_with_rng(&mut rng, message); let encoded_signature = BASE64_ENGINE.encode(signature.to_bytes()); let rsa_public_key = private_key.to_public_key(); let pem_format_public_key = rsa_public_key .to_public_key_pem(rsa::pkcs8::LineEnding::LF) .expect("transformation failed"); let encoded_pub_key = BASE64_ENGINE.encode(&pem_format_public_key[..]); let right_verified = super::RsaSha256 .verify_signature( encoded_pub_key.as_bytes(), encoded_signature.as_bytes(), message, ) .expect("Right signature verification result"); assert!(right_verified); } }
crates/common_utils/src/crypto.rs#chunk1
common_utils
chunk
1,677
null
null
null
null
null
null
null
null
null
null
null
null
null
pub fn payments_complete_authorize() {}
crates/openapi/src/routes/payments.rs
openapi
function_signature
8
rust
null
null
null
null
payments_complete_authorize
null
null
null
null
null
null
null
pub struct PaymentAttemptBatchNew { pub payment_id: common_utils::id_type::PaymentId, pub merchant_id: common_utils::id_type::MerchantId, pub attempt_id: String, pub status: AttemptStatus, pub amount: MinorUnit, pub currency: Option<Currency>, pub save_to_locker: Option<bool>, pub connector: Option<String>, pub error_message: Option<String>, pub offer_amount: Option<MinorUnit>, pub surcharge_amount: Option<MinorUnit>, pub tax_amount: Option<MinorUnit>, pub payment_method_id: Option<String>, pub payment_method: Option<PaymentMethod>, pub capture_method: Option<CaptureMethod>, #[serde(default, with = "common_utils::custom_serde::iso8601::option")] pub capture_on: Option<PrimitiveDateTime>, pub confirm: bool, pub authentication_type: Option<AuthenticationType>, #[serde(with = "common_utils::custom_serde::iso8601")] pub created_at: PrimitiveDateTime, #[serde(with = "common_utils::custom_serde::iso8601")] pub modified_at: PrimitiveDateTime, #[serde(default, with = "common_utils::custom_serde::iso8601::option")] pub last_synced: Option<PrimitiveDateTime>, pub cancellation_reason: Option<String>, pub amount_to_capture: Option<MinorUnit>, pub mandate_id: Option<String>, pub browser_info: Option<serde_json::Value>, pub payment_token: Option<String>, pub error_code: Option<String>, pub connector_metadata: Option<serde_json::Value>, pub payment_experience: Option<PaymentExperience>, pub payment_method_type: Option<PaymentMethodType>, pub payment_method_data: Option<serde_json::Value>, pub business_sub_label: Option<String>, pub straight_through_algorithm: Option<serde_json::Value>, pub preprocessing_step_id: Option<String>, pub mandate_details: Option<MandateDataType>, pub error_reason: Option<String>, pub connector_response_reference_id: Option<String>, pub connector_transaction_id: Option<ConnectorTransactionId>, pub multiple_capture_count: Option<i16>, pub amount_capturable: MinorUnit, pub updated_by: String, pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>, pub authentication_data: Option<serde_json::Value>, pub encoded_data: Option<String>, pub unified_code: Option<String>, pub unified_message: Option<String>, pub net_amount: Option<MinorUnit>, pub external_three_ds_authentication_attempted: Option<bool>, pub authentication_connector: Option<String>, pub authentication_id: Option<common_utils::id_type::AuthenticationId>, pub mandate_data: Option<MandateDetails>, pub payment_method_billing_address_id: Option<String>, pub fingerprint_id: Option<String>, pub charge_id: Option<String>, pub client_source: Option<String>, pub client_version: Option<String>, pub customer_acceptance: Option<common_utils::pii::SecretSerdeValue>, pub profile_id: common_utils::id_type::ProfileId, pub organization_id: common_utils::id_type::OrganizationId, pub shipping_cost: Option<MinorUnit>, pub order_tax_amount: Option<MinorUnit>, pub processor_transaction_data: Option<String>, pub connector_mandate_detail: Option<ConnectorMandateReferenceId>, pub request_extended_authorization: Option<RequestExtendedAuthorizationBool>, pub extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>, pub capture_before: Option<PrimitiveDateTime>, pub card_discovery: Option<common_enums::CardDiscovery>, pub processor_merchant_id: Option<common_utils::id_type::MerchantId>, pub created_by: Option<String>, pub setup_future_usage_applied: Option<common_enums::FutureUsage>, pub routing_approach: Option<common_enums::RoutingApproach>, pub connector_request_reference_id: Option<String>, pub network_transaction_id: Option<String>, }
crates/diesel_models/src/user/sample_data.rs
diesel_models
struct_definition
868
rust
PaymentAttemptBatchNew
null
null
null
null
null
null
null
null
null
null
null
Web Documentation: Click To Pay | Hyperswitch # Type: Web Doc This feature is currently in Beta. For access, please contact us at [email protected] Click to Pay is a secure and user-friendly digital payment solution designed to simplify the online checkout process. With Click to Pay, consumers can use their saved payment cards without manually entering card details or recalling a password for each purchase. All payment information is securely stored within a single, centralized profile tied to the user via an email/phone, making it easy to manage various payment methods. This solution is built on EMVCo standards and is supported by major global card networks, enabling international interoperability and secure transaction acceptance. By streamlining the payment process, Click to Pay reduces cart abandonment, providing a smooth user experience while strengthening security through tokenization . Payment Journey for Click to pay signed up users What Makes Hyperswitch’s Implementation Unique? Passkeys Support Hyperswitch is among the first certified Mastercard and Visa partners for the passkey-enabled Click to Pay solution. Unlike the older Click to Pay versions, which required OTPs or push provisioning, Hyperswitch enables seamless biometric authentication using passkeys. Unified SDK A single integration with the Hyperswitch SDK supports Visa, Mastercard, Amex, and Discover cards on Click to Pay. Hyperswitch ensures business continuity by intelligently switching between card systems if one network becomes unavailable, all while maintaining a single, blended UI. Easier and Customizable Integration Hyperswitch simplifies integration with low-code options, allowing merchants to blend Click to Pay into their checkout page as part of the card section or offer it as a guest checkout button. Offers UI customization to align with the merchant’s branding for a seamless user experience. Faster Go-live Certified partnerships with Mastercard and Visa enable Hyperswitch to help merchants go live in days rather than months, minimizing merchant effort. Benefits for Merchants Seamless Checkout Eliminates the need for customers to re-enter card details after initial enrollment. Fetches stored card details based on the customer’s email or phone number. Secured Transactions Cards are tokenized and securely stored at the network's end. Authentication is managed via passkeys using public-private key cryptography, making interception nearly impossible. Enhanced Authentication Passkeys enable a quick and secure authentication process using biometrics (e.g., fingerprint, face ID) instead of OTPs or push notifications. Liability Shift Merchants benefit from a chargeback liability shift to the issuer when transactions are authenticated via Click to Pay with Passkeys. By combining the tokenization of payment credentials with seamless biometric authentication, Click to Pay is bringing EMVCo , World Wide Web Consortium and the FIDO Alliance industry standards together to speed and secure checkouts. On the customers' side, many are hesitant to enter their card details on a merchant website due to lack of trust and security concerns. With Click to Pay, these customers need not enter their card details manually, but fetch those from a secured, known EMVCo SRC system. This reduces the cart abandonment rate and increased sales for the merchants who offer Click to Pay. Payment Operations 10 months ago Was this helpful?
https://docs.hyperswitch.io/explore-hyperswitch/merchant-controls/payment-features/click-to-pay
null
web_doc_file
664
doc
null
null
null
null
null
web
null
null
null
https://docs.hyperswitch.io/explore-hyperswitch/merchant-controls/payment-features/click-to-pay
Click To Pay | Hyperswitch
null
pub async fn customers_retrieve( state: web::Data<AppState>, req: HttpRequest, path: web::Path<id_type::GlobalCustomerId>, ) -> HttpResponse { use crate::services::authentication::api_or_client_auth; let flow = Flow::CustomersRetrieve; let id = path.into_inner(); let v2_client_auth = auth::V2ClientAuth( common_utils::types::authentication::ResourceId::Customer(id.clone()), ); let auth = if auth::is_jwt_auth(req.headers()) { &auth::JWTAuth { permission: Permission::MerchantCustomerRead, } } else { api_or_client_auth( &auth::V2ApiKeyAuth { is_connected_allowed: false, is_platform_allowed: false, }, &v2_client_auth, req.headers(), ) }; Box::pin(api::server_wrap( flow, state, &req, id, |state, auth: auth::AuthenticationData, id, _| { let merchant_context = domain::MerchantContext::NormalMerchant(Box::new( domain::Context(auth.merchant_account, auth.key_store), )); retrieve_customer(state, merchant_context, id) }, auth, api_locking::LockAction::NotApplicable, )) .await }
crates/router/src/routes/customers.rs
router
function_signature
282
rust
null
null
null
null
customers_retrieve
null
null
null
null
null
null
null
pub fn get_payment_method(&self) -> Option<common_enums::PaymentMethod> { Some(self.payment_method) }
crates/api_models/src/admin.rs
api_models
function_signature
27
rust
null
null
null
null
get_payment_method
null
null
null
null
null
null
null
impl Gsm { pub fn server(state: AppState) -> Scope { web::scope("/v2/gsm") .app_data(web::Data::new(state)) .service(web::resource("").route(web::post().to(gsm::create_gsm_rule))) .service(web::resource("/get").route(web::post().to(gsm::get_gsm_rule))) .service(web::resource("/update").route(web::post().to(gsm::update_gsm_rule))) .service(web::resource("/delete").route(web::post().to(gsm::delete_gsm_rule))) } }
crates/router/src/routes/app.rs
router
impl_block
129
rust
null
Gsm
null
impl Gsm
null
null
null
null
null
null
null
null
File: crates/router/tests/connectors/barclaycard.rs use masking::Secret; use router::types::{self, api, domain, storage::enums}; use test_utils::connector_auth; use crate::utils::{self, ConnectorActions}; #[derive(Clone, Copy)] struct BarclaycardTest; impl ConnectorActions for BarclaycardTest {} impl utils::Connector for BarclaycardTest { fn get_data(&self) -> api::ConnectorData { use router::connector::Barclaycard; utils::construct_connector_data_old( Box::new(Barclaycard::new()), types::Connector::DummyConnector1, api::GetToken::Connector, None, ) } fn get_auth_token(&self) -> types::ConnectorAuthType { utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .barclaycard .expect("Missing connector authentication configuration") .into(), ) } fn get_name(&self) -> String { "barclaycard".to_string() } } static CONNECTOR: BarclaycardTest = BarclaycardTest {}; fn get_default_payment_info() -> Option<utils::PaymentInfo> { None } fn payment_method_details() -> Option<types::PaymentsAuthorizeData> { None } // Cards Positive Tests // Creates a payment using the manual capture flow (Non 3DS). #[actix_web::test] async fn should_only_authorize_payment() { let response = CONNECTOR .authorize_payment(payment_method_details(), get_default_payment_info()) .await .expect("Authorize payment response"); assert_eq!(response.status, enums::AttemptStatus::Authorized); } // Captures a payment using the manual capture flow (Non 3DS). #[actix_web::test] async fn should_capture_authorized_payment() { let response = CONNECTOR .authorize_and_capture_payment(payment_method_details(), None, get_default_payment_info()) .await .expect("Capture payment response"); assert_eq!(response.status, enums::AttemptStatus::Charged); } // Partially captures a payment using the manual capture flow (Non 3DS). #[actix_web::test] async fn should_partially_capture_authorized_payment() { let response = CONNECTOR .authorize_and_capture_payment( payment_method_details(), Some(types::PaymentsCaptureData { amount_to_capture: 50, ..utils::PaymentCaptureType::default().0 }), get_default_payment_info(), ) .await .expect("Capture payment response"); assert_eq!(response.status, enums::AttemptStatus::Charged); } // Synchronizes a payment using the manual capture flow (Non 3DS). #[actix_web::test] async fn should_sync_authorized_payment() { let authorize_response = CONNECTOR .authorize_payment(payment_method_details(), get_default_payment_info()) .await .expect("Authorize payment response"); let txn_id = utils::get_connector_transaction_id(authorize_response.response); let response = CONNECTOR .psync_retry_till_status_matches( enums::AttemptStatus::Authorized, Some(types::PaymentsSyncData { connector_transaction_id: types::ResponseId::ConnectorTransactionId( txn_id.unwrap(), ), ..Default::default() }), get_default_payment_info(), ) .await .expect("PSync response"); assert_eq!(response.status, enums::AttemptStatus::Authorized,); } // Voids a payment using the manual capture flow (Non 3DS). #[actix_web::test] async fn should_void_authorized_payment() { let response = CONNECTOR .authorize_and_void_payment( payment_method_details(), Some(types::PaymentsCancelData { connector_transaction_id: String::from(""), cancellation_reason: Some("requested_by_customer".to_string()), ..Default::default() }), get_default_payment_info(), ) .await .expect("Void payment response"); assert_eq!(response.status, enums::AttemptStatus::Voided); } // Refunds a payment using the manual capture flow (Non 3DS). #[actix_web::test] async fn should_refund_manually_captured_payment() { let response = CONNECTOR .capture_payment_and_refund( payment_method_details(), None, None, get_default_payment_info(), ) .await .unwrap(); assert_eq!( response.response.unwrap().refund_status, enums::RefundStatus::Success, ); } // Partially refunds a payment using the manual capture flow (Non 3DS). #[actix_web::test] async fn should_partially_refund_manually_captured_payment() { let response = CONNECTOR .capture_payment_and_refund( payment_method_details(), None, Some(types::RefundsData { refund_amount: 50, ..utils::PaymentRefundType::default().0 }), get_default_payment_info(), ) .await .unwrap(); assert_eq!( response.response.unwrap().refund_status, enums::RefundStatus::Success, ); } // Synchronizes a refund using the manual capture flow (Non 3DS). #[actix_web::test] async fn should_sync_manually_captured_refund() { let refund_response = CONNECTOR .capture_payment_and_refund( payment_method_details(), None, None, get_default_payment_info(), ) .await .unwrap(); let response = CONNECTOR .rsync_retry_till_status_matches( enums::RefundStatus::Success, refund_response.response.unwrap().connector_refund_id, None, get_default_payment_info(), ) .await .unwrap(); assert_eq!( response.response.unwrap().refund_status, enums::RefundStatus::Success, ); } // Creates a payment using the automatic capture flow (Non 3DS). #[actix_web::test] async fn should_make_payment() { let authorize_response = CONNECTOR .make_payment(payment_method_details(), get_default_payment_info()) .await .unwrap(); assert_eq!(authorize_response.status, enums::AttemptStatus::Charged); } // Synchronizes a payment using the automatic capture flow (Non 3DS). #[actix_web::test] async fn should_sync_auto_captured_payment() { let authorize_response = CONNECTOR .make_payment(payment_method_details(), get_default_payment_info()) .await .unwrap(); assert_eq!(authorize_response.status, enums::AttemptStatus::Charged); let txn_id = utils::get_connector_transaction_id(authorize_response.response); assert_ne!(txn_id, None, "Empty connector transaction id"); let response = CONNECTOR .psync_retry_till_status_matches( enums::AttemptStatus::Charged, Some(types::PaymentsSyncData { connector_transaction_id: types::ResponseId::ConnectorTransactionId( txn_id.unwrap(), ), capture_method: Some(enums::CaptureMethod::Automatic), ..Default::default() }), get_default_payment_info(), ) .await .unwrap(); assert_eq!(response.status, enums::AttemptStatus::Charged,); } // Refunds a payment using the automatic capture flow (Non 3DS). #[actix_web::test] async fn should_refund_auto_captured_payment() { let response = CONNECTOR .make_payment_and_refund(payment_method_details(), None, get_default_payment_info()) .await .unwrap(); assert_eq!( response.response.unwrap().refund_status, enums::RefundStatus::Success, ); } // Partially refunds a payment using the automatic capture flow (Non 3DS). #[actix_web::test] async fn should_partially_refund_succeeded_payment() { let refund_response = CONNECTOR .make_payment_and_refund( payment_method_details(), Some(types::RefundsData { refund_amount: 50, ..utils::PaymentRefundType::default().0 }), get_default_payment_info(), ) .await .unwrap(); assert_eq!( refund_response.response.unwrap().refund_status, enums::RefundStatus::Success, ); } // Creates multiple refunds against a payment using the automatic capture flow (Non 3DS). #[actix_web::test] async fn should_refund_succeeded_payment_multiple_times() { CONNECTOR .make_payment_and_multiple_refund( payment_method_details(), Some(types::RefundsData { refund_amount: 50, ..utils::PaymentRefundType::default().0 }), get_default_payment_info(), ) .await; } // Synchronizes a refund using the automatic capture flow (Non 3DS). #[actix_web::test] async fn should_sync_refund() { let refund_response = CONNECTOR .make_payment_and_refund(payment_method_details(), None, get_default_payment_info()) .await .unwrap(); let response = CONNECTOR .rsync_retry_till_status_matches( enums::RefundStatus::Success, refund_response.response.unwrap().connector_refund_id, None, get_default_payment_info(), ) .await .unwrap(); assert_eq!( response.response.unwrap().refund_status, enums::RefundStatus::Success, ); } // Cards Negative scenarios // Creates a payment with incorrect CVC. #[actix_web::test] async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { payment_method_data: domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), ..utils::PaymentAuthorizeType::default().0 }), get_default_payment_info(), ) .await .unwrap(); assert_eq!( response.response.unwrap_err().message, "Your card's security code is invalid.".to_string(), ); } // Creates a payment with incorrect expiry month. #[actix_web::test] async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { payment_method_data: domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), ..utils::PaymentAuthorizeType::default().0 }), get_default_payment_info(), ) .await .unwrap(); assert_eq!( response.response.unwrap_err().message, "Your card's expiration month is invalid.".to_string(), ); } // Creates a payment with incorrect expiry year. #[actix_web::test] async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { payment_method_data: domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), ..utils::PaymentAuthorizeType::default().0 }), get_default_payment_info(), ) .await .unwrap(); assert_eq!( response.response.unwrap_err().message, "Your card's expiration year is invalid.".to_string(), ); } // Voids a payment using automatic capture flow (Non 3DS). #[actix_web::test] async fn should_fail_void_payment_for_auto_capture() { let authorize_response = CONNECTOR .make_payment(payment_method_details(), get_default_payment_info()) .await .unwrap(); assert_eq!(authorize_response.status, enums::AttemptStatus::Charged); let txn_id = utils::get_connector_transaction_id(authorize_response.response); assert_ne!(txn_id, None, "Empty connector transaction id"); let void_response = CONNECTOR .void_payment(txn_id.unwrap(), None, get_default_payment_info()) .await .unwrap(); assert_eq!( void_response.response.unwrap_err().message, "You cannot cancel this PaymentIntent because it has a status of succeeded." ); } // Captures a payment using invalid connector payment id. #[actix_web::test] async fn should_fail_capture_for_invalid_payment() { let capture_response = CONNECTOR .capture_payment("123456789".to_string(), None, get_default_payment_info()) .await .unwrap(); assert_eq!( capture_response.response.unwrap_err().message, String::from("No such payment_intent: '123456789'") ); } // Refunds a payment with refund amount higher than payment amount. #[actix_web::test] async fn should_fail_for_refund_amount_higher_than_payment_amount() { let response = CONNECTOR .make_payment_and_refund( payment_method_details(), Some(types::RefundsData { refund_amount: 150, ..utils::PaymentRefundType::default().0 }), get_default_payment_info(), ) .await .unwrap(); assert_eq!( response.response.unwrap_err().message, "Refund amount (₹1.50) is greater than charge amount (₹1.00)", ); } // Connector dependent test cases goes here // [#478]: add unit tests for non 3DS, wallets & webhooks in connector tests
crates/router/tests/connectors/barclaycard.rs
router
full_file
2,939
null
null
null
null
null
null
null
null
null
null
null
null
null
pub async fn merchant_account_update() {}
crates/openapi/src/routes/merchant_account.rs
openapi
function_signature
8
rust
null
null
null
null
merchant_account_update
null
null
null
null
null
null
null
pub async fn create_org_merchant_for_user( state: SessionState, req: user_api::UserOrgMerchantCreateRequest, ) -> UserResponse<()> { let db_organization = ForeignFrom::foreign_from(req.clone()); let org: diesel_models::organization::Organization = state .accounts_store .insert_organization(db_organization) .await .change_context(UserErrors::InternalServerError)?; let default_product_type = consts::user::DEFAULT_PRODUCT_TYPE; let merchant_account_create_request = utils::user::create_merchant_account_request_for_org( req, org.clone(), default_product_type, )?; admin::create_merchant_account( state.clone(), merchant_account_create_request, Some(auth::AuthenticationDataWithOrg { organization_id: org.get_organization_id(), }), ) .await .change_context(UserErrors::InternalServerError) .attach_printable("Error while creating a merchant")?; Ok(ApplicationResponse::StatusOk) }
crates/router/src/core/user.rs
router
function_signature
208
rust
null
null
null
null
create_org_merchant_for_user
null
null
null
null
null
null
null
pub struct DeutschebankMandateMetadata { account_holder: Secret<String>, iban: Secret<String>, reference: Secret<String>, signed_on: String, }
crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs
hyperswitch_connectors
struct_definition
36
rust
DeutschebankMandateMetadata
null
null
null
null
null
null
null
null
null
null
null
impl IncomingWebhook for Placetopay { fn get_webhook_object_reference_id( &self, _request: &IncomingWebhookRequestDetails<'_>, ) -> CustomResult<ObjectReferenceId, errors::ConnectorError> { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &IncomingWebhookRequestDetails<'_>, ) -> CustomResult<IncomingWebhookEvent, errors::ConnectorError> { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &IncomingWebhookRequestDetails<'_>, ) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } }
crates/hyperswitch_connectors/src/connectors/placetopay.rs
hyperswitch_connectors
impl_block
187
rust
null
Placetopay
IncomingWebhook for
impl IncomingWebhook for for Placetopay
null
null
null
null
null
null
null
null
impl api::Payment for Dwolla {}
crates/hyperswitch_connectors/src/connectors/dwolla.rs
hyperswitch_connectors
impl_block
8
rust
null
Dwolla
api::Payment for
impl api::Payment for for Dwolla
null
null
null
null
null
null
null
null
pub async fn refund_list( state: SessionState, merchant_context: domain::MerchantContext, profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>, req: api_models::refunds::RefundListRequest, ) -> RouterResponse<api_models::refunds::RefundListResponse> { let db = state.store; let limit = validator::validate_refund_list(req.limit)?; let offset = req.offset.unwrap_or_default(); let refund_list = db .filter_refund_by_constraints( merchant_context.get_merchant_account().get_id(), &(req.clone(), profile_id_list.clone()).try_into()?, merchant_context.get_merchant_account().storage_scheme, limit, offset, ) .await .to_not_found_response(errors::ApiErrorResponse::RefundNotFound)?; let data: Vec<refunds::RefundResponse> = refund_list .into_iter() .map(ForeignInto::foreign_into) .collect(); let total_count = db .get_total_count_of_refunds( merchant_context.get_merchant_account().get_id(), &(req, profile_id_list).try_into()?, merchant_context.get_merchant_account().storage_scheme, ) .await .to_not_found_response(errors::ApiErrorResponse::InternalServerError)?; Ok(services::ApplicationResponse::Json( api_models::refunds::RefundListResponse { count: data.len(), total_count, data, }, )) }
crates/router/src/core/refunds.rs
router
function_signature
323
rust
null
null
null
null
refund_list
null
null
null
null
null
null
null
/// Middleware for Adding Accept-Language header based on query params pub struct AddAcceptLanguageHeader;
crates/router/src/middleware.rs
router
struct_definition
19
rust
AddAcceptLanguageHeader
null
null
null
null
null
null
null
null
null
null
null
pub struct OrderInformation { amount_details: Amount, }
crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
hyperswitch_connectors
struct_definition
12
rust
OrderInformation
null
null
null
null
null
null
null
null
null
null
null
pub async fn find_by_merchant_id_authentication_id( conn: &PgPooledConn, merchant_id: &common_utils::id_type::MerchantId, authentication_id: &common_utils::id_type::AuthenticationId, ) -> StorageResult<Self> { generics::generic_find_one::<<Self as HasTable>::Table, _, _>( conn, dsl::merchant_id .eq(merchant_id.to_owned()) .and(dsl::authentication_id.eq(authentication_id.to_owned())), ) .await }
crates/diesel_models/src/query/authentication.rs
diesel_models
function_signature
116
rust
null
null
null
null
find_by_merchant_id_authentication_id
null
null
null
null
null
null
null
pub struct Theme { pub theme_id: String, pub tenant_id: id_type::TenantId, pub org_id: Option<id_type::OrganizationId>, pub merchant_id: Option<id_type::MerchantId>, pub profile_id: Option<id_type::ProfileId>, pub created_at: PrimitiveDateTime, pub last_modified_at: PrimitiveDateTime, pub entity_type: EntityType, pub theme_name: String, pub email_primary_color: String, pub email_foreground_color: String, pub email_background_color: String, pub email_entity_name: String, pub email_entity_logo_url: String, }
crates/diesel_models/src/user/theme.rs
diesel_models
struct_definition
135
rust
Theme
null
null
null
null
null
null
null
null
null
null
null
impl TypedSql { pub fn to_field_value_pairs( &self, request_id: String, global_id: String, ) -> crate::StorageResult<Vec<(&str, String)>> { let pushed_at = common_utils::date_time::now_unix_timestamp(); Ok(vec![ ( "typed_sql", serde_json::to_string(self) .change_context(errors::DatabaseError::QueryGenerationFailed)?, ), ("global_id", global_id), ("request_id", request_id), ("pushed_at", pushed_at.to_string()), ]) } }
crates/diesel_models/src/kv.rs
diesel_models
impl_block
125
rust
null
TypedSql
null
impl TypedSql
null
null
null
null
null
null
null
null
pub struct AirwallexCompleteRequest { request_id: String, three_ds: AirwallexThreeDsData, #[serde(rename = "type")] three_ds_type: AirwallexThreeDsType, }
crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs
hyperswitch_connectors
struct_definition
46
rust
AirwallexCompleteRequest
null
null
null
null
null
null
null
null
null
null
null
pub struct GocardlessRefundRequest { refunds: GocardlessRefund, }
crates/hyperswitch_connectors/src/connectors/gocardless/transformers.rs
hyperswitch_connectors
struct_definition
19
rust
GocardlessRefundRequest
null
null
null
null
null
null
null
null
null
null
null
pub struct Retrieve;
crates/hyperswitch_domain_models/src/router_flow_types/files.rs
hyperswitch_domain_models
struct_definition
4
rust
Retrieve
null
null
null
null
null
null
null
null
null
null
null
impl ApiKeyId { /// Generate Api Key Id from prefix pub fn generate_key_id(prefix: &'static str) -> Self { Self(crate::generate_ref_id_with_default_length(prefix)) } }
crates/common_utils/src/id_type/api_key.rs
common_utils
impl_block
43
rust
null
ApiKeyId
null
impl ApiKeyId
null
null
null
null
null
null
null
null
pub async fn call_locker_api<T>( state: &routes::SessionState, request: Request, flow_name: &str, locker_choice: Option<api_enums::LockerChoice>, ) -> errors::CustomResult<T, errors::VaultError> where T: serde::de::DeserializeOwned, { let locker = &state.conf.locker; let jwekey = state.conf.jwekey.get_inner(); let response_type_name = type_name!(T); let response = services::call_connector_api(state, request, flow_name) .await .change_context(errors::VaultError::ApiError)?; let is_locker_call_succeeded = response.is_ok(); let jwe_body = response .unwrap_or_else(|err| err) .response .parse_struct::<services::JweBody>("JweBody") .change_context(errors::VaultError::ResponseDeserializationFailed) .attach_printable("Failed while parsing locker response into JweBody")?; let decrypted_payload = payment_methods::get_decrypted_response_payload( jwekey, jwe_body, locker_choice, locker.decryption_scheme.clone(), ) .await .change_context(errors::VaultError::ResponseDeserializationFailed) .attach_printable("Failed while decrypting locker payload response")?; // Irrespective of locker's response status, payload is JWE + JWS decrypted. But based on locker's status, // if Ok, deserialize the decrypted payload into given type T // if Err, raise an error including locker error message too if is_locker_call_succeeded { let stored_card_resp: Result<T, error_stack::Report<errors::VaultError>> = decrypted_payload .parse_struct(response_type_name) .change_context(errors::VaultError::ResponseDeserializationFailed) .attach_printable_lazy(|| { format!("Failed while parsing locker response into {response_type_name}") }); stored_card_resp } else { Err::<T, error_stack::Report<errors::VaultError>>((errors::VaultError::ApiError).into()) .attach_printable_lazy(|| format!("Locker error response: {decrypted_payload:?}")) } }
crates/router/src/core/payment_methods/cards.rs
router
function_signature
479
rust
null
null
null
null
call_locker_api
null
null
null
null
null
null
null
pub struct TokenizationNew { pub id: id_type::GlobalTokenId, pub merchant_id: id_type::MerchantId, pub customer_id: id_type::GlobalCustomerId, pub locker_id: String, pub created_at: PrimitiveDateTime, pub updated_at: PrimitiveDateTime, pub version: common_enums::enums::ApiVersion, pub flag: common_enums::enums::TokenizationFlag, }
crates/diesel_models/src/tokenization.rs
diesel_models
struct_definition
90
rust
TokenizationNew
null
null
null
null
null
null
null
null
null
null
null
File: crates/analytics/src/auth_events/metrics.rs Public structs: 1 use std::collections::HashSet; use api_models::analytics::{ auth_events::{ AuthEventDimensions, AuthEventFilters, AuthEventMetrics, AuthEventMetricsBucketIdentifier, }, Granularity, TimeRange, }; use diesel_models::enums as storage_enums; use time::PrimitiveDateTime; use crate::{ query::{Aggregate, GroupByClause, ToSql, Window}, types::{AnalyticsCollection, AnalyticsDataSource, DBEnumWrapper, LoadRow, MetricsResult}, AuthInfo, }; mod authentication_attempt_count; mod authentication_count; mod authentication_error_message; mod authentication_exemption_approved_count; mod authentication_exemption_requested_count; mod authentication_funnel; mod authentication_success_count; mod challenge_attempt_count; mod challenge_flow_count; mod challenge_success_count; mod frictionless_flow_count; mod frictionless_success_count; use authentication_attempt_count::AuthenticationAttemptCount; use authentication_count::AuthenticationCount; use authentication_error_message::AuthenticationErrorMessage; use authentication_exemption_approved_count::AuthenticationExemptionApprovedCount; use authentication_exemption_requested_count::AuthenticationExemptionRequestedCount; use authentication_funnel::AuthenticationFunnel; use authentication_success_count::AuthenticationSuccessCount; use challenge_attempt_count::ChallengeAttemptCount; use challenge_flow_count::ChallengeFlowCount; use challenge_success_count::ChallengeSuccessCount; use frictionless_flow_count::FrictionlessFlowCount; use frictionless_success_count::FrictionlessSuccessCount; #[derive(Debug, PartialEq, Eq, serde::Deserialize, Hash)] pub struct AuthEventMetricRow { pub count: Option<i64>, pub authentication_status: Option<DBEnumWrapper<storage_enums::AuthenticationStatus>>, pub trans_status: Option<DBEnumWrapper<storage_enums::TransactionStatus>>, pub authentication_type: Option<DBEnumWrapper<storage_enums::DecoupledAuthenticationType>>, pub error_message: Option<String>, pub authentication_connector: Option<DBEnumWrapper<storage_enums::AuthenticationConnectors>>, pub message_version: Option<String>, pub acs_reference_number: Option<String>, pub platform: Option<String>, pub mcc: Option<String>, pub currency: Option<DBEnumWrapper<storage_enums::Currency>>, pub merchant_country: Option<String>, pub billing_country: Option<String>, pub shipping_country: Option<String>, pub issuer_country: Option<String>, pub earliest_supported_version: Option<String>, pub latest_supported_version: Option<String>, pub whitelist_decision: Option<bool>, pub device_manufacturer: Option<String>, pub device_type: Option<String>, pub device_brand: Option<String>, pub device_os: Option<String>, pub device_display: Option<String>, pub browser_name: Option<String>, pub browser_version: Option<String>, pub issuer_id: Option<String>, pub scheme_name: Option<String>, pub exemption_requested: Option<bool>, pub exemption_accepted: Option<bool>, #[serde(with = "common_utils::custom_serde::iso8601::option")] pub start_bucket: Option<PrimitiveDateTime>, #[serde(with = "common_utils::custom_serde::iso8601::option")] pub end_bucket: Option<PrimitiveDateTime>, } pub trait AuthEventMetricAnalytics: LoadRow<AuthEventMetricRow> {} #[async_trait::async_trait] pub trait AuthEventMetric<T> where T: AnalyticsDataSource + AuthEventMetricAnalytics, { async fn load_metrics( &self, auth: &AuthInfo, dimensions: &[AuthEventDimensions], filters: &AuthEventFilters, granularity: Option<Granularity>, time_range: &TimeRange, pool: &T, ) -> MetricsResult<HashSet<(AuthEventMetricsBucketIdentifier, AuthEventMetricRow)>>; } #[async_trait::async_trait] impl<T> AuthEventMetric<T> for AuthEventMetrics where T: AnalyticsDataSource + AuthEventMetricAnalytics, PrimitiveDateTime: ToSql<T>, AnalyticsCollection: ToSql<T>, Granularity: GroupByClause<T>, Aggregate<&'static str>: ToSql<T>, Window<&'static str>: ToSql<T>, { async fn load_metrics( &self, auth: &AuthInfo, dimensions: &[AuthEventDimensions], filters: &AuthEventFilters, granularity: Option<Granularity>, time_range: &TimeRange, pool: &T, ) -> MetricsResult<HashSet<(AuthEventMetricsBucketIdentifier, AuthEventMetricRow)>> { match self { Self::AuthenticationCount => { AuthenticationCount .load_metrics(auth, dimensions, filters, granularity, time_range, pool) .await } Self::AuthenticationAttemptCount => { AuthenticationAttemptCount .load_metrics(auth, dimensions, filters, granularity, time_range, pool) .await } Self::AuthenticationSuccessCount => { AuthenticationSuccessCount .load_metrics(auth, dimensions, filters, granularity, time_range, pool) .await } Self::ChallengeFlowCount => { ChallengeFlowCount .load_metrics(auth, dimensions, filters, granularity, time_range, pool) .await } Self::ChallengeAttemptCount => { ChallengeAttemptCount .load_metrics(auth, dimensions, filters, granularity, time_range, pool) .await } Self::ChallengeSuccessCount => { ChallengeSuccessCount .load_metrics(auth, dimensions, filters, granularity, time_range, pool) .await } Self::FrictionlessFlowCount => { FrictionlessFlowCount .load_metrics(auth, dimensions, filters, granularity, time_range, pool) .await } Self::FrictionlessSuccessCount => { FrictionlessSuccessCount .load_metrics(auth, dimensions, filters, granularity, time_range, pool) .await } Self::AuthenticationErrorMessage => { AuthenticationErrorMessage .load_metrics(auth, dimensions, filters, granularity, time_range, pool) .await } Self::AuthenticationFunnel => { AuthenticationFunnel .load_metrics(auth, dimensions, filters, granularity, time_range, pool) .await } Self::AuthenticationExemptionApprovedCount => { AuthenticationExemptionApprovedCount .load_metrics(auth, dimensions, filters, granularity, time_range, pool) .await } Self::AuthenticationExemptionRequestedCount => { AuthenticationExemptionRequestedCount .load_metrics(auth, dimensions, filters, granularity, time_range, pool) .await } } } }
crates/analytics/src/auth_events/metrics.rs
analytics
full_file
1,406
null
null
null
null
null
null
null
null
null
null
null
null
null
impl Responder { let flow = Flow::RoutingUnlinkConfig; let path = path.into_inner(); Box::pin(oss_api::server_wrap( flow, state, &req, path.clone(), |state, auth: auth::AuthenticationData, path, _| { let merchant_context = domain::MerchantContext::NormalMerchant(Box::new( domain::Context(auth.merchant_account, auth.key_store), )); routing::unlink_routing_config_under_profile( state, merchant_context, path, transaction_type, ) }, #[cfg(not(feature = "release"))] auth::auth_type( &auth::V2ApiKeyAuth { is_connected_allowed: false, is_platform_allowed: false, }, &auth::JWTAuthProfileFromRoute { profile_id: path, required_permission: Permission::MerchantRoutingWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuthProfileFromRoute { profile_id: path, required_permission: Permission::MerchantRoutingWrite, }, api_locking::LockAction::NotApplicable, )) .await }
crates/router/src/routes/routing.rs
router
impl_block
251
rust
null
Responder
null
impl Responder
null
null
null
null
null
null
null
null
impl api::RefundExecute for Hipay {}
crates/hyperswitch_connectors/src/connectors/hipay.rs
hyperswitch_connectors
impl_block
10
rust
null
Hipay
api::RefundExecute for
impl api::RefundExecute for for Hipay
null
null
null
null
null
null
null
null
pub struct ProcessingInformation { action_list: Option<Vec<WellsfargoActionsList>>, action_token_types: Option<Vec<WellsfargoActionsTokenType>>, authorization_options: Option<WellsfargoAuthorizationOptions>, commerce_indicator: String, capture: Option<bool>, capture_options: Option<CaptureOptions>, payment_solution: Option<String>, }
crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs
hyperswitch_connectors
struct_definition
73
rust
ProcessingInformation
null
null
null
null
null
null
null
null
null
null
null
pub struct IncomingWebhookRequestDetails<'a> { /// method pub method: http::Method, /// uri pub uri: http::Uri, /// headers pub headers: &'a actix_web::http::header::HeaderMap, /// body pub body: &'a [u8], /// query_params pub query_params: String, }
crates/hyperswitch_interfaces/src/webhooks.rs
hyperswitch_interfaces
struct_definition
83
rust
IncomingWebhookRequestDetails
null
null
null
null
null
null
null
null
null
null
null
pub struct MonerisRouterData<T> { pub amount: MinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc. pub router_data: T, }
crates/hyperswitch_connectors/src/connectors/moneris/transformers.rs
hyperswitch_connectors
struct_definition
50
rust
MonerisRouterData
null
null
null
null
null
null
null
null
null
null
null
impl api::PaymentSync for Datatrans {}
crates/hyperswitch_connectors/src/connectors/datatrans.rs
hyperswitch_connectors
impl_block
10
rust
null
Datatrans
api::PaymentSync for
impl api::PaymentSync for for Datatrans
null
null
null
null
null
null
null
null
pub struct RouterHealthCheckResponse { pub database: bool, pub redis: bool, #[serde(skip_serializing_if = "Option::is_none")] pub vault: Option<bool>, #[cfg(feature = "olap")] pub analytics: bool, #[cfg(feature = "olap")] pub opensearch: bool, pub outgoing_request: bool, #[cfg(feature = "dynamic_routing")] pub grpc_health_check: HealthCheckMap, #[cfg(feature = "dynamic_routing")] pub decision_engine: bool, pub unified_connector_service: Option<bool>, }
crates/api_models/src/health_check.rs
api_models
struct_definition
124
rust
RouterHealthCheckResponse
null
null
null
null
null
null
null
null
null
null
null
pub struct PollId { pub poll_id: String, }
crates/router/src/types/api/poll.rs
router
struct_definition
13
rust
PollId
null
null
null
null
null
null
null
null
null
null
null
OpenAPI Block Path: components.schemas.PaymentLinkSdkLabelType { "type": "string", "enum": [ "above", "floating", "never" ] }
./hyperswitch/api-reference/v1/openapi_spec_v1.json
null
openapi_block
42
.json
null
null
null
null
null
openapi_spec
components
[ "schemas", "PaymentLinkSdkLabelType" ]
null
null
null
null
OpenAPI Block Path: components.schemas.PhoneDetails { "type": "object", "properties": { "number": { "type": "string", "description": "The contact number", "example": "9123456789", "nullable": true }, "country_code": { "type": "string", "description": "The country code attached to the number", "example": "+1", "nullable": true } } }
./hyperswitch/api-reference/v1/openapi_spec_v1.json
null
openapi_block
113
.json
null
null
null
null
null
openapi_spec
components
[ "schemas", "PhoneDetails" ]
null
null
null
null
pub struct ReportConfig { pub payment_function: String, pub refund_function: String, pub dispute_function: String, pub authentication_function: String, pub region: String, }
crates/analytics/src/lib.rs
analytics
struct_definition
40
rust
ReportConfig
null
null
null
null
null
null
null
null
null
null
null
impl api::PaymentSync for Payme {}
crates/hyperswitch_connectors/src/connectors/payme.rs
hyperswitch_connectors
impl_block
9
rust
null
Payme
api::PaymentSync for
impl api::PaymentSync for for Payme
null
null
null
null
null
null
null
null
File: crates/router/src/core/metrics.rs use router_env::{counter_metric, global_meter}; global_meter!(GLOBAL_METER, "ROUTER_API"); counter_metric!(INCOMING_DISPUTE_WEBHOOK_METRIC, GLOBAL_METER); // No. of incoming dispute webhooks counter_metric!( INCOMING_DISPUTE_WEBHOOK_SIGNATURE_FAILURE_METRIC, GLOBAL_METER ); // No. of incoming dispute webhooks for which signature verification failed counter_metric!( INCOMING_DISPUTE_WEBHOOK_VALIDATION_FAILURE_METRIC, GLOBAL_METER ); // No. of incoming dispute webhooks for which validation failed counter_metric!(INCOMING_DISPUTE_WEBHOOK_NEW_RECORD_METRIC, GLOBAL_METER); // No. of incoming dispute webhooks for which new record is created in our db counter_metric!(INCOMING_DISPUTE_WEBHOOK_UPDATE_RECORD_METRIC, GLOBAL_METER); // No. of incoming dispute webhooks for which we have updated the details to existing record counter_metric!( INCOMING_DISPUTE_WEBHOOK_MERCHANT_NOTIFIED_METRIC, GLOBAL_METER ); // No. of incoming dispute webhooks which are notified to merchant counter_metric!( ACCEPT_DISPUTE_STATUS_VALIDATION_FAILURE_METRIC, GLOBAL_METER ); //No. of status validation failures while accepting a dispute counter_metric!( EVIDENCE_SUBMISSION_DISPUTE_STATUS_VALIDATION_FAILURE_METRIC, GLOBAL_METER ); //No. of status validation failures while submitting evidence for a dispute //No. of status validation failures while attaching evidence for a dispute counter_metric!( ATTACH_EVIDENCE_DISPUTE_STATUS_VALIDATION_FAILURE_METRIC, GLOBAL_METER ); counter_metric!(INCOMING_PAYOUT_WEBHOOK_METRIC, GLOBAL_METER); // No. of incoming payout webhooks counter_metric!( INCOMING_PAYOUT_WEBHOOK_SIGNATURE_FAILURE_METRIC, GLOBAL_METER ); // No. of incoming payout webhooks for which signature verification failed counter_metric!(WEBHOOK_INCOMING_COUNT, GLOBAL_METER); counter_metric!(WEBHOOK_INCOMING_FILTERED_COUNT, GLOBAL_METER); counter_metric!(WEBHOOK_SOURCE_VERIFIED_COUNT, GLOBAL_METER); counter_metric!(WEBHOOK_OUTGOING_COUNT, GLOBAL_METER); counter_metric!(WEBHOOK_OUTGOING_RECEIVED_COUNT, GLOBAL_METER); counter_metric!(WEBHOOK_OUTGOING_NOT_RECEIVED_COUNT, GLOBAL_METER); counter_metric!(WEBHOOK_PAYMENT_NOT_FOUND, GLOBAL_METER); counter_metric!( WEBHOOK_EVENT_TYPE_IDENTIFICATION_FAILURE_COUNT, GLOBAL_METER ); counter_metric!(ROUTING_CREATE_REQUEST_RECEIVED, GLOBAL_METER); counter_metric!(ROUTING_CREATE_SUCCESS_RESPONSE, GLOBAL_METER); counter_metric!(ROUTING_MERCHANT_DICTIONARY_RETRIEVE, GLOBAL_METER); counter_metric!( ROUTING_MERCHANT_DICTIONARY_RETRIEVE_SUCCESS_RESPONSE, GLOBAL_METER ); counter_metric!(ROUTING_LINK_CONFIG, GLOBAL_METER); counter_metric!(ROUTING_LINK_CONFIG_SUCCESS_RESPONSE, GLOBAL_METER); counter_metric!(ROUTING_RETRIEVE_CONFIG, GLOBAL_METER); counter_metric!(ROUTING_RETRIEVE_CONFIG_SUCCESS_RESPONSE, GLOBAL_METER); counter_metric!(ROUTING_RETRIEVE_DEFAULT_CONFIG, GLOBAL_METER); counter_metric!( ROUTING_RETRIEVE_DEFAULT_CONFIG_SUCCESS_RESPONSE, GLOBAL_METER ); counter_metric!(ROUTING_RETRIEVE_LINK_CONFIG, GLOBAL_METER); counter_metric!(ROUTING_RETRIEVE_LINK_CONFIG_SUCCESS_RESPONSE, GLOBAL_METER); counter_metric!(ROUTING_UNLINK_CONFIG, GLOBAL_METER); counter_metric!(ROUTING_UNLINK_CONFIG_SUCCESS_RESPONSE, GLOBAL_METER); counter_metric!(ROUTING_UPDATE_CONFIG, GLOBAL_METER); counter_metric!(ROUTING_UPDATE_CONFIG_SUCCESS_RESPONSE, GLOBAL_METER); counter_metric!(ROUTING_UPDATE_CONFIG_FOR_PROFILE, GLOBAL_METER); counter_metric!( ROUTING_UPDATE_CONFIG_FOR_PROFILE_SUCCESS_RESPONSE, GLOBAL_METER ); counter_metric!(ROUTING_RETRIEVE_CONFIG_FOR_PROFILE, GLOBAL_METER); counter_metric!( ROUTING_RETRIEVE_CONFIG_FOR_PROFILE_SUCCESS_RESPONSE, GLOBAL_METER ); counter_metric!(DYNAMIC_SUCCESS_BASED_ROUTING, GLOBAL_METER); counter_metric!(DYNAMIC_CONTRACT_BASED_ROUTING, GLOBAL_METER); #[cfg(feature = "partial-auth")] counter_metric!(PARTIAL_AUTH_FAILURE, GLOBAL_METER); counter_metric!(API_KEY_REQUEST_INITIATED, GLOBAL_METER); counter_metric!(API_KEY_REQUEST_COMPLETED, GLOBAL_METER);
crates/router/src/core/metrics.rs
router
full_file
936
null
null
null
null
null
null
null
null
null
null
null
null
null
pub struct RefundResponse { id: String, status: RefundStatus, }
crates/hyperswitch_connectors/src/connectors/breadpay/transformers.rs
hyperswitch_connectors
struct_definition
19
rust
RefundResponse
null
null
null
null
null
null
null
null
null
null
null
impl api::PaymentSync for CtpMastercard {}
crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs
hyperswitch_connectors
impl_block
11
rust
null
CtpMastercard
api::PaymentSync for
impl api::PaymentSync for for CtpMastercard
null
null
null
null
null
null
null
null
File: crates/analytics/src/health_check.rs use common_utils::errors::CustomResult; use crate::types::QueryExecutionError; #[async_trait::async_trait] pub trait HealthCheck { async fn deep_health_check(&self) -> CustomResult<(), QueryExecutionError>; }
crates/analytics/src/health_check.rs
analytics
full_file
59
null
null
null
null
null
null
null
null
null
null
null
null
null
impl CreateOrValidateOrganization { #[cfg(all(feature = "v1", feature = "olap"))] /// Create an action to either create or validate the given organization_id /// If organization_id is passed, then validate if this organization exists /// If not passed, create a new organization fn new(organization_id: Option<id_type::OrganizationId>) -> Self { if let Some(organization_id) = organization_id { Self::Validate { organization_id } } else { Self::Create } } #[cfg(all(feature = "v2", feature = "olap"))] /// Create an action to validate the provided organization_id fn new(organization_id: id_type::OrganizationId) -> Self { Self::Validate { organization_id } } #[cfg(feature = "olap")] /// Apply the action, whether to create the organization or validate the given organization_id async fn create_or_validate( &self, db: &dyn AccountsStorageInterface, ) -> RouterResult<diesel_models::organization::Organization> { match self { #[cfg(feature = "v1")] Self::Create => { let new_organization = api_models::organization::OrganizationNew::new( OrganizationType::Standard, None, ); let db_organization = ForeignFrom::foreign_from(new_organization); db.insert_organization(db_organization) .await .to_duplicate_response(errors::ApiErrorResponse::InternalServerError) .attach_printable("Error when creating organization") } Self::Validate { organization_id } => db .find_organization_by_org_id(organization_id) .await .to_not_found_response(errors::ApiErrorResponse::GenericNotFoundError { message: "organization with the given id does not exist".to_string(), }), } } }
crates/router/src/core/admin.rs
router
impl_block
388
rust
null
CreateOrValidateOrganization
null
impl CreateOrValidateOrganization
null
null
null
null
null
null
null
null
impl DummyConnectors { pub fn get_connector_image_link(self, base_url: &str) -> String { let image_name = match self { Self::PhonyPay => "PHONYPAY.svg", Self::FauxPay => "FAUXPAY.svg", Self::PretendPay => "PRETENDPAY.svg", Self::StripeTest => "STRIPE_TEST.svg", Self::PaypalTest => "PAYPAL_TEST.svg", _ => "PHONYPAY.svg", }; format!("{base_url}{image_name}") } }
crates/router/src/routes/dummy_connector/types.rs
router
impl_block
123
rust
null
DummyConnectors
null
impl DummyConnectors
null
null
null
null
null
null
null
null
pub struct QrCodeData { #[serde(rename = "tranID")] pub tran_id: String, pub status: String, }
crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs
hyperswitch_connectors
struct_definition
30
rust
QrCodeData
null
null
null
null
null
null
null
null
null
null
null
impl Payme { pub const fn new() -> &'static Self { &Self { amount_converter: &MinorUnitForConnector, apple_pay_google_pay_amount_converter: &StringMajorUnitForConnector, amount_converter_webhooks: &StringMinorUnitForConnector, } } }
crates/hyperswitch_connectors/src/connectors/payme.rs
hyperswitch_connectors
impl_block
62
rust
null
Payme
null
impl Payme
null
null
null
null
null
null
null
null
request: &webhooks::IncomingWebhookRequestDetails<'_>, _merchant_id: &common_utils::id_type::MerchantId, _connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets, ) -> CustomResult<Vec<u8>, errors::ConnectorError> { let trustpay_response: trustpay::TrustpayWebhookResponse = request .body .parse_struct("TrustpayWebhookResponse") .switch()?; let response: serde_json::Value = request.body.parse_struct("Webhook Value").switch()?; let values = utils::collect_and_sort_values_by_removing_signature( &response, &trustpay_response.signature, ); let payload = values.join("/"); Ok(payload.into_bytes()) } fn get_dispute_details( &self, request: &webhooks::IncomingWebhookRequestDetails<'_>, ) -> CustomResult<DisputePayload, errors::ConnectorError> { let trustpay_response: trustpay::TrustpayWebhookResponse = request .body .parse_struct("TrustpayWebhookResponse") .switch()?; let payment_info = trustpay_response.payment_information; let reason = payment_info.status_reason_information.unwrap_or_default(); let connector_dispute_id = payment_info .references .payment_id .ok_or(errors::ConnectorError::WebhookReferenceIdNotFound)?; let amount = utils::convert_back_amount_to_minor_units( self.amount_converter_to_float_major_unit, payment_info.amount.amount, payment_info.amount.currency, )?; Ok(DisputePayload { amount: utils::convert_amount( self.amount_converter_to_string_minor_unit, amount, payment_info.amount.currency, )?, currency: payment_info.amount.currency, dispute_stage: api_models::enums::DisputeStage::Dispute, connector_dispute_id, connector_reason: reason.reason.reject_reason, connector_reason_code: reason.reason.code, challenge_required_by: None, connector_status: payment_info.status.to_string(), created_at: None, updated_at: None, }) } } impl ConnectorRedirectResponse for Trustpay { fn get_flow_type( &self, _query_params: &str, _json_payload: Option<serde_json::Value>, action: PaymentAction, ) -> CustomResult<enums::CallConnectorAction, errors::ConnectorError> { match action { PaymentAction::PSync | PaymentAction::CompleteAuthorize | PaymentAction::PaymentAuthenticateCompleteAuthorize => { Ok(enums::CallConnectorAction::Trigger) } } } } impl utils::ConnectorErrorTypeMapping for Trustpay { fn get_connector_error_type( &self, error_code: String, error_message: String, ) -> ConnectorErrorType { match (error_code.as_str(), error_message.as_str()) { // 2xx card api error codes and messages mapping ("100.100.600", "Empty CVV for VISA, MASTER not allowed") => ConnectorErrorType::UserError, ("100.350.100", "Referenced session is rejected (no action possible)") => ConnectorErrorType::TechnicalError, ("100.380.401", "User authentication failed") => ConnectorErrorType::UserError, ("100.380.501", "Risk management transaction timeout") => ConnectorErrorType::TechnicalError, ("100.390.103", "PARes validation failed - problem with signature") => ConnectorErrorType::TechnicalError, ("100.390.111", "Communication error to VISA/Mastercard Directory Server") => ConnectorErrorType::TechnicalError, ("100.390.112", "Technical error in 3D system") => ConnectorErrorType::TechnicalError, ("100.390.115", "Authentication failed due to invalid message format") => ConnectorErrorType::TechnicalError, ("100.390.118", "Authentication failed due to suspected fraud") => ConnectorErrorType::UserError, ("100.400.304", "Invalid input data") => ConnectorErrorType::UserError, ("200.300.404", "Invalid or missing parameter") => ConnectorErrorType::UserError, ("300.100.100", "Transaction declined (additional customer authentication required)") => ConnectorErrorType::UserError, ("400.001.301", "Card not enrolled in 3DS") => ConnectorErrorType::UserError, ("400.001.600", "Authentication error") => ConnectorErrorType::UserError, ("400.001.601", "Transaction declined (auth. declined)") => ConnectorErrorType::UserError, ("400.001.602", "Invalid transaction") => ConnectorErrorType::UserError, ("400.001.603", "Invalid transaction") => ConnectorErrorType::UserError, ("700.400.200", "Cannot refund (refund volume exceeded or tx reversed or invalid workflow)") => ConnectorErrorType::BusinessError, ("700.500.001", "Referenced session contains too many transactions") => ConnectorErrorType::TechnicalError, ("700.500.003", "Test accounts not allowed in production") => ConnectorErrorType::UserError, ("800.100.151", "Transaction declined (invalid card)") => ConnectorErrorType::UserError, ("800.100.152", "Transaction declined by authorization system") => ConnectorErrorType::UserError, ("800.100.153", "Transaction declined (invalid CVV)") => ConnectorErrorType::UserError, ("800.100.155", "Transaction declined (amount exceeds credit)") => ConnectorErrorType::UserError, ("800.100.157", "Transaction declined (wrong expiry date)") => ConnectorErrorType::UserError, ("800.100.162", "Transaction declined (limit exceeded)") => ConnectorErrorType::BusinessError, ("800.100.163", "Transaction declined (maximum transaction frequency exceeded)") => ConnectorErrorType::BusinessError, ("800.100.168", "Transaction declined (restricted card)") => ConnectorErrorType::UserError, ("800.100.170", "Transaction declined (transaction not permitted)") => ConnectorErrorType::UserError, ("800.100.172", "Transaction declined (account blocked)") => ConnectorErrorType::BusinessError, ("800.100.190", "Transaction declined (invalid configuration data)") => ConnectorErrorType::BusinessError, ("800.120.100", "Rejected by throttling") => ConnectorErrorType::TechnicalError, ("800.300.401", "Bin blacklisted") => ConnectorErrorType::BusinessError, ("800.700.100", "Transaction for the same session is currently being processed, please try again later") => ConnectorErrorType::TechnicalError, ("900.100.300", "Timeout, uncertain result") => ConnectorErrorType::TechnicalError, // 4xx error codes for cards api are unique and messages vary, so we are relying only on error code to decide an error type ("4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "26" | "34" | "39" | "48" | "52" | "85" | "86", _) => ConnectorErrorType::UserError, ("21" | "22" | "23" | "30" | "31" | "32" | "35" | "37" | "40" | "41" | "45" | "46" | "49" | "50" | "56" | "60" | "67" | "81" | "82" | "83" | "84" | "87", _) => ConnectorErrorType::BusinessError, ("59", _) => ConnectorErrorType::TechnicalError, ("1", _) => ConnectorErrorType::UnknownError, // Error codes for bank redirects api are unique and messages vary, so we are relying only on error code to decide an error type ("1112008" | "1132000" | "1152000", _) => ConnectorErrorType::UserError, ("1112009" | "1122006" | "1132001" | "1132002" | "1132003" | "1132004" | "1132005" | "1132006" | "1132008" | "1132009" | "1132010" | "1132011" | "1132012" | "1132013" | "1133000" | "1133001" | "1133002" | "1133003" | "1133004", _) => ConnectorErrorType::BusinessError, ("1132014", _) => ConnectorErrorType::TechnicalError, ("1132007", _) => ConnectorErrorType::UnknownError, _ => ConnectorErrorType::UnknownError, } } } static TRUSTPAY_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| { let supported_capture_methods = vec![ enums::CaptureMethod::Automatic, enums::CaptureMethod::SequentialAutomatic, ]; let supported_card_network = vec![ common_enums::CardNetwork::Mastercard, common_enums::CardNetwork::Visa, common_enums::CardNetwork::Interac, common_enums::CardNetwork::AmericanExpress, common_enums::CardNetwork::JCB, common_enums::CardNetwork::DinersClub, common_enums::CardNetwork::Discover, common_enums::CardNetwork::CartesBancaires, common_enums::CardNetwork::UnionPay, ]; let mut trustpay_supported_payment_methods = SupportedPaymentMethods::new(); trustpay_supported_payment_methods.add( enums::PaymentMethod::Card, enums::PaymentMethodType::Credit, PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods: supported_capture_methods.clone(), specific_features: Some( api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({ api_models::feature_matrix::CardSpecificFeatures { three_ds: common_enums::FeatureStatus::NotSupported, no_three_ds: common_enums::FeatureStatus::Supported, supported_card_networks: supported_card_network.clone(), } }), ), }, ); trustpay_supported_payment_methods.add( enums::PaymentMethod::Card, enums::PaymentMethodType::Debit, PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods: supported_capture_methods.clone(), specific_features: Some( api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({ api_models::feature_matrix::CardSpecificFeatures { three_ds: common_enums::FeatureStatus::NotSupported, no_three_ds: common_enums::FeatureStatus::Supported, supported_card_networks: supported_card_network, } }), ), }, ); trustpay_supported_payment_methods.add( enums::PaymentMethod::Wallet, enums::PaymentMethodType::GooglePay, PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods: supported_capture_methods.clone(), specific_features: None, }, ); trustpay_supported_payment_methods.add( enums::PaymentMethod::Wallet, enums::PaymentMethodType::ApplePay, PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods: supported_capture_methods.clone(), specific_features: None, }, ); trustpay_supported_payment_methods.add( enums::PaymentMethod::BankRedirect, enums::PaymentMethodType::Eps, PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods: supported_capture_methods.clone(), specific_features: None, }, ); trustpay_supported_payment_methods.add( enums::PaymentMethod::BankRedirect, enums::PaymentMethodType::Giropay, PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods: supported_capture_methods.clone(), specific_features: None, }, ); trustpay_supported_payment_methods.add( enums::PaymentMethod::BankRedirect, enums::PaymentMethodType::Ideal, PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods: supported_capture_methods.clone(), specific_features: None, }, ); trustpay_supported_payment_methods.add( enums::PaymentMethod::BankRedirect, enums::PaymentMethodType::Sofort, PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods: supported_capture_methods.clone(), specific_features: None, }, ); trustpay_supported_payment_methods.add( enums::PaymentMethod::BankRedirect, enums::PaymentMethodType::Blik, PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods: supported_capture_methods.clone(), specific_features: None, }, ); trustpay_supported_payment_methods.add( enums::PaymentMethod::BankTransfer, enums::PaymentMethodType::SepaBankTransfer, PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods: supported_capture_methods.clone(), specific_features: None, }, ); trustpay_supported_payment_methods.add( enums::PaymentMethod::BankTransfer, enums::PaymentMethodType::InstantBankTransfer, PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods: supported_capture_methods.clone(), specific_features: None, }, ); trustpay_supported_payment_methods.add( enums::PaymentMethod::BankTransfer, enums::PaymentMethodType::InstantBankTransferFinland, PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods: supported_capture_methods.clone(), specific_features: None, }, ); trustpay_supported_payment_methods.add( enums::PaymentMethod::BankTransfer, enums::PaymentMethodType::InstantBankTransferPoland, PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods, specific_features: None, }, ); trustpay_supported_payment_methods }); static TRUSTPAY_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { display_name: "Trustpay", description: "TrustPay offers cross-border payment solutions for online businesses, including global card processing, local payment methods, business accounts, and reconciliation tools—all under one roof.", connector_type: enums::HyperswitchConnectorCategory::PaymentGateway, integration_status: enums::ConnectorIntegrationStatus::Live, }; static TRUSTPAY_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 3] = [ enums::EventClass::Payments, enums::EventClass::Refunds, enums::EventClass::Disputes, ]; impl ConnectorSpecifications for Trustpay { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { Some(&TRUSTPAY_CONNECTOR_INFO) } fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { Some(&*TRUSTPAY_SUPPORTED_PAYMENT_METHODS) } fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { Some(&TRUSTPAY_SUPPORTED_WEBHOOK_FLOWS) } }
crates/hyperswitch_connectors/src/connectors/trustpay.rs#chunk1
hyperswitch_connectors
chunk
3,840
null
null
null
null
null
null
null
null
null
null
null
null
null
pub async fn list_customer_payment_methods_core( state: &SessionState, merchant_context: &domain::MerchantContext, customer_id: &id_type::GlobalCustomerId, ) -> RouterResult<Vec<payment_methods::CustomerPaymentMethodResponseItem>> { let db = &*state.store; let key_manager_state = &(state).into(); let saved_payment_methods = db .find_payment_method_by_global_customer_id_merchant_id_status( key_manager_state, merchant_context.get_merchant_key_store(), customer_id, merchant_context.get_merchant_account().get_id(), common_enums::PaymentMethodStatus::Active, None, merchant_context.get_merchant_account().storage_scheme, ) .await .to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?; let mut customer_payment_methods = Vec::new(); let payment_method_results: Result<Vec<_>, error_stack::Report<errors::ApiErrorResponse>> = saved_payment_methods .into_iter() .map(|pm| async move { let parent_payment_method_token = generate_id(consts::ID_LENGTH, "token"); // For payment methods that are active we should always have the payment method type let payment_method_type = pm .payment_method_type .get_required_value("payment_method_type")?; let intent_fulfillment_time = common_utils::consts::DEFAULT_INTENT_FULFILLMENT_TIME; let token_data = get_pm_list_token_data(payment_method_type, &pm)?; if let Some(token_data) = token_data { pm_routes::ParentPaymentMethodToken::create_key_for_token(( &parent_payment_method_token, payment_method_type, )) .insert(intent_fulfillment_time, token_data, state) .await?; let final_pm = api::CustomerPaymentMethodResponseItem::foreign_try_from(( pm, parent_payment_method_token, )) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to convert payment method to response format")?; Ok(Some(final_pm)) } else { Ok(None) } }) .collect::<futures::stream::FuturesUnordered<_>>() .try_collect::<Vec<_>>() .await; customer_payment_methods.extend(payment_method_results?.into_iter().flatten()); Ok(customer_payment_methods) }
crates/router/src/core/payment_methods.rs
router
function_signature
501
rust
null
null
null
null
list_customer_payment_methods_core
null
null
null
null
null
null
null
impl State for TokenizeWithPmId {}
crates/router/src/core/payment_methods/tokenize/payment_method_executor.rs
router
impl_block
10
rust
null
TokenizeWithPmId
State for
impl State for for TokenizeWithPmId
null
null
null
null
null
null
null
null
pub async fn proxy_for_call_connector_service<F, RouterDReq, ApiRequest, D>( state: &SessionState, req_state: ReqState, merchant_context: &domain::MerchantContext, connector: api::ConnectorData, operation: &BoxedOperation<'_, F, ApiRequest, D>, payment_data: &mut D, customer: &Option<domain::Customer>, call_connector_action: CallConnectorAction, validate_result: &operations::ValidateResult, schedule_time: Option<time::PrimitiveDateTime>, header_payload: HeaderPayload, business_profile: &domain::Profile, return_raw_connector_response: Option<bool>, ) -> RouterResult<( RouterData<F, RouterDReq, router_types::PaymentsResponseData>, helpers::MerchantConnectorAccountType, )> where F: Send + Clone + Sync, RouterDReq: Send + Sync, // To create connector flow specific interface data D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone, D: ConstructFlowSpecificData<F, RouterDReq, router_types::PaymentsResponseData>, RouterData<F, RouterDReq, router_types::PaymentsResponseData>: Feature<F, RouterDReq> + Send, // To construct connector flow specific api dyn api::Connector: services::api::ConnectorIntegration<F, RouterDReq, router_types::PaymentsResponseData>, { let stime_connector = Instant::now(); let merchant_connector_account = construct_profile_id_and_get_mca( state, merchant_context, payment_data, &connector.connector_name.to_string(), connector.merchant_connector_id.as_ref(), false, ) .await?; if payment_data .get_payment_attempt() .merchant_connector_id .is_none() { payment_data.set_merchant_connector_id_in_attempt(merchant_connector_account.get_mca_id()); } let merchant_recipient_data = None; let mut router_data = payment_data .construct_router_data( state, connector.connector.id(), merchant_context, customer, &merchant_connector_account, merchant_recipient_data, None, ) .await?; let add_access_token_result = router_data .add_access_token( state, &connector, merchant_context, payment_data.get_creds_identifier(), ) .await?; router_data = router_data.add_session_token(state, &connector).await?; let mut should_continue_further = access_token::update_router_data_with_access_token_result( &add_access_token_result, &mut router_data, &call_connector_action, ); (router_data, should_continue_further) = complete_preprocessing_steps_if_required( state, &connector, payment_data, router_data, operation, should_continue_further, ) .await?; if let Ok(router_types::PaymentsResponseData::PreProcessingResponse { session_token: Some(session_token), .. }) = router_data.response.to_owned() { payment_data.push_sessions_token(session_token); }; let (connector_request, should_continue_further) = if should_continue_further { // Check if the actual flow specific request can be built with available data router_data .build_flow_specific_connector_request(state, &connector, call_connector_action.clone()) .await? } else { (None, false) }; if should_add_task_to_process_tracker(payment_data) { operation .to_domain()? .add_task_to_process_tracker( state, payment_data.get_payment_attempt(), validate_result.requeue, schedule_time, ) .await .map_err(|error| logger::error!(process_tracker_error=?error)) .ok(); } let updated_customer = None; let frm_suggestion = None; (_, *payment_data) = operation .to_update_tracker()? .update_trackers( state, req_state, payment_data.clone(), customer.clone(), merchant_context.get_merchant_account().storage_scheme, updated_customer, merchant_context.get_merchant_key_store(), frm_suggestion, header_payload.clone(), ) .await?; let router_data = if should_continue_further { // The status of payment_attempt and intent will be updated in the previous step // update this in router_data. // This is added because few connector integrations do not update the status, // and rely on previous status set in router_data router_data.status = payment_data.get_payment_attempt().status; router_data .decide_flows( state, &connector, call_connector_action, connector_request, business_profile, header_payload.clone(), return_raw_connector_response, ) .await } else { Ok(router_data) }?; let etime_connector = Instant::now(); let duration_connector = etime_connector.saturating_duration_since(stime_connector); tracing::info!(duration = format!("Duration taken: {}", duration_connector.as_millis())); Ok((router_data, merchant_connector_account)) }
crates/router/src/core/payments.rs
router
function_signature
1,100
rust
null
null
null
null
proxy_for_call_connector_service
null
null
null
null
null
null
null
pub struct Venmo { /// mobile number linked to venmo account #[schema(value_type = String, example = "16608213349")] pub telephone_number: Option<Secret<String>>, }
crates/api_models/src/payouts.rs
api_models
struct_definition
49
rust
Venmo
null
null
null
null
null
null
null
null
null
null
null
impl api::RefundSync for Flexiti {}
crates/hyperswitch_connectors/src/connectors/flexiti.rs
hyperswitch_connectors
impl_block
10
rust
null
Flexiti
api::RefundSync for
impl api::RefundSync for for Flexiti
null
null
null
null
null
null
null
null
impl api::ConnectorAccessToken for Jpmorgan {}
crates/hyperswitch_connectors/src/connectors/jpmorgan.rs
hyperswitch_connectors
impl_block
10
rust
null
Jpmorgan
api::ConnectorAccessToken for
impl api::ConnectorAccessToken for for Jpmorgan
null
null
null
null
null
null
null
null
pub async fn routing_retrieve_config() {}
crates/openapi/src/routes/routing.rs
openapi
function_signature
9
rust
null
null
null
null
routing_retrieve_config
null
null
null
null
null
null
null
pub struct RefundBodyResponse { submit_single_refund_response: SubmitSingleRefundResponse, }
crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs
hyperswitch_connectors
struct_definition
21
rust
RefundBodyResponse
null
null
null
null
null
null
null
null
null
null
null
pub struct ConnectorTokenReferenceRecord { pub connector_token: String, pub payment_method_subtype: Option<common_enums::PaymentMethodType>, pub original_payment_authorized_amount: Option<MinorUnit>, pub original_payment_authorized_currency: Option<Currency>, pub metadata: Option<pii::SecretSerdeValue>, pub connector_token_status: common_enums::ConnectorTokenStatus, pub connector_token_request_reference_id: Option<String>, }
crates/hyperswitch_domain_models/src/mandates.rs
hyperswitch_domain_models
struct_definition
94
rust
ConnectorTokenReferenceRecord
null
null
null
null
null
null
null
null
null
null
null
pub struct CardAndNetworkTokenDataForVault { pub card_data: payment_method_data::Card, pub network_token: NetworkTokenDataForVault, }
crates/hyperswitch_domain_models/src/payments.rs
hyperswitch_domain_models
struct_definition
33
rust
CardAndNetworkTokenDataForVault
null
null
null
null
null
null
null
null
null
null
null
pub async fn signout_hypersense_token( state: web::Data<AppState>, http_req: HttpRequest, json_payload: web::Json<external_service_auth_api::ExternalSignoutTokenRequest>, ) -> HttpResponse { let flow = Flow::HypersenseSignoutToken; Box::pin(api::server_wrap( flow, state.clone(), &http_req, json_payload.into_inner(), |state, _: (), json_payload, _| { external_service_auth::signout_external_token(state, json_payload) }, &authentication::NoAuth, api_locking::LockAction::NotApplicable, )) .await }
crates/router/src/routes/hypersense.rs
router
function_signature
143
rust
null
null
null
null
signout_hypersense_token
null
null
null
null
null
null
null
pub fn new() -> Self { Self { data: Vec::new(), _marker: PhantomData, } }
crates/hyperswitch_constraint_graph/src/dense_map.rs
hyperswitch_constraint_graph
function_signature
28
rust
null
null
null
null
new
null
null
null
null
null
null
null
File: crates/storage_impl/src/mock_db/redis_conn.rs use std::sync::Arc; use redis_interface::errors::RedisError; use super::MockDb; use crate::redis::kv_store::RedisConnInterface; impl RedisConnInterface for MockDb { fn get_redis_conn( &self, ) -> Result<Arc<redis_interface::RedisConnectionPool>, error_stack::Report<RedisError>> { self.redis.get_redis_conn() } }
crates/storage_impl/src/mock_db/redis_conn.rs
storage_impl
full_file
98
null
null
null
null
null
null
null
null
null
null
null
null
null
pub fn new() -> &'static Self { &Self { amount_converter: &StringMajorUnitForConnector, } }
crates/hyperswitch_connectors/src/connectors/aci.rs
hyperswitch_connectors
function_signature
28
rust
null
null
null
null
new
null
null
null
null
null
null
null
pub struct Stripebilling { amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync), }
crates/hyperswitch_connectors/src/connectors/stripebilling.rs
hyperswitch_connectors
struct_definition
27
rust
Stripebilling
null
null
null
null
null
null
null
null
null
null
null
File: crates/hyperswitch_domain_models/src/router_response_types/fraud_check.rs use serde::Serialize; use crate::router_response_types::ResponseId; #[derive(Debug, Clone, Serialize)] #[serde(untagged)] pub enum FraudCheckResponseData { TransactionResponse { resource_id: ResponseId, status: diesel_models::enums::FraudCheckStatus, connector_metadata: Option<serde_json::Value>, reason: Option<serde_json::Value>, score: Option<i32>, }, FulfillmentResponse { order_id: String, shipment_ids: Vec<String>, }, RecordReturnResponse { resource_id: ResponseId, connector_metadata: Option<serde_json::Value>, return_id: Option<String>, }, } impl common_utils::events::ApiEventMetric for FraudCheckResponseData { fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> { Some(common_utils::events::ApiEventsType::FraudCheck) } }
crates/hyperswitch_domain_models/src/router_response_types/fraud_check.rs
hyperswitch_domain_models
full_file
218
null
null
null
null
null
null
null
null
null
null
null
null
null
pub async fn do_auth_connector_call<F, Req, Res>( state: &SessionState, authentication_connector_name: String, router_data: RouterData<F, Req, Res>, ) -> RouterResult<RouterData<F, Req, Res>> where Req: std::fmt::Debug + Clone + 'static, Res: std::fmt::Debug + Clone + 'static, F: std::fmt::Debug + Clone + 'static, dyn api::Connector + Sync: services::api::ConnectorIntegration<F, Req, Res>, dyn api::ConnectorV2 + Sync: services::api::ConnectorIntegrationV2<F, ExternalAuthenticationFlowData, Req, Res>, { let connector_data = api::AuthenticationConnectorData::get_connector_by_name(&authentication_connector_name)?; let connector_integration: services::BoxedExternalAuthenticationConnectorIntegrationInterface< F, Req, Res, > = connector_data.connector.get_connector_integration(); let router_data = execute_connector_processing_step( state, connector_integration, &router_data, payments::CallConnectorAction::Trigger, None, None, ) .await .to_payment_failed_response()?; Ok(router_data) }
crates/router/src/core/authentication/utils.rs
router
function_signature
258
rust
null
null
null
null
do_auth_connector_call
null
null
null
null
null
null
null
pub struct PowertranzErrorResponse { pub errors: Vec<Error>, }
crates/hyperswitch_connectors/src/connectors/powertranz/transformers.rs
hyperswitch_connectors
struct_definition
16
rust
PowertranzErrorResponse
null
null
null
null
null
null
null
null
null
null
null
impl CoBadgedCardNetworks { pub fn get_card_networks(&self) -> Vec<common_enums::CardNetwork> { self.0.iter().map(|info| info.network.clone()).collect() } pub fn get_signature_network(&self) -> Option<common_enums::CardNetwork> { self.0 .iter() .find(|info| info.network.is_signature_network()) .map(|info| info.network.clone()) } }
crates/api_models/src/open_router.rs
api_models
impl_block
101
rust
null
CoBadgedCardNetworks
null
impl CoBadgedCardNetworks
null
null
null
null
null
null
null
null