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
// Function: get_output // File: crates/euclid/src/backend.rs // Module: euclid pub fn get_output(&self) -> &O
crates/euclid/src/backend.rs
euclid
function_signature
null
null
null
33
get_output
null
null
null
null
null
null
// Struct: CardDetail // File: crates/api_models/src/payment_methods.rs // Module: api_models // Implementations: 0 pub struct CardDetail
crates/api_models/src/payment_methods.rs
api_models
struct_definition
CardDetail
0
[]
34
null
null
null
null
null
null
null
// Function: rotate_password // File: crates/router/src/core/user.rs // Module: router pub fn rotate_password( state: SessionState, user_token: auth::UserFromSinglePurposeToken, request: user_api::RotatePasswordRequest, _req_state: ReqState, ) -> UserResponse<()>
crates/router/src/core/user.rs
router
function_signature
null
null
null
67
rotate_password
null
null
null
null
null
null
// Trait: AuthEventMetric // File: crates/analytics/src/auth_events/metrics.rs // Module: analytics pub trait AuthEventMetric<T>
crates/analytics/src/auth_events/metrics.rs
analytics
trait_definition
null
null
null
32
null
null
AuthEventMetric
null
null
null
null
// Implementation: impl api::PaymentToken for for Bamboraapac // File: crates/hyperswitch_connectors/src/connectors/bamboraapac.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::PaymentToken for for Bamboraapac
crates/hyperswitch_connectors/src/connectors/bamboraapac.rs
hyperswitch_connectors
impl_block
null
null
null
66
null
Bamboraapac
api::PaymentToken for
0
0
null
null
// Struct: AciVoidResponse // File: crates/hyperswitch_connectors/src/connectors/aci/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct AciVoidResponse
crates/hyperswitch_connectors/src/connectors/aci/transformers.rs
hyperswitch_connectors
struct_definition
AciVoidResponse
0
[]
49
null
null
null
null
null
null
null
// Function: success_based_routing_update_configs // File: crates/openapi/src/routes/routing.rs // Module: openapi pub fn success_based_routing_update_configs()
crates/openapi/src/routes/routing.rs
openapi
function_signature
null
null
null
35
success_based_routing_update_configs
null
null
null
null
null
null
// File: crates/router/tests/connectors/paystack.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 PaystackTest; impl ConnectorActions for PaystackTest {} impl utils::Connector for PaystackTest { fn get_data(&self) -> api::ConnectorData { use router::connector::Paystack; utils::construct_connector_data_old( Box::new(Paystack::new()), types::Connector::Plaid, api::GetToken::Connector, None, ) } fn get_auth_token(&self) -> types::ConnectorAuthType { utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .paystack .expect("Missing connector authentication configuration") .into(), ) } fn get_name(&self) -> String { "paystack".to_string() } } static CONNECTOR: PaystackTest = PaystackTest {}; 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/paystack.rs
router
full_file
null
null
null
2,931
null
null
null
null
null
null
null
// File: crates/diesel_models/src/query/tokenization.rs // Module: diesel_models // Public functions: 3 #[cfg(feature = "v2")] use diesel::associations::HasTable; #[cfg(feature = "v2")] use diesel::ExpressionMethods; #[cfg(feature = "v2")] use crate::{ errors, query::generics, schema_v2::tokenization, tokenization as tokenization_diesel, PgPooledConn, StorageResult, }; #[cfg(all(feature = "v2", feature = "tokenization_v2"))] impl tokenization_diesel::Tokenization { pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<Self> { generics::generic_insert(conn, self).await } pub async fn find_by_id( conn: &PgPooledConn, id: &common_utils::id_type::GlobalTokenId, ) -> StorageResult<Self> { generics::generic_find_one::<<Self as HasTable>::Table, _, _>( conn, tokenization::dsl::id.eq(id.to_owned()), ) .await } pub async fn update_with_id( self, conn: &PgPooledConn, tokenization_record: tokenization_diesel::TokenizationUpdateInternal, ) -> StorageResult<Self> { match generics::generic_update_with_unique_predicate_get_result::< <Self as HasTable>::Table, _, _, _, >( conn, tokenization::dsl::id.eq(self.id.to_owned()), tokenization_record, ) .await { Err(error) => match error.current_context() { errors::DatabaseError::NoFieldsToUpdate => Ok(self), _ => Err(error), }, result => result, } } }
crates/diesel_models/src/query/tokenization.rs
diesel_models
full_file
null
null
null
390
null
null
null
null
null
null
null
// Trait: DisputeMetricAccumulator // File: crates/analytics/src/disputes/accumulators.rs // Module: analytics pub trait DisputeMetricAccumulator
crates/analytics/src/disputes/accumulators.rs
analytics
trait_definition
null
null
null
38
null
null
DisputeMetricAccumulator
null
null
null
null
// File: crates/router/tests/connectors/hyperswitch_vault.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 HyperswitchVaultTest; impl ConnectorActions for HyperswitchVaultTest {} impl utils::Connector for HyperswitchVaultTest { fn get_data(&self) -> api::ConnectorData { use router::connector::HyperswitchVault; utils::construct_connector_data_old( Box::new(&HyperswitchVault), types::Connector::HyperswitchVault, api::GetToken::Connector, None, ) } fn get_auth_token(&self) -> types::ConnectorAuthType { utils::to_connector_auth_type( connector_auth::ConnectorAuthentication::new() .hyperswitch_vault .expect("Missing connector authentication configuration") .into(), ) } fn get_name(&self) -> String { "hyperswitch_vault".to_string() } } static CONNECTOR: HyperswitchVaultTest = HyperswitchVaultTest {}; 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/hyperswitch_vault.rs
router
full_file
null
null
null
2,958
null
null
null
null
null
null
null
// Function: get_domain_info // File: crates/analytics/src/core.rs // Module: analytics pub fn get_domain_info( domain: AnalyticsDomain, ) -> crate::errors::AnalyticsResult<GetInfoResponse>
crates/analytics/src/core.rs
analytics
function_signature
null
null
null
47
get_domain_info
null
null
null
null
null
null
// Implementation: impl ConnectorCommon for for ConnectorEnum // File: crates/hyperswitch_interfaces/src/connector_integration_interface.rs // Module: hyperswitch_interfaces // Methods: 6 total (0 public) impl ConnectorCommon for for ConnectorEnum
crates/hyperswitch_interfaces/src/connector_integration_interface.rs
hyperswitch_interfaces
impl_block
null
null
null
51
null
ConnectorEnum
ConnectorCommon for
6
0
null
null
// Function: check_two_factor_auth_status // File: crates/router/src/core/user.rs // Module: router pub fn check_two_factor_auth_status( state: SessionState, user_token: auth::UserFromToken, ) -> UserResponse<user_api::TwoFactorAuthStatusResponse>
crates/router/src/core/user.rs
router
function_signature
null
null
null
62
check_two_factor_auth_status
null
null
null
null
null
null
// Implementation: impl Responder // File: crates/router/src/routes/webhook_events.rs // Module: router // Methods: 0 total (0 public) impl Responder
crates/router/src/routes/webhook_events.rs
router
impl_block
null
null
null
37
null
Responder
null
0
0
null
null
// Function: connector_mandate_details_migrated // File: crates/payment_methods/src/core/migration.rs // Module: payment_methods pub fn connector_mandate_details_migrated( &mut self, connector_mandate_details_migrated: Option<bool>, )
crates/payment_methods/src/core/migration.rs
payment_methods
function_signature
null
null
null
58
connector_mandate_details_migrated
null
null
null
null
null
null
// Trait: CrmInterface // File: crates/hyperswitch_interfaces/src/crm.rs // Module: hyperswitch_interfaces pub trait CrmInterface: Send + Sync
crates/hyperswitch_interfaces/src/crm.rs
hyperswitch_interfaces
trait_definition
null
null
null
37
null
null
CrmInterface
null
null
null
null
// Function: find_by_key // File: crates/diesel_models/src/query/configs.rs // Module: diesel_models pub fn find_by_key(conn: &PgPooledConn, key: &str) -> StorageResult<Self>
crates/diesel_models/src/query/configs.rs
diesel_models
function_signature
null
null
null
49
find_by_key
null
null
null
null
null
null
// Function: check_internal_api_key_auth // File: crates/router/src/services/authentication.rs // Module: router pub fn check_internal_api_key_auth<T>( headers: &HeaderMap, payload: &impl ClientSecretFetch, api_auth: ApiKeyAuth, internal_api_key_auth: settings::InternalMerchantIdProfileIdAuthSettings, ) -> RouterResult<( Box<dyn AuthenticateAndFetch<AuthenticationData, T>>, api::AuthFlow, )> where T: SessionStateInfo + Sync + Send, ApiKeyAuth: AuthenticateAndFetch<AuthenticationData, T>,
crates/router/src/services/authentication.rs
router
function_signature
null
null
null
125
check_internal_api_key_auth
null
null
null
null
null
null
// Implementation: impl api::PaymentsPreAuthenticate for for Cybersource // File: crates/hyperswitch_connectors/src/connectors/cybersource.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::PaymentsPreAuthenticate for for Cybersource
crates/hyperswitch_connectors/src/connectors/cybersource.rs
hyperswitch_connectors
impl_block
null
null
null
63
null
Cybersource
api::PaymentsPreAuthenticate for
0
0
null
null
// Implementation: impl api::PaymentSync for for Opayo // File: crates/hyperswitch_connectors/src/connectors/opayo.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::PaymentSync for for Opayo
crates/hyperswitch_connectors/src/connectors/opayo.rs
hyperswitch_connectors
impl_block
null
null
null
57
null
Opayo
api::PaymentSync for
0
0
null
null
// Struct: CybersourceAuthEnrollmentRequest // File: crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct CybersourceAuthEnrollmentRequest
crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
hyperswitch_connectors
struct_definition
CybersourceAuthEnrollmentRequest
0
[]
57
null
null
null
null
null
null
null
// Function: get_filters // File: crates/analytics/src/frm/core.rs // Module: analytics pub fn get_filters( pool: &AnalyticsProvider, req: GetFrmFilterRequest, merchant_id: &common_utils::id_type::MerchantId, ) -> AnalyticsResult<FrmFiltersResponse>
crates/analytics/src/frm/core.rs
analytics
function_signature
null
null
null
67
get_filters
null
null
null
null
null
null
// Struct: ZenWebhookObjectReference // File: crates/hyperswitch_connectors/src/connectors/zen/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct ZenWebhookObjectReference
crates/hyperswitch_connectors/src/connectors/zen/transformers.rs
hyperswitch_connectors
struct_definition
ZenWebhookObjectReference
0
[]
51
null
null
null
null
null
null
null
// Implementation: impl api::RefundExecute for for Nexinets // File: crates/hyperswitch_connectors/src/connectors/nexinets.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::RefundExecute for for Nexinets
crates/hyperswitch_connectors/src/connectors/nexinets.rs
hyperswitch_connectors
impl_block
null
null
null
63
null
Nexinets
api::RefundExecute for
0
0
null
null
// Struct: NoonWebhookBody // File: crates/hyperswitch_connectors/src/connectors/noon/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct NoonWebhookBody
crates/hyperswitch_connectors/src/connectors/noon/transformers.rs
hyperswitch_connectors
struct_definition
NoonWebhookBody
0
[]
49
null
null
null
null
null
null
null
// Struct: CoinbaseErrorResponse // File: crates/hyperswitch_connectors/src/connectors/coinbase/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct CoinbaseErrorResponse
crates/hyperswitch_connectors/src/connectors/coinbase/transformers.rs
hyperswitch_connectors
struct_definition
CoinbaseErrorResponse
0
[]
46
null
null
null
null
null
null
null
// Implementation: impl ConnectorValidation for for Checkout // File: crates/hyperswitch_connectors/src/connectors/checkout.rs // Module: hyperswitch_connectors // Methods: 2 total (0 public) impl ConnectorValidation for for Checkout
crates/hyperswitch_connectors/src/connectors/checkout.rs
hyperswitch_connectors
impl_block
null
null
null
51
null
Checkout
ConnectorValidation for
2
0
null
null
// Struct: CustomerAssigned // File: crates/router/src/core/payment_methods/tokenize/card_executor.rs // Module: router // Implementations: 1 // Traits: State pub struct CustomerAssigned
crates/router/src/core/payment_methods/tokenize/card_executor.rs
router
struct_definition
CustomerAssigned
1
[ "State" ]
42
null
null
null
null
null
null
null
// Struct: CardData // File: crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct CardData
crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs
hyperswitch_connectors
struct_definition
CardData
0
[]
46
null
null
null
null
null
null
null
// Function: get_payment_method_type // File: crates/hyperswitch_domain_models/src/payments/payment_attempt.rs // Module: hyperswitch_domain_models pub fn get_payment_method_type(&self) -> Option<storage_enums::PaymentMethodType>
crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
hyperswitch_domain_models
function_signature
null
null
null
53
get_payment_method_type
null
null
null
null
null
null
// Struct: JpmorganPaymentsResponse // File: crates/hyperswitch_connectors/src/connectors/jpmorgan/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct JpmorganPaymentsResponse
crates/hyperswitch_connectors/src/connectors/jpmorgan/transformers.rs
hyperswitch_connectors
struct_definition
JpmorganPaymentsResponse
0
[]
52
null
null
null
null
null
null
null
// Struct: SyncResponse // File: crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct SyncResponse
crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs
hyperswitch_connectors
struct_definition
SyncResponse
0
[]
46
null
null
null
null
null
null
null
// Struct: BankOfAmericaClientReferenceResponse // File: crates/hyperswitch_connectors/src/connectors/bankofamerica/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct BankOfAmericaClientReferenceResponse
crates/hyperswitch_connectors/src/connectors/bankofamerica/transformers.rs
hyperswitch_connectors
struct_definition
BankOfAmericaClientReferenceResponse
0
[]
56
null
null
null
null
null
null
null
// Implementation: impl ConvertRaw for for TransientBatchDecryptDataRequest // File: crates/common_utils/src/keymanager.rs // Module: common_utils // Methods: 1 total (0 public) impl ConvertRaw for for TransientBatchDecryptDataRequest
crates/common_utils/src/keymanager.rs
common_utils
impl_block
null
null
null
53
null
TransientBatchDecryptDataRequest
ConvertRaw for
1
0
null
null
// Struct: Settings // File: crates/drainer/src/settings.rs // Module: drainer // Implementations: 1 pub struct Settings<S: SecretState>
crates/drainer/src/settings.rs
drainer
struct_definition
Settings
1
[]
36
null
null
null
null
null
null
null
// Struct: ShippingName // File: crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct ShippingName
crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
hyperswitch_connectors
struct_definition
ShippingName
0
[]
45
null
null
null
null
null
null
null
// File: crates/hyperswitch_connectors/src/connectors/checkbook/transformers.rs // Module: hyperswitch_connectors // Public structs: 4 use api_models::webhooks::IncomingWebhookEvent; use common_utils::{pii, types::FloatMajorUnit}; use hyperswitch_domain_models::{ payment_method_data::{BankTransferData, PaymentMethodData}, router_data::{ConnectorAuthType, RouterData}, router_request_types::ResponseId, router_response_types::PaymentsResponseData, types::PaymentsAuthorizeRouterData, }; use hyperswitch_interfaces::errors::ConnectorError; use masking::Secret; use serde::{Deserialize, Serialize}; use crate::{ types::ResponseRouterData, utils::{get_unimplemented_payment_method_error_message, RouterData as _}, }; #[derive(Debug, Serialize)] pub struct CheckbookPaymentsRequest { name: Secret<String>, recipient: pii::Email, amount: FloatMajorUnit, description: String, } impl TryFrom<(FloatMajorUnit, &PaymentsAuthorizeRouterData)> for CheckbookPaymentsRequest { type Error = error_stack::Report<ConnectorError>; fn try_from( (amount, item): (FloatMajorUnit, &PaymentsAuthorizeRouterData), ) -> Result<Self, Self::Error> { match item.request.payment_method_data.clone() { PaymentMethodData::BankTransfer(bank_transfer_data) => match *bank_transfer_data { BankTransferData::AchBankTransfer {} => Ok(Self { name: item.get_billing_full_name()?, recipient: item.get_billing_email()?, amount, description: item.get_description()?, }), _ => Err(ConnectorError::NotImplemented( get_unimplemented_payment_method_error_message("Checkbook"), ) .into()), }, _ => Err(ConnectorError::NotImplemented( get_unimplemented_payment_method_error_message("Checkbook"), ) .into()), } } } pub struct CheckbookAuthType { pub(super) publishable_key: Secret<String>, pub(super) secret_key: Secret<String>, } impl TryFrom<&ConnectorAuthType> for CheckbookAuthType { type Error = error_stack::Report<ConnectorError>; fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> { match auth_type { ConnectorAuthType::BodyKey { key1, api_key } => Ok(Self { publishable_key: key1.to_owned(), secret_key: api_key.to_owned(), }), _ => Err(ConnectorError::FailedToObtainAuthType.into()), } } } // PaymentsResponse #[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum CheckbookPaymentStatus { Unpaid, InProcess, Paid, Mailed, Printed, Failed, Expired, Void, #[default] Processing, } impl From<CheckbookPaymentStatus> for common_enums::AttemptStatus { fn from(item: CheckbookPaymentStatus) -> Self { match item { CheckbookPaymentStatus::Paid | CheckbookPaymentStatus::Mailed | CheckbookPaymentStatus::Printed => Self::Charged, CheckbookPaymentStatus::Failed | CheckbookPaymentStatus::Expired => Self::Failure, CheckbookPaymentStatus::Unpaid => Self::AuthenticationPending, CheckbookPaymentStatus::InProcess | CheckbookPaymentStatus::Processing => Self::Pending, CheckbookPaymentStatus::Void => Self::Voided, } } } impl From<CheckbookPaymentStatus> for IncomingWebhookEvent { fn from(status: CheckbookPaymentStatus) -> Self { match status { CheckbookPaymentStatus::Mailed | CheckbookPaymentStatus::Printed | CheckbookPaymentStatus::Paid => Self::PaymentIntentSuccess, CheckbookPaymentStatus::Failed | CheckbookPaymentStatus::Expired => { Self::PaymentIntentFailure } CheckbookPaymentStatus::Unpaid | CheckbookPaymentStatus::InProcess | CheckbookPaymentStatus::Processing => Self::PaymentIntentProcessing, CheckbookPaymentStatus::Void => Self::PaymentIntentCancelled, } } } #[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct CheckbookPaymentsResponse { pub status: CheckbookPaymentStatus, pub id: String, pub amount: Option<FloatMajorUnit>, pub description: Option<String>, pub name: Option<String>, pub recipient: Option<String>, } impl<F, T> TryFrom<ResponseRouterData<F, CheckbookPaymentsResponse, T, PaymentsResponseData>> for RouterData<F, T, PaymentsResponseData> { type Error = error_stack::Report<ConnectorError>; fn try_from( item: ResponseRouterData<F, CheckbookPaymentsResponse, T, PaymentsResponseData>, ) -> Result<Self, Self::Error> { Ok(Self { status: common_enums::AttemptStatus::from(item.response.status), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.id), redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, charges: None, }), ..item.data }) } } #[derive(Default, Debug, Serialize, Deserialize, PartialEq)] pub struct CheckbookErrorResponse { pub status_code: u16, pub code: String, pub message: String, pub reason: Option<String>, }
crates/hyperswitch_connectors/src/connectors/checkbook/transformers.rs
hyperswitch_connectors
full_file
null
null
null
1,211
null
null
null
null
null
null
null
// File: crates/hyperswitch_connectors/src/connectors/getnet/transformers.rs // Module: hyperswitch_connectors // Public functions: 8 // Public structs: 35 use api_models::webhooks::IncomingWebhookEvent; use base64::Engine; use cards::CardNumber; use common_enums::{enums, AttemptStatus, CaptureMethod, CountryAlpha2}; use common_utils::{ consts::BASE64_ENGINE, errors::CustomResult, pii::{Email, IpAddress}, types::FloatMajorUnit, }; use error_stack::ResultExt; use hyperswitch_domain_models::{ payment_method_data::PaymentMethodData, router_data::{ConnectorAuthType, RouterData}, router_flow_types::refunds::{Execute, RSync}, router_request_types::{ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, ResponseId, }, router_response_types::{PaymentsResponseData, RefundsResponseData}, types::{ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData, RefundsRouterData, }, }; use hyperswitch_interfaces::errors; use masking::{PeekInterface, Secret}; use serde::{Deserialize, Serialize}; use crate::{ connectors::paybox::transformers::parse_url_encoded_to_struct, types::{PaymentsSyncResponseRouterData, RefundsResponseRouterData, ResponseRouterData}, utils::{ BrowserInformationData, PaymentsAuthorizeRequestData, PaymentsSyncRequestData, RouterData as _, }, }; pub struct GetnetRouterData<T> { pub amount: FloatMajorUnit, pub router_data: T, } impl<T> From<(FloatMajorUnit, T)> for GetnetRouterData<T> { fn from((amount, item): (FloatMajorUnit, T)) -> Self { Self { amount, router_data: item, } } } #[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct Amount { pub value: FloatMajorUnit, pub currency: enums::Currency, } #[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct Address { #[serde(rename = "street1")] pub street1: Option<Secret<String>>, pub city: Option<String>, pub state: Option<Secret<String>>, pub country: Option<CountryAlpha2>, } #[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct AccountHolder { #[serde(rename = "first-name")] pub first_name: Option<Secret<String>>, #[serde(rename = "last-name")] pub last_name: Option<Secret<String>>, pub email: Option<Email>, pub phone: Option<Secret<String>>, pub address: Option<Address>, } #[derive(Default, Debug, Serialize, PartialEq)] pub struct Card { #[serde(rename = "account-number")] pub account_number: CardNumber, #[serde(rename = "expiration-month")] pub expiration_month: Secret<String>, #[serde(rename = "expiration-year")] pub expiration_year: Secret<String>, #[serde(rename = "card-security-code")] pub card_security_code: Secret<String>, #[serde(rename = "card-type")] pub card_type: String, } #[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] #[serde(rename_all = "lowercase")] pub enum GetnetPaymentMethods { CreditCard, } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct PaymentMethod { pub name: GetnetPaymentMethods, } #[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct Notification { pub url: Option<String>, } #[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct PaymentMethodContainer { #[serde(rename = "payment-method")] pub payment_method: Vec<PaymentMethod>, } #[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] #[serde(rename_all = "lowercase")] pub enum NotificationFormat { #[serde(rename = "application/json-signed")] JsonSigned, #[serde(rename = "application/json")] Json, #[serde(rename = "application/xml")] Xml, #[serde(rename = "application/html")] Html, #[serde(rename = "application/x-www-form-urlencoded")] Urlencoded, } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct NotificationContainer { pub notification: Vec<Notification>, pub format: NotificationFormat, } #[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)] pub struct MerchantAccountId { pub value: Secret<String>, } #[derive(Debug, Serialize, PartialEq)] pub struct PaymentData { #[serde(rename = "merchant-account-id")] pub merchant_account_id: MerchantAccountId, #[serde(rename = "request-id")] pub request_id: String, #[serde(rename = "transaction-type")] pub transaction_type: GetnetTransactionType, #[serde(rename = "requested-amount")] pub requested_amount: Amount, #[serde(rename = "account-holder")] pub account_holder: Option<AccountHolder>, pub card: Card, #[serde(rename = "ip-address")] pub ip_address: Option<Secret<String, IpAddress>>, #[serde(rename = "payment-methods")] pub payment_methods: PaymentMethodContainer, pub notifications: Option<NotificationContainer>, } #[derive(Debug, Serialize)] pub struct GetnetPaymentsRequest { payment: PaymentData, } #[derive(Default, Debug, Serialize, Eq, PartialEq)] pub struct GetnetCard { number: CardNumber, expiry_month: Secret<String>, expiry_year: Secret<String>, cvc: Secret<String>, complete: bool, } impl TryFrom<enums::PaymentMethodType> for PaymentMethodContainer { type Error = error_stack::Report<errors::ConnectorError>; fn try_from(payment_method_type: enums::PaymentMethodType) -> Result<Self, Self::Error> { match payment_method_type { enums::PaymentMethodType::Credit => Ok(Self { payment_method: vec![PaymentMethod { name: GetnetPaymentMethods::CreditCard, }], }), _ => Err(errors::ConnectorError::NotSupported { message: "Payment method type not supported".to_string(), connector: "Getnet", } .into()), } } } impl TryFrom<&GetnetRouterData<&PaymentsAuthorizeRouterData>> for GetnetPaymentsRequest { type Error = error_stack::Report<errors::ConnectorError>; fn try_from( item: &GetnetRouterData<&PaymentsAuthorizeRouterData>, ) -> Result<Self, Self::Error> { match item.router_data.request.payment_method_data.clone() { PaymentMethodData::Card(ref req_card) => { if item.router_data.is_three_ds() { return Err(errors::ConnectorError::NotSupported { message: "3DS payments".to_string(), connector: "Getnet", } .into()); } let request = &item.router_data.request; let auth_type = GetnetAuthType::try_from(&item.router_data.connector_auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; let merchant_account_id = MerchantAccountId { value: auth_type.merchant_id, }; let requested_amount = Amount { value: item.amount, currency: request.currency, }; let account_holder = AccountHolder { first_name: item.router_data.get_optional_billing_first_name(), last_name: item.router_data.get_optional_billing_last_name(), email: item.router_data.request.get_optional_email(), phone: item.router_data.get_optional_billing_phone_number(), address: Some(Address { street1: item.router_data.get_optional_billing_line2(), city: item.router_data.get_optional_billing_city(), state: item.router_data.get_optional_billing_state(), country: item.router_data.get_optional_billing_country(), }), }; let card = Card { account_number: req_card.card_number.clone(), expiration_month: req_card.card_exp_month.clone(), expiration_year: req_card.card_exp_year.clone(), card_security_code: req_card.card_cvc.clone(), card_type: req_card .card_network .as_ref() .map(|network| network.to_string().to_lowercase()) .unwrap_or_default(), }; let pmt = item.router_data.request.get_payment_method_type()?; let payment_method = PaymentMethodContainer::try_from(pmt)?; let notifications: NotificationContainer = NotificationContainer { format: NotificationFormat::JsonSigned, notification: vec![Notification { url: Some(item.router_data.request.get_webhook_url()?), }], }; let transaction_type = if request.is_auto_capture()? { GetnetTransactionType::Purchase } else { GetnetTransactionType::Authorization }; let payment_data = PaymentData { merchant_account_id, request_id: item.router_data.payment_id.clone(), transaction_type, requested_amount, account_holder: Some(account_holder), card, ip_address: Some(request.get_browser_info()?.get_ip_address()?), payment_methods: payment_method, notifications: Some(notifications), }; Ok(Self { payment: payment_data, }) } _ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()), } } } pub struct GetnetAuthType { pub username: Secret<String>, pub password: Secret<String>, pub merchant_id: Secret<String>, } impl TryFrom<&ConnectorAuthType> for GetnetAuthType { type Error = error_stack::Report<errors::ConnectorError>; fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> { match auth_type { ConnectorAuthType::SignatureKey { api_key, key1, api_secret, } => Ok(Self { username: key1.to_owned(), password: api_key.to_owned(), merchant_id: api_secret.to_owned(), }), _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()), } } } #[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "lowercase")] pub enum GetnetPaymentStatus { Success, Failed, #[default] InProgress, } impl From<GetnetPaymentStatus> for AttemptStatus { fn from(item: GetnetPaymentStatus) -> Self { match item { GetnetPaymentStatus::Success => Self::Charged, GetnetPaymentStatus::Failed => Self::Failure, GetnetPaymentStatus::InProgress => Self::Pending, } } } #[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct Status { pub code: String, pub description: String, pub severity: String, } #[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct Statuses { pub status: Vec<Status>, } #[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct CardToken { #[serde(rename = "token-id")] pub token_id: Secret<String>, #[serde(rename = "masked-account-number")] pub masked_account_number: Secret<String>, } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct PaymentResponseData { pub statuses: Statuses, pub descriptor: Option<String>, pub notifications: NotificationContainer, #[serde(rename = "merchant-account-id")] pub merchant_account_id: MerchantAccountId, #[serde(rename = "transaction-id")] pub transaction_id: String, #[serde(rename = "request-id")] pub request_id: String, #[serde(rename = "transaction-type")] pub transaction_type: GetnetTransactionType, #[serde(rename = "transaction-state")] pub transaction_state: GetnetPaymentStatus, #[serde(rename = "completion-time-stamp")] pub completion_time_stamp: Option<i64>, #[serde(rename = "requested-amount")] pub requested_amount: Amount, #[serde(rename = "account-holder")] pub account_holder: Option<AccountHolder>, #[serde(rename = "card-token")] pub card_token: CardToken, #[serde(rename = "ip-address")] pub ip_address: Option<Secret<String, IpAddress>>, #[serde(rename = "payment-methods")] pub payment_methods: PaymentMethodContainer, #[serde(rename = "api-id")] pub api_id: String, #[serde(rename = "self")] pub self_url: String, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct PaymentsResponse { payment: PaymentResponseData, } #[derive(Debug, Serialize, Deserialize)] #[serde(untagged)] pub enum GetnetPaymentsResponse { PaymentsResponse(Box<PaymentsResponse>), GetnetWebhookNotificationResponse(Box<GetnetWebhookNotificationResponseBody>), } pub fn authorization_attempt_status_from_transaction_state( getnet_status: GetnetPaymentStatus, is_auto_capture: bool, ) -> AttemptStatus { match getnet_status { GetnetPaymentStatus::Success => { if is_auto_capture { AttemptStatus::Charged } else { AttemptStatus::Authorized } } GetnetPaymentStatus::InProgress => AttemptStatus::Pending, GetnetPaymentStatus::Failed => AttemptStatus::Failure, } } impl<F> TryFrom< ResponseRouterData<F, GetnetPaymentsResponse, PaymentsAuthorizeData, PaymentsResponseData>, > for RouterData<F, PaymentsAuthorizeData, PaymentsResponseData> { type Error = error_stack::Report<errors::ConnectorError>; fn try_from( item: ResponseRouterData< F, GetnetPaymentsResponse, PaymentsAuthorizeData, PaymentsResponseData, >, ) -> Result<Self, Self::Error> { match item.response { GetnetPaymentsResponse::PaymentsResponse(ref payment_response) => Ok(Self { status: authorization_attempt_status_from_transaction_state( payment_response.payment.transaction_state.clone(), item.data.request.is_auto_capture()?, ), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId( payment_response.payment.transaction_id.clone(), ), redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, charges: None, }), ..item.data }), _ => Err(error_stack::Report::new( errors::ConnectorError::ResponseHandlingFailed, )), } } } pub fn psync_attempt_status_from_transaction_state( getnet_status: GetnetPaymentStatus, is_auto_capture: bool, transaction_type: GetnetTransactionType, ) -> AttemptStatus { match getnet_status { GetnetPaymentStatus::Success => { if is_auto_capture && transaction_type == GetnetTransactionType::CaptureAuthorization { AttemptStatus::Charged } else { AttemptStatus::Authorized } } GetnetPaymentStatus::InProgress => AttemptStatus::Pending, GetnetPaymentStatus::Failed => AttemptStatus::Failure, } } impl TryFrom<PaymentsSyncResponseRouterData<GetnetPaymentsResponse>> for PaymentsSyncRouterData { type Error = error_stack::Report<errors::ConnectorError>; fn try_from( item: PaymentsSyncResponseRouterData<GetnetPaymentsResponse>, ) -> Result<Self, Self::Error> { match item.response { GetnetPaymentsResponse::PaymentsResponse(ref payment_response) => Ok(Self { status: authorization_attempt_status_from_transaction_state( payment_response.payment.transaction_state.clone(), item.data.request.is_auto_capture()?, ), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId( payment_response.payment.transaction_id.clone(), ), redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, charges: None, }), ..item.data }), GetnetPaymentsResponse::GetnetWebhookNotificationResponse(ref webhook_response) => { Ok(Self { status: psync_attempt_status_from_transaction_state( webhook_response.payment.transaction_state.clone(), item.data.request.is_auto_capture()?, webhook_response.payment.transaction_type.clone(), ), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId( webhook_response.payment.transaction_id.clone(), ), redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, charges: None, }), ..item.data }) } } } } #[derive(Debug, Serialize, PartialEq)] pub struct CapturePaymentData { #[serde(rename = "merchant-account-id")] pub merchant_account_id: MerchantAccountId, #[serde(rename = "request-id")] pub request_id: String, #[serde(rename = "transaction-type")] pub transaction_type: GetnetTransactionType, #[serde(rename = "parent-transaction-id")] pub parent_transaction_id: String, #[serde(rename = "requested-amount")] pub requested_amount: Amount, pub notifications: NotificationContainer, #[serde(rename = "ip-address")] pub ip_address: Option<Secret<String, IpAddress>>, } #[derive(Debug, Serialize)] pub struct GetnetCaptureRequest { pub payment: CapturePaymentData, } impl TryFrom<&GetnetRouterData<&PaymentsCaptureRouterData>> for GetnetCaptureRequest { type Error = error_stack::Report<errors::ConnectorError>; fn try_from(item: &GetnetRouterData<&PaymentsCaptureRouterData>) -> Result<Self, Self::Error> { let request = &item.router_data.request; let auth_type = GetnetAuthType::try_from(&item.router_data.connector_auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; let merchant_account_id = MerchantAccountId { value: auth_type.merchant_id, }; let requested_amount = Amount { value: item.amount, currency: request.currency, }; let req = &item.router_data.request; let webhook_url = &req.webhook_url; let notifications = NotificationContainer { format: NotificationFormat::JsonSigned, notification: vec![Notification { url: webhook_url.clone(), }], }; let transaction_type = GetnetTransactionType::CaptureAuthorization; let ip_address = req .browser_info .as_ref() .and_then(|info| info.ip_address.as_ref()) .map(|ip| Secret::new(ip.to_string())); let request_id = item.router_data.connector_request_reference_id.clone(); let parent_transaction_id = item.router_data.request.connector_transaction_id.clone(); let capture_payment_data = CapturePaymentData { merchant_account_id, request_id, transaction_type, parent_transaction_id, requested_amount, notifications, ip_address, }; Ok(Self { payment: capture_payment_data, }) } } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct CaptureResponseData { pub statuses: Statuses, pub descriptor: String, pub notifications: NotificationContainer, #[serde(rename = "merchant-account-id")] pub merchant_account_id: MerchantAccountId, #[serde(rename = "transaction-id")] pub transaction_id: String, #[serde(rename = "request-id")] pub request_id: String, #[serde(rename = "transaction-type")] pub transaction_type: GetnetTransactionType, #[serde(rename = "transaction-state")] pub transaction_state: GetnetPaymentStatus, #[serde(rename = "completion-time-stamp")] pub completion_time_stamp: Option<i64>, #[serde(rename = "requested-amount")] pub requested_amount: Amount, #[serde(rename = "parent-transaction-id")] pub parent_transaction_id: String, #[serde(rename = "account-holder")] pub account_holder: Option<AccountHolder>, #[serde(rename = "card-token")] pub card_token: CardToken, #[serde(rename = "ip-address")] pub ip_address: Option<Secret<String, IpAddress>>, #[serde(rename = "payment-methods")] pub payment_methods: PaymentMethodContainer, #[serde(rename = "parent-transaction-amount")] pub parent_transaction_amount: Amount, #[serde(rename = "authorization-code")] pub authorization_code: String, #[serde(rename = "api-id")] pub api_id: String, #[serde(rename = "self")] pub self_url: String, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct GetnetCaptureResponse { payment: CaptureResponseData, } pub fn capture_status_from_transaction_state(getnet_status: GetnetPaymentStatus) -> AttemptStatus { match getnet_status { GetnetPaymentStatus::Success => AttemptStatus::Charged, GetnetPaymentStatus::InProgress => AttemptStatus::Pending, GetnetPaymentStatus::Failed => AttemptStatus::Authorized, } } impl<F> TryFrom<ResponseRouterData<F, GetnetCaptureResponse, PaymentsCaptureData, PaymentsResponseData>> for RouterData<F, PaymentsCaptureData, PaymentsResponseData> { type Error = error_stack::Report<errors::ConnectorError>; fn try_from( item: ResponseRouterData< F, GetnetCaptureResponse, PaymentsCaptureData, PaymentsResponseData, >, ) -> Result<Self, Self::Error> { Ok(Self { status: capture_status_from_transaction_state(item.response.payment.transaction_state), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId( item.response.payment.transaction_id, ), redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, charges: None, }), ..item.data }) } } #[derive(Debug, Serialize, PartialEq)] pub struct RefundPaymentData { #[serde(rename = "merchant-account-id")] pub merchant_account_id: MerchantAccountId, #[serde(rename = "request-id")] pub request_id: String, #[serde(rename = "transaction-type")] pub transaction_type: GetnetTransactionType, #[serde(rename = "parent-transaction-id")] pub parent_transaction_id: String, pub notifications: NotificationContainer, #[serde(rename = "ip-address")] pub ip_address: Option<Secret<String, IpAddress>>, } #[derive(Debug, Serialize)] pub struct GetnetRefundRequest { pub payment: RefundPaymentData, } impl<F> TryFrom<&GetnetRouterData<&RefundsRouterData<F>>> for GetnetRefundRequest { type Error = error_stack::Report<errors::ConnectorError>; fn try_from(item: &GetnetRouterData<&RefundsRouterData<F>>) -> Result<Self, Self::Error> { let request = &item.router_data.request; let auth_type = GetnetAuthType::try_from(&item.router_data.connector_auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; let url = request.webhook_url.clone(); let merchant_account_id = MerchantAccountId { value: auth_type.merchant_id, }; let notifications = NotificationContainer { format: NotificationFormat::JsonSigned, notification: vec![Notification { url }], }; let capture_method = request.capture_method; let transaction_type = match capture_method { Some(CaptureMethod::Automatic) => GetnetTransactionType::RefundPurchase, Some(CaptureMethod::Manual) => GetnetTransactionType::RefundCapture, Some(CaptureMethod::ManualMultiple) | Some(CaptureMethod::Scheduled) | Some(CaptureMethod::SequentialAutomatic) | None => { return Err(errors::ConnectorError::CaptureMethodNotSupported {}.into()); } }; let ip_address = request .browser_info .as_ref() .and_then(|browser_info| browser_info.ip_address.as_ref()) .map(|ip| Secret::new(ip.to_string())); let request_id = item .router_data .refund_id .clone() .ok_or(errors::ConnectorError::MissingConnectorRefundID)?; let parent_transaction_id = item.router_data.request.connector_transaction_id.clone(); let refund_payment_data = RefundPaymentData { merchant_account_id, request_id, transaction_type, parent_transaction_id, notifications, ip_address, }; Ok(Self { payment: refund_payment_data, }) } } #[allow(dead_code)] #[derive(Debug, Serialize, Default, Deserialize, Clone, PartialEq)] #[serde(rename_all = "lowercase")] pub enum RefundStatus { Success, Failed, #[default] InProgress, } impl From<RefundStatus> for enums::RefundStatus { fn from(item: RefundStatus) -> Self { match item { RefundStatus::Success => Self::Success, RefundStatus::Failed => Self::Failure, RefundStatus::InProgress => Self::Pending, } } } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct RefundResponseData { pub statuses: Statuses, pub descriptor: String, pub notifications: NotificationContainer, #[serde(rename = "merchant-account-id")] pub merchant_account_id: MerchantAccountId, #[serde(rename = "transaction-id")] pub transaction_id: String, #[serde(rename = "request-id")] pub request_id: String, #[serde(rename = "transaction-type")] pub transaction_type: GetnetTransactionType, #[serde(rename = "transaction-state")] pub transaction_state: RefundStatus, #[serde(rename = "completion-time-stamp")] pub completion_time_stamp: Option<i64>, #[serde(rename = "requested-amount")] pub requested_amount: Amount, #[serde(rename = "parent-transaction-id")] #[serde(skip_serializing_if = "Option::is_none")] pub parent_transaction_id: Option<String>, #[serde(rename = "account-holder")] pub account_holder: Option<AccountHolder>, #[serde(rename = "card-token")] pub card_token: CardToken, #[serde(rename = "ip-address")] pub ip_address: Option<Secret<String, IpAddress>>, #[serde(rename = "payment-methods")] pub payment_methods: PaymentMethodContainer, #[serde(rename = "parent-transaction-amount")] #[serde(skip_serializing_if = "Option::is_none")] pub parent_transaction_amount: Option<Amount>, #[serde(rename = "api-id")] pub api_id: String, #[serde(rename = "self")] pub self_url: String, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct RefundResponse { payment: RefundResponseData, } impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> for RefundsRouterData<Execute> { type Error = error_stack::Report<errors::ConnectorError>; fn try_from( item: RefundsResponseRouterData<Execute, RefundResponse>, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: item.response.payment.transaction_id, refund_status: enums::RefundStatus::from(item.response.payment.transaction_state), }), ..item.data }) } } impl TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> for RefundsRouterData<RSync> { type Error = error_stack::Report<errors::ConnectorError>; fn try_from( item: RefundsResponseRouterData<RSync, RefundResponse>, ) -> Result<Self, Self::Error> { Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: item.response.payment.transaction_id, refund_status: enums::RefundStatus::from(item.response.payment.transaction_state), }), ..item.data }) } } #[derive(Debug, Serialize, PartialEq)] pub struct CancelPaymentData { #[serde(rename = "merchant-account-id")] pub merchant_account_id: MerchantAccountId, #[serde(rename = "request-id")] pub request_id: String, #[serde(rename = "transaction-type")] pub transaction_type: GetnetTransactionType, #[serde(rename = "parent-transaction-id")] pub parent_transaction_id: String, pub notifications: NotificationContainer, #[serde(rename = "ip-address")] pub ip_address: Option<Secret<String, IpAddress>>, } #[derive(Debug, Serialize)] pub struct GetnetCancelRequest { pub payment: CancelPaymentData, } impl TryFrom<&PaymentsCancelRouterData> for GetnetCancelRequest { type Error = error_stack::Report<errors::ConnectorError>; fn try_from(item: &PaymentsCancelRouterData) -> Result<Self, Self::Error> { let request = &item.request; let auth_type = GetnetAuthType::try_from(&item.connector_auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; let merchant_account_id = MerchantAccountId { value: auth_type.merchant_id, }; let webhook_url = &item.request.webhook_url; let notifications = NotificationContainer { format: NotificationFormat::JsonSigned, notification: vec![Notification { url: webhook_url.clone(), }], }; let capture_method = &item.request.capture_method; let transaction_type = match capture_method { Some(CaptureMethod::Automatic) => GetnetTransactionType::VoidPurchase, Some(CaptureMethod::Manual) => GetnetTransactionType::VoidAuthorization, Some(CaptureMethod::ManualMultiple) | Some(CaptureMethod::Scheduled) | Some(CaptureMethod::SequentialAutomatic) => { return Err(errors::ConnectorError::CaptureMethodNotSupported {}.into()); } None => { return Err(errors::ConnectorError::CaptureMethodNotSupported {}.into()); } }; let ip_address = request .browser_info .as_ref() .and_then(|browser_info| browser_info.ip_address.as_ref()) .map(|ip| Secret::new(ip.to_string())); let request_id = &item.connector_request_reference_id.clone(); let parent_transaction_id = item.request.connector_transaction_id.clone(); let cancel_payment_data = CancelPaymentData { merchant_account_id, request_id: request_id.to_string(), transaction_type, parent_transaction_id, notifications, ip_address, }; Ok(Self { payment: cancel_payment_data, }) } } #[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] #[serde(rename_all = "lowercase")] pub enum GetnetTransactionType { Purchase, #[serde(rename = "capture-authorization")] CaptureAuthorization, #[serde(rename = "refund-purchase")] RefundPurchase, #[serde(rename = "refund-capture")] RefundCapture, #[serde(rename = "void-authorization")] VoidAuthorization, #[serde(rename = "void-purchase")] VoidPurchase, Authorization, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "lowercase")] pub struct CancelResponseData { pub statuses: Statuses, pub descriptor: String, pub notifications: NotificationContainer, #[serde(rename = "merchant-account-id")] pub merchant_account_id: MerchantAccountId, #[serde(rename = "transaction-id")] pub transaction_id: String, #[serde(rename = "request-id")] pub request_id: String, #[serde(rename = "transaction-type")] pub transaction_type: GetnetTransactionType, #[serde(rename = "transaction-state")] pub transaction_state: GetnetPaymentStatus, #[serde(rename = "completion-time-stamp")] pub completion_time_stamp: Option<i64>, #[serde(rename = "requested-amount")] pub requested_amount: Amount, #[serde(rename = "parent-transaction-id")] pub parent_transaction_id: String, #[serde(rename = "account-holder")] pub account_holder: Option<AccountHolder>, #[serde(rename = "card-token")] pub card_token: CardToken, #[serde(rename = "ip-address")] pub ip_address: Option<Secret<String, IpAddress>>, #[serde(rename = "payment-methods")] pub payment_methods: PaymentMethodContainer, #[serde(rename = "parent-transaction-amount")] pub parent_transaction_amount: Amount, #[serde(rename = "api-id")] pub api_id: String, #[serde(rename = "self")] pub self_url: String, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct GetnetCancelResponse { payment: CancelResponseData, } pub fn cancel_status_from_transaction_state(getnet_status: GetnetPaymentStatus) -> AttemptStatus { match getnet_status { GetnetPaymentStatus::Success => AttemptStatus::Voided, GetnetPaymentStatus::InProgress => AttemptStatus::Pending, GetnetPaymentStatus::Failed => AttemptStatus::VoidFailed, } } impl<F> TryFrom<ResponseRouterData<F, GetnetCancelResponse, PaymentsCancelData, PaymentsResponseData>> for RouterData<F, PaymentsCancelData, PaymentsResponseData> { type Error = error_stack::Report<errors::ConnectorError>; fn try_from( item: ResponseRouterData<F, GetnetCancelResponse, PaymentsCancelData, PaymentsResponseData>, ) -> Result<Self, Self::Error> { Ok(Self { status: cancel_status_from_transaction_state(item.response.payment.transaction_state), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId( item.response.payment.transaction_id, ), redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, charges: None, }), ..item.data }) } } #[derive(Default, Debug, Serialize, Deserialize, PartialEq)] pub struct GetnetErrorResponse { pub status_code: u16, pub code: String, pub message: String, pub reason: Option<String>, } #[derive(Serialize, Deserialize, Debug)] pub struct GetnetWebhookNotificationResponse { #[serde(rename = "response-signature-base64")] pub response_signature_base64: Secret<String>, #[serde(rename = "response-signature-algorithm")] pub response_signature_algorithm: Secret<String>, #[serde(rename = "response-base64")] pub response_base64: Secret<String>, } #[derive(Debug, Serialize, Deserialize, PartialEq)] pub struct WebhookResponseData { pub statuses: Statuses, pub descriptor: String, pub notifications: NotificationContainer, #[serde(rename = "merchant-account-id")] pub merchant_account_id: MerchantAccountId, #[serde(rename = "transaction-id")] pub transaction_id: String, #[serde(rename = "request-id")] pub request_id: String, #[serde(rename = "transaction-type")] pub transaction_type: GetnetTransactionType, #[serde(rename = "transaction-state")] pub transaction_state: GetnetPaymentStatus, #[serde(rename = "completion-time-stamp")] pub completion_time_stamp: u64, #[serde(rename = "requested-amount")] pub requested_amount: Amount, #[serde(rename = "parent-transaction-id")] #[serde(skip_serializing_if = "Option::is_none")] pub parent_transaction_id: Option<String>, #[serde(rename = "account-holder")] pub account_holder: Option<AccountHolder>, #[serde(rename = "card-token")] pub card_token: CardToken, #[serde(rename = "ip-address")] pub ip_address: Option<Secret<String, IpAddress>>, #[serde(rename = "payment-methods")] pub payment_methods: PaymentMethodContainer, #[serde(rename = "parent-transaction-amount")] #[serde(skip_serializing_if = "Option::is_none")] pub parent_transaction_amount: Option<Amount>, #[serde(rename = "authorization-code")] #[serde(skip_serializing_if = "Option::is_none")] pub authorization_code: Option<String>, #[serde(rename = "api-id")] pub api_id: String, #[serde(rename = "provider-account-id")] #[serde(skip_serializing_if = "Option::is_none")] pub provider_account_id: Option<String>, } #[derive(Serialize, Deserialize, Debug)] pub struct GetnetWebhookNotificationResponseBody { pub payment: WebhookResponseData, } pub fn is_refund_event(transaction_type: &GetnetTransactionType) -> bool { matches!( transaction_type, GetnetTransactionType::RefundPurchase | GetnetTransactionType::RefundCapture ) } pub fn get_webhook_object_from_body( body: &[u8], ) -> CustomResult<GetnetWebhookNotificationResponseBody, errors::ConnectorError> { let body_bytes = bytes::Bytes::copy_from_slice(body); let parsed_param: GetnetWebhookNotificationResponse = parse_url_encoded_to_struct(body_bytes) .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; let response_base64 = &parsed_param.response_base64.peek(); let decoded_response = BASE64_ENGINE .decode(response_base64) .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; let getnet_webhook_notification_response: GetnetWebhookNotificationResponseBody = match serde_json::from_slice::<GetnetWebhookNotificationResponseBody>(&decoded_response) { Ok(response) => response, Err(_e) => { return Err(errors::ConnectorError::WebhookBodyDecodingFailed)?; } };
crates/hyperswitch_connectors/src/connectors/getnet/transformers.rs#chunk0
hyperswitch_connectors
chunk
null
null
null
8,186
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
// Function: api_key_list // File: crates/openapi/src/routes/api_keys.rs // Module: openapi pub fn api_key_list()
crates/openapi/src/routes/api_keys.rs
openapi
function_signature
null
null
null
31
api_key_list
null
null
null
null
null
null
// Implementation: impl ThreeDSDecisionRule // File: crates/common_types/src/three_ds_decision_rule_engine.rs // Module: common_types // Methods: 1 total (1 public) impl ThreeDSDecisionRule
crates/common_types/src/three_ds_decision_rule_engine.rs
common_types
impl_block
null
null
null
45
null
ThreeDSDecisionRule
null
1
1
null
null
// Struct: DeutschebankThreeDSInitializeRequestCustomerData // File: crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct DeutschebankThreeDSInitializeRequestCustomerData
crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs
hyperswitch_connectors
struct_definition
DeutschebankThreeDSInitializeRequestCustomerData
0
[]
58
null
null
null
null
null
null
null
// Struct: CardInfoUpdateRequest // File: crates/api_models/src/cards_info.rs // Module: api_models // Implementations: 1 // Traits: ApiEventMetric pub struct CardInfoUpdateRequest
crates/api_models/src/cards_info.rs
api_models
struct_definition
CardInfoUpdateRequest
1
[ "ApiEventMetric" ]
45
null
null
null
null
null
null
null
// Implementation: impl Invoice // File: crates/diesel_models/src/query/invoice.rs // Module: diesel_models // Methods: 2 total (0 public) impl Invoice
crates/diesel_models/src/query/invoice.rs
diesel_models
impl_block
null
null
null
37
null
Invoice
null
2
0
null
null
// Implementation: impl api::ConnectorAccessToken for for Mifinity // File: crates/hyperswitch_connectors/src/connectors/mifinity.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::ConnectorAccessToken for for Mifinity
crates/hyperswitch_connectors/src/connectors/mifinity.rs
hyperswitch_connectors
impl_block
null
null
null
60
null
Mifinity
api::ConnectorAccessToken for
0
0
null
null
// Struct: Dsync // File: crates/hyperswitch_domain_models/src/router_flow_types/dispute.rs // Module: hyperswitch_domain_models // Implementations: 0 pub struct Dsync
crates/hyperswitch_domain_models/src/router_flow_types/dispute.rs
hyperswitch_domain_models
struct_definition
Dsync
0
[]
43
null
null
null
null
null
null
null
// Struct: OutgoingWebhookResponseContent // File: crates/api_models/src/webhook_events.rs // Module: api_models // Implementations: 0 pub struct OutgoingWebhookResponseContent
crates/api_models/src/webhook_events.rs
api_models
struct_definition
OutgoingWebhookResponseContent
0
[]
43
null
null
null
null
null
null
null
// Implementation: impl ConnectorValidation for for Custombilling // File: crates/hyperswitch_connectors/src/connectors/custombilling.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl ConnectorValidation for for Custombilling
crates/hyperswitch_connectors/src/connectors/custombilling.rs
hyperswitch_connectors
impl_block
null
null
null
53
null
Custombilling
ConnectorValidation for
0
0
null
null
// Struct: PayoutListConstraints // File: crates/api_models/src/payouts.rs // Module: api_models // Implementations: 0 pub struct PayoutListConstraints
crates/api_models/src/payouts.rs
api_models
struct_definition
PayoutListConstraints
0
[]
39
null
null
null
null
null
null
null
// Function: get_html_body // File: crates/router/src/services/email/types.rs // Module: router pub fn get_html_body(email_body: EmailBody) -> String
crates/router/src/services/email/types.rs
router
function_signature
null
null
null
36
get_html_body
null
null
null
null
null
null
// Function: get_action_url // File: crates/router/src/core/connector_onboarding.rs // Module: router pub fn get_action_url( state: SessionState, user_from_token: auth::UserFromToken, request: api::ActionUrlRequest, _req_state: ReqState, ) -> RouterResponse<api::ActionUrlResponse>
crates/router/src/core/connector_onboarding.rs
router
function_signature
null
null
null
76
get_action_url
null
null
null
null
null
null
// Struct: CreateUserThemeRequest // File: crates/api_models/src/user/theme.rs // Module: api_models // Implementations: 0 pub struct CreateUserThemeRequest
crates/api_models/src/user/theme.rs
api_models
struct_definition
CreateUserThemeRequest
0
[]
36
null
null
null
null
null
null
null
// File: crates/hyperswitch_connectors/src/connectors/inespay/transformers.rs // Module: hyperswitch_connectors // Public structs: 12 use common_enums::enums; use common_utils::{ request::Method, types::{MinorUnit, StringMinorUnit, StringMinorUnitForConnector}, }; use error_stack::ResultExt; use hyperswitch_domain_models::{ payment_method_data::{BankDebitData, PaymentMethodData}, router_data::{ConnectorAuthType, ErrorResponse, RouterData}, router_flow_types::refunds::{Execute, RSync}, router_request_types::ResponseId, router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData}, types::{PaymentsAuthorizeRouterData, RefundsRouterData}, }; use hyperswitch_interfaces::errors; use masking::Secret; use serde::{Deserialize, Serialize}; use url::Url; use crate::{ types::{RefundsResponseRouterData, ResponseRouterData}, utils::{self, PaymentsAuthorizeRequestData, RouterData as _}, }; pub struct InespayRouterData<T> { pub amount: StringMinorUnit, pub router_data: T, } impl<T> From<(StringMinorUnit, T)> for InespayRouterData<T> { fn from((amount, item): (StringMinorUnit, T)) -> Self { Self { amount, router_data: item, } } } #[derive(Default, Debug, Serialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct InespayPaymentsRequest { description: String, amount: StringMinorUnit, reference: String, debtor_account: Option<Secret<String>>, success_link_redirect: Option<String>, notif_url: Option<String>, } impl TryFrom<&InespayRouterData<&PaymentsAuthorizeRouterData>> for InespayPaymentsRequest { type Error = error_stack::Report<errors::ConnectorError>; fn try_from( item: &InespayRouterData<&PaymentsAuthorizeRouterData>, ) -> Result<Self, Self::Error> { match item.router_data.request.payment_method_data.clone() { PaymentMethodData::BankDebit(BankDebitData::SepaBankDebit { iban, .. }) => { let order_id = item.router_data.connector_request_reference_id.clone(); let webhook_url = item.router_data.request.get_webhook_url()?; let return_url = item.router_data.request.get_router_return_url()?; Ok(Self { description: item.router_data.get_description()?, amount: item.amount.clone(), reference: order_id, debtor_account: Some(iban), success_link_redirect: Some(return_url), notif_url: Some(webhook_url), }) } _ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()), } } } pub struct InespayAuthType { pub(super) api_key: Secret<String>, pub authorization: Secret<String>, } impl TryFrom<&ConnectorAuthType> for InespayAuthType { type Error = error_stack::Report<errors::ConnectorError>; fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> { match auth_type { ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self { api_key: api_key.to_owned(), authorization: key1.to_owned(), }), _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()), } } } #[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct InespayPaymentsResponseData { status: String, status_desc: String, single_payin_id: String, single_payin_link: String, } #[derive(Debug, Deserialize, Serialize)] #[serde(untagged)] pub enum InespayPaymentsResponse { InespayPaymentsData(InespayPaymentsResponseData), InespayPaymentsError(InespayErrorResponse), } impl<F, T> TryFrom<ResponseRouterData<F, InespayPaymentsResponse, T, PaymentsResponseData>> for RouterData<F, T, PaymentsResponseData> { type Error = error_stack::Report<errors::ConnectorError>; fn try_from( item: ResponseRouterData<F, InespayPaymentsResponse, T, PaymentsResponseData>, ) -> Result<Self, Self::Error> { let (status, response) = match item.response { InespayPaymentsResponse::InespayPaymentsData(data) => { let redirection_url = Url::parse(data.single_payin_link.as_str()) .change_context(errors::ConnectorError::ParsingFailed)?; let redirection_data = RedirectForm::from((redirection_url, Method::Get)); ( common_enums::AttemptStatus::AuthenticationPending, Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId( data.single_payin_id.clone(), ), redirection_data: Box::new(Some(redirection_data)), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, charges: None, }), ) } InespayPaymentsResponse::InespayPaymentsError(data) => ( common_enums::AttemptStatus::Failure, Err(ErrorResponse { code: data.status.clone(), message: data.status_desc.clone(), reason: Some(data.status_desc.clone()), attempt_status: None, connector_transaction_id: None, status_code: item.http_code, network_advice_code: None, network_decline_code: None, network_error_message: None, connector_metadata: None, }), ), }; Ok(Self { status, response, ..item.data }) } } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum InespayPSyncStatus { Ok, Created, Opened, BankSelected, Initiated, Pending, Aborted, Unfinished, Rejected, Cancelled, PartiallyAccepted, Failed, Settled, PartRefunded, Refunded, } impl From<InespayPSyncStatus> for common_enums::AttemptStatus { fn from(item: InespayPSyncStatus) -> Self { match item { InespayPSyncStatus::Ok | InespayPSyncStatus::Settled => Self::Charged, InespayPSyncStatus::Created | InespayPSyncStatus::Opened | InespayPSyncStatus::BankSelected | InespayPSyncStatus::Initiated | InespayPSyncStatus::Pending | InespayPSyncStatus::Unfinished | InespayPSyncStatus::PartiallyAccepted => Self::AuthenticationPending, InespayPSyncStatus::Aborted | InespayPSyncStatus::Rejected | InespayPSyncStatus::Cancelled | InespayPSyncStatus::Failed => Self::Failure, InespayPSyncStatus::PartRefunded | InespayPSyncStatus::Refunded => Self::AutoRefunded, } } } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct InespayPSyncResponseData { cod_status: InespayPSyncStatus, status_desc: String, single_payin_id: String, single_payin_link: String, } #[derive(Debug, Deserialize, Serialize)] #[serde(untagged)] pub enum InespayPSyncResponse { InespayPSyncData(InespayPSyncResponseData), InespayPSyncWebhook(InespayPaymentWebhookData), InespayPSyncError(InespayErrorResponse), } impl<F, T> TryFrom<ResponseRouterData<F, InespayPSyncResponse, T, PaymentsResponseData>> for RouterData<F, T, PaymentsResponseData> { type Error = error_stack::Report<errors::ConnectorError>; fn try_from( item: ResponseRouterData<F, InespayPSyncResponse, T, PaymentsResponseData>, ) -> Result<Self, Self::Error> { match item.response { InespayPSyncResponse::InespayPSyncData(data) => { let redirection_url = Url::parse(data.single_payin_link.as_str()) .change_context(errors::ConnectorError::ParsingFailed)?; let redirection_data = RedirectForm::from((redirection_url, Method::Get)); Ok(Self { status: common_enums::AttemptStatus::from(data.cod_status), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId( data.single_payin_id.clone(), ), redirection_data: Box::new(Some(redirection_data)), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, charges: None, }), ..item.data }) } InespayPSyncResponse::InespayPSyncWebhook(data) => { let status = enums::AttemptStatus::from(data.cod_status); Ok(Self { status, response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId( data.single_payin_id.clone(), ), redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, charges: None, }), ..item.data }) } InespayPSyncResponse::InespayPSyncError(data) => Ok(Self { response: Err(ErrorResponse { code: data.status.clone(), message: data.status_desc.clone(), reason: Some(data.status_desc.clone()), attempt_status: None, connector_transaction_id: None, status_code: item.http_code, network_advice_code: None, network_decline_code: None, network_error_message: None, connector_metadata: None, }), ..item.data }), } } } #[derive(Default, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct InespayRefundRequest { single_payin_id: String, amount: Option<MinorUnit>, } impl<F> TryFrom<&InespayRouterData<&RefundsRouterData<F>>> for InespayRefundRequest { type Error = error_stack::Report<errors::ConnectorError>; fn try_from(item: &InespayRouterData<&RefundsRouterData<F>>) -> Result<Self, Self::Error> { let amount = utils::convert_back_amount_to_minor_units( &StringMinorUnitForConnector, item.amount.to_owned(), item.router_data.request.currency, )?; Ok(Self { single_payin_id: item.router_data.request.connector_transaction_id.clone(), amount: Some(amount), }) } } #[derive(Debug, Serialize, Default, Deserialize, Clone, PartialEq)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum InespayRSyncStatus { Confirmed, #[default] Pending, Rejected, Denied, Reversed, Mistake, } impl From<InespayRSyncStatus> for enums::RefundStatus { fn from(item: InespayRSyncStatus) -> Self { match item { InespayRSyncStatus::Confirmed => Self::Success, InespayRSyncStatus::Pending => Self::Pending, InespayRSyncStatus::Rejected | InespayRSyncStatus::Denied | InespayRSyncStatus::Reversed | InespayRSyncStatus::Mistake => Self::Failure, } } } #[derive(Default, Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct RefundsData { status: String, status_desc: String, refund_id: String, } #[derive(Debug, Deserialize, Serialize)] #[serde(untagged)] pub enum InespayRefundsResponse { InespayRefundsData(RefundsData), InespayRefundsError(InespayErrorResponse), } impl TryFrom<RefundsResponseRouterData<Execute, InespayRefundsResponse>> for RefundsRouterData<Execute> { type Error = error_stack::Report<errors::ConnectorError>; fn try_from( item: RefundsResponseRouterData<Execute, InespayRefundsResponse>, ) -> Result<Self, Self::Error> { match item.response { InespayRefundsResponse::InespayRefundsData(data) => Ok(Self { response: Ok(RefundsResponseData { connector_refund_id: data.refund_id, refund_status: enums::RefundStatus::Pending, }), ..item.data }), InespayRefundsResponse::InespayRefundsError(data) => Ok(Self { response: Err(ErrorResponse { code: data.status.clone(), message: data.status_desc.clone(), reason: Some(data.status_desc.clone()), attempt_status: None, connector_transaction_id: None, status_code: item.http_code, network_advice_code: None, network_decline_code: None, network_error_message: None, connector_metadata: None, }), ..item.data }), } } } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct InespayRSyncResponseData { cod_status: InespayRSyncStatus, status_desc: String, refund_id: String, } #[derive(Debug, Deserialize, Serialize)] #[serde(untagged)] pub enum InespayRSyncResponse { InespayRSyncData(InespayRSyncResponseData), InespayRSyncWebhook(InespayRefundWebhookData), InespayRSyncError(InespayErrorResponse), } impl TryFrom<RefundsResponseRouterData<RSync, InespayRSyncResponse>> for RefundsRouterData<RSync> { type Error = error_stack::Report<errors::ConnectorError>; fn try_from( item: RefundsResponseRouterData<RSync, InespayRSyncResponse>, ) -> Result<Self, Self::Error> { let response = match item.response { InespayRSyncResponse::InespayRSyncData(data) => Ok(RefundsResponseData { connector_refund_id: data.refund_id, refund_status: enums::RefundStatus::from(data.cod_status), }), InespayRSyncResponse::InespayRSyncWebhook(data) => Ok(RefundsResponseData { connector_refund_id: data.refund_id, refund_status: enums::RefundStatus::from(data.cod_status), }), InespayRSyncResponse::InespayRSyncError(data) => Err(ErrorResponse { code: data.status.clone(), message: data.status_desc.clone(), reason: Some(data.status_desc.clone()), attempt_status: None, connector_transaction_id: None, status_code: item.http_code, network_advice_code: None, network_decline_code: None, network_error_message: None, connector_metadata: None, }), }; Ok(Self { response, ..item.data }) } } #[derive(Serialize, Deserialize, Clone, Debug)] #[serde(rename_all = "camelCase")] pub struct InespayPaymentWebhookData { pub single_payin_id: String, pub cod_status: InespayPSyncStatus, pub description: String, pub amount: MinorUnit, pub reference: String, pub creditor_account: Secret<String>, pub debtor_name: Secret<String>, pub debtor_account: Secret<String>, pub custom_data: Option<String>, } #[derive(Serialize, Deserialize, Clone, Debug)] #[serde(rename_all = "camelCase")] pub struct InespayRefundWebhookData { pub refund_id: String, pub simple_payin_id: String, pub cod_status: InespayRSyncStatus, pub description: String, pub amount: MinorUnit, pub reference: String, } #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(untagged)] pub enum InespayWebhookEventData { Payment(InespayPaymentWebhookData), Refund(InespayRefundWebhookData), } #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "camelCase")] pub struct InespayWebhookEvent { pub data_return: String, pub signature_data_return: String, } #[derive(Default, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct InespayErrorResponse { pub status: String, pub status_desc: String, } impl From<InespayWebhookEventData> for api_models::webhooks::IncomingWebhookEvent { fn from(item: InespayWebhookEventData) -> Self { match item { InespayWebhookEventData::Payment(payment_data) => match payment_data.cod_status { InespayPSyncStatus::Ok | InespayPSyncStatus::Settled => Self::PaymentIntentSuccess, InespayPSyncStatus::Failed | InespayPSyncStatus::Rejected => { Self::PaymentIntentFailure } InespayPSyncStatus::Created | InespayPSyncStatus::Opened | InespayPSyncStatus::BankSelected | InespayPSyncStatus::Initiated | InespayPSyncStatus::Pending | InespayPSyncStatus::Unfinished | InespayPSyncStatus::PartiallyAccepted => Self::PaymentIntentProcessing, InespayPSyncStatus::Aborted | InespayPSyncStatus::Cancelled | InespayPSyncStatus::PartRefunded | InespayPSyncStatus::Refunded => Self::EventNotSupported, }, InespayWebhookEventData::Refund(refund_data) => match refund_data.cod_status { InespayRSyncStatus::Confirmed => Self::RefundSuccess, InespayRSyncStatus::Rejected | InespayRSyncStatus::Denied | InespayRSyncStatus::Reversed | InespayRSyncStatus::Mistake => Self::RefundFailure, InespayRSyncStatus::Pending => Self::EventNotSupported, }, } } }
crates/hyperswitch_connectors/src/connectors/inespay/transformers.rs
hyperswitch_connectors
full_file
null
null
null
4,065
null
null
null
null
null
null
null
// Implementation: impl GetSubscriptionPlanPricesV2 for for Chargebee // File: crates/hyperswitch_connectors/src/connectors/chargebee.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl GetSubscriptionPlanPricesV2 for for Chargebee
crates/hyperswitch_connectors/src/connectors/chargebee.rs
hyperswitch_connectors
impl_block
null
null
null
62
null
Chargebee
GetSubscriptionPlanPricesV2 for
0
0
null
null
// Struct: StripeConnectPayoutFulfillResponse // File: crates/hyperswitch_connectors/src/connectors/stripe/transformers/connect.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct StripeConnectPayoutFulfillResponse
crates/hyperswitch_connectors/src/connectors/stripe/transformers/connect.rs
hyperswitch_connectors
struct_definition
StripeConnectPayoutFulfillResponse
0
[]
56
null
null
null
null
null
null
null
// Function: new // File: crates/hyperswitch_connectors/src/connectors/fiserv.rs // Module: hyperswitch_connectors pub fn new() -> &'static Self
crates/hyperswitch_connectors/src/connectors/fiserv.rs
hyperswitch_connectors
function_signature
null
null
null
39
new
null
null
null
null
null
null
// Function: validate // File: crates/api_models/src/admin.rs // Module: api_models pub fn validate(&self) -> Result<(), &str>
crates/api_models/src/admin.rs
api_models
function_signature
null
null
null
33
validate
null
null
null
null
null
null
// Struct: MultisafepayRouterData // File: crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct MultisafepayRouterData<T>
crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs
hyperswitch_connectors
struct_definition
MultisafepayRouterData
0
[]
61
null
null
null
null
null
null
null
// Struct: ThreeDSAuthData // File: crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct ThreeDSAuthData
crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs
hyperswitch_connectors
struct_definition
ThreeDSAuthData
0
[]
51
null
null
null
null
null
null
null
// Module Structure // File: crates/hyperswitch_connectors/src/connectors/cashtocode/transformers.rs // Module: hyperswitch_connectors // Public exports: pub use common_utils::request::Method;
crates/hyperswitch_connectors/src/connectors/cashtocode/transformers.rs
hyperswitch_connectors
module_structure
null
null
null
47
null
null
null
null
null
0
1
// Implementation: impl StructType // File: crates/router_derive/src/macros/to_encryptable.rs // Module: router_derive // Methods: 4 total (0 public) impl StructType
crates/router_derive/src/macros/to_encryptable.rs
router_derive
impl_block
null
null
null
42
null
StructType
null
4
0
null
null
// Struct: ParentGroupInfoRequest // File: crates/api_models/src/user_role/role.rs // Module: api_models // Implementations: 0 pub struct ParentGroupInfoRequest
crates/api_models/src/user_role/role.rs
api_models
struct_definition
ParentGroupInfoRequest
0
[]
40
null
null
null
null
null
null
null
// Implementation: impl SdkEventMetricsAccumulator // File: crates/analytics/src/sdk_events/accumulator.rs // Module: analytics // Methods: 1 total (1 public) impl SdkEventMetricsAccumulator
crates/analytics/src/sdk_events/accumulator.rs
analytics
impl_block
null
null
null
48
null
SdkEventMetricsAccumulator
null
1
1
null
null
// Function: find_by_merchant_id_payout_attempt_id // File: crates/diesel_models/src/query/payout_attempt.rs // Module: diesel_models pub fn find_by_merchant_id_payout_attempt_id( conn: &PgPooledConn, merchant_id: &common_utils::id_type::MerchantId, payout_attempt_id: &str, ) -> StorageResult<Self>
crates/diesel_models/src/query/payout_attempt.rs
diesel_models
function_signature
null
null
null
83
find_by_merchant_id_payout_attempt_id
null
null
null
null
null
null
// Struct: Reason // File: crates/hyperswitch_connectors/src/connectors/hipay/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct Reason
crates/hyperswitch_connectors/src/connectors/hipay/transformers.rs
hyperswitch_connectors
struct_definition
Reason
0
[]
44
null
null
null
null
null
null
null
// Struct: StripeConnectReversalRequest // File: crates/hyperswitch_connectors/src/connectors/stripe/transformers/connect.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct StripeConnectReversalRequest
crates/hyperswitch_connectors/src/connectors/stripe/transformers/connect.rs
hyperswitch_connectors
struct_definition
StripeConnectReversalRequest
0
[]
54
null
null
null
null
null
null
null
// Struct: GpayInfo // File: crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct GpayInfo
crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs
hyperswitch_connectors
struct_definition
GpayInfo
0
[]
51
null
null
null
null
null
null
null
// Struct: PaymentMethodTokenResult // File: crates/router/src/types.rs // Module: router // Implementations: 0 pub struct PaymentMethodTokenResult
crates/router/src/types.rs
router
struct_definition
PaymentMethodTokenResult
0
[]
35
null
null
null
null
null
null
null
// Function: get_merchant_api_event_filters // File: crates/router/src/analytics.rs // Module: router pub fn get_merchant_api_event_filters( state: web::Data<AppState>, req: actix_web::HttpRequest, json_payload: web::Json<GetApiEventFiltersRequest>, ) -> impl Responder
crates/router/src/analytics.rs
router
function_signature
null
null
null
72
get_merchant_api_event_filters
null
null
null
null
null
null
// Function: log_payment_attempt_delete // File: crates/router/src/services/kafka.rs // Module: router pub fn log_payment_attempt_delete( &self, delete_old_attempt: &PaymentAttempt, tenant_id: TenantID, ) -> MQResult<()>
crates/router/src/services/kafka.rs
router
function_signature
null
null
null
57
log_payment_attempt_delete
null
null
null
null
null
null
// Implementation: impl RelationResolution // File: crates/hyperswitch_constraint_graph/src/types.rs // Module: hyperswitch_constraint_graph // Methods: 1 total (1 public) impl RelationResolution
crates/hyperswitch_constraint_graph/src/types.rs
hyperswitch_constraint_graph
impl_block
null
null
null
42
null
RelationResolution
null
1
1
null
null
// Implementation: impl crate::events::ApiEventMetric for for GlobalPaymentMethodSessionId // File: crates/common_utils/src/id_type/global_id/payment_methods.rs // Module: common_utils // Methods: 1 total (0 public) impl crate::events::ApiEventMetric for for GlobalPaymentMethodSessionId
crates/common_utils/src/id_type/global_id/payment_methods.rs
common_utils
impl_block
null
null
null
65
null
GlobalPaymentMethodSessionId
crate::events::ApiEventMetric for
1
0
null
null
// Struct: StoredCredential // File: crates/hyperswitch_connectors/src/connectors/globalpay/requests.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct StoredCredential
crates/hyperswitch_connectors/src/connectors/globalpay/requests.rs
hyperswitch_connectors
struct_definition
StoredCredential
0
[]
44
null
null
null
null
null
null
null
// Function: get_verified_apple_domains_with_mid_mca_id // File: crates/router/src/core/verification.rs // Module: router pub fn get_verified_apple_domains_with_mid_mca_id( state: SessionState, merchant_id: common_utils::id_type::MerchantId, merchant_connector_id: common_utils::id_type::MerchantConnectorAccountId, ) -> CustomResult< services::ApplicationResponse<verifications::ApplepayVerifiedDomainsResponse>, errors::ApiErrorResponse, >
crates/router/src/core/verification.rs
router
function_signature
null
null
null
104
get_verified_apple_domains_with_mid_mca_id
null
null
null
null
null
null
// Function: validate_and_get_records_with_errors // File: crates/api_models/src/revenue_recovery_data_backfill.rs // Module: api_models pub fn validate_and_get_records_with_errors(&self) -> Result<CsvParsingResult, BackfillError>
crates/api_models/src/revenue_recovery_data_backfill.rs
api_models
function_signature
null
null
null
53
validate_and_get_records_with_errors
null
null
null
null
null
null
// Struct: PayoutsData // File: crates/hyperswitch_domain_models/src/router_request_types.rs // Module: hyperswitch_domain_models // Implementations: 0 pub struct PayoutsData
crates/hyperswitch_domain_models/src/router_request_types.rs
hyperswitch_domain_models
struct_definition
PayoutsData
0
[]
45
null
null
null
null
null
null
null
// Struct: BankOfAmericaAuthorizationOptions // File: crates/hyperswitch_connectors/src/connectors/bankofamerica/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct BankOfAmericaAuthorizationOptions
crates/hyperswitch_connectors/src/connectors/bankofamerica/transformers.rs
hyperswitch_connectors
struct_definition
BankOfAmericaAuthorizationOptions
0
[]
54
null
null
null
null
null
null
null
// Function: update_algorithm_id // File: crates/api_models/src/routing.rs // Module: api_models pub fn update_algorithm_id(&mut self, new_id: common_utils::id_type::RoutingId)
crates/api_models/src/routing.rs
api_models
function_signature
null
null
null
45
update_algorithm_id
null
null
null
null
null
null
fn get_optional_user_agent(&self) -> Option<String>; fn get_original_amount(&self) -> i64; fn get_surcharge_amount(&self) -> Option<i64>; fn get_tax_on_surcharge_amount(&self) -> Option<i64>; fn get_total_surcharge_amount(&self) -> Option<i64>; fn get_metadata_as_object(&self) -> Option<pii::SecretSerdeValue>; fn get_authentication_data(&self) -> Result<AuthenticationData, Error>; fn get_customer_name(&self) -> Result<Secret<String>, Error>; fn get_connector_mandate_request_reference_id(&self) -> Result<String, Error>; fn get_card_holder_name_from_additional_payment_method_data( &self, ) -> Result<Secret<String>, Error>; fn is_cit_mandate_payment(&self) -> bool; fn get_optional_network_transaction_id(&self) -> Option<String>; fn get_optional_email(&self) -> Option<Email>; fn get_card_network_from_additional_payment_method_data( &self, ) -> Result<enums::CardNetwork, Error>; fn get_connector_testing_data(&self) -> Option<pii::SecretSerdeValue>; fn get_order_id(&self) -> Result<String, errors::ConnectorError>; fn get_card_mandate_info(&self) -> Result<CardMandateInfo, Error>; } impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData { fn is_auto_capture(&self) -> Result<bool, Error> { match self.capture_method { Some(enums::CaptureMethod::Automatic) | Some(enums::CaptureMethod::SequentialAutomatic) | None => Ok(true), Some(enums::CaptureMethod::Manual) => Ok(false), Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()), } } fn get_email(&self) -> Result<Email, Error> { self.email.clone().ok_or_else(missing_field_err("email")) } fn get_browser_info(&self) -> Result<BrowserInformation, Error> { self.browser_info .clone() .ok_or_else(missing_field_err("browser_info")) } fn get_optional_language_from_browser_info(&self) -> Option<String> { self.browser_info .clone() .and_then(|browser_info| browser_info.language) } fn get_order_details(&self) -> Result<Vec<OrderDetailsWithAmount>, Error> { self.order_details .clone() .ok_or_else(missing_field_err("order_details")) } fn get_card(&self) -> Result<Card, Error> { match self.payment_method_data.clone() { PaymentMethodData::Card(card) => Ok(card), _ => Err(missing_field_err("card")()), } } fn get_complete_authorize_url(&self) -> Result<String, Error> { self.complete_authorize_url .clone() .ok_or_else(missing_field_err("complete_authorize_url")) } fn connector_mandate_id(&self) -> Option<String> { self.mandate_id .as_ref() .and_then(|mandate_ids| match &mandate_ids.mandate_reference_id { Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => { connector_mandate_ids.get_connector_mandate_id() } Some(payments::MandateReferenceId::NetworkMandateId(_)) | None | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None, }) } fn is_mandate_payment(&self) -> bool { ((self.customer_acceptance.is_some() || self.setup_mandate_details.is_some()) && (self.setup_future_usage == Some(FutureUsage::OffSession))) || self .mandate_id .as_ref() .and_then(|mandate_ids| mandate_ids.mandate_reference_id.as_ref()) .is_some() } fn get_webhook_url(&self) -> Result<String, Error> { self.webhook_url .clone() .ok_or_else(missing_field_err("webhook_url")) } fn get_router_return_url(&self) -> Result<String, Error> { self.router_return_url .clone() .ok_or_else(missing_field_err("return_url")) } fn is_wallet(&self) -> bool { matches!(self.payment_method_data, PaymentMethodData::Wallet(_)) } fn is_card(&self) -> bool { matches!(self.payment_method_data, PaymentMethodData::Card(_)) } fn get_payment_method_type(&self) -> Result<enums::PaymentMethodType, Error> { self.payment_method_type .to_owned() .ok_or_else(missing_field_err("payment_method_type")) } fn get_connector_mandate_id(&self) -> Result<String, Error> { self.connector_mandate_id() .ok_or_else(missing_field_err("connector_mandate_id")) } fn get_ip_address_as_optional(&self) -> Option<Secret<String, IpAddress>> { self.browser_info.clone().and_then(|browser_info| { browser_info .ip_address .map(|ip| Secret::new(ip.to_string())) }) } fn get_ip_address(&self) -> Result<Secret<String, IpAddress>, Error> { let ip_address = self .browser_info .clone() .and_then(|browser_info| browser_info.ip_address); let val = ip_address.ok_or_else(missing_field_err("browser_info.ip_address"))?; Ok(Secret::new(val.to_string())) } fn get_optional_user_agent(&self) -> Option<String> { self.browser_info .clone() .and_then(|browser_info| browser_info.user_agent) } fn get_original_amount(&self) -> i64 { self.surcharge_details .as_ref() .map(|surcharge_details| surcharge_details.original_amount.get_amount_as_i64()) .unwrap_or(self.amount) } fn get_surcharge_amount(&self) -> Option<i64> { self.surcharge_details .as_ref() .map(|surcharge_details| surcharge_details.surcharge_amount.get_amount_as_i64()) } fn get_tax_on_surcharge_amount(&self) -> Option<i64> { self.surcharge_details.as_ref().map(|surcharge_details| { surcharge_details .tax_on_surcharge_amount .get_amount_as_i64() }) } fn get_total_surcharge_amount(&self) -> Option<i64> { self.surcharge_details.as_ref().map(|surcharge_details| { surcharge_details .get_total_surcharge_amount() .get_amount_as_i64() }) } fn is_customer_initiated_mandate_payment(&self) -> bool { (self.customer_acceptance.is_some() || self.setup_mandate_details.is_some()) && self.setup_future_usage == Some(FutureUsage::OffSession) } fn get_metadata_as_object(&self) -> Option<pii::SecretSerdeValue> { self.metadata.clone().and_then(|meta_data| match meta_data { Value::Null | Value::Bool(_) | Value::Number(_) | Value::String(_) | Value::Array(_) => None, Value::Object(_) => Some(meta_data.into()), }) } fn get_authentication_data(&self) -> Result<AuthenticationData, Error> { self.authentication_data .clone() .ok_or_else(missing_field_err("authentication_data")) } fn get_customer_name(&self) -> Result<Secret<String>, Error> { self.customer_name .clone() .ok_or_else(missing_field_err("customer_name")) } fn get_card_holder_name_from_additional_payment_method_data( &self, ) -> Result<Secret<String>, Error> { match &self.additional_payment_method_data { Some(payments::AdditionalPaymentData::Card(card_data)) => Ok(card_data .card_holder_name .clone() .ok_or_else(|| errors::ConnectorError::MissingRequiredField { field_name: "card_holder_name", })?), _ => Err(errors::ConnectorError::MissingRequiredFields { field_names: vec!["card_holder_name"], } .into()), } } /// Attempts to retrieve the connector mandate reference ID as a `Result<String, Error>`. fn get_connector_mandate_request_reference_id(&self) -> Result<String, Error> { self.mandate_id .as_ref() .and_then(|mandate_ids| match &mandate_ids.mandate_reference_id { Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => { connector_mandate_ids.get_connector_mandate_request_reference_id() } Some(payments::MandateReferenceId::NetworkMandateId(_)) | None | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None, }) .ok_or_else(missing_field_err("connector_mandate_request_reference_id")) } fn is_cit_mandate_payment(&self) -> bool { (self.customer_acceptance.is_some() || self.setup_mandate_details.is_some()) && self.setup_future_usage == Some(FutureUsage::OffSession) } fn get_optional_network_transaction_id(&self) -> Option<String> { self.mandate_id .as_ref() .and_then(|mandate_ids| match &mandate_ids.mandate_reference_id { Some(payments::MandateReferenceId::NetworkMandateId(network_transaction_id)) => { Some(network_transaction_id.clone()) } Some(payments::MandateReferenceId::ConnectorMandateId(_)) | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) | None => None, }) } fn get_optional_email(&self) -> Option<Email> { self.email.clone() } fn get_card_network_from_additional_payment_method_data( &self, ) -> Result<enums::CardNetwork, Error> { match &self.additional_payment_method_data { Some(payments::AdditionalPaymentData::Card(card_data)) => Ok(card_data .card_network .clone() .ok_or_else(|| errors::ConnectorError::MissingRequiredField { field_name: "card_network", })?), _ => Err(errors::ConnectorError::MissingRequiredFields { field_names: vec!["card_network"], } .into()), } } fn get_connector_testing_data(&self) -> Option<pii::SecretSerdeValue> { self.connector_testing_data.clone() } fn get_order_id(&self) -> Result<String, errors::ConnectorError> { self.order_id .to_owned() .ok_or(errors::ConnectorError::RequestEncodingFailed) } fn get_card_mandate_info(&self) -> Result<CardMandateInfo, Error> { match &self.additional_payment_method_data { Some(payments::AdditionalPaymentData::Card(card_data)) => Ok(CardMandateInfo { card_exp_month: card_data.card_exp_month.clone().ok_or_else(|| { errors::ConnectorError::MissingRequiredField { field_name: "card_exp_month", } })?, card_exp_year: card_data.card_exp_year.clone().ok_or_else(|| { errors::ConnectorError::MissingRequiredField { field_name: "card_exp_year", } })?, }), _ => Err(errors::ConnectorError::MissingRequiredFields { field_names: vec!["card_exp_month", "card_exp_year"], } .into()), } } } pub trait PaymentsCaptureRequestData { fn get_optional_language_from_browser_info(&self) -> Option<String>; fn is_multiple_capture(&self) -> bool; fn get_browser_info(&self) -> Result<BrowserInformation, Error>; fn get_webhook_url(&self) -> Result<String, Error>; } impl PaymentsCaptureRequestData for PaymentsCaptureData { fn is_multiple_capture(&self) -> bool { self.multiple_capture_data.is_some() } fn get_browser_info(&self) -> Result<BrowserInformation, Error> { self.browser_info .clone() .ok_or_else(missing_field_err("browser_info")) } fn get_optional_language_from_browser_info(&self) -> Option<String> { self.browser_info .clone() .and_then(|browser_info| browser_info.language) } fn get_webhook_url(&self) -> Result<String, Error> { self.webhook_url .clone() .ok_or_else(missing_field_err("webhook_url")) } } pub trait PaymentsSyncRequestData { fn is_auto_capture(&self) -> Result<bool, Error>; fn get_connector_transaction_id(&self) -> CustomResult<String, errors::ConnectorError>; fn is_mandate_payment(&self) -> bool; fn get_optional_connector_transaction_id(&self) -> Option<String>; } impl PaymentsSyncRequestData for PaymentsSyncData { fn is_auto_capture(&self) -> Result<bool, Error> { match self.capture_method { Some(enums::CaptureMethod::Automatic) | Some(enums::CaptureMethod::SequentialAutomatic) | None => Ok(true), Some(enums::CaptureMethod::Manual) => Ok(false), Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()), } } fn get_connector_transaction_id(&self) -> CustomResult<String, errors::ConnectorError> { match self.connector_transaction_id.clone() { ResponseId::ConnectorTransactionId(txn_id) => Ok(txn_id), _ => Err( common_utils::errors::ValidationError::IncorrectValueProvided { field_name: "connector_transaction_id", }, ) .attach_printable("Expected connector transaction ID not found") .change_context(errors::ConnectorError::MissingConnectorTransactionID)?, } } fn is_mandate_payment(&self) -> bool { matches!(self.setup_future_usage, Some(FutureUsage::OffSession)) } fn get_optional_connector_transaction_id(&self) -> Option<String> { match self.connector_transaction_id.clone() { ResponseId::ConnectorTransactionId(txn_id) => Some(txn_id), _ => None, } } } pub trait PaymentsPostSessionTokensRequestData { fn is_auto_capture(&self) -> Result<bool, Error>; } impl PaymentsPostSessionTokensRequestData for PaymentsPostSessionTokensData { fn is_auto_capture(&self) -> Result<bool, Error> { match self.capture_method { Some(enums::CaptureMethod::Automatic) | None | Some(enums::CaptureMethod::SequentialAutomatic) => Ok(true), Some(enums::CaptureMethod::Manual) => Ok(false), Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()), } } } pub trait PaymentsCancelRequestData { fn get_optional_language_from_browser_info(&self) -> Option<String>; fn get_amount(&self) -> Result<i64, Error>; fn get_currency(&self) -> Result<enums::Currency, Error>; fn get_cancellation_reason(&self) -> Result<String, Error>; fn get_browser_info(&self) -> Result<BrowserInformation, Error>; fn get_webhook_url(&self) -> Result<String, Error>; } impl PaymentsCancelRequestData for PaymentsCancelData { fn get_amount(&self) -> Result<i64, Error> { self.amount.ok_or_else(missing_field_err("amount")) } fn get_currency(&self) -> Result<enums::Currency, Error> { self.currency.ok_or_else(missing_field_err("currency")) } fn get_cancellation_reason(&self) -> Result<String, Error> { self.cancellation_reason .clone() .ok_or_else(missing_field_err("cancellation_reason")) } fn get_browser_info(&self) -> Result<BrowserInformation, Error> { self.browser_info .clone() .ok_or_else(missing_field_err("browser_info")) } fn get_optional_language_from_browser_info(&self) -> Option<String> { self.browser_info .clone() .and_then(|browser_info| browser_info.language) } fn get_webhook_url(&self) -> Result<String, Error> { self.webhook_url .clone() .ok_or_else(missing_field_err("webhook_url")) } } pub trait RefundsRequestData { fn get_optional_language_from_browser_info(&self) -> Option<String>; fn get_connector_refund_id(&self) -> Result<String, Error>; fn get_webhook_url(&self) -> Result<String, Error>; fn get_browser_info(&self) -> Result<BrowserInformation, Error>; fn get_connector_metadata(&self) -> Result<Value, Error>; } impl RefundsRequestData for RefundsData { #[track_caller] fn get_connector_refund_id(&self) -> Result<String, Error> { self.connector_refund_id .clone() .get_required_value("connector_refund_id") .change_context(errors::ConnectorError::MissingConnectorTransactionID) } fn get_webhook_url(&self) -> Result<String, Error> { self.webhook_url .clone() .ok_or_else(missing_field_err("webhook_url")) } fn get_browser_info(&self) -> Result<BrowserInformation, Error> { self.browser_info .clone() .ok_or_else(missing_field_err("browser_info")) } fn get_optional_language_from_browser_info(&self) -> Option<String> { self.browser_info .clone() .and_then(|browser_info| browser_info.language) } fn get_connector_metadata(&self) -> Result<Value, Error> { self.connector_metadata .clone() .ok_or_else(missing_field_err("connector_metadata")) } } pub trait PaymentsSetupMandateRequestData { fn get_browser_info(&self) -> Result<BrowserInformation, Error>; fn get_email(&self) -> Result<Email, Error>; fn get_router_return_url(&self) -> Result<String, Error>; fn is_card(&self) -> bool; fn get_return_url(&self) -> Result<String, Error>; fn get_webhook_url(&self) -> Result<String, Error>; fn get_optional_language_from_browser_info(&self) -> Option<String>; fn get_complete_authorize_url(&self) -> Result<String, Error>; fn is_auto_capture(&self) -> Result<bool, Error>; fn is_customer_initiated_mandate_payment(&self) -> bool; } impl PaymentsSetupMandateRequestData for SetupMandateRequestData { fn get_browser_info(&self) -> Result<BrowserInformation, Error> { self.browser_info .clone() .ok_or_else(missing_field_err("browser_info")) } fn get_email(&self) -> Result<Email, Error> { self.email.clone().ok_or_else(missing_field_err("email")) } fn get_router_return_url(&self) -> Result<String, Error> { self.router_return_url .clone() .ok_or_else(missing_field_err("router_return_url")) } fn is_card(&self) -> bool { matches!(self.payment_method_data, PaymentMethodData::Card(_)) } fn get_return_url(&self) -> Result<String, Error> { self.router_return_url .clone() .ok_or_else(missing_field_err("return_url")) } fn get_webhook_url(&self) -> Result<String, Error> { self.webhook_url .clone() .ok_or_else(missing_field_err("webhook_url")) } fn get_optional_language_from_browser_info(&self) -> Option<String> { self.browser_info .clone() .and_then(|browser_info| browser_info.language) } fn get_complete_authorize_url(&self) -> Result<String, Error> { self.complete_authorize_url .clone() .ok_or_else(missing_field_err("complete_authorize_url")) } fn is_auto_capture(&self) -> Result<bool, Error> { match self.capture_method { Some(enums::CaptureMethod::Automatic) | Some(enums::CaptureMethod::SequentialAutomatic) | None => Ok(true), Some(enums::CaptureMethod::Manual) => Ok(false), Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()), } } fn is_customer_initiated_mandate_payment(&self) -> bool { (self.customer_acceptance.is_some() || self.setup_mandate_details.is_some()) && self.setup_future_usage == Some(FutureUsage::OffSession) } } pub trait PaymentMethodTokenizationRequestData { fn get_browser_info(&self) -> Result<BrowserInformation, Error>; fn is_mandate_payment(&self) -> bool; } impl PaymentMethodTokenizationRequestData for PaymentMethodTokenizationData { fn get_browser_info(&self) -> Result<BrowserInformation, Error> { self.browser_info .clone() .ok_or_else(missing_field_err("browser_info")) } fn is_mandate_payment(&self) -> bool { ((self.customer_acceptance.is_some() || self.setup_mandate_details.is_some()) && (self.setup_future_usage == Some(FutureUsage::OffSession))) || self .mandate_id .as_ref() .and_then(|mandate_ids| mandate_ids.mandate_reference_id.as_ref()) .is_some() } } pub trait PaymentsCompleteAuthorizeRequestData { fn is_auto_capture(&self) -> Result<bool, Error>; fn get_email(&self) -> Result<Email, Error>; fn get_redirect_response_payload(&self) -> Result<pii::SecretSerdeValue, Error>; fn get_complete_authorize_url(&self) -> Result<String, Error>; fn is_mandate_payment(&self) -> bool; fn get_connector_mandate_request_reference_id(&self) -> Result<String, Error>; fn is_cit_mandate_payment(&self) -> bool; fn get_browser_info(&self) -> Result<BrowserInformation, Error>; fn get_threeds_method_comp_ind(&self) -> Result<payments::ThreeDsCompletionIndicator, Error>; } impl PaymentsCompleteAuthorizeRequestData for CompleteAuthorizeData { fn is_auto_capture(&self) -> Result<bool, Error> { match self.capture_method { Some(enums::CaptureMethod::Automatic) | Some(enums::CaptureMethod::SequentialAutomatic) | None => Ok(true), Some(enums::CaptureMethod::Manual) => Ok(false), Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()), } } fn get_email(&self) -> Result<Email, Error> { self.email.clone().ok_or_else(missing_field_err("email")) } fn get_redirect_response_payload(&self) -> Result<pii::SecretSerdeValue, Error> { self.redirect_response .as_ref() .and_then(|res| res.payload.to_owned()) .ok_or( errors::ConnectorError::MissingConnectorRedirectionPayload { field_name: "request.redirect_response.payload", } .into(), ) } fn get_complete_authorize_url(&self) -> Result<String, Error> { self.complete_authorize_url .clone() .ok_or_else(missing_field_err("complete_authorize_url")) } fn is_mandate_payment(&self) -> bool { ((self.customer_acceptance.is_some() || self.setup_mandate_details.is_some()) && self.setup_future_usage == Some(FutureUsage::OffSession)) || self .mandate_id .as_ref() .and_then(|mandate_ids| mandate_ids.mandate_reference_id.as_ref()) .is_some() } /// Attempts to retrieve the connector mandate reference ID as a `Result<String, Error>`. fn get_connector_mandate_request_reference_id(&self) -> Result<String, Error> { self.mandate_id .as_ref() .and_then(|mandate_ids| match &mandate_ids.mandate_reference_id { Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => { connector_mandate_ids.get_connector_mandate_request_reference_id() } Some(payments::MandateReferenceId::NetworkMandateId(_)) | None | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None, }) .ok_or_else(missing_field_err("connector_mandate_request_reference_id")) } fn is_cit_mandate_payment(&self) -> bool { (self.customer_acceptance.is_some() || self.setup_mandate_details.is_some()) && self.setup_future_usage == Some(FutureUsage::OffSession) } fn get_browser_info(&self) -> Result<BrowserInformation, Error> { self.browser_info .clone() .ok_or_else(missing_field_err("browser_info")) } fn get_threeds_method_comp_ind(&self) -> Result<payments::ThreeDsCompletionIndicator, Error> { self.threeds_method_comp_ind .clone() .ok_or_else(missing_field_err("threeds_method_comp_ind")) } } pub trait AddressData { fn get_optional_full_name(&self) -> Option<Secret<String>>; fn get_email(&self) -> Result<Email, Error>; fn get_phone_with_country_code(&self) -> Result<Secret<String>, Error>; fn get_optional_first_name(&self) -> Option<Secret<String>>; fn get_optional_last_name(&self) -> Option<Secret<String>>; } impl AddressData for Address { fn get_optional_full_name(&self) -> Option<Secret<String>> { self.address .as_ref() .and_then(|billing_address| billing_address.get_optional_full_name()) } fn get_email(&self) -> Result<Email, Error> { self.email.clone().ok_or_else(missing_field_err("email")) } fn get_phone_with_country_code(&self) -> Result<Secret<String>, Error> { self.phone .clone() .map(|phone_details| phone_details.get_number_with_country_code()) .transpose()? .ok_or_else(missing_field_err("phone")) } fn get_optional_first_name(&self) -> Option<Secret<String>> { self.address .as_ref() .and_then(|billing_address| billing_address.get_optional_first_name()) } fn get_optional_last_name(&self) -> Option<Secret<String>> { self.address .as_ref() .and_then(|billing_address| billing_address.get_optional_last_name()) } } pub trait PaymentsPreProcessingRequestData { fn get_redirect_response_payload(&self) -> Result<pii::SecretSerdeValue, Error>; fn get_email(&self) -> Result<Email, Error>; fn get_payment_method_type(&self) -> Result<enums::PaymentMethodType, Error>; fn get_currency(&self) -> Result<enums::Currency, Error>; fn get_amount(&self) -> Result<i64, Error>; fn get_minor_amount(&self) -> Result<MinorUnit, Error>; fn is_auto_capture(&self) -> Result<bool, Error>; fn get_order_details(&self) -> Result<Vec<OrderDetailsWithAmount>, Error>; fn get_webhook_url(&self) -> Result<String, Error>; fn get_router_return_url(&self) -> Result<String, Error>; fn get_browser_info(&self) -> Result<BrowserInformation, Error>; fn get_complete_authorize_url(&self) -> Result<String, Error>; fn connector_mandate_id(&self) -> Option<String>; fn get_payment_method_data(&self) -> Result<PaymentMethodData, Error>; } impl PaymentsPreProcessingRequestData for PaymentsPreProcessingData { fn get_email(&self) -> Result<Email, Error> { self.email.clone().ok_or_else(missing_field_err("email")) } fn get_payment_method_type(&self) -> Result<enums::PaymentMethodType, Error> { self.payment_method_type .to_owned() .ok_or_else(missing_field_err("payment_method_type")) } fn get_payment_method_data(&self) -> Result<PaymentMethodData, Error> { self.payment_method_data .to_owned() .ok_or_else(missing_field_err("payment_method_data")) } fn get_currency(&self) -> Result<enums::Currency, Error> { self.currency.ok_or_else(missing_field_err("currency")) } fn get_amount(&self) -> Result<i64, Error> { self.amount.ok_or_else(missing_field_err("amount")) } // New minor amount function for amount framework fn get_minor_amount(&self) -> Result<MinorUnit, Error> { self.minor_amount.ok_or_else(missing_field_err("amount")) } fn is_auto_capture(&self) -> Result<bool, Error> { match self.capture_method { Some(enums::CaptureMethod::Automatic) | None | Some(enums::CaptureMethod::SequentialAutomatic) => Ok(true), Some(enums::CaptureMethod::Manual) => Ok(false), Some(enums::CaptureMethod::ManualMultiple) | Some(enums::CaptureMethod::Scheduled) => { Err(errors::ConnectorError::CaptureMethodNotSupported.into()) } } } fn get_order_details(&self) -> Result<Vec<OrderDetailsWithAmount>, Error> { self.order_details .clone() .ok_or_else(missing_field_err("order_details")) } fn get_webhook_url(&self) -> Result<String, Error> { self.webhook_url .clone() .ok_or_else(missing_field_err("webhook_url")) } fn get_router_return_url(&self) -> Result<String, Error> { self.router_return_url .clone() .ok_or_else(missing_field_err("return_url")) } fn get_browser_info(&self) -> Result<BrowserInformation, Error> { self.browser_info .clone() .ok_or_else(missing_field_err("browser_info")) } fn get_complete_authorize_url(&self) -> Result<String, Error> { self.complete_authorize_url .clone() .ok_or_else(missing_field_err("complete_authorize_url")) } fn get_redirect_response_payload(&self) -> Result<pii::SecretSerdeValue, Error> { self.redirect_response .as_ref() .and_then(|res| res.payload.to_owned()) .ok_or( errors::ConnectorError::MissingConnectorRedirectionPayload { field_name: "request.redirect_response.payload", } .into(), ) } fn connector_mandate_id(&self) -> Option<String> { self.mandate_id .as_ref() .and_then(|mandate_ids| match &mandate_ids.mandate_reference_id { Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => { connector_mandate_ids.get_connector_mandate_id() } Some(payments::MandateReferenceId::NetworkMandateId(_)) | None | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None, }) } } pub trait BrowserInformationData { fn get_accept_header(&self) -> Result<String, Error>; fn get_language(&self) -> Result<String, Error>; fn get_screen_height(&self) -> Result<u32, Error>; fn get_screen_width(&self) -> Result<u32, Error>; fn get_color_depth(&self) -> Result<u8, Error>; fn get_user_agent(&self) -> Result<String, Error>; fn get_time_zone(&self) -> Result<i32, Error>; fn get_java_enabled(&self) -> Result<bool, Error>; fn get_java_script_enabled(&self) -> Result<bool, Error>; fn get_ip_address(&self) -> Result<Secret<String, IpAddress>, Error>; fn get_os_type(&self) -> Result<String, Error>; fn get_os_version(&self) -> Result<String, Error>; fn get_device_model(&self) -> Result<String, Error>; } impl BrowserInformationData for BrowserInformation { fn get_ip_address(&self) -> Result<Secret<String, IpAddress>, Error> { let ip_address = self .ip_address .ok_or_else(missing_field_err("browser_info.ip_address"))?; Ok(Secret::new(ip_address.to_string())) } fn get_accept_header(&self) -> Result<String, Error> { self.accept_header .clone() .ok_or_else(missing_field_err("browser_info.accept_header")) } fn get_language(&self) -> Result<String, Error> { self.language .clone() .ok_or_else(missing_field_err("browser_info.language")) } fn get_screen_height(&self) -> Result<u32, Error> { self.screen_height .ok_or_else(missing_field_err("browser_info.screen_height")) } fn get_screen_width(&self) -> Result<u32, Error> { self.screen_width .ok_or_else(missing_field_err("browser_info.screen_width")) } fn get_color_depth(&self) -> Result<u8, Error> { self.color_depth .ok_or_else(missing_field_err("browser_info.color_depth")) } fn get_user_agent(&self) -> Result<String, Error> { self.user_agent .clone() .ok_or_else(missing_field_err("browser_info.user_agent")) } fn get_time_zone(&self) -> Result<i32, Error> { self.time_zone .ok_or_else(missing_field_err("browser_info.time_zone")) } fn get_java_enabled(&self) -> Result<bool, Error> { self.java_enabled .ok_or_else(missing_field_err("browser_info.java_enabled")) } fn get_java_script_enabled(&self) -> Result<bool, Error> { self.java_script_enabled .ok_or_else(missing_field_err("browser_info.java_script_enabled")) } fn get_os_type(&self) -> Result<String, Error> { self.os_type .clone() .ok_or_else(missing_field_err("browser_info.os_type")) } fn get_os_version(&self) -> Result<String, Error> { self.os_version .clone() .ok_or_else(missing_field_err("browser_info.os_version")) } fn get_device_model(&self) -> Result<String, Error> { self.device_model .clone() .ok_or_else(missing_field_err("browser_info.device_model")) } } pub fn get_header_key_value<'a>( key: &str, headers: &'a actix_web::http::header::HeaderMap, ) -> CustomResult<&'a str, errors::ConnectorError> { get_header_field(headers.get(key)) } pub fn get_http_header<'a>( key: &str, headers: &'a http::HeaderMap, ) -> CustomResult<&'a str, errors::ConnectorError> { get_header_field(headers.get(key)) } fn get_header_field( field: Option<&http::HeaderValue>, ) -> CustomResult<&str, errors::ConnectorError> { field .map(|header_value| { header_value .to_str() .change_context(errors::ConnectorError::WebhookSignatureNotFound) }) .ok_or(report!( errors::ConnectorError::WebhookSourceVerificationFailed ))? } pub trait CryptoData { fn get_pay_currency(&self) -> Result<String, Error>; } impl CryptoData for payment_method_data::CryptoData { fn get_pay_currency(&self) -> Result<String, Error> { self.pay_currency .clone() .ok_or_else(missing_field_err("crypto_data.pay_currency")) } } #[macro_export] macro_rules! capture_method_not_supported { ($connector:expr, $capture_method:expr) => { Err(errors::ConnectorError::NotSupported { message: format!("{} for selected payment method", $capture_method), connector: $connector, } .into()) }; ($connector:expr, $capture_method:expr, $payment_method_type:expr) => { Err(errors::ConnectorError::NotSupported { message: format!("{} for {}", $capture_method, $payment_method_type), connector: $connector, } .into()) }; } #[macro_export] macro_rules! get_formatted_date_time { ($date_format:tt) => {{ let format = time::macros::format_description!($date_format); time::OffsetDateTime::now_utc() .format(&format) .change_context(ConnectorError::InvalidDateFormat) }}; } #[macro_export] macro_rules! unimplemented_payment_method { ($payment_method:expr, $connector:expr) => {
crates/hyperswitch_connectors/src/utils.rs#chunk2
hyperswitch_connectors
chunk
null
null
null
8,191
null
null
null
null
null
null
null
// Struct: PlaidBankAccountCredentialsBalances // File: crates/pm_auth/src/connector/plaid/transformers.rs // Module: pm_auth // Implementations: 0 pub struct PlaidBankAccountCredentialsBalances
crates/pm_auth/src/connector/plaid/transformers.rs
pm_auth
struct_definition
PlaidBankAccountCredentialsBalances
0
[]
49
null
null
null
null
null
null
null
// Struct: ProcessTrackerBatch // File: crates/scheduler/src/consumer/types/batch.rs // Module: scheduler // Implementations: 1 pub struct ProcessTrackerBatch
crates/scheduler/src/consumer/types/batch.rs
scheduler
struct_definition
ProcessTrackerBatch
1
[]
38
null
null
null
null
null
null
null
// File: crates/router/src/types/storage/events.rs // Module: router pub use diesel_models::events::{Event, EventMetadata, EventNew};
crates/router/src/types/storage/events.rs
router
full_file
null
null
null
31
null
null
null
null
null
null
null
// Function: add_payment_method_data // File: crates/router/src/core/payment_methods/cards.rs // Module: router pub fn add_payment_method_data( state: routes::SessionState, req: api::PaymentMethodCreate, merchant_context: domain::MerchantContext, pm_id: String, ) -> errors::RouterResponse<api::PaymentMethodResponse>
crates/router/src/core/payment_methods/cards.rs
router
function_signature
null
null
null
77
add_payment_method_data
null
null
null
null
null
null
// Implementation: impl api::MandateSetup for for Billwerk // File: crates/hyperswitch_connectors/src/connectors/billwerk.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::MandateSetup for for Billwerk
crates/hyperswitch_connectors/src/connectors/billwerk.rs
hyperswitch_connectors
impl_block
null
null
null
62
null
Billwerk
api::MandateSetup for
0
0
null
null
// Implementation: impl api::MandateSetup for for Paytm // File: crates/hyperswitch_connectors/src/connectors/paytm.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::MandateSetup for for Paytm
crates/hyperswitch_connectors/src/connectors/paytm.rs
hyperswitch_connectors
impl_block
null
null
null
61
null
Paytm
api::MandateSetup for
0
0
null
null
// Struct: CeleroPaymentsRequest // File: crates/hyperswitch_connectors/src/connectors/celero/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct CeleroPaymentsRequest
crates/hyperswitch_connectors/src/connectors/celero/transformers.rs
hyperswitch_connectors
struct_definition
CeleroPaymentsRequest
0
[]
50
null
null
null
null
null
null
null
// File: crates/hyperswitch_connectors/src/connectors/redsys.rs // Module: hyperswitch_connectors // Public functions: 1 // Public structs: 1 pub mod transformers; use std::sync::LazyLock; use common_utils::{ errors::CustomResult, ext_traits::{BytesExt, XmlExt}, request::{Method, Request, RequestBuilder, RequestContent}, types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector}, }; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::{ router_data::{AccessToken, ErrorResponse, RouterData}, router_flow_types::{ access_token_auth::AccessTokenAuth, payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void}, refunds::{Execute, RSync}, CompleteAuthorize, PreProcessing, }, 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, RefundExecuteRouterData, RefundSyncRouterData, }, }; use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, types::{ PaymentsAuthorizeType, PaymentsCaptureType, PaymentsCompleteAuthorizeType, PaymentsPreProcessingType, PaymentsSyncType, PaymentsVoidType, RefundExecuteType, RefundSyncType, Response, }, webhooks, }; use transformers as redsys; use crate::{constants::headers, types::ResponseRouterData, utils as connector_utils}; #[derive(Clone)] pub struct Redsys { amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync), } impl Redsys { pub fn new() -> &'static Self { &Self { amount_converter: &StringMinorUnitForConnector, } } } impl api::Payment for Redsys {} impl api::PaymentSession for Redsys {} impl api::ConnectorAccessToken for Redsys {} impl api::MandateSetup for Redsys {} impl api::PaymentAuthorize for Redsys {} impl api::PaymentSync for Redsys {} impl api::PaymentCapture for Redsys {} impl api::PaymentVoid for Redsys {} impl api::Refund for Redsys {} impl api::RefundExecute for Redsys {} impl api::RefundSync for Redsys {} impl api::PaymentToken for Redsys {} impl api::PaymentsPreProcessing for Redsys {} impl api::PaymentsCompleteAuthorize for Redsys {} impl ConnectorCommon for Redsys { fn id(&self) -> &'static str { "redsys" } 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.redsys.base_url.as_ref() } fn build_error_response( &self, res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult<ErrorResponse, errors::ConnectorError> { let response: redsys::RedsysErrorResponse = res .response .parse_struct("RedsysErrorResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; 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.error_code.clone(), message: response.error_code.clone(), reason: Some(response.error_code.clone()), 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 Redsys {} impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Redsys {} impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Redsys {} impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData> for Redsys { fn build_request( &self, _req: &RouterData<SetupMandate, SetupMandateRequestData, PaymentsResponseData>, _connectors: &Connectors, ) -> CustomResult<Option<Request>, errors::ConnectorError> { Err( errors::ConnectorError::NotImplemented("Setup Mandate flow for Redsys".to_string()) .into(), ) } } impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Redsys 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 headers = vec![ ( headers::CONTENT_TYPE.to_string(), "application/xml".to_string().into(), ), ( headers::SOAP_ACTION.to_string(), redsys::REDSYS_SOAP_ACTION.to_string().into(), ), ]; Ok(headers) } } impl ConnectorIntegration<PreProcessing, PaymentsPreProcessingData, PaymentsResponseData> for Redsys { 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!( "{}/sis/rest/iniciaPeticionREST", self.base_url(connectors) )) } fn get_request_body( &self, req: &PaymentsPreProcessingRouterData, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let minor_amount = req.request .minor_amount .ok_or(errors::ConnectorError::MissingRequiredField { field_name: "minor_amount", })?; let currency = req.request .currency .ok_or(errors::ConnectorError::MissingRequiredField { field_name: "currency", })?; let amount = connector_utils::convert_amount(self.amount_converter, minor_amount, currency)?; let connector_router_data = redsys::RedsysRouterData::from((amount, req, currency)); let connector_req = redsys::RedsysTransaction::try_from(&connector_router_data)?; 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(&PaymentsPreProcessingType::get_url(self, req, connectors)?) .attach_default_headers() .set_body(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: redsys::RedsysResponse = res .response .parse_struct("RedsysResponse") .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 Redsys { 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> { Ok(format!( "{}/sis/rest/trataPeticionREST", self.base_url(connectors) )) } fn get_request_body( &self, req: &PaymentsAuthorizeRouterData, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let minor_amount = req.request.minor_amount; let currency = req.request.currency; let amount = connector_utils::convert_amount(self.amount_converter, minor_amount, currency)?; let connector_router_data = redsys::RedsysRouterData::from((amount, req, currency)); let connector_req = redsys::RedsysTransaction::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> { let request = RequestBuilder::new() .method(Method::Post) .url(&PaymentsAuthorizeType::get_url(self, req, connectors)?) .attach_default_headers() .set_body(self.get_request_body(req, connectors)?) .build(); Ok(Some(request)) } fn handle_response( &self, data: &PaymentsAuthorizeRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> { let response: redsys::RedsysResponse = res.response .parse_struct("Redsys RedsysResponse") .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 Redsys { 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!( "{}/sis/rest/trataPeticionREST", self.base_url(connectors) )) } fn get_request_body( &self, req: &PaymentsCompleteAuthorizeRouterData, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let amount = connector_utils::convert_amount( self.amount_converter, req.request.minor_amount, req.request.currency, )?; let connector_router_data = redsys::RedsysRouterData::from((amount, req, req.request.currency)); let connector_req = redsys::RedsysTransaction::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(&PaymentsCompleteAuthorizeType::get_url( self, req, connectors, )?) .attach_default_headers() .headers(PaymentsCompleteAuthorizeType::get_headers( self, req, connectors, )?) .set_body(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: redsys::RedsysResponse = res.response .parse_struct("Redsys RedsysResponse") .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<Capture, PaymentsCaptureData, PaymentsResponseData> for Redsys { fn get_url( &self, _req: &PaymentsCaptureRouterData, connectors: &Connectors, ) -> CustomResult<String, errors::ConnectorError> { Ok(format!( "{}/sis/rest/trataPeticionREST", self.base_url(connectors) )) } fn get_request_body( &self, req: &PaymentsCaptureRouterData, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let amount = connector_utils::convert_amount( self.amount_converter, req.request.minor_amount_to_capture, req.request.currency, )?; let connector_router_data = redsys::RedsysRouterData::from((amount, req, req.request.currency)); let connector_req = redsys::RedsysTransaction::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(&PaymentsCaptureType::get_url(self, req, connectors)?) .attach_default_headers() .set_body(PaymentsCaptureType::get_request_body( self, req, connectors, )?) .build(), )) } fn handle_response( &self, data: &PaymentsCaptureRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult< RouterData<Capture, PaymentsCaptureData, PaymentsResponseData>, errors::ConnectorError, > { let response: redsys::RedsysResponse = res.response .parse_struct("Redsys RedsysResponse") .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 Redsys { fn get_url( &self, _req: &PaymentsCancelRouterData, connectors: &Connectors, ) -> CustomResult<String, errors::ConnectorError> { Ok(format!( "{}/sis/rest/trataPeticionREST", self.base_url(connectors) )) } fn get_content_type(&self) -> &'static str { self.common_get_content_type() } 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: "minor_amount", })?; let currency = req.request .currency .ok_or(errors::ConnectorError::MissingRequiredField { field_name: "currency", })?; let amount = connector_utils::convert_amount(self.amount_converter, minor_amount, currency)?; let connector_router_data = redsys::RedsysRouterData::from((amount, req, currency)); let connector_req = redsys::RedsysTransaction::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(&PaymentsVoidType::get_url(self, req, connectors)?) .attach_default_headers() .headers(PaymentsVoidType::get_headers(self, req, connectors)?) .set_body(self.get_request_body(req, connectors)?) .build(), )) } fn handle_response( &self, data: &PaymentsCancelRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<PaymentsCancelRouterData, errors::ConnectorError> { let response: redsys::RedsysResponse = res.response .parse_struct("Redsys RedsysResponse") .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 Redsys { fn get_content_type(&self) -> &'static str { self.common_get_content_type() } fn get_url( &self, _req: &RefundExecuteRouterData, connectors: &Connectors, ) -> CustomResult<String, errors::ConnectorError> { Ok(format!( "{}/sis/rest/trataPeticionREST", self.base_url(connectors) )) } fn get_request_body( &self, req: &RefundExecuteRouterData, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let refund_amount = connector_utils::convert_amount( self.amount_converter, req.request.minor_refund_amount, req.request.currency, )?; let connector_router_data = redsys::RedsysRouterData::from((refund_amount, req, req.request.currency)); let connector_req = redsys::RedsysTransaction::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } fn build_request( &self, req: &RefundExecuteRouterData, connectors: &Connectors, ) -> CustomResult<Option<Request>, errors::ConnectorError> { Ok(Some( RequestBuilder::new() .method(Method::Post) .url(&RefundExecuteType::get_url(self, req, connectors)?) .attach_default_headers() .headers(RefundExecuteType::get_headers(self, req, connectors)?) .set_body(self.get_request_body(req, connectors)?) .build(), )) } fn handle_response( &self, data: &RefundExecuteRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<RefundExecuteRouterData, errors::ConnectorError> { let response: redsys::RedsysResponse = res.response .parse_struct("Redsys RedsysResponse") .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 Redsys { fn get_headers( &self, req: &PaymentsSyncRouterData, connectors: &Connectors, ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> { self.build_headers(req, connectors) } fn get_url( &self, _req: &PaymentsSyncRouterData, connectors: &Connectors, ) -> CustomResult<String, errors::ConnectorError> { Ok(format!( "{}/apl02/services/SerClsWSConsulta", self.base_url(connectors) )) } fn get_content_type(&self) -> &'static str { self.common_get_content_type() } fn get_request_body( &self, req: &PaymentsSyncRouterData, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let connector_req = redsys::build_payment_sync_request(req)?; Ok(RequestContent::RawBytes(connector_req)) } fn build_request( &self, req: &PaymentsSyncRouterData, connectors: &Connectors, ) -> CustomResult<Option<Request>, errors::ConnectorError> { Ok(Some( RequestBuilder::new() .method(Method::Post) .url(&PaymentsSyncType::get_url(self, req, connectors)?) .attach_default_headers() .headers(PaymentsSyncType::get_headers(self, req, connectors)?) .set_body(self.get_request_body(req, connectors)?) .build(), )) } fn handle_response( &self, data: &PaymentsSyncRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> { let response = String::from_utf8(res.response.to_vec()) .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; let response_data = html_escape::decode_html_entities(&response).to_ascii_lowercase(); let response = response_data .parse_xml::<redsys::RedsysSyncResponse>() .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 Redsys { 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> { Ok(format!( "{}/apl02/services/SerClsWSConsulta", self.base_url(connectors) )) } fn get_request_body( &self, req: &RefundSyncRouterData, _connectors: &Connectors, ) -> CustomResult<RequestContent, errors::ConnectorError> { let connector_req = redsys::build_refund_sync_request(req)?; Ok(RequestContent::RawBytes(connector_req)) } fn build_request( &self, req: &RefundSyncRouterData, connectors: &Connectors, ) -> CustomResult<Option<Request>, errors::ConnectorError> { Ok(Some( RequestBuilder::new() .method(Method::Post) .url(&RefundSyncType::get_url(self, req, connectors)?) .attach_default_headers() .headers(RefundSyncType::get_headers(self, req, connectors)?) .set_body(self.get_request_body(req, connectors)?) .build(), )) } fn handle_response( &self, data: &RefundSyncRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> { let response = String::from_utf8(res.response.to_vec()) .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; let response_data = html_escape::decode_html_entities(&response).to_ascii_lowercase(); let response = response_data .parse_xml::<redsys::RedsysSyncResponse>() .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<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData> for Redsys { } #[async_trait::async_trait] impl webhooks::IncomingWebhook for Redsys { 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)) } } static REDSYS_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| { let default_capture_methods = vec![ common_enums::CaptureMethod::Automatic, common_enums::CaptureMethod::Manual, ]; let supported_card_network = vec![ common_enums::CardNetwork::Visa, common_enums::CardNetwork::Mastercard, common_enums::CardNetwork::AmericanExpress, common_enums::CardNetwork::Discover, common_enums::CardNetwork::JCB, common_enums::CardNetwork::DinersClub, common_enums::CardNetwork::UnionPay, ]; let mut redsys_supported_payment_methods = SupportedPaymentMethods::new(); redsys_supported_payment_methods.add( common_enums::PaymentMethod::Card, common_enums::PaymentMethodType::Credit, PaymentMethodDetails { mandates: common_enums::FeatureStatus::NotSupported, refunds: common_enums::FeatureStatus::Supported, supported_capture_methods: default_capture_methods.clone(), specific_features: Some( api_models::feature_matrix::PaymentMethodSpecificFeatures::Card( api_models::feature_matrix::CardSpecificFeatures { three_ds: common_enums::FeatureStatus::Supported, no_three_ds: common_enums::FeatureStatus::NotSupported, supported_card_networks: supported_card_network.clone(), }, ), ), }, ); redsys_supported_payment_methods.add( common_enums::PaymentMethod::Card, common_enums::PaymentMethodType::Debit, PaymentMethodDetails { mandates: common_enums::FeatureStatus::NotSupported, refunds: common_enums::FeatureStatus::Supported, supported_capture_methods: default_capture_methods.clone(), specific_features: Some( api_models::feature_matrix::PaymentMethodSpecificFeatures::Card( api_models::feature_matrix::CardSpecificFeatures { three_ds: common_enums::FeatureStatus::Supported, no_three_ds: common_enums::FeatureStatus::NotSupported, supported_card_networks: supported_card_network.clone(), }, ), ), }, ); redsys_supported_payment_methods }); static REDSYS_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { display_name: "Redsys", description: "Redsys is a Spanish payment gateway offering secure and innovative payment solutions for merchants and banks", connector_type: common_enums::HyperswitchConnectorCategory::PaymentGateway, integration_status: common_enums::ConnectorIntegrationStatus::Live, }; static REDSYS_SUPPORTED_WEBHOOK_FLOWS: [common_enums::EventClass; 0] = []; impl ConnectorSpecifications for Redsys { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { Some(&REDSYS_CONNECTOR_INFO) } fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { Some(&*REDSYS_SUPPORTED_PAYMENT_METHODS) } fn get_supported_webhook_flows(&self) -> Option<&'static [common_enums::EventClass]> { Some(&REDSYS_SUPPORTED_WEBHOOK_FLOWS) } #[cfg(feature = "v1")] fn generate_connector_request_reference_id( &self, payment_intent: &hyperswitch_domain_models::payments::PaymentIntent, payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt, is_config_enabled_to_send_payment_id_as_connector_request_id: bool, ) -> String { if is_config_enabled_to_send_payment_id_as_connector_request_id && payment_intent.is_payment_id_from_merchant.unwrap_or(false) { payment_attempt.payment_id.get_string_repr().to_owned() } else { connector_utils::generate_12_digit_number().to_string() } } }
crates/hyperswitch_connectors/src/connectors/redsys.rs
hyperswitch_connectors
full_file
null
null
null
7,035
null
null
null
null
null
null
null
// Function: transform_ucs_webhook_response // File: crates/router/src/core/unified_connector_service/transformers.rs // Module: router // Documentation: Transform UCS webhook response into webhook event data pub fn transform_ucs_webhook_response( response: PaymentServiceTransformResponse, ) -> Result<WebhookTransformData, error_stack::Report<errors::ApiErrorResponse>>
crates/router/src/core/unified_connector_service/transformers.rs
router
function_signature
null
null
null
79
transform_ucs_webhook_response
null
null
null
null
null
null
// Function: is_invitable // File: crates/router/src/services/authorization/roles.rs // Module: router pub fn is_invitable(&self) -> bool
crates/router/src/services/authorization/roles.rs
router
function_signature
null
null
null
35
is_invitable
null
null
null
null
null
null
// Function: parser // File: crates/euclid_wasm/src/lib.rs // Module: euclid_wasm pub fn parser(val: String) -> String
crates/euclid_wasm/src/lib.rs
euclid_wasm
function_signature
null
null
null
35
parser
null
null
null
null
null
null
// Implementation: impl api::ConnectorAccessToken for for CtpMastercard // File: crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs // Module: hyperswitch_connectors // Methods: 0 total (0 public) impl api::ConnectorAccessToken for for CtpMastercard
crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs
hyperswitch_connectors
impl_block
null
null
null
63
null
CtpMastercard
api::ConnectorAccessToken for
0
0
null
null
// Module Structure // File: crates/router/src/core/unified_connector_service.rs // Module: router // Public submodules: pub mod transformers; // Public exports: pub use transformers::WebhookTransformData;
crates/router/src/core/unified_connector_service.rs
router
module_structure
null
null
null
44
null
null
null
null
null
1
1
// Struct: AwsFileStorageClient // File: crates/external_services/src/file_storage/aws_s3.rs // Module: external_services // Implementations: 2 // Traits: FileStorageInterface pub struct AwsFileStorageClient
crates/external_services/src/file_storage/aws_s3.rs
external_services
struct_definition
AwsFileStorageClient
2
[ "FileStorageInterface" ]
49
null
null
null
null
null
null
null
// Struct: PaymentResponse // File: crates/hyperswitch_connectors/src/connectors/worldline/transformers.rs // Module: hyperswitch_connectors // Implementations: 0 pub struct PaymentResponse
crates/hyperswitch_connectors/src/connectors/worldline/transformers.rs
hyperswitch_connectors
struct_definition
PaymentResponse
0
[]
45
null
null
null
null
null
null
null
// Struct: InviteUserRequest // File: crates/api_models/src/user.rs // Module: api_models // Implementations: 0 pub struct InviteUserRequest
crates/api_models/src/user.rs
api_models
struct_definition
InviteUserRequest
0
[]
35
null
null
null
null
null
null
null
// Implementation: impl RedisConnInterface for for KVRouterStore // File: crates/storage_impl/src/kv_router_store.rs // Module: storage_impl // Methods: 1 total (0 public) impl RedisConnInterface for for KVRouterStore
crates/storage_impl/src/kv_router_store.rs
storage_impl
impl_block
null
null
null
51
null
KVRouterStore
RedisConnInterface for
1
0
null
null
// Struct: Profile // File: crates/hyperswitch_domain_models/src/business_profile.rs // Module: hyperswitch_domain_models // Implementations: 4 // Traits: super::behaviour::Conversion, super::behaviour::Conversion pub struct Profile
crates/hyperswitch_domain_models/src/business_profile.rs
hyperswitch_domain_models
struct_definition
Profile
4
[ "super::behaviour::Conversion", "super::behaviour::Conversion" ]
55
null
null
null
null
null
null
null
// File: crates/hyperswitch_connectors/src/connectors/cryptopay/transformers.rs // Module: hyperswitch_connectors // Public structs: 8 use common_enums::enums; use common_utils::{ pii, types::{MinorUnit, StringMajorUnit}, }; use hyperswitch_domain_models::{ payment_method_data::PaymentMethodData, router_data::{ConnectorAuthType, ErrorResponse, RouterData}, router_request_types::ResponseId, router_response_types::{PaymentsResponseData, RedirectForm}, types, }; use hyperswitch_interfaces::{consts, errors}; use masking::Secret; use reqwest::Url; use serde::{Deserialize, Serialize}; use crate::{ types::ResponseRouterData, utils::{self, CryptoData, ForeignTryFrom, PaymentsAuthorizeRequestData}, }; #[derive(Debug, Serialize)] pub struct CryptopayRouterData<T> { pub amount: StringMajorUnit, pub router_data: T, } impl<T> From<(StringMajorUnit, T)> for CryptopayRouterData<T> { fn from((amount, item): (StringMajorUnit, T)) -> Self { Self { amount, router_data: item, } } } #[derive(Default, Debug, Serialize)] pub struct CryptopayPaymentsRequest { price_amount: StringMajorUnit, price_currency: enums::Currency, pay_currency: String, #[serde(skip_serializing_if = "Option::is_none")] network: Option<String>, success_redirect_url: Option<String>, unsuccess_redirect_url: Option<String>, #[serde(skip_serializing_if = "Option::is_none")] metadata: Option<pii::SecretSerdeValue>, custom_id: String, } impl TryFrom<&CryptopayRouterData<&types::PaymentsAuthorizeRouterData>> for CryptopayPaymentsRequest { type Error = error_stack::Report<errors::ConnectorError>; fn try_from( item: &CryptopayRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result<Self, Self::Error> { let cryptopay_request = match item.router_data.request.payment_method_data { PaymentMethodData::Crypto(ref cryptodata) => { let pay_currency = cryptodata.get_pay_currency()?; Ok(Self { price_amount: item.amount.clone(), price_currency: item.router_data.request.currency, pay_currency, network: cryptodata.network.to_owned(), success_redirect_url: item.router_data.request.router_return_url.clone(), unsuccess_redirect_url: item.router_data.request.router_return_url.clone(), //Cryptopay only accepts metadata as Object. If any other type, payment will fail with error. metadata: item.router_data.request.get_metadata_as_object(), custom_id: item.router_data.connector_request_reference_id.clone(), }) } PaymentMethodData::Card(_) | PaymentMethodData::CardRedirect(_) | PaymentMethodData::Wallet(_) | PaymentMethodData::PayLater(_) | PaymentMethodData::BankRedirect(_) | PaymentMethodData::BankDebit(_) | PaymentMethodData::BankTransfer(_) | PaymentMethodData::MandatePayment | PaymentMethodData::Reward | PaymentMethodData::RealTimePayment(_) | PaymentMethodData::Upi(_) | PaymentMethodData::MobilePayment(_) | PaymentMethodData::Voucher(_) | PaymentMethodData::GiftCard(_) | PaymentMethodData::OpenBanking(_) | PaymentMethodData::CardToken(_) | PaymentMethodData::NetworkToken(_) | PaymentMethodData::CardDetailsForNetworkTransactionId(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("CryptoPay"), )) } }?; Ok(cryptopay_request) } } // Auth Struct pub struct CryptopayAuthType { pub(super) api_key: Secret<String>, pub(super) api_secret: Secret<String>, } impl TryFrom<&ConnectorAuthType> for CryptopayAuthType { type Error = error_stack::Report<errors::ConnectorError>; fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> { if let ConnectorAuthType::BodyKey { api_key, key1 } = auth_type { Ok(Self { api_key: api_key.to_owned(), api_secret: key1.to_owned(), }) } else { Err(errors::ConnectorError::FailedToObtainAuthType.into()) } } } // PaymentsResponse #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub enum CryptopayPaymentStatus { New, Completed, Unresolved, Refunded, Cancelled, } impl From<CryptopayPaymentStatus> for enums::AttemptStatus { fn from(item: CryptopayPaymentStatus) -> Self { match item { CryptopayPaymentStatus::New => Self::AuthenticationPending, CryptopayPaymentStatus::Completed => Self::Charged, CryptopayPaymentStatus::Cancelled => Self::Failure, CryptopayPaymentStatus::Unresolved | CryptopayPaymentStatus::Refunded => { Self::Unresolved } //mapped refunded to Unresolved because refund api is not available, also merchant has done the action on the connector dashboard. } } } #[derive(Debug, Serialize, Deserialize)] pub struct CryptopayPaymentsResponse { pub data: CryptopayPaymentResponseData, } impl<F, T> ForeignTryFrom<( ResponseRouterData<F, CryptopayPaymentsResponse, T, PaymentsResponseData>, Option<MinorUnit>, )> for RouterData<F, T, PaymentsResponseData> { type Error = error_stack::Report<errors::ConnectorError>; fn foreign_try_from( (item, amount_captured_in_minor_units): ( ResponseRouterData<F, CryptopayPaymentsResponse, T, PaymentsResponseData>, Option<MinorUnit>, ), ) -> Result<Self, Self::Error> { let status = enums::AttemptStatus::from(item.response.data.status.clone()); let response = if utils::is_payment_failure(status) { let payment_response = &item.response.data; Err(ErrorResponse { code: payment_response .name .clone() .unwrap_or(consts::NO_ERROR_CODE.to_string()), message: payment_response .status_context .clone() .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), reason: payment_response.status_context.clone(), status_code: item.http_code, attempt_status: None, connector_transaction_id: Some(payment_response.id.clone()), network_advice_code: None, network_decline_code: None, network_error_message: None, connector_metadata: None, }) } else { let redirection_data = item .response .data .hosted_page_url .map(|x| RedirectForm::from((x, common_utils::request::Method::Get))); Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.data.id.clone()), redirection_data: Box::new(redirection_data), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: item .response .data .custom_id .or(Some(item.response.data.id)), incremental_authorization_allowed: None, charges: None, }) }; match amount_captured_in_minor_units { Some(minor_amount) => { let amount_captured = Some(minor_amount.get_amount_as_i64()); Ok(Self { status, response, amount_captured, minor_amount_captured: amount_captured_in_minor_units, ..item.data }) } None => Ok(Self { status, response, ..item.data }), } } } #[derive(Default, Debug, Serialize, Deserialize)] pub struct CryptopayErrorData { pub code: String, pub message: String, pub reason: Option<String>, } #[derive(Default, Debug, Serialize, Deserialize)] pub struct CryptopayErrorResponse { pub error: CryptopayErrorData, } #[derive(Debug, Serialize, Deserialize)] pub struct CryptopayPaymentResponseData { pub id: String, pub custom_id: Option<String>, pub customer_id: Option<String>, pub status: CryptopayPaymentStatus, pub status_context: Option<String>, pub address: Option<Secret<String>>, pub network: Option<String>, pub uri: Option<String>, pub price_amount: Option<StringMajorUnit>, pub price_currency: Option<String>, pub pay_amount: Option<StringMajorUnit>, pub pay_currency: Option<String>, pub fee: Option<String>, pub fee_currency: Option<String>, pub paid_amount: Option<String>, pub name: Option<String>, pub description: Option<String>, pub success_redirect_url: Option<String>, pub unsuccess_redirect_url: Option<String>, pub hosted_page_url: Option<Url>, pub created_at: Option<String>, pub expires_at: Option<String>, } #[derive(Debug, Serialize, Deserialize)] pub struct CryptopayWebhookDetails { #[serde(rename = "type")] pub service_type: String, pub event: WebhookEvent, pub data: CryptopayPaymentResponseData, } #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum WebhookEvent { TransactionCreated, TransactionConfirmed, StatusChanged, }
crates/hyperswitch_connectors/src/connectors/cryptopay/transformers.rs
hyperswitch_connectors
full_file
null
null
null
2,063
null
null
null
null
null
null
null
// Function: update_default_fallback_routing // File: crates/router/src/core/routing.rs // Module: router pub fn update_default_fallback_routing( state: SessionState, merchant_context: domain::MerchantContext, profile_id: common_utils::id_type::ProfileId, updated_list_of_connectors: Vec<routing_types::RoutableConnectorChoice>, ) -> RouterResponse<Vec<routing_types::RoutableConnectorChoice>>
crates/router/src/core/routing.rs
router
function_signature
null
null
null
94
update_default_fallback_routing
null
null
null
null
null
null