text
stringlengths
65
57.3k
file_path
stringlengths
22
92
module
stringclasses
38 values
type
stringclasses
7 values
struct_name
stringlengths
3
60
impl_count
int64
0
60
traits
listlengths
0
59
tokens
int64
16
8.19k
function_name
stringlengths
3
85
type_name
stringlengths
1
67
trait_name
stringclasses
573 values
method_count
int64
0
31
public_method_count
int64
0
19
submodule_count
int64
0
56
export_count
int64
0
9
// Struct: NovalnetCancelResponse // File: crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct NovalnetCancelResponse
crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
hyperswitch_connectors
struct_definition
NovalnetCancelResponse
0
[]
52
null
null
null
null
null
null
null
// Implementation: impl ErrorResponse // File: crates/pm_auth/src/types.rs // Module: pm_auth // Methods: 1 total (0 public) impl ErrorResponse
crates/pm_auth/src/types.rs
pm_auth
impl_block
null
null
null
34
null
ErrorResponse
null
1
0
null
null
// Struct: Details // File: crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct Details
crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs
hyperswitch_connectors
struct_definition
Details
0
[]
45
null
null
null
null
null
null
null
// Struct: GpayAllowedMethodsParameters // File: crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct GpayAllowedMethodsParameters
crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rs
hyperswitch_connectors
struct_definition
GpayAllowedMethodsParameters
0
[]
52
null
null
null
null
null
null
null
// File: crates/analytics/src/payment_intents/metrics/successful_smart_retries.rs // Module: analytics use std::collections::HashSet; use api_models::{ analytics::{ payment_intents::{ PaymentIntentDimensions, PaymentIntentFilters, PaymentIntentMetricsBucketIdentifier, }, Granularity, TimeRange, }, enums::IntentStatus, }; use common_utils::errors::ReportSwitchExt; use error_stack::ResultExt; use time::PrimitiveDateTime; use super::PaymentIntentMetricRow; use crate::{ enums::AuthInfo, query::{ Aggregate, FilterTypes, GroupByClause, QueryBuilder, QueryFilter, SeriesBucket, ToSql, Window, }, types::{AnalyticsCollection, AnalyticsDataSource, MetricsError, MetricsResult}, }; #[derive(Default)] pub(super) struct SuccessfulSmartRetries; #[async_trait::async_trait] impl<T> super::PaymentIntentMetric<T> for SuccessfulSmartRetries where T: AnalyticsDataSource + super::PaymentIntentMetricAnalytics, PrimitiveDateTime: ToSql<T>, AnalyticsCollection: ToSql<T>, Granularity: GroupByClause<T>, Aggregate<&'static str>: ToSql<T>, Window<&'static str>: ToSql<T>, { async fn load_metrics( &self, dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, granularity: Option<Granularity>, time_range: &TimeRange, pool: &T, ) -> MetricsResult<HashSet<(PaymentIntentMetricsBucketIdentifier, PaymentIntentMetricRow)>> { let mut query_builder: QueryBuilder<T> = QueryBuilder::new(AnalyticsCollection::PaymentIntent); for dim in dimensions.iter() { query_builder.add_select_column(dim).switch()?; } query_builder .add_select_column(Aggregate::Count { field: None, alias: Some("count"), }) .switch()?; query_builder .add_select_column(Aggregate::Min { field: "created_at", alias: Some("start_bucket"), }) .switch()?; query_builder .add_select_column(Aggregate::Max { field: "created_at", alias: Some("end_bucket"), }) .switch()?; filters.set_filter_clause(&mut query_builder).switch()?; auth.set_filter_clause(&mut query_builder).switch()?; query_builder .add_custom_filter_clause("attempt_count", "1", FilterTypes::Gt) .switch()?; query_builder .add_custom_filter_clause("status", IntentStatus::Succeeded, FilterTypes::Equal) .switch()?; time_range .set_filter_clause(&mut query_builder) .attach_printable("Error filtering time range") .switch()?; for dim in dimensions.iter() { query_builder .add_group_by_clause(dim) .attach_printable("Error grouping by dimensions") .switch()?; } if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") .switch()?; } query_builder .execute_query::<PaymentIntentMetricRow, _>(pool) .await .change_context(MetricsError::QueryBuildingError)? .change_context(MetricsError::QueryExecutionFailure)? .into_iter() .map(|i| { Ok(( PaymentIntentMetricsBucketIdentifier::new( i.status.as_ref().map(|i| i.0), i.currency.as_ref().map(|i| i.0), i.profile_id.clone(), i.connector.clone(), i.authentication_type.as_ref().map(|i| i.0), i.payment_method.clone(), i.payment_method_type.clone(), i.card_network.clone(), i.merchant_id.clone(), i.card_last_4.clone(), i.card_issuer.clone(), i.error_reason.clone(), TimeRange { start_time: match (granularity, i.start_bucket) { (Some(g), Some(st)) => g.clip_to_start(st)?, _ => time_range.start_time, }, end_time: granularity.as_ref().map_or_else( || Ok(time_range.end_time), |g| i.end_bucket.map(|et| g.clip_to_end(et)).transpose(), )?, }, ), i, )) }) .collect::<error_stack::Result< HashSet<(PaymentIntentMetricsBucketIdentifier, PaymentIntentMetricRow)>, crate::query::PostProcessingError, >>() .change_context(MetricsError::PostProcessingFailure) } }
crates/analytics/src/payment_intents/metrics/successful_smart_retries.rs
analytics
full_file
null
null
null
996
null
null
null
null
null
null
null
// Implementation: impl api::PaymentToken for for Payeezy // File: crates/hyperswitch_connectors/src/connectors/payeezy.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::PaymentToken for for Payeezy
crates/hyperswitch_connectors/src/connectors/payeezy.rs
hyperswitch_connectors
impl_block
null
null
null
60
null
Payeezy
api::PaymentToken for
0
0
null
null
// Function: mobile_payment_next_steps_check // File: crates/router/src/core/payments/transformers.rs // Module: router pub fn mobile_payment_next_steps_check( payment_attempt: &storage::PaymentAttempt, ) -> RouterResult<Option<api_models::payments::MobilePaymentNextStepData>>
crates/router/src/core/payments/transformers.rs
router
function_signature
null
null
null
63
mobile_payment_next_steps_check
null
null
null
null
null
null
// Struct: CustomerGeneralUpdate // File: crates/hyperswitch_domain_models/src/customer.rs // Module: hyperswitch_domain_models // Implementations: 0 pub struct CustomerGeneralUpdate
crates/hyperswitch_domain_models/src/customer.rs
hyperswitch_domain_models
struct_definition
CustomerGeneralUpdate
0
[]
41
null
null
null
null
null
null
null
// Struct: CardInfo // File: crates/hyperswitch_connectors/src/connectors/xendit/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct CardInfo
crates/hyperswitch_connectors/src/connectors/xendit/transformers.rs
hyperswitch_connectors
struct_definition
CardInfo
0
[]
46
null
null
null
null
null
null
null
// Struct: EphemeralKey // File: crates/diesel_models/src/ephemeral_key.rs // Module: diesel_models // Implementations: 1 // Traits: common_utils::events::ApiEventMetric pub struct EphemeralKey
crates/diesel_models/src/ephemeral_key.rs
diesel_models
struct_definition
EphemeralKey
1
[ "common_utils::events::ApiEventMetric" ]
54
null
null
null
null
null
null
null
// Function: increment_blocked_count_in_cache // File: crates/router/src/services/card_testing_guard.rs // Module: router pub fn increment_blocked_count_in_cache<A>( state: &A, cache_key: &str, expiry: i64, ) -> RouterResult<()> where A: SessionStateInfo + Sync,
crates/router/src/services/card_testing_guard.rs
router
function_signature
null
null
null
72
increment_blocked_count_in_cache
null
null
null
null
null
null
// Function: error_type // File: crates/router_derive/src/macros/api_error.rs // Module: router_derive pub fn error_type(&self) -> #error_type_enum
crates/router_derive/src/macros/api_error.rs
router_derive
function_signature
null
null
null
39
error_type
null
null
null
null
null
null
// Implementation: impl SecretState for for SecuredSecret // File: crates/hyperswitch_interfaces/src/secrets_interface/secret_state.rs // Module: hyperswitch_interfaces // Methods: 0 total (0 public) impl SecretState for for SecuredSecret
crates/hyperswitch_interfaces/src/secrets_interface/secret_state.rs
hyperswitch_interfaces
impl_block
null
null
null
55
null
SecuredSecret
SecretState for
0
0
null
null
// Function: get_no_three_ds_account_id // File: crates/hyperswitch_connectors/src/connectors/paysafe/transformers.rs // Module: hyperswitch_connectors pub fn get_no_three_ds_account_id( &self, currency: Currency, ) -> Result<Secret<String>, errors::ConnectorError>
crates/hyperswitch_connectors/src/connectors/paysafe/transformers.rs
hyperswitch_connectors
function_signature
null
null
null
70
get_no_three_ds_account_id
null
null
null
null
null
null
// Function: server // File: crates/router/src/routes/app.rs // Module: router pub fn server(state: AppState) -> Scope
crates/router/src/routes/app.rs
router
function_signature
null
null
null
29
server
null
null
null
null
null
null
// Struct: DisputeListConstraints // File: crates/hyperswitch_domain_models/src/disputes.rs // Module: hyperswitch_domain_models // Implementations: 0 pub struct DisputeListConstraints
crates/hyperswitch_domain_models/src/disputes.rs
hyperswitch_domain_models
struct_definition
DisputeListConstraints
0
[]
45
null
null
null
null
null
null
null
// Struct: Payu // File: crates/hyperswitch_connectors/src/connectors/payu.rs // Module: hyperswitch_connectors // Implementations: 17 // Traits: ConnectorCommon, ConnectorValidation, api::Payment, api::MandateSetup, api::PaymentToken, api::PaymentVoid, api::ConnectorAccessToken, api::PaymentSync, api::PaymentCapture, api::PaymentSession, api::PaymentAuthorize, api::Refund, api::RefundExecute, api::RefundSync, IncomingWebhook, ConnectorSpecifications pub struct Payu
crates/hyperswitch_connectors/src/connectors/payu.rs
hyperswitch_connectors
struct_definition
Payu
17
[ "ConnectorCommon", "ConnectorValidation", "api::Payment", "api::MandateSetup", "api::PaymentToken", "api::PaymentVoid", "api::ConnectorAccessToken", "api::PaymentSync", "api::PaymentCapture", "api::PaymentSession", "api::PaymentAuthorize", "api::Refund", "api::RefundExecute", "api::RefundSync", "IncomingWebhook", "ConnectorSpecifications" ]
122
null
null
null
null
null
null
null
// Implementation: impl Trustpay // File: crates/hyperswitch_connectors/src/connectors/trustpay.rs // Module: hyperswitch_connectors // Methods: 1 total (1 public) impl Trustpay
crates/hyperswitch_connectors/src/connectors/trustpay.rs
hyperswitch_connectors
impl_block
null
null
null
46
null
Trustpay
null
1
1
null
null
// Struct: ChargebeeMetadata // File: crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct ChargebeeMetadata
crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs
hyperswitch_connectors
struct_definition
ChargebeeMetadata
0
[]
48
null
null
null
null
null
null
null
// Implementation: impl api::Refund for for Stripe // File: crates/hyperswitch_connectors/src/connectors/stripe.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::Refund for for Stripe
crates/hyperswitch_connectors/src/connectors/stripe.rs
hyperswitch_connectors
impl_block
null
null
null
55
null
Stripe
api::Refund for
0
0
null
null
// Function: validate_and_create_refund // File: crates/router/src/core/refunds.rs // Module: router pub fn validate_and_create_refund( state: &SessionState, merchant_context: &domain::MerchantContext, payment_attempt: &storage::PaymentAttempt, payment_intent: &storage::PaymentIntent, refund_amount: MinorUnit, req: refunds::RefundRequest, creds_identifier: Option<String>, ) -> RouterResult<refunds::RefundResponse>
crates/router/src/core/refunds.rs
router
function_signature
null
null
null
105
validate_and_create_refund
null
null
null
null
null
null
// Struct: Source // File: crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct Source
crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs
hyperswitch_connectors
struct_definition
Source
0
[]
43
null
null
null
null
null
null
null
// Struct: CoingatePaymentsResponse // File: crates/hyperswitch_connectors/src/connectors/coingate/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct CoingatePaymentsResponse
crates/hyperswitch_connectors/src/connectors/coingate/transformers.rs
hyperswitch_connectors
struct_definition
CoingatePaymentsResponse
0
[]
52
null
null
null
null
null
null
null
// Struct: PaymentData // File: crates/router/src/core/payments.rs // Module: router // Implementations: 1 pub struct PaymentData<F>
crates/router/src/core/payments.rs
router
struct_definition
PaymentData
1
[]
35
null
null
null
null
null
null
null
// Struct: RoutableConnectors // File: crates/router/src/core/routing.rs // Module: router // Implementations: 1 pub struct RoutableConnectors
crates/router/src/core/routing.rs
router
struct_definition
RoutableConnectors
1
[]
37
null
null
null
null
null
null
null
// Implementation: impl api::PaymentVoid for for Bitpay // File: crates/hyperswitch_connectors/src/connectors/bitpay.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::PaymentVoid for for Bitpay
crates/hyperswitch_connectors/src/connectors/bitpay.rs
hyperswitch_connectors
impl_block
null
null
null
57
null
Bitpay
api::PaymentVoid for
0
0
null
null
// Trait: RefundDistributionAnalytics // File: crates/analytics/src/refunds/distribution.rs // Module: analytics pub trait RefundDistributionAnalytics: LoadRow<RefundDistributionRow>
crates/analytics/src/refunds/distribution.rs
analytics
trait_definition
null
null
null
41
null
null
RefundDistributionAnalytics
null
null
null
null
// Implementation: impl api::PaymentToken for for Blackhawknetwork // File: crates/hyperswitch_connectors/src/connectors/blackhawknetwork.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::PaymentToken for for Blackhawknetwork
crates/hyperswitch_connectors/src/connectors/blackhawknetwork.rs
hyperswitch_connectors
impl_block
null
null
null
60
null
Blackhawknetwork
api::PaymentToken for
0
0
null
null
// Struct: ResponseRouterData // File: crates/pm_auth/src/types.rs // Module: pm_auth // Implementations: 0 pub struct ResponseRouterData<Flow, R, Request, Response>
crates/pm_auth/src/types.rs
pm_auth
struct_definition
ResponseRouterData
0
[]
44
null
null
null
null
null
null
null
// Function: get_connector_image_link // File: crates/router/src/routes/dummy_connector/types.rs // Module: router pub fn get_connector_image_link(self, base_url: &str) -> String
crates/router/src/routes/dummy_connector/types.rs
router
function_signature
null
null
null
42
get_connector_image_link
null
null
null
null
null
null
// Implementation: impl PaymentVoid for for Payone // File: crates/hyperswitch_connectors/src/connectors/payone.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl PaymentVoid for for Payone
crates/hyperswitch_connectors/src/connectors/payone.rs
hyperswitch_connectors
impl_block
null
null
null
53
null
Payone
PaymentVoid for
0
0
null
null
// Implementation: impl RequestIdStore for for MockDb // File: crates/router/src/db.rs // Module: router // Methods: 0 total (0 public) impl RequestIdStore for for MockDb
crates/router/src/db.rs
router
impl_block
null
null
null
44
null
MockDb
RequestIdStore for
0
0
null
null
// Implementation: impl ForeignIDRef for for PaymentAttempt // File: crates/hyperswitch_domain_models/src/payments/payment_attempt.rs // Module: hyperswitch_domain_models // Methods: 1 total (0 public) impl ForeignIDRef for for PaymentAttempt
crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
hyperswitch_domain_models
impl_block
null
null
null
55
null
PaymentAttempt
ForeignIDRef for
1
0
null
null
// Implementation: impl ConnectorSpecifications for for Gocardless // File: crates/hyperswitch_connectors/src/connectors/gocardless.rs // Module: hyperswitch_connectors // Methods: 4 total (0 public) impl ConnectorSpecifications for for Gocardless
crates/hyperswitch_connectors/src/connectors/gocardless.rs
hyperswitch_connectors
impl_block
null
null
null
56
null
Gocardless
ConnectorSpecifications for
4
0
null
null
// Implementation: impl api::PaymentSession for for Adyen // File: crates/hyperswitch_connectors/src/connectors/adyen.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::PaymentSession for for Adyen
crates/hyperswitch_connectors/src/connectors/adyen.rs
hyperswitch_connectors
impl_block
null
null
null
58
null
Adyen
api::PaymentSession for
0
0
null
null
// Implementation: impl MasterKeyInterface for for KafkaStore // File: crates/router/src/db/kafka_store.rs // Module: router // Methods: 1 total (0 public) impl MasterKeyInterface for for KafkaStore
crates/router/src/db/kafka_store.rs
router
impl_block
null
null
null
47
null
KafkaStore
MasterKeyInterface for
1
0
null
null
// Struct: SantanderCard // File: crates/hyperswitch_connectors/src/connectors/santander/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct SantanderCard
crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
hyperswitch_connectors
struct_definition
SantanderCard
0
[]
48
null
null
null
null
null
null
null
// Struct: NordeaErrorBody // File: crates/hyperswitch_connectors/src/connectors/nordea/responses.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct NordeaErrorBody
crates/hyperswitch_connectors/src/connectors/nordea/responses.rs
hyperswitch_connectors
struct_definition
NordeaErrorBody
0
[]
49
null
null
null
null
null
null
null
// File: crates/hyperswitch_connectors/src/connectors/nexixpay.rs // Module: hyperswitch_connectors // Public functions: 1 // Public structs: 1 pub mod transformers; use std::collections::HashSet; use common_enums::enums; use common_utils::{ errors::CustomResult, ext_traits::BytesExt, request::{Method, Request, RequestBuilder, RequestContent}, types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector}, }; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::{ payment_method_data::PaymentMethodData, router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, router_flow_types::{ access_token_auth::AccessTokenAuth, payments::{ Authorize, Capture, CompleteAuthorize, PSync, PaymentMethodToken, PreProcessing, Session, SetupMandate, Void, }, refunds::{Execute, RSync}, }, router_request_types::{ AccessTokenRequestData, CompleteAuthorizeData, PaymentMethodTokenizationData, PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsPreProcessingData, PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData, }, router_response_types::{ ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods, SupportedPaymentMethodsExt, }, types::{ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, PaymentsCompleteAuthorizeRouterData, PaymentsPreProcessingRouterData, PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData, SetupMandateRouterData, }, }; use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, types::{self, Response}, webhooks, }; use lazy_static::lazy_static; use masking::{ExposeInterface, Mask}; use serde_json::Value; use transformers as nexixpay; use uuid::Uuid; use crate::{ constants::headers, types::ResponseRouterData, utils::{self, PaymentMethodDataType, RefundsRequestData}, }; #[derive(Clone)] pub struct Nexixpay { amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync), } impl Nexixpay { pub fn new() -> &'static Self { &Self { amount_converter: &StringMinorUnitForConnector, } } } impl api::Payment for Nexixpay {} impl api::PaymentsPreProcessing for Nexixpay {} impl api::PaymentSession for Nexixpay {} impl api::ConnectorAccessToken for Nexixpay {} impl api::MandateSetup for Nexixpay {} impl api::PaymentAuthorize for Nexixpay {} impl api::PaymentSync for Nexixpay {} impl api::PaymentCapture for Nexixpay {} impl api::PaymentVoid for Nexixpay {} impl api::Refund for Nexixpay {} impl api::RefundExecute for Nexixpay {} impl api::RefundSync for Nexixpay {} impl api::PaymentToken for Nexixpay {} impl api::PaymentsCompleteAuthorize for Nexixpay {} impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData> for Nexixpay { // Not Implemented (R) } impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Nexixpay where Self: ConnectorIntegration<Flow, Request, Response>, { fn build_headers( &self, req: &RouterData<Flow, Request, Response>, _connectors: &Connectors, ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> { let mut header = vec![( headers::CONTENT_TYPE.to_string(), self.get_content_type().to_string().into(), )]; let mut api_key = self.get_auth_header(&req.connector_auth_type)?; header.append(&mut api_key); Ok(header) } } impl ConnectorCommon for Nexixpay { fn id(&self) -> &'static str { "nexixpay" } fn get_currency_unit(&self) -> api::CurrencyUnit { api::CurrencyUnit::Minor } fn common_get_content_type(&self) -> &'static str { "application/json" } fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str { connectors.nexixpay.base_url.as_ref() } fn get_auth_header( &self, auth_type: &ConnectorAuthType, ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> { let auth = nexixpay::NexixpayAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![ ( headers::X_API_KEY.to_string(), auth.api_key.expose().into_masked(), ), ( headers::CORRELATION_ID.to_string(), Uuid::new_v4().to_string().into_masked(), ), ]) } fn build_error_response( &self, res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult<ErrorResponse, errors::ConnectorError> { let response: nexixpay::NexixpayErrorResponse = match res.status_code { 401 => nexixpay::NexixpayErrorResponse { errors: vec![nexixpay::NexixpayErrorBody { code: Some(consts::NO_ERROR_CODE.to_string()), description: Some("UNAUTHORIZED".to_string()), }], }, 404 => nexixpay::NexixpayErrorResponse { errors: vec![nexixpay::NexixpayErrorBody { code: Some(consts::NO_ERROR_CODE.to_string()), description: Some("NOT FOUND".to_string()), }], }, _ => res .response .parse_struct("NexixpayErrorResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, }; let concatenated_descriptions: Option<String> = { let descriptions: Vec<String> = response .errors .iter() .filter_map(|error| error.description.as_ref()) .cloned() .collect(); if descriptions.is_empty() { None } else { Some(descriptions.join(", ")) } }; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); Ok(ErrorResponse { status_code: res.status_code, code: response .errors .first() .and_then(|error| error.code.clone()) .unwrap_or(consts::NO_ERROR_CODE.to_string()), message: response .errors .first() .and_then(|error| error.description.clone()) .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), reason: concatenated_descriptions, attempt_status: None, connector_transaction_id: None, network_advice_code: None, network_decline_code: None, network_error_message: None, connector_metadata: None, }) } } impl ConnectorValidation for Nexixpay { fn validate_mandate_payment( &self, pm_type: Option<enums::PaymentMethodType>, pm_data: PaymentMethodData, ) -> CustomResult<(), errors::ConnectorError> { let mandate_supported_pmd: HashSet<PaymentMethodDataType> = HashSet::from([PaymentMethodDataType::Card]); utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id()) } } impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Nexixpay {} impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Nexixpay {} impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData> for Nexixpay { fn get_headers( &self, req: &SetupMandateRouterData, connectors: &Connectors, ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> { self.build_headers(req, connectors) } fn get_content_type(&self) -> &'static str { self.common_get_content_type() } fn get_url( &self, _req: &SetupMandateRouterData, connectors: &Connectors, ) -> CustomResult<String, errors::ConnectorError> { Ok(format!("{}/orders/3steps/init", self.base_url(connectors))) } fn get_request_body( &self, req: &SetupMandateRouterData, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let authorize_req = utils::convert_payment_authorize_router_response(( req, utils::convert_setup_mandate_router_data_to_authorize_router_data(req), )); let amount = utils::convert_amount( self.amount_converter, authorize_req.request.minor_amount, authorize_req.request.currency, )?; let connector_router_data = nexixpay::NexixpayRouterData::from((amount, &authorize_req)); let connector_req = nexixpay::NexixpayPaymentsRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } fn build_request( &self, req: &SetupMandateRouterData, connectors: &Connectors, ) -> CustomResult<Option<Request>, errors::ConnectorError> { Ok(Some( RequestBuilder::new() .method(Method::Post) .url(&types::SetupMandateType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::SetupMandateType::get_headers(self, req, connectors)?) .set_body(types::SetupMandateType::get_request_body( self, req, connectors, )?) .build(), )) } fn handle_response( &self, data: &SetupMandateRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<SetupMandateRouterData, errors::ConnectorError> { let response: nexixpay::PaymentsResponse = res .response .parse_struct("PaymentsResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, }) } fn get_error_response( &self, res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult<ErrorResponse, errors::ConnectorError> { self.build_error_response(res, event_builder) } } impl ConnectorIntegration<PreProcessing, PaymentsPreProcessingData, PaymentsResponseData> for Nexixpay { fn get_headers( &self, req: &PaymentsPreProcessingRouterData, connectors: &Connectors, ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> { self.build_headers(req, connectors) } fn get_content_type(&self) -> &'static str { self.common_get_content_type() } fn get_url( &self, _req: &PaymentsPreProcessingRouterData, connectors: &Connectors, ) -> CustomResult<String, errors::ConnectorError> { Ok(format!( "{}/orders/3steps/validation", self.base_url(connectors) )) } fn get_request_body( &self, req: &PaymentsPreProcessingRouterData, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let connector_req = nexixpay::NexixpayPreProcessingRequest::try_from(req)?; Ok(RequestContent::Json(Box::new(connector_req))) } fn build_request( &self, req: &PaymentsPreProcessingRouterData, connectors: &Connectors, ) -> CustomResult<Option<Request>, errors::ConnectorError> { Ok(Some( RequestBuilder::new() .method(Method::Post) .url(&types::PaymentsPreProcessingType::get_url( self, req, connectors, )?) .attach_default_headers() .headers(types::PaymentsPreProcessingType::get_headers( self, req, connectors, )?) .set_body(types::PaymentsPreProcessingType::get_request_body( self, req, connectors, )?) .build(), )) } fn handle_response( &self, data: &PaymentsPreProcessingRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<PaymentsPreProcessingRouterData, errors::ConnectorError> { let response: nexixpay::NexixpayPreProcessingResponse = res .response .parse_struct("NexixpayPreProcessingResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, }) } fn get_error_response( &self, res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult<ErrorResponse, errors::ConnectorError> { self.build_error_response(res, event_builder) } } impl ConnectorIntegration<CompleteAuthorize, CompleteAuthorizeData, PaymentsResponseData> for Nexixpay { fn get_headers( &self, req: &PaymentsCompleteAuthorizeRouterData, connectors: &Connectors, ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> { self.build_headers(req, connectors) } fn get_content_type(&self) -> &'static str { self.common_get_content_type() } fn get_url( &self, _req: &PaymentsCompleteAuthorizeRouterData, connectors: &Connectors, ) -> CustomResult<String, errors::ConnectorError> { Ok(format!( "{}/orders/3steps/payment", self.base_url(connectors) )) } fn get_request_body( &self, req: &PaymentsCompleteAuthorizeRouterData, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let amount = utils::convert_amount( self.amount_converter, req.request.minor_amount, req.request.currency, )?; let connector_router_data = nexixpay::NexixpayRouterData::from((amount, req)); let connector_req = nexixpay::NexixpayCompleteAuthorizeRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } fn build_request( &self, req: &PaymentsCompleteAuthorizeRouterData, connectors: &Connectors, ) -> CustomResult<Option<Request>, errors::ConnectorError> { Ok(Some( RequestBuilder::new() .method(Method::Post) .url(&types::PaymentsCompleteAuthorizeType::get_url( self, req, connectors, )?) .attach_default_headers() .headers(types::PaymentsCompleteAuthorizeType::get_headers( self, req, connectors, )?) .set_body(types::PaymentsCompleteAuthorizeType::get_request_body( self, req, connectors, )?) .build(), )) } fn handle_response( &self, data: &PaymentsCompleteAuthorizeRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<PaymentsCompleteAuthorizeRouterData, errors::ConnectorError> { let response: nexixpay::NexixpayCompleteAuthorizeResponse = res .response .parse_struct("NexixpayCompleteAuthorizeResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, }) } fn get_error_response( &self, res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult<ErrorResponse, errors::ConnectorError> { self.build_error_response(res, event_builder) } } impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Nexixpay { fn get_headers( &self, req: &PaymentsAuthorizeRouterData, connectors: &Connectors, ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> { self.build_headers(req, connectors) } fn get_content_type(&self) -> &'static str { self.common_get_content_type() } fn get_url( &self, req: &PaymentsAuthorizeRouterData, connectors: &Connectors, ) -> CustomResult<String, errors::ConnectorError> { if req.request.off_session == Some(true) { Ok(format!("{}/orders/mit", self.base_url(connectors))) } else { Ok(format!("{}/orders/3steps/init", self.base_url(connectors))) } } fn get_request_body( &self, req: &PaymentsAuthorizeRouterData, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let amount = utils::convert_amount( self.amount_converter, req.request.minor_amount, req.request.currency, )?; let connector_router_data = nexixpay::NexixpayRouterData::from((amount, req)); let connector_req = nexixpay::NexixpayPaymentsRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } fn build_request( &self, req: &PaymentsAuthorizeRouterData, connectors: &Connectors, ) -> CustomResult<Option<Request>, errors::ConnectorError> { Ok(Some( RequestBuilder::new() .method(Method::Post) .url(&types::PaymentsAuthorizeType::get_url( self, req, connectors, )?) .attach_default_headers() .headers(types::PaymentsAuthorizeType::get_headers( self, req, connectors, )?) .set_body(types::PaymentsAuthorizeType::get_request_body( self, req, connectors, )?) .build(), )) } fn handle_response( &self, data: &PaymentsAuthorizeRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> { let response: nexixpay::NexixpayPaymentsResponse = res .response .parse_struct("NexixpayPaymentsResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, }) } fn get_error_response( &self, res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult<ErrorResponse, errors::ConnectorError> { self.build_error_response(res, event_builder) } } impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Nexixpay { fn get_headers( &self, req: &PaymentsSyncRouterData, connectors: &Connectors, ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> { self.build_headers(req, connectors) } fn get_content_type(&self) -> &'static str { self.common_get_content_type() } fn get_url( &self, req: &PaymentsSyncRouterData, connectors: &Connectors, ) -> CustomResult<String, errors::ConnectorError> { let connector_payment_id = get_payment_id((req.request.connector_meta.clone(), None))?; Ok(format!( "{}/operations/{}", self.base_url(connectors), connector_payment_id )) } fn build_request( &self, req: &PaymentsSyncRouterData, connectors: &Connectors, ) -> CustomResult<Option<Request>, errors::ConnectorError> { Ok(Some( RequestBuilder::new() .method(Method::Get) .url(&types::PaymentsSyncType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?) .build(), )) } fn handle_response( &self, data: &PaymentsSyncRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> { let response: nexixpay::NexixpayTransactionResponse = res .response .parse_struct("NexixpayTransactionResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, }) } fn get_error_response( &self, res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult<ErrorResponse, errors::ConnectorError> { self.build_error_response(res, event_builder) } } fn get_payment_id( (metadata, payment_intent): (Option<Value>, Option<nexixpay::NexixpayPaymentIntent>), ) -> CustomResult<String, errors::ConnectorError> { let connector_metadata = metadata.ok_or(errors::ConnectorError::MissingRequiredField { field_name: "connector_meta", })?; let nexixpay_meta_data = serde_json::from_value::<nexixpay::NexixpayConnectorMetaData>(connector_metadata) .change_context(errors::ConnectorError::ParsingFailed)?; let payment_flow = payment_intent.unwrap_or(nexixpay_meta_data.psync_flow); let payment_id = match payment_flow { nexixpay::NexixpayPaymentIntent::Cancel => nexixpay_meta_data.cancel_operation_id, nexixpay::NexixpayPaymentIntent::Capture => nexixpay_meta_data.capture_operation_id, nexixpay::NexixpayPaymentIntent::Authorize => nexixpay_meta_data.authorization_operation_id, }; payment_id.ok_or_else(|| { errors::ConnectorError::MissingRequiredField { field_name: "operation_id", } .into() }) } impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Nexixpay { fn get_headers( &self, req: &PaymentsCaptureRouterData, _connectors: &Connectors, ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> { let mut header = vec![( headers::IDEMPOTENCY_KEY.to_string(), Uuid::new_v4().to_string().into_masked(), )]; let mut api_key = self.get_auth_header(&req.connector_auth_type)?; header.append(&mut api_key); Ok(header) } fn get_content_type(&self) -> &'static str { self.common_get_content_type() } fn get_url( &self, req: &PaymentsCaptureRouterData, connectors: &Connectors, ) -> CustomResult<String, errors::ConnectorError> { let connector_payment_id = get_payment_id(( req.request.connector_meta.clone(), Some(nexixpay::NexixpayPaymentIntent::Authorize), ))?; Ok(format!( "{}/operations/{}/captures", self.base_url(connectors), connector_payment_id )) } fn get_request_body( &self, req: &PaymentsCaptureRouterData, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let amount = utils::convert_amount( self.amount_converter, req.request.minor_amount_to_capture, req.request.currency, )?; let connector_router_data = nexixpay::NexixpayRouterData::from((amount, req)); let connector_req = nexixpay::NexixpayPaymentsCaptureRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } fn build_request( &self, req: &PaymentsCaptureRouterData, connectors: &Connectors, ) -> CustomResult<Option<Request>, errors::ConnectorError> { Ok(Some( RequestBuilder::new() .method(Method::Post) .url(&types::PaymentsCaptureType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::PaymentsCaptureType::get_headers( self, req, connectors, )?) .set_body(types::PaymentsCaptureType::get_request_body( self, req, connectors, )?) .build(), )) } fn handle_response( &self, data: &PaymentsCaptureRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> { let response: nexixpay::NexixpayOperationResponse = res .response .parse_struct("NexixpayOperationResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, }) } fn get_error_response( &self, res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult<ErrorResponse, errors::ConnectorError> { self.build_error_response(res, event_builder) } } impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Nexixpay { fn get_headers( &self, req: &PaymentsCancelRouterData, _connectors: &Connectors, ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> { let mut header = vec![( headers::IDEMPOTENCY_KEY.to_string(), Uuid::new_v4().to_string().into_masked(), )]; let mut api_key = self.get_auth_header(&req.connector_auth_type)?; header.append(&mut api_key); Ok(header) } fn get_content_type(&self) -> &'static str { self.common_get_content_type() } fn get_url( &self, req: &PaymentsCancelRouterData, connectors: &Connectors, ) -> CustomResult<String, errors::ConnectorError> { let connector_payment_id = get_payment_id(( req.request.connector_meta.clone(), Some(nexixpay::NexixpayPaymentIntent::Authorize), ))?; Ok(format!( "{}/operations/{}/refunds", self.base_url(connectors), connector_payment_id )) } fn get_request_body( &self, req: &PaymentsCancelRouterData, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let minor_amount = req.request .minor_amount .ok_or(errors::ConnectorError::MissingRequiredField { field_name: "amount", })?; let currency = req.request .currency .ok_or(errors::ConnectorError::MissingRequiredField { field_name: "currency", })?; let amount = utils::convert_amount(self.amount_converter, minor_amount, currency)?; let connector_router_data = nexixpay::NexixpayRouterData::from((amount, req)); let connector_req = nexixpay::NexixpayPaymentsCancelRequest::try_from(connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } fn build_request( &self, req: &PaymentsCancelRouterData, connectors: &Connectors, ) -> CustomResult<Option<Request>, errors::ConnectorError> { Ok(Some( RequestBuilder::new() .method(Method::Post) .url(&types::PaymentsVoidType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::PaymentsVoidType::get_headers(self, req, connectors)?) .set_body(types::PaymentsVoidType::get_request_body( self, req, connectors, )?) .build(), )) } fn handle_response( &self, data: &PaymentsCancelRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<PaymentsCancelRouterData, errors::ConnectorError> { let response: nexixpay::NexixpayOperationResponse = res .response .parse_struct("NexixpayOperationResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, }) } fn get_error_response( &self, res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult<ErrorResponse, errors::ConnectorError> { self.build_error_response(res, event_builder) } } impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Nexixpay { fn get_headers( &self, req: &RefundsRouterData<Execute>, _connectors: &Connectors, ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> { let mut header = vec![( headers::IDEMPOTENCY_KEY.to_string(), Uuid::new_v4().to_string().into_masked(), )]; let mut api_key = self.get_auth_header(&req.connector_auth_type)?; header.append(&mut api_key); Ok(header) } fn get_content_type(&self) -> &'static str { self.common_get_content_type() } fn get_url( &self, req: &RefundsRouterData<Execute>, connectors: &Connectors, ) -> CustomResult<String, errors::ConnectorError> { let connector_payment_id = get_payment_id(( req.request.connector_metadata.clone(), Some(nexixpay::NexixpayPaymentIntent::Capture), ))?; Ok(format!( "{}/operations/{}/refunds", self.base_url(connectors), connector_payment_id )) } fn get_request_body( &self, req: &RefundsRouterData<Execute>, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let refund_amount = utils::convert_amount( self.amount_converter, req.request.minor_refund_amount, req.request.currency, )?; let connector_router_data = nexixpay::NexixpayRouterData::from((refund_amount, req)); let connector_req = nexixpay::NexixpayRefundRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } fn build_request( &self, req: &RefundsRouterData<Execute>, connectors: &Connectors, ) -> CustomResult<Option<Request>, errors::ConnectorError> { let request = RequestBuilder::new() .method(Method::Post) .url(&types::RefundExecuteType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::RefundExecuteType::get_headers( self, req, connectors, )?) .set_body(types::RefundExecuteType::get_request_body( self, req, connectors, )?) .build(); Ok(Some(request)) } fn handle_response( &self, data: &RefundsRouterData<Execute>, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> { let response: nexixpay::RefundResponse = res .response .parse_struct("RefundResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, }) } fn get_error_response( &self, res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult<ErrorResponse, errors::ConnectorError> { self.build_error_response(res, event_builder) } } impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Nexixpay { fn get_headers( &self, req: &RefundSyncRouterData, connectors: &Connectors, ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> { self.build_headers(req, connectors) } fn get_content_type(&self) -> &'static str { self.common_get_content_type() } fn get_url( &self, req: &RefundSyncRouterData, connectors: &Connectors, ) -> CustomResult<String, errors::ConnectorError> { let connector_refund_id = req.request.get_connector_refund_id()?; Ok(format!( "{}/operations/{}", self.base_url(connectors), connector_refund_id )) } fn build_request( &self, req: &RefundSyncRouterData, connectors: &Connectors, ) -> CustomResult<Option<Request>, errors::ConnectorError> { Ok(Some( RequestBuilder::new() .method(Method::Get) .url(&types::RefundSyncType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::RefundSyncType::get_headers(self, req, connectors)?) .set_body(types::RefundSyncType::get_request_body( self, req, connectors, )?) .build(), )) } fn handle_response( &self, data: &RefundSyncRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> { let response: nexixpay::NexixpayRSyncResponse = res .response .parse_struct("NexixpayRSyncResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, }) } fn get_error_response( &self, res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult<ErrorResponse, errors::ConnectorError> { self.build_error_response(res, event_builder) } } #[async_trait::async_trait] impl webhooks::IncomingWebhook for Nexixpay { fn get_webhook_object_reference_id( &self, _request: &webhooks::IncomingWebhookRequestDetails<'_>, ) -> CustomResult<api_models::webhooks::ObjectReferenceId, errors::ConnectorError> { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &webhooks::IncomingWebhookRequestDetails<'_>, ) -> CustomResult<api_models::webhooks::IncomingWebhookEvent, errors::ConnectorError> { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &webhooks::IncomingWebhookRequestDetails<'_>, ) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> { Err(report!(errors::ConnectorError::WebhooksNotImplemented))
crates/hyperswitch_connectors/src/connectors/nexixpay.rs#chunk0
hyperswitch_connectors
chunk
null
null
null
8,192
null
null
null
null
null
null
null
// Function: delete_payment_method_data_from_vault // File: crates/router/src/core/payment_methods/vault.rs // Module: router pub fn delete_payment_method_data_from_vault( state: &routes::SessionState, merchant_context: &domain::MerchantContext, profile: &domain::Profile, pm: &domain::PaymentMethod, ) -> RouterResult<pm_types::VaultDeleteResponse>
crates/router/src/core/payment_methods/vault.rs
router
function_signature
null
null
null
87
delete_payment_method_data_from_vault
null
null
null
null
null
null
// Function: derive_to_encryption_attr // File: crates/router_derive/src/lib.rs // Module: router_derive pub fn derive_to_encryption_attr(input: proc_macro::TokenStream) -> proc_macro::TokenStream
crates/router_derive/src/lib.rs
router_derive
function_signature
null
null
null
48
derive_to_encryption_attr
null
null
null
null
null
null
// Struct: RefundData // File: crates/hyperswitch_connectors/src/connectors/braintree/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct RefundData
crates/hyperswitch_connectors/src/connectors/braintree/transformers.rs
hyperswitch_connectors
struct_definition
RefundData
0
[]
48
null
null
null
null
null
null
null
// Struct: FiservResponseInteractions // File: crates/hyperswitch_connectors/src/connectors/fiserv/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct FiservResponseInteractions
crates/hyperswitch_connectors/src/connectors/fiserv/transformers.rs
hyperswitch_connectors
struct_definition
FiservResponseInteractions
0
[]
54
null
null
null
null
null
null
null
// Implementation: impl api::PaymentToken for for Payload // File: crates/hyperswitch_connectors/src/connectors/payload.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::PaymentToken for for Payload
crates/hyperswitch_connectors/src/connectors/payload.rs
hyperswitch_connectors
impl_block
null
null
null
55
null
Payload
api::PaymentToken for
0
0
null
null
// Function: add_top_n_clause // File: crates/analytics/src/query.rs // Module: analytics pub fn add_top_n_clause( &mut self, columns: &[impl ToSql<T>], count: u64, order_column: impl ToSql<T>, order: Order, ) -> QueryResult<()> where Window<&'static str>: ToSql<T>,
crates/analytics/src/query.rs
analytics
function_signature
null
null
null
87
add_top_n_clause
null
null
null
null
null
null
// File: crates/hyperswitch_connectors/src/connectors/signifyd/transformers.rs // Module: hyperswitch_connectors #[cfg(feature = "frm")] pub mod api; pub mod auth; #[cfg(feature = "frm")] pub use self::api::*; pub use self::auth::*;
crates/hyperswitch_connectors/src/connectors/signifyd/transformers.rs
hyperswitch_connectors
full_file
null
null
null
63
null
null
null
null
null
null
null
// Implementation: impl KafkaMessage for for KafkaEvent // File: crates/router/src/services/kafka.rs // Module: router // Methods: 3 total (0 public) impl KafkaMessage for for KafkaEvent
crates/router/src/services/kafka.rs
router
impl_block
null
null
null
44
null
KafkaEvent
KafkaMessage for
3
0
null
null
// Function: payments_redirect_response // File: crates/router/src/routes/payments.rs // Module: router pub fn payments_redirect_response( state: web::Data<app::AppState>, req: actix_web::HttpRequest, json_payload: Option<web::Form<serde_json::Value>>, path: web::Path<( common_utils::id_type::PaymentId, common_utils::id_type::MerchantId, String, )
crates/router/src/routes/payments.rs
router
function_signature
null
null
null
97
payments_redirect_response
null
null
null
null
null
null
// Function: get_frm_config_as_secret // File: crates/router/src/core/admin.rs // Module: router pub fn get_frm_config_as_secret( frm_configs: Option<Vec<api_models::admin::FrmConfigs>>, ) -> Option<Vec<Secret<serde_json::Value>>>
crates/router/src/core/admin.rs
router
function_signature
null
null
null
60
get_frm_config_as_secret
null
null
null
null
null
null
// Struct: NordeaOAuthExchangeRequest // File: crates/hyperswitch_connectors/src/connectors/nordea/requests.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct NordeaOAuthExchangeRequest
crates/hyperswitch_connectors/src/connectors/nordea/requests.rs
hyperswitch_connectors
struct_definition
NordeaOAuthExchangeRequest
0
[]
51
null
null
null
null
null
null
null
// Struct: AuthipayGatewayResponse // File: crates/hyperswitch_connectors/src/connectors/authipay/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct AuthipayGatewayResponse
crates/hyperswitch_connectors/src/connectors/authipay/transformers.rs
hyperswitch_connectors
struct_definition
AuthipayGatewayResponse
0
[]
49
null
null
null
null
null
null
null
// Implementation: impl ConnectorCommon for for Threedsecureio // File: crates/hyperswitch_connectors/src/connectors/threedsecureio.rs // Module: hyperswitch_connectors // Methods: 6 total (0 public) impl ConnectorCommon for for Threedsecureio
crates/hyperswitch_connectors/src/connectors/threedsecureio.rs
hyperswitch_connectors
impl_block
null
null
null
59
null
Threedsecureio
ConnectorCommon for
6
0
null
null
// Struct: Payme // File: crates/hyperswitch_connectors/src/connectors/payme.rs // Module: hyperswitch_connectors // Implementations: 20 // Traits: api::Payment, api::PaymentSession, api::PaymentsCompleteAuthorize, api::ConnectorAccessToken, api::MandateSetup, api::PaymentAuthorize, api::PaymentSync, api::PaymentCapture, api::PaymentVoid, api::Refund, api::RefundExecute, api::RefundSync, api::PaymentToken, ConnectorCommon, ConnectorValidation, PaymentsPreProcessing, ConnectorRedirectResponse, webhooks::IncomingWebhook, ConnectorSpecifications pub struct Payme
crates/hyperswitch_connectors/src/connectors/payme.rs
hyperswitch_connectors
struct_definition
Payme
20
[ "api::Payment", "api::PaymentSession", "api::PaymentsCompleteAuthorize", "api::ConnectorAccessToken", "api::MandateSetup", "api::PaymentAuthorize", "api::PaymentSync", "api::PaymentCapture", "api::PaymentVoid", "api::Refund", "api::RefundExecute", "api::RefundSync", "api::PaymentToken", "ConnectorCommon", "ConnectorValidation", "PaymentsPreProcessing", "ConnectorRedirectResponse", "webhooks::IncomingWebhook", "ConnectorSpecifications" ]
139
null
null
null
null
null
null
null
// File: crates/router/src/core/payments/operations/payment_create_intent.rs // Module: router // Public structs: 1 use std::marker::PhantomData; use api_models::{enums::FrmSuggestion, payments::PaymentsCreateIntentRequest}; use async_trait::async_trait; use common_utils::{ errors::CustomResult, ext_traits::Encode, types::{authentication, keymanager::ToEncryptable}, }; use error_stack::ResultExt; use masking::PeekInterface; use router_env::{instrument, tracing}; use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest}; use crate::{ core::{ errors::{self, RouterResult, StorageErrorExt}, payments::{self, helpers, operations}, }, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; #[derive(Debug, Clone, Copy)] pub struct PaymentIntentCreate; impl<F: Send + Clone + Sync> Operation<F, PaymentsCreateIntentRequest> for &PaymentIntentCreate { type Data = payments::PaymentIntentData<F>; fn to_validate_request( &self, ) -> RouterResult< &(dyn ValidateRequest<F, PaymentsCreateIntentRequest, Self::Data> + Send + Sync), > { Ok(*self) } fn to_get_tracker( &self, ) -> RouterResult<&(dyn GetTracker<F, Self::Data, PaymentsCreateIntentRequest> + Send + Sync)> { Ok(*self) } fn to_domain(&self) -> RouterResult<&(dyn Domain<F, PaymentsCreateIntentRequest, Self::Data>)> { Ok(*self) } fn to_update_tracker( &self, ) -> RouterResult<&(dyn UpdateTracker<F, Self::Data, PaymentsCreateIntentRequest> + Send + Sync)> { Ok(*self) } } impl<F: Send + Clone + Sync> Operation<F, PaymentsCreateIntentRequest> for PaymentIntentCreate { type Data = payments::PaymentIntentData<F>; fn to_validate_request( &self, ) -> RouterResult< &(dyn ValidateRequest<F, PaymentsCreateIntentRequest, Self::Data> + Send + Sync), > { Ok(self) } fn to_get_tracker( &self, ) -> RouterResult<&(dyn GetTracker<F, Self::Data, PaymentsCreateIntentRequest> + Send + Sync)> { Ok(self) } fn to_domain(&self) -> RouterResult<&dyn Domain<F, PaymentsCreateIntentRequest, Self::Data>> { Ok(self) } fn to_update_tracker( &self, ) -> RouterResult<&(dyn UpdateTracker<F, Self::Data, PaymentsCreateIntentRequest> + Send + Sync)> { Ok(self) } } type PaymentsCreateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsCreateIntentRequest, payments::PaymentIntentData<F>>; #[async_trait] impl<F: Send + Clone + Sync> GetTracker<F, payments::PaymentIntentData<F>, PaymentsCreateIntentRequest> for PaymentIntentCreate { #[instrument(skip_all)] async fn get_trackers<'a>( &'a self, state: &'a SessionState, payment_id: &common_utils::id_type::GlobalPaymentId, request: &PaymentsCreateIntentRequest, merchant_context: &domain::MerchantContext, profile: &domain::Profile, _header_payload: &hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<operations::GetTrackerResponse<payments::PaymentIntentData<F>>> { let db = &*state.store; if let Some(routing_algorithm_id) = request.routing_algorithm_id.as_ref() { helpers::validate_routing_id_with_profile_id( db, routing_algorithm_id, profile.get_id(), ) .await?; } let key_manager_state = &state.into(); let storage_scheme = merchant_context.get_merchant_account().storage_scheme; let batch_encrypted_data = domain_types::crypto_operation( key_manager_state, common_utils::type_name!(hyperswitch_domain_models::payments::PaymentIntent), domain_types::CryptoOperation::BatchEncrypt( hyperswitch_domain_models::payments::FromRequestEncryptablePaymentIntent::to_encryptable( hyperswitch_domain_models::payments::FromRequestEncryptablePaymentIntent { shipping_address: request.shipping.clone().map(|address| address.encode_to_value()).transpose().change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to encode shipping address")?.map(masking::Secret::new), billing_address: request.billing.clone().map(|address| address.encode_to_value()).transpose().change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to encode billing address")?.map(masking::Secret::new), customer_details: None, }, ), ), common_utils::types::keymanager::Identifier::Merchant(merchant_context.get_merchant_account().get_id().to_owned()), merchant_context.get_merchant_key_store().key.peek(), ) .await .and_then(|val| val.try_into_batchoperation()) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed while encrypting payment intent details".to_string())?; let encrypted_data = hyperswitch_domain_models::payments::FromRequestEncryptablePaymentIntent::from_encryptable(batch_encrypted_data) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed while encrypting payment intent details")?; let payment_intent_domain = hyperswitch_domain_models::payments::PaymentIntent::create_domain_model_from_request( payment_id, merchant_context, profile, request.clone(), encrypted_data, ) .await?; let payment_intent = db .insert_payment_intent( key_manager_state, payment_intent_domain, merchant_context.get_merchant_key_store(), storage_scheme, ) .await .to_duplicate_response(errors::ApiErrorResponse::GenericDuplicateError { message: format!( "Payment Intent with payment_id {} already exists", payment_id.get_string_repr() ), }) .attach_printable("failed while inserting new payment intent")?; let client_secret = helpers::create_client_secret( state, merchant_context.get_merchant_account().get_id(), authentication::ResourceId::Payment(payment_id.clone()), ) .await .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to create client secret")?; let payment_data = payments::PaymentIntentData { flow: PhantomData, payment_intent, client_secret: Some(client_secret.secret), sessions_token: vec![], vault_session_details: None, connector_customer_id: None, }; let get_trackers_response = operations::GetTrackerResponse { payment_data }; Ok(get_trackers_response) } } #[async_trait] impl<F: Clone + Sync> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsCreateIntentRequest> for PaymentIntentCreate { #[instrument(skip_all)] async fn update_trackers<'b>( &'b self, _state: &'b SessionState, _req_state: ReqState, payment_data: payments::PaymentIntentData<F>, _customer: Option<domain::Customer>, _storage_scheme: enums::MerchantStorageScheme, _updated_customer: Option<storage::CustomerUpdate>, _key_store: &domain::MerchantKeyStore, _frm_suggestion: Option<FrmSuggestion>, _header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<( PaymentsCreateIntentOperation<'b, F>, payments::PaymentIntentData<F>, )> where F: 'b + Send, { Ok((Box::new(self), payment_data)) } } impl<F: Send + Clone> ValidateRequest<F, PaymentsCreateIntentRequest, payments::PaymentIntentData<F>> for PaymentIntentCreate { #[instrument(skip_all)] fn validate_request<'a, 'b>( &'b self, _request: &PaymentsCreateIntentRequest, merchant_context: &'a domain::MerchantContext, ) -> RouterResult<operations::ValidateResult> { Ok(operations::ValidateResult { merchant_id: merchant_context.get_merchant_account().get_id().to_owned(), storage_scheme: merchant_context.get_merchant_account().storage_scheme, requeue: false, }) } } #[async_trait] impl<F: Clone + Send + Sync> Domain<F, PaymentsCreateIntentRequest, payments::PaymentIntentData<F>> for PaymentIntentCreate { #[instrument(skip_all)] async fn get_customer_details<'a>( &'a self, state: &SessionState, payment_data: &mut payments::PaymentIntentData<F>, merchant_key_store: &domain::MerchantKeyStore, storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult< ( BoxedOperation<'a, F, PaymentsCreateIntentRequest, payments::PaymentIntentData<F>>, Option<domain::Customer>, ), errors::StorageError, > { // validate customer_id if sent in the request if let Some(id) = payment_data.payment_intent.customer_id.clone() { state .store .find_customer_by_global_id(&state.into(), &id, merchant_key_store, storage_scheme) .await?; } Ok((Box::new(self), None)) } #[instrument(skip_all)] async fn make_pm_data<'a>( &'a self, _state: &'a SessionState, _payment_data: &mut payments::PaymentIntentData<F>, _storage_scheme: enums::MerchantStorageScheme, _merchant_key_store: &domain::MerchantKeyStore, _customer: &Option<domain::Customer>, _business_profile: &domain::Profile, _should_retry_with_pan: bool, ) -> RouterResult<( PaymentsCreateIntentOperation<'a, F>, Option<domain::PaymentMethodData>, Option<String>, )> { Ok((Box::new(self), None, None)) } #[instrument(skip_all)] async fn perform_routing<'a>( &'a self, merchant_context: &domain::MerchantContext, business_profile: &domain::Profile, state: &SessionState, // TODO: do not take the whole payment data here payment_data: &mut payments::PaymentIntentData<F>, ) -> CustomResult<api::ConnectorCallType, errors::ApiErrorResponse> { Ok(api::ConnectorCallType::Skip) } #[instrument(skip_all)] async fn guard_payment_against_blocklist<'a>( &'a self, _state: &SessionState, _merchant_context: &domain::MerchantContext, _payment_data: &mut payments::PaymentIntentData<F>, ) -> CustomResult<bool, errors::ApiErrorResponse> { Ok(false) } }
crates/router/src/core/payments/operations/payment_create_intent.rs
router
full_file
null
null
null
2,379
null
null
null
null
null
null
null
// Function: create_specific_dynamic_routing_setup // File: crates/router/src/core/routing/helpers.rs // Module: router pub fn create_specific_dynamic_routing_setup( state: &SessionState, key_store: domain::MerchantKeyStore, business_profile: domain::Profile, feature_to_enable: routing_types::DynamicRoutingFeatures, mut dynamic_routing_algo_ref: routing_types::DynamicRoutingAlgorithmRef, dynamic_routing_type: routing_types::DynamicRoutingType, payload: routing_types::DynamicRoutingPayload, ) -> RouterResult<ApplicationResponse<routing_types::RoutingDictionaryRecord>>
crates/router/src/core/routing/helpers.rs
router
function_signature
null
null
null
122
create_specific_dynamic_routing_setup
null
null
null
null
null
null
// Struct: ListUsersInEntityResponse // File: crates/api_models/src/user_role.rs // Module: api_models // Implementations: 0 pub struct ListUsersInEntityResponse
crates/api_models/src/user_role.rs
api_models
struct_definition
ListUsersInEntityResponse
0
[]
40
null
null
null
null
null
null
null
// Struct: PaypalNetworkTransactionReference // File: crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct PaypalNetworkTransactionReference
crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
hyperswitch_connectors
struct_definition
PaypalNetworkTransactionReference
0
[]
49
null
null
null
null
null
null
null
// File: crates/payment_methods/src/core/errors.rs // Module: payment_methods pub use common_utils::errors::{CustomResult, ParsingError, ValidationError}; pub use hyperswitch_domain_models::{ api, errors::api_error_response::{self, *}, }; pub type PmResult<T> = CustomResult<T, ApiErrorResponse>; pub type PmResponse<T> = CustomResult<api::ApplicationResponse<T>, ApiErrorResponse>; pub type VaultResult<T> = CustomResult<T, VaultError>; #[derive(Debug, thiserror::Error)] pub enum VaultError { #[error("Failed to save card in card vault")] SaveCardFailed, #[error("Failed to fetch card details from card vault")] FetchCardFailed, #[error("Failed to delete card in card vault")] DeleteCardFailed, #[error("Failed to encode card vault request")] RequestEncodingFailed, #[error("Failed to deserialize card vault response")] ResponseDeserializationFailed, #[error("Failed to create payment method")] PaymentMethodCreationFailed, #[error("The given payment method is currently not supported in vault")] PaymentMethodNotSupported, #[error("The given payout method is currently not supported in vault")] PayoutMethodNotSupported, #[error("Missing required field: {field_name}")] MissingRequiredField { field_name: &'static str }, #[error("The card vault returned an unexpected response: {0:?}")] UnexpectedResponseError(bytes::Bytes), #[error("Failed to update in PMD table")] UpdateInPaymentMethodDataTableFailed, #[error("Failed to fetch payment method in vault")] FetchPaymentMethodFailed, #[error("Failed to save payment method in vault")] SavePaymentMethodFailed, #[error("Failed to generate fingerprint")] GenerateFingerprintFailed, #[error("Failed to encrypt vault request")] RequestEncryptionFailed, #[error("Failed to decrypt vault response")] ResponseDecryptionFailed, #[error("Failed to call vault")] VaultAPIError, #[error("Failed while calling locker API")] ApiError, }
crates/payment_methods/src/core/errors.rs
payment_methods
full_file
null
null
null
440
null
null
null
null
null
null
null
// Implementation: impl api::ConnectorAccessToken for for Opennode // File: crates/hyperswitch_connectors/src/connectors/opennode.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::ConnectorAccessToken for for Opennode
crates/hyperswitch_connectors/src/connectors/opennode.rs
hyperswitch_connectors
impl_block
null
null
null
59
null
Opennode
api::ConnectorAccessToken for
0
0
null
null
// Struct: ChargebeePaymentMethodDetails // File: crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct ChargebeePaymentMethodDetails
crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs
hyperswitch_connectors
struct_definition
ChargebeePaymentMethodDetails
0
[]
52
null
null
null
null
null
null
null
// Implementation: impl ErrorResponse // File: crates/hyperswitch_domain_models/src/router_data.rs // Module: hyperswitch_domain_models // Methods: 1 total (1 public) impl ErrorResponse
crates/hyperswitch_domain_models/src/router_data.rs
hyperswitch_domain_models
impl_block
null
null
null
41
null
ErrorResponse
null
1
1
null
null
// Function: get_error_message // File: crates/hyperswitch_connectors/src/connectors/trustpayments/transformers.rs // Module: hyperswitch_connectors pub fn get_error_message(&self) -> String
crates/hyperswitch_connectors/src/connectors/trustpayments/transformers.rs
hyperswitch_connectors
function_signature
null
null
null
46
get_error_message
null
null
null
null
null
null
// Function: add_select_column // File: crates/analytics/src/query.rs // Module: analytics pub fn add_select_column(&mut self, column: impl ToSql<T>) -> QueryResult<()>
crates/analytics/src/query.rs
analytics
function_signature
null
null
null
42
add_select_column
null
null
null
null
null
null
// Implementation: impl ConnectorValidation for for Globepay // File: crates/hyperswitch_connectors/src/connectors/globepay.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl ConnectorValidation for for Globepay
crates/hyperswitch_connectors/src/connectors/globepay.rs
hyperswitch_connectors
impl_block
null
null
null
57
null
Globepay
ConnectorValidation for
0
0
null
null
// File: crates/router/src/core/webhooks.rs // Module: router #[cfg(feature = "v1")] pub mod incoming; #[cfg(feature = "v2")] mod incoming_v2; #[cfg(feature = "v1")] mod network_tokenization_incoming; #[cfg(feature = "v1")] mod outgoing; #[cfg(feature = "v2")] mod outgoing_v2; #[cfg(all(feature = "revenue_recovery", feature = "v2"))] pub mod recovery_incoming; pub mod types; pub mod utils; #[cfg(feature = "olap")] pub mod webhook_events; #[cfg(feature = "v1")] pub(crate) use self::{ incoming::{incoming_webhooks_wrapper, network_token_incoming_webhooks_wrapper}, outgoing::{ create_event_and_trigger_outgoing_webhook, get_outgoing_webhook_request, trigger_webhook_and_raise_event, }, }; #[cfg(feature = "v2")] pub(crate) use self::{ incoming_v2::incoming_webhooks_wrapper, outgoing_v2::create_event_and_trigger_outgoing_webhook, }; const MERCHANT_ID: &str = "merchant_id";
crates/router/src/core/webhooks.rs
router
full_file
null
null
null
235
null
null
null
null
null
null
null
// Struct: CalSuccessRateEventRequest // File: crates/router/src/core/payments/routing/utils.rs // Module: router // Implementations: 0 pub struct CalSuccessRateEventRequest
crates/router/src/core/payments/routing/utils.rs
router
struct_definition
CalSuccessRateEventRequest
0
[]
42
null
null
null
null
null
null
null
// Function: perform_session_flow_routing // File: crates/router/src/core/payments/routing.rs // Module: router pub fn perform_session_flow_routing( session_input: SessionFlowRoutingInput<'_>, business_profile: &domain::Profile, transaction_type: &api_enums::TransactionType, ) -> RoutingResult<( FxHashMap<api_enums::PaymentMethodType, Vec<routing_types::SessionRoutingChoice>>, Option<common_enums::RoutingApproach>, )>
crates/router/src/core/payments/routing.rs
router
function_signature
null
null
null
105
perform_session_flow_routing
null
null
null
null
null
null
// Struct: RefundResponse // File: crates/hyperswitch_connectors/src/connectors/zen/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct RefundResponse
crates/hyperswitch_connectors/src/connectors/zen/transformers.rs
hyperswitch_connectors
struct_definition
RefundResponse
0
[]
47
null
null
null
null
null
null
null
// Function: delete_payment_method_data_from_vault_external // File: crates/router/src/core/payment_methods/vault.rs // Module: router pub fn delete_payment_method_data_from_vault_external( state: &routes::SessionState, merchant_account: &domain::MerchantAccount, merchant_connector_account: domain::MerchantConnectorAccountTypeDetails, vault_id: domain::VaultId, customer_id: &id_type::GlobalCustomerId, ) -> RouterResult<pm_types::VaultDeleteResponse>
crates/router/src/core/payment_methods/vault.rs
router
function_signature
null
null
null
105
delete_payment_method_data_from_vault_external
null
null
null
null
null
null
// Implementation: impl api::RefundSync for for Fiservemea // File: crates/hyperswitch_connectors/src/connectors/fiservemea.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::RefundSync for for Fiservemea
crates/hyperswitch_connectors/src/connectors/fiservemea.rs
hyperswitch_connectors
impl_block
null
null
null
68
null
Fiservemea
api::RefundSync for
0
0
null
null
// File: crates/storage_impl/src/database/store.rs // Module: storage_impl // Public functions: 1 // Public structs: 2 use async_bb8_diesel::{AsyncConnection, ConnectionError}; use bb8::CustomizeConnection; use common_utils::DbConnectionParams; use diesel::PgConnection; use error_stack::ResultExt; use crate::{ config::{Database, TenantConfig}, errors::{StorageError, StorageResult}, }; pub type PgPool = bb8::Pool<async_bb8_diesel::ConnectionManager<PgConnection>>; pub type PgPooledConn = async_bb8_diesel::Connection<PgConnection>; #[async_trait::async_trait] pub trait DatabaseStore: Clone + Send + Sync { type Config: Send; async fn new( config: Self::Config, tenant_config: &dyn TenantConfig, test_transaction: bool, ) -> StorageResult<Self>; fn get_master_pool(&self) -> &PgPool; fn get_replica_pool(&self) -> &PgPool; fn get_accounts_master_pool(&self) -> &PgPool; fn get_accounts_replica_pool(&self) -> &PgPool; } #[derive(Debug, Clone)] pub struct Store { pub master_pool: PgPool, pub accounts_pool: PgPool, } #[async_trait::async_trait] impl DatabaseStore for Store { type Config = Database; async fn new( config: Database, tenant_config: &dyn TenantConfig, test_transaction: bool, ) -> StorageResult<Self> { Ok(Self { master_pool: diesel_make_pg_pool(&config, tenant_config.get_schema(), test_transaction) .await?, accounts_pool: diesel_make_pg_pool( &config, tenant_config.get_accounts_schema(), test_transaction, ) .await?, }) } fn get_master_pool(&self) -> &PgPool { &self.master_pool } fn get_replica_pool(&self) -> &PgPool { &self.master_pool } fn get_accounts_master_pool(&self) -> &PgPool { &self.accounts_pool } fn get_accounts_replica_pool(&self) -> &PgPool { &self.accounts_pool } } #[derive(Debug, Clone)] pub struct ReplicaStore { pub master_pool: PgPool, pub replica_pool: PgPool, pub accounts_master_pool: PgPool, pub accounts_replica_pool: PgPool, } #[async_trait::async_trait] impl DatabaseStore for ReplicaStore { type Config = (Database, Database); async fn new( config: (Database, Database), tenant_config: &dyn TenantConfig, test_transaction: bool, ) -> StorageResult<Self> { let (master_config, replica_config) = config; let master_pool = diesel_make_pg_pool(&master_config, tenant_config.get_schema(), test_transaction) .await .attach_printable("failed to create master pool")?; let accounts_master_pool = diesel_make_pg_pool( &master_config, tenant_config.get_accounts_schema(), test_transaction, ) .await .attach_printable("failed to create accounts master pool")?; let replica_pool = diesel_make_pg_pool( &replica_config, tenant_config.get_schema(), test_transaction, ) .await .attach_printable("failed to create replica pool")?; let accounts_replica_pool = diesel_make_pg_pool( &replica_config, tenant_config.get_accounts_schema(), test_transaction, ) .await .attach_printable("failed to create accounts pool")?; Ok(Self { master_pool, replica_pool, accounts_master_pool, accounts_replica_pool, }) } fn get_master_pool(&self) -> &PgPool { &self.master_pool } fn get_replica_pool(&self) -> &PgPool { &self.replica_pool } fn get_accounts_master_pool(&self) -> &PgPool { &self.accounts_master_pool } fn get_accounts_replica_pool(&self) -> &PgPool { &self.accounts_replica_pool } } pub async fn diesel_make_pg_pool( database: &Database, schema: &str, test_transaction: bool, ) -> StorageResult<PgPool> { let database_url = database.get_database_url(schema); let manager = async_bb8_diesel::ConnectionManager::<PgConnection>::new(database_url); let mut pool = bb8::Pool::builder() .max_size(database.pool_size) .min_idle(database.min_idle) .queue_strategy(database.queue_strategy.into()) .connection_timeout(std::time::Duration::from_secs(database.connection_timeout)) .max_lifetime(database.max_lifetime.map(std::time::Duration::from_secs)); if test_transaction { pool = pool.connection_customizer(Box::new(TestTransaction)); } pool.build(manager) .await .change_context(StorageError::InitializationError) .attach_printable("Failed to create PostgreSQL connection pool") } #[derive(Debug)] struct TestTransaction; #[async_trait::async_trait] impl CustomizeConnection<PgPooledConn, ConnectionError> for TestTransaction { #[allow(clippy::unwrap_used)] async fn on_acquire(&self, conn: &mut PgPooledConn) -> Result<(), ConnectionError> { use diesel::Connection; conn.run(|conn| { conn.begin_test_transaction().unwrap(); Ok(()) }) .await } }
crates/storage_impl/src/database/store.rs
storage_impl
full_file
null
null
null
1,182
null
null
null
null
null
null
null
// Implementation: impl Authentication // File: crates/diesel_models/src/authentication.rs // Module: diesel_models // Methods: 2 total (2 public) impl Authentication
crates/diesel_models/src/authentication.rs
diesel_models
impl_block
null
null
null
35
null
Authentication
null
2
2
null
null
// File: crates/router/tests/connectors/prophetpay.rs // Module: router use masking::Secret; use router::types::{self, domain, storage::enums}; use test_utils::connector_auth; use crate::utils::{self, ConnectorActions}; #[derive(Clone, Copy)] struct ProphetpayTest; impl ConnectorActions for ProphetpayTest {} impl utils::Connector for ProphetpayTest { fn get_data(&self) -> types::api::ConnectorData { use router::connector::Prophetpay; utils::construct_connector_data_old( Box::new(&Prophetpay), types::Connector::Prophetpay, types::api::GetToken::Connector, None, ) } fn get_auth_token(&self) -> types::ConnectorAuthType { utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .prophetpay .expect("Missing connector authentication configuration") .into(), ) } fn get_name(&self) -> String { "prophetpay".to_string() } } static CONNECTOR: ProphetpayTest = ProphetpayTest {}; 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/prophetpay.rs
router
full_file
null
null
null
2,935
null
null
null
null
null
null
null
// File: crates/router/tests/connectors/fiservemea.rs // Module: router use hyperswitch_domain_models::payment_method_data::{Card, PaymentMethodData}; use masking::Secret; use router::types::{self, api, storage::enums}; use test_utils::connector_auth; use crate::utils::{self, ConnectorActions}; #[derive(Clone, Copy)] struct FiservemeaTest; impl ConnectorActions for FiservemeaTest {} impl utils::Connector for FiservemeaTest { fn get_data(&self) -> api::ConnectorData { use router::connector::Fiservemea; utils::construct_connector_data_old( Box::new(Fiservemea::new()), types::Connector::Plaid, api::GetToken::Connector, None, ) } fn get_auth_token(&self) -> types::ConnectorAuthType { utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .fiservemea .expect("Missing connector authentication configuration") .into(), ) } fn get_name(&self) -> String { "fiservemea".to_string() } } static CONNECTOR: FiservemeaTest = FiservemeaTest {}; 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: PaymentMethodData::Card(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: PaymentMethodData::Card(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: PaymentMethodData::Card(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/fiservemea.rs
router
full_file
null
null
null
2,960
null
null
null
null
null
null
null
// File: crates/router/tests/connectors/wellsfargo.rs // Module: router 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 WellsfargoTest; impl ConnectorActions for WellsfargoTest {} impl utils::Connector for WellsfargoTest { fn get_data(&self) -> api::ConnectorData { use router::connector::Wellsfargo; utils::construct_connector_data_old( Box::new(Wellsfargo::new()), types::Connector::Wellsfargo, api::GetToken::Connector, None, ) } fn get_auth_token(&self) -> types::ConnectorAuthType { utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .wellsfargo .expect("Missing connector authentication configuration") .into(), ) } fn get_name(&self) -> String { "wellsfargo".to_string() } } static CONNECTOR: WellsfargoTest = WellsfargoTest {}; 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/wellsfargo.rs
router
full_file
null
null
null
2,945
null
null
null
null
null
null
null
// Implementation: impl api::RefundExecute for for Barclaycard // File: crates/hyperswitch_connectors/src/connectors/barclaycard.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::RefundExecute for for Barclaycard
crates/hyperswitch_connectors/src/connectors/barclaycard.rs
hyperswitch_connectors
impl_block
null
null
null
63
null
Barclaycard
api::RefundExecute for
0
0
null
null
// Function: get_payment_id // File: crates/api_models/src/webhooks.rs // Module: api_models pub fn get_payment_id(&self) -> Option<common_utils::id_type::PaymentId>
crates/api_models/src/webhooks.rs
api_models
function_signature
null
null
null
44
get_payment_id
null
null
null
null
null
null
// File: crates/api_models/src/disputes.rs // Module: api_models // Public structs: 10 use std::collections::HashMap; use common_utils::types::{StringMinorUnit, TimeRange}; use masking::{Deserialize, Serialize}; use serde::de::Error; use time::PrimitiveDateTime; use utoipa::ToSchema; use super::enums::{Currency, DisputeStage, DisputeStatus}; use crate::{admin::MerchantConnectorInfo, files}; #[derive(Clone, Debug, Serialize, ToSchema, Eq, PartialEq)] pub struct DisputeResponse { /// The identifier for dispute pub dispute_id: String, /// The identifier for payment_intent #[schema(value_type = String)] pub payment_id: common_utils::id_type::PaymentId, /// The identifier for payment_attempt pub attempt_id: String, /// The dispute amount pub amount: StringMinorUnit, /// The three-letter ISO currency code #[schema(value_type = Currency)] pub currency: Currency, /// Stage of the dispute pub dispute_stage: DisputeStage, /// Status of the dispute pub dispute_status: DisputeStatus, /// connector to which dispute is associated with pub connector: String, /// Status of the dispute sent by connector pub connector_status: String, /// Dispute id sent by connector pub connector_dispute_id: String, /// Reason of dispute sent by connector pub connector_reason: Option<String>, /// Reason code of dispute sent by connector pub connector_reason_code: Option<String>, /// Evidence deadline of dispute sent by connector #[serde(with = "common_utils::custom_serde::iso8601::option")] pub challenge_required_by: Option<PrimitiveDateTime>, /// Dispute created time sent by connector #[serde(with = "common_utils::custom_serde::iso8601::option")] pub connector_created_at: Option<PrimitiveDateTime>, /// Dispute updated time sent by connector #[serde(with = "common_utils::custom_serde::iso8601::option")] pub connector_updated_at: Option<PrimitiveDateTime>, /// Time at which dispute is received #[serde(with = "common_utils::custom_serde::iso8601")] pub created_at: PrimitiveDateTime, /// The `profile_id` associated with the dispute #[schema(value_type = Option<String>)] pub profile_id: Option<common_utils::id_type::ProfileId>, /// The `merchant_connector_id` of the connector / processor through which the dispute was processed #[schema(value_type = Option<String>)] pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>, } #[derive(Clone, Debug, Serialize, ToSchema, Eq, PartialEq)] pub struct DisputeResponsePaymentsRetrieve { /// The identifier for dispute pub dispute_id: String, /// Stage of the dispute pub dispute_stage: DisputeStage, /// Status of the dispute pub dispute_status: DisputeStatus, /// Status of the dispute sent by connector pub connector_status: String, /// Dispute id sent by connector pub connector_dispute_id: String, /// Reason of dispute sent by connector pub connector_reason: Option<String>, /// Reason code of dispute sent by connector pub connector_reason_code: Option<String>, /// Evidence deadline of dispute sent by connector #[serde(with = "common_utils::custom_serde::iso8601::option")] pub challenge_required_by: Option<PrimitiveDateTime>, /// Dispute created time sent by connector #[serde(with = "common_utils::custom_serde::iso8601::option")] pub connector_created_at: Option<PrimitiveDateTime>, /// Dispute updated time sent by connector #[serde(with = "common_utils::custom_serde::iso8601::option")] pub connector_updated_at: Option<PrimitiveDateTime>, /// Time at which dispute is received #[serde(with = "common_utils::custom_serde::iso8601")] pub created_at: PrimitiveDateTime, } #[derive(Debug, Serialize, Deserialize, strum::Display, Clone)] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum EvidenceType { CancellationPolicy, CustomerCommunication, CustomerSignature, Receipt, RefundPolicy, ServiceDocumentation, ShippingDocumentation, InvoiceShowingDistinctTransactions, RecurringTransactionAgreement, UncategorizedFile, } #[derive(Clone, Debug, Serialize, ToSchema)] pub struct DisputeEvidenceBlock { /// Evidence type pub evidence_type: EvidenceType, /// File metadata pub file_metadata_response: files::FileMetadataResponse, } #[derive(Clone, Debug, Deserialize, Serialize, ToSchema)] #[serde(deny_unknown_fields)] pub struct DisputeListGetConstraints { /// The identifier for dispute pub dispute_id: Option<String>, /// The payment_id against which dispute is raised pub payment_id: Option<common_utils::id_type::PaymentId>, /// Limit on the number of objects to return pub limit: Option<u32>, /// The starting point within a list of object pub offset: Option<u32>, /// The identifier for business profile #[schema(value_type = Option<String>)] pub profile_id: Option<common_utils::id_type::ProfileId>, /// The comma separated list of status of the disputes #[serde(default, deserialize_with = "parse_comma_separated")] pub dispute_status: Option<Vec<DisputeStatus>>, /// The comma separated list of stages of the disputes #[serde(default, deserialize_with = "parse_comma_separated")] pub dispute_stage: Option<Vec<DisputeStage>>, /// Reason for the dispute pub reason: Option<String>, /// The comma separated list of connectors linked to disputes #[serde(default, deserialize_with = "parse_comma_separated")] pub connector: Option<Vec<String>>, /// The comma separated list of currencies of the disputes #[serde(default, deserialize_with = "parse_comma_separated")] pub currency: Option<Vec<Currency>>, /// The merchant connector id to filter the disputes list pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>, /// The time range for which objects are needed. TimeRange has two fields start_time and end_time from which objects can be filtered as per required scenarios (created_at, time less than, greater than etc). #[serde(flatten)] pub time_range: Option<TimeRange>, } #[derive(Clone, Debug, serde::Serialize, ToSchema)] pub struct DisputeListFilters { /// The map of available connector filters, where the key is the connector name and the value is a list of MerchantConnectorInfo instances pub connector: HashMap<String, Vec<MerchantConnectorInfo>>, /// The list of available currency filters pub currency: Vec<Currency>, /// The list of available dispute status filters pub dispute_status: Vec<DisputeStatus>, /// The list of available dispute stage filters pub dispute_stage: Vec<DisputeStage>, } #[derive(Default, Clone, Debug, Serialize, Deserialize, ToSchema)] pub struct SubmitEvidenceRequest { ///Dispute Id pub dispute_id: String, /// Logs showing the usage of service by customer pub access_activity_log: Option<String>, /// Billing address of the customer pub billing_address: Option<String>, /// File Id of cancellation policy pub cancellation_policy: Option<String>, /// Details of showing cancellation policy to customer before purchase pub cancellation_policy_disclosure: Option<String>, /// Details telling why customer's subscription was not cancelled pub cancellation_rebuttal: Option<String>, /// File Id of customer communication pub customer_communication: Option<String>, /// Customer email address pub customer_email_address: Option<String>, /// Customer name pub customer_name: Option<String>, /// IP address of the customer pub customer_purchase_ip: Option<String>, /// Fild Id of customer signature pub customer_signature: Option<String>, /// Product Description pub product_description: Option<String>, /// File Id of receipt pub receipt: Option<String>, /// File Id of refund policy pub refund_policy: Option<String>, /// Details of showing refund policy to customer before purchase pub refund_policy_disclosure: Option<String>, /// Details why customer is not entitled to refund pub refund_refusal_explanation: Option<String>, /// Customer service date pub service_date: Option<String>, /// File Id service documentation pub service_documentation: Option<String>, /// Shipping address of the customer pub shipping_address: Option<String>, /// Delivery service that shipped the product pub shipping_carrier: Option<String>, /// Shipping date pub shipping_date: Option<String>, /// File Id shipping documentation pub shipping_documentation: Option<String>, /// Tracking number of shipped product pub shipping_tracking_number: Option<String>, /// File Id showing two distinct transactions when customer claims a payment was charged twice pub invoice_showing_distinct_transactions: Option<String>, /// File Id of recurring transaction agreement pub recurring_transaction_agreement: Option<String>, /// Any additional supporting file pub uncategorized_file: Option<String>, /// Any additional evidence statements pub uncategorized_text: Option<String>, } #[derive(Clone, Debug, Serialize, Deserialize, ToSchema)] pub struct DeleteEvidenceRequest { /// Id of the dispute pub dispute_id: String, /// Evidence Type to be deleted pub evidence_type: EvidenceType, } #[derive(Debug, Deserialize, Serialize)] pub struct DisputeRetrieveRequest { /// The identifier for dispute pub dispute_id: String, /// Decider to enable or disable the connector call for dispute retrieve request pub force_sync: Option<bool>, } #[derive(Clone, Debug, serde::Serialize)] pub struct DisputesAggregateResponse { /// Different status of disputes with their count pub status_with_count: HashMap<DisputeStatus, i64>, } #[derive(Debug, Deserialize, Serialize)] pub struct DisputeRetrieveBody { /// Decider to enable or disable the connector call for dispute retrieve request pub force_sync: Option<bool>, } fn parse_comma_separated<'de, D, T>(v: D) -> Result<Option<Vec<T>>, D::Error> where D: serde::Deserializer<'de>, T: std::str::FromStr, <T as std::str::FromStr>::Err: std::fmt::Debug + std::fmt::Display + std::error::Error, { let output = Option::<&str>::deserialize(v)?; output .map(|s| { s.split(",") .map(|x| x.parse::<T>().map_err(D::Error::custom)) .collect::<Result<_, _>>() }) .transpose() }
crates/api_models/src/disputes.rs
api_models
full_file
null
null
null
2,360
null
null
null
null
null
null
null
// Function: profiles_list_at_profile_level // File: crates/router/src/routes/profiles.rs // Module: router pub fn profiles_list_at_profile_level( state: web::Data<AppState>, req: HttpRequest, path: web::Path<common_utils::id_type::MerchantId>, ) -> HttpResponse
crates/router/src/routes/profiles.rs
router
function_signature
null
null
null
66
profiles_list_at_profile_level
null
null
null
null
null
null
// File: crates/drainer/src/stream.rs // Module: drainer // Public functions: 6 use std::collections::HashMap; use redis_interface as redis; use router_env::{logger, tracing}; use crate::{errors, metrics, Store}; pub type StreamEntries = Vec<(String, HashMap<String, String>)>; pub type StreamReadResult = HashMap<String, StreamEntries>; impl Store { #[inline(always)] pub fn drainer_stream(&self, shard_key: &str) -> String { // Example: {shard_5}_drainer_stream format!("{{{}}}_{}", shard_key, self.config.drainer_stream_name,) } #[inline(always)] pub(crate) fn get_stream_key_flag(&self, stream_index: u8) -> String { format!("{}_in_use", self.get_drainer_stream_name(stream_index)) } #[inline(always)] pub(crate) fn get_drainer_stream_name(&self, stream_index: u8) -> String { self.drainer_stream(format!("shard_{stream_index}").as_str()) } #[router_env::instrument(skip_all)] pub async fn is_stream_available(&self, stream_index: u8) -> bool { let stream_key_flag = self.get_stream_key_flag(stream_index); match self .redis_conn .set_key_if_not_exists_with_expiry(&stream_key_flag.as_str().into(), true, None) .await { Ok(resp) => resp == redis::types::SetnxReply::KeySet, Err(error) => { logger::error!(operation="lock_stream",err=?error); false } } } pub async fn make_stream_available(&self, stream_name_flag: &str) -> errors::DrainerResult<()> { match self.redis_conn.delete_key(&stream_name_flag.into()).await { Ok(redis::DelReply::KeyDeleted) => Ok(()), Ok(redis::DelReply::KeyNotDeleted) => { logger::error!("Tried to unlock a stream which is already unlocked"); Ok(()) } Err(error) => Err(errors::DrainerError::from(error).into()), } } pub async fn read_from_stream( &self, stream_name: &str, max_read_count: u64, ) -> errors::DrainerResult<StreamReadResult> { // "0-0" id gives first entry let stream_id = "0-0"; let (output, execution_time) = common_utils::date_time::time_it(|| async { self.redis_conn .stream_read_entries(stream_name, stream_id, Some(max_read_count)) .await .map_err(errors::DrainerError::from) }) .await; metrics::REDIS_STREAM_READ_TIME.record( execution_time, router_env::metric_attributes!(("stream", stream_name.to_owned())), ); Ok(output?) } pub async fn trim_from_stream( &self, stream_name: &str, minimum_entry_id: &str, ) -> errors::DrainerResult<usize> { let trim_kind = redis::StreamCapKind::MinID; let trim_type = redis::StreamCapTrim::Exact; let trim_id = minimum_entry_id; let (trim_result, execution_time) = common_utils::date_time::time_it::<errors::DrainerResult<_>, _, _>(|| async { let trim_result = self .redis_conn .stream_trim_entries(&stream_name.into(), (trim_kind, trim_type, trim_id)) .await .map_err(errors::DrainerError::from)?; // Since xtrim deletes entries below given id excluding the given id. // Hence, deleting the minimum entry id self.redis_conn .stream_delete_entries(&stream_name.into(), minimum_entry_id) .await .map_err(errors::DrainerError::from)?; Ok(trim_result) }) .await; metrics::REDIS_STREAM_TRIM_TIME.record( execution_time, router_env::metric_attributes!(("stream", stream_name.to_owned())), ); // adding 1 because we are deleting the given id too Ok(trim_result? + 1) } pub async fn delete_from_stream( &self, stream_name: &str, entry_id: &str, ) -> errors::DrainerResult<()> { let (_trim_result, execution_time) = common_utils::date_time::time_it::<errors::DrainerResult<_>, _, _>(|| async { self.redis_conn .stream_delete_entries(&stream_name.into(), entry_id) .await .map_err(errors::DrainerError::from)?; Ok(()) }) .await; metrics::REDIS_STREAM_DEL_TIME.record( execution_time, router_env::metric_attributes!(("stream", stream_name.to_owned())), ); Ok(()) } }
crates/drainer/src/stream.rs
drainer
full_file
null
null
null
1,057
null
null
null
null
null
null
null
// Struct: Plaid // File: crates/hyperswitch_connectors/src/connectors/plaid.rs // Module: hyperswitch_connectors // Implementations: 18 // Traits: Payment, PaymentSession, ConnectorAccessToken, MandateSetup, PaymentAuthorize, PaymentSync, PaymentCapture, PaymentVoid, Refund, RefundExecute, RefundSync, PaymentToken, PaymentsPostProcessing, ConnectorCommon, ConnectorValidation, IncomingWebhook, ConnectorSpecifications pub struct Plaid
crates/hyperswitch_connectors/src/connectors/plaid.rs
hyperswitch_connectors
struct_definition
Plaid
18
[ "Payment", "PaymentSession", "ConnectorAccessToken", "MandateSetup", "PaymentAuthorize", "PaymentSync", "PaymentCapture", "PaymentVoid", "Refund", "RefundExecute", "RefundSync", "PaymentToken", "PaymentsPostProcessing", "ConnectorCommon", "ConnectorValidation", "IncomingWebhook", "ConnectorSpecifications" ]
101
null
null
null
null
null
null
null
// Function: list_initial_attempts_by_profile_id_primary_object_id // File: crates/diesel_models/src/query/events.rs // Module: diesel_models pub fn list_initial_attempts_by_profile_id_primary_object_id( conn: &PgPooledConn, profile_id: &common_utils::id_type::ProfileId, primary_object_id: &str, ) -> StorageResult<Vec<Self>>
crates/diesel_models/src/query/events.rs
diesel_models
function_signature
null
null
null
82
list_initial_attempts_by_profile_id_primary_object_id
null
null
null
null
null
null
// Struct: PaystackPaymentWebhookData // File: crates/hyperswitch_connectors/src/connectors/paystack/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct PaystackPaymentWebhookData
crates/hyperswitch_connectors/src/connectors/paystack/transformers.rs
hyperswitch_connectors
struct_definition
PaystackPaymentWebhookData
0
[]
53
null
null
null
null
null
null
null
// Struct: DummyConnectorUpiCollect // File: crates/router/src/routes/dummy_connector/types.rs // Module: router // Implementations: 0 pub struct DummyConnectorUpiCollect
crates/router/src/routes/dummy_connector/types.rs
router
struct_definition
DummyConnectorUpiCollect
0
[]
41
null
null
null
null
null
null
null
// Module Structure // File: crates/router/src/types/storage/payment_method.rs // Module: router // Public exports: pub use diesel_models::payment_method::{ PaymentMethod, PaymentMethodNew, PaymentMethodUpdate, PaymentMethodUpdateInternal, TokenizeCoreWorkflow, };
crates/router/src/types/storage/payment_method.rs
router
module_structure
null
null
null
57
null
null
null
null
null
0
1
// Struct: Destination // File: crates/hyperswitch_connectors/src/connectors/signifyd/transformers/api.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct Destination
crates/hyperswitch_connectors/src/connectors/signifyd/transformers/api.rs
hyperswitch_connectors
struct_definition
Destination
0
[]
45
null
null
null
null
null
null
null
// Module Structure // File: crates/hyperswitch_connectors/src/connectors/trustpay.rs // Module: hyperswitch_connectors // Public submodules: pub mod transformers;
crates/hyperswitch_connectors/src/connectors/trustpay.rs
hyperswitch_connectors
module_structure
null
null
null
39
null
null
null
null
null
1
0
// File: crates/api_models/src/apple_pay_certificates_migration.rs // Module: api_models // Public structs: 2 #[derive(Debug, Clone, serde::Serialize)] pub struct ApplePayCertificatesMigrationResponse { pub migration_successful: Vec<common_utils::id_type::MerchantId>, pub migration_failed: Vec<common_utils::id_type::MerchantId>, } #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)] pub struct ApplePayCertificatesMigrationRequest { pub merchant_ids: Vec<common_utils::id_type::MerchantId>, } impl common_utils::events::ApiEventMetric for ApplePayCertificatesMigrationRequest {}
crates/api_models/src/apple_pay_certificates_migration.rs
api_models
full_file
null
null
null
137
null
null
null
null
null
null
null
// Struct: EncryptableAddress // File: crates/diesel_models/src/address.rs // Module: diesel_models // Implementations: 0 pub struct EncryptableAddress
crates/diesel_models/src/address.rs
diesel_models
struct_definition
EncryptableAddress
0
[]
36
null
null
null
null
null
null
null
// Struct: PaypalPaymentsCancelResponse // File: crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct PaypalPaymentsCancelResponse
crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
hyperswitch_connectors
struct_definition
PaypalPaymentsCancelResponse
0
[]
49
null
null
null
null
null
null
null
// Implementation: impl Responder // File: crates/router/src/routes/routing.rs // Module: router // Methods: 0 total (0 public) impl Responder
crates/router/src/routes/routing.rs
router
impl_block
null
null
null
36
null
Responder
null
0
0
null
null
// Struct: PaymentApprove // File: crates/router/src/core/payments/operations/payment_approve.rs // Module: router // Implementations: 0 pub struct PaymentApprove
crates/router/src/core/payments/operations/payment_approve.rs
router
struct_definition
PaymentApprove
0
[]
40
null
null
null
null
null
null
null
// File: crates/storage_impl/src/mock_db/payout_attempt.rs // Module: storage_impl use common_utils::errors::CustomResult; use diesel_models::enums as storage_enums; use hyperswitch_domain_models::payouts::{ payout_attempt::{ PayoutAttempt, PayoutAttemptInterface, PayoutAttemptNew, PayoutAttemptUpdate, }, payouts::Payouts, }; use super::MockDb; use crate::errors::StorageError; #[async_trait::async_trait] impl PayoutAttemptInterface for MockDb { type Error = StorageError; async fn update_payout_attempt( &self, _this: &PayoutAttempt, _payout_attempt_update: PayoutAttemptUpdate, _payouts: &Payouts, _storage_scheme: storage_enums::MerchantStorageScheme, ) -> CustomResult<PayoutAttempt, StorageError> { // TODO: Implement function for `MockDb` Err(StorageError::MockDbError)? } async fn insert_payout_attempt( &self, _payout_attempt: PayoutAttemptNew, _payouts: &Payouts, _storage_scheme: storage_enums::MerchantStorageScheme, ) -> CustomResult<PayoutAttempt, StorageError> { // TODO: Implement function for `MockDb` Err(StorageError::MockDbError)? } async fn find_payout_attempt_by_merchant_id_payout_attempt_id( &self, _merchant_id: &common_utils::id_type::MerchantId, _payout_attempt_id: &str, _storage_scheme: storage_enums::MerchantStorageScheme, ) -> CustomResult<PayoutAttempt, StorageError> { // TODO: Implement function for `MockDb` Err(StorageError::MockDbError)? } async fn find_payout_attempt_by_merchant_id_connector_payout_id( &self, _merchant_id: &common_utils::id_type::MerchantId, _connector_payout_id: &str, _storage_scheme: storage_enums::MerchantStorageScheme, ) -> CustomResult<PayoutAttempt, StorageError> { // TODO: Implement function for `MockDb` Err(StorageError::MockDbError)? } async fn get_filters_for_payouts( &self, _payouts: &[Payouts], _merchant_id: &common_utils::id_type::MerchantId, _storage_scheme: storage_enums::MerchantStorageScheme, ) -> CustomResult< hyperswitch_domain_models::payouts::payout_attempt::PayoutListFilters, StorageError, > { Err(StorageError::MockDbError)? } async fn find_payout_attempt_by_merchant_id_merchant_order_reference_id( &self, _merchant_id: &common_utils::id_type::MerchantId, _merchant_order_reference_id: &str, _storage_scheme: storage_enums::MerchantStorageScheme, ) -> CustomResult<PayoutAttempt, StorageError> { Err(StorageError::MockDbError)? } }
crates/storage_impl/src/mock_db/payout_attempt.rs
storage_impl
full_file
null
null
null
666
null
null
null
null
null
null
null
// Struct: NovalnetPaymentsRequestBilling // File: crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct NovalnetPaymentsRequestBilling
crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
hyperswitch_connectors
struct_definition
NovalnetPaymentsRequestBilling
0
[]
54
null
null
null
null
null
null
null
// Function: delete_by_merchant_id_payment_method_id // File: crates/diesel_models/src/query/payment_method.rs // Module: diesel_models pub fn delete_by_merchant_id_payment_method_id( conn: &PgPooledConn, merchant_id: &common_utils::id_type::MerchantId, payment_method_id: &str, ) -> StorageResult<Self>
crates/diesel_models/src/query/payment_method.rs
diesel_models
function_signature
null
null
null
80
delete_by_merchant_id_payment_method_id
null
null
null
null
null
null
// Implementation: impl api::RefundSync for for Prophetpay // File: crates/hyperswitch_connectors/src/connectors/prophetpay.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::RefundSync for for Prophetpay
crates/hyperswitch_connectors/src/connectors/prophetpay.rs
hyperswitch_connectors
impl_block
null
null
null
60
null
Prophetpay
api::RefundSync for
0
0
null
null
// Function: get_optional_full_name // File: crates/hyperswitch_domain_models/src/address.rs // Module: hyperswitch_domain_models pub fn get_optional_full_name(&self) -> Option<Secret<String>>
crates/hyperswitch_domain_models/src/address.rs
hyperswitch_domain_models
function_signature
null
null
null
45
get_optional_full_name
null
null
null
null
null
null
// Implementation: impl RefundExecute for for Plaid // File: crates/hyperswitch_connectors/src/connectors/plaid.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl RefundExecute for for Plaid
crates/hyperswitch_connectors/src/connectors/plaid.rs
hyperswitch_connectors
impl_block
null
null
null
55
null
Plaid
RefundExecute for
0
0
null
null
// Struct: V2ClientAuth // File: crates/router/src/services/authentication.rs // Module: router // Implementations: 0 pub struct V2ClientAuth
crates/router/src/services/authentication.rs
router
struct_definition
V2ClientAuth
0
[]
36
null
null
null
null
null
null
null
// Implementation: impl api::PaymentToken for for Square // File: crates/hyperswitch_connectors/src/connectors/square.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::PaymentToken for for Square
crates/hyperswitch_connectors/src/connectors/square.rs
hyperswitch_connectors
impl_block
null
null
null
55
null
Square
api::PaymentToken for
0
0
null
null