text stringlengths 70 351k | source stringclasses 4 values |
|---|---|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts/helpers.rs | crate: router
use api_models::{enums, payment_methods::Card, payouts};
use common_utils::{
crypto::Encryptable,
encryption::Encryption,
errors::CustomResult,
ext_traits::{AsyncExt, StringExt},
fp_utils, id_type, payout_method_utils as payout_additional, pii, type_name,
types::{
keymanager::{Identifier, KeyManagerState},
MinorUnit, UnifiedCode, UnifiedMessage,
},
};
use error_stack::{report, ResultExt};
use super::PayoutData;
use crate::{
consts,
core::{
errors::{self, RouterResult, StorageErrorExt},
payment_methods::{
cards,
transformers::{DataDuplicationCheck, StoreCardReq, StoreGenericReq, StoreLockerReq},
vault,
},
payments::{helpers as payment_helpers, routing, CustomerDetails},
routing::TransactionData,
utils as core_utils,
},
db::StorageInterface,
routes::{metrics, SessionState},
services,
types::{
api::{self, enums as api_enums},
domain::{self, types::AsyncLift},
storage,
transformers::ForeignFrom,
},
utils::{self, OptionExt},
};
pub async fn make_payout_method_data(
state: &SessionState,
payout_method_data: Option<&api::PayoutMethodData>,
payout_token: Option<&str>,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
payout_type: Option<api_enums::PayoutType>,
merchant_key_store: &domain::MerchantKeyStore,
payout_data: Option<&mut PayoutData>,
storage_scheme: storage::enums::MerchantStorageScheme,
) -> RouterResult<Option<api::PayoutMethodData>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payouts/helpers.rs | crate: router
})
})
})
});
Ok(connector_transfer_method_id)
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "payment_methods_v2")
))]
pub async fn save_payout_data_to_locker(
state: &SessionState,
payout_data: &mut PayoutData,
customer_id: &id_type::CustomerId,
payout_method_data: &api::PayoutMethodData,
connector_mandate_details: Option<serde_json::Value>,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> RouterResult<()> {
let payouts = &payout_data.payouts;
let key_manager_state = state.into();
let (mut locker_req, card_details, bank_details, wallet_details, payment_method_type) =
match payout_method_data {
pub async fn save_payout_data_to_locker(
state: &SessionState,
payout_data: &mut PayoutData,
customer_id: &id_type::CustomerId,
payout_method_data: &api::PayoutMethodData,
connector_mandate_details: Option<serde_json::Value>,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> RouterResult<()> {
{let payouts = &payout_data.payouts;<|fim_suffix|>
<|fim_middle|>
Ok(())}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use std::{
collections::{HashMap, HashSet},
marker::PhantomData,
str::FromStr,
};
use api_models::payouts::PayoutVendorAccountDetails;
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use crate::{constants::UNSUPPORTED_ERROR_MESSAGE, types::RefreshTokenRouterData};
pub(crate) fn convert_payment_authorize_router_response<F1, F2, T1, T2>(
item: (&ConnectorRouterData<F1, T1, PaymentsResponseData>, T2),
) -> ConnectorRouterData<F2, T2, PaymentsResponseData> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use crate::{constants::UNSUPPORTED_ERROR_MESSAGE, types::RefreshTokenRouterData};
pub(crate) fn convert_setup_mandate_router_data_to_authorize_router_data(
data: &SetupMandateRouterData,
) -> PaymentsAuthorizeData {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use std::{
collections::{HashMap, HashSet},
marker::PhantomData,
str::FromStr,
};
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use error_stack::{report, ResultExt};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use image::{DynamicImage, ImageBuffer, ImageFormat, Luma, Rgba};
type Error = error_stack::Report<errors::ConnectorError>;
pub fn new_colored_from_data(
data: String,
hex_color: &str,
) -> Result<Self, error_stack::Report<common_utils::errors::QrCodeError>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
"Šibenik-Knin County" => Ok(Self::SibenikKninCounty),
_ => Err(errors::ConnectorError::InvalidDataFormat {
field_name: "address.state",
}
.into()),
},
}
}
}
impl ForeignTryFrom<String> for BulgariaStatesAbbreviation {
type Error = error_stack::Report<errors::ConnectorError>;
fn foreign_try_from(value: String) -> Result<Self, Self::Error> {
let state_abbreviation_check =
StringExt::<Self>::parse_enum(value.clone(), "BulgariaStatesAbbreviation");
match state_abbreviation_check {
Ok(state_abbreviation) => Ok(state_abbreviation),
Err(_) => match value.as_str() {
"Blagoevgrad Province" => Ok(Self::BlagoevgradProvince),
"Burgas Province" => Ok(Self::BurgasProvince),
"Dobrich Province" => Ok(Self::DobrichProvince),
"Gabrovo Province" => Ok(Self::GabrovoProvince),
"Haskovo Province" => Ok(Self::HaskovoProvince),
"Kardzhali Province" => Ok(Self::KardzhaliProvince),
"Kyustendil Province" => Ok(Self::KyustendilProvince),
fn foreign_try_from(value: String) -> Result<Self, Self::Error> {
let state_abbreviation_check =
StringExt::<Self>::parse_enum(value.clone(), "BulgariaStatesAbbreviation");
match state_abbreviation_check {
Ok(state_abbreviation) => Ok(state_abbreviation),
Err(_) => match value.as_str() {
"Blagoevgrad Province" => Ok(Self::BlagoevgradProvince),
"Burgas Province" => Ok(Self::BurgasProvince),
"Dobrich Province" => Ok(Self::DobrichProvince),
"Gabrovo Province" => Ok(Self::GabrovoProvince),
"Haskovo Province" => Ok(Self::HaskovoProvince),
"Kardzhali Province" => Ok(Self::KardzhaliProvince),
"Kyustendil Province" => Ok(Self::KyustendilProvince),
"Lovech Province" => Ok(Self::LovechProvince),
"Montana Province" => Ok(Self::MontanaProvince),
"Pazardzhik Province" => Ok(Self::PazardzhikProvince),
"Pernik Province" => Ok(Self::PernikProvince),
"Pleven Province" => Ok(Self::PlevenProvince),
"Plovdiv Province" => Ok(Self::PlovdivProvince),
"Razgrad Province" => Ok(Self::RazgradProvince),
"Ruse Province" => Ok(Self::RuseProvince),
"Shumen" => Ok(Self::Shumen),
"Silistra Province" => Ok(Self::SilistraProvince),
"Sliven Province" => Ok(Self::SlivenProvince),
"Smolyan Province" => Ok(Self::SmolyanProvince),
"Sofia City Province" => Ok(Self::SofiaCityProvince),
"Sofia Province" => Ok(Self::SofiaProvince),
"Stara Zagora Province" => Ok(Self::StaraZagoraProvince),
"Targovishte Provinc" => Ok(Self::TargovishteProvince),
"Varna Province" => Ok(Self::VarnaProvince),
"Veliko Tarnovo Province" => Ok(Self::VelikoTarnovoProvince),
"Vidin Province" => Ok(Self::VidinProvince),
"Vratsa Province" => Ok(Self::VratsaProvince),
"Yambol Province" => Ok(Self::YambolProvince),
_ => Err(errors::ConnectorError::InvalidDataFormat {
field_name: "address.state",
}
.into()),
},
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_enums::{
enums,
enums::{
AlbaniaStatesAbbreviation, AndorraStatesAbbreviation, AttemptStatus,
AustriaStatesAbbreviation, BelarusStatesAbbreviation, BelgiumStatesAbbreviation,
BosniaAndHerzegovinaStatesAbbreviation, BulgariaStatesAbbreviation,
CanadaStatesAbbreviation, CroatiaStatesAbbreviation, CzechRepublicStatesAbbreviation,
DenmarkStatesAbbreviation, FinlandStatesAbbreviation, FranceStatesAbbreviation,
FutureUsage, GermanyStatesAbbreviation, GreeceStatesAbbreviation,
HungaryStatesAbbreviation, IcelandStatesAbbreviation, IrelandStatesAbbreviation,
ItalyStatesAbbreviation, LatviaStatesAbbreviation, LiechtensteinStatesAbbreviation,
LithuaniaStatesAbbreviation, LuxembourgStatesAbbreviation, MaltaStatesAbbreviation,
MoldovaStatesAbbreviation, MonacoStatesAbbreviation, MontenegroStatesAbbreviation,
NetherlandsStatesAbbreviation, NorthMacedoniaStatesAbbreviation, NorwayStatesAbbreviation,
PolandStatesAbbreviation, PortugalStatesAbbreviation, RomaniaStatesAbbreviation,
RussiaStatesAbbreviation, SanMarinoStatesAbbreviation, SerbiaStatesAbbreviation,
SlovakiaStatesAbbreviation, SloveniaStatesAbbreviation, SpainStatesAbbreviation,
SwedenStatesAbbreviation, SwitzerlandStatesAbbreviation, UkraineStatesAbbreviation,
UnitedKingdomStatesAbbreviation, UsStatesAbbreviation,
},
};
use crate::{constants::UNSUPPORTED_ERROR_MESSAGE, types::RefreshTokenRouterData};
pub(crate) fn is_payment_failure(status: AttemptStatus) -> bool {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use std::{
collections::{HashMap, HashSet},
marker::PhantomData,
str::FromStr,
};
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use router_env::logger;
use serde_json::Value;
use crate::{constants::UNSUPPORTED_ERROR_MESSAGE, types::RefreshTokenRouterData};
type Error = error_stack::Report<errors::ConnectorError>;
pub(crate) fn handle_json_response_deserialization_failure(
res: Response,
connector: &'static str,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
{
Ok(_) => Err(errors::ConnectorError::ResponseDeserializationFailed)?,<|fim_suffix|>
<|fim_middle|>
Err(error_msg) => {
logger::error!(deserialization_error=?error_msg);
logger::error!("UNEXPECTED RESPONSE FROM CONNECTOR: {}", response_data);
Ok(ErrorResponse {
status_code: res.status_code,
code: consts::NO_ERROR_CODE.to_string(),
message: UNSUPPORTED_ERROR_MESSAGE.to_string(),
reason: Some(response_data),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
}
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use std::{
collections::{HashMap, HashSet},
marker::PhantomData,
str::FromStr,
};
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use crate::{constants::UNSUPPORTED_ERROR_MESSAGE, types::RefreshTokenRouterData};
type Error = error_stack::Report<errors::ConnectorError>;
pub(crate) fn construct_captures_response_hashmap<T>(
capture_sync_response_list: Vec<T>,
) -> CustomResult<HashMap<String, CaptureSyncResponse>, errors::ConnectorError>
where
T: MultipleCaptureSyncResponse,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
}
}
pub trait WalletData {
fn get_wallet_token(&self) -> Result<Secret<String>, Error>;
fn get_wallet_token_as_json<T>(&self, wallet_name: String) -> Result<T, Error>
where
T: serde::de::DeserializeOwned;
fn get_encoded_wallet_token(&self) -> Result<String, Error>;
}
impl WalletData for payment_method_data::WalletData {
fn get_wallet_token(&self) -> Result<Secret<String>, Error> {
match self {
Self::GooglePay(data) => Ok(Secret::new(data.tokenization_data.token.clone())),
Self::ApplePay(data) => Ok(data.get_applepay_decoded_payment_data()?),
Self::PaypalSdk(data) => Ok(Secret::new(data.token.clone())),
_ => Err(errors::ConnectorError::InvalidWallet.into()),
}
}
fn get_wallet_token_as_json<T>(&self, wallet_name: String) -> Result<T, Error>
where
T: serde::de::DeserializeOwned,
{
serde_json::from_str::<T>(self.get_wallet_token()?.peek())
fn get_wallet_token(&self) -> Result<Secret<String>, Error> {
{
Self::GooglePay(data) => Ok(Secret::new(data.tokenization_data.token.clone())),<|fim_suffix|>
<|fim_middle|>
_ => Err(errors::ConnectorError::InvalidWallet.into()),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
fn from(pm_data: PaymentMethodData) -> Self {
{
payment_method_data::BankRedirectData::BancontactCard { .. } => {
Self::BancontactCard
}<|fim_suffix|>
<|fim_middle|>
payment_method_data::BankRedirectData::LocalBankRedirect {} => {
Self::LocalBankRedirect
}
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use std::{
collections::{HashMap, HashSet},
marker::PhantomData,
str::FromStr,
};
use once_cell::sync::Lazy;
use regex::Regex;
type Error = error_stack::Report<errors::ConnectorError>;
/// Normalizes a string by converting to lowercase, performing NFKD normalization(https://unicode.org/reports/tr15/#Description_Norm),and removing special characters and spaces.
pub fn normalize_string(value: String) -> Result<String, regex::Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use rand::Rng;
pub fn generate_12_digit_number() -> u64 {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
#[cfg(feature = "v1")]
fn get_cryptogram(&self) -> Option<Secret<String>> {
self.token_cryptogram.clone()
}
#[cfg(feature = "v2")]
fn get_cryptogram(&self) -> Option<Secret<String>> {
self.cryptogram.clone()
}
}
pub fn convert_uppercase<'de, D, T>(v: D) -> Result<T, D::Error>
where
D: serde::Deserializer<'de>,
T: FromStr,
<T as FromStr>::Err: std::fmt::Debug + std::fmt::Display + std::error::Error,
{
use serde::de::Error;
let output = <&str>::deserialize(v)?;
output.to_uppercase().parse::<T>().map_err(D::Error::custom)
}
pub(crate) fn convert_setup_mandate_router_data_to_authorize_router_data(
data: &SetupMandateRouterData,
pub fn convert_uppercase<'de, D, T>(v: D) -> Result<T, D::Error>
where
D: serde::Deserializer<'de>,
T: FromStr,
<T as FromStr>::Err: std::fmt::Debug + std::fmt::Display + std::error::Error,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use masking::{ExposeInterface, PeekInterface, Secret};
fn get_cryptogram(&self) -> Option<Secret<String>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use masking::{ExposeInterface, PeekInterface, Secret};
fn get_network_token_expiry_year(&self) -> Secret<String> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use masking::{ExposeInterface, PeekInterface, Secret};
fn get_network_token_expiry_month(&self) -> Secret<String> {
self.network_token_exp_month.clone()
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use masking::{ExposeInterface, PeekInterface, Secret};
fn get_network_token_expiry_month(&self) -> Secret<String> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
fn get_network_token(&self) -> NetworkTokenNumber {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use masking::{ExposeInterface, PeekInterface, Secret};
fn get_expiry_year_4_digit(&self) -> Secret<String> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use masking::{ExposeInterface, PeekInterface, Secret};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_cardholder_name(&self) -> Result<Secret<String>, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use masking::{ExposeInterface, PeekInterface, Secret};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_expiry_year_as_4_digit_i32(&self) -> Result<Secret<i32>, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use masking::{ExposeInterface, PeekInterface, Secret};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_expiry_date_as_mmyy(&self) -> Result<Secret<String>, errors::ConnectorError> {
let year = self.get_card_expiry_year_2_digit()?.expose();
let month = self.expiry_month.clone().expose();
Ok(Secret::new(format!("{month}{year}")))
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use masking::{ExposeInterface, PeekInterface, Secret};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_expiry_year_as_i32(&self) -> Result<Secret<i32>, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use masking::{ExposeInterface, PeekInterface, Secret};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_expiry_month_as_i8(&self) -> Result<Secret<i8>, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use masking::{ExposeInterface, PeekInterface, Secret};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_card_expiry_month_year_2_digit_with_delimiter(
&self,
delimiter: String,
) -> Result<Secret<String>, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_card_issuer(&self) -> Result<CardIssuer, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use masking::{ExposeInterface, PeekInterface, Secret};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_card_expiry_year_2_digit(&self) -> Result<Secret<String>, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
}
}
pub trait RecurringMandateData {
fn get_original_payment_amount(&self) -> Result<i64, Error>;
fn get_original_payment_currency(&self) -> Result<enums::Currency, Error>;
}
impl RecurringMandateData for RecurringMandatePaymentData {
fn get_original_payment_amount(&self) -> Result<i64, Error> {
self.original_payment_authorized_amount
.ok_or_else(missing_field_err("original_payment_authorized_amount"))
}
fn get_original_payment_currency(&self) -> Result<enums::Currency, Error> {
self.original_payment_authorized_currency
.ok_or_else(missing_field_err("original_payment_authorized_currency"))
}
}
#[cfg(feature = "payouts")]
impl CardData for api_models::payouts::CardPayout {
fn get_card_expiry_year_2_digit(&self) -> Result<Secret<String>, errors::ConnectorError> {
let binding = self.expiry_year.clone();
let year = binding.peek();
Ok(Secret::new(
year.get(year.len() - 2..)
fn get_original_payment_currency(&self) -> Result<enums::Currency, Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_original_payment_amount(&self) -> Result<i64, Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
&self,
) -> Result<hyperswitch_domain_models::router_request_types::CustomerDetails, Error> {
self.customer_details
.clone()
.ok_or_else(missing_field_err("customer_details"))
}
fn get_vendor_details(&self) -> Result<PayoutVendorAccountDetails, Error> {
self.vendor_details
.clone()
.ok_or_else(missing_field_err("vendor_details"))
}
#[cfg(feature = "payouts")]
fn get_payout_type(&self) -> Result<enums::PayoutType, Error> {
self.payout_type
.to_owned()
.ok_or_else(missing_field_err("payout_type"))
}
}
pub trait RevokeMandateRequestData {
fn get_connector_mandate_id(&self) -> Result<String, Error>;
}
impl RevokeMandateRequestData for MandateRevokeRequestData {
fn get_connector_mandate_id(&self) -> Result<String, Error> {
self.connector_mandate_id
fn get_payout_type(&self) -> Result<enums::PayoutType, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_customer_details(
&self,
) -> Result<hyperswitch_domain_models::router_request_types::CustomerDetails, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use std::{
collections::{HashMap, HashSet},
marker::PhantomData,
str::FromStr,
};
pub fn is_html_response(response: &str) -> bool {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use std::{
collections::{HashMap, HashSet},
marker::PhantomData,
str::FromStr,
};
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use router_env::logger;
use serde::Deserialize;
type Error = error_stack::Report<errors::ConnectorError>;
pub fn deserialize_xml_to_struct<T: serde::de::DeserializeOwned>(
xml_data: &[u8],
) -> Result<T, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use serde_json::Value;
type Error = error_stack::Report<errors::ConnectorError>;
fn get_encoded_wallet_token(&self) -> Result<String, Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use serde::Deserialize;
use serde_json::Value;
type Error = error_stack::Report<errors::ConnectorError>;
fn get_wallet_token_as_json<T>(&self, wallet_name: String) -> Result<T, Error>
where
T: serde::de::DeserializeOwned,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use masking::{ExposeInterface, PeekInterface, Secret};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_wallet_token(&self) -> Result<Secret<String>, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use masking::{ExposeInterface, PeekInterface, Secret};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_applepay_decoded_payment_data(&self) -> Result<Secret<String>, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use serde_json::Value;
pub fn collect_and_sort_values_by_removing_signature(
value: &Value,
signature: &String,
) -> Vec<String> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use serde_json::Value;
pub fn collect_values_by_removing_signature(value: &Value, signature: &String) -> Vec<String> {
{
Value::Null => vec!["null".to_owned()],<|fim_suffix|>
<|fim_middle|>
Value::Object(obj) => obj
.values()
.flat_map(|v| collect_values_by_removing_signature(v, signature))
.collect(),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
type Error = error_stack::Report<errors::ConnectorError>;
pub fn get_mandate_details(
setup_mandate_details: Option<mandates::MandateData>,
) -> Result<Option<mandates::MandateAmountData>, error_stack::Report<errors::ConnectorError>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
}
#[cfg(test)]
mod tests {
use crate::utils;
#[test]
fn test_image_data_source_url() {
let qr_image_data_source_url = utils::QrImage::new_from_data("Hyperswitch".to_string());
assert!(qr_image_data_source_url.is_ok());
}
}
pub fn is_mandate_supported(
selected_pmd: PaymentMethodData,
payment_method_type: Option<enums::PaymentMethodType>,
mandate_implemented_pmds: HashSet<PaymentMethodDataType>,
connector: &'static str,
) -> Result<(), Error> {
if mandate_implemented_pmds.contains(&PaymentMethodDataType::from(selected_pmd.clone())) {
Ok(())
} else {
match payment_method_type {
Some(pm_type) => Err(errors::ConnectorError::NotSupported {
message: format!("{} mandate payment", pm_type),
connector,
pub fn is_mandate_supported(
selected_pmd: PaymentMethodData,
payment_method_type: Option<enums::PaymentMethodType>,
mandate_implemented_pmds: HashSet<PaymentMethodDataType>,
connector: &'static str,
) -> Result<(), Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
fn test_image_data_source_url() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use std::{
collections::{HashMap, HashSet},
marker::PhantomData,
str::FromStr,
};
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
type Error = error_stack::Report<errors::ConnectorError>;
pub fn parse_hex_color(hex: &str) -> Result<(u8, u8, u8), common_utils::errors::QrCodeError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use std::{
collections::{HashMap, HashSet},
marker::PhantomData,
str::FromStr,
};
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use error_stack::{report, ResultExt};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use image::{DynamicImage, ImageBuffer, ImageFormat, Luma, Rgba};
type Error = error_stack::Report<errors::ConnectorError>;
pub fn new_from_data(
data: String,
) -> Result<Self, error_stack::Report<common_utils::errors::QrCodeError>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
"Šumadija District" => Ok(Self::ŠumadijaDistrict),
_ => Err(errors::ConnectorError::InvalidDataFormat {
field_name: "address.state",
}
.into()),
},
}
}
}
impl ForeignTryFrom<String> for SlovakiaStatesAbbreviation {
type Error = error_stack::Report<errors::ConnectorError>;
fn foreign_try_from(value: String) -> Result<Self, Self::Error> {
let state_abbreviation_check =
StringExt::<Self>::parse_enum(value.clone(), "SlovakiaStatesAbbreviation");
match state_abbreviation_check {
Ok(state_abbreviation) => Ok(state_abbreviation),
Err(_) => match value.as_str() {
"Banská Bystrica Region" => Ok(Self::BanskaBystricaRegion),
"Bratislava Region" => Ok(Self::BratislavaRegion),
"Košice Region" => Ok(Self::KosiceRegion),
"Nitra Region" => Ok(Self::NitraRegion),
"Prešov Region" => Ok(Self::PresovRegion),
"Trenčín Region" => Ok(Self::TrencinRegion),
"Trnava Region" => Ok(Self::TrnavaRegion),
fn foreign_try_from(value: String) -> Result<Self, Self::Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
"Vlorë" => Ok(Self::Vlore),
_ => Err(errors::ConnectorError::InvalidDataFormat {
field_name: "address.state",
}
.into()),
},
}
}
}
impl ForeignTryFrom<String> for AndorraStatesAbbreviation {
type Error = error_stack::Report<errors::ConnectorError>;
fn foreign_try_from(value: String) -> Result<Self, Self::Error> {
let state_abbreviation_check =
StringExt::<Self>::parse_enum(value.clone(), "AndorraStatesAbbreviation");
match state_abbreviation_check {
Ok(state_abbreviation) => Ok(state_abbreviation),
Err(_) => match value.as_str() {
"Andorra la Vella" => Ok(Self::AndorraLaVella),
"Canillo" => Ok(Self::Canillo),
"Encamp" => Ok(Self::Encamp),
"Escaldes-Engordany" => Ok(Self::EscaldesEngordany),
"La Massana" => Ok(Self::LaMassana),
"Ordino" => Ok(Self::Ordino),
"Sant Julià de Lòria" => Ok(Self::SantJuliaDeLoria),
fn foreign_try_from(value: String) -> Result<Self, Self::Error> {
{
Ok(state_abbreviation) => Ok(state_abbreviation),<|fim_suffix|>
<|fim_middle|>
Err(_) => match value.as_str() {
"Andorra la Vella" => Ok(Self::AndorraLaVella),
"Canillo" => Ok(Self::Canillo),
"Encamp" => Ok(Self::Encamp),
"Escaldes-Engordany" => Ok(Self::EscaldesEngordany),
"La Massana" => Ok(Self::LaMassana),
"Ordino" => Ok(Self::Ordino),
"Sant Julià de Lòria" => Ok(Self::SantJuliaDeLoria),
_ => Err(errors::ConnectorError::InvalidDataFormat {
field_name: "address.state",
}
.into()),
},
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_pay_currency(&self) -> Result<String, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use std::{
collections::{HashMap, HashSet},
marker::PhantomData,
str::FromStr,
};
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use error_stack::{report, ResultExt};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_header_field(
field: Option<&http::HeaderValue>,
) -> CustomResult<&str, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use std::{
collections::{HashMap, HashSet},
marker::PhantomData,
str::FromStr,
};
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
type Error = error_stack::Report<errors::ConnectorError>;
pub fn get_http_header<'a>(
key: &str,
headers: &'a http::HeaderMap,
) -> CustomResult<&'a str, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use std::{
collections::{HashMap, HashSet},
marker::PhantomData,
str::FromStr,
};
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
type Error = error_stack::Report<errors::ConnectorError>;
pub fn get_header_key_value<'a>(
key: &str,
headers: &'a actix_web::http::header::HeaderMap,
) -> CustomResult<&'a str, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_device_model(&self) -> Result<String, Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_os_version(&self) -> Result<String, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_os_type(&self) -> Result<String, Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_java_script_enabled(&self) -> Result<bool, Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_java_enabled(&self) -> Result<bool, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_time_zone(&self) -> Result<i32, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_user_agent(&self) -> Result<String, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_color_depth(&self) -> Result<u8, Error> {
self.color_depth
.ok_or_else(missing_field_err("browser_info.color_depth"))
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_screen_width(&self) -> Result<u32, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_screen_height(&self) -> Result<u32, Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_language(&self) -> Result<String, Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use api_models::payments;
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
fn connector_mandate_id(&self) -> Option<String> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_redirect_response_payload(&self) -> Result<pii::SecretSerdeValue, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_webhook_url(&self) -> Result<String, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
}
fn get_currency(&self) -> Result<enums::Currency, Error> {
self.currency.ok_or_else(missing_field_err("currency"))
}
fn get_amount(&self) -> Result<i64, Error> {
self.amount.ok_or_else(missing_field_err("amount"))
}
// New minor amount function for amount framework
fn get_minor_amount(&self) -> Result<MinorUnit, Error> {
self.minor_amount.ok_or_else(missing_field_err("amount"))
}
fn is_auto_capture(&self) -> Result<bool, Error> {
match self.capture_method {
Some(enums::CaptureMethod::Automatic)
| None
| Some(enums::CaptureMethod::SequentialAutomatic) => Ok(true),
Some(enums::CaptureMethod::Manual) => Ok(false),
Some(enums::CaptureMethod::ManualMultiple) | Some(enums::CaptureMethod::Scheduled) => {
Err(errors::ConnectorError::CaptureMethodNotSupported.into())
}
}
}
fn get_order_details(&self) -> Result<Vec<OrderDetailsWithAmount>, Error> {
self.order_details
fn is_auto_capture(&self) -> Result<bool, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_minor_amount(&self) -> Result<MinorUnit, Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_amount(&self) -> Result<i64, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
fn connector_mandate_id(&self) -> Option<String>;
}
impl PaymentsPreProcessingRequestData for PaymentsPreProcessingData {
fn get_email(&self) -> Result<Email, Error> {
self.email.clone().ok_or_else(missing_field_err("email"))
}
fn get_payment_method_type(&self) -> Result<enums::PaymentMethodType, Error> {
self.payment_method_type
.to_owned()
.ok_or_else(missing_field_err("payment_method_type"))
}
fn get_currency(&self) -> Result<enums::Currency, Error> {
self.currency.ok_or_else(missing_field_err("currency"))
}
fn get_amount(&self) -> Result<i64, Error> {
self.amount.ok_or_else(missing_field_err("amount"))
}
// New minor amount function for amount framework
fn get_minor_amount(&self) -> Result<MinorUnit, Error> {
self.minor_amount.ok_or_else(missing_field_err("amount"))
}
fn is_auto_capture(&self) -> Result<bool, Error> {
match self.capture_method {
fn get_currency(&self) -> Result<enums::Currency, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use masking::{ExposeInterface, PeekInterface, Secret};
fn get_optional_last_name(&self) -> Option<Secret<String>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use masking::{ExposeInterface, PeekInterface, Secret};
fn get_optional_first_name(&self) -> Option<Secret<String>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_email(&self) -> Result<Email, Error> {
self.email.clone().ok_or_else(missing_field_err("email"))
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use api_models::payments;
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_threeds_method_comp_ind(&self) -> Result<payments::ThreeDsCompletionIndicator, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_complete_authorize_url(&self) -> Result<String, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_email(&self) -> Result<Email, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_browser_info(&self) -> Result<BrowserInformation, Error> {
self.browser_info
.clone()
.ok_or_else(missing_field_err("browser_info"))
} | ast_fragments |
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
.ok_or_else(missing_field_err("webhook_url"))
}
fn get_optional_language_from_browser_info(&self) -> Option<String> {
self.browser_info
.clone()
.and_then(|browser_info| browser_info.language)
}
fn get_complete_authorize_url(&self) -> Result<String, Error> {
self.complete_authorize_url
.clone()
.ok_or_else(missing_field_err("complete_authorize_url"))
}
fn is_auto_capture(&self) -> Result<bool, Error> {
match self.capture_method {
Some(enums::CaptureMethod::Automatic)
| Some(enums::CaptureMethod::SequentialAutomatic)
| None => Ok(true),
Some(enums::CaptureMethod::Manual) => Ok(false),
Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()),
}
}
}
pub trait PaymentMethodTokenizationRequestData {
fn get_browser_info(&self) -> Result<BrowserInformation, Error>;
fn is_auto_capture(&self) -> Result<bool, Error> {
match self.capture_method {
Some(enums::CaptureMethod::Automatic)
| Some(enums::CaptureMethod::SequentialAutomatic)
| None => Ok(true),
Some(enums::CaptureMethod::Manual) => Ok(false),
Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()),
}
} | ast_fragments |
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_complete_authorize_url(&self) -> Result<String, Error> {
self.complete_authorize_url
.clone()
.ok_or_else(missing_field_err("complete_authorize_url"))
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
fn get_optional_language_from_browser_info(&self) -> Option<String> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_return_url(&self) -> Result<String, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_router_return_url(&self) -> Result<String, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_browser_info(&self) -> Result<BrowserInformation, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use serde_json::Value;
type Error = error_stack::Report<errors::ConnectorError>;
fn get_connector_metadata(&self) -> Result<Value, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_cancellation_reason(&self) -> Result<String, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_connector_transaction_id(&self) -> CustomResult<String, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
fn is_multiple_capture(&self) -> bool {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
Some(payments::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
Some(network_transaction_id.clone())
}
Some(payments::MandateReferenceId::ConnectorMandateId(_))
| Some(payments::MandateReferenceId::NetworkTokenWithNTI(_))
| None => None,
})
}
fn get_optional_email(&self) -> Option<Email> {
self.email.clone()
}
fn get_card_network_from_additional_payment_method_data(
&self,
) -> Result<enums::CardNetwork, Error> {
match &self.additional_payment_method_data {
Some(payments::AdditionalPaymentData::Card(card_data)) => Ok(card_data
.card_network
.clone()
.ok_or_else(|| errors::ConnectorError::MissingRequiredField {
field_name: "card_network",
})?),
_ => Err(errors::ConnectorError::MissingRequiredFields {
field_names: vec!["card_network"],
}
fn get_card_network_from_additional_payment_method_data(
&self,
) -> Result<enums::CardNetwork, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
connector_mandate_ids.get_connector_mandate_request_reference_id()
}
Some(payments::MandateReferenceId::NetworkMandateId(_))
| None
| Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
})
.ok_or_else(missing_field_err("connector_mandate_request_reference_id"))
}
fn is_cit_mandate_payment(&self) -> bool {
(self.customer_acceptance.is_some() || self.setup_mandate_details.is_some())
&& self.setup_future_usage == Some(FutureUsage::OffSession)
}
fn get_optional_network_transaction_id(&self) -> Option<String> {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
Some(payments::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
Some(network_transaction_id.clone())
}
Some(payments::MandateReferenceId::ConnectorMandateId(_))
| Some(payments::MandateReferenceId::NetworkTokenWithNTI(_))
fn is_cit_mandate_payment(&self) -> bool {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use api_models::payments;
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
/// Attempts to retrieve the connector mandate reference ID as a `Result<String, Error>`.
fn get_connector_mandate_request_reference_id(&self) -> Result<String, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use api_models::payments;
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use hyperswitch_interfaces::{api, consts, errors, types::Response};
use masking::{ExposeInterface, PeekInterface, Secret};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_card_holder_name_from_additional_payment_method_data(
&self,
) -> Result<Secret<String>, Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use masking::{ExposeInterface, PeekInterface, Secret};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_customer_name(&self) -> Result<Secret<String>, Error> {
self.customer_name
.clone()
.ok_or_else(missing_field_err("customer_name"))
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
type Error = error_stack::Report<errors::ConnectorError>;
fn get_authentication_data(&self) -> Result<AuthenticationData, Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
use serde_json::Value;
fn get_metadata_as_object(&self) -> Option<pii::SecretSerdeValue> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
fn get_tax_on_surcharge_amount(&self) -> Option<i64> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/utils.rs | crate: hyperswitch_connectors
use common_utils::{
consts::BASE64_ENGINE,
errors::{CustomResult, ParsingError, ReportSwitchExt},
ext_traits::{OptionExt, StringExt, ValueExt},
id_type,
pii::{self, Email, IpAddress},
types::{AmountConvertor, MinorUnit},
};
use hyperswitch_domain_models::{
address::{Address, AddressDetails, PhoneDetails},
mandates,
network_tokenization::NetworkTokenNumber,
payment_method_data::{self, Card, CardDetailsForNetworkTransactionId, PaymentMethodData},
router_data::{
ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData,
RouterData as ConnectorRouterData,
},
router_request_types::{
AuthenticationData, BrowserInformation, CompleteAuthorizeData, ConnectorCustomerData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData,
PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,
SetupMandateRequestData,
},
router_response_types::{CaptureSyncResponse, PaymentsResponseData},
types::{OrderDetailsWithAmount, SetupMandateRouterData},
};
fn get_surcharge_amount(&self) -> Option<i64> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_connectors/src/connectors/wellsfargo.rs | crate: hyperswitch_connectors | connector: wellsfargo
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
fn get_5xx_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: wellsfargo::WellsfargoServerErrorResponse = res
.response
.parse_struct("WellsfargoServerErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|event| event.set_response_body(&response));
router_env::logger::info!(error_response=?response);
fn get_5xx_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: wellsfargo::WellsfargoServerErrorResponse = res
.response
.parse_struct("WellsfargoServerErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|event| event.set_response_body(&response));
router_env::logger::info!(error_response=?response);
Ok(ErrorResponse {
status_code: res.status_code,
reason: response.status.clone(),
code: response
.status
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()),
message: response
.message
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
} | ast_fragments |
// file: hyperswitch/crates/hyperswitch_connectors/src/connectors/wellsfargo.rs | crate: hyperswitch_connectors | connector: wellsfargo
req: &MandateRevokeRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Delete)
.url(&MandateRevokeType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(MandateRevokeType::get_headers(self, req, connectors)?)
.build(),
))
}
fn handle_response(
&self,
data: &MandateRevokeRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<MandateRevokeRouterData, errors::ConnectorError> {
if matches!(res.status_code, 204) {
event_builder.map(|i| i.set_response_body(&serde_json::json!({"mandate_status": common_enums::MandateStatus::Revoked.to_string()})));
Ok(MandateRevokeRouterData {
response: Ok(MandateRevokeResponseData {
mandate_status: common_enums::MandateStatus::Revoked,
}),
..data.clone()
fn handle_response(
&self,
data: &MandateRevokeRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<MandateRevokeRouterData, errors::ConnectorError> {
if matches!(res.status_code, 204) {
event_builder.map(|i| i.set_response_body(&serde_json::json!({"mandate_status": common_enums::MandateStatus::Revoked.to_string()})));
Ok(MandateRevokeRouterData {
response: Ok(MandateRevokeResponseData {
mandate_status: common_enums::MandateStatus::Revoked,
}),
..data.clone()
})
} else {
// If http_code != 204 || http_code != 4xx, we dont know any other response scenario yet.
let response_value: serde_json::Value = serde_json::from_slice(&res.response)
.change_context(errors::ConnectorError::ResponseHandlingFailed)?;
let response_string = response_value.to_string();
event_builder.map(|i| {
i.set_response_body(
&serde_json::json!({"response_string": response_string.clone()}),
)
});
router_env::logger::info!(connector_response=?response_string);
Ok(MandateRevokeRouterData {
response: Err(ErrorResponse {
code: hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string(),
message: response_string.clone(),
reason: Some(response_string),
status_code: res.status_code,
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
}),
..data.clone()
})
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/connectors/wellsfargo.rs | crate: hyperswitch_connectors | connector: wellsfargo
use common_utils::{
consts,
errors::CustomResult,
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
types::{AmountConvertor, MinorUnit, StringMajorUnit, StringMajorUnitForConnector},
};
use hyperswitch_interfaces::{
api::{
self,
refunds::{Refund, RefundExecute, RefundSync},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications,
ConnectorValidation,
},
configs::Connectors,
errors,
events::connector_api_logs::ConnectorEvent,
types::{
IncrementalAuthorizationType, MandateRevokeType, PaymentsAuthorizeType,
PaymentsCaptureType, PaymentsSyncType, PaymentsVoidType, RefundExecuteType, RefundSyncType,
Response, SetupMandateType,
},
webhooks,
};
use ring::{digest, hmac};
use transformers as wellsfargo;
use crate::{
constants::{self, headers},
types::ResponseRouterData,
utils::{self, convert_amount, PaymentMethodDataType, RefundsRequestData},
};
pub fn generate_signature(
&self,
auth: wellsfargo::WellsfargoAuthType,
host: String,
resource: &str,
payload: &String,
date: OffsetDateTime,
http_method: Method,
) -> CustomResult<String, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/connectors/wellsfargo.rs | crate: hyperswitch_connectors | connector: wellsfargo
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
}
}
impl Refund for Wellsfargo {}
impl RefundExecute for Wellsfargo {}
impl RefundSync for Wellsfargo {}
impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Wellsfargo {
fn get_headers(
&self,
req: &RefundExecuteRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
fn get_headers(
&self,
req: &RefundExecuteRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_connectors/src/connectors/wellsfargo.rs | crate: hyperswitch_connectors | connector: wellsfargo
})
}
Err(error_msg) => {
event_builder.map(|event| event.set_error(serde_json::json!({"error": res.response.escape_ascii().to_string(), "status_code": res.status_code})));
router_env::logger::error!(deserialization_error =? error_msg);
utils::handle_json_response_deserialization_failure(res, "wellsfargo")
}
}
}
}
impl ConnectorValidation for Wellsfargo {
fn validate_connector_against_payment_request(
&self,
capture_method: Option<enums::CaptureMethod>,
_payment_method: enums::PaymentMethod,
_pmt: Option<enums::PaymentMethodType>,
) -> CustomResult<(), errors::ConnectorError> {
let capture_method = capture_method.unwrap_or_default();
match capture_method {
enums::CaptureMethod::Automatic
| enums::CaptureMethod::Manual
| enums::CaptureMethod::SequentialAutomatic => Ok(()),
enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err(
utils::construct_not_implemented_error_report(capture_method, self.id()),
fn validate_connector_against_payment_request(
&self,
capture_method: Option<enums::CaptureMethod>,
_payment_method: enums::PaymentMethod,
_pmt: Option<enums::PaymentMethodType>,
) -> CustomResult<(), errors::ConnectorError> {
{
enums::CaptureMethod::Automatic
| enums::CaptureMethod::Manual
| enums::CaptureMethod::SequentialAutomatic => Ok(()),<|fim_suffix|>
<|fim_middle|>
enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err(
utils::construct_not_implemented_error_report(capture_method, self.id()),
),
}
} | ast_fragments |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.