text
stringlengths 65
57.3k
| file_path
stringlengths 22
92
| module
stringclasses 38
values | type
stringclasses 7
values | struct_name
stringlengths 3
60
⌀ | impl_count
int64 0
60
⌀ | traits
listlengths 0
59
⌀ | tokens
int64 16
8.19k
| function_name
stringlengths 3
85
⌀ | type_name
stringlengths 1
67
⌀ | trait_name
stringclasses 573
values | method_count
int64 0
31
⌀ | public_method_count
int64 0
19
⌀ | submodule_count
int64 0
56
⌀ | export_count
int64 0
9
⌀ |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
// Struct: CustomerDetails
// File: crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct CustomerDetails
|
crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
CustomerDetails
| 0
|
[] | 47
| null | null | null | null | null | null | null |
// Implementation: impl api::RefundExecute for for Checkout
// File: crates/hyperswitch_connectors/src/connectors/checkout.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::RefundExecute for for Checkout
|
crates/hyperswitch_connectors/src/connectors/checkout.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 57
| null |
Checkout
|
api::RefundExecute for
| 0
| 0
| null | null |
// Function: get_filters
// File: crates/analytics/src/sdk_events/core.rs
// Module: analytics
pub fn get_filters(
pool: &AnalyticsProvider,
req: GetSdkEventFiltersRequest,
publishable_key: &String,
) -> AnalyticsResult<SdkEventFiltersResponse>
|
crates/analytics/src/sdk_events/core.rs
|
analytics
|
function_signature
| null | null | null | 62
|
get_filters
| null | null | null | null | null | null |
// Function: execute_query
// File: crates/analytics/src/query.rs
// Module: analytics
pub fn execute_query<R, P>(
&mut self,
store: &P,
) -> CustomResult<CustomResult<Vec<R>, QueryExecutionError>, QueryBuildingError>
where
P: LoadRow<R> + AnalyticsDataSource,
Aggregate<&'static str>: ToSql<T>,
Window<&'static str>: ToSql<T>,
|
crates/analytics/src/query.rs
|
analytics
|
function_signature
| null | null | null | 95
|
execute_query
| null | null | null | null | null | null |
// Implementation: impl Responder
// File: crates/router/src/analytics.rs
// Module: router
// Methods: 0 total (0 public)
impl Responder
|
crates/router/src/analytics.rs
|
router
|
impl_block
| null | null | null | 35
| null |
Responder
| null | 0
| 0
| null | null |
// Implementation: impl GatewayStatusMappingNew
// File: crates/diesel_models/src/query/gsm.rs
// Module: diesel_models
// Methods: 1 total (0 public)
impl GatewayStatusMappingNew
|
crates/diesel_models/src/query/gsm.rs
|
diesel_models
|
impl_block
| null | null | null | 43
| null |
GatewayStatusMappingNew
| null | 1
| 0
| null | null |
// Struct: AuthenticationSyncPostUpdateRequest
// File: crates/api_models/src/authentication.rs
// Module: api_models
// Implementations: 1
// Traits: ApiEventMetric
pub struct AuthenticationSyncPostUpdateRequest
|
crates/api_models/src/authentication.rs
|
api_models
|
struct_definition
|
AuthenticationSyncPostUpdateRequest
| 1
|
[
"ApiEventMetric"
] | 46
| null | null | null | null | null | null | null |
// Struct: Level
// File: crates/router_env/src/logger/config.rs
// Module: router_env
// Implementations: 1
pub struct Level
|
crates/router_env/src/logger/config.rs
|
router_env
|
struct_definition
|
Level
| 1
|
[] | 32
| null | null | null | null | null | null | null |
// Implementation: impl api::PaymentsCompleteAuthorize for for Bluesnap
// File: crates/hyperswitch_connectors/src/connectors/bluesnap.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentsCompleteAuthorize for for Bluesnap
|
crates/hyperswitch_connectors/src/connectors/bluesnap.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 60
| null |
Bluesnap
|
api::PaymentsCompleteAuthorize for
| 0
| 0
| null | null |
// Implementation: impl Health
// File: crates/router/src/bin/scheduler.rs
// Module: router
// Methods: 1 total (1 public)
impl Health
|
crates/router/src/bin/scheduler.rs
|
router
|
impl_block
| null | null | null | 34
| null |
Health
| null | 1
| 1
| null | null |
// Function: is_true
// File: crates/common_types/src/primitive_wrappers.rs
// Module: common_types
// Documentation: returns the inner bool value
pub fn is_true(&self) -> bool
|
crates/common_types/src/primitive_wrappers.rs
|
common_types
|
function_signature
| null | null | null | 43
|
is_true
| null | null | null | null | null | null |
// Implementation: impl ThemeNew
// File: crates/diesel_models/src/user/theme.rs
// Module: diesel_models
// Methods: 1 total (1 public)
impl ThemeNew
|
crates/diesel_models/src/user/theme.rs
|
diesel_models
|
impl_block
| null | null | null | 38
| null |
ThemeNew
| null | 1
| 1
| null | null |
// Struct: ConnectorData
// File: crates/router/src/types/api/connector_mapping.rs
// Module: router
// Implementations: 1
pub struct ConnectorData
|
crates/router/src/types/api/connector_mapping.rs
|
router
|
struct_definition
|
ConnectorData
| 1
|
[] | 35
| null | null | null | null | null | null | null |
// Implementation: impl ConnectorSpecifications for for Tokenio
// File: crates/hyperswitch_connectors/src/connectors/tokenio.rs
// Module: hyperswitch_connectors
// Methods: 3 total (0 public)
impl ConnectorSpecifications for for Tokenio
|
crates/hyperswitch_connectors/src/connectors/tokenio.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 53
| null |
Tokenio
|
ConnectorSpecifications for
| 3
| 0
| null | null |
// Struct: DeutschebankAmount
// File: crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct DeutschebankAmount
|
crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
DeutschebankAmount
| 0
|
[] | 48
| null | null | null | null | null | null | null |
// Struct: AuthenticationDetails
// File: crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct AuthenticationDetails
|
crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
AuthenticationDetails
| 0
|
[] | 47
| null | null | null | null | null | null | null |
// Struct: CardCapRes
// File: crates/hyperswitch_connectors/src/connectors/jpmorgan/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct CardCapRes
|
crates/hyperswitch_connectors/src/connectors/jpmorgan/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
CardCapRes
| 0
|
[] | 48
| null | null | null | null | null | null | null |
// Trait: AddHeaders
// File: crates/external_services/src/grpc_client.rs
// Module: external_services
// Documentation: Trait to add necessary headers to the tonic Request
pub trait AddHeaders
|
crates/external_services/src/grpc_client.rs
|
external_services
|
trait_definition
| null | null | null | 41
| null | null |
AddHeaders
| null | null | null | null |
// Function: get_id
// File: crates/hyperswitch_domain_models/src/merchant_connector_account.rs
// Module: hyperswitch_domain_models
pub fn get_id(&self) -> id_type::MerchantConnectorAccountId
|
crates/hyperswitch_domain_models/src/merchant_connector_account.rs
|
hyperswitch_domain_models
|
function_signature
| null | null | null | 45
|
get_id
| null | null | null | null | null | null |
// Implementation: impl Responder
// File: crates/router/src/routes/three_ds_decision_rule.rs
// Module: router
// Methods: 0 total (0 public)
impl Responder
|
crates/router/src/routes/three_ds_decision_rule.rs
|
router
|
impl_block
| null | null | null | 39
| null |
Responder
| null | 0
| 0
| null | null |
// Function: get_payment_sync_body
// File: crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs
// Module: hyperswitch_connectors
pub fn get_payment_sync_body(req: &types::PaymentsSyncRouterData) -> Result<Vec<u8>, Error>
|
crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs
|
hyperswitch_connectors
|
function_signature
| null | null | null | 63
|
get_payment_sync_body
| null | null | null | null | null | null |
// Struct: Bambora
// File: crates/hyperswitch_connectors/src/connectors/bambora.rs
// Module: hyperswitch_connectors
// Implementations: 19
// Traits: api::Payment, api::PaymentToken, api::PaymentAuthorize, api::PaymentVoid, api::MandateSetup, api::ConnectorAccessToken, api::PaymentSync, api::PaymentCapture, api::PaymentSession, api::Refund, api::RefundExecute, api::RefundSync, api::PaymentsCompleteAuthorize, ConnectorCommon, ConnectorValidation, ConnectorRedirectResponse, webhooks::IncomingWebhook, ConnectorSpecifications
pub struct Bambora
|
crates/hyperswitch_connectors/src/connectors/bambora.rs
|
hyperswitch_connectors
|
struct_definition
|
Bambora
| 19
|
[
"api::Payment",
"api::PaymentToken",
"api::PaymentAuthorize",
"api::PaymentVoid",
"api::MandateSetup",
"api::ConnectorAccessToken",
"api::PaymentSync",
"api::PaymentCapture",
"api::PaymentSession",
"api::Refund",
"api::RefundExecute",
"api::RefundSync",
"api::PaymentsCompleteAuthorize",
"ConnectorCommon",
"ConnectorValidation",
"ConnectorRedirectResponse",
"webhooks::IncomingWebhook",
"ConnectorSpecifications"
] | 138
| null | null | null | null | null | null | null |
// File: crates/hyperswitch_domain_models/src/router_flow_types/files.rs
// Module: hyperswitch_domain_models
// Public structs: 2
#[derive(Debug, Clone)]
pub struct Retrieve;
#[derive(Debug, Clone)]
pub struct Upload;
|
crates/hyperswitch_domain_models/src/router_flow_types/files.rs
|
hyperswitch_domain_models
|
full_file
| null | null | null | 52
| null | null | null | null | null | null | null |
// Implementation: impl api::PaymentSession for for Sift
// File: crates/hyperswitch_connectors/src/connectors/sift.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentSession for for Sift
|
crates/hyperswitch_connectors/src/connectors/sift.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 57
| null |
Sift
|
api::PaymentSession for
| 0
| 0
| null | null |
// Function: from_storage
// File: crates/router/src/services/kafka/payment_intent.rs
// Module: router
pub fn from_storage(intent: &'a PaymentIntent, infra_values: Option<Value>) -> Self
|
crates/router/src/services/kafka/payment_intent.rs
|
router
|
function_signature
| null | null | null | 43
|
from_storage
| null | null | null | null | null | null |
// File: crates/hyperswitch_domain_models/src/router_flow_types/access_token_auth.rs
// Module: hyperswitch_domain_models
// Public structs: 2
#[derive(Clone, Debug)]
pub struct AccessTokenAuthentication;
#[derive(Clone, Debug)]
pub struct AccessTokenAuth;
|
crates/hyperswitch_domain_models/src/router_flow_types/access_token_auth.rs
|
hyperswitch_domain_models
|
full_file
| null | null | null | 56
| null | null | null | null | null | null | null |
// Struct: PaymentMethodListResponse
// File: crates/api_models/src/payment_methods.rs
// Module: api_models
// Implementations: 0
pub struct PaymentMethodListResponse
|
crates/api_models/src/payment_methods.rs
|
api_models
|
struct_definition
|
PaymentMethodListResponse
| 0
|
[] | 38
| null | null | null | null | null | null | null |
// Implementation: impl ConnectorValidation for for Stax
// File: crates/hyperswitch_connectors/src/connectors/stax.rs
// Module: hyperswitch_connectors
// Methods: 1 total (0 public)
impl ConnectorValidation for for Stax
|
crates/hyperswitch_connectors/src/connectors/stax.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 53
| null |
Stax
|
ConnectorValidation for
| 1
| 0
| null | null |
// File: crates/router/src/core/card_testing_guard/utils.rs
// Module: router
// Public functions: 3
use error_stack::ResultExt;
use hyperswitch_domain_models::{
card_testing_guard_data::CardTestingGuardData, router_request_types::BrowserInformation,
};
use masking::{PeekInterface, Secret};
use router_env::logger;
use super::errors;
use crate::{
core::{errors::RouterResult, payments::helpers},
routes::SessionState,
services,
types::{api, domain},
utils::crypto::{self, SignMessage},
};
pub async fn validate_card_testing_guard_checks(
state: &SessionState,
request: &api::PaymentsRequest,
payment_method_data: Option<&api_models::payments::PaymentMethodData>,
customer_id: &Option<common_utils::id_type::CustomerId>,
business_profile: &domain::Profile,
) -> RouterResult<Option<CardTestingGuardData>> {
match &business_profile.card_testing_guard_config {
Some(card_testing_guard_config) => {
let fingerprint = generate_fingerprint(payment_method_data, business_profile).await?;
let card_testing_guard_expiry = card_testing_guard_config.card_testing_guard_expiry;
let mut card_ip_blocking_cache_key = String::new();
let mut guest_user_card_blocking_cache_key = String::new();
let mut customer_id_blocking_cache_key = String::new();
if card_testing_guard_config.is_card_ip_blocking_enabled {
if let Some(browser_info) = &request.browser_info {
#[cfg(feature = "v1")]
{
let browser_info =
serde_json::from_value::<BrowserInformation>(browser_info.clone())
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("could not parse browser_info")?;
if let Some(browser_info_ip) = browser_info.ip_address {
card_ip_blocking_cache_key =
helpers::validate_card_ip_blocking_for_business_profile(
state,
browser_info_ip,
fingerprint.clone(),
card_testing_guard_config,
)
.await?;
}
}
#[cfg(feature = "v2")]
{
if let Some(browser_info_ip) = browser_info.ip_address {
card_ip_blocking_cache_key =
helpers::validate_card_ip_blocking_for_business_profile(
state,
browser_info_ip,
fingerprint.clone(),
card_testing_guard_config,
)
.await?;
}
}
}
}
if card_testing_guard_config.is_guest_user_card_blocking_enabled {
guest_user_card_blocking_cache_key =
helpers::validate_guest_user_card_blocking_for_business_profile(
state,
fingerprint.clone(),
customer_id.clone(),
card_testing_guard_config,
)
.await?;
}
if card_testing_guard_config.is_customer_id_blocking_enabled {
if let Some(customer_id) = customer_id.clone() {
customer_id_blocking_cache_key =
helpers::validate_customer_id_blocking_for_business_profile(
state,
customer_id.clone(),
business_profile.get_id(),
card_testing_guard_config,
)
.await?;
}
}
Ok(Some(CardTestingGuardData {
is_card_ip_blocking_enabled: card_testing_guard_config.is_card_ip_blocking_enabled,
card_ip_blocking_cache_key,
is_guest_user_card_blocking_enabled: card_testing_guard_config
.is_guest_user_card_blocking_enabled,
guest_user_card_blocking_cache_key,
is_customer_id_blocking_enabled: card_testing_guard_config
.is_customer_id_blocking_enabled,
customer_id_blocking_cache_key,
card_testing_guard_expiry,
}))
}
None => Ok(None),
}
}
pub async fn generate_fingerprint(
payment_method_data: Option<&api_models::payments::PaymentMethodData>,
business_profile: &domain::Profile,
) -> RouterResult<Secret<String>> {
let card_testing_secret_key = &business_profile.card_testing_secret_key;
match card_testing_secret_key {
Some(card_testing_secret_key) => {
let card_number_fingerprint = payment_method_data
.as_ref()
.and_then(|pm_data| match pm_data {
api_models::payments::PaymentMethodData::Card(card) => {
crypto::HmacSha512::sign_message(
&crypto::HmacSha512,
card_testing_secret_key.get_inner().peek().as_bytes(),
card.card_number.clone().get_card_no().as_bytes(),
)
.attach_printable("error in pm fingerprint creation")
.map_or_else(
|err| {
logger::error!(error=?err);
None
},
Some,
)
}
_ => None,
})
.map(hex::encode);
card_number_fingerprint.map(Secret::new).ok_or_else(|| {
error_stack::report!(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error while masking fingerprint")
})
}
None => Err(errors::ApiErrorResponse::InternalServerError)
.attach_printable("card testing secret key not configured")?,
}
}
pub async fn increment_blocked_count_in_cache(
state: &SessionState,
card_testing_guard_data: Option<CardTestingGuardData>,
) -> RouterResult<()> {
if let Some(card_testing_guard_data) = card_testing_guard_data.clone() {
if card_testing_guard_data.is_card_ip_blocking_enabled
&& !card_testing_guard_data
.card_ip_blocking_cache_key
.is_empty()
{
let _ = services::card_testing_guard::increment_blocked_count_in_cache(
state,
&card_testing_guard_data.card_ip_blocking_cache_key,
card_testing_guard_data.card_testing_guard_expiry.into(),
)
.await;
}
if card_testing_guard_data.is_guest_user_card_blocking_enabled
&& !card_testing_guard_data
.guest_user_card_blocking_cache_key
.is_empty()
{
let _ = services::card_testing_guard::increment_blocked_count_in_cache(
state,
&card_testing_guard_data.guest_user_card_blocking_cache_key,
card_testing_guard_data.card_testing_guard_expiry.into(),
)
.await;
}
if card_testing_guard_data.is_customer_id_blocking_enabled
&& !card_testing_guard_data
.customer_id_blocking_cache_key
.is_empty()
{
let _ = services::card_testing_guard::increment_blocked_count_in_cache(
state,
&card_testing_guard_data.customer_id_blocking_cache_key,
card_testing_guard_data.card_testing_guard_expiry.into(),
)
.await;
}
}
Ok(())
}
|
crates/router/src/core/card_testing_guard/utils.rs
|
router
|
full_file
| null | null | null | 1,353
| null | null | null | null | null | null | null |
// Struct: NexixpayCompleteAuthorizeResponse
// File: crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct NexixpayCompleteAuthorizeResponse
|
crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
NexixpayCompleteAuthorizeResponse
| 0
|
[] | 55
| null | null | null | null | null | null | null |
// Function: initiate_payment_link
// File: crates/router/src/routes/payment_link.rs
// Module: router
pub fn initiate_payment_link(
state: web::Data<AppState>,
req: actix_web::HttpRequest,
path: web::Path<(
common_utils::id_type::MerchantId,
common_utils::id_type::PaymentId,
)
|
crates/router/src/routes/payment_link.rs
|
router
|
function_signature
| null | null | null | 77
|
initiate_payment_link
| null | null | null | null | null | null |
// Function: value_type
// File: crates/euclid/src/frontend/ast/parser.rs
// Module: euclid
pub fn value_type(input: &str) -> ParseResult<&str, ast::ValueType>
|
crates/euclid/src/frontend/ast/parser.rs
|
euclid
|
function_signature
| null | null | null | 45
|
value_type
| null | null | null | null | null | null |
// Function: should_call_frm
// File: crates/router/src/core/fraud_check.rs
// Module: router
pub fn should_call_frm<F, D>(
_merchant_context: &domain::MerchantContext,
_payment_data: &D,
_state: &SessionState,
) -> RouterResult<(
bool,
Option<FrmRoutingAlgorithm>,
Option<common_utils::id_type::ProfileId>,
Option<FrmConfigsObject>,
)>
where
F: Send + Clone,
D: payments::OperationSessionGetters<F> + Send + Sync + Clone,
|
crates/router/src/core/fraud_check.rs
|
router
|
function_signature
| null | null | null | 123
|
should_call_frm
| null | null | null | null | null | null |
// Struct: PaymentIntentListParams
// File: crates/hyperswitch_domain_models/src/payments/payment_intent.rs
// Module: hyperswitch_domain_models
// Implementations: 0
pub struct PaymentIntentListParams
|
crates/hyperswitch_domain_models/src/payments/payment_intent.rs
|
hyperswitch_domain_models
|
struct_definition
|
PaymentIntentListParams
| 0
|
[] | 46
| null | null | null | null | null | null | null |
// Function: find_payment_intent_from_refund_id_type
// File: crates/router/src/utils.rs
// Module: router
pub fn find_payment_intent_from_refund_id_type(
state: &SessionState,
refund_id_type: webhooks::RefundIdType,
merchant_context: &domain::MerchantContext,
connector_name: &str,
) -> CustomResult<PaymentIntent, errors::ApiErrorResponse>
|
crates/router/src/utils.rs
|
router
|
function_signature
| null | null | null | 87
|
find_payment_intent_from_refund_id_type
| null | null | null | null | null | null |
// Struct: LabelWithScoreEventResponse
// File: crates/api_models/src/routing.rs
// Module: api_models
// Implementations: 0
pub struct LabelWithScoreEventResponse
|
crates/api_models/src/routing.rs
|
api_models
|
struct_definition
|
LabelWithScoreEventResponse
| 0
|
[] | 40
| null | null | null | null | null | null | null |
// Implementation: impl GenericLinkNew
// File: crates/diesel_models/src/query/generic_link.rs
// Module: diesel_models
// Methods: 3 total (0 public)
impl GenericLinkNew
|
crates/diesel_models/src/query/generic_link.rs
|
diesel_models
|
impl_block
| null | null | null | 42
| null |
GenericLinkNew
| null | 3
| 0
| null | null |
// Struct: SerializeVec
// File: crates/masking/src/serde.rs
// Module: masking
// Implementations: 0
pub struct SerializeVec<T: Serializer>
|
crates/masking/src/serde.rs
|
masking
|
struct_definition
|
SerializeVec
| 0
|
[] | 37
| null | null | null | null | null | null | null |
// File: crates/diesel_models/src/query/connector_response.rs
// Module: diesel_models
// Public functions: 3
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use router_env::{instrument, logger, tracing};
use super::generics;
use crate::{
connector_response::{
ConnectorResponse, ConnectorResponseNew, ConnectorResponseUpdate,
ConnectorResponseUpdateInternal,
},
errors,
payment_attempt::{PaymentAttempt, PaymentAttemptUpdate, PaymentAttemptUpdateInternal},
schema::{connector_response::dsl, payment_attempt::dsl as pa_dsl},
PgPooledConn, StorageResult,
};
impl ConnectorResponseNew {
#[instrument(skip(conn))]
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<ConnectorResponse> {
let payment_attempt_update = PaymentAttemptUpdate::ConnectorResponse {
authentication_data: self.authentication_data.clone(),
encoded_data: self.encoded_data.clone(),
connector_transaction_id: self.connector_transaction_id.clone(),
connector: self.connector_name.clone(),
updated_by: self.updated_by.clone(),
charge_id: self.charge_id.clone(),
};
let _payment_attempt: Result<PaymentAttempt, _> =
generics::generic_update_with_unique_predicate_get_result::<
<PaymentAttempt as HasTable>::Table,
_,
_,
_,
>(
conn,
pa_dsl::attempt_id
.eq(self.attempt_id.to_owned())
.and(pa_dsl::merchant_id.eq(self.merchant_id.to_owned())),
PaymentAttemptUpdateInternal::from(payment_attempt_update),
)
.await
.inspect_err(|err| {
logger::error!(
"Error while updating payment attempt in connector_response flow {:?}",
err
);
});
generics::generic_insert(conn, self).await
}
}
impl ConnectorResponse {
#[instrument(skip(conn))]
pub async fn update(
self,
conn: &PgPooledConn,
connector_response: ConnectorResponseUpdate,
) -> StorageResult<Self> {
let payment_attempt_update = match connector_response.clone() {
ConnectorResponseUpdate::ResponseUpdate {
connector_transaction_id,
authentication_data,
encoded_data,
connector_name,
charge_id,
updated_by,
} => PaymentAttemptUpdate::ConnectorResponse {
authentication_data,
encoded_data,
connector_transaction_id,
connector: connector_name,
charge_id,
updated_by,
},
ConnectorResponseUpdate::ErrorUpdate {
connector_name,
updated_by,
} => PaymentAttemptUpdate::ConnectorResponse {
authentication_data: None,
encoded_data: None,
connector_transaction_id: None,
connector: connector_name,
charge_id: None,
updated_by,
},
};
let _payment_attempt: Result<PaymentAttempt, _> =
generics::generic_update_with_unique_predicate_get_result::<
<PaymentAttempt as HasTable>::Table,
_,
_,
_,
>(
conn,
pa_dsl::attempt_id
.eq(self.attempt_id.to_owned())
.and(pa_dsl::merchant_id.eq(self.merchant_id.to_owned())),
PaymentAttemptUpdateInternal::from(payment_attempt_update),
)
.await
.inspect_err(|err| {
logger::error!(
"Error while updating payment attempt in connector_response flow {:?}",
err
);
});
let connector_response_result =
match generics::generic_update_with_unique_predicate_get_result::<
<Self as HasTable>::Table,
_,
_,
_,
>(
conn,
dsl::merchant_id
.eq(self.merchant_id.clone())
.and(dsl::payment_id.eq(self.payment_id.clone()))
.and(dsl::attempt_id.eq(self.attempt_id.clone())),
ConnectorResponseUpdateInternal::from(connector_response),
)
.await
{
Err(error) => match error.current_context() {
errors::DatabaseError::NoFieldsToUpdate => Ok(self),
_ => Err(error),
},
result => result,
};
connector_response_result
}
#[instrument(skip(conn))]
pub async fn find_by_payment_id_merchant_id_attempt_id(
conn: &PgPooledConn,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
attempt_id: &str,
) -> StorageResult<Self> {
let connector_response: Self =
generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
conn,
dsl::merchant_id.eq(merchant_id.to_owned()).and(
dsl::payment_id
.eq(payment_id.to_owned())
.and(dsl::attempt_id.eq(attempt_id.to_owned())),
),
)
.await?;
match generics::generic_find_one::<<PaymentAttempt as HasTable>::Table, _, _>(
conn,
pa_dsl::payment_id.eq(payment_id.to_owned()).and(
pa_dsl::merchant_id
.eq(merchant_id.to_owned())
.and(pa_dsl::attempt_id.eq(attempt_id.to_owned())),
),
)
.await
{
Ok::<PaymentAttempt, _>(payment_attempt) => {
if payment_attempt.authentication_data != connector_response.authentication_data {
logger::error!(
"Not Equal pa_authentication_data : {:?}, cr_authentication_data: {:?} ",
payment_attempt.authentication_data,
connector_response.authentication_data
);
}
if payment_attempt.encoded_data != connector_response.encoded_data {
logger::error!(
"Not Equal pa_encoded_data : {:?}, cr_encoded_data: {:?} ",
payment_attempt.encoded_data,
connector_response.encoded_data
);
}
if payment_attempt.connector_transaction_id
!= connector_response.connector_transaction_id
{
logger::error!(
"Not Equal pa_connector_transaction_id : {:?}, cr_connector_transaction_id: {:?} ",
payment_attempt.connector_transaction_id,
connector_response.connector_transaction_id
);
}
if payment_attempt.connector != connector_response.connector_name {
logger::error!(
"Not Equal pa_connector : {:?}, cr_connector_name: {:?} ",
payment_attempt.connector,
connector_response.connector_name
);
}
}
Err(err) => {
logger::error!(
"Error while finding payment attempt in connector_response flow {:?}",
err
);
}
}
Ok(connector_response)
}
}
|
crates/diesel_models/src/query/connector_response.rs
|
diesel_models
|
full_file
| null | null | null | 1,383
| null | null | null | null | null | null | null |
// Struct: ThreedsecureioPreAuthenticationResponseData
// File: crates/hyperswitch_connectors/src/connectors/threedsecureio/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct ThreedsecureioPreAuthenticationResponseData
|
crates/hyperswitch_connectors/src/connectors/threedsecureio/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
ThreedsecureioPreAuthenticationResponseData
| 0
|
[] | 59
| null | null | null | null | null | null | null |
// Module Structure
// File: crates/hyperswitch_connectors/src/connectors/nordea.rs
// Module: hyperswitch_connectors
// Public submodules:
pub mod transformers;
|
crates/hyperswitch_connectors/src/connectors/nordea.rs
|
hyperswitch_connectors
|
module_structure
| null | null | null | 39
| null | null | null | null | null | 1
| 0
|
// Struct: Shipping
// File: crates/router/src/compatibility/stripe/customers/types.rs
// Module: router
// Implementations: 0
pub struct Shipping
|
crates/router/src/compatibility/stripe/customers/types.rs
|
router
|
struct_definition
|
Shipping
| 0
|
[] | 36
| null | null | null | null | null | null | null |
// Implementation: impl api::PaymentAuthorize for for Ebanx
// File: crates/hyperswitch_connectors/src/connectors/ebanx.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentAuthorize for for Ebanx
|
crates/hyperswitch_connectors/src/connectors/ebanx.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 61
| null |
Ebanx
|
api::PaymentAuthorize for
| 0
| 0
| null | null |
// Trait: IntoContext
// File: crates/kgraph_utils/src/transformers.rs
// Module: kgraph_utils
pub trait IntoContext
|
crates/kgraph_utils/src/transformers.rs
|
kgraph_utils
|
trait_definition
| null | null | null | 30
| null | null |
IntoContext
| null | null | null | null |
// Struct: NovalnetWebhookEvent
// File: crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct NovalnetWebhookEvent
|
crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
NovalnetWebhookEvent
| 0
|
[] | 54
| null | null | null | null | null | null | null |
// Module Structure
// File: crates/hyperswitch_connectors/src/connectors/redsys.rs
// Module: hyperswitch_connectors
// Public submodules:
pub mod transformers;
|
crates/hyperswitch_connectors/src/connectors/redsys.rs
|
hyperswitch_connectors
|
module_structure
| null | null | null | 38
| null | null | null | null | null | 1
| 0
|
// Function: api_key_list
// File: crates/router/src/routes/api_keys.rs
// Module: router
pub fn api_key_list(
state: web::Data<AppState>,
req: HttpRequest,
query: web::Query<api_types::ListApiKeyConstraints>,
) -> impl Responder
|
crates/router/src/routes/api_keys.rs
|
router
|
function_signature
| null | null | null | 62
|
api_key_list
| null | null | null | null | null | null |
// Struct: RefundResponse
// File: crates/hyperswitch_connectors/src/connectors/hipay/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct RefundResponse
|
crates/hyperswitch_connectors/src/connectors/hipay/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
RefundResponse
| 0
|
[] | 48
| null | null | null | null | null | null | null |
// Struct: PoRecipientAccount
// File: crates/hyperswitch_domain_models/src/router_flow_types/payouts.rs
// Module: hyperswitch_domain_models
// Implementations: 0
pub struct PoRecipientAccount
|
crates/hyperswitch_domain_models/src/router_flow_types/payouts.rs
|
hyperswitch_domain_models
|
struct_definition
|
PoRecipientAccount
| 0
|
[] | 46
| null | null | null | null | null | null | null |
// Function: payments_manual_update
// File: crates/router/src/core/payments.rs
// Module: router
pub fn payments_manual_update(
state: SessionState,
req: api_models::payments::PaymentsManualUpdateRequest,
) -> RouterResponse<api_models::payments::PaymentsManualUpdateResponse>
|
crates/router/src/core/payments.rs
|
router
|
function_signature
| null | null | null | 63
|
payments_manual_update
| null | null | null | null | null | null |
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
)]
#[router_derive::diesel_enum(storage_type = "text")]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum UserAuthType {
OpenIdConnect,
MagicLink,
#[default]
Password,
}
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
)]
#[router_derive::diesel_enum(storage_type = "text")]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum Owner {
Organization,
Tenant,
Internal,
}
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
ToSchema,
)]
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum ApiVersion {
V1,
V2,
}
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
Ord,
PartialOrd,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
strum::EnumIter,
ToSchema,
Hash,
)]
#[router_derive::diesel_enum(storage_type = "text")]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum EntityType {
Tenant = 3,
Organization = 2,
Merchant = 1,
Profile = 0,
}
#[derive(Clone, Debug, serde::Serialize)]
#[serde(rename_all = "snake_case")]
pub enum PayoutRetryType {
SingleConnector,
MultiConnector,
}
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
ToSchema,
Hash,
)]
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum OrderFulfillmentTimeOrigin {
Create,
Confirm,
}
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
ToSchema,
Hash,
)]
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum UIWidgetFormLayout {
Tabs,
Journey,
}
#[derive(
Clone,
Copy,
Debug,
Default,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
ToSchema,
)]
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum DeleteStatus {
#[default]
Active,
Redacted,
}
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
Hash,
strum::EnumString,
)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
#[router_derive::diesel_enum(storage_type = "db_enum")]
pub enum SuccessBasedRoutingConclusiveState {
// pc: payment connector
// sc: success based routing outcome/first connector
// status: payment status
//
// status = success && pc == sc
TruePositive,
// status = failed && pc == sc
FalsePositive,
// status = failed && pc != sc
TrueNegative,
// status = success && pc != sc
FalseNegative,
// status = processing
NonDeterministic,
}
/// Whether 3ds authentication is requested or not
#[derive(
Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize, Default, ToSchema,
)]
pub enum External3dsAuthenticationRequest {
/// Request for 3ds authentication
Enable,
/// Skip 3ds authentication
#[default]
Skip,
}
/// Whether payment link is requested to be enabled or not for this transaction
#[derive(
Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize, Default, ToSchema,
)]
pub enum EnablePaymentLinkRequest {
/// Request for enabling payment link
Enable,
/// Skip enabling payment link
#[default]
Skip,
}
#[derive(
Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize, Default, ToSchema,
)]
pub enum MitExemptionRequest {
/// Request for applying MIT exemption
Apply,
/// Skip applying MIT exemption
#[default]
Skip,
}
/// Set to `present` to indicate that the customer is in your checkout flow during this payment, and therefore is able to authenticate. This parameter should be `absent` when merchant's doing merchant initiated payments and customer is not present while doing the payment.
#[derive(
Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize, Default, ToSchema,
)]
#[serde(rename_all = "snake_case")]
pub enum PresenceOfCustomerDuringPayment {
/// Customer is present during the payment. This is the default value
#[default]
Present,
/// Customer is absent during the payment
Absent,
}
impl From<ConnectorType> for TransactionType {
fn from(connector_type: ConnectorType) -> Self {
match connector_type {
#[cfg(feature = "payouts")]
ConnectorType::PayoutProcessor => Self::Payout,
_ => Self::Payment,
}
}
}
impl From<RefundStatus> for RelayStatus {
fn from(refund_status: RefundStatus) -> Self {
match refund_status {
RefundStatus::Failure | RefundStatus::TransactionFailure => Self::Failure,
RefundStatus::ManualReview | RefundStatus::Pending => Self::Pending,
RefundStatus::Success => Self::Success,
}
}
}
impl From<RelayStatus> for RefundStatus {
fn from(relay_status: RelayStatus) -> Self {
match relay_status {
RelayStatus::Failure => Self::Failure,
RelayStatus::Pending | RelayStatus::Created => Self::Pending,
RelayStatus::Success => Self::Success,
}
}
}
#[derive(
Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize, Default, ToSchema,
)]
#[serde(rename_all = "snake_case")]
pub enum TaxCalculationOverride {
/// Skip calling the external tax provider
#[default]
Skip,
/// Calculate tax by calling the external tax provider
Calculate,
}
impl From<Option<bool>> for TaxCalculationOverride {
fn from(value: Option<bool>) -> Self {
match value {
Some(true) => Self::Calculate,
_ => Self::Skip,
}
}
}
impl TaxCalculationOverride {
pub fn as_bool(self) -> bool {
match self {
Self::Skip => false,
Self::Calculate => true,
}
}
}
#[derive(
Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize, Default, ToSchema,
)]
#[serde(rename_all = "snake_case")]
pub enum SurchargeCalculationOverride {
/// Skip calculating surcharge
#[default]
Skip,
/// Calculate surcharge
Calculate,
}
impl From<Option<bool>> for SurchargeCalculationOverride {
fn from(value: Option<bool>) -> Self {
match value {
Some(true) => Self::Calculate,
_ => Self::Skip,
}
}
}
impl SurchargeCalculationOverride {
pub fn as_bool(self) -> bool {
match self {
Self::Skip => false,
Self::Calculate => true,
}
}
}
/// Connector Mandate Status
#[derive(
Clone, Copy, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, strum::Display,
)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum ConnectorMandateStatus {
/// Indicates that the connector mandate is active and can be used for payments.
Active,
/// Indicates that the connector mandate is not active and hence cannot be used for payments.
Inactive,
}
/// Connector Mandate Status
#[derive(
Clone, Copy, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, strum::Display,
)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum ConnectorTokenStatus {
/// Indicates that the connector mandate is active and can be used for payments.
Active,
/// Indicates that the connector mandate is not active and hence cannot be used for payments.
Inactive,
}
#[derive(
Clone,
Copy,
Debug,
strum::Display,
PartialEq,
Eq,
serde::Serialize,
serde::Deserialize,
strum::EnumString,
ToSchema,
PartialOrd,
Ord,
)]
#[router_derive::diesel_enum(storage_type = "text")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum ErrorCategory {
FrmDecline,
ProcessorDowntime,
ProcessorDeclineUnauthorized,
IssueWithPaymentMethod,
ProcessorDeclineIncorrectData,
HardDecline,
SoftDecline,
}
impl ErrorCategory {
pub fn should_perform_elimination_routing(self) -> bool {
match self {
Self::ProcessorDowntime | Self::ProcessorDeclineUnauthorized => true,
Self::IssueWithPaymentMethod
| Self::ProcessorDeclineIncorrectData
| Self::FrmDecline
| Self::HardDecline
| Self::SoftDecline => false,
}
}
}
#[derive(
Clone,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
ToSchema,
Hash,
)]
pub enum PaymentChargeType {
#[serde(untagged)]
Stripe(StripeChargeType),
}
#[derive(
Clone,
Debug,
Default,
Hash,
Eq,
PartialEq,
ToSchema,
serde::Serialize,
serde::Deserialize,
strum::Display,
strum::EnumString,
)]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "lowercase")]
pub enum StripeChargeType {
#[default]
Direct,
Destination,
}
/// Authentication Products
#[derive(
Clone,
Copy,
Debug,
Eq,
Hash,
PartialEq,
serde::Serialize,
serde::Deserialize,
strum::Display,
strum::EnumString,
ToSchema,
)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum AuthenticationProduct {
ClickToPay,
}
/// Connector Access Method
#[derive(
Clone,
Copy,
Debug,
Eq,
Hash,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
ToSchema,
)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum HyperswitchConnectorCategory {
PaymentGateway,
AlternativePaymentMethod,
BankAcquirer,
PayoutProcessor,
AuthenticationProvider,
FraudAndRiskManagementProvider,
TaxCalculationProvider,
RevenueGrowthManagementPlatform,
}
/// Connector Integration Status
#[derive(
Clone,
Copy,
Debug,
Eq,
Hash,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
ToSchema,
)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum ConnectorIntegrationStatus {
/// Connector is integrated and live on production
Live,
/// Connector is integrated and fully tested on sandbox
Sandbox,
/// Connector is integrated and partially tested on sandbox
Beta,
/// Connector is integrated using the online documentation but not tested yet
Alpha,
}
/// The status of the feature
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
ToSchema,
)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum FeatureStatus {
NotSupported,
Supported,
}
/// The type of tokenization to use for the payment method
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
ToSchema,
)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum TokenizationType {
/// Create a single use token for the given payment method
/// The user might have to go through additional factor authentication when using the single use token if required by the payment method
SingleUse,
/// Create a multi use token for the given payment method
/// User will have to complete the additional factor authentication only once when creating the multi use token
/// This will create a mandate at the connector which can be used for recurring payments
MultiUse,
}
/// The network tokenization toggle, whether to enable or skip the network tokenization
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
pub enum NetworkTokenizationToggle {
/// Enable network tokenization for the payment method
Enable,
/// Skip network tokenization for the payment method
Skip,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, ToSchema)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum GooglePayAuthMethod {
/// Contain pan data only
PanOnly,
/// Contain cryptogram data along with pan data
#[serde(rename = "CRYPTOGRAM_3DS")]
Cryptogram,
}
#[derive(
Clone,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
ToSchema,
)]
#[strum(serialize_all = "PascalCase")]
#[serde(rename_all = "PascalCase")]
pub enum AdyenSplitType {
/// Books split amount to the specified account.
BalanceAccount,
/// The aggregated amount of the interchange and scheme fees.
AcquiringFees,
/// The aggregated amount of all transaction fees.
PaymentFee,
/// The aggregated amount of Adyen's commission and markup fees.
AdyenFees,
/// The transaction fees due to Adyen under blended rates.
AdyenCommission,
/// The transaction fees due to Adyen under Interchange ++ pricing.
AdyenMarkup,
/// The fees paid to the issuer for each payment made with the card network.
Interchange,
/// The fees paid to the card scheme for using their network.
SchemeFee,
/// Your platform's commission on the payment (specified in amount), booked to your liable balance account.
Commission,
/// Allows you and your users to top up balance accounts using direct debit, card payments, or other payment methods.
TopUp,
/// The value-added tax charged on the payment, booked to your platforms liable balance account.
Vat,
}
#[derive(
Clone, Copy, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, Default,
)]
#[serde(rename = "snake_case")]
pub enum PaymentConnectorTransmission {
/// Failed to call the payment connector
#[default]
ConnectorCallUnsuccessful,
/// Payment Connector call succeeded
ConnectorCallSucceeded,
}
#[derive(
Clone,
Copy,
Debug,
Default,
Eq,
Hash,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
ToSchema,
)]
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum TriggeredBy {
/// Denotes payment attempt is been created by internal system.
#[default]
Internal,
/// Denotes payment attempt is been created by external system.
External,
}
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
ToSchema,
)]
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum ProcessTrackerStatus {
// Picked by the producer
Processing,
// State when the task is added
New,
// Send to retry
Pending,
// Picked by consumer
ProcessStarted,
// Finished by consumer
Finish,
// Review the task
Review,
}
#[derive(
serde::Serialize,
serde::Deserialize,
Clone,
Copy,
Debug,
PartialEq,
Eq,
strum::EnumString,
strum::Display,
)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
pub enum ProcessTrackerRunner {
PaymentsSyncWorkflow,
RefundWorkflowRouter,
DeleteTokenizeDataWorkflow,
ApiKeyExpiryWorkflow,
OutgoingWebhookRetryWorkflow,
AttachPayoutAccountWorkflow,
PaymentMethodStatusUpdateWorkflow,
PassiveRecoveryWorkflow,
ProcessDisputeWorkflow,
DisputeListWorkflow,
}
#[derive(Debug)]
pub enum CryptoPadding {
PKCS7,
ZeroPadding,
}
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
ToSchema,
)]
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum TokenizationFlag {
/// Token is active and can be used for payments
Enabled,
/// Token is inactive and cannot be used for payments
Disabled,
}
/// The type of token data to fetch for get-token endpoint
#[derive(Clone, Copy, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum TokenDataType {
/// Fetch single use token for the given payment method
SingleUseToken,
/// Fetch multi use token for the given payment method
MultiUseToken,
/// Fetch network token for the given payment method
NetworkToken,
}
#[derive(
Clone,
Debug,
Default,
Eq,
Hash,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::VariantNames,
strum::EnumIter,
strum::EnumString,
ToSchema,
)]
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum RoutingApproach {
SuccessRateExploitation,
SuccessRateExploration,
ContractBasedRouting,
DebitRouting,
RuleBasedRouting,
VolumeBasedRouting,
StraightThroughRouting,
#[default]
DefaultFallback,
#[serde(untagged)]
#[strum(default)]
Other(String),
}
impl RoutingApproach {
pub fn from_decision_engine_approach(approach: &str) -> Self {
match approach {
"SR_SELECTION_V3_ROUTING" => Self::SuccessRateExploitation,
"SR_V3_HEDGING" | "DEFAULT" => Self::SuccessRateExploration,
"NTW_BASED_ROUTING" => Self::DebitRouting,
_ => Self::DefaultFallback,
}
}
}
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Serialize,
serde::Deserialize,
ToSchema,
strum::Display,
strum::EnumString,
Hash,
)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
#[router_derive::diesel_enum(storage_type = "text")]
pub enum CallbackMapperIdType {
NetworkTokenRequestorReferenceID,
}
/// Payment Method Status
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
serde::Serialize,
serde::Deserialize,
strum::Display,
strum::EnumString,
ToSchema,
)]
#[router_derive::diesel_enum(storage_type = "text")]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum VaultType {
/// Indicates that the payment method is stored in internal vault.
Internal,
/// Indicates that the payment method is stored in external vault.
External,
}
#[derive(
Clone,
Debug,
Copy,
Default,
Eq,
Hash,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
ToSchema,
)]
#[router_derive::diesel_enum(storage_type = "text")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum ExternalVaultEnabled {
Enable,
#[default]
Skip,
}
|
crates/common_enums/src/enums.rs#chunk8
|
common_enums
|
chunk
| null | null | null | 4,770
| null | null | null | null | null | null | null |
// File: crates/diesel_models/src/kv.rs
// Module: diesel_models
// Public functions: 4
// Public structs: 12
use error_stack::ResultExt;
use serde::{Deserialize, Serialize};
#[cfg(feature = "v2")]
use crate::payment_attempt::PaymentAttemptUpdateInternal;
#[cfg(feature = "v1")]
use crate::payment_intent::PaymentIntentUpdate;
#[cfg(feature = "v2")]
use crate::payment_intent::PaymentIntentUpdateInternal;
use crate::{
address::{Address, AddressNew, AddressUpdateInternal},
customers::{Customer, CustomerNew, CustomerUpdateInternal},
errors,
payment_attempt::{PaymentAttempt, PaymentAttemptNew, PaymentAttemptUpdate},
payment_intent::PaymentIntentNew,
payout_attempt::{PayoutAttempt, PayoutAttemptNew, PayoutAttemptUpdate},
payouts::{Payouts, PayoutsNew, PayoutsUpdate},
refund::{Refund, RefundNew, RefundUpdate},
reverse_lookup::{ReverseLookup, ReverseLookupNew},
Mandate, MandateNew, MandateUpdateInternal, PaymentIntent, PaymentMethod, PaymentMethodNew,
PaymentMethodUpdateInternal, PgPooledConn,
};
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case", tag = "db_op", content = "data")]
pub enum DBOperation {
Insert { insertable: Box<Insertable> },
Update { updatable: Box<Updateable> },
}
impl DBOperation {
pub fn operation<'a>(&self) -> &'a str {
match self {
Self::Insert { .. } => "insert",
Self::Update { .. } => "update",
}
}
pub fn table<'a>(&self) -> &'a str {
match self {
Self::Insert { insertable } => match **insertable {
Insertable::PaymentIntent(_) => "payment_intent",
Insertable::PaymentAttempt(_) => "payment_attempt",
Insertable::Refund(_) => "refund",
Insertable::Address(_) => "address",
Insertable::Payouts(_) => "payouts",
Insertable::PayoutAttempt(_) => "payout_attempt",
Insertable::Customer(_) => "customer",
Insertable::ReverseLookUp(_) => "reverse_lookup",
Insertable::PaymentMethod(_) => "payment_method",
Insertable::Mandate(_) => "mandate",
},
Self::Update { updatable } => match **updatable {
Updateable::PaymentIntentUpdate(_) => "payment_intent",
Updateable::PaymentAttemptUpdate(_) => "payment_attempt",
Updateable::RefundUpdate(_) => "refund",
Updateable::CustomerUpdate(_) => "customer",
Updateable::AddressUpdate(_) => "address",
Updateable::PayoutsUpdate(_) => "payouts",
Updateable::PayoutAttemptUpdate(_) => "payout_attempt",
Updateable::PaymentMethodUpdate(_) => "payment_method",
Updateable::MandateUpdate(_) => " mandate",
},
}
}
}
#[derive(Debug)]
pub enum DBResult {
PaymentIntent(Box<PaymentIntent>),
PaymentAttempt(Box<PaymentAttempt>),
Refund(Box<Refund>),
Address(Box<Address>),
Customer(Box<Customer>),
ReverseLookUp(Box<ReverseLookup>),
Payouts(Box<Payouts>),
PayoutAttempt(Box<PayoutAttempt>),
PaymentMethod(Box<PaymentMethod>),
Mandate(Box<Mandate>),
}
#[derive(Debug, Serialize, Deserialize)]
pub struct TypedSql {
#[serde(flatten)]
pub op: DBOperation,
}
impl DBOperation {
pub async fn execute(self, conn: &PgPooledConn) -> crate::StorageResult<DBResult> {
Ok(match self {
Self::Insert { insertable } => match *insertable {
Insertable::PaymentIntent(a) => {
DBResult::PaymentIntent(Box::new(a.insert(conn).await?))
}
Insertable::PaymentAttempt(a) => {
DBResult::PaymentAttempt(Box::new(a.insert(conn).await?))
}
Insertable::Refund(a) => DBResult::Refund(Box::new(a.insert(conn).await?)),
Insertable::Address(addr) => DBResult::Address(Box::new(addr.insert(conn).await?)),
Insertable::Customer(cust) => {
DBResult::Customer(Box::new(cust.insert(conn).await?))
}
Insertable::ReverseLookUp(rev) => {
DBResult::ReverseLookUp(Box::new(rev.insert(conn).await?))
}
Insertable::Payouts(rev) => DBResult::Payouts(Box::new(rev.insert(conn).await?)),
Insertable::PayoutAttempt(rev) => {
DBResult::PayoutAttempt(Box::new(rev.insert(conn).await?))
}
Insertable::PaymentMethod(rev) => {
DBResult::PaymentMethod(Box::new(rev.insert(conn).await?))
}
Insertable::Mandate(m) => DBResult::Mandate(Box::new(m.insert(conn).await?)),
},
Self::Update { updatable } => match *updatable {
#[cfg(feature = "v1")]
Updateable::PaymentIntentUpdate(a) => {
DBResult::PaymentIntent(Box::new(a.orig.update(conn, a.update_data).await?))
}
#[cfg(feature = "v2")]
Updateable::PaymentIntentUpdate(a) => {
DBResult::PaymentIntent(Box::new(a.orig.update(conn, a.update_data).await?))
}
#[cfg(feature = "v1")]
Updateable::PaymentAttemptUpdate(a) => DBResult::PaymentAttempt(Box::new(
a.orig.update_with_attempt_id(conn, a.update_data).await?,
)),
#[cfg(feature = "v2")]
Updateable::PaymentAttemptUpdate(a) => DBResult::PaymentAttempt(Box::new(
a.orig.update_with_attempt_id(conn, a.update_data).await?,
)),
#[cfg(feature = "v1")]
Updateable::RefundUpdate(a) => {
DBResult::Refund(Box::new(a.orig.update(conn, a.update_data).await?))
}
#[cfg(feature = "v2")]
Updateable::RefundUpdate(a) => {
DBResult::Refund(Box::new(a.orig.update_with_id(conn, a.update_data).await?))
}
Updateable::AddressUpdate(a) => {
DBResult::Address(Box::new(a.orig.update(conn, a.update_data).await?))
}
Updateable::PayoutsUpdate(a) => {
DBResult::Payouts(Box::new(a.orig.update(conn, a.update_data).await?))
}
Updateable::PayoutAttemptUpdate(a) => DBResult::PayoutAttempt(Box::new(
a.orig.update_with_attempt_id(conn, a.update_data).await?,
)),
#[cfg(feature = "v1")]
Updateable::PaymentMethodUpdate(v) => DBResult::PaymentMethod(Box::new(
v.orig
.update_with_payment_method_id(conn, v.update_data)
.await?,
)),
#[cfg(feature = "v2")]
Updateable::PaymentMethodUpdate(v) => DBResult::PaymentMethod(Box::new(
v.orig.update_with_id(conn, v.update_data).await?,
)),
Updateable::MandateUpdate(m) => DBResult::Mandate(Box::new(
Mandate::update_by_merchant_id_mandate_id(
conn,
&m.orig.merchant_id,
&m.orig.mandate_id,
m.update_data,
)
.await?,
)),
#[cfg(feature = "v1")]
Updateable::CustomerUpdate(cust) => DBResult::Customer(Box::new(
Customer::update_by_customer_id_merchant_id(
conn,
cust.orig.customer_id.clone(),
cust.orig.merchant_id.clone(),
cust.update_data,
)
.await?,
)),
#[cfg(feature = "v2")]
Updateable::CustomerUpdate(cust) => DBResult::Customer(Box::new(
Customer::update_by_id(conn, cust.orig.id, cust.update_data).await?,
)),
},
})
}
}
impl TypedSql {
pub fn to_field_value_pairs(
&self,
request_id: String,
global_id: String,
) -> crate::StorageResult<Vec<(&str, String)>> {
let pushed_at = common_utils::date_time::now_unix_timestamp();
Ok(vec![
(
"typed_sql",
serde_json::to_string(self)
.change_context(errors::DatabaseError::QueryGenerationFailed)?,
),
("global_id", global_id),
("request_id", request_id),
("pushed_at", pushed_at.to_string()),
])
}
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case", tag = "table", content = "data")]
pub enum Insertable {
PaymentIntent(Box<PaymentIntentNew>),
PaymentAttempt(Box<PaymentAttemptNew>),
Refund(RefundNew),
Address(Box<AddressNew>),
Customer(CustomerNew),
ReverseLookUp(ReverseLookupNew),
Payouts(PayoutsNew),
PayoutAttempt(PayoutAttemptNew),
PaymentMethod(PaymentMethodNew),
Mandate(MandateNew),
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case", tag = "table", content = "data")]
pub enum Updateable {
PaymentIntentUpdate(Box<PaymentIntentUpdateMems>),
PaymentAttemptUpdate(Box<PaymentAttemptUpdateMems>),
RefundUpdate(Box<RefundUpdateMems>),
CustomerUpdate(CustomerUpdateMems),
AddressUpdate(Box<AddressUpdateMems>),
PayoutsUpdate(PayoutsUpdateMems),
PayoutAttemptUpdate(PayoutAttemptUpdateMems),
PaymentMethodUpdate(Box<PaymentMethodUpdateMems>),
MandateUpdate(MandateUpdateMems),
}
#[derive(Debug, Serialize, Deserialize)]
pub struct CustomerUpdateMems {
pub orig: Customer,
pub update_data: CustomerUpdateInternal,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AddressUpdateMems {
pub orig: Address,
pub update_data: AddressUpdateInternal,
}
#[cfg(feature = "v1")]
#[derive(Debug, Serialize, Deserialize)]
pub struct PaymentIntentUpdateMems {
pub orig: PaymentIntent,
pub update_data: PaymentIntentUpdate,
}
#[cfg(feature = "v2")]
#[derive(Debug, Serialize, Deserialize)]
pub struct PaymentIntentUpdateMems {
pub orig: PaymentIntent,
pub update_data: PaymentIntentUpdateInternal,
}
#[cfg(feature = "v1")]
#[derive(Debug, Serialize, Deserialize)]
pub struct PaymentAttemptUpdateMems {
pub orig: PaymentAttempt,
pub update_data: PaymentAttemptUpdate,
}
#[cfg(feature = "v2")]
#[derive(Debug, Serialize, Deserialize)]
pub struct PaymentAttemptUpdateMems {
pub orig: PaymentAttempt,
pub update_data: PaymentAttemptUpdateInternal,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct RefundUpdateMems {
pub orig: Refund,
pub update_data: RefundUpdate,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PayoutsUpdateMems {
pub orig: Payouts,
pub update_data: PayoutsUpdate,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PayoutAttemptUpdateMems {
pub orig: PayoutAttempt,
pub update_data: PayoutAttemptUpdate,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PaymentMethodUpdateMems {
pub orig: PaymentMethod,
pub update_data: PaymentMethodUpdateInternal,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct MandateUpdateMems {
pub orig: Mandate,
pub update_data: MandateUpdateInternal,
}
|
crates/diesel_models/src/kv.rs
|
diesel_models
|
full_file
| null | null | null | 2,555
| null | null | null | null | null | null | null |
// Implementation: impl api::PaymentCapture for for Bankofamerica
// File: crates/hyperswitch_connectors/src/connectors/bankofamerica.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentCapture for for Bankofamerica
|
crates/hyperswitch_connectors/src/connectors/bankofamerica.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 64
| null |
Bankofamerica
|
api::PaymentCapture for
| 0
| 0
| null | null |
// Implementation: impl api::Refund for for Blackhawknetwork
// File: crates/hyperswitch_connectors/src/connectors/blackhawknetwork.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::Refund for for Blackhawknetwork
|
crates/hyperswitch_connectors/src/connectors/blackhawknetwork.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 60
| null |
Blackhawknetwork
|
api::Refund for
| 0
| 0
| null | null |
// File: crates/router/src/env.rs
// Module: router
#[doc(inline)]
pub use router_env::*;
|
crates/router/src/env.rs
|
router
|
full_file
| null | null | null | 24
| null | null | null | null | null | null | null |
// Implementation: impl api::Payment for for Prophetpay
// File: crates/hyperswitch_connectors/src/connectors/prophetpay.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::Payment for for Prophetpay
|
crates/hyperswitch_connectors/src/connectors/prophetpay.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 56
| null |
Prophetpay
|
api::Payment for
| 0
| 0
| null | null |
// Implementation: impl ConnectorCommon for for Vgs
// File: crates/hyperswitch_connectors/src/connectors/vgs.rs
// Module: hyperswitch_connectors
// Methods: 6 total (0 public)
impl ConnectorCommon for for Vgs
|
crates/hyperswitch_connectors/src/connectors/vgs.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 53
| null |
Vgs
|
ConnectorCommon for
| 6
| 0
| null | null |
// Struct: DsResponse
// File: crates/hyperswitch_connectors/src/connectors/redsys/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct DsResponse
|
crates/hyperswitch_connectors/src/connectors/redsys/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
DsResponse
| 0
|
[] | 47
| null | null | null | null | null | null | null |
// Struct: IntegrationMethod
// File: crates/api_models/src/user/dashboard_metadata.rs
// Module: api_models
// Implementations: 0
pub struct IntegrationMethod
|
crates/api_models/src/user/dashboard_metadata.rs
|
api_models
|
struct_definition
|
IntegrationMethod
| 0
|
[] | 35
| null | null | null | null | null | null | null |
// Struct: TrustpaymentsSyncRequest
// File: crates/hyperswitch_connectors/src/connectors/trustpayments/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct TrustpaymentsSyncRequest
|
crates/hyperswitch_connectors/src/connectors/trustpayments/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
TrustpaymentsSyncRequest
| 0
|
[] | 50
| null | null | null | null | null | null | null |
// Struct: PaypalSupplementaryData
// File: crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct PaypalSupplementaryData
|
crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
PaypalSupplementaryData
| 0
|
[] | 49
| null | null | null | null | null | null | null |
// Function: initiate_secure_payment_link_flow
// File: crates/router/src/core/payment_link.rs
// Module: router
pub fn initiate_secure_payment_link_flow(
state: SessionState,
merchant_context: domain::MerchantContext,
merchant_id: common_utils::id_type::MerchantId,
payment_id: common_utils::id_type::PaymentId,
request_headers: &header::HeaderMap,
) -> RouterResponse<services::PaymentLinkFormData>
|
crates/router/src/core/payment_link.rs
|
router
|
function_signature
| null | null | null | 95
|
initiate_secure_payment_link_flow
| null | null | null | null | null | null |
// File: crates/hyperswitch_connectors/src/connectors/breadpay.rs
// Module: hyperswitch_connectors
// Public functions: 1
// Public structs: 1
pub mod transformers;
use std::sync::LazyLock;
use base64::Engine;
use common_enums::{enums, CallConnectorAction, PaymentAction};
use common_utils::{
consts::BASE64_ENGINE,
errors::CustomResult,
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector},
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::{
access_token_auth::AccessTokenAuth,
payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},
refunds::{Execute, RSync},
CompleteAuthorize,
},
router_request_types::{
AccessTokenRequestData, CompleteAuthorizeData, PaymentMethodTokenizationData,
PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData,
PaymentsSyncData, RefundsData, SetupMandateRequestData,
},
router_response_types::{
ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData,
SupportedPaymentMethods, SupportedPaymentMethodsExt,
},
types::{
PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
PaymentsCompleteAuthorizeRouterData, PaymentsSyncRouterData, RefundSyncRouterData,
RefundsRouterData,
},
};
use hyperswitch_interfaces::{
api::{
self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse,
ConnectorSpecifications, ConnectorValidation,
},
configs::Connectors,
errors,
events::connector_api_logs::ConnectorEvent,
types::{self, Response},
webhooks,
};
use masking::{ExposeInterface, Mask, Maskable, PeekInterface};
use transformers::{
self as breadpay, BreadpayTransactionRequest, BreadpayTransactionResponse,
BreadpayTransactionType,
};
use crate::{
connectors::breadpay::transformers::CallBackResponse,
constants::headers,
types::ResponseRouterData,
utils::{self, PaymentsCompleteAuthorizeRequestData},
};
#[derive(Clone)]
pub struct Breadpay {
amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),
}
impl Breadpay {
pub fn new() -> &'static Self {
&Self {
amount_converter: &StringMinorUnitForConnector,
}
}
}
impl api::Payment for Breadpay {}
impl api::PaymentSession for Breadpay {}
impl api::PaymentsCompleteAuthorize for Breadpay {}
impl api::ConnectorAccessToken for Breadpay {}
impl api::MandateSetup for Breadpay {}
impl api::PaymentAuthorize for Breadpay {}
impl api::PaymentSync for Breadpay {}
impl api::PaymentCapture for Breadpay {}
impl api::PaymentVoid for Breadpay {}
impl api::Refund for Breadpay {}
impl api::RefundExecute for Breadpay {}
impl api::RefundSync for Breadpay {}
impl api::PaymentToken for Breadpay {}
impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
for Breadpay
{
// Not Implemented (R)
}
impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Breadpay
where
Self: ConnectorIntegration<Flow, Request, Response>,
{
fn build_headers(
&self,
req: &RouterData<Flow, Request, Response>,
_connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
let mut header = vec![(
headers::CONTENT_TYPE.to_string(),
self.get_content_type().to_string().into(),
)];
let mut api_key = self.get_auth_header(&req.connector_auth_type)?;
header.append(&mut api_key);
Ok(header)
}
}
impl ConnectorCommon for Breadpay {
fn id(&self) -> &'static str {
"breadpay"
}
fn get_currency_unit(&self) -> api::CurrencyUnit {
api::CurrencyUnit::Minor
// TODO! Check connector documentation, on which unit they are processing the currency.
// If the connector accepts amount in lower unit ( i.e cents for USD) then return api::CurrencyUnit::Minor,
// if connector accepts amount in base unit (i.e dollars for USD) then return api::CurrencyUnit::Base
}
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {
connectors.breadpay.base_url.as_ref()
}
fn get_auth_header(
&self,
auth_type: &ConnectorAuthType,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
let auth = breadpay::BreadpayAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
let encoded_api_key = BASE64_ENGINE.encode(format!(
"{}:{}",
auth.api_key.peek(),
auth.api_secret.peek()
));
Ok(vec![(
headers::AUTHORIZATION.to_string(),
format!("Basic {encoded_api_key}").into_masked(),
)])
}
fn build_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: breadpay::BreadpayErrorResponse = res
.response
.parse_struct("BreadpayErrorResponse")
.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_type.clone(),
message: response.description.clone(),
reason: Some(response.description),
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 Breadpay {}
impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Breadpay {
//TODO: implement sessions flow
}
impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Breadpay {}
impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>
for Breadpay
{
}
impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Breadpay {
fn get_headers(
&self,
req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, 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!("{}{}", self.base_url(connectors), "/carts"))
}
fn get_request_body(
&self,
req: &PaymentsAuthorizeRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let amount = utils::convert_amount(
self.amount_converter,
req.request.minor_amount,
req.request.currency,
)?;
let connector_router_data = breadpay::BreadpayRouterData::from((amount, req));
let connector_req = breadpay::BreadpayCartRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&types::PaymentsAuthorizeType::get_url(
self, req, connectors,
)?)
.attach_default_headers()
.headers(types::PaymentsAuthorizeType::get_headers(
self, req, connectors,
)?)
.set_body(types::PaymentsAuthorizeType::get_request_body(
self, req, connectors,
)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsAuthorizeRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
let response: breadpay::BreadpayPaymentsResponse = res
.response
.parse_struct("Breadpay BreadpayPaymentsResponse")
.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 Breadpay
{
fn get_headers(
&self,
req: &PaymentsCompleteAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_request_body(
&self,
req: &PaymentsCompleteAuthorizeRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let transaction_type = if req.request.is_auto_capture()? {
BreadpayTransactionType::Settle
} else {
BreadpayTransactionType::Authorize
};
let connector_req = BreadpayTransactionRequest { transaction_type };
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn get_url(
&self,
req: &PaymentsCompleteAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
let redirect_response = req.request.redirect_response.clone().ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "redirect_response",
},
)?;
let redirect_payload = redirect_response
.payload
.ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload {
field_name: "request.redirect_response.payload",
})?
.expose();
let call_back_response: CallBackResponse = serde_json::from_value::<CallBackResponse>(
redirect_payload.clone(),
)
.change_context(errors::ConnectorError::MissingConnectorRedirectionPayload {
field_name: "redirection_payload",
})?;
Ok(format!(
"{}{}{}",
self.base_url(connectors),
"/transactions/actions",
call_back_response.transaction_id
))
}
fn build_request(
&self,
req: &PaymentsCompleteAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&types::PaymentsCompleteAuthorizeType::get_url(
self, req, connectors,
)?)
.headers(types::PaymentsCompleteAuthorizeType::get_headers(
self, req, connectors,
)?)
.set_body(types::PaymentsCompleteAuthorizeType::get_request_body(
self, req, connectors,
)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsCompleteAuthorizeRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsCompleteAuthorizeRouterData, errors::ConnectorError> {
let response: BreadpayTransactionResponse = res
.response
.parse_struct("BreadpayTransactionResponse")
.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 Breadpay {
fn get_headers(
&self,
req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!(
"{}{}{}",
self.base_url(connectors),
"/transactions",
req.request
.connector_transaction_id
.get_connector_transaction_id()
.change_context(errors::ConnectorError::MissingConnectorTransactionID)?
))
}
fn build_request(
&self,
req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Get)
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
let response: BreadpayTransactionResponse = res
.response
.parse_struct("BreadpayTransactionResponse")
.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 Breadpay {
fn get_headers(
&self,
req: &PaymentsCaptureRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, 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: &PaymentsCaptureRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!(
"{}{}{}",
self.base_url(connectors),
"/transactions/actions",
req.request.connector_transaction_id
))
}
fn get_request_body(
&self,
_req: &PaymentsCaptureRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let connector_req = BreadpayTransactionRequest {
transaction_type: BreadpayTransactionType::Settle,
};
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &PaymentsCaptureRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&types::PaymentsCaptureType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsCaptureType::get_headers(
self, req, connectors,
)?)
.set_body(types::PaymentsCaptureType::get_request_body(
self, req, connectors,
)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsCaptureRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {
let response: BreadpayTransactionResponse = res
.response
.parse_struct("BreadpayTransactionResponse")
.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 Breadpay {
fn get_headers(
&self,
req: &PaymentsCancelRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, 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: &PaymentsCancelRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!(
"{}{}{}",
self.base_url(connectors),
"/transactions/actions",
req.request.connector_transaction_id
))
}
fn get_request_body(
&self,
_req: &PaymentsCancelRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let connector_req = BreadpayTransactionRequest {
transaction_type: BreadpayTransactionType::Cancel,
};
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &PaymentsCancelRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&types::PaymentsVoidType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsVoidType::get_headers(self, req, connectors)?)
.set_body(types::PaymentsVoidType::get_request_body(
self, req, connectors,
)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsCancelRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsCancelRouterData, errors::ConnectorError> {
let response: BreadpayTransactionResponse = res
.response
.parse_struct("BreadpayTransactionResponse")
.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 Breadpay {
fn get_headers(
&self,
req: &RefundsRouterData<Execute>,
connectors: &Connectors,
) -> CustomResult<Vec<(String, 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: &RefundsRouterData<Execute>,
_connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
}
fn get_request_body(
&self,
req: &RefundsRouterData<Execute>,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let refund_amount = utils::convert_amount(
self.amount_converter,
req.request.minor_refund_amount,
req.request.currency,
)?;
let connector_router_data = breadpay::BreadpayRouterData::from((refund_amount, req));
let connector_req = breadpay::BreadpayRefundRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &RefundsRouterData<Execute>,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
let request = RequestBuilder::new()
.method(Method::Post)
.url(&types::RefundExecuteType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::RefundExecuteType::get_headers(
self, req, connectors,
)?)
.set_body(types::RefundExecuteType::get_request_body(
self, req, connectors,
)?)
.build();
Ok(Some(request))
}
fn handle_response(
&self,
data: &RefundsRouterData<Execute>,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> {
let response: breadpay::RefundResponse = res
.response
.parse_struct("breadpay RefundResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Breadpay {
fn get_headers(
&self,
req: &RefundSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, 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> {
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
}
fn build_request(
&self,
req: &RefundSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Get)
.url(&types::RefundSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::RefundSyncType::get_headers(self, req, connectors)?)
.set_body(types::RefundSyncType::get_request_body(
self, req, connectors,
)?)
.build(),
))
}
fn handle_response(
&self,
data: &RefundSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> {
let response: breadpay::RefundResponse = res
.response
.parse_struct("breadpay RefundSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
#[async_trait::async_trait]
impl webhooks::IncomingWebhook for Breadpay {
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 BREADPAY_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =
LazyLock::new(|| {
let supported_capture_methods = vec![
enums::CaptureMethod::Automatic,
enums::CaptureMethod::Manual,
enums::CaptureMethod::SequentialAutomatic,
];
let mut breadpay_supported_payment_methods = SupportedPaymentMethods::new();
breadpay_supported_payment_methods.add(
enums::PaymentMethod::PayLater,
enums::PaymentMethodType::Breadpay,
PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods,
specific_features: None,
},
);
breadpay_supported_payment_methods
});
static BREADPAY_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Breadpay",
description: "Breadpay connector",
connector_type: enums::HyperswitchConnectorCategory::PaymentGateway,
integration_status: enums::ConnectorIntegrationStatus::Alpha,
};
static BREADPAY_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
impl ConnectorSpecifications for Breadpay {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&BREADPAY_CONNECTOR_INFO)
}
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
Some(&*BREADPAY_SUPPORTED_PAYMENT_METHODS)
}
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&BREADPAY_SUPPORTED_WEBHOOK_FLOWS)
}
}
impl ConnectorRedirectResponse for Breadpay {
fn get_flow_type(
&self,
_query_params: &str,
_json_payload: Option<serde_json::Value>,
action: PaymentAction,
) -> CustomResult<CallConnectorAction, errors::ConnectorError> {
match action {
PaymentAction::PSync
| PaymentAction::CompleteAuthorize
| PaymentAction::PaymentAuthenticateCompleteAuthorize => {
Ok(CallConnectorAction::Trigger)
}
}
}
}
|
crates/hyperswitch_connectors/src/connectors/breadpay.rs
|
hyperswitch_connectors
|
full_file
| null | null | null | 6,286
| null | null | null | null | null | null | null |
// Implementation: impl api::PaymentSession for for Taxjar
// File: crates/hyperswitch_connectors/src/connectors/taxjar.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentSession for for Taxjar
|
crates/hyperswitch_connectors/src/connectors/taxjar.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 58
| null |
Taxjar
|
api::PaymentSession for
| 0
| 0
| null | null |
// Struct: BamboraPaymentsCaptureRequest
// File: crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct BamboraPaymentsCaptureRequest
|
crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
BamboraPaymentsCaptureRequest
| 0
|
[] | 54
| null | null | null | null | null | null | null |
// Struct: DebitRoutingOutput
// File: crates/api_models/src/open_router.rs
// Module: api_models
// Implementations: 0
pub struct DebitRoutingOutput
|
crates/api_models/src/open_router.rs
|
api_models
|
struct_definition
|
DebitRoutingOutput
| 0
|
[] | 38
| null | null | null | null | null | null | null |
// Struct: PaytmAuthType
// File: crates/hyperswitch_connectors/src/connectors/paytm/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct PaytmAuthType
|
crates/hyperswitch_connectors/src/connectors/paytm/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
PaytmAuthType
| 0
|
[] | 49
| null | null | null | null | null | null | null |
// Function: fetch_payout_method_data
// File: crates/router/src/core/payouts/helpers.rs
// Module: router
pub fn fetch_payout_method_data(
state: &SessionState,
payout_data: &mut PayoutData,
connector_data: &api::ConnectorData,
merchant_context: &domain::MerchantContext,
) -> RouterResult<()>
|
crates/router/src/core/payouts/helpers.rs
|
router
|
function_signature
| null | null | null | 77
|
fetch_payout_method_data
| null | null | null | null | null | null |
// Implementation: impl api::PaymentVoid for for Mifinity
// File: crates/hyperswitch_connectors/src/connectors/mifinity.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentVoid for for Mifinity
|
crates/hyperswitch_connectors/src/connectors/mifinity.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 60
| null |
Mifinity
|
api::PaymentVoid for
| 0
| 0
| null | null |
// Implementation: impl Responder
// File: crates/router/src/analytics.rs
// Module: router
// Methods: 0 total (0 public)
impl Responder
|
crates/router/src/analytics.rs
|
router
|
impl_block
| null | null | null | 35
| null |
Responder
| null | 0
| 0
| null | null |
// File: crates/hyperswitch_constraint_graph/src/types.rs
// Module: hyperswitch_constraint_graph
// Public functions: 6
// Public structs: 9
use std::{
any::Any,
fmt, hash,
ops::{Deref, DerefMut},
sync::Arc,
};
use rustc_hash::{FxHashMap, FxHashSet};
use crate::{dense_map::impl_entity, error::AnalysisTrace};
pub trait KeyNode: fmt::Debug + Clone + hash::Hash + serde::Serialize + PartialEq + Eq {}
pub trait ValueNode: fmt::Debug + Clone + hash::Hash + serde::Serialize + PartialEq + Eq {
type Key: KeyNode;
fn get_key(&self) -> Self::Key;
}
#[cfg(feature = "viz")]
pub trait NodeViz {
fn viz(&self) -> String;
}
#[derive(Debug, Clone, Copy, serde::Serialize, PartialEq, Eq, Hash)]
#[serde(transparent)]
pub struct NodeId(usize);
impl_entity!(NodeId);
#[derive(Debug)]
pub struct Node<V: ValueNode> {
pub node_type: NodeType<V>,
pub preds: Vec<EdgeId>,
pub succs: Vec<EdgeId>,
}
impl<V: ValueNode> Node<V> {
pub(crate) fn new(node_type: NodeType<V>) -> Self {
Self {
node_type,
preds: Vec::new(),
succs: Vec::new(),
}
}
}
#[derive(Debug, PartialEq, Eq)]
pub enum NodeType<V: ValueNode> {
AllAggregator,
AnyAggregator,
InAggregator(FxHashSet<V>),
Value(NodeValue<V>),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize)]
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
pub enum NodeValue<V: ValueNode> {
Key(<V as ValueNode>::Key),
Value(V),
}
impl<V: ValueNode> From<V> for NodeValue<V> {
fn from(value: V) -> Self {
Self::Value(value)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct EdgeId(usize);
impl_entity!(EdgeId);
#[derive(
Debug, Clone, Copy, serde::Serialize, PartialEq, Eq, Hash, strum::Display, PartialOrd, Ord,
)]
pub enum Strength {
Weak,
Normal,
Strong,
}
impl Strength {
pub fn get_resolved_strength(prev_strength: Self, curr_strength: Self) -> Self {
std::cmp::max(prev_strength, curr_strength)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, strum::Display, serde::Serialize)]
#[serde(rename_all = "snake_case")]
pub enum Relation {
Positive,
Negative,
}
impl From<Relation> for bool {
fn from(value: Relation) -> Self {
matches!(value, Relation::Positive)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, strum::Display, serde::Serialize)]
pub enum RelationResolution {
Positive,
Negative,
Contradiction,
}
impl From<Relation> for RelationResolution {
fn from(value: Relation) -> Self {
match value {
Relation::Positive => Self::Positive,
Relation::Negative => Self::Negative,
}
}
}
impl RelationResolution {
pub fn get_resolved_relation(prev_relation: Self, curr_relation: Self) -> Self {
if prev_relation != curr_relation {
Self::Contradiction
} else {
curr_relation
}
}
}
#[derive(Debug, Clone)]
pub struct Edge {
pub strength: Strength,
pub relation: Relation,
pub pred: NodeId,
pub succ: NodeId,
pub domain: Option<DomainId>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DomainId(usize);
impl_entity!(DomainId);
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DomainIdentifier(String);
impl DomainIdentifier {
pub fn new(identifier: String) -> Self {
Self(identifier)
}
pub fn into_inner(&self) -> String {
self.0.clone()
}
}
impl From<String> for DomainIdentifier {
fn from(value: String) -> Self {
Self(value)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DomainInfo {
pub domain_identifier: DomainIdentifier,
pub domain_description: String,
}
pub trait CheckingContext {
type Value: ValueNode;
fn from_node_values<L>(vals: impl IntoIterator<Item = L>) -> Self
where
L: Into<Self::Value>;
fn check_presence(&self, value: &NodeValue<Self::Value>, strength: Strength) -> bool;
fn get_values_by_key(
&self,
expected: &<Self::Value as ValueNode>::Key,
) -> Option<Vec<Self::Value>>;
}
#[derive(Debug, Clone, serde::Serialize)]
pub struct Memoization<V: ValueNode>(
#[allow(clippy::type_complexity)]
FxHashMap<(NodeId, Relation, Strength), Result<(), Arc<AnalysisTrace<V>>>>,
);
impl<V: ValueNode> Memoization<V> {
pub fn new() -> Self {
Self(FxHashMap::default())
}
}
impl<V: ValueNode> Default for Memoization<V> {
#[inline]
fn default() -> Self {
Self::new()
}
}
impl<V: ValueNode> Deref for Memoization<V> {
type Target = FxHashMap<(NodeId, Relation, Strength), Result<(), Arc<AnalysisTrace<V>>>>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<V: ValueNode> DerefMut for Memoization<V> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
#[derive(Debug, Clone)]
pub struct CycleCheck(FxHashMap<NodeId, (Strength, RelationResolution)>);
impl CycleCheck {
pub fn new() -> Self {
Self(FxHashMap::default())
}
}
impl Default for CycleCheck {
#[inline]
fn default() -> Self {
Self::new()
}
}
impl Deref for CycleCheck {
type Target = FxHashMap<NodeId, (Strength, RelationResolution)>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for CycleCheck {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
pub trait Metadata: erased_serde::Serialize + Any + Send + Sync + fmt::Debug {}
erased_serde::serialize_trait_object!(Metadata);
impl<M> Metadata for M where M: erased_serde::Serialize + Any + Send + Sync + fmt::Debug {}
|
crates/hyperswitch_constraint_graph/src/types.rs
|
hyperswitch_constraint_graph
|
full_file
| null | null | null | 1,475
| null | null | null | null | null | null | null |
// Function: get_lineage_for_user_id_and_entity_for_accepting_invite
// File: crates/router/src/utils/user_role.rs
// Module: router
pub fn get_lineage_for_user_id_and_entity_for_accepting_invite(
state: &SessionState,
user_id: &str,
tenant_id: &id_type::TenantId,
entity_id: String,
entity_type: EntityType,
) -> UserResult<
Option<(
id_type::OrganizationId,
Option<id_type::MerchantId>,
Option<id_type::ProfileId>,
)>,
>
|
crates/router/src/utils/user_role.rs
|
router
|
function_signature
| null | null | null | 122
|
get_lineage_for_user_id_and_entity_for_accepting_invite
| null | null | null | null | null | null |
// Struct: BokuRouterData
// File: crates/hyperswitch_connectors/src/connectors/boku/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct BokuRouterData<T>
|
crates/hyperswitch_connectors/src/connectors/boku/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
BokuRouterData
| 0
|
[] | 51
| null | null | null | null | null | null | null |
// Struct: PSyncResponseData
// File: crates/hyperswitch_connectors/src/connectors/braintree/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct PSyncResponseData
|
crates/hyperswitch_connectors/src/connectors/braintree/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
PSyncResponseData
| 0
|
[] | 50
| null | null | null | null | null | null | null |
// Struct: CardDetailsPaymentMethod
// File: crates/hyperswitch_domain_models/src/payment_method_data.rs
// Module: hyperswitch_domain_models
// Implementations: 1
pub struct CardDetailsPaymentMethod
|
crates/hyperswitch_domain_models/src/payment_method_data.rs
|
hyperswitch_domain_models
|
struct_definition
|
CardDetailsPaymentMethod
| 1
|
[] | 45
| null | null | null | null | null | null | null |
// Function: get_setup_mandate_body
// File: crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs
// Module: hyperswitch_connectors
pub fn get_setup_mandate_body(req: &types::SetupMandateRouterData) -> Result<Vec<u8>, Error>
|
crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs
|
hyperswitch_connectors
|
function_signature
| null | null | null | 69
|
get_setup_mandate_body
| null | null | null | null | null | null |
// Struct: MultisafepayPaymentDetails
// File: crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct MultisafepayPaymentDetails
|
crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
MultisafepayPaymentDetails
| 0
|
[] | 59
| null | null | null | null | null | null | null |
// Function: update_by_merchant_id_payout_id
// File: crates/diesel_models/src/query/payouts.rs
// Module: diesel_models
pub fn update_by_merchant_id_payout_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
payout_id: &common_utils::id_type::PayoutId,
payout: PayoutsUpdate,
) -> StorageResult<Self>
|
crates/diesel_models/src/query/payouts.rs
|
diesel_models
|
function_signature
| null | null | null | 96
|
update_by_merchant_id_payout_id
| null | null | null | null | null | null |
// Implementation: impl PartialEq for for PaymentMetricsBucketIdentifier
// File: crates/api_models/src/analytics/payments.rs
// Module: api_models
// Methods: 1 total (0 public)
impl PartialEq for for PaymentMetricsBucketIdentifier
|
crates/api_models/src/analytics/payments.rs
|
api_models
|
impl_block
| null | null | null | 49
| null |
PaymentMetricsBucketIdentifier
|
PartialEq for
| 1
| 0
| null | null |
// Implementation: impl api::PaymentsPreProcessing for for Nuvei
// File: crates/hyperswitch_connectors/src/connectors/nuvei.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentsPreProcessing for for Nuvei
|
crates/hyperswitch_connectors/src/connectors/nuvei.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 63
| null |
Nuvei
|
api::PaymentsPreProcessing for
| 0
| 0
| null | null |
// Function: decode_and_decrypt_locker_data
// File: crates/router/src/core/payment_methods/cards.rs
// Module: router
pub fn decode_and_decrypt_locker_data(
state: &routes::SessionState,
key_store: &domain::MerchantKeyStore,
enc_card_data: String,
) -> errors::CustomResult<Secret<String>, errors::VaultError>
|
crates/router/src/core/payment_methods/cards.rs
|
router
|
function_signature
| null | null | null | 78
|
decode_and_decrypt_locker_data
| null | null | null | null | null | null |
// Struct: AuthipayCaptureRequest
// File: crates/hyperswitch_connectors/src/connectors/authipay/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct AuthipayCaptureRequest
|
crates/hyperswitch_connectors/src/connectors/authipay/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
AuthipayCaptureRequest
| 0
|
[] | 49
| null | null | null | null | null | null | null |
// Implementation: impl api::RefundSync for for Adyen
// File: crates/hyperswitch_connectors/src/connectors/adyen.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::RefundSync for for Adyen
|
crates/hyperswitch_connectors/src/connectors/adyen.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 60
| null |
Adyen
|
api::RefundSync for
| 0
| 0
| null | null |
// Implementation: impl api::PaymentVoid for for Nordea
// File: crates/hyperswitch_connectors/src/connectors/nordea.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentVoid for for Nordea
|
crates/hyperswitch_connectors/src/connectors/nordea.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 58
| null |
Nordea
|
api::PaymentVoid for
| 0
| 0
| null | null |
// Struct: DashboardNoPermissionAuth
// File: crates/router/src/services/authentication.rs
// Module: router
// Implementations: 0
pub struct DashboardNoPermissionAuth
|
crates/router/src/services/authentication.rs
|
router
|
struct_definition
|
DashboardNoPermissionAuth
| 0
|
[] | 36
| null | null | null | null | null | null | null |
// Implementation: impl api::PaymentSync for for Worldpayxml
// File: crates/hyperswitch_connectors/src/connectors/worldpayxml.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentSync for for Worldpayxml
|
crates/hyperswitch_connectors/src/connectors/worldpayxml.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 60
| null |
Worldpayxml
|
api::PaymentSync for
| 0
| 0
| null | null |
// File: crates/hyperswitch_connectors/src/connectors/klarna.rs
// Module: hyperswitch_connectors
// Public functions: 1
// Public structs: 1
pub mod transformers;
use std::sync::LazyLock;
use api_models::webhooks::IncomingWebhookEvent;
use base64::Engine;
use common_enums::enums;
use common_utils::{
consts::BASE64_ENGINE,
errors::CustomResult,
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
types::{AmountConvertor, MinorUnit, MinorUnitForConnector},
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
payment_method_data::{PayLaterData, PaymentMethodData},
router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::{
access_token_auth::AccessTokenAuth,
payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},
refunds::{Execute, RSync},
},
router_request_types::{
AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData,
RefundsData, SetupMandateRequestData,
},
router_response_types::{
ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData,
SupportedPaymentMethods, SupportedPaymentMethodsExt,
},
types::{
PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
PaymentsSessionRouterData, PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData,
},
};
use hyperswitch_interfaces::{
api::{
self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications,
ConnectorValidation,
},
configs::Connectors,
consts::NO_ERROR_MESSAGE,
errors,
events::connector_api_logs::ConnectorEvent,
types::{self, Response},
webhooks::{IncomingWebhook, IncomingWebhookRequestDetails},
};
use masking::{Mask, PeekInterface};
use router_env::logger;
use transformers as klarna;
use crate::{
constants::headers,
types::ResponseRouterData,
utils::{
convert_amount, get_http_header, get_unimplemented_payment_method_error_message,
missing_field_err, RefundsRequestData,
},
};
#[derive(Clone)]
pub struct Klarna {
amount_converter: &'static (dyn AmountConvertor<Output = MinorUnit> + Sync),
}
impl Klarna {
pub fn new() -> &'static Self {
&Self {
amount_converter: &MinorUnitForConnector,
}
}
}
impl ConnectorCommon for Klarna {
fn id(&self) -> &'static str {
"klarna"
}
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.klarna.base_url.as_ref()
}
fn get_auth_header(
&self,
auth_type: &ConnectorAuthType,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
let auth = klarna::KlarnaAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
let encoded_api_key =
BASE64_ENGINE.encode(format!("{}:{}", auth.username.peek(), auth.password.peek()));
Ok(vec![(
headers::AUTHORIZATION.to_string(),
format!("Basic {encoded_api_key}").into_masked(),
)])
}
fn build_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: klarna::KlarnaErrorResponse = res
.response
.parse_struct("KlarnaErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_error_response_body(&response));
router_env::logger::info!(connector_response=?response);
// KlarnaErrorResponse will either have error_messages or error_message field Ref: https://docs.klarna.com/api/errors/
let reason = response
.error_messages
.map(|messages| messages.join(" & "))
.or(response.error_message.clone());
Ok(ErrorResponse {
status_code: res.status_code,
code: response.error_code,
message: response
.error_message
.unwrap_or(NO_ERROR_MESSAGE.to_string()),
reason,
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 Klarna {}
impl api::Payment for Klarna {}
impl api::PaymentAuthorize for Klarna {}
impl api::PaymentSync for Klarna {}
impl api::PaymentVoid for Klarna {}
impl api::PaymentCapture for Klarna {}
impl api::PaymentSession for Klarna {}
impl api::ConnectorAccessToken for Klarna {}
impl api::PaymentToken for Klarna {}
impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
for Klarna
{
// Not Implemented (R)
}
impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Klarna {
// Not Implemented (R)
}
impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Klarna
where
Self: ConnectorIntegration<Flow, Request, Response>,
{
fn build_headers(
&self,
req: &RouterData<Flow, Request, Response>,
_connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
let mut header = vec![(
headers::CONTENT_TYPE.to_string(),
types::PaymentsAuthorizeType::get_content_type(self)
.to_string()
.into(),
)];
let mut api_key = self.get_auth_header(&req.connector_auth_type)?;
header.append(&mut api_key);
Ok(header)
}
}
fn build_region_specific_endpoint(
base_url: &str,
connector_metadata: &Option<common_utils::pii::SecretSerdeValue>,
) -> CustomResult<String, errors::ConnectorError> {
let klarna_metadata_object =
transformers::KlarnaConnectorMetadataObject::try_from(connector_metadata)?;
let klarna_region = klarna_metadata_object
.klarna_region
.ok_or(errors::ConnectorError::InvalidConnectorConfig {
config: "merchant_connector_account.metadata.klarna_region",
})
.map(String::from)?;
Ok(base_url.replace("{{klarna_region}}", &klarna_region))
}
impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Klarna {
fn get_headers(
&self,
req: &PaymentsSessionRouterData,
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: &PaymentsSessionRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
let endpoint =
build_region_specific_endpoint(self.base_url(connectors), &req.connector_meta_data)?;
Ok(format!("{endpoint}payments/v1/sessions"))
}
fn get_request_body(
&self,
req: &PaymentsSessionRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let amount = convert_amount(
self.amount_converter,
req.request.minor_amount,
req.request.currency,
)?;
let connector_router_data = klarna::KlarnaRouterData::from((amount, req));
let connector_req = klarna::KlarnaSessionRequest::try_from(&connector_router_data)?;
// encode only for for urlencoded things.
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &PaymentsSessionRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&types::PaymentsSessionType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsSessionType::get_headers(
self, req, connectors,
)?)
.set_body(types::PaymentsSessionType::get_request_body(
self, req, connectors,
)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsSessionRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsSessionRouterData, errors::ConnectorError> {
let response: klarna::KlarnaSessionResponse = res
.response
.parse_struct("KlarnaSessionResponse")
.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,
})
.change_context(errors::ConnectorError::ResponseHandlingFailed)
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl api::MandateSetup for Klarna {}
impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData> for Klarna {
// Not Implemented(R)
fn build_request(
&self,
_req: &RouterData<SetupMandate, SetupMandateRequestData, PaymentsResponseData>,
_connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Err(
errors::ConnectorError::NotImplemented("Setup Mandate flow for Klarna".to_string())
.into(),
)
}
}
impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Klarna {
fn get_headers(
&self,
req: &PaymentsCaptureRouterData,
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: &PaymentsCaptureRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
let order_id = req.request.connector_transaction_id.clone();
let endpoint =
build_region_specific_endpoint(self.base_url(connectors), &req.connector_meta_data)?;
Ok(format!(
"{endpoint}ordermanagement/v1/orders/{order_id}/captures"
))
}
fn get_request_body(
&self,
req: &PaymentsCaptureRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let amount = convert_amount(
self.amount_converter,
req.request.minor_amount_to_capture,
req.request.currency,
)?;
let connector_router_data = klarna::KlarnaRouterData::from((amount, req));
let connector_req = klarna::KlarnaCaptureRequest::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> {
let request = RequestBuilder::new()
.method(Method::Post)
.url(&types::PaymentsCaptureType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsCaptureType::get_headers(
self, req, connectors,
)?)
.set_body(types::PaymentsCaptureType::get_request_body(
self, req, connectors,
)?)
.build();
Ok(Some(request))
}
fn handle_response(
&self,
data: &PaymentsCaptureRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {
match res.headers {
Some(headers) => {
let capture_id = get_http_header("Capture-Id", &headers)
.attach_printable("Missing capture id in headers")
.change_context(errors::ConnectorError::ResponseHandlingFailed)?;
let response = klarna::KlarnaCaptureResponse {
capture_id: Some(capture_id.to_owned()),
};
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,
})
.change_context(errors::ConnectorError::ResponseHandlingFailed)
}
None => Err(errors::ConnectorError::ResponseDeserializationFailed)
.attach_printable("Expected headers, but received no headers in response")?,
}
}
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 Klarna {
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> {
let order_id = req
.request
.connector_transaction_id
.get_connector_transaction_id()
.change_context(errors::ConnectorError::RequestEncodingFailed)?;
let endpoint =
build_region_specific_endpoint(self.base_url(connectors), &req.connector_meta_data)?;
let payment_experience = req.request.payment_experience;
match payment_experience {
Some(common_enums::PaymentExperience::InvokeSdkClient) => {
Ok(format!("{endpoint}ordermanagement/v1/orders/{order_id}"))
}
Some(common_enums::PaymentExperience::RedirectToUrl) => {
Ok(format!("{endpoint}checkout/v3/orders/{order_id}"))
}
None => Err(error_stack::report!(errors::ConnectorError::NotSupported {
message: "payment_experience not supported".to_string(),
connector: "klarna",
})),
_ => Err(error_stack::report!(errors::ConnectorError::NotSupported {
message: "payment_experience not supported".to_string(),
connector: "klarna",
})),
}
}
fn build_request(
&self,
req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Get)
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
let response: klarna::KlarnaPsyncResponse = res
.response
.parse_struct("klarna KlarnaPsyncResponse")
.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 Klarna {
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> {
let payment_method_data = &req.request.payment_method_data;
let payment_experience = req
.request
.payment_experience
.as_ref()
.ok_or_else(missing_field_err("payment_experience"))?;
let payment_method_type = req
.request
.payment_method_type
.as_ref()
.ok_or_else(missing_field_err("payment_method_type"))?;
let endpoint =
build_region_specific_endpoint(self.base_url(connectors), &req.connector_meta_data)?;
match payment_method_data {
PaymentMethodData::PayLater(PayLaterData::KlarnaSdk { token }) => {
match (payment_experience, payment_method_type) {
(
common_enums::PaymentExperience::InvokeSdkClient,
common_enums::PaymentMethodType::Klarna,
) => Ok(format!(
"{endpoint}payments/v1/authorizations/{token}/order",
)),
#[cfg(feature = "v1")]
(
common_enums::PaymentExperience::DisplayQrCode
| common_enums::PaymentExperience::DisplayWaitScreen
| common_enums::PaymentExperience::InvokePaymentApp
| common_enums::PaymentExperience::InvokeSdkClient
| common_enums::PaymentExperience::LinkWallet
| common_enums::PaymentExperience::OneClick
| common_enums::PaymentExperience::RedirectToUrl
| common_enums::PaymentExperience::CollectOtp,
common_enums::PaymentMethodType::Ach
| common_enums::PaymentMethodType::Bluecode
| common_enums::PaymentMethodType::Affirm
| common_enums::PaymentMethodType::AfterpayClearpay
| common_enums::PaymentMethodType::Alfamart
| common_enums::PaymentMethodType::AliPay
| common_enums::PaymentMethodType::AliPayHk
| common_enums::PaymentMethodType::Alma
| common_enums::PaymentMethodType::AmazonPay
| common_enums::PaymentMethodType::BhnCardNetwork
| common_enums::PaymentMethodType::Paysera
| common_enums::PaymentMethodType::Skrill
| common_enums::PaymentMethodType::ApplePay
| common_enums::PaymentMethodType::Atome
| common_enums::PaymentMethodType::Bacs
| common_enums::PaymentMethodType::BancontactCard
| common_enums::PaymentMethodType::Becs
| common_enums::PaymentMethodType::Benefit
| common_enums::PaymentMethodType::Bizum
| common_enums::PaymentMethodType::Blik
| common_enums::PaymentMethodType::Boleto
| common_enums::PaymentMethodType::BcaBankTransfer
| common_enums::PaymentMethodType::BniVa
| common_enums::PaymentMethodType::BriVa
| common_enums::PaymentMethodType::CardRedirect
| common_enums::PaymentMethodType::CimbVa
| common_enums::PaymentMethodType::ClassicReward
| common_enums::PaymentMethodType::Credit
| common_enums::PaymentMethodType::CryptoCurrency
| common_enums::PaymentMethodType::Cashapp
| common_enums::PaymentMethodType::Dana
| common_enums::PaymentMethodType::DanamonVa
| common_enums::PaymentMethodType::Debit
| common_enums::PaymentMethodType::DirectCarrierBilling
| common_enums::PaymentMethodType::Efecty
| common_enums::PaymentMethodType::Eft
| common_enums::PaymentMethodType::Eps
| common_enums::PaymentMethodType::Evoucher
| common_enums::PaymentMethodType::Giropay
| common_enums::PaymentMethodType::Givex
| common_enums::PaymentMethodType::GooglePay
| common_enums::PaymentMethodType::GoPay
| common_enums::PaymentMethodType::Gcash
| common_enums::PaymentMethodType::Ideal
| common_enums::PaymentMethodType::Interac
| common_enums::PaymentMethodType::Indomaret
| common_enums::PaymentMethodType::Klarna
| common_enums::PaymentMethodType::KakaoPay
| common_enums::PaymentMethodType::MandiriVa
| common_enums::PaymentMethodType::Knet
| common_enums::PaymentMethodType::MbWay
| common_enums::PaymentMethodType::MobilePay
| common_enums::PaymentMethodType::Momo
| common_enums::PaymentMethodType::MomoAtm
| common_enums::PaymentMethodType::Multibanco
| common_enums::PaymentMethodType::LocalBankRedirect
| common_enums::PaymentMethodType::OnlineBankingThailand
| common_enums::PaymentMethodType::OnlineBankingCzechRepublic
| common_enums::PaymentMethodType::OnlineBankingFinland
| common_enums::PaymentMethodType::OnlineBankingFpx
| common_enums::PaymentMethodType::OnlineBankingPoland
| common_enums::PaymentMethodType::OnlineBankingSlovakia
| common_enums::PaymentMethodType::Oxxo
| common_enums::PaymentMethodType::PagoEfectivo
| common_enums::PaymentMethodType::PermataBankTransfer
| common_enums::PaymentMethodType::OpenBankingUk
| common_enums::PaymentMethodType::PayBright
| common_enums::PaymentMethodType::Paypal
| common_enums::PaymentMethodType::Paze
| common_enums::PaymentMethodType::Pix
| common_enums::PaymentMethodType::PaySafeCard
| common_enums::PaymentMethodType::Przelewy24
| common_enums::PaymentMethodType::Pse
| common_enums::PaymentMethodType::RedCompra
| common_enums::PaymentMethodType::RedPagos
| common_enums::PaymentMethodType::SamsungPay
| common_enums::PaymentMethodType::Sepa
| common_enums::PaymentMethodType::SepaBankTransfer
| common_enums::PaymentMethodType::Sofort
| common_enums::PaymentMethodType::Swish
| common_enums::PaymentMethodType::TouchNGo
| common_enums::PaymentMethodType::Trustly
| common_enums::PaymentMethodType::Twint
| common_enums::PaymentMethodType::UpiCollect
| common_enums::PaymentMethodType::UpiIntent
| common_enums::PaymentMethodType::Venmo
| common_enums::PaymentMethodType::Vipps
| common_enums::PaymentMethodType::Walley
| common_enums::PaymentMethodType::WeChatPay
| common_enums::PaymentMethodType::SevenEleven
| common_enums::PaymentMethodType::Lawson
| common_enums::PaymentMethodType::LocalBankTransfer
| common_enums::PaymentMethodType::InstantBankTransfer
| common_enums::PaymentMethodType::InstantBankTransferFinland
| common_enums::PaymentMethodType::InstantBankTransferPoland
| common_enums::PaymentMethodType::MiniStop
| common_enums::PaymentMethodType::FamilyMart
| common_enums::PaymentMethodType::Seicomart
| common_enums::PaymentMethodType::PayEasy
| common_enums::PaymentMethodType::Mifinity
| common_enums::PaymentMethodType::Fps
| common_enums::PaymentMethodType::DuitNow
| common_enums::PaymentMethodType::PromptPay
| common_enums::PaymentMethodType::VietQr
| common_enums::PaymentMethodType::Flexiti
| common_enums::PaymentMethodType::OpenBankingPIS
| common_enums::PaymentMethodType::RevolutPay
| common_enums::PaymentMethodType::IndonesianBankTransfer
| common_enums::PaymentMethodType::Breadpay,
) => Err(error_stack::report!(errors::ConnectorError::NotSupported {
message: payment_method_type.to_string(),
connector: "klarna",
})),
#[cfg(feature = "v2")]
(
common_enums::PaymentExperience::DisplayQrCode
| common_enums::PaymentExperience::DisplayWaitScreen
| common_enums::PaymentExperience::InvokePaymentApp
| common_enums::PaymentExperience::InvokeSdkClient
| common_enums::PaymentExperience::LinkWallet
| common_enums::PaymentExperience::OneClick
| common_enums::PaymentExperience::RedirectToUrl
| common_enums::PaymentExperience::CollectOtp,
common_enums::PaymentMethodType::Ach
| common_enums::PaymentMethodType::Bluecode
| common_enums::PaymentMethodType::Affirm
| common_enums::PaymentMethodType::AfterpayClearpay
| common_enums::PaymentMethodType::Alfamart
| common_enums::PaymentMethodType::AliPay
| common_enums::PaymentMethodType::AliPayHk
| common_enums::PaymentMethodType::Alma
| common_enums::PaymentMethodType::AmazonPay
| common_enums::PaymentMethodType::Paysera
| common_enums::PaymentMethodType::Skrill
| common_enums::PaymentMethodType::ApplePay
| common_enums::PaymentMethodType::Atome
| common_enums::PaymentMethodType::Bacs
| common_enums::PaymentMethodType::BancontactCard
| common_enums::PaymentMethodType::Becs
| common_enums::PaymentMethodType::Benefit
| common_enums::PaymentMethodType::Bizum
| common_enums::PaymentMethodType::Blik
| common_enums::PaymentMethodType::Boleto
| common_enums::PaymentMethodType::BcaBankTransfer
| common_enums::PaymentMethodType::BhnCardNetwork
| common_enums::PaymentMethodType::BniVa
| common_enums::PaymentMethodType::BriVa
| common_enums::PaymentMethodType::CardRedirect
| common_enums::PaymentMethodType::CimbVa
| common_enums::PaymentMethodType::ClassicReward
| common_enums::PaymentMethodType::Credit
| common_enums::PaymentMethodType::Card
| common_enums::PaymentMethodType::CryptoCurrency
| common_enums::PaymentMethodType::Cashapp
| common_enums::PaymentMethodType::Dana
| common_enums::PaymentMethodType::DanamonVa
| common_enums::PaymentMethodType::Debit
| common_enums::PaymentMethodType::DirectCarrierBilling
| common_enums::PaymentMethodType::Efecty
| common_enums::PaymentMethodType::Eft
| common_enums::PaymentMethodType::Eps
| common_enums::PaymentMethodType::Evoucher
| common_enums::PaymentMethodType::Giropay
| common_enums::PaymentMethodType::Givex
| common_enums::PaymentMethodType::GooglePay
| common_enums::PaymentMethodType::GoPay
| common_enums::PaymentMethodType::Gcash
| common_enums::PaymentMethodType::Ideal
| common_enums::PaymentMethodType::Interac
| common_enums::PaymentMethodType::Indomaret
| common_enums::PaymentMethodType::Klarna
| common_enums::PaymentMethodType::KakaoPay
| common_enums::PaymentMethodType::MandiriVa
| common_enums::PaymentMethodType::Knet
| common_enums::PaymentMethodType::MbWay
| common_enums::PaymentMethodType::MobilePay
| common_enums::PaymentMethodType::Momo
| common_enums::PaymentMethodType::MomoAtm
| common_enums::PaymentMethodType::Multibanco
| common_enums::PaymentMethodType::LocalBankRedirect
| common_enums::PaymentMethodType::OnlineBankingThailand
| common_enums::PaymentMethodType::OnlineBankingCzechRepublic
| common_enums::PaymentMethodType::OnlineBankingFinland
| common_enums::PaymentMethodType::OnlineBankingFpx
| common_enums::PaymentMethodType::OnlineBankingPoland
| common_enums::PaymentMethodType::OnlineBankingSlovakia
| common_enums::PaymentMethodType::Oxxo
| common_enums::PaymentMethodType::PagoEfectivo
| common_enums::PaymentMethodType::PermataBankTransfer
| common_enums::PaymentMethodType::OpenBankingUk
| common_enums::PaymentMethodType::PayBright
| common_enums::PaymentMethodType::Paypal
| common_enums::PaymentMethodType::Paze
| common_enums::PaymentMethodType::Pix
| common_enums::PaymentMethodType::PaySafeCard
| common_enums::PaymentMethodType::Przelewy24
| common_enums::PaymentMethodType::Pse
| common_enums::PaymentMethodType::RedCompra
| common_enums::PaymentMethodType::RedPagos
| common_enums::PaymentMethodType::SamsungPay
| common_enums::PaymentMethodType::Sepa
| common_enums::PaymentMethodType::SepaBankTransfer
| common_enums::PaymentMethodType::Sofort
| common_enums::PaymentMethodType::Swish
| common_enums::PaymentMethodType::TouchNGo
| common_enums::PaymentMethodType::Trustly
| common_enums::PaymentMethodType::Twint
| common_enums::PaymentMethodType::UpiCollect
| common_enums::PaymentMethodType::UpiIntent
| common_enums::PaymentMethodType::Venmo
| common_enums::PaymentMethodType::Vipps
| common_enums::PaymentMethodType::Walley
| common_enums::PaymentMethodType::WeChatPay
| common_enums::PaymentMethodType::SevenEleven
| common_enums::PaymentMethodType::Lawson
| common_enums::PaymentMethodType::LocalBankTransfer
| common_enums::PaymentMethodType::InstantBankTransfer
| common_enums::PaymentMethodType::InstantBankTransferFinland
| common_enums::PaymentMethodType::InstantBankTransferPoland
| common_enums::PaymentMethodType::MiniStop
| common_enums::PaymentMethodType::FamilyMart
| common_enums::PaymentMethodType::Seicomart
| common_enums::PaymentMethodType::PayEasy
| common_enums::PaymentMethodType::Mifinity
| common_enums::PaymentMethodType::Fps
| common_enums::PaymentMethodType::DuitNow
| common_enums::PaymentMethodType::PromptPay
| common_enums::PaymentMethodType::VietQr
| common_enums::PaymentMethodType::Flexiti
| common_enums::PaymentMethodType::OpenBankingPIS
| common_enums::PaymentMethodType::Skrill
| common_enums::PaymentMethodType::IndonesianBankTransfer
| common_enums::PaymentMethodType::RevolutPay
| common_enums::PaymentMethodType::Breadpay,
) => Err(error_stack::report!(errors::ConnectorError::NotSupported {
message: payment_method_type.to_string(),
connector: "klarna",
})),
}
}
PaymentMethodData::PayLater(PayLaterData::KlarnaRedirect {}) => {
match (payment_experience, payment_method_type) {
(
common_enums::PaymentExperience::RedirectToUrl,
common_enums::PaymentMethodType::Klarna,
) => Ok(format!("{endpoint}checkout/v3/orders")),
#[cfg(feature = "v1")]
(
common_enums::PaymentExperience::DisplayQrCode
| common_enums::PaymentExperience::DisplayWaitScreen
| common_enums::PaymentExperience::InvokePaymentApp
| common_enums::PaymentExperience::InvokeSdkClient
| common_enums::PaymentExperience::LinkWallet
| common_enums::PaymentExperience::OneClick
| common_enums::PaymentExperience::RedirectToUrl
| common_enums::PaymentExperience::CollectOtp,
common_enums::PaymentMethodType::Ach
| common_enums::PaymentMethodType::Bluecode
| common_enums::PaymentMethodType::Affirm
| common_enums::PaymentMethodType::AfterpayClearpay
| common_enums::PaymentMethodType::Alfamart
| common_enums::PaymentMethodType::AliPay
| common_enums::PaymentMethodType::AliPayHk
| common_enums::PaymentMethodType::Alma
| common_enums::PaymentMethodType::AmazonPay
| common_enums::PaymentMethodType::Paysera
| common_enums::PaymentMethodType::Skrill
| common_enums::PaymentMethodType::ApplePay
| common_enums::PaymentMethodType::Atome
| common_enums::PaymentMethodType::Bacs
| common_enums::PaymentMethodType::BancontactCard
| common_enums::PaymentMethodType::Becs
| common_enums::PaymentMethodType::Benefit
| common_enums::PaymentMethodType::Bizum
| common_enums::PaymentMethodType::Blik
| common_enums::PaymentMethodType::Boleto
| common_enums::PaymentMethodType::BhnCardNetwork
| common_enums::PaymentMethodType::BcaBankTransfer
| common_enums::PaymentMethodType::BniVa
| common_enums::PaymentMethodType::BriVa
| common_enums::PaymentMethodType::CardRedirect
| common_enums::PaymentMethodType::CimbVa
| common_enums::PaymentMethodType::ClassicReward
| common_enums::PaymentMethodType::Credit
| common_enums::PaymentMethodType::CryptoCurrency
| common_enums::PaymentMethodType::Cashapp
| common_enums::PaymentMethodType::Dana
| common_enums::PaymentMethodType::DanamonVa
| common_enums::PaymentMethodType::Debit
| common_enums::PaymentMethodType::DirectCarrierBilling
| common_enums::PaymentMethodType::Efecty
| common_enums::PaymentMethodType::Eft
| common_enums::PaymentMethodType::Eps
| common_enums::PaymentMethodType::Evoucher
| common_enums::PaymentMethodType::Giropay
| common_enums::PaymentMethodType::Givex
| common_enums::PaymentMethodType::GooglePay
| common_enums::PaymentMethodType::GoPay
| common_enums::PaymentMethodType::Gcash
| common_enums::PaymentMethodType::Ideal
| common_enums::PaymentMethodType::Interac
| common_enums::PaymentMethodType::Indomaret
|
crates/hyperswitch_connectors/src/connectors/klarna.rs#chunk0
|
hyperswitch_connectors
|
chunk
| null | null | null | 8,190
| null | null | null | null | null | null | null |
// Implementation: impl super::refunds::distribution::RefundDistributionAnalytics for for ClickhouseClient
// File: crates/analytics/src/clickhouse.rs
// Module: analytics
// Methods: 0 total (0 public)
impl super::refunds::distribution::RefundDistributionAnalytics for for ClickhouseClient
|
crates/analytics/src/clickhouse.rs
|
analytics
|
impl_block
| null | null | null | 65
| null |
ClickhouseClient
|
super::refunds::distribution::RefundDistributionAnalytics for
| 0
| 0
| null | null |
// Struct: SantanderAuthType
// File: crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct SantanderAuthType
|
crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
SantanderAuthType
| 0
|
[] | 50
| null | null | null | null | null | null | null |
// Struct: ConnectorTomlConfig
// File: crates/connector_configs/src/connector.rs
// Module: connector_configs
// Implementations: 0
pub struct ConnectorTomlConfig
|
crates/connector_configs/src/connector.rs
|
connector_configs
|
struct_definition
|
ConnectorTomlConfig
| 0
|
[] | 39
| null | null | null | null | null | null | null |
// Function: get_session_token_for_click_to_pay
// File: crates/router/src/core/payments.rs
// Module: router
pub fn get_session_token_for_click_to_pay(
state: &SessionState,
merchant_id: &id_type::MerchantId,
merchant_context: &domain::MerchantContext,
authentication_product_ids: common_types::payments::AuthenticationConnectorAccountMap,
payment_intent: &payments::PaymentIntent,
profile_id: &id_type::ProfileId,
) -> RouterResult<api_models::payments::SessionToken>
|
crates/router/src/core/payments.rs
|
router
|
function_signature
| null | null | null | 114
|
get_session_token_for_click_to_pay
| null | null | null | null | null | null |
// Module Structure
// File: crates/router/src/routes/files.rs
// Module: router
// Public submodules:
pub mod transformers;
|
crates/router/src/routes/files.rs
|
router
|
module_structure
| null | null | null | 28
| null | null | null | null | null | 1
| 0
|
// Struct: SilverflowRouterData
// File: crates/hyperswitch_connectors/src/connectors/silverflow/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct SilverflowRouterData<T>
|
crates/hyperswitch_connectors/src/connectors/silverflow/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
SilverflowRouterData
| 0
|
[] | 52
| null | null | null | null | null | null | null |
// Implementation: impl api::Refund for for Paytm
// File: crates/hyperswitch_connectors/src/connectors/paytm.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::Refund for for Paytm
|
crates/hyperswitch_connectors/src/connectors/paytm.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 57
| null |
Paytm
|
api::Refund for
| 0
| 0
| null | null |
// Struct: NoonRefundSyncResponseResult
// File: crates/hyperswitch_connectors/src/connectors/noon/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct NoonRefundSyncResponseResult
|
crates/hyperswitch_connectors/src/connectors/noon/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
NoonRefundSyncResponseResult
| 0
|
[] | 53
| null | null | null | null | null | null | null |
// Implementation: impl api::MandateSetup for for Globepay
// File: crates/hyperswitch_connectors/src/connectors/globepay.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::MandateSetup for for Globepay
|
crates/hyperswitch_connectors/src/connectors/globepay.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 65
| null |
Globepay
|
api::MandateSetup for
| 0
| 0
| null | null |
// Implementation: impl PartialEq for for SdkEventMetricsBucketIdentifier
// File: crates/api_models/src/analytics/sdk_events.rs
// Module: api_models
// Methods: 1 total (0 public)
impl PartialEq for for SdkEventMetricsBucketIdentifier
|
crates/api_models/src/analytics/sdk_events.rs
|
api_models
|
impl_block
| null | null | null | 53
| null |
SdkEventMetricsBucketIdentifier
|
PartialEq for
| 1
| 0
| null | null |
// Struct: AffirmErrorResponse
// File: crates/hyperswitch_connectors/src/connectors/affirm/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct AffirmErrorResponse
|
crates/hyperswitch_connectors/src/connectors/affirm/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
AffirmErrorResponse
| 0
|
[] | 48
| null | null | null | null | null | null | null |
// Struct: CaptureIntegrityObject
// File: crates/hyperswitch_domain_models/src/router_request_types.rs
// Module: hyperswitch_domain_models
// Implementations: 0
pub struct CaptureIntegrityObject
|
crates/hyperswitch_domain_models/src/router_request_types.rs
|
hyperswitch_domain_models
|
struct_definition
|
CaptureIntegrityObject
| 0
|
[] | 45
| null | null | null | null | null | null | null |
// File: crates/storage_impl/src/payments/payment_attempt.rs
// Module: storage_impl
use common_utils::errors::CustomResult;
#[cfg(feature = "v2")]
use common_utils::types::keymanager::KeyManagerState;
#[cfg(feature = "v1")]
use common_utils::{
fallback_reverse_lookup_not_found,
types::{ConnectorTransactionId, ConnectorTransactionIdTrait, CreatedBy},
};
#[cfg(feature = "v1")]
use diesel_models::payment_attempt::PaymentAttemptNew as DieselPaymentAttemptNew;
use diesel_models::{
enums::{
MandateAmountData as DieselMandateAmountData, MandateDataType as DieselMandateType,
MandateDetails as DieselMandateDetails, MerchantStorageScheme,
},
kv,
payment_attempt::PaymentAttempt as DieselPaymentAttempt,
reverse_lookup::{ReverseLookup, ReverseLookupNew},
};
use error_stack::ResultExt;
#[cfg(feature = "v1")]
use hyperswitch_domain_models::payments::payment_attempt::PaymentAttemptNew;
#[cfg(feature = "v2")]
use hyperswitch_domain_models::{
behaviour::{Conversion, ReverseConversion},
merchant_key_store::MerchantKeyStore,
};
use hyperswitch_domain_models::{
mandates::{MandateAmountData, MandateDataType, MandateDetails},
payments::payment_attempt::{PaymentAttempt, PaymentAttemptInterface, PaymentAttemptUpdate},
};
#[cfg(all(feature = "v1", feature = "olap"))]
use hyperswitch_domain_models::{
payments::payment_attempt::PaymentListFilters, payments::PaymentIntent,
};
#[cfg(feature = "v2")]
use label::*;
use redis_interface::HsetnxReply;
use router_env::{instrument, tracing};
#[cfg(feature = "v2")]
use crate::kv_router_store::{FilterResourceParams, FindResourceBy, UpdateResourceParams};
use crate::{
diesel_error_to_data_error, errors,
errors::RedisErrorExt,
kv_router_store::KVRouterStore,
lookup::ReverseLookupInterface,
redis::kv_store::{decide_storage_scheme, kv_wrapper, KvOperation, Op, PartitionKey},
utils::{pg_connection_read, pg_connection_write, try_redis_get_else_try_database_get},
DataModelExt, DatabaseStore, RouterStore,
};
#[async_trait::async_trait]
impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
type Error = errors::StorageError;
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn insert_payment_attempt(
&self,
payment_attempt: PaymentAttemptNew,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_write(self).await?;
payment_attempt
.to_storage_model()
.insert(&conn)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
.map(PaymentAttempt::from_storage_model)
}
#[cfg(feature = "v2")]
#[instrument(skip_all)]
async fn insert_payment_attempt(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
payment_attempt: PaymentAttempt,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_write(self).await?;
payment_attempt
.construct_new()
.await
.change_context(errors::StorageError::EncryptionError)?
.insert(&conn)
.await
.map_err(|error| {
let new_error = diesel_error_to_data_error(*error.current_context());
error.change_context(new_error)
})?
.convert(
key_manager_state,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
}
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn update_payment_attempt_with_attempt_id(
&self,
this: PaymentAttempt,
payment_attempt: PaymentAttemptUpdate,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_write(self).await?;
this.to_storage_model()
.update_with_attempt_id(&conn, payment_attempt.to_storage_model())
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
.map(PaymentAttempt::from_storage_model)
}
#[cfg(feature = "v2")]
#[instrument(skip_all)]
async fn update_payment_attempt(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
this: PaymentAttempt,
payment_attempt: PaymentAttemptUpdate,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_write(self).await?;
Conversion::convert(this)
.await
.change_context(errors::StorageError::EncryptionError)?
.update_with_attempt_id(
&conn,
diesel_models::PaymentAttemptUpdateInternal::from(payment_attempt),
)
.await
.map_err(|error| {
let new_error = diesel_error_to_data_error(*error.current_context());
error.change_context(new_error)
})?
.convert(
key_manager_state,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
}
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(
&self,
connector_transaction_id: &ConnectorTransactionId,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_read(self).await?;
DieselPaymentAttempt::find_by_connector_transaction_id_payment_id_merchant_id(
&conn,
connector_transaction_id,
payment_id,
merchant_id,
)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
.map(PaymentAttempt::from_storage_model)
}
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(
&self,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_read(self).await?;
DieselPaymentAttempt::find_last_successful_attempt_by_payment_id_merchant_id(
&conn,
payment_id,
merchant_id,
)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
.map(PaymentAttempt::from_storage_model)
}
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(
&self,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_read(self).await?;
DieselPaymentAttempt::find_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(
&conn,
payment_id,
merchant_id,
)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
.map(PaymentAttempt::from_storage_model)
}
#[cfg(feature = "v2")]
#[instrument(skip_all)]
async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
payment_id: &common_utils::id_type::GlobalPaymentId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_read(self).await?;
DieselPaymentAttempt::find_last_successful_or_partially_captured_attempt_by_payment_id(
&conn, payment_id,
)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})?
.convert(
key_manager_state,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
}
#[instrument(skip_all)]
#[cfg(feature = "v1")]
async fn find_payment_attempt_by_merchant_id_connector_txn_id(
&self,
merchant_id: &common_utils::id_type::MerchantId,
connector_txn_id: &str,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_read(self).await?;
DieselPaymentAttempt::find_by_merchant_id_connector_txn_id(
&conn,
merchant_id,
connector_txn_id,
)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
.map(PaymentAttempt::from_storage_model)
}
#[instrument(skip_all)]
#[cfg(feature = "v2")]
async fn find_payment_attempt_by_profile_id_connector_transaction_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_id: &common_utils::id_type::ProfileId,
connector_txn_id: &str,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_read(self).await?;
DieselPaymentAttempt::find_by_profile_id_connector_transaction_id(
&conn,
profile_id,
connector_txn_id,
)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})?
.convert(
key_manager_state,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
}
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(
&self,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
attempt_id: &str,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_read(self).await?;
DieselPaymentAttempt::find_by_payment_id_merchant_id_attempt_id(
&conn,
payment_id,
merchant_id,
attempt_id,
)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
.map(PaymentAttempt::from_storage_model)
}
#[cfg(all(feature = "v1", feature = "olap"))]
#[instrument(skip_all)]
async fn get_filters_for_payments(
&self,
pi: &[PaymentIntent],
merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentListFilters, errors::StorageError> {
use hyperswitch_domain_models::behaviour::Conversion;
let conn = pg_connection_read(self).await?;
let intents = futures::future::try_join_all(pi.iter().cloned().map(|pi| async {
Conversion::convert(pi)
.await
.change_context(errors::StorageError::EncryptionError)
}))
.await?;
DieselPaymentAttempt::get_filters_for_payments(&conn, intents.as_slice(), merchant_id)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
.map(
|(
connector,
currency,
status,
payment_method,
payment_method_type,
authentication_type,
)| PaymentListFilters {
connector,
currency,
status,
payment_method,
payment_method_type,
authentication_type,
},
)
}
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn find_payment_attempt_by_preprocessing_id_merchant_id(
&self,
preprocessing_id: &str,
merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_read(self).await?;
DieselPaymentAttempt::find_by_merchant_id_preprocessing_id(
&conn,
merchant_id,
preprocessing_id,
)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
.map(PaymentAttempt::from_storage_model)
}
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn find_attempts_by_merchant_id_payment_id(
&self,
merchant_id: &common_utils::id_type::MerchantId,
payment_id: &common_utils::id_type::PaymentId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<PaymentAttempt>, errors::StorageError> {
let conn = pg_connection_read(self).await?;
DieselPaymentAttempt::find_by_merchant_id_payment_id(&conn, merchant_id, payment_id)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
.map(|a| {
a.into_iter()
.map(PaymentAttempt::from_storage_model)
.collect()
})
}
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn find_payment_attempt_by_attempt_id_merchant_id(
&self,
attempt_id: &str,
merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_read(self).await?;
DieselPaymentAttempt::find_by_merchant_id_attempt_id(&conn, merchant_id, attempt_id)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
.map(PaymentAttempt::from_storage_model)
}
#[cfg(feature = "v2")]
#[instrument(skip_all)]
async fn find_payment_attempt_by_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
attempt_id: &common_utils::id_type::GlobalAttemptId,
_storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_read(self).await?;
DieselPaymentAttempt::find_by_id(&conn, attempt_id)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})?
.convert(
key_manager_state,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
}
#[cfg(feature = "v2")]
#[instrument(skip_all)]
async fn find_payment_attempts_by_payment_intent_id(
&self,
key_manager_state: &KeyManagerState,
payment_id: &common_utils::id_type::GlobalPaymentId,
merchant_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<Vec<PaymentAttempt>, errors::StorageError> {
use common_utils::ext_traits::AsyncExt;
let conn = pg_connection_read(self).await?;
DieselPaymentAttempt::find_by_payment_id(&conn, payment_id)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
.async_and_then(|payment_attempts| async {
let mut domain_payment_attempts = Vec::with_capacity(payment_attempts.len());
for attempt in payment_attempts.into_iter() {
domain_payment_attempts.push(
attempt
.convert(
key_manager_state,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)?,
);
}
Ok(domain_payment_attempts)
})
.await
}
#[cfg(all(feature = "v1", feature = "olap"))]
#[instrument(skip_all)]
async fn get_total_count_of_filtered_payment_attempts(
&self,
merchant_id: &common_utils::id_type::MerchantId,
active_attempt_ids: &[String],
connector: Option<Vec<api_models::enums::Connector>>,
payment_method: Option<Vec<common_enums::PaymentMethod>>,
payment_method_type: Option<Vec<common_enums::PaymentMethodType>>,
authentication_type: Option<Vec<common_enums::AuthenticationType>>,
merchant_connector_id: Option<Vec<common_utils::id_type::MerchantConnectorAccountId>>,
card_network: Option<Vec<common_enums::CardNetwork>>,
card_discovery: Option<Vec<common_enums::CardDiscovery>>,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<i64, errors::StorageError> {
let conn = self
.db_store
.get_replica_pool()
.get()
.await
.change_context(errors::StorageError::DatabaseConnectionError)?;
let connector_strings = connector.as_ref().map(|connector| {
connector
.iter()
.map(|c| c.to_string())
.collect::<Vec<String>>()
});
DieselPaymentAttempt::get_total_count_of_attempts(
&conn,
merchant_id,
active_attempt_ids,
connector_strings,
payment_method,
payment_method_type,
authentication_type,
merchant_connector_id,
card_network,
card_discovery,
)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
}
#[cfg(all(feature = "v2", feature = "olap"))]
#[instrument(skip_all)]
async fn get_total_count_of_filtered_payment_attempts(
&self,
merchant_id: &common_utils::id_type::MerchantId,
active_attempt_ids: &[String],
connector: Option<Vec<api_models::enums::Connector>>,
payment_method_type: Option<Vec<common_enums::PaymentMethod>>,
payment_method_subtype: Option<Vec<common_enums::PaymentMethodType>>,
authentication_type: Option<Vec<common_enums::AuthenticationType>>,
merchant_connector_id: Option<Vec<common_utils::id_type::MerchantConnectorAccountId>>,
card_network: Option<Vec<common_enums::CardNetwork>>,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<i64, errors::StorageError> {
let conn = self
.db_store
.get_replica_pool()
.get()
.await
.change_context(errors::StorageError::DatabaseConnectionError)?;
DieselPaymentAttempt::get_total_count_of_attempts(
&conn,
merchant_id,
active_attempt_ids,
connector
.as_ref()
.map(|vals| vals.iter().map(|v| v.to_string()).collect()),
payment_method_type,
payment_method_subtype,
authentication_type,
merchant_connector_id,
card_network,
)
.await
.map_err(|er| {
let new_err = diesel_error_to_data_error(*er.current_context());
er.change_context(new_err)
})
}
}
#[async_trait::async_trait]
impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
type Error = errors::StorageError;
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn insert_payment_attempt(
&self,
payment_attempt: PaymentAttemptNew,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
self,
storage_scheme,
Op::Insert,
))
.await;
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
self.router_store
.insert_payment_attempt(payment_attempt, storage_scheme)
.await
}
MerchantStorageScheme::RedisKv => {
let merchant_id = payment_attempt.merchant_id.clone();
let payment_id = payment_attempt.payment_id.clone();
let key = PartitionKey::MerchantIdPaymentId {
merchant_id: &merchant_id,
payment_id: &payment_id,
};
let key_str = key.to_string();
let created_attempt = PaymentAttempt {
payment_id: payment_attempt.payment_id.clone(),
merchant_id: payment_attempt.merchant_id.clone(),
attempt_id: payment_attempt.attempt_id.clone(),
status: payment_attempt.status,
net_amount: payment_attempt.net_amount.clone(),
currency: payment_attempt.currency,
save_to_locker: payment_attempt.save_to_locker,
connector: payment_attempt.connector.clone(),
error_message: payment_attempt.error_message.clone(),
offer_amount: payment_attempt.offer_amount,
payment_method_id: payment_attempt.payment_method_id.clone(),
payment_method: payment_attempt.payment_method,
connector_transaction_id: None,
capture_method: payment_attempt.capture_method,
capture_on: payment_attempt.capture_on,
confirm: payment_attempt.confirm,
authentication_type: payment_attempt.authentication_type,
created_at: payment_attempt
.created_at
.unwrap_or_else(common_utils::date_time::now),
modified_at: payment_attempt
.created_at
.unwrap_or_else(common_utils::date_time::now),
last_synced: payment_attempt.last_synced,
amount_to_capture: payment_attempt.amount_to_capture,
cancellation_reason: payment_attempt.cancellation_reason.clone(),
mandate_id: payment_attempt.mandate_id.clone(),
browser_info: payment_attempt.browser_info.clone(),
payment_token: payment_attempt.payment_token.clone(),
error_code: payment_attempt.error_code.clone(),
connector_metadata: payment_attempt.connector_metadata.clone(),
payment_experience: payment_attempt.payment_experience,
payment_method_type: payment_attempt.payment_method_type,
payment_method_data: payment_attempt.payment_method_data.clone(),
business_sub_label: payment_attempt.business_sub_label.clone(),
straight_through_algorithm: payment_attempt.straight_through_algorithm.clone(),
mandate_details: payment_attempt.mandate_details.clone(),
preprocessing_step_id: payment_attempt.preprocessing_step_id.clone(),
error_reason: payment_attempt.error_reason.clone(),
multiple_capture_count: payment_attempt.multiple_capture_count,
connector_response_reference_id: None,
charge_id: None,
amount_capturable: payment_attempt.amount_capturable,
updated_by: storage_scheme.to_string(),
authentication_data: payment_attempt.authentication_data.clone(),
encoded_data: payment_attempt.encoded_data.clone(),
merchant_connector_id: payment_attempt.merchant_connector_id.clone(),
unified_code: payment_attempt.unified_code.clone(),
unified_message: payment_attempt.unified_message.clone(),
external_three_ds_authentication_attempted: payment_attempt
.external_three_ds_authentication_attempted,
authentication_connector: payment_attempt.authentication_connector.clone(),
authentication_id: payment_attempt.authentication_id.clone(),
mandate_data: payment_attempt.mandate_data.clone(),
payment_method_billing_address_id: payment_attempt
.payment_method_billing_address_id
.clone(),
fingerprint_id: payment_attempt.fingerprint_id.clone(),
client_source: payment_attempt.client_source.clone(),
client_version: payment_attempt.client_version.clone(),
customer_acceptance: payment_attempt.customer_acceptance.clone(),
organization_id: payment_attempt.organization_id.clone(),
profile_id: payment_attempt.profile_id.clone(),
connector_mandate_detail: payment_attempt.connector_mandate_detail.clone(),
request_extended_authorization: payment_attempt.request_extended_authorization,
extended_authorization_applied: payment_attempt.extended_authorization_applied,
capture_before: payment_attempt.capture_before,
card_discovery: payment_attempt.card_discovery,
charges: None,
issuer_error_code: None,
issuer_error_message: None,
processor_merchant_id: payment_attempt.processor_merchant_id.clone(),
created_by: payment_attempt.created_by.clone(),
setup_future_usage_applied: payment_attempt.setup_future_usage_applied,
routing_approach: payment_attempt.routing_approach.clone(),
connector_request_reference_id: payment_attempt
.connector_request_reference_id
.clone(),
debit_routing_savings: None,
network_transaction_id: payment_attempt.network_transaction_id.clone(),
is_overcapture_enabled: None,
network_details: payment_attempt.network_details.clone(),
is_stored_credential: payment_attempt.is_stored_credential,
};
let field = format!("pa_{}", created_attempt.attempt_id);
let redis_entry = kv::TypedSql {
op: kv::DBOperation::Insert {
insertable: Box::new(kv::Insertable::PaymentAttempt(Box::new(
payment_attempt.to_storage_model(),
))),
},
};
//Reverse lookup for attempt_id
let reverse_lookup = ReverseLookupNew {
lookup_id: format!(
"pa_{}_{}",
created_attempt.merchant_id.get_string_repr(),
&created_attempt.attempt_id,
),
pk_id: key_str.clone(),
sk_id: field.clone(),
source: "payment_attempt".to_string(),
updated_by: storage_scheme.to_string(),
};
self.insert_reverse_lookup(reverse_lookup, storage_scheme)
.await?;
match Box::pin(kv_wrapper::<PaymentAttempt, _, _>(
self,
KvOperation::HSetNx(
&field,
&created_attempt.clone().to_storage_model(),
redis_entry,
),
key,
))
.await
.map_err(|err| err.to_redis_failed_response(&key_str))?
.try_into_hsetnx()
{
Ok(HsetnxReply::KeyNotSet) => Err(errors::StorageError::DuplicateValue {
entity: "payment attempt",
key: Some(key_str),
}
.into()),
Ok(HsetnxReply::KeySet) => Ok(created_attempt),
Err(error) => Err(error.change_context(errors::StorageError::KVError)),
}
}
}
}
#[cfg(feature = "v2")]
#[instrument(skip_all)]
async fn insert_payment_attempt(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
payment_attempt: PaymentAttempt,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
let decided_storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
self,
storage_scheme,
Op::Insert,
))
.await;
match decided_storage_scheme {
MerchantStorageScheme::PostgresOnly => {
self.router_store
.insert_payment_attempt(
key_manager_state,
merchant_key_store,
payment_attempt,
decided_storage_scheme,
)
.await
}
MerchantStorageScheme::RedisKv => {
let key = PartitionKey::GlobalPaymentId {
id: &payment_attempt.payment_id,
};
let key_str = key.to_string();
let field = format!(
"{}_{}",
label::CLUSTER_LABEL,
payment_attempt.id.get_string_repr()
);
let diesel_payment_attempt_new = payment_attempt
.clone()
.construct_new()
.await
.change_context(errors::StorageError::EncryptionError)?;
let diesel_payment_attempt_for_redis: DieselPaymentAttempt =
Conversion::convert(payment_attempt.clone())
.await
.change_context(errors::StorageError::EncryptionError)?;
let redis_entry = kv::TypedSql {
op: kv::DBOperation::Insert {
insertable: Box::new(kv::Insertable::PaymentAttempt(Box::new(
diesel_payment_attempt_new.clone(),
))),
},
};
let reverse_lookup_attempt_id = ReverseLookupNew {
lookup_id: label::get_global_id_label(&payment_attempt.id),
pk_id: key_str.clone(),
sk_id: field.clone(),
source: "payment_attempt".to_string(),
updated_by: decided_storage_scheme.to_string(),
};
self.insert_reverse_lookup(reverse_lookup_attempt_id, decided_storage_scheme)
.await?;
if let Some(ref conn_txn_id_val) = payment_attempt.connector_payment_id {
let reverse_lookup_conn_txn_id = ReverseLookupNew {
lookup_id: label::get_profile_id_connector_transaction_label(
payment_attempt.profile_id.get_string_repr(),
conn_txn_id_val,
),
pk_id: key_str.clone(),
sk_id: field.clone(),
source: "payment_attempt".to_string(),
updated_by: decided_storage_scheme.to_string(),
};
self.insert_reverse_lookup(reverse_lookup_conn_txn_id, decided_storage_scheme)
.await?;
}
match Box::pin(kv_wrapper::<DieselPaymentAttempt, _, _>(
self,
KvOperation::HSetNx(&field, &diesel_payment_attempt_for_redis, redis_entry),
key,
))
.await
.map_err(|err| err.to_redis_failed_response(&key_str))?
.try_into_hsetnx()
{
Ok(HsetnxReply::KeyNotSet) => Err(errors::StorageError::DuplicateValue {
entity: "payment_attempt",
key: Some(payment_attempt.id.get_string_repr().to_owned()),
}
.into()),
Ok(HsetnxReply::KeySet) => Ok(payment_attempt),
Err(error) => Err(error.change_context(errors::StorageError::KVError)),
}
}
}
}
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn update_payment_attempt_with_attempt_id(
&self,
this: PaymentAttempt,
payment_attempt: PaymentAttemptUpdate,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
let key = PartitionKey::MerchantIdPaymentId {
merchant_id: &this.merchant_id,
payment_id: &this.payment_id,
};
let field = format!("pa_{}", this.attempt_id);
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
self,
storage_scheme,
Op::Update(key.clone(), &field, Some(&this.updated_by)),
))
.await;
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
self.router_store
.update_payment_attempt_with_attempt_id(this, payment_attempt, storage_scheme)
.await
}
MerchantStorageScheme::RedisKv => {
let key_str = key.to_string();
let old_connector_transaction_id = &this.get_connector_payment_id();
let old_preprocessing_id = &this.preprocessing_step_id;
let updated_attempt = PaymentAttempt::from_storage_model(
payment_attempt
.clone()
.to_storage_model()
.apply_changeset(this.clone().to_storage_model()),
);
// Check for database presence as well Maybe use a read replica here ?
let redis_value = serde_json::to_string(&updated_attempt)
.change_context(errors::StorageError::KVError)?;
let redis_entry = kv::TypedSql {
op: kv::DBOperation::Update {
updatable: Box::new(kv::Updateable::PaymentAttemptUpdate(Box::new(
kv::PaymentAttemptUpdateMems {
orig: this.clone().to_storage_model(),
update_data: payment_attempt.to_storage_model(),
},
))),
},
};
match (
old_connector_transaction_id,
&updated_attempt.get_connector_payment_id(),
) {
(None, Some(connector_transaction_id)) => {
add_connector_txn_id_to_reverse_lookup(
self,
key_str.as_str(),
&this.merchant_id,
updated_attempt.attempt_id.as_str(),
connector_transaction_id,
storage_scheme,
)
.await?;
}
(Some(old_connector_transaction_id), Some(connector_transaction_id)) => {
if old_connector_transaction_id.ne(connector_transaction_id) {
add_connector_txn_id_to_reverse_lookup(
self,
key_str.as_str(),
&this.merchant_id,
updated_attempt.attempt_id.as_str(),
connector_transaction_id,
storage_scheme,
)
.await?;
}
}
(_, _) => {}
}
match (old_preprocessing_id, &updated_attempt.preprocessing_step_id) {
(None, Some(preprocessing_id)) => {
add_preprocessing_id_to_reverse_lookup(
self,
key_str.as_str(),
&this.merchant_id,
updated_attempt.attempt_id.as_str(),
preprocessing_id.as_str(),
storage_scheme,
)
.await?;
}
(Some(old_preprocessing_id), Some(preprocessing_id)) => {
if old_preprocessing_id.ne(preprocessing_id) {
add_preprocessing_id_to_reverse_lookup(
self,
key_str.as_str(),
&this.merchant_id,
updated_attempt.attempt_id.as_str(),
preprocessing_id.as_str(),
storage_scheme,
)
.await?;
}
}
(_, _) => {}
}
Box::pin(kv_wrapper::<(), _, _>(
self,
KvOperation::Hset::<DieselPaymentAttempt>((&field, redis_value), redis_entry),
key,
))
.await
.change_context(errors::StorageError::KVError)?
.try_into_hset()
.change_context(errors::StorageError::KVError)?;
Ok(updated_attempt)
}
}
}
#[cfg(feature = "v2")]
#[instrument(skip_all)]
async fn update_payment_attempt(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
this: PaymentAttempt,
payment_attempt_update: PaymentAttemptUpdate,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
let payment_attempt = Conversion::convert(this.clone())
.await
.change_context(errors::StorageError::DecryptionError)?;
let key = PartitionKey::GlobalPaymentId {
id: &this.payment_id,
};
let field = format!("{}_{}", label::CLUSTER_LABEL, this.id.get_string_repr());
let conn = pg_connection_write(self).await?;
let payment_attempt_internal =
diesel_models::PaymentAttemptUpdateInternal::from(payment_attempt_update);
let updated_payment_attempt = payment_attempt_internal
.clone()
.apply_changeset(payment_attempt.clone());
let updated_by = updated_payment_attempt.updated_by.to_owned();
let updated_payment_attempt_with_id = payment_attempt
.clone()
.update_with_attempt_id(&conn, payment_attempt_internal.clone());
Box::pin(self.update_resource(
key_manager_state,
merchant_key_store,
storage_scheme,
updated_payment_attempt_with_id,
updated_payment_attempt,
UpdateResourceParams {
updateable: kv::Updateable::PaymentAttemptUpdate(Box::new(
kv::PaymentAttemptUpdateMems {
orig: payment_attempt,
update_data: payment_attempt_internal,
},
)),
operation: Op::Update(key.clone(), &field, Some(updated_by.as_str())),
},
))
.await
}
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(
&self,
connector_transaction_id: &ConnectorTransactionId,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
self,
storage_scheme,
Op::Find,
))
.await;
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
self.router_store
.find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(
connector_transaction_id,
payment_id,
merchant_id,
storage_scheme,
)
.await
}
MerchantStorageScheme::RedisKv => {
// We assume that PaymentAttempt <=> PaymentIntent is a one-to-one relation for now
let lookup_id = format!(
"pa_conn_trans_{}_{}",
merchant_id.get_string_repr(),
connector_transaction_id.get_id()
);
let lookup = fallback_reverse_lookup_not_found!(
self.get_lookup_by_lookup_id(&lookup_id, storage_scheme)
.await,
self.router_store
|
crates/storage_impl/src/payments/payment_attempt.rs#chunk0
|
storage_impl
|
chunk
| null | null | null | 8,183
| null | null | null | null | null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.