text
stringlengths 70
351k
| source
stringclasses 4
values |
|---|---|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use crate::types::domain::behaviour::Conversion;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn complete_payout_retrieve(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
connector_call_type: api::ConnectorCallType,
payout_data: &mut PayoutData,
) -> RouterResult<()> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use crate::types::domain::behaviour::Conversion;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn create_recipient(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
connector_data: &api::ConnectorData,
payout_data: &mut PayoutData,
) -> RouterResult<()> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use common_utils::{
consts,
ext_traits::{AsyncExt, ValueExt},
id_type::CustomerId,
link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus},
types::{MinorUnit, UnifiedCode, UnifiedMessage},
};
use crate::types::domain::behaviour::Conversion;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn payouts_list_core(
_state: SessionState,
_merchant_account: domain::MerchantAccount,
_profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,
_key_store: domain::MerchantKeyStore,
_constraints: payouts::PayoutListConstraints,
) -> RouterResponse<payouts::PayoutListResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use std::{
collections::{HashMap, HashSet},
vec::IntoIter,
};
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub fn get_next_connector(
connectors: &mut IntoIter<api::ConnectorData>,
) -> RouterResult<api::ConnectorData> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
{
Ok(business_profile)
} else {
db.find_business_profile_by_profile_id(key_manager_state, merchant_key_store, profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
})
}
}
#[allow(clippy::too_many_arguments)]
pub async fn create_payout_link(
state: &SessionState,
business_profile: &domain::Profile,
customer_id: &CustomerId,
merchant_id: &common_utils::id_type::MerchantId,
req: &payouts::PayoutCreateRequest,
payout_id: &str,
locale: &str,
) -> RouterResult<PayoutLink> {
let payout_link_config_req = req.payout_link_config.to_owned();
// Fetch all configs
let default_config = &state.conf.generic_link.payout_link;
pub async fn create_payout_link(
state: &SessionState,
business_profile: &domain::Profile,
customer_id: &CustomerId,
merchant_id: &common_utils::id_type::MerchantId,
req: &payouts::PayoutCreateRequest,
payout_id: &str,
locale: &str,
) -> RouterResult<PayoutLink> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use hyperswitch_domain_models::payment_methods::PaymentMethod;
use crate::types::domain::behaviour::Conversion;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn response_handler(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
payout_data: &PayoutData,
) -> RouterResponse<payouts::PayoutCreateResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use api_models::payments as payment_enums;
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use common_utils::{
consts,
ext_traits::{AsyncExt, ValueExt},
id_type::CustomerId,
link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus},
types::{MinorUnit, UnifiedCode, UnifiedMessage},
};
use diesel_models::{
enums as storage_enums,
generic_link::{GenericLinkNew, PayoutLink},
CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord,
};
use crate::types::domain::behaviour::Conversion;
use crate::types::PayoutActionData;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn cancel_payout(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
connector_data: &api::ConnectorData,
payout_data: &mut PayoutData,
) -> RouterResult<()> {
// 1. Form Router data
let router_data = core_utils::construct_payout_router_data(
state,
connector_data,
merchant_account,
payout_data,
)
.await?;
// 2. Fetch connector integration details
let connector_integration: services::BoxedPayoutConnectorIntegrationInterface<
api::PoCancel,
types::PayoutsData,
types::PayoutsResponseData,
> = connector_data.connector.get_connector_integration();
// 3. Call connector service
let router_data_resp = services::execute_connector_processing_step(
state,
connector_integration,
&router_data,
payments::CallConnectorAction::Trigger,
None,
)
.await
.to_payout_failed_response()?;
// 4. Process data returned by the connector
let db = &*state.store;
match router_data_resp.response {
Ok(payout_response_data) => {
let status = payout_response_data
.status
.unwrap_or(payout_data.payout_attempt.status.to_owned());
let updated_payout_attempt = storage::PayoutAttemptUpdate::StatusUpdate {
connector_payout_id: payout_response_data.connector_payout_id,
status,
error_code: None,
error_message: None,
is_eligible: payout_response_data.payout_eligible,
unified_code: None,
unified_message: None,
};
payout_data.payout_attempt = db
.update_payout_attempt(
&payout_data.payout_attempt,
updated_payout_attempt,
&payout_data.payouts,
merchant_account.storage_scheme,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error updating payout_attempt in db")?;
payout_data.payouts = db
.update_payout(
&payout_data.payouts,
storage::PayoutsUpdate::StatusUpdate { status },
&payout_data.payout_attempt,
merchant_account.storage_scheme,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error updating payouts in db")?;
}
Err(err) => {
let status = storage_enums::PayoutStatus::Failed;
let (error_code, error_message) = (Some(err.code), Some(err.message));
let (unified_code, unified_message) = helpers::get_gsm_record(
state,
error_code.clone(),
error_message.clone(),
payout_data.payout_attempt.connector.clone(),
consts::PAYOUT_FLOW_STR,
)
.await
.map_or((None, None), |gsm| (gsm.unified_code, gsm.unified_message));
let updated_payout_attempt = storage::PayoutAttemptUpdate::StatusUpdate {
connector_payout_id: payout_data.payout_attempt.connector_payout_id.to_owned(),
status,
error_code,
error_message,
is_eligible: None,
unified_code: unified_code
.map(UnifiedCode::try_from)
.transpose()
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "unified_code",
})?,
unified_message: unified_message
.map(UnifiedMessage::try_from)
.transpose()
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "unified_message",
})?,
};
payout_data.payout_attempt = db
.update_payout_attempt(
&payout_data.payout_attempt,
updated_payout_attempt,
&payout_data.payouts,
merchant_account.storage_scheme,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error updating payout_attempt in db")?;
payout_data.payouts = db
.update_payout(
&payout_data.payouts,
storage::PayoutsUpdate::StatusUpdate { status },
&payout_data.payout_attempt,
merchant_account.storage_scheme,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error updating payouts in db")?;
}
};
Ok(())
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use common_utils::{
consts,
ext_traits::{AsyncExt, ValueExt},
id_type::CustomerId,
link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus},
types::{MinorUnit, UnifiedCode, UnifiedMessage},
};
use router_env::{instrument, logger, tracing, Env};
use crate::types::domain::behaviour::Conversion;
use crate::types::PayoutActionData;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn update_retrieve_payout_tracker<F, T>(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
payout_data: &mut PayoutData,
payout_router_data: &types::RouterData<F, T, types::PayoutsResponseData>,
) -> RouterResult<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use api_models::payments as payment_enums;
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use common_utils::{
consts,
ext_traits::{AsyncExt, ValueExt},
id_type::CustomerId,
link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus},
types::{MinorUnit, UnifiedCode, UnifiedMessage},
};
use diesel_models::{
enums as storage_enums,
generic_link::{GenericLinkNew, PayoutLink},
CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord,
};
use error_stack::{report, ResultExt};
use serde_json;
use crate::types::domain::behaviour::Conversion;
use crate::types::PayoutActionData;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn create_payout(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
connector_data: &api::ConnectorData,
payout_data: &mut PayoutData,
) -> RouterResult<()> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use api_models::payments as payment_enums;
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use common_utils::{
consts,
ext_traits::{AsyncExt, ValueExt},
id_type::CustomerId,
link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus},
types::{MinorUnit, UnifiedCode, UnifiedMessage},
};
use diesel_models::{
enums as storage_enums,
generic_link::{GenericLinkNew, PayoutLink},
CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord,
};
use error_stack::{report, ResultExt};
use serde_json;
use crate::types::domain::behaviour::Conversion;
use crate::types::PayoutActionData;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn check_payout_eligibility(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
connector_data: &api::ConnectorData,
payout_data: &mut PayoutData,
) -> RouterResult<()> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use diesel_models::{
enums as storage_enums,
generic_link::{GenericLinkNew, PayoutLink},
CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord,
};
use crate::types::domain::behaviour::Conversion;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn call_connector_payout(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
connector_data: &api::ConnectorData,
payout_data: &mut PayoutData,
) -> RouterResult<()> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use api_models::payments as payment_enums;
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use common_utils::{
consts,
ext_traits::{AsyncExt, ValueExt},
id_type::CustomerId,
link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus},
types::{MinorUnit, UnifiedCode, UnifiedMessage},
};
use diesel_models::{
enums as storage_enums,
generic_link::{GenericLinkNew, PayoutLink},
CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord,
};
use futures::future::join_all;
use router_env::{instrument, logger, tracing, Env};
use crate::types::domain::behaviour::Conversion;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn payouts_filtered_list_core(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,
key_store: domain::MerchantKeyStore,
filters: payouts::PayoutListFilterConstraints,
) -> RouterResponse<payouts::PayoutListResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use api_models::payments as payment_enums;
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use common_utils::{
consts,
ext_traits::{AsyncExt, ValueExt},
id_type::CustomerId,
link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus},
types::{MinorUnit, UnifiedCode, UnifiedMessage},
};
use diesel_models::{
enums as storage_enums,
generic_link::{GenericLinkNew, PayoutLink},
CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord,
};
use hyperswitch_domain_models::payment_methods::PaymentMethod;
use router_env::{instrument, logger, tracing, Env};
use scheduler::utils as pt_utils;
use crate::types::domain::behaviour::Conversion;
use crate::types::PayoutActionData;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn payouts_list_core(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,
key_store: domain::MerchantKeyStore,
constraints: payouts::PayoutListConstraints,
) -> RouterResponse<payouts::PayoutListResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use error_stack::{report, ResultExt};
use serde_json;
use crate::types::domain::behaviour::Conversion;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn payouts_fulfill_core(
state: SessionState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
req: payouts::PayoutActionRequest,
) -> RouterResponse<payouts::PayoutCreateResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use diesel_models::{
enums as storage_enums,
generic_link::{GenericLinkNew, PayoutLink},
CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord,
};
use error_stack::{report, ResultExt};
use crate::types::domain::behaviour::Conversion;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn payouts_cancel_core(
state: SessionState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
req: payouts::PayoutActionRequest,
) -> RouterResponse<payouts::PayoutCreateResponse> {
{
Some(connector) => api::ConnectorData::get_payout_connector_by_name(
&state.conf.connectors,
connector,
api::GetToken::Connector,
payout_attempt.merchant_connector_id.clone(),
)
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to get the connector data")?,<|fim_suffix|>
<|fim_middle|>
_ => Err(errors::ApplicationError::InvalidConfigurationValueError(
"Connector not found in payout_attempt - should not reach here".to_string(),
))
.change_context(errors::ApiErrorResponse::MissingRequiredField {
field_name: "connector",
})
.attach_printable("Connector not found for payout cancellation")?,
}
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use common_enums::PayoutRetryType;
use retry::GsmValidation;
use crate::types::domain::behaviour::Conversion;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn make_connector_decision(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
connector_call_type: api::ConnectorCallType,
payout_data: &mut PayoutData,
) -> RouterResult<()> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use std::{
collections::{HashMap, HashSet},
vec::IntoIter,
};
use api_models::payments as payment_enums;
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use common_utils::{
consts,
ext_traits::{AsyncExt, ValueExt},
id_type::CustomerId,
link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus},
types::{MinorUnit, UnifiedCode, UnifiedMessage},
};
use hyperswitch_domain_models::payment_methods::PaymentMethod;
use scheduler::utils as pt_utils;
use crate::types::domain::behaviour::Conversion;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn make_payout_data(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
auth_profile_id: Option<common_utils::id_type::ProfileId>,
key_store: &domain::MerchantKeyStore,
req: &payouts::PayoutRequest,
locale: &str,
) -> RouterResult<PayoutData> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
_profile_id: &str,
_stored_payout_method_data: Option<&payouts::PayoutMethodData>,
_locale: &str,
_customer: Option<&domain::Customer>,
_payment_method: Option<PaymentMethod>,
) -> RouterResult<PayoutData> {
todo!()
}
// DB entries
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[allow(clippy::too_many_arguments)]
pub async fn payout_create_db_entries(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
req: &payouts::PayoutCreateRequest,
payout_id: &String,
profile_id: &common_utils::id_type::ProfileId,
stored_payout_method_data: Option<&payouts::PayoutMethodData>,
locale: &str,
customer: Option<&domain::Customer>,
payment_method: Option<PaymentMethod>,
) -> RouterResult<PayoutData> {
let db = &*state.store;
pub async fn payout_create_db_entries(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
req: &payouts::PayoutCreateRequest,
payout_id: &String,
profile_id: &common_utils::id_type::ProfileId,
stored_payout_method_data: Option<&payouts::PayoutMethodData>,
locale: &str,
customer: Option<&domain::Customer>,
payment_method: Option<PaymentMethod>,
) -> RouterResult<PayoutData> {
{
Some(true) => storage_enums::PayoutStatus::RequiresCreation,<|fim_suffix|>
<|fim_middle|>
_ => storage_enums::PayoutStatus::RequiresConfirmation,
}
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
use api_models::payments as payment_enums;
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use common_utils::{
consts,
ext_traits::{AsyncExt, ValueExt},
id_type::CustomerId,
link_utils::{GenericLinkStatus, GenericLinkUiConfig, PayoutLinkData, PayoutLinkStatus},
types::{MinorUnit, UnifiedCode, UnifiedMessage},
};
use diesel_models::{
enums as storage_enums,
generic_link::{GenericLinkNew, PayoutLink},
CommonMandateReference, PayoutsMandateReference, PayoutsMandateReferenceRecord,
};
use error_stack::{report, ResultExt};
use serde_json;
use crate::types::domain::behaviour::Conversion;
use crate::types::PayoutActionData;
use crate::{
core::{
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
payments::{self, customers, helpers as payment_helpers},
utils as core_utils,
},
db::StorageInterface,
routes::SessionState,
services,
types::{
self,
api::{self, payments as payment_api_types, payouts},
domain,
storage::{self, PaymentRoutingInfo},
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn fulfill_payout(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
connector_data: &api::ConnectorData,
payout_data: &mut PayoutData,
) -> RouterResult<()> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts.rs | crate: router
state,
merchant_account,
connector_data,
payout_data,
key_store,
))
.await
.attach_printable("Creation of customer failed")?;
}
Ok(())
}
pub async fn create_recipient_disburse_account(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
connector_data: &api::ConnectorData,
payout_data: &mut PayoutData,
key_store: &domain::MerchantKeyStore,
) -> RouterResult<()> {
// 1. Form Router data
let router_data = core_utils::construct_payout_router_data(
state,
connector_data,
merchant_account,
payout_data,
pub async fn create_recipient_disburse_account(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
connector_data: &api::ConnectorData,
payout_data: &mut PayoutData,
key_store: &domain::MerchantKeyStore,
) -> RouterResult<()> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use api_models::cards_info as cards_info_api_types;
use common_utils::fp_utils::when;
use diesel_models::cards_info as card_info_models;
use rdkafka::message::ToBytes;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
pub async fn update_card_info(
state: routes::SessionState,
card_info_request: cards_info_api_types::CardInfoUpdateRequest,
) -> RouterResponse<cards_info_api_types::CardInfoResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use api_models::cards_info as cards_info_api_types;
use error_stack::{report, ResultExt};
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
pub async fn retrieve_card_info(
state: routes::SessionState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
request: cards_info_api_types::CardsInfoRequest,
) -> RouterResponse<cards_info_api_types::CardInfoResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use api_models::cards_info as cards_info_api_types;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
async fn card_info_flow(
record: cards_info_api_types::CardInfoUpdateRequest,
state: routes::SessionState,
) -> RouterResponse<cards_info_api_types::CardInfoMigrateResponseRecord> {
{
Some(card_info) => {
let builder = builder.set_card_info(card_info);
let updated_card_info = executor.update_card_info().await?;
builder.set_updated_card_info(updated_card_info)
}<|fim_suffix|>
<|fim_middle|>
None => {
let builder = builder.transition();
let added_card_info = executor.add_card_info().await?;
builder.set_added_card_info(added_card_info)
}
}
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use api_models::cards_info as cards_info_api_types;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
pub async fn migrate_cards_info(
state: routes::SessionState,
card_info_records: Vec<cards_info_api_types::CardInfoUpdateRequest>,
) -> RouterResponse<Vec<cards_info_api_types::CardInfoMigrationResponse>> {
{
Ok(ApplicationResponse::Json(response)) => Ok(response),<|fim_suffix|>
<|fim_middle|>
_ => Err("Failed to migrate card info".to_string()),
}
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use api_models::cards_info as cards_info_api_types;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
async fn card_info_flow(
record: cards_info_api_types::CardInfoUpdateRequest,
state: routes::SessionState,
) -> RouterResponse<cards_info_api_types::CardInfoMigrateResponseRecord> {
let builder = CardInfoBuilder::new();
let executor = CardInfoMigrateExecutor::new(&state, &record);
let fetched_card_info_details = executor.fetch_card_info().await?;
let builder = match fetched_card_info_details {
Some(card_info) => {
let builder = builder.set_card_info(card_info);
let updated_card_info = executor.update_card_info().await?;
builder.set_updated_card_info(updated_card_info)
}
None => {
let builder = builder.transition();
let added_card_info = executor.add_card_info().await?;
builder.set_added_card_info(added_card_info)
}
};
Ok(ApplicationResponse::Json(builder.build()))
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use api_models::cards_info as cards_info_api_types;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
pub fn build(self) -> cards_info_api_types::CardInfoMigrateResponseRecord {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use diesel_models::cards_info as card_info_models;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
fn set_added_card_info(
self,
card_info: card_info_models::CardInfo,
) -> CardInfoBuilder<CardInfoResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use diesel_models::cards_info as card_info_models;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
fn set_updated_card_info(
self,
card_info: card_info_models::CardInfo,
) -> CardInfoBuilder<CardInfoResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
fn transition(self) -> CardInfoBuilder<CardInfoAdd> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use diesel_models::cards_info as card_info_models;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
fn set_card_info(
self,
card_info: card_info_models::CardInfo,
) -> CardInfoBuilder<CardInfoUpdate> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use common_utils::fp_utils::when;
use diesel_models::cards_info as card_info_models;
use rdkafka::message::ToBytes;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
async fn update_card_info(&self) -> RouterResult<card_info_models::CardInfo> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use diesel_models::cards_info as card_info_models;
use rdkafka::message::ToBytes;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
async fn add_card_info(&self) -> RouterResult<card_info_models::CardInfo> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use diesel_models::cards_info as card_info_models;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
async fn fetch_card_info(&self) -> RouterResult<Option<card_info_models::CardInfo>> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use api_models::cards_info as cards_info_api_types;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
fn new(
state: &'a routes::SessionState,
record: &'a cards_info_api_types::CardInfoUpdateRequest,
) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use api_models::cards_info as cards_info_api_types;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
pub async fn migrate_cards_info(
state: routes::SessionState,
card_info_records: Vec<cards_info_api_types::CardInfoUpdateRequest>,
) -> RouterResponse<Vec<cards_info_api_types::CardInfoMigrationResponse>> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use actix_multipart::form::{bytes::Bytes, MultipartForm};
use api_models::cards_info as cards_info_api_types;
use rdkafka::message::ToBytes;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
pub fn get_cards_bin_records(
form: CardsInfoUpdateForm,
) -> Result<Vec<cards_info_api_types::CardInfoUpdateRequest>, errors::ApiErrorResponse> {
{
Ok(records) => Ok(records),<|fim_suffix|>
<|fim_middle|>
Err(e) => Err(errors::ApiErrorResponse::PreconditionFailed {
message: e.to_string(),
}),
}
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use api_models::cards_info as cards_info_api_types;
use csv::Reader;
fn parse_cards_bin_csv(
data: &[u8],
) -> csv::Result<Vec<cards_info_api_types::CardInfoUpdateRequest>> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use api_models::cards_info as cards_info_api_types;
use rdkafka::message::ToBytes;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
pub async fn create_card_info(
state: routes::SessionState,
card_info_request: cards_info_api_types::CardInfoCreateRequest,
) -> RouterResponse<cards_info_api_types::CardInfoResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/cards_info.rs | crate: router
use common_utils::fp_utils::when;
use crate::{
core::{
errors::{self, RouterResponse, RouterResult, StorageErrorExt},
payments::helpers,
},
db::cards_info::CardsInfoInterface,
routes,
services::ApplicationResponse,
types::{
domain,
transformers::{ForeignFrom, ForeignInto},
},
};
fn verify_iin_length(card_iin: &str) -> Result<(), errors::ApiErrorResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payout_link.rs | crate: router
use api_models::payouts;
use super::errors::{RouterResponse, StorageErrorExt};
use crate::{
configs::settings::{PaymentMethodFilterKey, PaymentMethodFilters},
core::payouts::{helpers as payout_helpers, validator},
errors,
routes::{app::StorageInterface, SessionState},
services,
types::{api, domain, transformers::ForeignFrom},
};
pub fn check_currency_country_filters(
payout_method_filter: Option<&PaymentMethodFilters>,
request_payout_method_type: &api_models::payment_methods::RequestPaymentMethodTypes,
currency: common_enums::Currency,
country: Option<&common_enums::CountryAlpha2>,
) -> errors::RouterResult<Option<bool>> {
if matches!(
request_payout_method_type.payment_method_type,
common_enums::PaymentMethodType::Credit | common_enums::PaymentMethodType::Debit
) {
Ok(Some(true))
} else {
let payout_method_type_filter =
payout_method_filter.and_then(|payout_method_filter: &PaymentMethodFilters| {
payout_method_filter
.0
.get(&PaymentMethodFilterKey::PaymentMethodType(
request_payout_method_type.payment_method_type,
))
});
let country_filter = country.as_ref().and_then(|country| {
payout_method_type_filter.and_then(|currency_country_filter| {
currency_country_filter
.country
.as_ref()
.map(|country_hash_set| country_hash_set.contains(country))
})
});
let currency_filter = payout_method_type_filter.and_then(|currency_country_filter| {
currency_country_filter
.currency
.as_ref()
.map(|currency_hash_set| currency_hash_set.contains(¤cy))
});
Ok(currency_filter.or(country_filter))
}
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payout_link.rs | crate: router
use api_models::payouts;
use super::errors::{RouterResponse, StorageErrorExt};
use crate::{
configs::settings::{PaymentMethodFilterKey, PaymentMethodFilters},
core::payouts::{helpers as payout_helpers, validator},
errors,
routes::{app::StorageInterface, SessionState},
services,
types::{api, domain, transformers::ForeignFrom},
};
pub fn check_currency_country_filters(
payout_method_filter: Option<&PaymentMethodFilters>,
request_payout_method_type: &api_models::payment_methods::RequestPaymentMethodTypes,
currency: common_enums::Currency,
country: Option<&common_enums::CountryAlpha2>,
) -> errors::RouterResult<Option<bool>> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payout_link.rs | crate: router
use actix_web::http::header;
use api_models::payouts;
use super::errors::{RouterResponse, StorageErrorExt};
use crate::{
configs::settings::{PaymentMethodFilterKey, PaymentMethodFilters},
core::payouts::{helpers as payout_helpers, validator},
errors,
routes::{app::StorageInterface, SessionState},
services,
types::{api, domain, transformers::ForeignFrom},
};
pub async fn initiate_payout_link(
_state: SessionState,
_merchant_account: domain::MerchantAccount,
_key_store: domain::MerchantKeyStore,
_req: payouts::PayoutLinkInitiateRequest,
_request_headers: &header::HeaderMap,
_locale: String,
) -> RouterResponse<services::GenericLinkFormData> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payout_link.rs | crate: router
use std::{
cmp::Ordering,
collections::{HashMap, HashSet},
};
use actix_web::http::header;
use api_models::payouts;
use common_utils::{
ext_traits::{AsyncExt, Encode, OptionExt},
link_utils,
types::{AmountConvertor, StringMajorUnitForConnector},
};
use diesel_models::PayoutLinkUpdate;
use error_stack::ResultExt;
use hyperswitch_domain_models::api::{GenericLinks, GenericLinksData};
use super::errors::{RouterResponse, StorageErrorExt};
use crate::{
configs::settings::{PaymentMethodFilterKey, PaymentMethodFilters},
core::payouts::{helpers as payout_helpers, validator},
errors,
routes::{app::StorageInterface, SessionState},
services,
types::{api, domain, transformers::ForeignFrom},
};
pub async fn filter_payout_methods(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
payout: &hyperswitch_domain_models::payouts::payouts::Payouts,
address: Option<&domain::Address>,
) -> errors::RouterResult<Vec<link_utils::EnabledPaymentMethod>> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payout_link.rs | crate: router
use std::{
cmp::Ordering,
collections::{HashMap, HashSet},
};
use actix_web::http::header;
use api_models::payouts;
use common_utils::{
ext_traits::{AsyncExt, Encode, OptionExt},
link_utils,
types::{AmountConvertor, StringMajorUnitForConnector},
};
use diesel_models::PayoutLinkUpdate;
use hyperswitch_domain_models::api::{GenericLinks, GenericLinksData};
use super::errors::{RouterResponse, StorageErrorExt};
use crate::{
configs::settings::{PaymentMethodFilterKey, PaymentMethodFilters},
core::payouts::{helpers as payout_helpers, validator},
errors,
routes::{app::StorageInterface, SessionState},
services,
types::{api, domain, transformers::ForeignFrom},
};
pub async fn initiate_payout_link(
state: SessionState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
req: payouts::PayoutLinkInitiateRequest,
request_headers: &header::HeaderMap,
) -> RouterResponse<services::GenericLinkFormData> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
acs_reference_number: authentication_response.acs_reference_number,
acs_trans_id: authentication_response.acs_trans_id,
three_dsserver_trans_id: authentication_response.three_dsserver_trans_id,
acs_signed_content: authentication_response.acs_signed_content,
three_ds_requestor_url: authentication_details.three_ds_requestor_url,
three_ds_requestor_app_url: authentication_details.three_ds_requestor_app_url,
},
))
}
#[instrument(skip_all)]
#[cfg(feature = "v2")]
pub async fn payment_start_redirection(
state: SessionState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
req: api_models::payments::PaymentStartRedirectionRequest,
) -> RouterResponse<serde_json::Value> {
let db = &*state.store;
let key_manager_state = &(&state).into();
let storage_scheme = merchant_account.storage_scheme;
let payment_intent = db
.find_payment_intent_by_id(key_manager_state, &req.id, &key_store, storage_scheme)
pub async fn payment_start_redirection(
state: SessionState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
req: api_models::payments::PaymentStartRedirectionRequest,
) -> RouterResponse<serde_json::Value> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
business_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
transaction_data: &payouts::PayoutData,
routing_data: &mut storage::RoutingData,
eligible_connectors: Option<Vec<enums::RoutableConnectors>>,
) -> RouterResult<ConnectorCallType> {
todo!()
}
#[cfg(feature = "payouts")]
#[cfg(feature = "v1")]
#[allow(clippy::too_many_arguments)]
pub async fn route_connector_v1_for_payouts(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
business_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
transaction_data: &payouts::PayoutData,
routing_data: &mut storage::RoutingData,
eligible_connectors: Option<Vec<enums::RoutableConnectors>>,
) -> RouterResult<ConnectorCallType> {
let routing_algorithm_id = {
let routing_algorithm = business_profile.payout_routing_algorithm.clone();
let algorithm_ref = routing_algorithm
pub async fn route_connector_v1_for_payouts(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
business_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
transaction_data: &payouts::PayoutData,
routing_data: &mut storage::RoutingData,
eligible_connectors: Option<Vec<enums::RoutableConnectors>>,
) -> RouterResult<ConnectorCallType> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
let final_list = connectors.filter_and_validate_for_session_flow(&result)?;
Ok(final_list)
}
pub struct SessionTokenRoutingResult {
pub final_result: api::SessionConnectorDatas,
pub routing_result:
FxHashMap<common_enums::PaymentMethodType, Vec<api::routing::SessionRoutingChoice>>,
}
#[cfg(feature = "v2")]
pub async fn perform_session_token_routing<F, D>(
state: SessionState,
business_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
payment_data: &D,
connectors: api::SessionConnectorDatas,
) -> RouterResult<SessionTokenRoutingResult>
where
F: Clone,
D: OperationSessionGetters<F>,
{
let chosen = connectors.apply_filter_for_session_routing();
let sfr = SessionFlowRoutingInput {
pub async fn perform_session_token_routing<F, D>(
state: SessionState,
business_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
payment_data: &D,
connectors: api::SessionConnectorDatas,
) -> RouterResult<SessionTokenRoutingResult>
where
F: Clone,
D: OperationSessionGetters<F>,
{
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
is_connector_agnostic_mit_enabled == Some(true)
&& payment_method_info.get_payment_method_type() == Some(storage_enums::PaymentMethod::Card)
&& ntid_supported_connectors.contains(&connector)
&& payment_method_info.network_transaction_id.is_some()
}
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Eq, PartialEq)]
pub enum IsNtWithNtiFlow {
NtWithNtiSupported(String), //Network token with Network transaction id supported flow
NTWithNTINotSupported, //Network token with Network transaction id not supported
}
pub fn is_network_token_with_network_transaction_id_flow(
is_connector_agnostic_mit_enabled: Option<bool>,
is_network_tokenization_enabled: bool,
payment_method_info: &domain::PaymentMethod,
) -> IsNtWithNtiFlow {
match (
is_connector_agnostic_mit_enabled,
is_network_tokenization_enabled,
payment_method_info.get_payment_method_type(),
payment_method_info.network_transaction_id.clone(),
payment_method_info.network_token_locker_id.is_some(),
payment_method_info
.network_token_requestor_reference_id
pub fn is_network_token_with_network_transaction_id_flow(
is_connector_agnostic_mit_enabled: Option<bool>,
is_network_tokenization_enabled: bool,
payment_method_info: &domain::PaymentMethod,
) -> IsNtWithNtiFlow {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
pub fn filter_network_tokenization_supported_connectors(
connectors: Vec<api::ConnectorData>,
network_tokenization_supported_connectors: &HashSet<enums::Connector>,
) -> Vec<api::ConnectorData> {
connectors
.into_iter()
.filter(|data| network_tokenization_supported_connectors.contains(&data.connector_name))
.collect()
}
#[cfg(feature = "v1")]
pub async fn decide_action_type(
state: &SessionState,
is_connector_agnostic_mit_enabled: Option<bool>,
is_network_tokenization_enabled: bool,
payment_method_info: &domain::PaymentMethod,
filtered_nt_supported_connectors: Vec<api::ConnectorData>, //network tokenization supported connectors
) -> Option<ActionType> {
match (
is_network_token_with_network_transaction_id_flow(
is_connector_agnostic_mit_enabled,
is_network_tokenization_enabled,
payment_method_info,
),
pub async fn decide_action_type(
state: &SessionState,
is_connector_agnostic_mit_enabled: Option<bool>,
is_network_tokenization_enabled: bool,
payment_method_info: &domain::PaymentMethod,
filtered_nt_supported_connectors: Vec<api::ConnectorData>, //network tokenization supported connectors
) -> Option<ActionType> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
});
// Set the card details received in the recurring details within the payment method data.
payment_data.set_payment_method_data(Some(
hyperswitch_domain_models::payment_method_data::PaymentMethodData::CardDetailsForNetworkTransactionId(card_details_for_network_transaction_id),
));
Ok(eligible_connector_data)
}
#[cfg(feature = "v1")]
#[allow(clippy::too_many_arguments)]
pub async fn connector_selection<F, D>(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
business_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
payment_data: &mut D,
request_straight_through: Option<serde_json::Value>,
eligible_connectors: Option<Vec<enums::RoutableConnectors>>,
mandate_type: Option<api::MandateTransactionType>,
) -> RouterResult<ConnectorCallType>
where
F: Send + Clone,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
pub async fn connector_selection<F, D>(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
business_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
payment_data: &mut D,
request_straight_through: Option<serde_json::Value>,
eligible_connectors: Option<Vec<enums::RoutableConnectors>>,
mandate_type: Option<api::MandateTransactionType>,
) -> RouterResult<ConnectorCallType>
where
F: Send + Clone,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
.first()
.ok_or(errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration)
.attach_printable(
"No eligible connector found for the network transaction id based mit flow",
)?;
Ok((
mandate_reference_id,
card_details_for_network_transaction_id,
eligible_connector_data.clone(),
))
}
pub async fn set_eligible_connector_for_nti_in_payment_data<F, D>(
state: &SessionState,
business_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
payment_data: &mut D,
connector_choice: api::ConnectorChoice,
) -> RouterResult<api::ConnectorData>
where
F: Send + Clone,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
let (mandate_reference_id, card_details_for_network_transaction_id, eligible_connector_data) =
match connector_choice {
pub async fn set_eligible_connector_for_nti_in_payment_data<F, D>(
state: &SessionState,
business_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
payment_data: &mut D,
connector_choice: api::ConnectorChoice,
) -> RouterResult<api::ConnectorData>
where
F: Send + Clone,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
} else if let api::ConnectorChoice::StraightThrough(algorithm) = connector_choice {
update_straight_through_routing(payment_data, algorithm)
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to update straight through routing algorithm")?;
None
} else {
None
};
Ok(connector)
}
async fn get_eligible_connector_for_nti<T: core_routing::GetRoutableConnectorsForChoice, F, D>(
state: &SessionState,
key_store: &domain::MerchantKeyStore,
payment_data: &D,
connector_choice: T,
business_profile: &domain::Profile,
) -> RouterResult<(
api_models::payments::MandateReferenceId,
hyperswitch_domain_models::payment_method_data::CardDetailsForNetworkTransactionId,
api::ConnectorData,
)>
where
async fn get_eligible_connector_for_nti<T: core_routing::GetRoutableConnectorsForChoice, F, D>(
state: &SessionState,
key_store: &domain::MerchantKeyStore,
payment_data: &D,
connector_choice: T,
business_profile: &domain::Profile,
) -> RouterResult<(
api_models::payments::MandateReferenceId,
hyperswitch_domain_models::payment_method_data::CardDetailsForNetworkTransactionId,
api::ConnectorData,
)>
where
F: Send + Clone,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
let _: api_models::routing::RoutingAlgorithm = request_straight_through
.clone()
.parse_value("RoutingAlgorithm")
.attach_printable("Invalid straight through routing rules format")?;
payment_data.set_straight_through_algorithm_in_payment_attempt(request_straight_through);
Ok(())
}
#[cfg(feature = "v1")]
#[allow(clippy::too_many_arguments)]
pub async fn get_connector_choice<F, Req, D>(
operation: &BoxedOperation<'_, F, Req, D>,
state: &SessionState,
req: &Req,
merchant_account: &domain::MerchantAccount,
business_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
payment_data: &mut D,
eligible_connectors: Option<Vec<enums::RoutableConnectors>>,
mandate_type: Option<api::MandateTransactionType>,
) -> RouterResult<Option<ConnectorCallType>>
where
F: Send + Clone,
pub async fn get_connector_choice<F, Req, D>(
operation: &BoxedOperation<'_, F, Req, D>,
state: &SessionState,
req: &Req,
merchant_account: &domain::MerchantAccount,
business_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
payment_data: &mut D,
eligible_connectors: Option<Vec<enums::RoutableConnectors>>,
mandate_type: Option<api::MandateTransactionType>,
) -> RouterResult<Option<ConnectorCallType>>
where
F: Send + Clone,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
for status in enums::IntentStatus::iter() {
status_map.entry(status).or_default();
}
Ok(services::ApplicationResponse::Json(
api::PaymentsAggregateResponse {
status_with_count: status_map,
},
))
}
#[cfg(feature = "v1")]
pub async fn add_process_sync_task(
db: &dyn StorageInterface,
payment_attempt: &storage::PaymentAttempt,
schedule_time: time::PrimitiveDateTime,
) -> CustomResult<(), errors::StorageError> {
let tracking_data = api::PaymentsRetrieveRequest {
force_sync: true,
merchant_id: Some(payment_attempt.merchant_id.clone()),
resource_id: api::PaymentIdType::PaymentAttemptId(payment_attempt.get_id().to_owned()),
..Default::default()
};
let runner = storage::ProcessTrackerRunner::PaymentsSyncWorkflow;
let task = "PAYMENTS_SYNC";
pub async fn add_process_sync_task(
db: &dyn StorageInterface,
payment_attempt: &storage::PaymentAttempt,
schedule_time: time::PrimitiveDateTime,
) -> CustomResult<(), errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
total_count,
data,
},
))
},
&metrics::PAYMENT_LIST_LATENCY,
router_env::metric_attributes!(("merchant_id", merchant.get_id().clone())),
)
.await
}
#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn get_filters_for_payments(
state: SessionState,
merchant: domain::MerchantAccount,
merchant_key_store: domain::MerchantKeyStore,
time_range: common_utils::types::TimeRange,
) -> RouterResponse<api::PaymentListFilters> {
let db = state.store.as_ref();
let pi = db
.filter_payment_intents_by_time_range_constraints(
&(&state).into(),
merchant.get_id(),
&time_range,
&merchant_key_store,
pub async fn get_filters_for_payments(
state: SessionState,
merchant: domain::MerchantAccount,
merchant_key_store: domain::MerchantKeyStore,
time_range: common_utils::types::TimeRange,
) -> RouterResponse<api::PaymentListFilters> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
total_count,
data,
},
))
},
&metrics::PAYMENT_LIST_LATENCY,
router_env::metric_attributes!(("merchant_id", merchant.get_id().clone())),
)
.await
}
#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn apply_filters_on_payments(
state: SessionState,
merchant: domain::MerchantAccount,
profile_id_list: Option<Vec<id_type::ProfileId>>,
merchant_key_store: domain::MerchantKeyStore,
constraints: api::PaymentListFilterConstraints,
) -> RouterResponse<api::PaymentListResponseV2> {
common_utils::metrics::utils::record_operation_time(
async {
let limit = &constraints.limit;
helpers::validate_payment_list_request_for_joins(*limit)?;
let db: &dyn StorageInterface = state.store.as_ref();
let pi_fetch_constraints = (constraints.clone(), profile_id_list.clone()).try_into()?;
pub async fn apply_filters_on_payments(
state: SessionState,
merchant: domain::MerchantAccount,
profile_id_list: Option<Vec<id_type::ProfileId>>,
merchant_key_store: domain::MerchantKeyStore,
constraints: api::PaymentListFilterConstraints,
) -> RouterResponse<api::PaymentListResponseV2> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
.map(ForeignFrom::foreign_from)
.collect();
Ok(services::ApplicationResponse::Json(
api::PaymentListResponse {
size: data.len(),
data,
},
))
}
#[cfg(all(feature = "v2", feature = "olap"))]
pub async fn list_payments(
state: SessionState,
merchant: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
constraints: api::PaymentListConstraints,
) -> RouterResponse<payments_api::PaymentListResponse> {
common_utils::metrics::utils::record_operation_time(
async {
let limit = &constraints.limit;
helpers::validate_payment_list_request_for_joins(*limit)?;
let db: &dyn StorageInterface = state.store.as_ref();
let fetch_constraints = constraints.clone().into();
let list: Vec<(storage::PaymentIntent, Option<storage::PaymentAttempt>)> = db
pub async fn list_payments(
state: SessionState,
merchant: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
constraints: api::PaymentListConstraints,
) -> RouterResponse<payments_api::PaymentListResponse> {
common_utils::metrics::utils::record_operation_time(
async {
let limit = &constraints.limit;
helpers::validate_payment_list_request_for_joins(*limit)?;
let db: &dyn StorageInterface = state.store.as_ref();
let fetch_constraints = constraints.clone().into();
let list: Vec<(storage::PaymentIntent, Option<storage::PaymentAttempt>)> = db
.get_filtered_payment_intents_attempt(
&(&state).into(),
merchant.get_id(),
&fetch_constraints,
&key_store,
merchant.storage_scheme,
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
let data: Vec<api_models::payments::PaymentsListResponseItem> =
list.into_iter().map(ForeignFrom::foreign_from).collect();
let active_attempt_ids = db
.get_filtered_active_attempt_ids_for_total_count(
merchant.get_id(),
&fetch_constraints,
merchant.storage_scheme,
)
.await
.to_not_found_response(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error while retrieving active_attempt_ids for merchant")?;
let total_count = if constraints.has_no_attempt_filters() {
i64::try_from(active_attempt_ids.len())
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error while converting from usize to i64")
} else {
let active_attempt_ids = active_attempt_ids
.into_iter()
.flatten()
.collect::<Vec<String>>();
db.get_total_count_of_filtered_payment_attempts(
merchant.get_id(),
&active_attempt_ids,
constraints.connector,
constraints.payment_method_type,
constraints.payment_method_subtype,
constraints.authentication_type,
constraints.merchant_connector_id,
constraints.card_network,
merchant.storage_scheme,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error while retrieving total count of payment attempts")
}?;
Ok(services::ApplicationResponse::Json(
api_models::payments::PaymentListResponse {
count: data.len(),
total_count,
data,
},
))
},
&metrics::PAYMENT_LIST_LATENCY,
router_env::metric_attributes!(("merchant_id", merchant.get_id().clone())),
)
.await
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
}
}
pub fn is_operation_confirm<Op: Debug>(operation: &Op) -> bool {
matches!(format!("{operation:?}").as_str(), "PaymentConfirm")
}
pub fn is_operation_complete_authorize<Op: Debug>(operation: &Op) -> bool {
matches!(format!("{operation:?}").as_str(), "CompleteAuthorize")
}
#[cfg(all(feature = "olap", feature = "v1"))]
pub async fn list_payments(
state: SessionState,
merchant: domain::MerchantAccount,
profile_id_list: Option<Vec<id_type::ProfileId>>,
key_store: domain::MerchantKeyStore,
constraints: api::PaymentListConstraints,
) -> RouterResponse<api::PaymentListResponse> {
helpers::validate_payment_list_request(&constraints)?;
let merchant_id = merchant.get_id();
let db = state.store.as_ref();
let payment_intents = helpers::filter_by_constraints(
&state,
&(constraints, profile_id_list).try_into()?,
pub async fn list_payments(
state: SessionState,
merchant: domain::MerchantAccount,
profile_id_list: Option<Vec<id_type::ProfileId>>,
key_store: domain::MerchantKeyStore,
constraints: api::PaymentListConstraints,
) -> RouterResponse<api::PaymentListResponse> {
helpers::validate_payment_list_request(&constraints)?;
let merchant_id = merchant.get_id();
let db = state.store.as_ref();
let payment_intents = helpers::filter_by_constraints(
&state,
&(constraints, profile_id_list).try_into()?,
merchant_id,
&key_store,
merchant.storage_scheme,
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
let collected_futures = payment_intents.into_iter().map(|pi| {
async {
match db
.find_payment_attempt_by_payment_id_merchant_id_attempt_id(
&pi.payment_id,
merchant_id,
&pi.active_attempt.get_id(),
// since OLAP doesn't have KV. Force to get the data from PSQL.
storage_enums::MerchantStorageScheme::PostgresOnly,
)
.await
{
Ok(pa) => Some(Ok((pi, pa))),
Err(error) => {
if matches!(
error.current_context(),
errors::StorageError::ValueNotFound(_)
) {
logger::warn!(
?error,
"payment_attempts missing for payment_id : {:?}",
pi.payment_id,
);
return None;
}
Some(Err(error))
}
}
}
});
//If any of the response are Err, we will get Result<Err(_)>
let pi_pa_tuple_vec: Result<Vec<(storage::PaymentIntent, storage::PaymentAttempt)>, _> =
join_all(collected_futures)
.await
.into_iter()
.flatten() //Will ignore `None`, will only flatten 1 level
.collect::<Result<Vec<(storage::PaymentIntent, storage::PaymentAttempt)>, _>>();
//Will collect responses in same order async, leading to sorted responses
//Converting Intent-Attempt array to Response if no error
let data: Vec<api::PaymentsResponse> = pi_pa_tuple_vec
.change_context(errors::ApiErrorResponse::InternalServerError)?
.into_iter()
.map(ForeignFrom::foreign_from)
.collect();
Ok(services::ApplicationResponse::Json(
api::PaymentListResponse {
size: data.len(),
data,
},
))
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
&'a PaymentConfirm: Operation<F, R, Data = PaymentData<F>>,
Op: Operation<F, R, Data = PaymentData<F>> + Send + Sync,
&'a Op: Operation<F, R, Data = PaymentData<F>>,
{
if confirm.unwrap_or(false) {
Box::new(&PaymentConfirm)
} else {
Box::new(operation)
}
}
#[cfg(feature = "v1")]
pub fn should_call_connector<Op: Debug, F: Clone, D>(operation: &Op, payment_data: &D) -> bool
where
D: OperationSessionGetters<F> + Send + Sync + Clone,
{
match format!("{operation:?}").as_str() {
"PaymentConfirm" => true,
"PaymentStart" => {
!matches!(
payment_data.get_payment_intent().status,
storage_enums::IntentStatus::Failed | storage_enums::IntentStatus::Succeeded
) && payment_data
.get_payment_attempt()
.authentication_data
pub fn should_call_connector<Op: Debug, F: Clone, D>(operation: &Op, payment_data: &D) -> bool
where
D: OperationSessionGetters<F> + Send + Sync + Clone,
{
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
merchant_key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
business_profile: &domain::Profile,
) -> RouterResult<D>
where
F: Send + Clone,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
todo!()
}
#[cfg(feature = "v1")]
pub async fn tokenize_in_router_when_confirm_false_or_external_authentication<F, Req, D>(
state: &SessionState,
operation: &BoxedOperation<'_, F, Req, D>,
payment_data: &mut D,
validate_result: &operations::ValidateResult,
merchant_key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
business_profile: &domain::Profile,
) -> RouterResult<D>
where
F: Send + Clone,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
pub async fn tokenize_in_router_when_confirm_false_or_external_authentication<F, Req, D>(
state: &SessionState,
operation: &BoxedOperation<'_, F, Req, D>,
payment_data: &mut D,
validate_result: &operations::ValidateResult,
merchant_key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
business_profile: &domain::Profile,
) -> RouterResult<D>
where
F: Send + Clone,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
domain::ApplePayFlow::Manual
}
}
},
api_models::payments::ApplepaySessionTokenMetadata::ApplePay(_) => {
domain::ApplePayFlow::Manual
}
})
})
})
}
fn get_google_pay_connector_wallet_details(
state: &SessionState,
merchant_connector_account: &helpers::MerchantConnectorAccountType,
) -> Option<GooglePayPaymentProcessingDetails> {
let google_pay_root_signing_keys = state
.conf
.google_pay_decrypt_keys
.as_ref()
.map(|google_pay_keys| google_pay_keys.google_pay_root_signing_keys.clone());
match merchant_connector_account.get_connector_wallets_details() {
Some(wallet_details) => {
let google_pay_wallet_details = wallet_details
.parse_value::<api_models::payments::GooglePayWalletDetails>(
fn get_google_pay_connector_wallet_details(
state: &SessionState,
merchant_connector_account: &helpers::MerchantConnectorAccountType,
) -> Option<GooglePayPaymentProcessingDetails> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
state: &SessionState,
payment_method_type: Option<enums::PaymentMethodType>,
merchant_connector_account: Option<&helpers::MerchantConnectorAccountType>,
) -> Option<domain::ApplePayFlow> {
payment_method_type.and_then(|pmt| match pmt {
enums::PaymentMethodType::ApplePay => {
check_apple_pay_metadata(state, merchant_connector_account)
}
_ => None,
})
}
fn check_apple_pay_metadata(
state: &SessionState,
merchant_connector_account: Option<&helpers::MerchantConnectorAccountType>,
) -> Option<domain::ApplePayFlow> {
merchant_connector_account.and_then(|mca| {
let metadata = mca.get_metadata();
metadata.and_then(|apple_pay_metadata| {
let parsed_metadata = apple_pay_metadata
.clone()
.parse_value::<api_models::payments::ApplepayCombinedSessionTokenData>(
"ApplepayCombinedSessionTokenData",
)
.map(|combined_metadata| {
fn check_apple_pay_metadata(
state: &SessionState,
merchant_connector_account: Option<&helpers::MerchantConnectorAccountType>,
) -> Option<domain::ApplePayFlow> {
merchant_connector_account.and_then(|mca| {
let metadata = mca.get_metadata();
metadata.and_then(|apple_pay_metadata| {
let parsed_metadata = apple_pay_metadata
.clone()
.parse_value::<api_models::payments::ApplepayCombinedSessionTokenData>(
"ApplepayCombinedSessionTokenData",
)
.map(|combined_metadata| {
api_models::payments::ApplepaySessionTokenMetadata::ApplePayCombined(
combined_metadata.apple_pay_combined,
)
})
.or_else(|_| {
apple_pay_metadata
.parse_value::<api_models::payments::ApplepaySessionTokenData>(
"ApplepaySessionTokenData",
)
.map(|old_metadata| {
api_models::payments::ApplepaySessionTokenMetadata::ApplePay(
old_metadata.apple_pay,
)
})
})
.map_err(|error| {
logger::warn!(?error, "Failed to Parse Value to ApplepaySessionTokenData")
});
parsed_metadata.ok().map(|metadata| match metadata {
api_models::payments::ApplepaySessionTokenMetadata::ApplePayCombined(
apple_pay_combined,
) => match apple_pay_combined {
api_models::payments::ApplePayCombinedMetadata::Simplified { .. } => {
domain::ApplePayFlow::Simplified(payments_api::PaymentProcessingDetails {
payment_processing_certificate: state
.conf
.applepay_decrypt_keys
.get_inner()
.apple_pay_ppc
.clone(),
payment_processing_certificate_key: state
.conf
.applepay_decrypt_keys
.get_inner()
.apple_pay_ppc_key
.clone(),
})
}
api_models::payments::ApplePayCombinedMetadata::Manual {
payment_request_data: _,
session_token_data,
} => {
if let Some(manual_payment_processing_details_at) =
session_token_data.payment_processing_details_at
{
match manual_payment_processing_details_at {
payments_api::PaymentProcessingDetailsAt::Hyperswitch(
payment_processing_details,
) => domain::ApplePayFlow::Simplified(payment_processing_details),
payments_api::PaymentProcessingDetailsAt::Connector => {
domain::ApplePayFlow::Manual
}
}
} else {
domain::ApplePayFlow::Manual
}
}
},
api_models::payments::ApplepaySessionTokenMetadata::ApplePay(_) => {
domain::ApplePayFlow::Manual
}
})
})
})
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
use api_models::{
self, enums,
mandates::RecurringDetails,
payments::{self as payments_api},
};
pub use common_enums::enums::CallConnectorAction;
use crate::{
configs::settings::{ApplePayPreDecryptFlow, PaymentMethodTypeTokenFilter},
connector::utils::missing_field_err,
consts,
core::{
errors::{self, CustomResult, RouterResponse, RouterResult},
payment_methods::{cards, network_tokenization},
payouts,
routing::{self as core_routing},
utils::{self as core_utils},
},
db::StorageInterface,
logger,
routes::{app::ReqState, metrics, payment_methods::ParentPaymentMethodToken, SessionState},
services::{self, api::Authenticate, ConnectorRedirectResponse},
types::{
self as router_types,
api::{self, ConnectorCallType, ConnectorCommon},
domain,
storage::{self, enums as storage_enums, payment_attempt::PaymentAttemptExt},
transformers::ForeignTryInto,
},
utils::{
self, add_apple_pay_flow_metrics, add_connector_http_status_code_metrics, Encode,
OptionExt, ValueExt,
},
workflows::payment_sync,
};
fn is_payment_method_tokenization_enabled_for_connector(
state: &SessionState,
connector_name: &str,
payment_method: storage::enums::PaymentMethod,
payment_method_type: Option<storage::enums::PaymentMethodType>,
apple_pay_flow: &Option<domain::ApplePayFlow>,
) -> RouterResult<bool> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
}
}
_ => Ok(router_data),
}
}
pub fn is_preprocessing_required_for_wallets(connector_name: String) -> bool {
connector_name == *"trustpay" || connector_name == *"payme"
}
#[cfg(feature = "v1")]
#[instrument(skip_all)]
pub async fn construct_profile_id_and_get_mca<'a, F, D>(
state: &'a SessionState,
merchant_account: &domain::MerchantAccount,
payment_data: &D,
connector_name: &str,
merchant_connector_id: Option<&id_type::MerchantConnectorAccountId>,
key_store: &domain::MerchantKeyStore,
_should_validate: bool,
) -> RouterResult<helpers::MerchantConnectorAccountType>
where
F: Clone,
D: OperationSessionGetters<F> + Send + Sync + Clone,
{
pub async fn construct_profile_id_and_get_mca<'a, F, D>(
state: &'a SessionState,
merchant_account: &domain::MerchantAccount,
payment_data: &D,
connector_name: &str,
merchant_connector_id: Option<&id_type::MerchantConnectorAccountId>,
key_store: &domain::MerchantKeyStore,
_should_validate: bool,
) -> RouterResult<helpers::MerchantConnectorAccountType>
where
F: Clone,
D: OperationSessionGetters<F> + Send + Sync + Clone,
{
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
(router_data, !is_error_in_response)
} else {
(router_data, should_continue_payment)
}
}
};
Ok(router_data_and_should_continue_payment)
}
#[cfg(feature = "v1")]
#[allow(clippy::too_many_arguments)]
async fn complete_postprocessing_steps_if_required<F, Q, RouterDReq, D>(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
merchant_conn_account: &helpers::MerchantConnectorAccountType,
connector: &api::ConnectorData,
payment_data: &mut D,
_operation: &BoxedOperation<'_, F, Q, D>,
header_payload: Option<HeaderPayload>,
) -> RouterResult<RouterData<F, RouterDReq, router_types::PaymentsResponseData>>
where
F: Send + Clone + Sync,
async fn complete_postprocessing_steps_if_required<F, Q, RouterDReq, D>(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
merchant_conn_account: &helpers::MerchantConnectorAccountType,
connector: &api::ConnectorData,
payment_data: &mut D,
_operation: &BoxedOperation<'_, F, Q, D>,
header_payload: Option<HeaderPayload>,
) -> RouterResult<RouterData<F, RouterDReq, router_types::PaymentsResponseData>>
where
F: Send + Clone + Sync,
RouterDReq: Send + Sync,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
RouterData<F, RouterDReq, router_types::PaymentsResponseData>: Feature<F, RouterDReq> + Send,
dyn api::Connector:
services::api::ConnectorIntegration<F, RouterDReq, router_types::PaymentsResponseData>,
D: ConstructFlowSpecificData<F, RouterDReq, router_types::PaymentsResponseData>,
{
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
}
}
let call_connectors_end_time = Instant::now();
let call_connectors_duration =
call_connectors_end_time.saturating_duration_since(call_connectors_start_time);
tracing::info!(duration = format!("Duration taken: {}", call_connectors_duration.as_millis()));
Ok(payment_data)
}
#[cfg(feature = "v1")]
pub async fn get_session_token_for_click_to_pay(
state: &SessionState,
merchant_id: &id_type::MerchantId,
key_store: &domain::MerchantKeyStore,
authentication_product_ids: common_types::payments::AuthenticationConnectorAccountMap,
payment_intent: &hyperswitch_domain_models::payments::PaymentIntent,
) -> RouterResult<api_models::payments::SessionToken> {
let click_to_pay_mca_id = authentication_product_ids
.get_click_to_pay_connector_account_id()
.change_context(errors::ApiErrorResponse::MissingRequiredField {
field_name: "authentication_product_ids",
})?;
let key_manager_state = &(state).into();
pub async fn get_session_token_for_click_to_pay(
state: &SessionState,
merchant_id: &id_type::MerchantId,
key_store: &domain::MerchantKeyStore,
authentication_product_ids: common_types::payments::AuthenticationConnectorAccountMap,
payment_intent: &hyperswitch_domain_models::payments::PaymentIntent,
) -> RouterResult<api_models::payments::SessionToken> {
let click_to_pay_mca_id = authentication_product_ids
.get_click_to_pay_connector_account_id()
.change_context(errors::ApiErrorResponse::MissingRequiredField {
field_name: "authentication_product_ids",
})?;
let key_manager_state = &(state).into();
let merchant_connector_account = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
key_manager_state,
merchant_id,
&click_to_pay_mca_id,
key_store,
)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
id: click_to_pay_mca_id.get_string_repr().to_string(),
})?;
let click_to_pay_metadata: ClickToPayMetaData = merchant_connector_account
.metadata
.parse_value("ClickToPayMetaData")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error while parsing ClickToPayMetaData")?;
let transaction_currency = payment_intent
.currency
.ok_or(errors::ApiErrorResponse::InternalServerError)
.attach_printable("currency is not present in payment_data.payment_intent")?;
let required_amount_type = common_utils::types::StringMajorUnitForConnector;
let transaction_amount = required_amount_type
.convert(payment_intent.amount, transaction_currency)
.change_context(errors::ApiErrorResponse::AmountConversionFailed {
amount_type: "string major unit",
})?;
let customer_details_value = payment_intent
.customer_details
.clone()
.get_required_value("customer_details")?;
let customer_details: CustomerData = customer_details_value
.parse_value("CustomerData")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error while parsing customer data from payment intent")?;
validate_customer_details_for_click_to_pay(&customer_details)?;
let provider = match merchant_connector_account.connector_name.as_str() {
"ctp_mastercard" => Some(enums::CtpServiceProvider::Mastercard),
"ctp_visa" => Some(enums::CtpServiceProvider::Visa),
_ => None,
};
Ok(api_models::payments::SessionToken::ClickToPay(Box::new(
api_models::payments::ClickToPaySessionResponse {
dpa_id: click_to_pay_metadata.dpa_id,
dpa_name: click_to_pay_metadata.dpa_name,
locale: click_to_pay_metadata.locale,
card_brands: click_to_pay_metadata.card_brands,
acquirer_bin: click_to_pay_metadata.acquirer_bin,
acquirer_merchant_id: click_to_pay_metadata.acquirer_merchant_id,
merchant_category_code: click_to_pay_metadata.merchant_category_code,
merchant_country_code: click_to_pay_metadata.merchant_country_code,
transaction_amount,
transaction_currency_code: transaction_currency,
phone_number: customer_details.phone.clone(),
email: customer_details.email.clone(),
phone_country_code: customer_details.phone_country_code.clone(),
provider,
dpa_client_id: click_to_pay_metadata.dpa_client_id.clone(),
},
)))
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
use redis_interface::errors::RedisError;
use self::{
conditional_configs::perform_decision_management,
flows::{ConstructFlowSpecificData, Feature},
operations::{BoxedOperation, Operation, PaymentResponse},
routing::{self as self_routing, SessionFlowRoutingInput},
};
use super::{
errors::StorageErrorExt, payment_methods::surcharge_decision_configs, routing::TransactionData,
};
use crate::{
configs::settings::{ApplePayPreDecryptFlow, PaymentMethodTypeTokenFilter},
connector::utils::missing_field_err,
consts,
core::{
errors::{self, CustomResult, RouterResponse, RouterResult},
payment_methods::{cards, network_tokenization},
payouts,
routing::{self as core_routing},
utils::{self as core_utils},
},
db::StorageInterface,
logger,
routes::{app::ReqState, metrics, payment_methods::ParentPaymentMethodToken, SessionState},
services::{self, api::Authenticate, ConnectorRedirectResponse},
types::{
self as router_types,
api::{self, ConnectorCallType, ConnectorCommon},
domain,
storage::{self, enums as storage_enums, payment_attempt::PaymentAttemptExt},
transformers::ForeignTryInto,
},
utils::{
self, add_apple_pay_flow_metrics, add_connector_http_status_code_metrics, Encode,
OptionExt, ValueExt,
},
workflows::payment_sync,
};
async fn blocklist_guard<F, ApiRequest, D>(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
operation: &BoxedOperation<'_, F, ApiRequest, D>,
payment_data: &mut D,
) -> CustomResult<bool, errors::ApiErrorResponse>
where
F: Send + Clone + Sync,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
Ok(None)
}
token_action => {
logger::info!(
"Invalid tokenization action found for decryption flow: {:?}",
token_action
);
Ok(None)
}
}
}
pub async fn get_merchant_bank_data_for_open_banking_connectors(
merchant_connector_account: &helpers::MerchantConnectorAccountType,
key_store: &domain::MerchantKeyStore,
connector: &api::ConnectorData,
state: &SessionState,
merchant_account: &domain::MerchantAccount,
) -> RouterResult<Option<router_types::MerchantRecipientData>> {
let merchant_data = merchant_connector_account
.get_additional_merchant_data()
.get_required_value("additional_merchant_data")?
.into_inner()
.peek()
.clone();
pub async fn get_merchant_bank_data_for_open_banking_connectors(
merchant_connector_account: &helpers::MerchantConnectorAccountType,
key_store: &domain::MerchantKeyStore,
connector: &api::ConnectorData,
state: &SessionState,
merchant_account: &domain::MerchantAccount,
) -> RouterResult<Option<router_types::MerchantRecipientData>> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
.store
.find_business_profile_by_profile_id(key_manager_state, &merchant_key_store, profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
})?;
Ok(router_types::AuthenticatePaymentFlowResponse {
payments_response,
poll_config,
business_profile,
})
}
fn generate_response(
&self,
payment_flow_response: &Self::PaymentFlowResponse,
payment_id: id_type::PaymentId,
connector: String,
) -> RouterResult<services::ApplicationResponse<api::RedirectionResponse>> {
let payments_response = &payment_flow_response.payments_response;
let redirect_response = helpers::get_handle_response_url(
payment_id.clone(),
&payment_flow_response.business_profile,
payments_response,
connector.clone(),
)?;
fn generate_response(
&self,
payment_flow_response: &Self::PaymentFlowResponse,
payment_id: id_type::PaymentId,
connector: String,
) -> RouterResult<services::ApplicationResponse<api::RedirectionResponse>> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
payment_sync_request,
get_tracker_response,
call_connector_action,
HeaderPayload::default(),
))
.await?;
Ok(router_types::RedirectPaymentFlowResponse {
payment_data,
profile,
})
}
fn generate_response(
&self,
payment_flow_response: &Self::PaymentFlowResponse,
) -> RouterResult<services::ApplicationResponse<api::RedirectionResponse>> {
let payment_intent = &payment_flow_response.payment_data.payment_intent;
let profile = &payment_flow_response.profile;
let return_url = payment_intent
.return_url
.as_ref()
.or(profile.return_url.as_ref())
.ok_or(errors::ApiErrorResponse::InternalServerError)
.attach_printable("return url not found in payment intent and profile")?
fn generate_response(
&self,
payment_flow_response: &Self::PaymentFlowResponse,
) -> RouterResult<services::ApplicationResponse<api::RedirectionResponse>> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
}
}
#[derive(Clone, Debug)]
pub struct PaymentRedirectSync;
#[cfg(feature = "v1")]
#[async_trait::async_trait]
impl PaymentRedirectFlow for PaymentRedirectSync {
type PaymentFlowResponse = router_types::RedirectPaymentFlowResponse;
#[allow(clippy::too_many_arguments)]
async fn call_payment_flow(
&self,
state: &SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
merchant_key_store: domain::MerchantKeyStore,
req: PaymentsRedirectResponseData,
connector_action: CallConnectorAction,
_connector: String,
_payment_id: id_type::PaymentId,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResult<Self::PaymentFlowResponse> {
let key_manager_state = &state.into();
async fn call_payment_flow(
&self,
state: &SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
merchant_key_store: domain::MerchantKeyStore,
req: PaymentsRedirectResponseData,
connector_action: CallConnectorAction,
_connector: String,
_payment_id: id_type::PaymentId,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResult<Self::PaymentFlowResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
flow_type,
connector.clone(),
resource_id.clone(),
platform_merchant_account,
)
.await?;
self.generate_response(&payment_flow_response, resource_id, connector)
}
#[cfg(feature = "v2")]
#[allow(clippy::too_many_arguments)]
async fn handle_payments_redirect_response(
&self,
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
profile: domain::Profile,
request: PaymentsRedirectResponseData,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<api::RedirectionResponse> {
metrics::REDIRECTION_TRIGGERED.add(
1,
router_env::metric_attributes!(("merchant_id", merchant_account.get_id().clone())),
async fn handle_payments_redirect_response(
&self,
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
profile: domain::Profile,
request: PaymentsRedirectResponseData,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<api::RedirectionResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
payment_flow_response: &Self::PaymentFlowResponse,
payment_id: id_type::PaymentId,
connector: String,
) -> RouterResult<services::ApplicationResponse<api::RedirectionResponse>>;
#[cfg(feature = "v2")]
fn generate_response(
&self,
payment_flow_response: &Self::PaymentFlowResponse,
) -> RouterResult<services::ApplicationResponse<api::RedirectionResponse>>;
#[cfg(feature = "v1")]
async fn handle_payments_redirect_response(
&self,
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
req: PaymentsRedirectResponseData,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<api::RedirectionResponse> {
metrics::REDIRECTION_TRIGGERED.add(
1,
router_env::metric_attributes!(
(
async fn handle_payments_redirect_response(
&self,
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
req: PaymentsRedirectResponseData,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<api::RedirectionResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
payment_id,
header_payload,
)
.await?;
logger::info!(?confirm_intent_response);
Ok(confirm_intent_response)
}
#[cfg(feature = "v2")]
#[allow(clippy::too_many_arguments)]
async fn decide_authorize_or_setup_intent_flow(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
create_intent_response: &payments_api::PaymentsIntentResponse,
confirm_intent_request: payments_api::PaymentsConfirmIntentRequest,
payment_id: id_type::GlobalPaymentId,
header_payload: HeaderPayload,
) -> RouterResponse<payments_api::PaymentsResponse> {
use hyperswitch_domain_models::{
payments::PaymentConfirmData,
async fn decide_authorize_or_setup_intent_flow(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
create_intent_response: &payments_api::PaymentsIntentResponse,
confirm_intent_request: payments_api::PaymentsConfirmIntentRequest,
payment_id: id_type::GlobalPaymentId,
header_payload: HeaderPayload,
) -> RouterResponse<payments_api::PaymentsResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
payment_data.generate_response(
&state,
connector_http_status_code,
external_latency,
header_payload.x_hs_latency,
&merchant_account,
&profile,
)
}
#[allow(clippy::too_many_arguments)]
#[cfg(feature = "v2")]
pub(crate) async fn payments_create_and_confirm_intent(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
request: payments_api::PaymentsRequest,
mut header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<payments_api::PaymentsResponse> {
use hyperswitch_domain_models::{
payments::PaymentIntentData, router_flow_types::PaymentCreateIntent,
};
pub(crate) async fn payments_create_and_confirm_intent(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
request: payments_api::PaymentsRequest,
mut header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<payments_api::PaymentsResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
&state.base_url,
operation,
&state.conf.connector_request_reference_id_config,
None,
None,
header_payload.x_hs_latency,
&merchant_account,
)
}
#[cfg(feature = "v2")]
#[allow(clippy::too_many_arguments)]
pub async fn payments_get_intent_using_merchant_reference(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
req_state: ReqState,
merchant_reference_id: &id_type::PaymentReferenceId,
header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<api::PaymentsIntentResponse> {
let db = state.store.as_ref();
let storage_scheme = merchant_account.storage_scheme;
let key_manager_state = &(&state).into();
pub async fn payments_get_intent_using_merchant_reference(
state: SessionState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
req_state: ReqState,
merchant_reference_id: &id_type::PaymentReferenceId,
header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<api::PaymentsIntentResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
payment_data,
&state,
None,
None,
header_payload.x_hs_latency,
&merchant_account,
&profile,
)
}
#[cfg(feature = "v2")]
#[allow(clippy::too_many_arguments)]
pub async fn payments_intent_core<F, Res, Req, Op, D>(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
operation: Op,
req: Req,
payment_id: id_type::GlobalPaymentId,
header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<Res>
where
pub async fn payments_intent_core<F, Res, Req, Op, D>(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
operation: Op,
req: Req,
payment_id: id_type::GlobalPaymentId,
header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<Res>
where
F: Send + Clone + Sync,
Op: Operation<F, Req, Data = D> + Send + Sync + Clone,
Req: Debug + Clone,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
Res: transformers::ToResponse<F, D, Op>,
{
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
payment_data.generate_response(
&state,
connector_http_status_code,
external_latency,
header_payload.x_hs_latency,
&merchant_account,
&profile,
)
}
#[cfg(feature = "v2")]
#[allow(clippy::too_many_arguments)]
pub async fn record_attempt_core(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
req: api_models::payments::PaymentsAttemptRecordRequest,
payment_id: id_type::GlobalPaymentId,
header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<api_models::payments::PaymentAttemptResponse> {
tracing::Span::current().record("merchant_id", merchant_account.get_id().get_string_repr());
pub async fn record_attempt_core(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
req: api_models::payments::PaymentsAttemptRecordRequest,
payment_id: id_type::GlobalPaymentId,
header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<api_models::payments::PaymentAttemptResponse> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
auth_flow,
&state.base_url,
operation,
&state.conf.connector_request_reference_id_config,
connector_http_status_code,
external_latency,
header_payload.x_hs_latency,
)
}
#[cfg(feature = "v2")]
#[allow(clippy::too_many_arguments)]
pub async fn proxy_for_payments_core<F, Res, Req, Op, FData, D>(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
operation: Op,
req: Req,
payment_id: id_type::GlobalPaymentId,
call_connector_action: CallConnectorAction,
header_payload: HeaderPayload,
) -> RouterResponse<Res>
where
pub async fn proxy_for_payments_core<F, Res, Req, Op, FData, D>(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
operation: Op,
req: Req,
payment_id: id_type::GlobalPaymentId,
call_connector_action: CallConnectorAction,
header_payload: HeaderPayload,
) -> RouterResponse<Res>
where
F: Send + Clone + Sync,
Req: Send + Sync,
FData: Send + Sync + Clone,
Op: Operation<F, Req, Data = D> + ValidateStatusForOperation + Send + Sync + Clone,
Req: Debug,
D: OperationSessionGetters<F>
+ OperationSessionSetters<F>
+ transformers::GenerateResponse<Res>
+ Send
+ Sync
+ Clone,
D: ConstructFlowSpecificData<F, FData, router_types::PaymentsResponseData>,
RouterData<F, FData, router_types::PaymentsResponseData>: Feature<F, FData>,
dyn api::Connector:
services::api::ConnectorIntegration<F, FData, router_types::PaymentsResponseData>,
PaymentResponse: Operation<F, FData, Data = D>,
RouterData<F, FData, router_types::PaymentsResponseData>:
hyperswitch_domain_models::router_data::TrackerPostUpdateObjects<F, FData, D>,
{
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
auth_flow,
&state.base_url,
operation,
&state.conf.connector_request_reference_id_config,
connector_http_status_code,
external_latency,
header_payload.x_hs_latency,
)
}
#[cfg(feature = "v1")]
#[allow(clippy::too_many_arguments)]
pub async fn proxy_for_payments_core<F, Res, Req, Op, FData, D>(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile_id: Option<id_type::ProfileId>,
key_store: domain::MerchantKeyStore,
operation: Op,
req: Req,
auth_flow: services::AuthFlow,
call_connector_action: CallConnectorAction,
header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<Res>
pub async fn proxy_for_payments_core<F, Res, Req, Op, FData, D>(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile_id: Option<id_type::ProfileId>,
key_store: domain::MerchantKeyStore,
operation: Op,
req: Req,
auth_flow: services::AuthFlow,
call_connector_action: CallConnectorAction,
header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<Res>
where
F: Send + Clone + Sync,
FData: Send + Sync + Clone,
Op: Operation<F, Req, Data = D> + Send + Sync + Clone,
Req: Debug + Authenticate + Clone,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
Res: transformers::ToResponse<F, D, Op>,
// To create connector flow specific interface data
D: ConstructFlowSpecificData<F, FData, router_types::PaymentsResponseData>,
RouterData<F, FData, router_types::PaymentsResponseData>: Feature<F, FData>,
// To construct connector flow specific api
dyn api::Connector:
services::api::ConnectorIntegration<F, FData, router_types::PaymentsResponseData>,
// To perform router related operation for PaymentResponse
PaymentResponse: Operation<F, FData, Data = D>,
{
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
.attach_printable("error performing surcharge decision operation")?;
Ok(if surcharge_results.is_empty_result() {
None
} else {
Some(api::SessionSurchargeDetails::Calculated(surcharge_results))
})
}
}
#[cfg(feature = "v1")]
#[allow(clippy::too_many_arguments)]
pub async fn payments_core<F, Res, Req, Op, FData, D>(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile_id: Option<id_type::ProfileId>,
key_store: domain::MerchantKeyStore,
operation: Op,
req: Req,
auth_flow: services::AuthFlow,
call_connector_action: CallConnectorAction,
eligible_connectors: Option<Vec<enums::Connector>>,
header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
pub async fn payments_core<F, Res, Req, Op, FData, D>(
state: SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile_id: Option<id_type::ProfileId>,
key_store: domain::MerchantKeyStore,
operation: Op,
req: Req,
auth_flow: services::AuthFlow,
call_connector_action: CallConnectorAction,
eligible_connectors: Option<Vec<enums::Connector>>,
header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResponse<Res>
where
F: Send + Clone + Sync,
FData: Send + Sync + Clone,
Op: Operation<F, Req, Data = D> + Send + Sync + Clone,
Req: Debug + Authenticate + Clone,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
Res: transformers::ToResponse<F, D, Op>,
// To create connector flow specific interface data
D: ConstructFlowSpecificData<F, FData, router_types::PaymentsResponseData>,
RouterData<F, FData, router_types::PaymentsResponseData>: Feature<F, FData>,
// To construct connector flow specific api
dyn api::Connector:
services::api::ConnectorIntegration<F, FData, router_types::PaymentsResponseData>,
// To perform router related operation for PaymentResponse
PaymentResponse: Operation<F, FData, Data = D>,
{
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
_merchant_account: &domain::MerchantAccount,
_business_profile: &domain::Profile,
_payment_attempt: &storage::PaymentAttempt,
_payment_intent: &storage::PaymentIntent,
_billing_address: Option<hyperswitch_domain_models::address::Address>,
_session_connector_data: &[api::SessionConnectorData],
) -> RouterResult<Option<api::SessionSurchargeDetails>> {
todo!()
}
#[cfg(feature = "v1")]
#[instrument(skip_all)]
pub async fn call_surcharge_decision_management_for_session_flow(
state: &SessionState,
_merchant_account: &domain::MerchantAccount,
_business_profile: &domain::Profile,
payment_attempt: &storage::PaymentAttempt,
payment_intent: &storage::PaymentIntent,
billing_address: Option<hyperswitch_domain_models::address::Address>,
session_connector_data: &api::SessionConnectorDatas,
) -> RouterResult<Option<api::SessionSurchargeDetails>> {
if let Some(surcharge_amount) = payment_attempt.net_amount.get_surcharge_amount() {
Ok(Some(api::SessionSurchargeDetails::PreDetermined(
types::SurchargeDetails {
original_amount: payment_attempt.net_amount.get_order_amount(),
pub async fn call_surcharge_decision_management_for_session_flow(
state: &SessionState,
_merchant_account: &domain::MerchantAccount,
_business_profile: &domain::Profile,
payment_attempt: &storage::PaymentAttempt,
payment_intent: &storage::PaymentIntent,
billing_address: Option<hyperswitch_domain_models::address::Address>,
session_connector_data: &api::SessionConnectorDatas,
) -> RouterResult<Option<api::SessionSurchargeDetails>> {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
async fn populate_surcharge_details<F>(
state: &SessionState,
payment_data: &mut PaymentData<F>,
) -> RouterResult<()>
where
F: Send + Clone,
{
todo!()
}
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn populate_surcharge_details<F>(
state: &SessionState,
payment_data: &mut PaymentData<F>,
) -> RouterResult<()>
where
F: Send + Clone,
{
if payment_data
.payment_intent
.surcharge_applicable
.unwrap_or(false)
{
logger::debug!("payment_intent.surcharge_applicable = true");
async fn populate_surcharge_details<F>(
state: &SessionState,
payment_data: &mut PaymentData<F>,
) -> RouterResult<()>
where
F: Send + Clone,
{
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
None,
&key_store,
None,
header_payload,
)
.await?;
Ok((payment_data, req, customer))
}
#[instrument(skip_all)]
#[cfg(feature = "v1")]
pub async fn call_decision_manager<F, D>(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
_business_profile: &domain::Profile,
payment_data: &D,
) -> RouterResult<Option<enums::AuthenticationType>>
where
F: Clone,
D: OperationSessionGetters<F>,
{
let setup_mandate = payment_data.get_setup_mandate();
let payment_method_data = payment_data.get_payment_method_data();
let payment_dsl_data = core_routing::PaymentsDslInput::new(
pub async fn call_decision_manager<F, D>(
state: &SessionState,
merchant_account: &domain::MerchantAccount,
_business_profile: &domain::Profile,
payment_data: &D,
) -> RouterResult<Option<enums::AuthenticationType>>
where
F: Clone,
D: OperationSessionGetters<F>,
{
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
}
ConnectorCallType::Retryable(vec) => todo!(),
ConnectorCallType::SessionMultiple(vec) => todo!(),
ConnectorCallType::Skip => payment_data,
};
Ok((payment_data, req, None, None))
}
#[cfg(feature = "v2")]
#[allow(clippy::too_many_arguments, clippy::type_complexity)]
#[instrument(skip_all, fields(payment_id, merchant_id))]
pub async fn payments_intent_operation_core<F, Req, Op, D>(
state: &SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
operation: Op,
req: Req,
payment_id: id_type::GlobalPaymentId,
header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResult<(D, Req, Option<domain::Customer>)>
where
pub async fn payments_intent_operation_core<F, Req, Op, D>(
state: &SessionState,
req_state: ReqState,
merchant_account: domain::MerchantAccount,
profile: domain::Profile,
key_store: domain::MerchantKeyStore,
operation: Op,
req: Req,
payment_id: id_type::GlobalPaymentId,
header_payload: HeaderPayload,
platform_merchant_account: Option<domain::MerchantAccount>,
) -> RouterResult<(D, Req, Option<domain::Customer>)>
where
F: Send + Clone + Sync,
Req: Clone,
Op: Operation<F, Req, Data = D> + Send + Sync,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_mandate_id(&mut self, _mandate_id: api_models::payments::MandateIds) {
todo!()
}
fn set_setup_future_usage_in_payment_intent(
&mut self,
setup_future_usage: storage_enums::FutureUsage,
) {
self.payment_intent.setup_future_usage = setup_future_usage;
}
fn set_connector_in_payment_attempt(&mut self, _connector: Option<String>) {
todo!()
}
}
#[cfg(feature = "v2")]
impl<F: Clone> OperationSessionGetters<F> for PaymentConfirmData<F> {
fn get_payment_attempt(&self) -> &storage::PaymentAttempt {
&self.payment_attempt
}
fn get_payment_intent(&self) -> &storage::PaymentIntent {
&self.payment_intent
fn set_connector_in_payment_attempt(&mut self, _connector: Option<String>) {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_surcharge_details(&mut self, surcharge_details: Option<types::SurchargeDetails>) {
self.surcharge_details = surcharge_details;
}
fn set_merchant_connector_id_in_attempt(
&mut self,
merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
) {
self.payment_attempt.merchant_connector_id = merchant_connector_id;
}
#[cfg(feature = "v1")]
fn set_capture_method_in_attempt(&mut self, capture_method: enums::CaptureMethod) {
self.payment_attempt.capture_method = Some(capture_method);
}
fn set_frm_message(&mut self, frm_message: FraudCheck) {
self.frm_message = Some(frm_message);
}
fn set_payment_intent_status(&mut self, status: storage_enums::IntentStatus) {
self.payment_intent.status = status;
}
fn set_authentication_type_in_attempt(
fn set_capture_method_in_attempt(&mut self, capture_method: enums::CaptureMethod) {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_mandate_id(&mut self, _mandate_id: api_models::payments::MandateIds) {
todo!()
}
fn set_setup_future_usage_in_payment_intent(
&mut self,
setup_future_usage: storage_enums::FutureUsage,
) {
self.payment_intent.setup_future_usage = setup_future_usage;
}
fn set_connector_in_payment_attempt(&mut self, connector: Option<String>) {
todo!()
}
}
fn set_connector_in_payment_attempt(&mut self, connector: Option<String>) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
// TODO: handle this case. Should we add connector_customer_id in paymentConfirmData?
}
fn push_sessions_token(&mut self, _token: api::SessionToken) {
todo!()
}
fn set_surcharge_details(&mut self, _surcharge_details: Option<types::SurchargeDetails>) {
todo!()
}
#[track_caller]
fn set_merchant_connector_id_in_attempt(
&mut self,
merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
) {
todo!()
}
fn set_frm_message(&mut self, _frm_message: FraudCheck) {
todo!()
}
fn set_payment_intent_status(&mut self, status: storage_enums::IntentStatus) {
self.payment_intent.status = status;
fn set_merchant_connector_id_in_attempt(
&mut self,
merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_pm_token(&mut self, _token: String) {
todo!()
}
fn set_connector_customer_id(&mut self, _customer_id: Option<String>) {
// TODO: handle this case. Should we add connector_customer_id in paymentConfirmData?
}
fn push_sessions_token(&mut self, _token: api::SessionToken) {
todo!()
}
fn set_surcharge_details(&mut self, _surcharge_details: Option<types::SurchargeDetails>) {
todo!()
}
#[track_caller]
fn set_merchant_connector_id_in_attempt(
&mut self,
merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
) {
todo!()
}
fn set_frm_message(&mut self, _frm_message: FraudCheck) {
fn set_surcharge_details(&mut self, _surcharge_details: Option<types::SurchargeDetails>) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_email_if_not_present(&mut self, _email: pii::Email) {
todo!()
}
fn set_pm_token(&mut self, _token: String) {
todo!()
}
fn set_connector_customer_id(&mut self, _customer_id: Option<String>) {
// TODO: handle this case. Should we add connector_customer_id in paymentConfirmData?
}
fn push_sessions_token(&mut self, _token: api::SessionToken) {
todo!()
}
fn set_surcharge_details(&mut self, _surcharge_details: Option<types::SurchargeDetails>) {
todo!()
}
#[track_caller]
fn set_merchant_connector_id_in_attempt(
&mut self,
merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
) {
fn push_sessions_token(&mut self, _token: api::SessionToken) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_payment_method_id_in_attempt(&mut self, _payment_method_id: Option<String>) {
todo!()
}
fn set_email_if_not_present(&mut self, _email: pii::Email) {
todo!()
}
fn set_pm_token(&mut self, _token: String) {
todo!()
}
fn set_connector_customer_id(&mut self, _customer_id: Option<String>) {
// TODO: handle this case. Should we add connector_customer_id in paymentConfirmData?
}
fn push_sessions_token(&mut self, _token: api::SessionToken) {
todo!()
}
fn set_surcharge_details(&mut self, _surcharge_details: Option<types::SurchargeDetails>) {
todo!()
}
#[track_caller]
fn set_connector_customer_id(&mut self, _customer_id: Option<String>) {
{<|fim_suffix|>
<|fim_middle|>
}}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_payment_method_data(&mut self, _payment_method_data: Option<domain::PaymentMethodData>) {
todo!()
}
fn set_payment_method_id_in_attempt(&mut self, _payment_method_id: Option<String>) {
todo!()
}
fn set_email_if_not_present(&mut self, _email: pii::Email) {
todo!()
}
fn set_pm_token(&mut self, _token: String) {
todo!()
}
fn set_connector_customer_id(&mut self, _customer_id: Option<String>) {
// TODO: handle this case. Should we add connector_customer_id in paymentConfirmData?
}
fn push_sessions_token(&mut self, _token: api::SessionToken) {
todo!()
}
fn set_surcharge_details(&mut self, _surcharge_details: Option<types::SurchargeDetails>) {
fn set_pm_token(&mut self, _token: String) {
todo!()
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn set_payment_intent(&mut self, payment_intent: storage::PaymentIntent) {
self.payment_intent = payment_intent;
}
fn set_payment_attempt(&mut self, payment_attempt: storage::PaymentAttempt) {
self.payment_attempt = payment_attempt;
}
fn set_payment_method_data(&mut self, _payment_method_data: Option<domain::PaymentMethodData>) {
todo!()
}
fn set_payment_method_id_in_attempt(&mut self, _payment_method_id: Option<String>) {
todo!()
}
fn set_email_if_not_present(&mut self, _email: pii::Email) {
todo!()
}
fn set_pm_token(&mut self, _token: String) {
todo!()
}
fn set_connector_customer_id(&mut self, _customer_id: Option<String>) {
fn set_payment_method_id_in_attempt(&mut self, _payment_method_id: Option<String>) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
}
#[cfg(feature = "v2")]
impl<F: Clone> OperationSessionSetters<F> for PaymentCaptureData<F> {
fn set_payment_intent(&mut self, payment_intent: storage::PaymentIntent) {
self.payment_intent = payment_intent;
}
fn set_payment_attempt(&mut self, payment_attempt: storage::PaymentAttempt) {
self.payment_attempt = payment_attempt;
}
fn set_payment_method_data(&mut self, _payment_method_data: Option<domain::PaymentMethodData>) {
todo!()
}
fn set_payment_method_id_in_attempt(&mut self, _payment_method_id: Option<String>) {
todo!()
}
fn set_email_if_not_present(&mut self, _email: pii::Email) {
todo!()
}
fn set_pm_token(&mut self, _token: String) {
fn set_payment_method_data(&mut self, _payment_method_data: Option<domain::PaymentMethodData>) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
#[cfg(feature = "v2")]
fn get_optional_payment_attempt(&self) -> Option<&storage::PaymentAttempt> {
Some(&self.payment_attempt)
}
}
#[cfg(feature = "v2")]
impl<F: Clone> OperationSessionSetters<F> for PaymentCaptureData<F> {
fn set_payment_intent(&mut self, payment_intent: storage::PaymentIntent) {
self.payment_intent = payment_intent;
}
fn set_payment_attempt(&mut self, payment_attempt: storage::PaymentAttempt) {
self.payment_attempt = payment_attempt;
}
fn set_payment_method_data(&mut self, _payment_method_data: Option<domain::PaymentMethodData>) {
todo!()
}
fn set_payment_method_id_in_attempt(&mut self, _payment_method_id: Option<String>) {
todo!()
}
fn set_email_if_not_present(&mut self, _email: pii::Email) {
fn set_payment_attempt(&mut self, payment_attempt: storage::PaymentAttempt) {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_capture_method(&self) -> Option<enums::CaptureMethod> {
todo!()
}
#[cfg(feature = "v2")]
fn get_optional_payment_attempt(&self) -> Option<&storage::PaymentAttempt> {
Some(&self.payment_attempt)
}
}
#[cfg(feature = "v2")]
impl<F: Clone> OperationSessionSetters<F> for PaymentCaptureData<F> {
fn set_payment_intent(&mut self, payment_intent: storage::PaymentIntent) {
self.payment_intent = payment_intent;
}
fn set_payment_attempt(&mut self, payment_attempt: storage::PaymentAttempt) {
self.payment_attempt = payment_attempt;
}
fn set_payment_method_data(&mut self, _payment_method_data: Option<domain::PaymentMethodData>) {
todo!()
}
fn set_payment_method_id_in_attempt(&mut self, _payment_method_id: Option<String>) {
fn set_payment_intent(&mut self, payment_intent: storage::PaymentIntent) {
self.payment_intent = payment_intent;
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_currency(&self) -> storage_enums::Currency {
self.payment_intent.amount_details.currency
}
fn get_amount(&self) -> api::Amount {
todo!()
}
fn get_payment_attempt_connector(&self) -> Option<&str> {
todo!()
}
fn get_merchant_connector_id_in_attempt(&self) -> Option<id_type::MerchantConnectorAccountId> {
todo!()
}
fn get_billing_address(&self) -> Option<hyperswitch_domain_models::address::Address> {
todo!()
}
fn get_payment_method_data(&self) -> Option<&domain::PaymentMethodData> {
todo!()
}
fn get_sessions_token(&self) -> Vec<api::SessionToken> {
fn get_merchant_connector_id_in_attempt(&self) -> Option<id_type::MerchantConnectorAccountId> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_payment_intent_profile_id(&self) -> Option<&id_type::ProfileId> {
Some(&self.payment_intent.profile_id)
}
fn get_currency(&self) -> storage_enums::Currency {
self.payment_intent.amount_details.currency
}
fn get_amount(&self) -> api::Amount {
todo!()
}
fn get_payment_attempt_connector(&self) -> Option<&str> {
todo!()
}
fn get_merchant_connector_id_in_attempt(&self) -> Option<id_type::MerchantConnectorAccountId> {
todo!()
}
fn get_billing_address(&self) -> Option<hyperswitch_domain_models::address::Address> {
todo!()
}
fn get_payment_method_data(&self) -> Option<&domain::PaymentMethodData> {
fn get_payment_attempt_connector(&self) -> Option<&str> {
<|fim_suffix|>
<|fim_middle|>
}
|
ast_fragments
|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments.rs | crate: router
fn get_recurring_details(&self) -> Option<&RecurringDetails> {
todo!()
}
fn get_payment_intent_profile_id(&self) -> Option<&id_type::ProfileId> {
Some(&self.payment_intent.profile_id)
}
fn get_currency(&self) -> storage_enums::Currency {
self.payment_intent.amount_details.currency
}
fn get_amount(&self) -> api::Amount {
todo!()
}
fn get_payment_attempt_connector(&self) -> Option<&str> {
todo!()
}
fn get_merchant_connector_id_in_attempt(&self) -> Option<id_type::MerchantConnectorAccountId> {
todo!()
}
fn get_billing_address(&self) -> Option<hyperswitch_domain_models::address::Address> {
fn get_amount(&self) -> api::Amount {
<|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.