text
stringlengths
70
351k
source
stringclasses
4 values
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_create.rs | crate: router use diesel_models::{ ephemeral_key, payment_attempt::ConnectorMandateReferenceId as DieselConnectorMandateReferenceId, }; use crate::{ consts, core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_link, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, db::StorageInterface, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{ self, enums::{self, IntentStatus}, }, transformers::{ForeignFrom, ForeignTryFrom}, }, utils::{self, OptionExt}, }; type PaymentCreateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; pub async fn get_ephemeral_key( request: &api::PaymentsRequest, state: &SessionState, merchant_account: &domain::MerchantAccount, ) -> Option<ephemeral_key::EphemeralKey> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_create.rs | crate: router request.retry_action, Some(api_models::enums::RetryAction::Requeue) ), }, )) } } impl PaymentCreate { #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[instrument(skip_all)] #[allow(clippy::too_many_arguments)] pub async fn make_payment_attempt( payment_id: &common_utils::id_type::PaymentId, merchant_id: &common_utils::id_type::MerchantId, organization_id: &common_utils::id_type::OrganizationId, money: (api::Amount, enums::Currency), payment_method: Option<enums::PaymentMethod>, payment_method_type: Option<enums::PaymentMethodType>, request: &api::PaymentsRequest, browser_info: Option<serde_json::Value>, state: &SessionState, payment_method_billing_address_id: Option<String>, payment_method_info: &Option<domain::PaymentMethod>, _key_store: &domain::MerchantKeyStore, pub async fn make_payment_attempt( payment_id: &common_utils::id_type::PaymentId, merchant_id: &common_utils::id_type::MerchantId, organization_id: &common_utils::id_type::OrganizationId, money: (api::Amount, enums::Currency), payment_method: Option<enums::PaymentMethod>, payment_method_type: Option<enums::PaymentMethodType>, request: &api::PaymentsRequest, browser_info: Option<serde_json::Value>, state: &SessionState, payment_method_billing_address_id: Option<String>, payment_method_info: &Option<domain::PaymentMethod>, _key_store: &domain::MerchantKeyStore, profile_id: common_utils::id_type::ProfileId, customer_acceptance: &Option<payments::CustomerAcceptance>, storage_scheme: enums::MerchantStorageScheme, ) -> RouterResult<( storage::PaymentAttemptNew, Option<api_models::payments::AdditionalPaymentData>, )> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_create.rs | crate: router use error_stack::{self, ResultExt}; use crate::{ consts, core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_link, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, db::StorageInterface, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{ self, enums::{self, IntentStatus}, }, transformers::{ForeignFrom, ForeignTryFrom}, }, utils::{self, OptionExt}, }; type PaymentCreateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; async fn get_connector<'a>( &'a self, _merchant_account: &domain::MerchantAccount, state: &SessionState, request: &api::PaymentsRequest, _payment_intent: &storage::PaymentIntent, _merchant_key_store: &domain::MerchantKeyStore, ) -> CustomResult<api::ConnectorChoice, errors::ApiErrorResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/payments/operations/payment_create.rs | crate: router use error_stack::{self, ResultExt}; use hyperswitch_domain_models::{ mandates::MandateDetails, payments::{ payment_attempt::PaymentAttempt, payment_intent::CustomerData, FromRequestEncryptablePaymentIntent, }, }; use time::PrimitiveDateTime; use crate::{ consts, core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_link, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, db::StorageInterface, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{ self, enums::{self, IntentStatus}, }, transformers::{ForeignFrom, ForeignTryFrom}, }, utils::{self, OptionExt}, }; type PaymentCreateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; async fn add_task_to_process_tracker<'a>( &'a self, _state: &'a SessionState, _payment_attempt: &PaymentAttempt, _requeue: bool, _schedule_time: Option<PrimitiveDateTime>, ) -> CustomResult<(), errors::ApiErrorResponse> { Ok(()) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_create.rs | crate: router use api_models::{ enums::FrmSuggestion, mandates::RecurringDetails, payment_methods::PaymentMethodsData, payments::GetAddressFromPaymentMethodData, }; use error_stack::{self, ResultExt}; use crate::{ consts, core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_link, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, db::StorageInterface, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{ self, enums::{self, IntentStatus}, }, transformers::{ForeignFrom, ForeignTryFrom}, }, utils::{self, OptionExt}, }; type PaymentCreateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; async fn get_or_create_customer_details<'a>( &'a self, state: &SessionState, payment_data: &mut PaymentData<F>, request: Option<CustomerDetails>, key_store: &domain::MerchantKeyStore, storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<(PaymentCreateOperation<'a, F>, Option<domain::Customer>), errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_create.rs | crate: router use api_models::{ enums::FrmSuggestion, mandates::RecurringDetails, payment_methods::PaymentMethodsData, payments::GetAddressFromPaymentMethodData, }; use error_stack::{self, ResultExt}; use hyperswitch_domain_models::{ mandates::MandateDetails, payments::{ payment_attempt::PaymentAttempt, payment_intent::CustomerData, FromRequestEncryptablePaymentIntent, }, }; use crate::{ consts, core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_link, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, db::StorageInterface, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{ self, enums::{self, IntentStatus}, }, transformers::{ForeignFrom, ForeignTryFrom}, }, utils::{self, OptionExt}, }; type PaymentCreateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<(PaymentCreateOperation<'b, F>, operations::ValidateResult)> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_create.rs | crate: router _state: &SessionState, _merchant_account: &domain::MerchantAccount, _key_store: &domain::MerchantKeyStore, _payment_data: &mut PaymentData<F>, ) -> CustomResult<bool, errors::ApiErrorResponse> { Ok(false) } } #[async_trait] impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for PaymentCreate { #[instrument(skip_all)] async fn update_trackers<'b>( &'b self, state: &'b SessionState, req_state: ReqState, mut payment_data: PaymentData<F>, customer: Option<domain::Customer>, storage_scheme: enums::MerchantStorageScheme, _updated_customer: Option<storage::CustomerUpdate>, key_store: &domain::MerchantKeyStore, _frm_suggestion: Option<FrmSuggestion>, _header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<(PaymentCreateOperation<'b, F>, PaymentData<F>)> where async fn update_trackers<'b>( &'b self, state: &'b SessionState, req_state: ReqState, mut payment_data: PaymentData<F>, customer: Option<domain::Customer>, storage_scheme: enums::MerchantStorageScheme, _updated_customer: Option<storage::CustomerUpdate>, key_store: &domain::MerchantKeyStore, _frm_suggestion: Option<FrmSuggestion>, _header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<(PaymentCreateOperation<'b, F>, PaymentData<F>)> where F: 'b + Send, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_create.rs | crate: router helpers::create_customer_if_not_exist( state, Box::new(self), payment_data, request, &key_store.merchant_id, key_store, storage_scheme, ) .await } async fn payments_dynamic_tax_calculation<'a>( &'a self, state: &SessionState, payment_data: &mut PaymentData<F>, _connector_call_type: &ConnectorCallType, business_profile: &domain::Profile, key_store: &domain::MerchantKeyStore, merchant_account: &domain::MerchantAccount, ) -> CustomResult<(), errors::ApiErrorResponse> { let is_tax_connector_enabled = business_profile.get_is_tax_connector_enabled(); let skip_external_tax_calculation = payment_data .payment_intent .skip_external_tax_calculation async fn payments_dynamic_tax_calculation<'a>( &'a self, state: &SessionState, payment_data: &mut PaymentData<F>, _connector_call_type: &ConnectorCallType, business_profile: &domain::Profile, key_store: &domain::MerchantKeyStore, merchant_account: &domain::MerchantAccount, ) -> CustomResult<(), errors::ApiErrorResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_create.rs | crate: router request_extended_authorization: None, extended_authorization_applied: None, capture_before: None, card_discovery: None, }, additional_pm_data, )) } #[instrument(skip_all)] #[allow(clippy::too_many_arguments)] async fn make_payment_intent( state: &SessionState, payment_id: &common_utils::id_type::PaymentId, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, money: (api::Amount, enums::Currency), request: &api::PaymentsRequest, shipping_address_id: Option<String>, payment_link_data: Option<api_models::payments::PaymentLinkResponse>, billing_address_id: Option<String>, active_attempt_id: String, profile_id: common_utils::id_type::ProfileId, session_expiry: PrimitiveDateTime, async fn make_payment_intent( state: &SessionState, payment_id: &common_utils::id_type::PaymentId, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, money: (api::Amount, enums::Currency), request: &api::PaymentsRequest, shipping_address_id: Option<String>, payment_link_data: Option<api_models::payments::PaymentLinkResponse>, billing_address_id: Option<String>, active_attempt_id: String, profile_id: common_utils::id_type::ProfileId, session_expiry: PrimitiveDateTime, platform_merchant_account: Option<&domain::MerchantAccount>, business_profile: &domain::Profile, ) -> RouterResult<storage::PaymentIntent> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_create.rs | crate: router storage::PaymentAttemptNew, Option<api_models::payments::AdditionalPaymentData>, )> { todo!() } #[cfg(all( any(feature = "v1", feature = "v2"), not(feature = "payment_methods_v2") ))] #[instrument(skip_all)] #[allow(clippy::too_many_arguments)] pub async fn make_payment_attempt( payment_id: &common_utils::id_type::PaymentId, merchant_id: &common_utils::id_type::MerchantId, organization_id: &common_utils::id_type::OrganizationId, money: (api::Amount, enums::Currency), payment_method: Option<enums::PaymentMethod>, payment_method_type: Option<enums::PaymentMethodType>, request: &api::PaymentsRequest, browser_info: Option<serde_json::Value>, state: &SessionState, optional_payment_method_billing_address_id: Option<String>, payment_method_info: &Option<domain::PaymentMethod>, key_store: &domain::MerchantKeyStore, pub async fn make_payment_attempt( payment_id: &common_utils::id_type::PaymentId, merchant_id: &common_utils::id_type::MerchantId, organization_id: &common_utils::id_type::OrganizationId, money: (api::Amount, enums::Currency), payment_method: Option<enums::PaymentMethod>, payment_method_type: Option<enums::PaymentMethodType>, request: &api::PaymentsRequest, browser_info: Option<serde_json::Value>, state: &SessionState, optional_payment_method_billing_address_id: Option<String>, payment_method_info: &Option<domain::PaymentMethod>, key_store: &domain::MerchantKeyStore, profile_id: common_utils::id_type::ProfileId, customer_acceptance: &Option<payments::CustomerAcceptance>, storage_scheme: enums::MerchantStorageScheme, ) -> RouterResult<( storage::PaymentAttemptNew, Option<api_models::payments::AdditionalPaymentData>, )> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_create.rs | crate: router #[derive(Debug, Clone, Copy, PaymentOperation)] #[operation(operations = "all", flow = "authorize")] pub struct PaymentCreate; type PaymentCreateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; /// The `get_trackers` function for `PaymentsCreate` is an entrypoint for new payments /// This will create all the entities required for a new payment from the request #[async_trait] impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for PaymentCreate { #[instrument(skip_all)] async fn get_trackers<'a>( &'a self, state: &'a SessionState, payment_id: &api::PaymentIdType, request: &api::PaymentsRequest, merchant_account: &domain::MerchantAccount, merchant_key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, header_payload: &hyperswitch_domain_models::payments::HeaderPayload, platform_merchant_account: Option<&domain::MerchantAccount>, ) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>> { let db = &*state.store; async fn get_trackers<'a>( &'a self, state: &'a SessionState, payment_id: &api::PaymentIdType, request: &api::PaymentsRequest, merchant_account: &domain::MerchantAccount, merchant_key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, header_payload: &hyperswitch_domain_models::payments::HeaderPayload, platform_merchant_account: Option<&domain::MerchantAccount>, ) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_cancel.rs | crate: router use api_models::enums::FrmSuggestion; use crate::{ core::{ errors::{self, RouterResult, StorageErrorExt}, payments::{helpers, operations, PaymentData}, utils::ValidatePlatformMerchant, }, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self as core_types, api::{self, PaymentIdTypeExt}, domain, storage::{self, enums}, }, utils::OptionExt, }; type PaymentCancelOperation<'b, F> = BoxedOperation<'b, F, api::PaymentsCancelRequest, PaymentData<F>>; async fn update_trackers<'b>( &'b self, state: &'b SessionState, req_state: ReqState, mut payment_data: PaymentData<F>, _customer: Option<domain::Customer>, storage_scheme: enums::MerchantStorageScheme, _updated_customer: Option<storage::CustomerUpdate>, key_store: &domain::MerchantKeyStore, _frm_suggestion: Option<FrmSuggestion>, _header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<(PaymentCancelOperation<'b, F>, PaymentData<F>)> where F: 'b + Send, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_cancel.rs | crate: router #[derive(Debug, Clone, Copy, router_derive::PaymentOperation)] #[operation(operations = "all", flow = "cancel")] pub struct PaymentCancel; type PaymentCancelOperation<'b, F> = BoxedOperation<'b, F, api::PaymentsCancelRequest, PaymentData<F>>; #[async_trait] impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRequest> for PaymentCancel { #[instrument(skip_all)] async fn get_trackers<'a>( &'a self, state: &'a SessionState, payment_id: &api::PaymentIdType, request: &api::PaymentsCancelRequest, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, _header_payload: &hyperswitch_domain_models::payments::HeaderPayload, platform_merchant_account: Option<&domain::MerchantAccount>, ) -> RouterResult< operations::GetTrackerResponse<'a, F, api::PaymentsCancelRequest, PaymentData<F>>, > { async fn get_trackers<'a>( &'a self, state: &'a SessionState, payment_id: &api::PaymentIdType, request: &api::PaymentsCancelRequest, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, _header_payload: &hyperswitch_domain_models::payments::HeaderPayload, platform_merchant_account: Option<&domain::MerchantAccount>, ) -> RouterResult< operations::GetTrackerResponse<'a, F, api::PaymentsCancelRequest, PaymentData<F>>, > { {let db = &*state.store;<|fim_suffix|> <|fim_middle|> Ok(get_trackers_response)}}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_cancel.rs | crate: router use crate::{ core::{ errors::{self, RouterResult, StorageErrorExt}, payments::{helpers, operations, PaymentData}, utils::ValidatePlatformMerchant, }, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self as core_types, api::{self, PaymentIdTypeExt}, domain, storage::{self, enums}, }, utils::OptionExt, }; type PaymentCancelOperation<'b, F> = BoxedOperation<'b, F, api::PaymentsCancelRequest, PaymentData<F>>; fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsCancelRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<(PaymentCancelOperation<'b, F>, operations::ValidateResult)> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_cancel.rs | crate: router use std::marker::PhantomData; use api_models::enums::FrmSuggestion; use crate::{ core::{ errors::{self, RouterResult, StorageErrorExt}, payments::{helpers, operations, PaymentData}, utils::ValidatePlatformMerchant, }, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self as core_types, api::{self, PaymentIdTypeExt}, domain, storage::{self, enums}, }, utils::OptionExt, }; type PaymentCancelOperation<'b, F> = BoxedOperation<'b, F, api::PaymentsCancelRequest, PaymentData<F>>; async fn get_trackers<'a>( &'a self, state: &'a SessionState, payment_id: &api::PaymentIdType, request: &api::PaymentsCancelRequest, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, _header_payload: &hyperswitch_domain_models::payments::HeaderPayload, platform_merchant_account: Option<&domain::MerchantAccount>, ) -> RouterResult< operations::GetTrackerResponse<'a, F, api::PaymentsCancelRequest, PaymentData<F>>, > { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router use api_models::payment_methods::PaymentMethodsData; use api_models::{ admin::ExtendedCardInfoConfig, enums::FrmSuggestion, // payment_methods::PaymentMethodsData, payments::{ConnectorMandateReferenceId, ExtendedCardInfo, GetAddressFromPaymentMethodData}, }; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::payments::payment_intent::PaymentIntentUpdateFields; use crate::{ core::{ authentication, blocklist::utils as blocklist_utils, card_testing_guard::utils as card_testing_guard_utils, errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payments::{ self, helpers, operations, populate_surcharge_details, CustomerDetails, PaymentAddress, PaymentData, }, unified_authentication_service::{ self as uas_utils, types::{ClickToPay, UnifiedAuthenticationService}, }, utils as core_utils, }, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain::{self}, storage::{self, enums as storage_enums}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; type PaymentConfirmOperation<'b, F> = BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>; fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<(PaymentConfirmOperation<'b, F>, operations::ValidateResult)> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router use api_models::{ admin::ExtendedCardInfoConfig, enums::FrmSuggestion, // payment_methods::PaymentMethodsData, payments::{ConnectorMandateReferenceId, ExtendedCardInfo, GetAddressFromPaymentMethodData}, }; use common_utils::ext_traits::{AsyncExt, Encode, StringExt, ValueExt}; use router_env::{instrument, logger, tracing}; use crate::{ core::{ authentication, blocklist::utils as blocklist_utils, card_testing_guard::utils as card_testing_guard_utils, errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payments::{ self, helpers, operations, populate_surcharge_details, CustomerDetails, PaymentAddress, PaymentData, }, unified_authentication_service::{ self as uas_utils, types::{ClickToPay, UnifiedAuthenticationService}, }, utils as core_utils, }, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain::{self}, storage::{self, enums as storage_enums}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; async fn store_extended_card_info_temporarily<'a>( &'a self, state: &SessionState, payment_id: &common_utils::id_type::PaymentId, business_profile: &domain::Profile, payment_method_data: Option<&domain::PaymentMethodData>, ) -> CustomResult<(), errors::ApiErrorResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router use crate::{ core::{ authentication, blocklist::utils as blocklist_utils, card_testing_guard::utils as card_testing_guard_utils, errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payments::{ self, helpers, operations, populate_surcharge_details, CustomerDetails, PaymentAddress, PaymentData, }, unified_authentication_service::{ self as uas_utils, types::{ClickToPay, UnifiedAuthenticationService}, }, utils as core_utils, }, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain::{self}, storage::{self, enums as storage_enums}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; type PaymentConfirmOperation<'b, F> = BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>; async fn make_pm_data<'a>( &'a self, state: &'a SessionState, payment_data: &mut PaymentData<F>, storage_scheme: storage_enums::MerchantStorageScheme, key_store: &domain::MerchantKeyStore, customer: &Option<domain::Customer>, business_profile: &domain::Profile, should_retry_with_pan: bool, ) -> RouterResult<( PaymentConfirmOperation<'a, F>, Option<domain::PaymentMethodData>, Option<String>, )> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router use api_models::payment_methods::PaymentMethodsData; use api_models::{ admin::ExtendedCardInfoConfig, enums::FrmSuggestion, // payment_methods::PaymentMethodsData, payments::{ConnectorMandateReferenceId, ExtendedCardInfo, GetAddressFromPaymentMethodData}, }; use hyperswitch_domain_models::payments::payment_intent::PaymentIntentUpdateFields; use crate::{ core::{ authentication, blocklist::utils as blocklist_utils, card_testing_guard::utils as card_testing_guard_utils, errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payments::{ self, helpers, operations, populate_surcharge_details, CustomerDetails, PaymentAddress, PaymentData, }, unified_authentication_service::{ self as uas_utils, types::{ClickToPay, UnifiedAuthenticationService}, }, utils as core_utils, }, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain::{self}, storage::{self, enums as storage_enums}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; type PaymentConfirmOperation<'b, F> = BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>; async fn validate_request_with_state( &self, state: &SessionState, request: &api::PaymentsRequest, payment_data: &mut PaymentData<F>, business_profile: &domain::Profile, ) -> RouterResult<()> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router )> where F: 'b + Send, { todo!() } } #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] #[async_trait] impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for PaymentConfirm { #[instrument(skip_all)] async fn update_trackers<'b>( &'b self, state: &'b SessionState, req_state: ReqState, mut payment_data: PaymentData<F>, customer: Option<domain::Customer>, storage_scheme: storage_enums::MerchantStorageScheme, updated_customer: Option<storage::CustomerUpdate>, key_store: &domain::MerchantKeyStore, frm_suggestion: Option<FrmSuggestion>, header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<( BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>, async fn update_trackers<'b>( &'b self, state: &'b SessionState, req_state: ReqState, mut payment_data: PaymentData<F>, customer: Option<domain::Customer>, storage_scheme: storage_enums::MerchantStorageScheme, updated_customer: Option<storage::CustomerUpdate>, key_store: &domain::MerchantKeyStore, frm_suggestion: Option<FrmSuggestion>, header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<( BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>, PaymentData<F>, )> where F: 'b + Send, { { (Some(frm_suggestion), _) => status_handler_for_frm_results(frm_suggestion),<|fim_suffix|> <|fim_middle|> _ => default_status_result, } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router let get_trackers_response = operations::GetTrackerResponse { operation: Box::new(self), customer_details: Some(customer_details), payment_data, business_profile, mandate_type, }; Ok(get_trackers_response) } async fn validate_request_with_state( &self, state: &SessionState, request: &api::PaymentsRequest, payment_data: &mut PaymentData<F>, business_profile: &domain::Profile, ) -> RouterResult<()> { let payment_method_data: Option<&api_models::payments::PaymentMethodData> = request .payment_method_data .as_ref() .and_then(|request_payment_method_data| { request_payment_method_data.payment_method_data.as_ref() }); async fn validate_request_with_state( &self, state: &SessionState, request: &api::PaymentsRequest, payment_data: &mut PaymentData<F>, business_profile: &domain::Profile, ) -> RouterResult<()> { { Some(api_models::payments::PaymentMethodData::Card(_card)) => { payment_data.card_testing_guard_data = card_testing_guard_utils::validate_card_testing_guard_checks( state, request, payment_method_data, customer_id, business_profile, ) .await?; Ok(()) }<|fim_suffix|> <|fim_middle|> _ => Ok(()), } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router use api_models::{ admin::ExtendedCardInfoConfig, enums::FrmSuggestion, // payment_methods::PaymentMethodsData, payments::{ConnectorMandateReferenceId, ExtendedCardInfo, GetAddressFromPaymentMethodData}, }; use hyperswitch_domain_models::payments::payment_intent::PaymentIntentUpdateFields; use hyperswitch_domain_models::router_request_types::unified_authentication_service; use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest}; use crate::{ core::{ authentication, blocklist::utils as blocklist_utils, card_testing_guard::utils as card_testing_guard_utils, errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payments::{ self, helpers, operations, populate_surcharge_details, CustomerDetails, PaymentAddress, PaymentData, }, unified_authentication_service::{ self as uas_utils, types::{ClickToPay, UnifiedAuthenticationService}, }, utils as core_utils, }, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain::{self}, storage::{self, enums as storage_enums}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; type PaymentConfirmOperation<'b, F> = BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>; async fn update_trackers<'b>( &'b self, _state: &'b SessionState, _req_state: ReqState, mut _payment_data: PaymentData<F>, _customer: Option<domain::Customer>, _storage_scheme: storage_enums::MerchantStorageScheme, _updated_customer: Option<storage::CustomerUpdate>, _key_store: &domain::MerchantKeyStore, _frm_suggestion: Option<FrmSuggestion>, _header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<( BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>, PaymentData<F>, )> where F: 'b + Send, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router use crate::{ core::{ authentication, blocklist::utils as blocklist_utils, card_testing_guard::utils as card_testing_guard_utils, errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payments::{ self, helpers, operations, populate_surcharge_details, CustomerDetails, PaymentAddress, PaymentData, }, unified_authentication_service::{ self as uas_utils, types::{ClickToPay, UnifiedAuthenticationService}, }, utils as core_utils, }, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain::{self}, storage::{self, enums as storage_enums}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; type PaymentConfirmOperation<'b, F> = BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>; async fn guard_payment_against_blocklist<'a>( &'a self, state: &SessionState, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, payment_data: &mut PaymentData<F>, ) -> CustomResult<bool, errors::ApiErrorResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router use diesel_models::payment_attempt::ConnectorMandateReferenceId as DieselConnectorMandateReferenceId; use hyperswitch_domain_models::payments::payment_intent::PaymentIntentUpdateFields; use crate::{ core::{ authentication, blocklist::utils as blocklist_utils, card_testing_guard::utils as card_testing_guard_utils, errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payments::{ self, helpers, operations, populate_surcharge_details, CustomerDetails, PaymentAddress, PaymentData, }, unified_authentication_service::{ self as uas_utils, types::{ClickToPay, UnifiedAuthenticationService}, }, utils as core_utils, }, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain::{self}, storage::{self, enums as storage_enums}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; type PaymentConfirmOperation<'b, F> = BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>; async fn populate_payment_data<'a>( &'a self, state: &SessionState, payment_data: &mut PaymentData<F>, _merchant_account: &domain::MerchantAccount, business_profile: &domain::Profile, connector_data: &api::ConnectorData, ) -> CustomResult<(), errors::ApiErrorResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router use api_models::{ admin::ExtendedCardInfoConfig, enums::FrmSuggestion, // payment_methods::PaymentMethodsData, payments::{ConnectorMandateReferenceId, ExtendedCardInfo, GetAddressFromPaymentMethodData}, }; use crate::{ core::{ authentication, blocklist::utils as blocklist_utils, card_testing_guard::utils as card_testing_guard_utils, errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payments::{ self, helpers, operations, populate_surcharge_details, CustomerDetails, PaymentAddress, PaymentData, }, unified_authentication_service::{ self as uas_utils, types::{ClickToPay, UnifiedAuthenticationService}, }, utils as core_utils, }, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain::{self}, storage::{self, enums as storage_enums}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; type PaymentConfirmOperation<'b, F> = BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>; async fn get_or_create_customer_details<'a>( &'a self, state: &SessionState, payment_data: &mut PaymentData<F>, request: Option<CustomerDetails>, key_store: &domain::MerchantKeyStore, storage_scheme: common_enums::enums::MerchantStorageScheme, ) -> CustomResult< (PaymentConfirmOperation<'a, F>, Option<domain::Customer>), errors::StorageError, > { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router use api_models::payment_methods::PaymentMethodsData; use api_models::{ admin::ExtendedCardInfoConfig, enums::FrmSuggestion, // payment_methods::PaymentMethodsData, payments::{ConnectorMandateReferenceId, ExtendedCardInfo, GetAddressFromPaymentMethodData}, }; use diesel_models::payment_attempt::ConnectorMandateReferenceId as DieselConnectorMandateReferenceId; use hyperswitch_domain_models::payments::payment_intent::PaymentIntentUpdateFields; use crate::{ core::{ authentication, blocklist::utils as blocklist_utils, card_testing_guard::utils as card_testing_guard_utils, errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payments::{ self, helpers, operations, populate_surcharge_details, CustomerDetails, PaymentAddress, PaymentData, }, unified_authentication_service::{ self as uas_utils, types::{ClickToPay, UnifiedAuthenticationService}, }, utils as core_utils, }, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain::{self}, storage::{self, enums as storage_enums}, transformers::ForeignFrom, }, utils::{self, OptionExt}, }; type PaymentConfirmOperation<'b, F> = BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>; async fn call_external_three_ds_authentication_if_eligible<'a>( &'a self, state: &SessionState, payment_data: &mut PaymentData<F>, should_continue_confirm_transaction: &mut bool, connector_call_type: &ConnectorCallType, business_profile: &domain::Profile, key_store: &domain::MerchantKeyStore, mandate_type: Option<api_models::payments::MandateTransactionType>, ) -> CustomResult<(), errors::ApiErrorResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router )> where F: 'b + Send, { todo!() } } #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] #[async_trait] impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for PaymentConfirm { #[instrument(skip_all)] async fn update_trackers<'b>( &'b self, state: &'b SessionState, req_state: ReqState, mut payment_data: PaymentData<F>, customer: Option<domain::Customer>, storage_scheme: storage_enums::MerchantStorageScheme, updated_customer: Option<storage::CustomerUpdate>, key_store: &domain::MerchantKeyStore, frm_suggestion: Option<FrmSuggestion>, header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<( BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>, async fn update_trackers<'b>( &'b self, state: &'b SessionState, req_state: ReqState, mut payment_data: PaymentData<F>, customer: Option<domain::Customer>, storage_scheme: storage_enums::MerchantStorageScheme, updated_customer: Option<storage::CustomerUpdate>, key_store: &domain::MerchantKeyStore, frm_suggestion: Option<FrmSuggestion>, header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<( BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>, PaymentData<F>, )> where F: 'b + Send, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router != api_models::enums::AuthenticationStatus::Success { *should_continue_confirm_transaction = false; } Some(authentication) } None => None, }; Ok(()) } #[allow(clippy::too_many_arguments)] async fn call_unified_authentication_service_if_eligible<'a>( &'a self, state: &SessionState, payment_data: &mut PaymentData<F>, should_continue_confirm_transaction: &mut bool, connector_call_type: &ConnectorCallType, business_profile: &domain::Profile, key_store: &domain::MerchantKeyStore, mandate_type: Option<api_models::payments::MandateTransactionType>, do_authorisation_confirmation: &bool, ) -> CustomResult<(), errors::ApiErrorResponse> { let unified_authentication_service_flow = helpers::decide_action_for_unified_authentication_service( async fn call_unified_authentication_service_if_eligible<'a>( &'a self, state: &SessionState, payment_data: &mut PaymentData<F>, should_continue_confirm_transaction: &mut bool, connector_call_type: &ConnectorCallType, business_profile: &domain::Profile, key_store: &domain::MerchantKeyStore, mandate_type: Option<api_models::payments::MandateTransactionType>, do_authorisation_confirmation: &bool, ) -> CustomResult<(), errors::ApiErrorResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm.rs | crate: router #[derive(Debug, Clone, Copy, PaymentOperation)] #[operation(operations = "all", flow = "authorize")] pub struct PaymentConfirm; type PaymentConfirmOperation<'b, F> = BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>; #[async_trait] impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for PaymentConfirm { #[instrument(skip_all)] async fn get_trackers<'a>( &'a self, state: &'a SessionState, payment_id: &api::PaymentIdType, request: &api::PaymentsRequest, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, auth_flow: services::AuthFlow, header_payload: &hyperswitch_domain_models::payments::HeaderPayload, _platform_merchant_account: Option<&domain::MerchantAccount>, ) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>> { let key_manager_state = &state.into(); async fn get_trackers<'a>( &'a self, state: &'a SessionState, payment_id: &api::PaymentIdType, request: &api::PaymentsRequest, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, auth_flow: services::AuthFlow, header_payload: &hyperswitch_domain_models::payments::HeaderPayload, _platform_merchant_account: Option<&domain::MerchantAccount>, ) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>> { {let key_manager_state = &state.into();let merchant_id = merchant_account.get_id();let storage_scheme = merchant_account.storage_scheme;let (currency, amount);let payment_id = payment_id .get_payment_intent_id() .change_context(errors::ApiErrorResponse::PaymentNotFound)?;// Stage 1let store = &*state.store;let m_merchant_id = merchant_id.clone();// Parallel calls - level 0let mut payment_intent = store .find_payment_intent_by_payment_id_merchant_id( key_manager_state, &payment_id, &m_merchant_id, key_store, storage_scheme, ) .await .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;// TODO (#7195): Add platform merchant account validation once client_secret auth is solvedif let Some(order_details) = &request.order_details { helpers::validate_order_details_amount( order_details.to_owned(), payment_intent.amount, false, )?; }<|fim_suffix|> <|fim_middle|> let address = PaymentAddress::new( shipping_address.as_ref().map(From::from), billing_address.as_ref().map(From::from), payment_method_billing.as_ref().map(From::from), business_profile.use_billing_as_payment_method_billing, );let payment_method_data_billing = request .payment_method_data .as_ref() .and_then(|pmd| pmd.payment_method_data.as_ref()) .and_then(|payment_method_data_billing| { payment_method_data_billing.get_billing_address() }) .map(From::from);let unified_address = address.unify_with_payment_method_data_billing(payment_method_data_billing);// If processor_payment_token is passed in request then populating the same in PaymentDatalet mandate_id = request .recurring_details .as_ref() .and_then(|recurring_details| match recurring_details { api_models::mandates::RecurringDetails::ProcessorPaymentToken(token) => { payment_intent.is_payment_processor_token_flow = Some(true); Some(api_models::payments::MandateIds { mandate_id: None, mandate_reference_id: Some( api_models::payments::MandateReferenceId::ConnectorMandateId( ConnectorMandateReferenceId::new( Some(token.processor_payment_token.clone()), // connector_mandate_id None, // payment_method_id None, // update_history None, // mandate_metadata None, // connector_mandate_request_reference_id ), ), ), }) } _ => None, });let pmt_order_tax_amount = payment_intent.tax_details.clone().and_then(|tax| { if tax.payment_method_type.clone().map(|a| a.pmt) == payment_attempt.payment_method_type { tax.payment_method_type.map(|a| a.order_tax_amount) } else { None } });let order_tax_amount = pmt_order_tax_amount.or_else(|| { payment_intent .tax_details .clone() .and_then(|tax| tax.default.map(|a| a.order_tax_amount)) });payment_attempt .net_amount .set_order_tax_amount(order_tax_amount);payment_attempt.connector_mandate_detail = Some( DieselConnectorMandateReferenceId::foreign_from(ConnectorMandateReferenceId::new( None, None, None, // update_history None, // mandate_metadata Some(common_utils::generate_id_with_len( consts::CONNECTOR_MANDATE_REQUEST_REFERENCE_ID_LENGTH, )), // connector_mandate_request_reference_id )), );let payment_data = PaymentData { flow: PhantomData, payment_intent, payment_attempt, currency, amount, email: request.email.clone(), mandate_id: mandate_id.clone(), mandate_connector, setup_mandate, customer_acceptance: customer_acceptance.map(From::from), token, address: unified_address, token_data, confirm: request.confirm, payment_method_data: payment_method_data_after_card_bin_call.map(Into::into), payment_method_info, force_sync: None, refunds: vec![], disputes: vec![], attempts: None, sessions_token: vec![], card_cvc: request.card_cvc.clone(), creds_identifier, pm_token: None, connector_customer_id: None, recurring_mandate_payment_data, ephemeral_key: None, multiple_capture_data: None, redirect_response: None, surcharge_details: None, frm_message: None, payment_link_data: None, incremental_authorization_details: None, authorizations: vec![], authentication: None, recurring_details, poll_config: None, tax_data: None, session_id: None, service_details: request.ctp_service_details.clone(), card_testing_guard_data: None, vault_operation: None, threeds_method_comp_ind: None, };let get_trackers_response = operations::GetTrackerResponse { operation: Box::new(self), customer_details: Some(customer_details), payment_data, business_profile, mandate_type, };Ok(get_trackers_response)}}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router use api_models::{ enums::{FrmSuggestion, UpdateActiveAttempt}, payments::PaymentsUpdateIntentRequest, }; use common_utils::{ errors::CustomResult, ext_traits::{Encode, ValueExt}, types::keymanager::ToEncryptable, }; use hyperswitch_domain_models::{ payments::payment_intent::{PaymentIntentUpdate, PaymentIntentUpdateFields}, ApiModelToDieselModelConvertor, }; use crate::{ core::{ errors::{self, RouterResult}, payments::{ self, helpers, operations::{self, ValidateStatusForOperation}, }, utils::ValidatePlatformMerchant, }, db::errors::StorageErrorExt, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; async fn update_trackers<'b>( &'b self, state: &'b SessionState, _req_state: ReqState, mut payment_data: payments::PaymentIntentData<F>, _customer: Option<domain::Customer>, storage_scheme: enums::MerchantStorageScheme, _updated_customer: Option<storage::CustomerUpdate>, key_store: &domain::MerchantKeyStore, _frm_suggestion: Option<FrmSuggestion>, _header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<( PaymentsUpdateIntentOperation<'b, F>, payments::PaymentIntentData<F>, )> where F: 'b + Send, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router Ok(self) } } type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; #[async_trait] impl<F: Send + Clone> GetTracker<F, payments::PaymentIntentData<F>, PaymentsUpdateIntentRequest> for PaymentUpdateIntent { #[instrument(skip_all)] async fn get_trackers<'a>( &'a self, state: &'a SessionState, payment_id: &common_utils::id_type::GlobalPaymentId, request: &PaymentsUpdateIntentRequest, merchant_account: &domain::MerchantAccount, _profile: &domain::Profile, key_store: &domain::MerchantKeyStore, _header_payload: &hyperswitch_domain_models::payments::HeaderPayload, platform_merchant_account: Option<&domain::MerchantAccount>, ) -> RouterResult<operations::GetTrackerResponse<payments::PaymentIntentData<F>>> { let db = &*state.store; let key_manager_state = &state.into(); async fn get_trackers<'a>( &'a self, state: &'a SessionState, payment_id: &common_utils::id_type::GlobalPaymentId, request: &PaymentsUpdateIntentRequest, merchant_account: &domain::MerchantAccount, _profile: &domain::Profile, key_store: &domain::MerchantKeyStore, _header_payload: &hyperswitch_domain_models::payments::HeaderPayload, platform_merchant_account: Option<&domain::MerchantAccount>, ) -> RouterResult<operations::GetTrackerResponse<payments::PaymentIntentData<F>>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router use api_models::{ enums::{FrmSuggestion, UpdateActiveAttempt}, payments::PaymentsUpdateIntentRequest, }; use common_utils::{ errors::CustomResult, ext_traits::{Encode, ValueExt}, types::keymanager::ToEncryptable, }; use hyperswitch_domain_models::{ payments::payment_intent::{PaymentIntentUpdate, PaymentIntentUpdateFields}, ApiModelToDieselModelConvertor, }; use crate::{ core::{ errors::{self, RouterResult}, payments::{ self, helpers, operations::{self, ValidateStatusForOperation}, }, utils::ValidatePlatformMerchant, }, db::errors::StorageErrorExt, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; async fn guard_payment_against_blocklist<'a>( &'a self, _state: &SessionState, _merchant_account: &domain::MerchantAccount, _key_store: &domain::MerchantKeyStore, _payment_data: &mut payments::PaymentIntentData<F>, ) -> CustomResult<bool, errors::ApiErrorResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router use api_models::{ enums::{FrmSuggestion, UpdateActiveAttempt}, payments::PaymentsUpdateIntentRequest, }; use common_utils::{ errors::CustomResult, ext_traits::{Encode, ValueExt}, types::keymanager::ToEncryptable, }; use hyperswitch_domain_models::{ payments::payment_intent::{PaymentIntentUpdate, PaymentIntentUpdateFields}, ApiModelToDieselModelConvertor, }; use crate::{ core::{ errors::{self, RouterResult}, payments::{ self, helpers, operations::{self, ValidateStatusForOperation}, }, utils::ValidatePlatformMerchant, }, db::errors::StorageErrorExt, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; async fn perform_routing<'a>( &'a self, _merchant_account: &domain::MerchantAccount, _business_profile: &domain::Profile, _state: &SessionState, _payment_data: &mut payments::PaymentIntentData<F>, _mechant_key_store: &domain::MerchantKeyStore, ) -> CustomResult<api::ConnectorCallType, errors::ApiErrorResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router use api_models::{ enums::{FrmSuggestion, UpdateActiveAttempt}, payments::PaymentsUpdateIntentRequest, }; use hyperswitch_domain_models::{ payments::payment_intent::{PaymentIntentUpdate, PaymentIntentUpdateFields}, ApiModelToDieselModelConvertor, }; use crate::{ core::{ errors::{self, RouterResult}, payments::{ self, helpers, operations::{self, ValidateStatusForOperation}, }, utils::ValidatePlatformMerchant, }, db::errors::StorageErrorExt, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; async fn make_pm_data<'a>( &'a self, _state: &'a SessionState, _payment_data: &mut payments::PaymentIntentData<F>, _storage_scheme: enums::MerchantStorageScheme, _merchant_key_store: &domain::MerchantKeyStore, _customer: &Option<domain::Customer>, _business_profile: &domain::Profile, _should_retry_with_pan: bool, ) -> RouterResult<( PaymentsUpdateIntentOperation<'a, F>, Option<domain::PaymentMethodData>, Option<String>, )> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router use api_models::{ enums::{FrmSuggestion, UpdateActiveAttempt}, payments::PaymentsUpdateIntentRequest, }; use common_utils::{ errors::CustomResult, ext_traits::{Encode, ValueExt}, types::keymanager::ToEncryptable, }; use hyperswitch_domain_models::{ payments::payment_intent::{PaymentIntentUpdate, PaymentIntentUpdateFields}, ApiModelToDieselModelConvertor, }; use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest}; use crate::{ core::{ errors::{self, RouterResult}, payments::{ self, helpers, operations::{self, ValidateStatusForOperation}, }, utils::ValidatePlatformMerchant, }, db::errors::StorageErrorExt, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; async fn get_customer_details<'a>( &'a self, _state: &SessionState, _payment_data: &mut payments::PaymentIntentData<F>, _merchant_key_store: &domain::MerchantKeyStore, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult< ( BoxedOperation<'a, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>, Option<domain::Customer>, ), errors::StorageError, > { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router use api_models::{ enums::{FrmSuggestion, UpdateActiveAttempt}, payments::PaymentsUpdateIntentRequest, }; use crate::{ core::{ errors::{self, RouterResult}, payments::{ self, helpers, operations::{self, ValidateStatusForOperation}, }, utils::ValidatePlatformMerchant, }, db::errors::StorageErrorExt, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; fn validate_request<'a, 'b>( &'b self, _request: &PaymentsUpdateIntentRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<operations::ValidateResult> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router use api_models::{ enums::{FrmSuggestion, UpdateActiveAttempt}, payments::PaymentsUpdateIntentRequest, }; use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest}; use crate::{ core::{ errors::{self, RouterResult}, payments::{ self, helpers, operations::{self, ValidateStatusForOperation}, }, utils::ValidatePlatformMerchant, }, db::errors::StorageErrorExt, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; fn to_update_tracker( &self, ) -> RouterResult<&(dyn UpdateTracker<F, Self::Data, PaymentsUpdateIntentRequest> + Send + Sync)> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router use api_models::{ enums::{FrmSuggestion, UpdateActiveAttempt}, payments::PaymentsUpdateIntentRequest, }; use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest}; use crate::{ core::{ errors::{self, RouterResult}, payments::{ self, helpers, operations::{self, ValidateStatusForOperation}, }, utils::ValidatePlatformMerchant, }, db::errors::StorageErrorExt, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; fn to_domain(&self) -> RouterResult<&dyn Domain<F, PaymentsUpdateIntentRequest, Self::Data>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router use api_models::{ enums::{FrmSuggestion, UpdateActiveAttempt}, payments::PaymentsUpdateIntentRequest, }; use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest}; use crate::{ core::{ errors::{self, RouterResult}, payments::{ self, helpers, operations::{self, ValidateStatusForOperation}, }, utils::ValidatePlatformMerchant, }, db::errors::StorageErrorExt, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; fn to_get_tracker( &self, ) -> RouterResult<&(dyn GetTracker<F, Self::Data, PaymentsUpdateIntentRequest> + Send + Sync)> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router use api_models::{ enums::{FrmSuggestion, UpdateActiveAttempt}, payments::PaymentsUpdateIntentRequest, }; use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest}; use crate::{ core::{ errors::{self, RouterResult}, payments::{ self, helpers, operations::{self, ValidateStatusForOperation}, }, utils::ValidatePlatformMerchant, }, db::errors::StorageErrorExt, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; fn to_domain(&self) -> RouterResult<&(dyn Domain<F, PaymentsUpdateIntentRequest, Self::Data>)> { Ok(*self) }
ast_fragments
// file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router use api_models::{ enums::{FrmSuggestion, UpdateActiveAttempt}, payments::PaymentsUpdateIntentRequest, }; use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest}; use crate::{ core::{ errors::{self, RouterResult}, payments::{ self, helpers, operations::{self, ValidateStatusForOperation}, }, utils::ValidatePlatformMerchant, }, db::errors::StorageErrorExt, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; fn to_get_tracker( &self, ) -> RouterResult<&(dyn GetTracker<F, Self::Data, PaymentsUpdateIntentRequest> + Send + Sync)> { Ok(*self) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router use api_models::{ enums::{FrmSuggestion, UpdateActiveAttempt}, payments::PaymentsUpdateIntentRequest, }; use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest}; use crate::{ core::{ errors::{self, RouterResult}, payments::{ self, helpers, operations::{self, ValidateStatusForOperation}, }, utils::ValidatePlatformMerchant, }, db::errors::StorageErrorExt, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; fn to_validate_request( &self, ) -> RouterResult< &(dyn ValidateRequest<F, PaymentsUpdateIntentRequest, Self::Data> + Send + Sync), > { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/router/src/core/payments/operations/payment_update_intent.rs | crate: router use std::marker::PhantomData; use api_models::{ enums::{FrmSuggestion, UpdateActiveAttempt}, payments::PaymentsUpdateIntentRequest, }; use common_utils::{ errors::CustomResult, ext_traits::{Encode, ValueExt}, types::keymanager::ToEncryptable, }; use diesel_models::types::FeatureMetadata; use hyperswitch_domain_models::{ payments::payment_intent::{PaymentIntentUpdate, PaymentIntentUpdateFields}, ApiModelToDieselModelConvertor, }; use masking::PeekInterface; use crate::{ core::{ errors::{self, RouterResult}, payments::{ self, helpers, operations::{self, ValidateStatusForOperation}, }, utils::ValidatePlatformMerchant, }, db::errors::StorageErrorExt, routes::{app::ReqState, SessionState}, types::{ api, domain::{self, types as domain_types}, storage::{self, enums}, }, }; type PaymentsUpdateIntentOperation<'b, F> = BoxedOperation<'b, F, PaymentsUpdateIntentRequest, payments::PaymentIntentData<F>>; async fn get_trackers<'a>( &'a self, state: &'a SessionState, payment_id: &common_utils::id_type::GlobalPaymentId, request: &PaymentsUpdateIntentRequest, merchant_account: &domain::MerchantAccount, _profile: &domain::Profile, key_store: &domain::MerchantKeyStore, _header_payload: &hyperswitch_domain_models::payments::HeaderPayload, platform_merchant_account: Option<&domain::MerchantAccount>, ) -> RouterResult<operations::GetTrackerResponse<payments::PaymentIntentData<F>>> { 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, payment_id, key_store, storage_scheme) .await .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; payment_intent .validate_platform_merchant(platform_merchant_account.map(|ma| ma.get_id()))?; self.validate_status_for_operation(payment_intent.status)?; let PaymentsUpdateIntentRequest { amount_details, routing_algorithm_id, capture_method, authentication_type, billing, shipping, customer_present, description, return_url, setup_future_usage, apply_mit_exemption, statement_descriptor, order_details, allowed_payment_method_types, metadata, connector_metadata, feature_metadata, payment_link_config, request_incremental_authorization, session_expiry, frm_metadata, request_external_three_ds_authentication, set_active_attempt_id, } = request.clone(); let batch_encrypted_data = domain_types::crypto_operation( key_manager_state, common_utils::type_name!(hyperswitch_domain_models::payments::PaymentIntent), domain_types::CryptoOperation::BatchEncrypt( hyperswitch_domain_models::payments::FromRequestEncryptablePaymentIntent::to_encryptable( hyperswitch_domain_models::payments::FromRequestEncryptablePaymentIntent { shipping_address: shipping.map(|address| address.encode_to_value()).transpose().change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to encode shipping address")?.map(masking::Secret::new), billing_address: billing.map(|address| address.encode_to_value()).transpose().change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to encode billing address")?.map(masking::Secret::new), customer_details: None, }, ), ), common_utils::types::keymanager::Identifier::Merchant(merchant_account.get_id().to_owned()), key_store.key.peek(), ) .await .and_then(|val| val.try_into_batchoperation()) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed while encrypting payment intent details".to_string())?; let decrypted_payment_intent = hyperswitch_domain_models::payments::FromRequestEncryptablePaymentIntent::from_encryptable(batch_encrypted_data) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed while encrypting payment intent details")?; let order_details = order_details.clone().map(|order_details| { order_details .into_iter() .map(|order_detail| { masking::Secret::new( diesel_models::types::OrderDetailsWithAmount::convert_from(order_detail), ) }) .collect() }); let session_expiry = session_expiry.map(|expiry| { payment_intent .created_at .saturating_add(time::Duration::seconds(i64::from(expiry))) }); let updated_amount_details = match amount_details { Some(details) => payment_intent.amount_details.update_from_request(&details), None => payment_intent.amount_details, }; let active_attempt_id = set_active_attempt_id .map(|active_attempt_req| match active_attempt_req { UpdateActiveAttempt::Set(global_attempt_id) => Some(global_attempt_id), UpdateActiveAttempt::Unset => None, }) .unwrap_or(payment_intent.active_attempt_id); let payment_intent = hyperswitch_domain_models::payments::PaymentIntent { amount_details: updated_amount_details, description: description.or(payment_intent.description), return_url: return_url.or(payment_intent.return_url), metadata: metadata.or(payment_intent.metadata), statement_descriptor: statement_descriptor.or(payment_intent.statement_descriptor), modified_at: common_utils::date_time::now(), order_details, connector_metadata: connector_metadata.or(payment_intent.connector_metadata), feature_metadata: (feature_metadata .map(FeatureMetadata::convert_from) .or(payment_intent.feature_metadata)), updated_by: storage_scheme.to_string(), request_incremental_authorization: request_incremental_authorization .unwrap_or(payment_intent.request_incremental_authorization), session_expiry: session_expiry.unwrap_or(payment_intent.session_expiry), request_external_three_ds_authentication: request_external_three_ds_authentication .unwrap_or(payment_intent.request_external_three_ds_authentication), frm_metadata: frm_metadata.or(payment_intent.frm_metadata), billing_address: decrypted_payment_intent .billing_address .as_ref() .map(|data| { data.clone() .deserialize_inner_value(|value| value.parse_value("Address")) }) .transpose() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to decode billing address")?, shipping_address: decrypted_payment_intent .shipping_address .as_ref() .map(|data| { data.clone() .deserialize_inner_value(|value| value.parse_value("Address")) }) .transpose() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to decode shipping address")?, capture_method: capture_method.unwrap_or(payment_intent.capture_method), authentication_type: authentication_type.or(payment_intent.authentication_type), payment_link_config: payment_link_config .map(ApiModelToDieselModelConvertor::convert_from) .or(payment_intent.payment_link_config), apply_mit_exemption: apply_mit_exemption.unwrap_or(payment_intent.apply_mit_exemption), customer_present: customer_present.unwrap_or(payment_intent.customer_present), routing_algorithm_id: routing_algorithm_id.or(payment_intent.routing_algorithm_id), allowed_payment_method_types: allowed_payment_method_types .or(payment_intent.allowed_payment_method_types), active_attempt_id, ..payment_intent }; let payment_data = payments::PaymentIntentData { flow: PhantomData, payment_intent, sessions_token: vec![], }; let get_trackers_response = operations::GetTrackerResponse { payment_data }; Ok(get_trackers_response) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update.rs | crate: router use hyperswitch_domain_models::payments::payment_intent::{ CustomerData, PaymentIntentUpdateFields, }; use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{self, enums as storage_enums, payment_attempt::PaymentAttemptExt}, transformers::ForeignTryFrom, }, utils::OptionExt, }; type PaymentUpdateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; fn populate_payment_intent_with_request( payment_intent: &mut storage::PaymentIntent, request: &api::PaymentsRequest, ) { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update.rs | crate: router use api_models::{ enums::FrmSuggestion, mandates::RecurringDetails, payments::RequestSurchargeDetails, }; use error_stack::{report, ResultExt}; use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{self, enums as storage_enums, payment_attempt::PaymentAttemptExt}, transformers::ForeignTryFrom, }, utils::OptionExt, }; type PaymentUpdateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<(PaymentUpdateOperation<'b, F>, operations::ValidateResult)> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update.rs | crate: router use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{self, enums as storage_enums, payment_attempt::PaymentAttemptExt}, transformers::ForeignTryFrom, }, utils::OptionExt, }; type PaymentUpdateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; async fn make_pm_data<'a>( &'a self, state: &'a SessionState, payment_data: &mut PaymentData<F>, storage_scheme: storage_enums::MerchantStorageScheme, merchant_key_store: &domain::MerchantKeyStore, customer: &Option<domain::Customer>, business_profile: &domain::Profile, should_retry_with_pan: bool, ) -> RouterResult<( PaymentUpdateOperation<'a, F>, Option<domain::PaymentMethodData>, Option<String>, )> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update.rs | crate: router payment_id, storage_scheme: merchant_account.storage_scheme, requeue: matches!( request.retry_action, Some(api_models::enums::RetryAction::Requeue) ), }, )) } } impl PaymentUpdate { fn populate_payment_attempt_with_request( payment_attempt: &mut storage::PaymentAttempt, request: &api::PaymentsRequest, ) { request .business_sub_label .clone() .map(|bsl| payment_attempt.business_sub_label.replace(bsl)); request .payment_method_type .map(|pmt| payment_attempt.payment_method_type.replace(pmt)); request .payment_experience fn populate_payment_attempt_with_request( payment_attempt: &mut storage::PaymentAttempt, request: &api::PaymentsRequest, ) { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/payments/operations/payment_update.rs | crate: router use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{self, enums as storage_enums, payment_attempt::PaymentAttemptExt}, transformers::ForeignTryFrom, }, utils::OptionExt, }; type PaymentUpdateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; fn populate_payment_attempt_with_request( payment_attempt: &mut storage::PaymentAttempt, request: &api::PaymentsRequest, ) { request .business_sub_label .clone() .map(|bsl| payment_attempt.business_sub_label.replace(bsl)); request .payment_method_type .map(|pmt| payment_attempt.payment_method_type.replace(pmt)); request .payment_experience .map(|experience| payment_attempt.payment_experience.replace(experience)); payment_attempt.amount_to_capture = request .amount_to_capture .or(payment_attempt.amount_to_capture); request .capture_method .map(|i| payment_attempt.capture_method.replace(i)); }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update.rs | crate: router use common_utils::{ ext_traits::{AsyncExt, Encode, ValueExt}, pii::Email, types::keymanager::KeyManagerState, }; use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{self, enums as storage_enums, payment_attempt::PaymentAttemptExt}, transformers::ForeignTryFrom, }, utils::OptionExt, }; fn foreign_try_from(value: domain::Customer) -> Result<Self, Self::Error> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update.rs | crate: router use api_models::{ enums::FrmSuggestion, mandates::RecurringDetails, payments::RequestSurchargeDetails, }; use hyperswitch_domain_models::payments::payment_intent::{ CustomerData, PaymentIntentUpdateFields, }; use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{self, enums as storage_enums, payment_attempt::PaymentAttemptExt}, transformers::ForeignTryFrom, }, utils::OptionExt, }; type PaymentUpdateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; async fn update_trackers<'b>( &'b self, _state: &'b SessionState, req_state: ReqState, mut _payment_data: PaymentData<F>, _customer: Option<domain::Customer>, _storage_scheme: storage_enums::MerchantStorageScheme, _updated_customer: Option<storage::CustomerUpdate>, _key_store: &domain::MerchantKeyStore, _frm_suggestion: Option<FrmSuggestion>, _header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<(PaymentUpdateOperation<'b, F>, PaymentData<F>)> where F: 'b + Send, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update.rs | crate: router use api_models::{ enums::FrmSuggestion, mandates::RecurringDetails, payments::RequestSurchargeDetails, }; use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{self, enums as storage_enums, payment_attempt::PaymentAttemptExt}, transformers::ForeignTryFrom, }, utils::OptionExt, }; type PaymentUpdateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; async fn get_or_create_customer_details<'a>( &'a self, state: &SessionState, payment_data: &mut PaymentData<F>, request: Option<CustomerDetails>, key_store: &domain::MerchantKeyStore, storage_scheme: common_enums::enums::MerchantStorageScheme, ) -> CustomResult<(PaymentUpdateOperation<'a, F>, Option<domain::Customer>), errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/payments/operations/payment_update.rs | crate: router use api_models::{ enums::FrmSuggestion, mandates::RecurringDetails, payments::RequestSurchargeDetails, }; use common_utils::{ ext_traits::{AsyncExt, Encode, ValueExt}, pii::Email, types::keymanager::KeyManagerState, }; use hyperswitch_domain_models::payments::payment_intent::{ CustomerData, PaymentIntentUpdateFields, }; use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{self, enums as storage_enums, payment_attempt::PaymentAttemptExt}, transformers::ForeignTryFrom, }, utils::OptionExt, }; type PaymentUpdateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; async fn payments_dynamic_tax_calculation<'a>( &'a self, state: &SessionState, payment_data: &mut PaymentData<F>, _connector_call_type: &ConnectorCallType, business_profile: &domain::Profile, key_store: &domain::MerchantKeyStore, merchant_account: &domain::MerchantAccount, ) -> CustomResult<(), errors::ApiErrorResponse> { let is_tax_connector_enabled = business_profile.get_is_tax_connector_enabled(); let skip_external_tax_calculation = payment_data .payment_intent .skip_external_tax_calculation .unwrap_or(false); if is_tax_connector_enabled && !skip_external_tax_calculation { let db = state.store.as_ref(); let key_manager_state: &KeyManagerState = &state.into(); let merchant_connector_id = business_profile .tax_connector_id .as_ref() .get_required_value("business_profile.tax_connector_id")?; #[cfg(feature = "v1")] let mca = db .find_by_merchant_connector_account_merchant_id_merchant_connector_id( key_manager_state, &business_profile.merchant_id, merchant_connector_id, key_store, ) .await .to_not_found_response( errors::ApiErrorResponse::MerchantConnectorAccountNotFound { id: merchant_connector_id.get_string_repr().to_string(), }, )?; #[cfg(feature = "v2")] let mca = db .find_merchant_connector_account_by_id( key_manager_state, merchant_connector_id, key_store, ) .await .to_not_found_response( errors::ApiErrorResponse::MerchantConnectorAccountNotFound { id: merchant_connector_id.get_string_repr().to_string(), }, )?; let connector_data = api::TaxCalculateConnectorData::get_connector_by_name(&mca.connector_name)?; let router_data = core_utils::construct_payments_dynamic_tax_calculation_router_data( state, merchant_account, key_store, payment_data, &mca, ) .await?; let connector_integration: services::BoxedPaymentConnectorIntegrationInterface< api::CalculateTax, types::PaymentsTaxCalculationData, types::TaxCalculationResponseData, > = connector_data.connector.get_connector_integration(); let response = services::execute_connector_processing_step( state, connector_integration, &router_data, payments::CallConnectorAction::Trigger, None, ) .await .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Tax connector Response Failed")?; let tax_response = response.response.map_err(|err| { errors::ApiErrorResponse::ExternalConnectorError { code: err.code, message: err.message, connector: connector_data.connector_name.clone().to_string(), status_code: err.status_code, reason: err.reason, } })?; payment_data.payment_intent.tax_details = Some(diesel_models::TaxDetails { default: Some(diesel_models::DefaultTax { order_tax_amount: tax_response.order_tax_amount, }), payment_method_type: None, }); Ok(()) } else { Ok(()) } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update.rs | crate: router use api_models::{ enums::FrmSuggestion, mandates::RecurringDetails, payments::RequestSurchargeDetails, }; use common_utils::{ ext_traits::{AsyncExt, Encode, ValueExt}, pii::Email, types::keymanager::KeyManagerState, }; use hyperswitch_domain_models::payments::payment_intent::{ CustomerData, PaymentIntentUpdateFields, }; use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{self, enums as storage_enums, payment_attempt::PaymentAttemptExt}, transformers::ForeignTryFrom, }, utils::OptionExt, }; type PaymentUpdateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; async fn update_trackers<'b>( &'b self, state: &'b SessionState, req_state: ReqState, mut payment_data: PaymentData<F>, customer: Option<domain::Customer>, storage_scheme: storage_enums::MerchantStorageScheme, _updated_customer: Option<storage::CustomerUpdate>, key_store: &domain::MerchantKeyStore, _frm_suggestion: Option<FrmSuggestion>, _header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<(PaymentUpdateOperation<'b, F>, PaymentData<F>)> where F: 'b + Send, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/operations/payment_update.rs | crate: router use std::marker::PhantomData; use api_models::{ enums::FrmSuggestion, mandates::RecurringDetails, payments::RequestSurchargeDetails, }; use common_utils::{ ext_traits::{AsyncExt, Encode, ValueExt}, pii::Email, types::keymanager::KeyManagerState, }; use hyperswitch_domain_models::payments::payment_intent::{ CustomerData, PaymentIntentUpdateFields, }; use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_methods::cards::create_encrypted_data, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ self, api::{self, ConnectorCallType, PaymentIdTypeExt}, domain, storage::{self, enums as storage_enums, payment_attempt::PaymentAttemptExt}, transformers::ForeignTryFrom, }, utils::OptionExt, }; type PaymentUpdateOperation<'a, F> = BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>; async fn get_trackers<'a>( &'a self, state: &'a SessionState, payment_id: &api::PaymentIdType, request: &api::PaymentsRequest, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, auth_flow: services::AuthFlow, _header_payload: &hyperswitch_domain_models::payments::HeaderPayload, _platform_merchant_account: Option<&domain::MerchantAccount>, ) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/routing/transformers.rs | crate: router use crate::{ configs::settings, types::transformers::{ForeignFrom, ForeignInto}, }; fn foreign_from(from: settings::CurrencyCountryFlowFilter) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/routing/transformers.rs | crate: router use crate::{ configs::settings, types::transformers::{ForeignFrom, ForeignInto}, }; fn foreign_from(from: settings::PaymentMethodFilterKey) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/routing/transformers.rs | crate: router use std::collections::HashMap; use crate::{ configs::settings, types::transformers::{ForeignFrom, ForeignInto}, }; fn foreign_from(from: settings::PaymentMethodFilters) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/routing/transformers.rs | crate: router use crate::{ configs::settings, types::transformers::{ForeignFrom, ForeignInto}, }; fn foreign_from(from: settings::NotAvailableFlows) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/router/src/core/payments/routing/transformers.rs | crate: router use crate::{ configs::settings, types::transformers::{ForeignFrom, ForeignInto}, }; fn foreign_from(from: settings::CurrencyCountryFlowFilter) -> Self { Self { currency: from.currency, country: from.country, not_available_flows: from.not_available_flows.map(ForeignInto::foreign_into), } }
ast_fragments
// file: hyperswitch/crates/router/src/core/payments/routing/transformers.rs | crate: router use crate::{ configs::settings, types::transformers::{ForeignFrom, ForeignInto}, }; fn foreign_from(from: settings::PaymentMethodFilterKey) -> Self { match from { settings::PaymentMethodFilterKey::PaymentMethodType(pmt) => { Self::PaymentMethodType(pmt) } settings::PaymentMethodFilterKey::CardNetwork(cn) => Self::CardNetwork(cn), } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/routing/transformers.rs | crate: router use diesel_models::enums as storage_enums; fn foreign_from(from: storage_enums::MandateDataType) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/routing/transformers.rs | crate: router use api_models::{self, routing as routing_types}; fn foreign_from(from: api_models::payments::MandateType) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/routing/transformers.rs | crate: router use api_models::{self, routing as routing_types}; fn foreign_from(from: api_models::payments::AcceptanceType) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/routing/transformers.rs | crate: router use diesel_models::enums as storage_enums; use euclid::{enums as dsl_enums, frontend::ast as dsl_ast}; fn foreign_from(value: storage_enums::CaptureMethod) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/routing/transformers.rs | crate: router use api_models::{self, routing as routing_types}; fn foreign_from(from: routing_types::RoutableConnectorChoice) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/complete_authorize_flow.rs | crate: router use super::{ConstructFlowSpecificData, Feature}; use crate::{ core::{ errors::{ApiErrorResponse, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, routes::{metrics, SessionState}, services, types::{self, api, domain, transformers::ForeignTryFrom}, }; async fn process_capture_flow( mut router_data: types::RouterData< api::CompleteAuthorize, types::CompleteAuthorizeData, types::PaymentsResponseData, >, complete_authorize_response: types::PaymentsResponseData, state: &SessionState, connector: &api::ConnectorData, call_connector_action: payments::CallConnectorAction, business_profile: &domain::Profile, header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult< types::RouterData< api::CompleteAuthorize, types::CompleteAuthorizeData, types::PaymentsResponseData, >, > { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/complete_authorize_flow.rs | crate: router use crate::{ core::{ errors::{ApiErrorResponse, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, routes::{metrics, SessionState}, services, types::{self, api, domain, transformers::ForeignTryFrom}, }; fn foreign_try_from( item: types::RouterData<F, types::CompleteAuthorizeData, types::PaymentsResponseData>, ) -> Result<Self, Self::Error> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/complete_authorize_flow.rs | crate: router use crate::{ core::{ errors::{ApiErrorResponse, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, routes::{metrics, SessionState}, services, types::{self, api, domain, transformers::ForeignTryFrom}, }; pub async fn complete_authorize_preprocessing_steps<F: Clone>( state: &SessionState, router_data: &types::RouterData<F, types::CompleteAuthorizeData, types::PaymentsResponseData>, confirm: bool, connector: &api::ConnectorData, ) -> RouterResult<types::RouterData<F, types::CompleteAuthorizeData, types::PaymentsResponseData>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/complete_authorize_flow.rs | crate: router use crate::{ core::{ errors::{ApiErrorResponse, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, routes::{metrics, SessionState}, services, types::{self, api, domain, transformers::ForeignTryFrom}, }; async fn add_payment_method_token<'a>( &mut self, state: &SessionState, connector: &api::ConnectorData, _tokenization_action: &payments::TokenizationAction, should_continue_payment: bool, ) -> RouterResult<types::PaymentMethodTokenResult> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/complete_authorize_flow.rs | crate: router use crate::{ core::{ errors::{ApiErrorResponse, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, routes::{metrics, SessionState}, services, types::{self, api, domain, transformers::ForeignTryFrom}, }; async fn construct_router_data<'a>( &self, state: &SessionState, connector_id: &str, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, customer: &Option<domain::Customer>, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option<types::MerchantRecipientData>, header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>, ) -> RouterResult< types::RouterData< api::CompleteAuthorize, types::CompleteAuthorizeData, types::PaymentsResponseData, >, > { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/complete_authorize_flow.rs | crate: router use crate::{ core::{ errors::{ApiErrorResponse, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, routes::{metrics, SessionState}, services, types::{self, api, domain, transformers::ForeignTryFrom}, }; async fn build_flow_specific_connector_request( &mut self, state: &SessionState, connector: &api::ConnectorData, call_connector_action: payments::CallConnectorAction, ) -> RouterResult<(Option<services::Request>, bool)> { { payments::CallConnectorAction::Trigger => { let connector_integration: services::BoxedPaymentConnectorIntegrationInterface< api::CompleteAuthorize, types::CompleteAuthorizeData, types::PaymentsResponseData, > = connector.connector.get_connector_integration(); connector_integration .build_request(self, &state.conf.connectors) .to_payment_failed_response()? }<|fim_suffix|> <|fim_middle|> _ => None, } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/complete_authorize_flow.rs | crate: router use crate::{ core::{ errors::{ApiErrorResponse, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, routes::{metrics, SessionState}, services, types::{self, api, domain, transformers::ForeignTryFrom}, }; async fn construct_router_data<'a>( &self, state: &SessionState, connector_id: &str, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, customer: &Option<domain::Customer>, merchant_connector_account: &domain::MerchantConnectorAccount, merchant_recipient_data: Option<types::MerchantRecipientData>, header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>, ) -> RouterResult< types::RouterData< api::CompleteAuthorize, types::CompleteAuthorizeData, types::PaymentsResponseData, >, > { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/incremental_authorization_flow.rs | crate: router use crate::{ core::{ errors::{ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, Feature, PaymentData}, }, routes::SessionState, services, types::{self, api, domain}, }; async fn decide_flows<'a>( self, state: &SessionState, connector: &api::ConnectorData, call_connector_action: payments::CallConnectorAction, connector_request: Option<services::Request>, _business_profile: &domain::Profile, _header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<Self> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/incremental_authorization_flow.rs | crate: router use crate::{ core::{ errors::{ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, Feature, PaymentData}, }, routes::SessionState, services, types::{self, api, domain}, }; async fn construct_router_data<'a>( &self, state: &SessionState, connector_id: &str, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, customer: &Option<domain::Customer>, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option<types::MerchantRecipientData>, header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>, ) -> RouterResult<types::PaymentsIncrementalAuthorizationRouterData> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/incremental_authorization_flow.rs | crate: router use crate::{ core::{ errors::{ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, Feature, PaymentData}, }, routes::SessionState, services, types::{self, api, domain}, }; async fn build_flow_specific_connector_request( &mut self, state: &SessionState, connector: &api::ConnectorData, call_connector_action: payments::CallConnectorAction, ) -> RouterResult<(Option<services::Request>, bool)> { { payments::CallConnectorAction::Trigger => { let connector_integration: services::BoxedPaymentConnectorIntegrationInterface< api::IncrementalAuthorization, types::PaymentsIncrementalAuthorizationData, types::PaymentsResponseData, > = connector.connector.get_connector_integration(); connector_integration .build_request(self, &state.conf.connectors) .to_payment_failed_response()? }<|fim_suffix|> <|fim_middle|> _ => None, } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/incremental_authorization_flow.rs | crate: router use crate::{ core::{ errors::{ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, Feature, PaymentData}, }, routes::SessionState, services, types::{self, api, domain}, }; async fn construct_router_data<'a>( &self, state: &SessionState, connector_id: &str, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, customer: &Option<domain::Customer>, merchant_connector_account: &domain::MerchantConnectorAccount, merchant_recipient_data: Option<types::MerchantRecipientData>, header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>, ) -> RouterResult<types::PaymentsIncrementalAuthorizationRouterData> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use hyperswitch_domain_models::payments::PaymentIntentData; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; async fn decide_flow<'a, 'b>( &'b self, state: &'a routes::SessionState, connector: &api::ConnectorData, _confirm: Option<bool>, call_connector_action: payments::CallConnectorAction, business_profile: &domain::Profile, header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<Self> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; fn create_paypal_sdk_session_token( _state: &routes::SessionState, router_data: &types::PaymentsSessionRouterData, connector: &api::ConnectorData, _business_profile: &domain::Profile, ) -> RouterResult<types::PaymentsSessionRouterData> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; fn get_allowed_payment_methods_from_cards( gpay_info: payment_types::GooglePayWalletDetails, gpay_token_specific_data: &payment_types::GooglePayTokenizationSpecification, is_billing_details_required: bool, ) -> RouterResult<payment_types::GpayAllowedPaymentMethods> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use hyperswitch_domain_models::payments::PaymentIntentData; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; fn create_apple_pay_session_response( router_data: &types::PaymentsSessionRouterData, session_response: Option<payment_types::ApplePaySessionResponse>, apple_pay_payment_request: Option<payment_types::ApplePayPaymentRequest>, connector_name: String, delayed_response: bool, next_action: payment_types::NextActionCall, header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<types::PaymentsSessionRouterData> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; fn get_apple_pay_payment_request( amount_info: payment_types::AmountInfo, payment_request_data: payment_types::PaymentRequestMetadata, session_data: types::PaymentsSessionData, merchant_identifier: &str, merchant_business_country: Option<api_models::enums::CountryAlpha2>, required_billing_contact_fields: Option<payment_types::ApplePayBillingContactFields>, required_shipping_contact_fields: Option<payment_types::ApplePayShippingContactFields>, ) -> RouterResult<payment_types::ApplePayPaymentRequest> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; /// Function to determine whether the shipping address is required to be collected from the wallet, /// based on business profile settings, the payment method type, and the connector required fields /// for the specific payment method type. /// /// If `always_collect_shipping_details_from_wallet_connector` is enabled, it indicates that the /// shipping address is always required to be collected from the wallet. /// /// If only `collect_shipping_details_from_wallet_connector` is enabled, the shipping address will be /// collected only if the connector required fields for the specific payment method type contain /// the shipping fields. fn is_shipping_address_required_to_be_collected_form_wallet( state: &routes::SessionState, connector: &api::ConnectorData, business_profile: &domain::Profile, payment_method_type: enums::PaymentMethodType, ) -> bool { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; /// Function to determine whether the billing address is required to be collected from the wallet, /// based on business profile settings, the payment method type, and the connector's required fields /// for the specific payment method. /// /// If `always_collect_billing_details_from_wallet_connector` is enabled, it indicates that the /// billing address is always required to be collected from the wallet. /// /// If only `collect_billing_details_from_wallet_connector` is enabled, the billing address will be /// collected only if the connector required fields for the specific payment method type contain /// the billing fields. fn is_billing_address_required_to_be_collected_from_wallet( state: &routes::SessionState, connector: &api::ConnectorData, business_profile: &domain::Profile, payment_method_type: enums::PaymentMethodType, ) -> bool { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use hyperswitch_domain_models::payments::PaymentIntentData; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; fn create_paze_session_token( router_data: &types::PaymentsSessionRouterData, _header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<types::PaymentsSessionRouterData> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; fn is_dynamic_fields_required( required_fields: &settings::RequiredFields, payment_method: enums::PaymentMethod, payment_method_type: enums::PaymentMethodType, connector: types::Connector, required_field_type: Vec<enums::FieldType>, ) -> bool { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use hyperswitch_domain_models::payments::PaymentIntentData; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; async fn construct_router_data<'a>( &self, state: &routes::SessionState, connector_id: &str, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, customer: &Option<domain::Customer>, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option<types::MerchantRecipientData>, header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>, ) -> RouterResult<types::PaymentsSessionRouterData> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; /// for the specific payment method type. /// /// If `always_collect_shipping_details_from_wallet_connector` is enabled, it indicates that the /// shipping address is always required to be collected from the wallet. /// /// If only `collect_shipping_details_from_wallet_connector` is enabled, the shipping address will be /// collected only if the connector required fields for the specific payment method type contain /// the shipping fields. fn is_shipping_address_required_to_be_collected_form_wallet( state: &routes::SessionState, connector: &api::ConnectorData, business_profile: &domain::Profile, payment_method_type: enums::PaymentMethodType, ) -> bool { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; /// for the specific payment method. /// /// If `always_collect_billing_details_from_wallet_connector` is enabled, it indicates that the /// billing address is always required to be collected from the wallet. /// /// If only `collect_billing_details_from_wallet_connector` is enabled, the billing address will be /// collected only if the connector required fields for the specific payment method type contain /// the billing fields. fn is_billing_address_required_to_be_collected_from_wallet( state: &routes::SessionState, connector: &api::ConnectorData, business_profile: &domain::Profile, payment_method_type: enums::PaymentMethodType, ) -> bool { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use error_stack::{Report, ResultExt}; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; fn log_session_response_if_error( response: &Result<Result<types::Response, types::Response>, Report<errors::ApiClientError>>, ) { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; fn is_session_response_delayed( state: &routes::SessionState, connector: &api::ConnectorData, ) -> bool { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; fn get_apple_pay_amount_info( label: &str, session_data: types::PaymentsSessionData, ) -> RouterResult<payment_types::AmountInfo> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; fn get_session_request_for_manual_apple_pay( session_token_data: payment_types::SessionTokenInfo, merchant_domain: Option<String>, ) -> RouterResult<payment_types::ApplepaySessionRequest> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; fn get_session_request_for_simplified_apple_pay( apple_pay_merchant_identifier: String, session_token_data: payment_types::SessionTokenForSimplifiedApplePay, ) -> payment_types::ApplepaySessionRequest { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use masking::{ExposeInterface, ExposeOptionInterface}; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; fn build_apple_pay_session_request( state: &routes::SessionState, request: payment_types::ApplepaySessionRequest, apple_pay_merchant_cert: masking::Secret<String>, apple_pay_merchant_cert_key: masking::Secret<String>, ) -> RouterResult<services::Request> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; async fn add_access_token<'a>( &self, state: &routes::SessionState, connector: &api::ConnectorData, merchant_account: &domain::MerchantAccount, creds_identifier: Option<&str>, ) -> RouterResult<types::AddAccessTokenResult> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use hyperswitch_domain_models::payments::PaymentIntentData; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; async fn decide_flows<'a>( self, state: &routes::SessionState, connector: &api::ConnectorData, call_connector_action: payments::CallConnectorAction, _connector_request: Option<services::Request>, business_profile: &domain::Profile, header_payload: hyperswitch_domain_models::payments::HeaderPayload, ) -> RouterResult<Self> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; async fn get_merchant_recipient_data<'a>( &self, _state: &routes::SessionState, _merchant_account: &domain::MerchantAccount, _key_store: &domain::MerchantKeyStore, _merchant_connector_account: &helpers::MerchantConnectorAccountType, _connector: &api::ConnectorData, ) -> RouterResult<Option<types::MerchantRecipientData>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use hyperswitch_domain_models::payments::PaymentIntentData; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; async fn construct_router_data<'a>( &self, state: &routes::SessionState, connector_id: &str, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, customer: &Option<domain::Customer>, merchant_connector_account: &domain::MerchantConnectorAccount, merchant_recipient_data: Option<types::MerchantRecipientData>, header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>, ) -> RouterResult<types::PaymentsSessionRouterData> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use hyperswitch_domain_models::payments::PaymentIntentData; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; fn create_samsung_pay_session_token( state: &routes::SessionState, router_data: &types::PaymentsSessionRouterData, header_payload: hyperswitch_domain_models::payments::HeaderPayload, connector: &api::ConnectorData, business_profile: &domain::Profile, ) -> RouterResult<types::PaymentsSessionRouterData> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payments/flows/session_flow.rs | crate: router use api_models::{admin as admin_types, payments as payment_types}; use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, types::{AmountConvertor, StringMajorUnitForConnector}, }; use hyperswitch_domain_models::payments::PaymentIntentData; use crate::{ consts::PROTOCOL, core::{ errors::{self, ConnectorErrorExt, RouterResult}, payments::{self, access_token, helpers, transformers, PaymentData}, }, headers, logger, routes::{self, app::settings, metrics}, services, types::{ self, api::{self, enums}, domain, }, utils::OptionExt, }; fn create_gpay_session_token( state: &routes::SessionState, router_data: &types::PaymentsSessionRouterData, connector: &api::ConnectorData, business_profile: &domain::Profile, ) -> RouterResult<types::PaymentsSessionRouterData> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments