text stringlengths 70 351k | source stringclasses 4 values |
|---|---|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_capture_v2.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsCaptureRequest};
use super::{Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
helpers,
operations::{self, ValidateStatusForOperation},
},
utils::ValidatePlatformMerchant,
},
routes::{app::ReqState, SessionState},
types::{
api::{self, ConnectorCallType},
domain::{self},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsCaptureRequest, PaymentCaptureData<F>>;
fn to_update_tracker(
&self,
) -> RouterResult<&(dyn UpdateTracker<F, Self::Data, PaymentsCaptureRequest> + Send + Sync)>
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_capture_v2.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsCaptureRequest};
use super::{Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
helpers,
operations::{self, ValidateStatusForOperation},
},
utils::ValidatePlatformMerchant,
},
routes::{app::ReqState, SessionState},
types::{
api::{self, ConnectorCallType},
domain::{self},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsCaptureRequest, PaymentCaptureData<F>>;
fn to_domain(&self) -> RouterResult<&dyn Domain<F, PaymentsCaptureRequest, Self::Data>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_capture_v2.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsCaptureRequest};
use super::{Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
helpers,
operations::{self, ValidateStatusForOperation},
},
utils::ValidatePlatformMerchant,
},
routes::{app::ReqState, SessionState},
types::{
api::{self, ConnectorCallType},
domain::{self},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsCaptureRequest, PaymentCaptureData<F>>;
fn to_get_tracker(
&self,
) -> RouterResult<&(dyn GetTracker<F, Self::Data, PaymentsCaptureRequest> + Send + Sync)> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_capture_v2.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsCaptureRequest};
use super::{Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
helpers,
operations::{self, ValidateStatusForOperation},
},
utils::ValidatePlatformMerchant,
},
routes::{app::ReqState, SessionState},
types::{
api::{self, ConnectorCallType},
domain::{self},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsCaptureRequest, PaymentCaptureData<F>>;
fn to_validate_request(
&self,
) -> RouterResult<&(dyn ValidateRequest<F, PaymentsCaptureRequest, Self::Data> + Send + Sync)>
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_get_intent.rs | crate: router
use std::marker::PhantomData;
use api_models::{enums::FrmSuggestion, payments::PaymentsGetIntentRequest};
use common_utils::errors::CustomResult;
use crate::{
core::{
errors::{self, RouterResult},
payments::{self, helpers, operations},
utils::ValidatePlatformMerchant,
},
db::errors::StorageErrorExt,
routes::{app::ReqState, SessionState},
types::{
api, domain,
storage::{self, enums},
},
};
type PaymentsGetIntentOperation<'b, F> =
BoxedOperation<'b, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>;
async fn get_trackers<'a>(
&'a self,
state: &'a SessionState,
_payment_id: &common_utils::id_type::GlobalPaymentId,
request: &PaymentsGetIntentRequest,
merchant_account: &domain::MerchantAccount,
_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
platform_merchant_account: Option<&domain::MerchantAccount>,
) -> RouterResult<operations::GetTrackerResponse<payments::PaymentIntentData<F>>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/router/src/core/payments/operations/payment_get_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsGetIntentRequest};
use common_utils::errors::CustomResult;
use crate::{
core::{
errors::{self, RouterResult},
payments::{self, helpers, operations},
utils::ValidatePlatformMerchant,
},
db::errors::StorageErrorExt,
routes::{app::ReqState, SessionState},
types::{
api, domain,
storage::{self, enums},
},
};
type PaymentsGetIntentOperation<'b, F> =
BoxedOperation<'b, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>;
async fn guard_payment_against_blocklist<'a>(
&'a self,
_state: &SessionState,
_merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
_payment_data: &mut payments::PaymentIntentData<F>,
) -> CustomResult<bool, errors::ApiErrorResponse> {
Ok(false)
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_get_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsGetIntentRequest};
use common_utils::errors::CustomResult;
use crate::{
core::{
errors::{self, RouterResult},
payments::{self, helpers, operations},
utils::ValidatePlatformMerchant,
},
db::errors::StorageErrorExt,
routes::{app::ReqState, SessionState},
types::{
api, domain,
storage::{self, enums},
},
};
type PaymentsGetIntentOperation<'b, F> =
BoxedOperation<'b, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>;
async fn perform_routing<'a>(
&'a self,
merchant_account: &domain::MerchantAccount,
business_profile: &domain::Profile,
state: &SessionState,
// TODO: do not take the whole payment data here
payment_data: &mut payments::PaymentIntentData<F>,
mechant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<api::ConnectorCallType, errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_get_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsGetIntentRequest};
use crate::{
core::{
errors::{self, RouterResult},
payments::{self, helpers, operations},
utils::ValidatePlatformMerchant,
},
db::errors::StorageErrorExt,
routes::{app::ReqState, SessionState},
types::{
api, domain,
storage::{self, enums},
},
};
type PaymentsGetIntentOperation<'b, F> =
BoxedOperation<'b, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>;
async fn make_pm_data<'a>(
&'a self,
_state: &'a SessionState,
_payment_data: &mut payments::PaymentIntentData<F>,
_storage_scheme: enums::MerchantStorageScheme,
_merchant_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
PaymentsGetIntentOperation<'a, F>,
Option<domain::PaymentMethodData>,
Option<String>,
)> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_get_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsGetIntentRequest};
use common_utils::errors::CustomResult;
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, RouterResult},
payments::{self, helpers, operations},
utils::ValidatePlatformMerchant,
},
db::errors::StorageErrorExt,
routes::{app::ReqState, SessionState},
types::{
api, domain,
storage::{self, enums},
},
};
type PaymentsGetIntentOperation<'b, F> =
BoxedOperation<'b, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>;
async fn get_customer_details<'a>(
&'a self,
state: &SessionState,
payment_data: &mut payments::PaymentIntentData<F>,
merchant_key_store: &domain::MerchantKeyStore,
storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<
(
BoxedOperation<'a, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>,
Option<domain::Customer>,
),
errors::StorageError,
> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_get_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsGetIntentRequest};
use crate::{
core::{
errors::{self, RouterResult},
payments::{self, helpers, operations},
utils::ValidatePlatformMerchant,
},
db::errors::StorageErrorExt,
routes::{app::ReqState, SessionState},
types::{
api, domain,
storage::{self, enums},
},
};
type PaymentsGetIntentOperation<'b, F> =
BoxedOperation<'b, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>;
fn validate_request<'a, 'b>(
&'b self,
_request: &PaymentsGetIntentRequest,
merchant_account: &'a domain::MerchantAccount,
) -> RouterResult<operations::ValidateResult> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_get_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsGetIntentRequest};
use crate::{
core::{
errors::{self, RouterResult},
payments::{self, helpers, operations},
utils::ValidatePlatformMerchant,
},
db::errors::StorageErrorExt,
routes::{app::ReqState, SessionState},
types::{
api, domain,
storage::{self, enums},
},
};
type PaymentsGetIntentOperation<'b, F> =
BoxedOperation<'b, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>;
async fn update_trackers<'b>(
&'b self,
_state: &'b SessionState,
_req_state: ReqState,
payment_data: payments::PaymentIntentData<F>,
_customer: Option<domain::Customer>,
_storage_scheme: enums::MerchantStorageScheme,
_updated_customer: Option<storage::CustomerUpdate>,
_key_store: &domain::MerchantKeyStore,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<(
PaymentsGetIntentOperation<'b, F>,
payments::PaymentIntentData<F>,
)>
where
F: 'b + Send,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_get_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsGetIntentRequest};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, RouterResult},
payments::{self, helpers, operations},
utils::ValidatePlatformMerchant,
},
db::errors::StorageErrorExt,
routes::{app::ReqState, SessionState},
types::{
api, domain,
storage::{self, enums},
},
};
type PaymentsGetIntentOperation<'b, F> =
BoxedOperation<'b, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>;
fn to_update_tracker(
&self,
) -> RouterResult<&(dyn UpdateTracker<F, Self::Data, PaymentsGetIntentRequest> + Send + Sync)>
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_get_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsGetIntentRequest};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, RouterResult},
payments::{self, helpers, operations},
utils::ValidatePlatformMerchant,
},
db::errors::StorageErrorExt,
routes::{app::ReqState, SessionState},
types::{
api, domain,
storage::{self, enums},
},
};
type PaymentsGetIntentOperation<'b, F> =
BoxedOperation<'b, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>;
fn to_domain(&self) -> RouterResult<&dyn Domain<F, PaymentsGetIntentRequest, Self::Data>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_get_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsGetIntentRequest};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, RouterResult},
payments::{self, helpers, operations},
utils::ValidatePlatformMerchant,
},
db::errors::StorageErrorExt,
routes::{app::ReqState, SessionState},
types::{
api, domain,
storage::{self, enums},
},
};
type PaymentsGetIntentOperation<'b, F> =
BoxedOperation<'b, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>;
fn to_get_tracker(
&self,
) -> RouterResult<&(dyn GetTracker<F, Self::Data, PaymentsGetIntentRequest> + Send + Sync)>
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_get_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsGetIntentRequest};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, RouterResult},
payments::{self, helpers, operations},
utils::ValidatePlatformMerchant,
},
db::errors::StorageErrorExt,
routes::{app::ReqState, SessionState},
types::{
api, domain,
storage::{self, enums},
},
};
type PaymentsGetIntentOperation<'b, F> =
BoxedOperation<'b, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>;
fn to_validate_request(
&self,
) -> RouterResult<&(dyn ValidateRequest<F, PaymentsGetIntentRequest, Self::Data> + Send + Sync)>
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_complete_authorize.rs | crate: router
use api_models::enums::FrmSuggestion;
use error_stack::{report, ResultExt};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
mandate::helpers as m_helpers,
payments::{
self, helpers, operations, CustomerAcceptance, CustomerDetails, PaymentAddress,
PaymentData,
},
},
events::audit_events::{AuditEvent, AuditEventType},
routes::{app::ReqState, SessionState},
services,
types::{
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type CompleteAuthorizeOperation<'b, F> =
BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>;
fn validate_request<'a, 'b>(
&'b self,
request: &api::PaymentsRequest,
merchant_account: &'a domain::MerchantAccount,
) -> RouterResult<(
CompleteAuthorizeOperation<'b, F>,
operations::ValidateResult,
)> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_complete_authorize.rs | crate: router
use api_models::enums::FrmSuggestion;
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
mandate::helpers as m_helpers,
payments::{
self, helpers, operations, CustomerAcceptance, CustomerDetails, PaymentAddress,
PaymentData,
},
},
events::audit_events::{AuditEvent, AuditEventType},
routes::{app::ReqState, SessionState},
services,
types::{
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type CompleteAuthorizeOperation<'b, F> =
BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>;
async fn update_trackers<'b>(
&'b self,
state: &'b SessionState,
req_state: ReqState,
mut payment_data: PaymentData<F>,
_customer: Option<domain::Customer>,
storage_scheme: storage_enums::MerchantStorageScheme,
_updated_customer: Option<storage::CustomerUpdate>,
key_store: &domain::MerchantKeyStore,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<(CompleteAuthorizeOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_complete_authorize.rs | crate: router
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
mandate::helpers as m_helpers,
payments::{
self, helpers, operations, CustomerAcceptance, CustomerDetails, PaymentAddress,
PaymentData,
},
},
events::audit_events::{AuditEvent, AuditEventType},
routes::{app::ReqState, SessionState},
services,
types::{
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type CompleteAuthorizeOperation<'b, F> =
BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>;
async fn make_pm_data<'a>(
&'a self,
state: &'a SessionState,
payment_data: &mut PaymentData<F>,
storage_scheme: storage_enums::MerchantStorageScheme,
merchant_key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
business_profile: &domain::Profile,
should_retry_with_pan: bool,
) -> RouterResult<(
CompleteAuthorizeOperation<'a, F>,
Option<domain::PaymentMethodData>,
Option<String>,
)> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_complete_authorize.rs | crate: router
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
mandate::helpers as m_helpers,
payments::{
self, helpers, operations, CustomerAcceptance, CustomerDetails, PaymentAddress,
PaymentData,
},
},
events::audit_events::{AuditEvent, AuditEventType},
routes::{app::ReqState, SessionState},
services,
types::{
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
async fn add_task_to_process_tracker<'a>(
&'a self,
_state: &'a SessionState,
_payment_attempt: &storage::PaymentAttempt,
_requeue: bool,
_schedule_time: Option<time::PrimitiveDateTime>,
) -> CustomResult<(), errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_complete_authorize.rs | crate: router
use api_models::enums::FrmSuggestion;
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
mandate::helpers as m_helpers,
payments::{
self, helpers, operations, CustomerAcceptance, CustomerDetails, PaymentAddress,
PaymentData,
},
},
events::audit_events::{AuditEvent, AuditEventType},
routes::{app::ReqState, SessionState},
services,
types::{
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type CompleteAuthorizeOperation<'b, F> =
BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>;
async fn get_or_create_customer_details<'a>(
&'a self,
state: &SessionState,
payment_data: &mut PaymentData<F>,
request: Option<CustomerDetails>,
key_store: &domain::MerchantKeyStore,
storage_scheme: common_enums::enums::MerchantStorageScheme,
) -> CustomResult<
(CompleteAuthorizeOperation<'a, F>, Option<domain::Customer>),
errors::StorageError,
> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/router/src/core/payments/operations/payment_complete_authorize.rs | crate: router
use std::marker::PhantomData;
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
mandate::helpers as m_helpers,
payments::{
self, helpers, operations, CustomerAcceptance, CustomerDetails, PaymentAddress,
PaymentData,
},
},
events::audit_events::{AuditEvent, AuditEventType},
routes::{app::ReqState, SessionState},
services,
types::{
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type CompleteAuthorizeOperation<'b, F> =
BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>;
async fn get_trackers<'a>(
&'a self,
state: &'a SessionState,
payment_id: &api::PaymentIdType,
request: &api::PaymentsRequest,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
_auth_flow: services::AuthFlow,
_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
_platform_merchant_account: Option<&domain::MerchantAccount>,
) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>>
{
let db = &*state.store;
let key_manager_state = &state.into();
let merchant_id = merchant_account.get_id();
let storage_scheme = merchant_account.storage_scheme;
let (mut payment_intent, mut payment_attempt, currency, amount);
let payment_id = payment_id
.get_payment_intent_id()
.change_context(errors::ApiErrorResponse::PaymentNotFound)?;
payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
key_manager_state,
&payment_id,
merchant_id,
key_store,
storage_scheme,
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
// TODO (#7195): Add platform merchant account validation once client_secret auth is solved
payment_intent.setup_future_usage = request
.setup_future_usage
.or(payment_intent.setup_future_usage);
helpers::authenticate_client_secret(request.client_secret.as_ref(), &payment_intent)?;
helpers::validate_payment_status_against_not_allowed_statuses(
payment_intent.status,
&[
storage_enums::IntentStatus::Failed,
storage_enums::IntentStatus::Succeeded,
],
"confirm",
)?;
let browser_info = request
.browser_info
.clone()
.as_ref()
.map(utils::Encode::encode_to_value)
.transpose()
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "browser_info",
})?;
let recurring_details = request.recurring_details.clone();
payment_attempt = db
.find_payment_attempt_by_payment_id_merchant_id_attempt_id(
&payment_intent.payment_id,
merchant_id,
&payment_intent.active_attempt.get_id(),
storage_scheme,
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
let mandate_type = m_helpers::get_mandate_type(
request.mandate_data.clone(),
request.off_session,
payment_intent.setup_future_usage,
request.customer_acceptance.clone(),
request.payment_token.clone(),
payment_attempt.payment_method,
)
.change_context(errors::ApiErrorResponse::MandateValidationFailed {
reason: "Expected one out of recurring_details and mandate_data but got both".into(),
})?;
let m_helpers::MandateGenericData {
token,
payment_method,
payment_method_type,
mandate_data,
recurring_mandate_payment_data,
mandate_connector,
payment_method_info,
} = Box::pin(helpers::get_token_pm_type_mandate_details(
state,
request,
mandate_type.to_owned(),
merchant_account,
key_store,
payment_attempt.payment_method_id.clone(),
payment_intent.customer_id.as_ref(),
))
.await?;
let customer_acceptance: Option<CustomerAcceptance> = request
.customer_acceptance
.clone()
.map(From::from)
.or(payment_method_info
.clone()
.map(|pm| {
pm.customer_acceptance
.parse_value::<CustomerAcceptance>("CustomerAcceptance")
})
.transpose()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to deserialize to CustomerAcceptance")?);
let token = token.or_else(|| payment_attempt.payment_token.clone());
if let Some(payment_method) = payment_method {
let should_validate_pm_or_token_given =
//this validation should happen if data was stored in the vault
helpers::should_store_payment_method_data_in_vault(
&state.conf.temp_locker_enable_config,
payment_attempt.connector.clone(),
payment_method,
);
if should_validate_pm_or_token_given {
helpers::validate_pm_or_token_given(
&request.payment_method,
&request
.payment_method_data
.as_ref()
.and_then(|pmd| pmd.payment_method_data.clone()),
&request.payment_method_type,
&mandate_type,
&token,
&request.ctp_service_details,
)?;
}
}
let token_data = if let Some((token, payment_method)) = token
.as_ref()
.zip(payment_method.or(payment_attempt.payment_method))
{
Some(
helpers::retrieve_payment_token_data(state, token.clone(), Some(payment_method))
.await?,
)
} else {
None
};
payment_attempt.payment_method = payment_method.or(payment_attempt.payment_method);
payment_attempt.browser_info = browser_info.or(payment_attempt.browser_info);
payment_attempt.payment_method_type =
payment_method_type.or(payment_attempt.payment_method_type);
payment_attempt.payment_experience = request
.payment_experience
.or(payment_attempt.payment_experience);
currency = payment_attempt.currency.get_required_value("currency")?;
amount = payment_attempt.get_total_amount().into();
let customer_id = payment_intent
.customer_id
.as_ref()
.or(request.customer_id.as_ref())
.cloned();
helpers::validate_customer_id_mandatory_cases(
request.setup_future_usage.is_some(),
customer_id.as_ref(),
)?;
let shipping_address = helpers::create_or_update_address_for_payment_by_request(
state,
request.shipping.as_ref(),
payment_intent.shipping_address_id.clone().as_deref(),
merchant_id,
payment_intent.customer_id.as_ref(),
key_store,
&payment_id,
storage_scheme,
)
.await?;
payment_intent.shipping_address_id = shipping_address
.as_ref()
.map(|shipping_address| shipping_address.address_id.clone());
let billing_address = helpers::get_address_by_id(
state,
payment_intent.billing_address_id.clone(),
key_store,
&payment_intent.payment_id,
merchant_id,
merchant_account.storage_scheme,
)
.await?;
let payment_method_billing = helpers::get_address_by_id(
state,
payment_attempt.payment_method_billing_address_id.clone(),
key_store,
&payment_intent.payment_id,
merchant_id,
merchant_account.storage_scheme,
)
.await?;
let redirect_response = request
.feature_metadata
.as_ref()
.and_then(|fm| fm.redirect_response.clone());
payment_intent.shipping_address_id = shipping_address.clone().map(|i| i.address_id);
payment_intent.billing_address_id = billing_address.clone().map(|i| i.address_id);
payment_intent.return_url = request
.return_url
.as_ref()
.map(|a| a.to_string())
.or(payment_intent.return_url);
payment_intent.allowed_payment_method_types = request
.get_allowed_payment_method_types_as_value()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error converting allowed_payment_types to Value")?
.or(payment_intent.allowed_payment_method_types);
payment_intent.connector_metadata = request
.get_connector_metadata_as_value()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error converting connector_metadata to Value")?
.or(payment_intent.connector_metadata);
payment_intent.feature_metadata = request
.get_feature_metadata_as_value()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error converting feature_metadata to Value")?
.or(payment_intent.feature_metadata);
payment_intent.metadata = request.metadata.clone().or(payment_intent.metadata);
// The operation merges mandate data from both request and payment_attempt
let setup_mandate = mandate_data;
let mandate_details_present =
payment_attempt.mandate_details.is_some() || request.mandate_data.is_some();
helpers::validate_mandate_data_and_future_usage(
payment_intent.setup_future_usage,
mandate_details_present,
)?;
let profile_id = payment_intent
.profile_id
.as_ref()
.get_required_value("profile_id")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("'profile_id' not set in payment intent")?;
let business_profile = db
.find_business_profile_by_profile_id(key_manager_state, key_store, profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
})?;
let creds_identifier =
request
.merchant_connector_details
.as_ref()
.map(|merchant_connector_details| {
merchant_connector_details.creds_identifier.to_owned()
});
let payment_data = PaymentData {
flow: PhantomData,
payment_intent,
payment_attempt,
currency,
amount,
email: request.email.clone(),
mandate_id: None,
mandate_connector,
setup_mandate,
customer_acceptance,
token,
token_data,
address: PaymentAddress::new(
shipping_address.as_ref().map(From::from),
billing_address.as_ref().map(From::from),
payment_method_billing.as_ref().map(From::from),
business_profile.use_billing_as_payment_method_billing,
),
confirm: request.confirm,
payment_method_data: request
.payment_method_data
.as_ref()
.and_then(|pmd| pmd.payment_method_data.clone().map(Into::into)),
payment_method_info,
force_sync: None,
refunds: vec![],
disputes: vec![],
attempts: None,
sessions_token: vec![],
card_cvc: request.card_cvc.clone(),
creds_identifier,
pm_token: None,
connector_customer_id: None,
recurring_mandate_payment_data,
ephemeral_key: None,
multiple_capture_data: None,
redirect_response,
surcharge_details: None,
frm_message: None,
payment_link_data: None,
incremental_authorization_details: None,
authorizations: vec![],
authentication: None,
recurring_details,
poll_config: None,
tax_data: None,
session_id: None,
service_details: None,
card_testing_guard_data: None,
vault_operation: None,
threeds_method_comp_ind: request.threeds_method_comp_ind.clone(),
};
let customer_details = Some(CustomerDetails {
customer_id,
name: request.name.clone(),
email: request.email.clone(),
phone: request.phone.clone(),
phone_country_code: request.phone_country_code.clone(),
});
let get_trackers_response = operations::GetTrackerResponse {
operation: Box::new(self),
customer_details,
payment_data,
business_profile,
mandate_type,
};
Ok(get_trackers_response)
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_capture.rs | crate: router
use api_models::enums::FrmSuggestion;
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{self, helpers, operations, types::MultipleCaptureData},
utils::ValidatePlatformMerchant,
},
events::audit_events::{AuditEvent, AuditEventType},
routes::{app::ReqState, SessionState},
services,
types::{
self as core_types,
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums, payment_attempt::PaymentAttemptExt},
},
utils::OptionExt,
};
type PaymentCaptureOperation<'b, F> =
BoxedOperation<'b, F, api::PaymentsCaptureRequest, payments::PaymentData<F>>;
async fn update_trackers<'b>(
&'b self,
db: &'b SessionState,
req_state: ReqState,
mut payment_data: payments::PaymentData<F>,
_customer: Option<domain::Customer>,
storage_scheme: enums::MerchantStorageScheme,
_updated_customer: Option<storage::CustomerUpdate>,
_mechant_key_store: &domain::MerchantKeyStore,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<(PaymentCaptureOperation<'b, F>, payments::PaymentData<F>)>
where
F: 'b + Send,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_capture.rs | crate: router
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{self, helpers, operations, types::MultipleCaptureData},
utils::ValidatePlatformMerchant,
},
events::audit_events::{AuditEvent, AuditEventType},
routes::{app::ReqState, SessionState},
services,
types::{
self as core_types,
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums, payment_attempt::PaymentAttemptExt},
},
utils::OptionExt,
};
type PaymentCaptureOperation<'b, F> =
BoxedOperation<'b, F, api::PaymentsCaptureRequest, payments::PaymentData<F>>;
fn validate_request<'a, 'b>(
&'b self,
request: &api::PaymentsCaptureRequest,
merchant_account: &'a domain::MerchantAccount,
) -> RouterResult<(PaymentCaptureOperation<'b, F>, operations::ValidateResult)> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_capture.rs | crate: router
use std::marker::PhantomData;
use api_models::enums::FrmSuggestion;
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{self, helpers, operations, types::MultipleCaptureData},
utils::ValidatePlatformMerchant,
},
events::audit_events::{AuditEvent, AuditEventType},
routes::{app::ReqState, SessionState},
services,
types::{
self as core_types,
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums, payment_attempt::PaymentAttemptExt},
},
utils::OptionExt,
};
type PaymentCaptureOperation<'b, F> =
BoxedOperation<'b, F, api::PaymentsCaptureRequest, payments::PaymentData<F>>;
async fn get_trackers<'a>(
&'a self,
state: &'a SessionState,
payment_id: &api::PaymentIdType,
request: &api::PaymentsCaptureRequest,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
_auth_flow: services::AuthFlow,
_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
platform_merchant_account: Option<&domain::MerchantAccount>,
) -> RouterResult<
operations::GetTrackerResponse<
'a,
F,
api::PaymentsCaptureRequest,
payments::PaymentData<F>,
>,
> {
{let db = &*state.store;<|fim_suffix|>
<|fim_middle|>
Ok(get_trackers_response)}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/proxy_payments_intent.rs | crate: router
use api_models::payments::ProxyPaymentsRequest;
use async_trait::async_trait;
use common_enums::enums;
use common_utils::types::keymanager::ToEncryptable;
use error_stack::ResultExt;
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData, payments::PaymentConfirmData,
};
use masking::PeekInterface;
use router_env::{instrument, tracing};
use super::{Domain, GetTracker, Operation, PostUpdateTracker, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
operations::{self, ValidateStatusForOperation},
OperationSessionGetters,
},
},
routes::{app::ReqState, SessionState},
types::{
self,
api::{self, ConnectorCallType},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, ProxyPaymentsRequest, PaymentConfirmData<F>>;
async fn update_tracker<'b>(
&'b self,
state: &'b SessionState,
mut payment_data: PaymentConfirmData<F>,
response: types::RouterData<F, types::PaymentsAuthorizeData, types::PaymentsResponseData>,
key_store: &domain::MerchantKeyStore,
storage_scheme: enums::MerchantStorageScheme,
) -> RouterResult<PaymentConfirmData<F>>
where
F: 'b + Send + Sync,
types::RouterData<F, types::PaymentsAuthorizeData, types::PaymentsResponseData>:
hyperswitch_domain_models::router_data::TrackerPostUpdateObjects<
F,
types::PaymentsAuthorizeData,
PaymentConfirmData<F>,
>,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/proxy_payments_intent.rs | crate: router
use error_stack::ResultExt;
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData, payments::PaymentConfirmData,
};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
operations::{self, ValidateStatusForOperation},
OperationSessionGetters,
},
},
routes::{app::ReqState, SessionState},
types::{
self,
api::{self, ConnectorCallType},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, ProxyPaymentsRequest, PaymentConfirmData<F>>;
async fn perform_routing<'a>(
&'a self,
_merchant_account: &domain::MerchantAccount,
_business_profile: &domain::Profile,
state: &SessionState,
payment_data: &mut PaymentConfirmData<F>,
_mechant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<ConnectorCallType, errors::ApiErrorResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/proxy_payments_intent.rs | crate: router
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData, payments::PaymentConfirmData,
};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
operations::{self, ValidateStatusForOperation},
OperationSessionGetters,
},
},
routes::{app::ReqState, SessionState},
types::{
self,
api::{self, ConnectorCallType},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, ProxyPaymentsRequest, PaymentConfirmData<F>>;
async fn make_pm_data<'a>(
&'a self,
_state: &'a SessionState,
_payment_data: &mut PaymentConfirmData<F>,
_storage_scheme: storage_enums::MerchantStorageScheme,
_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
BoxedConfirmOperation<'a, F>,
Option<PaymentMethodData>,
Option<String>,
)> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/proxy_payments_intent.rs | crate: router
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData, payments::PaymentConfirmData,
};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
operations::{self, ValidateStatusForOperation},
OperationSessionGetters,
},
},
routes::{app::ReqState, SessionState},
types::{
self,
api::{self, ConnectorCallType},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, ProxyPaymentsRequest, PaymentConfirmData<F>>;
async fn get_customer_details<'a>(
&'a self,
_state: &SessionState,
_payment_data: &mut PaymentConfirmData<F>,
_merchant_key_store: &domain::MerchantKeyStore,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<(BoxedConfirmOperation<'a, F>, Option<domain::Customer>), errors::StorageError>
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/proxy_payments_intent.rs | crate: router
use api_models::payments::ProxyPaymentsRequest;
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
operations::{self, ValidateStatusForOperation},
OperationSessionGetters,
},
},
routes::{app::ReqState, SessionState},
types::{
self,
api::{self, ConnectorCallType},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, ProxyPaymentsRequest, PaymentConfirmData<F>>;
fn validate_request<'a, 'b>(
&'b self,
_request: &ProxyPaymentsRequest,
merchant_account: &'a domain::MerchantAccount,
) -> RouterResult<operations::ValidateResult> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/proxy_payments_intent.rs | crate: router
use api_models::payments::ProxyPaymentsRequest;
use super::{Domain, GetTracker, Operation, PostUpdateTracker, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
operations::{self, ValidateStatusForOperation},
OperationSessionGetters,
},
},
routes::{app::ReqState, SessionState},
types::{
self,
api::{self, ConnectorCallType},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, ProxyPaymentsRequest, PaymentConfirmData<F>>;
fn to_update_tracker(
&self,
) -> RouterResult<&(dyn UpdateTracker<F, Self::Data, ProxyPaymentsRequest> + Send + Sync)> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/proxy_payments_intent.rs | crate: router
use api_models::payments::ProxyPaymentsRequest;
use super::{Domain, GetTracker, Operation, PostUpdateTracker, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
operations::{self, ValidateStatusForOperation},
OperationSessionGetters,
},
},
routes::{app::ReqState, SessionState},
types::{
self,
api::{self, ConnectorCallType},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, ProxyPaymentsRequest, PaymentConfirmData<F>>;
fn to_domain(&self) -> RouterResult<&dyn Domain<F, ProxyPaymentsRequest, Self::Data>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/proxy_payments_intent.rs | crate: router
use api_models::payments::ProxyPaymentsRequest;
use super::{Domain, GetTracker, Operation, PostUpdateTracker, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
operations::{self, ValidateStatusForOperation},
OperationSessionGetters,
},
},
routes::{app::ReqState, SessionState},
types::{
self,
api::{self, ConnectorCallType},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, ProxyPaymentsRequest, PaymentConfirmData<F>>;
fn to_get_tracker(
&self,
) -> RouterResult<&(dyn GetTracker<F, Self::Data, ProxyPaymentsRequest> + Send + Sync)> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/proxy_payments_intent.rs | crate: router
use api_models::payments::ProxyPaymentsRequest;
use super::{Domain, GetTracker, Operation, PostUpdateTracker, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
operations::{self, ValidateStatusForOperation},
OperationSessionGetters,
},
},
routes::{app::ReqState, SessionState},
types::{
self,
api::{self, ConnectorCallType},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, ProxyPaymentsRequest, PaymentConfirmData<F>>;
fn to_validate_request(
&self,
) -> RouterResult<&(dyn ValidateRequest<F, ProxyPaymentsRequest, Self::Data> + Send + Sync)>
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/proxy_payments_intent.rs | crate: router
use api_models::payments::ProxyPaymentsRequest;
use common_enums::enums;
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData, payments::PaymentConfirmData,
};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
operations::{self, ValidateStatusForOperation},
OperationSessionGetters,
},
},
routes::{app::ReqState, SessionState},
types::{
self,
api::{self, ConnectorCallType},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, ProxyPaymentsRequest, PaymentConfirmData<F>>;
async fn update_trackers<'b>(
&'b self,
state: &'b SessionState,
_req_state: ReqState,
mut payment_data: PaymentConfirmData<F>,
_customer: Option<domain::Customer>,
storage_scheme: storage_enums::MerchantStorageScheme,
_updated_customer: Option<storage::CustomerUpdate>,
key_store: &domain::MerchantKeyStore,
_frm_suggestion: Option<api_models::enums::FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<(BoxedConfirmOperation<'b, F>, PaymentConfirmData<F>)>
where
F: 'b + Send,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/proxy_payments_intent.rs | crate: router
use api_models::payments::ProxyPaymentsRequest;
use common_utils::types::keymanager::ToEncryptable;
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData, payments::PaymentConfirmData,
};
use crate::{
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
operations::{self, ValidateStatusForOperation},
OperationSessionGetters,
},
},
routes::{app::ReqState, SessionState},
types::{
self,
api::{self, ConnectorCallType},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::OptionExt,
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, ProxyPaymentsRequest, PaymentConfirmData<F>>;
async fn get_trackers<'a>(
&'a self,
state: &'a SessionState,
payment_id: &common_utils::id_type::GlobalPaymentId,
request: &ProxyPaymentsRequest,
merchant_account: &domain::MerchantAccount,
_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
_platform_merchant_account: Option<&domain::MerchantAccount>,
) -> RouterResult<operations::GetTrackerResponse<PaymentConfirmData<F>>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/flows/setup_mandate_flow.rs | crate: router
use router_env::logger;
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
mandate,
payments::{
self, access_token, customers, helpers, tokenization, transformers, PaymentData,
},
},
routes::SessionState,
services,
types::{self, api, domain},
};
async fn decide_flows<'a>(
mut self,
state: &SessionState,
connector: &api::ConnectorData,
call_connector_action: payments::CallConnectorAction,
connector_request: Option<services::Request>,
_business_profile: &domain::Profile,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/flows/setup_mandate_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
mandate,
payments::{
self, access_token, customers, helpers, tokenization, transformers, PaymentData,
},
},
routes::SessionState,
services,
types::{self, api, domain},
};
async fn construct_router_data<'a>(
&self,
state: &SessionState,
connector_id: &str,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
merchant_connector_account: &domain::MerchantConnectorAccount,
merchant_recipient_data: Option<types::MerchantRecipientData>,
header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,
) -> RouterResult<types::SetupMandateRouterData> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/flows/setup_mandate_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
mandate,
payments::{
self, access_token, customers, helpers, tokenization, transformers, PaymentData,
},
},
routes::SessionState,
services,
types::{self, api, domain},
};
async fn construct_router_data<'a>(
&self,
state: &SessionState,
connector_id: &str,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
merchant_connector_account: &helpers::MerchantConnectorAccountType,
merchant_recipient_data: Option<types::MerchantRecipientData>,
header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,
) -> RouterResult<types::SetupMandateRouterData> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/flows/setup_mandate_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
mandate,
payments::{
self, access_token, customers, helpers, tokenization, transformers, PaymentData,
},
},
routes::SessionState,
services,
types::{self, api, domain},
};
async fn get_merchant_recipient_data<'a>(
&self,
_state: &SessionState,
_merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
_merchant_connector_account: &helpers::MerchantConnectorAccountType,
_connector: &api::ConnectorData,
) -> RouterResult<Option<types::MerchantRecipientData>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/flows/approve_flow.rs | crate: router
use crate::{
core::{
errors::{ApiErrorResponse, NotImplementedMessage, RouterResult},
payments::{self, access_token, helpers, transformers, PaymentData},
},
routes::SessionState,
services,
types::{self, api, domain},
};
async fn construct_router_data<'a>(
&self,
state: &SessionState,
connector_id: &str,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
merchant_connector_account: &helpers::MerchantConnectorAccountType,
merchant_recipient_data: Option<types::MerchantRecipientData>,
header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,
) -> RouterResult<types::PaymentsApproveRouterData> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/flows/approve_flow.rs | crate: router
use crate::{
core::{
errors::{ApiErrorResponse, NotImplementedMessage, RouterResult},
payments::{self, access_token, helpers, transformers, PaymentData},
},
routes::SessionState,
services,
types::{self, api, domain},
};
async fn build_flow_specific_connector_request(
&mut self,
_state: &SessionState,
_connector: &api::ConnectorData,
_call_connector_action: payments::CallConnectorAction,
) -> RouterResult<(Option<services::Request>, bool)> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/flows/approve_flow.rs | crate: router
use crate::{
core::{
errors::{ApiErrorResponse, NotImplementedMessage, RouterResult},
payments::{self, access_token, helpers, transformers, PaymentData},
},
routes::SessionState,
services,
types::{self, api, domain},
};
async fn decide_flows<'a>(
self,
_state: &SessionState,
_connector: &api::ConnectorData,
_call_connector_action: payments::CallConnectorAction,
_connector_request: Option<services::Request>,
_business_profile: &domain::Profile,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/flows/approve_flow.rs | crate: router
use crate::{
core::{
errors::{ApiErrorResponse, NotImplementedMessage, RouterResult},
payments::{self, access_token, helpers, transformers, PaymentData},
},
routes::SessionState,
services,
types::{self, api, domain},
};
async fn construct_router_data<'a>(
&self,
state: &SessionState,
connector_id: &str,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
merchant_connector_account: &domain::MerchantConnectorAccount,
merchant_recipient_data: Option<types::MerchantRecipientData>,
header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,
) -> RouterResult<types::PaymentsApproveRouterData> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/operation.rs | crate: router
use common_enums::FrmSuggestion;
pub use self::{fraud_check_post::FraudCheckPost, fraud_check_pre::FraudCheckPre};
use super::{
types::{ConnectorDetailsCore, FrmConfigsObject, PaymentToFrmData},
FrmData,
};
use crate::{
core::errors::{self, RouterResult},
routes::{app::ReqState, SessionState},
types::{domain, fraud_check::FrmRouterData},
};
pub type BoxedFraudCheckOperation<F, D> = Box<dyn FraudCheckOperation<F, D> + Send + Sync>;
async fn execute_post_tasks(
&self,
_state: &SessionState,
_req_state: ReqState,
frm_data: &mut FrmData,
_merchant_account: &domain::MerchantAccount,
_frm_configs: FrmConfigsObject,
_frm_suggestion: &mut Option<FrmSuggestion>,
_key_store: domain::MerchantKeyStore,
_payment_data: &mut D,
_customer: &Option<domain::Customer>,
_should_continue_capture: &mut bool,
_platform_merchant_account: Option<&domain::MerchantAccount>,
) -> RouterResult<Option<FrmData>>
where
F: Send + Clone,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/operation.rs | crate: router
use error_stack::{report, ResultExt};
pub use self::{fraud_check_post::FraudCheckPost, fraud_check_pre::FraudCheckPre};
use super::{
types::{ConnectorDetailsCore, FrmConfigsObject, PaymentToFrmData},
FrmData,
};
use crate::{
core::errors::{self, RouterResult},
routes::{app::ReqState, SessionState},
types::{domain, fraud_check::FrmRouterData},
};
pub type BoxedFraudCheckOperation<F, D> = Box<dyn FraudCheckOperation<F, D> + Send + Sync>;
fn to_update_tracker(&self) -> RouterResult<&(dyn UpdateTracker<FrmData, F, D> + Send + Sync)> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/checkout_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::types::FrmData,
payments::{self, helpers},
},
errors, services,
types::{
api::{
self,
fraud_check::{self as frm_api, FraudCheckConnectorData},
},
domain,
fraud_check::{FraudCheckCheckoutData, FraudCheckResponseData, FrmCheckoutRouterData},
storage::enums as storage_enums,
BrowserInformation, ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
SessionState,
};
pub async fn decide_frm_flow(
router_data: &mut FrmCheckoutRouterData,
state: &SessionState,
connector: &FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
_merchant_account: &domain::MerchantAccount,
) -> RouterResult<FrmCheckoutRouterData> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/checkout_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::types::FrmData,
payments::{self, helpers},
},
errors, services,
types::{
api::{
self,
fraud_check::{self as frm_api, FraudCheckConnectorData},
},
domain,
fraud_check::{FraudCheckCheckoutData, FraudCheckResponseData, FrmCheckoutRouterData},
storage::enums as storage_enums,
BrowserInformation, ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
SessionState,
};
async fn decide_frm_flows<'a>(
mut self,
state: &SessionState,
connector: &FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
merchant_account: &domain::MerchantAccount,
) -> RouterResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/checkout_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::types::FrmData,
payments::{self, helpers},
},
errors, services,
types::{
api::{
self,
fraud_check::{self as frm_api, FraudCheckConnectorData},
},
domain,
fraud_check::{FraudCheckCheckoutData, FraudCheckResponseData, FrmCheckoutRouterData},
storage::enums as storage_enums,
BrowserInformation, ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
SessionState,
};
async fn construct_router_data<'a>(
&self,
_state: &SessionState,
_connector_id: &str,
_merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_merchant_connector_account: &domain::MerchantConnectorAccount,
_merchant_recipient_data: Option<MerchantRecipientData>,
_header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,
) -> RouterResult<RouterData<frm_api::Checkout, FraudCheckCheckoutData, FraudCheckResponseData>>
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/checkout_flow.rs | crate: router
use async_trait::async_trait;
use common_utils::{ext_traits::ValueExt, pii::Email};
use error_stack::ResultExt;
use masking::ExposeInterface;
use super::{ConstructFlowSpecificData, FeatureFrm};
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::types::FrmData,
payments::{self, helpers},
},
errors, services,
types::{
api::{
self,
fraud_check::{self as frm_api, FraudCheckConnectorData},
},
domain,
fraud_check::{FraudCheckCheckoutData, FraudCheckResponseData, FrmCheckoutRouterData},
storage::enums as storage_enums,
BrowserInformation, ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
SessionState,
};
async fn construct_router_data<'a>(
&self,
state: &SessionState,
connector_id: &str,
merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
merchant_connector_account: &helpers::MerchantConnectorAccountType,
_merchant_recipient_data: Option<MerchantRecipientData>,
header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,
) -> RouterResult<RouterData<frm_api::Checkout, FraudCheckCheckoutData, FraudCheckResponseData>>
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/transaction_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::{FeatureFrm, FrmData},
payments::{self, flows::ConstructFlowSpecificData, helpers},
},
errors, services,
types::{
api::{self, fraud_check as frm_api},
domain,
fraud_check::{
FraudCheckResponseData, FraudCheckTransactionData, FrmTransactionRouterData,
},
storage::enums as storage_enums,
ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
SessionState,
};
pub async fn decide_frm_flow(
router_data: &mut FrmTransactionRouterData,
state: &SessionState,
connector: &frm_api::FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
_merchant_account: &domain::MerchantAccount,
) -> RouterResult<FrmTransactionRouterData> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/transaction_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::{FeatureFrm, FrmData},
payments::{self, flows::ConstructFlowSpecificData, helpers},
},
errors, services,
types::{
api::{self, fraud_check as frm_api},
domain,
fraud_check::{
FraudCheckResponseData, FraudCheckTransactionData, FrmTransactionRouterData,
},
storage::enums as storage_enums,
ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
SessionState,
};
async fn decide_frm_flows<'a>(
mut self,
state: &SessionState,
connector: &frm_api::FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
merchant_account: &domain::MerchantAccount,
) -> RouterResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/transaction_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::{FeatureFrm, FrmData},
payments::{self, flows::ConstructFlowSpecificData, helpers},
},
errors, services,
types::{
api::{self, fraud_check as frm_api},
domain,
fraud_check::{
FraudCheckResponseData, FraudCheckTransactionData, FrmTransactionRouterData,
},
storage::enums as storage_enums,
ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
SessionState,
};
async fn get_merchant_recipient_data<'a>(
&self,
_state: &SessionState,
_merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
_merchant_connector_account: &helpers::MerchantConnectorAccountType,
_connector: &api::ConnectorData,
) -> RouterResult<Option<MerchantRecipientData>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/transaction_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::{FeatureFrm, FrmData},
payments::{self, flows::ConstructFlowSpecificData, helpers},
},
errors, services,
types::{
api::{self, fraud_check as frm_api},
domain,
fraud_check::{
FraudCheckResponseData, FraudCheckTransactionData, FrmTransactionRouterData,
},
storage::enums as storage_enums,
ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
SessionState,
};
async fn construct_router_data<'a>(
&self,
_state: &SessionState,
_connector_id: &str,
_merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_merchant_connector_account: &domain::MerchantConnectorAccount,
_merchant_recipient_data: Option<MerchantRecipientData>,
_header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,
) -> RouterResult<
RouterData<frm_api::Transaction, FraudCheckTransactionData, FraudCheckResponseData>,
> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/transaction_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::{FeatureFrm, FrmData},
payments::{self, flows::ConstructFlowSpecificData, helpers},
},
errors, services,
types::{
api::{self, fraud_check as frm_api},
domain,
fraud_check::{
FraudCheckResponseData, FraudCheckTransactionData, FrmTransactionRouterData,
},
storage::enums as storage_enums,
ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
SessionState,
};
async fn construct_router_data<'a>(
&self,
state: &SessionState,
connector_id: &str,
merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
merchant_connector_account: &helpers::MerchantConnectorAccountType,
_merchant_recipient_data: Option<MerchantRecipientData>,
header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,
) -> RouterResult<
RouterData<frm_api::Transaction, FraudCheckTransactionData, FraudCheckResponseData>,
> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/sale_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::{FeatureFrm, FraudCheckConnectorData, FrmData},
payments::{self, flows::ConstructFlowSpecificData, helpers},
},
errors, services,
types::{
api::{self, fraud_check as frm_api},
domain,
fraud_check::{FraudCheckResponseData, FraudCheckSaleData, FrmSaleRouterData},
storage::enums as storage_enums,
ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
SessionState,
};
pub async fn decide_frm_flow(
router_data: &mut FrmSaleRouterData,
state: &SessionState,
connector: &FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
_merchant_account: &domain::MerchantAccount,
) -> RouterResult<FrmSaleRouterData> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/router/src/core/fraud_check/flows/sale_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::{FeatureFrm, FraudCheckConnectorData, FrmData},
payments::{self, flows::ConstructFlowSpecificData, helpers},
},
errors, services,
types::{
api::{self, fraud_check as frm_api},
domain,
fraud_check::{FraudCheckResponseData, FraudCheckSaleData, FrmSaleRouterData},
storage::enums as storage_enums,
ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
SessionState,
};
async fn decide_frm_flows<'a>(
mut self,
state: &SessionState,
connector: &FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
merchant_account: &domain::MerchantAccount,
) -> RouterResult<Self> {
decide_frm_flow(
&mut self,
state,
connector,
call_connector_action,
merchant_account,
)
.await
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/sale_flow.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::{FeatureFrm, FraudCheckConnectorData, FrmData},
payments::{self, flows::ConstructFlowSpecificData, helpers},
},
errors, services,
types::{
api::{self, fraud_check as frm_api},
domain,
fraud_check::{FraudCheckResponseData, FraudCheckSaleData, FrmSaleRouterData},
storage::enums as storage_enums,
ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
SessionState,
};
async fn construct_router_data<'a>(
&self,
_state: &SessionState,
_connector_id: &str,
_merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_merchant_connector_account: &domain::MerchantConnectorAccount,
_merchant_recipient_data: Option<MerchantRecipientData>,
_header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,
) -> RouterResult<RouterData<frm_api::Sale, FraudCheckSaleData, FraudCheckResponseData>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/sale_flow.rs | crate: router
use common_utils::{ext_traits::ValueExt, pii::Email};
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::{FeatureFrm, FraudCheckConnectorData, FrmData},
payments::{self, flows::ConstructFlowSpecificData, helpers},
},
errors, services,
types::{
api::{self, fraud_check as frm_api},
domain,
fraud_check::{FraudCheckResponseData, FraudCheckSaleData, FrmSaleRouterData},
storage::enums as storage_enums,
ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
SessionState,
};
async fn construct_router_data<'a>(
&self,
state: &SessionState,
connector_id: &str,
merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
merchant_connector_account: &helpers::MerchantConnectorAccountType,
_merchant_recipient_data: Option<MerchantRecipientData>,
header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,
) -> RouterResult<RouterData<frm_api::Sale, FraudCheckSaleData, FraudCheckResponseData>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/record_return.rs | crate: router
use crate::{
connector::signifyd::transformers::RefundMethod,
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::{FeatureFrm, FraudCheckConnectorData, FrmData},
payments::{self, flows::ConstructFlowSpecificData, helpers},
},
errors, services,
types::{
api::{self, RecordReturn},
domain,
fraud_check::{
FraudCheckRecordReturnData, FraudCheckResponseData, FrmRecordReturnRouterData,
},
storage::enums as storage_enums,
ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
utils, SessionState,
};
pub async fn decide_frm_flow(
router_data: &mut FrmRecordReturnRouterData,
state: &SessionState,
connector: &FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
_merchant_account: &domain::MerchantAccount,
) -> RouterResult<FrmRecordReturnRouterData> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/record_return.rs | crate: router
use crate::{
connector::signifyd::transformers::RefundMethod,
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::{FeatureFrm, FraudCheckConnectorData, FrmData},
payments::{self, flows::ConstructFlowSpecificData, helpers},
},
errors, services,
types::{
api::{self, RecordReturn},
domain,
fraud_check::{
FraudCheckRecordReturnData, FraudCheckResponseData, FrmRecordReturnRouterData,
},
storage::enums as storage_enums,
ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
utils, SessionState,
};
async fn construct_router_data<'a>(
&self,
_state: &SessionState,
_connector_id: &str,
_merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_merchant_connector_account: &domain::MerchantConnectorAccount,
_merchant_recipient_data: Option<MerchantRecipientData>,
_header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,
) -> RouterResult<RouterData<RecordReturn, FraudCheckRecordReturnData, FraudCheckResponseData>>
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/record_return.rs | crate: router
use crate::{
connector::signifyd::transformers::RefundMethod,
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::{FeatureFrm, FraudCheckConnectorData, FrmData},
payments::{self, flows::ConstructFlowSpecificData, helpers},
},
errors, services,
types::{
api::{self, RecordReturn},
domain,
fraud_check::{
FraudCheckRecordReturnData, FraudCheckResponseData, FrmRecordReturnRouterData,
},
storage::enums as storage_enums,
ConnectorAuthType, MerchantRecipientData, ResponseId, RouterData,
},
utils, SessionState,
};
async fn construct_router_data<'a>(
&self,
state: &SessionState,
connector_id: &str,
merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
merchant_connector_account: &helpers::MerchantConnectorAccountType,
_merchant_recipient_data: Option<MerchantRecipientData>,
header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,
) -> RouterResult<RouterData<RecordReturn, FraudCheckRecordReturnData, FraudCheckResponseData>>
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs | crate: router
use crate::{
core::{
errors::RouterResult, fraud_check::frm_core_types::FrmFulfillmentRequest,
payments::helpers, utils as core_utils,
},
errors,
types::{
domain,
fraud_check::{FraudCheckFulfillmentData, FrmFulfillmentRouterData},
storage, ConnectorAuthType, ErrorResponse, PaymentAddress, RouterData,
},
utils, SessionState,
};
pub async fn construct_fulfillment_router_data<'a>(
_state: &'a SessionState,
_payment_intent: &'a storage::PaymentIntent,
_payment_attempt: &storage::PaymentAttempt,
_merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
_connector: String,
_fulfillment_request: FrmFulfillmentRequest,
) -> RouterResult<FrmFulfillmentRouterData> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs | crate: router
use common_utils::ext_traits::{OptionExt, ValueExt};
use crate::{
core::{
errors::RouterResult, fraud_check::frm_core_types::FrmFulfillmentRequest,
payments::helpers, utils as core_utils,
},
errors,
types::{
domain,
fraud_check::{FraudCheckFulfillmentData, FrmFulfillmentRouterData},
storage, ConnectorAuthType, ErrorResponse, PaymentAddress, RouterData,
},
utils, SessionState,
};
pub async fn construct_fulfillment_router_data<'a>(
state: &'a SessionState,
payment_intent: &'a storage::PaymentIntent,
payment_attempt: &storage::PaymentAttempt,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
connector: String,
fulfillment_request: FrmFulfillmentRequest,
) -> RouterResult<FrmFulfillmentRouterData> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user/theme.rs | crate: router
use api_models::user::theme as theme_api;
use hyperswitch_domain_models::api::ApplicationResponse;
use crate::{
core::errors::{StorageErrorExt, UserErrors, UserResponse},
routes::SessionState,
utils::user::theme as theme_utils,
};
pub async fn update_theme(
state: SessionState,
theme_id: String,
request: theme_api::UpdateThemeRequest,
) -> UserResponse<theme_api::GetThemeResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user/theme.rs | crate: router
use api_models::user::theme as theme_api;
use common_utils::{
ext_traits::{ByteSliceExt, Encode},
types::theme::ThemeLineage,
};
use diesel_models::user::theme::ThemeNew;
use hyperswitch_domain_models::api::ApplicationResponse;
use uuid::Uuid;
use crate::{
core::errors::{StorageErrorExt, UserErrors, UserResponse},
routes::SessionState,
utils::user::theme as theme_utils,
};
pub async fn create_theme(
state: SessionState,
request: theme_api::CreateThemeRequest,
) -> UserResponse<theme_api::GetThemeResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user/theme.rs | crate: router
use api_models::user::theme as theme_api;
use common_utils::{
ext_traits::{ByteSliceExt, Encode},
types::theme::ThemeLineage,
};
use diesel_models::user::theme::ThemeNew;
use hyperswitch_domain_models::api::ApplicationResponse;
use crate::{
core::errors::{StorageErrorExt, UserErrors, UserResponse},
routes::SessionState,
utils::user::theme as theme_utils,
};
pub async fn get_theme_using_theme_id(
state: SessionState,
theme_id: String,
) -> UserResponse<theme_api::GetThemeResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user/theme.rs | crate: router
use api_models::user::theme as theme_api;
use common_utils::{
ext_traits::{ByteSliceExt, Encode},
types::theme::ThemeLineage,
};
use diesel_models::user::theme::ThemeNew;
use hyperswitch_domain_models::api::ApplicationResponse;
use crate::{
core::errors::{StorageErrorExt, UserErrors, UserResponse},
routes::SessionState,
utils::user::theme as theme_utils,
};
pub async fn get_theme_using_lineage(
state: SessionState,
lineage: ThemeLineage,
) -> UserResponse<theme_api::GetThemeResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user/theme.rs | crate: router
use api_models::user::theme as theme_api;
use common_utils::{
ext_traits::{ByteSliceExt, Encode},
types::theme::ThemeLineage,
};
use diesel_models::user::theme::ThemeNew;
use hyperswitch_domain_models::api::ApplicationResponse;
use crate::{
core::errors::{StorageErrorExt, UserErrors, UserResponse},
routes::SessionState,
utils::user::theme as theme_utils,
};
pub async fn delete_theme(
state: SessionState,
theme_id: String,
lineage: ThemeLineage,
) -> UserResponse<()> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/user/theme.rs | crate: router
use api_models::user::theme as theme_api;
use hyperswitch_domain_models::api::ApplicationResponse;
use crate::{
core::errors::{StorageErrorExt, UserErrors, UserResponse},
routes::SessionState,
utils::user::theme as theme_utils,
};
pub async fn upload_file_to_theme_storage(
state: SessionState,
theme_id: String,
request: theme_api::UploadFileRequest,
) -> UserResponse<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/verification/utils.rs | crate: router
use common_utils::{errors::CustomResult, id_type::PaymentId};
use crate::{
core::{
errors::{self, utils::StorageErrorExt},
utils,
},
logger,
routes::SessionState,
services::authentication::AuthenticationData,
types::{self, storage},
};
pub async fn check_if_profile_id_is_present_in_payment_intent(
payment_id: PaymentId,
state: &SessionState,
auth_data: &AuthenticationData,
) -> CustomResult<(), errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/verification/utils.rs | crate: router
use common_utils::{errors::CustomResult, id_type::PaymentId};
use error_stack::{Report, ResultExt};
use crate::{
core::{
errors::{self, utils::StorageErrorExt},
utils,
},
logger,
routes::SessionState,
services::authentication::AuthenticationData,
types::{self, storage},
};
pub fn log_applepay_verification_response_if_error(
response: &Result<Result<types::Response, types::Response>, Report<errors::ApiClientError>>,
) {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/verification/utils.rs | crate: router
use common_utils::{errors::CustomResult, id_type::PaymentId};
use crate::{
core::{
errors::{self, utils::StorageErrorExt},
utils,
},
logger,
routes::SessionState,
services::authentication::AuthenticationData,
types::{self, storage},
};
pub async fn check_existence_and_add_domain_to_db(
state: &SessionState,
merchant_id: common_utils::id_type::MerchantId,
profile_id_from_auth_layer: Option<common_utils::id_type::ProfileId>,
merchant_connector_id: common_utils::id_type::MerchantConnectorAccountId,
domain_from_req: Vec<String>,
) -> CustomResult<Vec<String>, errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/routing/transformers.rs | crate: router
use api_models::routing::{
MerchantRoutingAlgorithm, RoutingAlgorithm as Algorithm, RoutingAlgorithmKind,
RoutingDictionaryRecord,
};
use crate::{
core::{errors, routing},
types::transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
};
fn from(value: &routing::TransactionData<'_>) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/routing/transformers.rs | crate: router
use api_models::routing::{
MerchantRoutingAlgorithm, RoutingAlgorithm as Algorithm, RoutingAlgorithmKind,
RoutingDictionaryRecord,
};
fn foreign_from(value: RoutingAlgorithmKind) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/routing/transformers.rs | crate: router
use api_models::routing::{
MerchantRoutingAlgorithm, RoutingAlgorithm as Algorithm, RoutingAlgorithmKind,
RoutingDictionaryRecord,
};
use diesel_models::{
enums as storage_enums,
routing_algorithm::{RoutingAlgorithm, RoutingProfileMetadata},
};
fn foreign_from(value: storage_enums::RoutingAlgorithmKind) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/routing/transformers.rs | crate: router
use api_models::routing::{
MerchantRoutingAlgorithm, RoutingAlgorithm as Algorithm, RoutingAlgorithmKind,
RoutingDictionaryRecord,
};
use diesel_models::{
enums as storage_enums,
routing_algorithm::{RoutingAlgorithm, RoutingProfileMetadata},
};
fn foreign_try_from(value: RoutingAlgorithm) -> Result<Self, Self::Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/routing/transformers.rs | crate: router
use api_models::routing::{
MerchantRoutingAlgorithm, RoutingAlgorithm as Algorithm, RoutingAlgorithmKind,
RoutingDictionaryRecord,
};
use diesel_models::{
enums as storage_enums,
routing_algorithm::{RoutingAlgorithm, RoutingProfileMetadata},
};
fn foreign_from(value: RoutingAlgorithm) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/routing/transformers.rs | crate: router
use diesel_models::{
enums as storage_enums,
routing_algorithm::{RoutingAlgorithm, RoutingProfileMetadata},
};
fn foreign_from(value: RoutingProfileMetadata) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/errors/error_handlers.rs | crate: router
use actix_web::{body, dev::ServiceResponse, middleware::ErrorHandlerResponse, ResponseError};
use http::StatusCode;
use super::ApiErrorResponse;
use crate::logger;
pub fn custom_error_handlers<B: body::MessageBody + 'static>(
res: ServiceResponse<B>,
) -> actix_web::Result<ErrorHandlerResponse<B>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/webhooks/types.rs | crate: router
use crate::{core::errors, headers, services::request::Maskable, types::storage::enums};
fn add_webhook_header(header: &mut Vec<(String, Maskable<String>)>, signature: String) {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/webhooks/incoming_v2.rs | crate: router
use std::{marker::PhantomData, str::FromStr, time::Instant};
use api_models::webhooks::{self, WebhookResponseTracker};
use common_utils::{
errors::ReportSwitchExt, events::ApiEventsType, types::keymanager::KeyManagerState,
};
use crate::{
core::{
api_locking,
errors::{self, ConnectorErrorExt, CustomResult, RouterResponse, StorageErrorExt},
metrics,
payments::{
self,
transformers::{GenerateResponse, ToResponse},
},
webhooks::utils::construct_webhook_router_data,
},
db::StorageInterface,
events::api_logs::ApiEvent,
logger,
routes::{
app::{ReqState, SessionStateInfo},
lock_utils, SessionState,
},
services::{
self, authentication as auth, connector_integration_interface::ConnectorEnum,
ConnectorValidation,
},
types::{
api::{self, ConnectorData, GetToken, IncomingWebhook},
domain,
storage::enums,
transformers::ForeignInto,
},
};
fn get_connector_by_connector_name(
state: &SessionState,
connector_name: &str,
merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
) -> CustomResult<(ConnectorEnum, String), errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/webhooks/incoming_v2.rs | crate: router
use std::{marker::PhantomData, str::FromStr, time::Instant};
use common_utils::{
errors::ReportSwitchExt, events::ApiEventsType, types::keymanager::KeyManagerState,
};
use hyperswitch_domain_models::{
payments::{HeaderPayload, PaymentStatusData},
router_request_types::VerifyWebhookSourceRequestData,
router_response_types::{VerifyWebhookSourceResponseData, VerifyWebhookStatus},
};
use hyperswitch_interfaces::webhooks::IncomingWebhookRequestDetails;
use crate::{
core::{
api_locking,
errors::{self, ConnectorErrorExt, CustomResult, RouterResponse, StorageErrorExt},
metrics,
payments::{
self,
transformers::{GenerateResponse, ToResponse},
},
webhooks::utils::construct_webhook_router_data,
},
db::StorageInterface,
events::api_logs::ApiEvent,
logger,
routes::{
app::{ReqState, SessionStateInfo},
lock_utils, SessionState,
},
services::{
self, authentication as auth, connector_integration_interface::ConnectorEnum,
ConnectorValidation,
},
types::{
api::{self, ConnectorData, GetToken, IncomingWebhook},
domain,
storage::enums,
transformers::ForeignInto,
},
};
async fn verify_webhook_source_verification_call(
connector: ConnectorEnum,
state: &SessionState,
merchant_account: &domain::MerchantAccount,
merchant_connector_account: domain::MerchantConnectorAccount,
connector_name: &str,
request_details: &IncomingWebhookRequestDetails<'_>,
) -> CustomResult<bool, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/webhooks/incoming_v2.rs | crate: router
use std::{marker::PhantomData, str::FromStr, time::Instant};
use actix_web::FromRequest;
use common_utils::{
errors::ReportSwitchExt, events::ApiEventsType, types::keymanager::KeyManagerState,
};
use router_env::{instrument, tracing, tracing_actix_web::RequestId};
use super::{types, utils, MERCHANT_ID};
use crate::{
core::{
api_locking,
errors::{self, ConnectorErrorExt, CustomResult, RouterResponse, StorageErrorExt},
metrics,
payments::{
self,
transformers::{GenerateResponse, ToResponse},
},
webhooks::utils::construct_webhook_router_data,
},
db::StorageInterface,
events::api_logs::ApiEvent,
logger,
routes::{
app::{ReqState, SessionStateInfo},
lock_utils, SessionState,
},
services::{
self, authentication as auth, connector_integration_interface::ConnectorEnum,
ConnectorValidation,
},
types::{
api::{self, ConnectorData, GetToken, IncomingWebhook},
domain,
storage::enums,
transformers::ForeignInto,
},
};
pub async fn incoming_webhooks_wrapper<W: types::OutgoingWebhookType>(
flow: &impl router_env::types::FlowMetric,
state: SessionState,
req_state: ReqState,
req: &actix_web::HttpRequest,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
connector_id: &common_utils::id_type::MerchantConnectorAccountId,
body: actix_web::web::Bytes,
is_relay_webhook: bool,
) -> RouterResponse<serde_json::Value> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/webhooks/incoming_v2.rs | crate: router
use common_utils::{
errors::ReportSwitchExt, events::ApiEventsType, types::keymanager::KeyManagerState,
};
use crate::{
core::{
api_locking,
errors::{self, ConnectorErrorExt, CustomResult, RouterResponse, StorageErrorExt},
metrics,
payments::{
self,
transformers::{GenerateResponse, ToResponse},
},
webhooks::utils::construct_webhook_router_data,
},
db::StorageInterface,
events::api_logs::ApiEvent,
logger,
routes::{
app::{ReqState, SessionStateInfo},
lock_utils, SessionState,
},
services::{
self, authentication as auth, connector_integration_interface::ConnectorEnum,
ConnectorValidation,
},
types::{
api::{self, ConnectorData, GetToken, IncomingWebhook},
domain,
storage::enums,
transformers::ForeignInto,
},
};
/// This function fetches the merchant connector account and connector details
async fn fetch_mca_and_connector(
state: &SessionState,
connector_id: &common_utils::id_type::MerchantConnectorAccountId,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<(domain::MerchantConnectorAccount, ConnectorEnum, String), errors::ApiErrorResponse>
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/webhooks/incoming_v2.rs | crate: router
use std::{marker::PhantomData, str::FromStr, time::Instant};
use api_models::webhooks::{self, WebhookResponseTracker};
use common_utils::{
errors::ReportSwitchExt, events::ApiEventsType, types::keymanager::KeyManagerState,
};
use hyperswitch_domain_models::{
payments::{HeaderPayload, PaymentStatusData},
router_request_types::VerifyWebhookSourceRequestData,
router_response_types::{VerifyWebhookSourceResponseData, VerifyWebhookStatus},
};
use crate::{
core::{
api_locking,
errors::{self, ConnectorErrorExt, CustomResult, RouterResponse, StorageErrorExt},
metrics,
payments::{
self,
transformers::{GenerateResponse, ToResponse},
},
webhooks::utils::construct_webhook_router_data,
},
db::StorageInterface,
events::api_logs::ApiEvent,
logger,
routes::{
app::{ReqState, SessionStateInfo},
lock_utils, SessionState,
},
services::{
self, authentication as auth, connector_integration_interface::ConnectorEnum,
ConnectorValidation,
},
types::{
api::{self, ConnectorData, GetToken, IncomingWebhook},
domain,
storage::enums,
transformers::ForeignInto,
},
};
async fn get_trackers_response_for_payment_get_operation<F>(
db: &dyn StorageInterface,
payment_id: &api::PaymentIdType,
profile_id: &common_utils::id_type::ProfileId,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
storage_scheme: enums::MerchantStorageScheme,
) -> errors::RouterResult<payments::operations::GetTrackerResponse<PaymentStatusData<F>>>
where
F: Clone,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/webhooks/incoming_v2.rs | crate: router
.get_webhook_api_response(&request_details, None)
.switch()
.attach_printable("Could not get incoming webhook api response from connector")?;
let serialized_request = event_object
.masked_serialize()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Could not convert webhook effect to string")?;
Ok((response, webhook_effect, serialized_request))
}
#[instrument(skip_all)]
async fn payments_incoming_webhook_flow(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
webhook_details: api::IncomingWebhookDetails,
source_verified: bool,
) -> CustomResult<WebhookResponseTracker, errors::ApiErrorResponse> {
let consume_or_trigger_flow = if source_verified {
payments::CallConnectorAction::HandleResponse(webhook_details.resource_object)
} else {
payments::CallConnectorAction::Trigger
async fn payments_incoming_webhook_flow(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
webhook_details: api::IncomingWebhookDetails,
source_verified: bool,
) -> CustomResult<WebhookResponseTracker, errors::ApiErrorResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/webhooks/incoming_v2.rs | crate: router
auth_type,
None,
api_event,
req,
req.method(),
);
state.event_handler().log_event(&api_event);
Ok(application_response)
}
#[instrument(skip_all)]
#[allow(clippy::too_many_arguments)]
async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(
state: SessionState,
req_state: ReqState,
req: &actix_web::HttpRequest,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
connector_id: &common_utils::id_type::MerchantConnectorAccountId,
body: actix_web::web::Bytes,
_is_relay_webhook: bool,
) -> errors::RouterResult<(
services::ApplicationResponse<serde_json::Value>,
WebhookResponseTracker,
async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(
state: SessionState,
req_state: ReqState,
req: &actix_web::HttpRequest,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
connector_id: &common_utils::id_type::MerchantConnectorAccountId,
body: actix_web::web::Bytes,
_is_relay_webhook: bool,
) -> errors::RouterResult<(
services::ApplicationResponse<serde_json::Value>,
WebhookResponseTracker,
serde_json::Value,
)> {
{metrics::WEBHOOK_INCOMING_COUNT.add(
1,
router_env::metric_attributes!((MERCHANT_ID, merchant_account.get_id().clone())),
);<|fim_suffix|>
<|fim_middle|>
Ok((response, webhook_effect, serialized_request))}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payment_methods/tokenize.rs | crate: router
use api_models::{enums as api_enums, payment_methods as payment_methods_api};
use common_utils::{
crypto::Encryptable,
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
use masking::{ExposeInterface, Secret};
use router_env::logger;
use crate::{
core::payment_methods::{
cards::{add_card_to_hs_locker, create_encrypted_data, tokenize_card_flow},
network_tokenization, transformers as pm_transformers,
},
errors::{self, RouterResult},
services,
types::{api, domain, payment_methods as pm_types},
SessionState,
};
type NetworkTokenizationResponse = (pm_types::CardNetworkTokenResponsePayload, Option<String>);
async fn store_network_token_in_locker(
&self,
network_token: &NetworkTokenizationResponse,
customer_id: &id_type::CustomerId,
card_holder_name: Option<Secret<String>>,
nick_name: Option<Secret<String>>,
) -> RouterResult<pm_transformers::StoreCardRespPayload> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payment_methods/tokenize.rs | crate: router
use api_models::{enums as api_enums, payment_methods as payment_methods_api};
use error_stack::{report, ResultExt};
use crate::{
core::payment_methods::{
cards::{add_card_to_hs_locker, create_encrypted_data, tokenize_card_flow},
network_tokenization, transformers as pm_transformers,
},
errors::{self, RouterResult},
services,
types::{api, domain, payment_methods as pm_types},
SessionState,
};
use rdkafka::message::ToBytes;
type NetworkTokenizationResponse = (pm_types::CardNetworkTokenResponsePayload, Option<String>);
fn validate_card_network(
&self,
optional_card_network: Option<&api_enums::CardNetwork>,
) -> RouterResult<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payment_methods/tokenize.rs | crate: router
use api_models::{enums as api_enums, payment_methods as payment_methods_api};
use cards::CardNumber;
use crate::{
core::payment_methods::{
cards::{add_card_to_hs_locker, create_encrypted_data, tokenize_card_flow},
network_tokenization, transformers as pm_transformers,
},
errors::{self, RouterResult},
services,
types::{api, domain, payment_methods as pm_types},
SessionState,
};
type NetworkTokenizationResponse = (pm_types::CardNetworkTokenResponsePayload, Option<String>);
async fn fetch_bin_details_and_validate_card_network(
&self,
card_number: CardNumber,
card_issuer: Option<&String>,
card_network: Option<&api_enums::CardNetwork>,
card_type: Option<&api_models::payment_methods::CardType>,
card_issuing_country: Option<&String>,
) -> RouterResult<Option<diesel_models::CardInfo>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payment_methods/tokenize.rs | crate: router
use actix_multipart::form::{bytes::Bytes, text::Text, MultipartForm};
use api_models::{enums as api_enums, payment_methods as payment_methods_api};
use cards::CardNumber;
use common_utils::{
crypto::Encryptable,
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::router_request_types as domain_request_types;
use masking::{ExposeInterface, Secret};
use router_env::logger;
use super::migration;
use crate::{
core::payment_methods::{
cards::{add_card_to_hs_locker, create_encrypted_data, tokenize_card_flow},
network_tokenization, transformers as pm_transformers,
},
errors::{self, RouterResult},
services,
types::{api, domain, payment_methods as pm_types},
SessionState,
};
pub use card_executor::*;
pub use payment_method_executor::*;
use rdkafka::message::ToBytes;
pub async fn tokenize_cards(
state: &SessionState,
records: Vec<payment_methods_api::CardNetworkTokenizeRequest>,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> errors::RouterResponse<Vec<payment_methods_api::CardNetworkTokenizeResponse>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payment_methods/tokenize.rs | crate: router
use api_models::{enums as api_enums, payment_methods as payment_methods_api};
use common_utils::{
crypto::Encryptable,
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
use router_env::logger;
use crate::{
core::payment_methods::{
cards::{add_card_to_hs_locker, create_encrypted_data, tokenize_card_flow},
network_tokenization, transformers as pm_transformers,
},
errors::{self, RouterResult},
services,
types::{api, domain, payment_methods as pm_types},
SessionState,
};
pub use card_executor::*;
pub use payment_method_executor::*;
pub fn parse_csv(
merchant_id: &id_type::MerchantId,
data: &[u8],
) -> csv::Result<Vec<payment_methods_api::CardNetworkTokenizeRequest>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payment_methods/tokenize.rs | crate: router
use common_utils::{
crypto::Encryptable,
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
use error_stack::{report, ResultExt};
use masking::{ExposeInterface, Secret};
use router_env::logger;
use crate::{
core::payment_methods::{
cards::{add_card_to_hs_locker, create_encrypted_data, tokenize_card_flow},
network_tokenization, transformers as pm_transformers,
},
errors::{self, RouterResult},
services,
types::{api, domain, payment_methods as pm_types},
SessionState,
};
type NetworkTokenizationResponse = (pm_types::CardNetworkTokenResponsePayload, Option<String>);
async fn tokenize_card(
&self,
customer_id: &id_type::CustomerId,
card: &domain::CardDetail,
optional_cvc: Option<Secret<String>>,
) -> RouterResult<NetworkTokenizationResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payment_methods/tokenize.rs | crate: router
use common_utils::{
crypto::Encryptable,
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
use masking::{ExposeInterface, Secret};
use router_env::logger;
use crate::{
core::payment_methods::{
cards::{add_card_to_hs_locker, create_encrypted_data, tokenize_card_flow},
network_tokenization, transformers as pm_transformers,
},
errors::{self, RouterResult},
services,
types::{api, domain, payment_methods as pm_types},
SessionState,
};
type NetworkTokenizationResponse = (pm_types::CardNetworkTokenResponsePayload, Option<String>);
async fn encrypt_network_token(
&self,
network_token_details: &NetworkTokenizationResponse,
card_details: &domain::CardDetail,
saved_to_locker: bool,
) -> RouterResult<Encryptable<Secret<serde_json::Value>>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payment_methods/tokenize.rs | crate: router
use common_utils::{
crypto::Encryptable,
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
use masking::{ExposeInterface, Secret};
use router_env::logger;
use crate::{
core::payment_methods::{
cards::{add_card_to_hs_locker, create_encrypted_data, tokenize_card_flow},
network_tokenization, transformers as pm_transformers,
},
errors::{self, RouterResult},
services,
types::{api, domain, payment_methods as pm_types},
SessionState,
};
async fn encrypt_card(
&self,
card_details: &domain::CardDetail,
saved_to_locker: bool,
) -> RouterResult<Encryptable<Secret<serde_json::Value>>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payment_methods/tokenize.rs | crate: router
use hyperswitch_domain_models::router_request_types as domain_request_types;
use crate::{
core::payment_methods::{
cards::{add_card_to_hs_locker, create_encrypted_data, tokenize_card_flow},
network_tokenization, transformers as pm_transformers,
},
errors::{self, RouterResult},
services,
types::{api, domain, payment_methods as pm_types},
SessionState,
};
fn new(
state: &'a SessionState,
key_store: &'a domain::MerchantKeyStore,
merchant_account: &'a domain::MerchantAccount,
data: &'a D,
customer: &'a domain_request_types::CustomerDetails,
) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payment_methods/tokenize.rs | crate: router
use actix_multipart::form::{bytes::Bytes, text::Text, MultipartForm};
use api_models::{enums as api_enums, payment_methods as payment_methods_api};
use common_utils::{
crypto::Encryptable,
id_type,
transformers::{ForeignFrom, ForeignTryFrom},
};
use router_env::logger;
use crate::{
core::payment_methods::{
cards::{add_card_to_hs_locker, create_encrypted_data, tokenize_card_flow},
network_tokenization, transformers as pm_transformers,
},
errors::{self, RouterResult},
services,
types::{api, domain, payment_methods as pm_types},
SessionState,
};
pub use card_executor::*;
pub use payment_method_executor::*;
use rdkafka::message::ToBytes;
pub fn get_tokenize_card_form_records(
form: CardNetworkTokenizeForm,
) -> Result<
(
id_type::MerchantId,
Vec<payment_methods_api::CardNetworkTokenizeRequest>,
),
errors::ApiErrorResponse,
> {
{
Ok(records) => {
logger::info!("Parsed a total of {} records", records.len());
Ok((form.merchant_id.0, records))
}<|fim_suffix|>
<|fim_middle|>
Err(e) => {
logger::error!("Failed to parse CSV: {:?}", e);
Err(errors::ApiErrorResponse::PreconditionFailed {
message: e.to_string(),
})
}
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/pm_auth/helpers.rs | crate: router
use pm_auth::types::{self as pm_auth_types, api::BoxedPaymentAuthConnector};
use crate::{
core::errors::{self, ApiErrorResponse},
types::{self, domain, transformers::ForeignTryFrom},
};
pub fn get_connector_auth_type(
merchant_connector_account: domain::MerchantConnectorAccount,
) -> errors::CustomResult<pm_auth_types::ConnectorAuthType, ApiErrorResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/authentication/types.rs | crate: router
pub use hyperswitch_domain_models::router_request_types::authentication::{
AcquirerDetails, ExternalThreeDSConnectorMetadata, PreAuthenticationData, ThreeDsMethodData,
};
use crate::{
core::errors,
types::{storage, transformers::ForeignTryFrom},
utils::OptionExt,
};
fn foreign_try_from(authentication: &storage::Authentication) -> Result<Self, Self::Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/authentication/utils.rs | crate: router
use crate::{
consts,
core::{
errors::{self, ConnectorErrorExt, StorageErrorExt},
payments,
},
errors::RouterResult,
routes::SessionState,
services::{self, execute_connector_processing_step},
types::{
api, authentication::AuthenticationResponseData, domain, storage,
transformers::ForeignFrom, RouterData,
},
utils::OptionExt,
};
pub async fn get_authentication_connector_data(
state: &SessionState,
key_store: &domain::MerchantKeyStore,
business_profile: &domain::Profile,
) -> RouterResult<(
common_enums::AuthenticationConnectors,
payments::helpers::MerchantConnectorAccountType,
)> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.