text stringlengths 70 351k | source stringclasses 4
values |
|---|---|
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/lib.rs | crate: hyperswitch_domain_models
fn from(value: T) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/address.rs | crate: hyperswitch_domain_models
/// Unify the address details, giving priority to `self` when details are present in both
pub fn unify_address_details(&self, other: Option<&Self>) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/address.rs | crate: hyperswitch_domain_models
/// Unify the address, giving priority to `self` when details are present in both
pub fn unify_address(&self, other: Option<&Self>) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/address.rs | crate: hyperswitch_domain_models
fn from(address: api_models::payments::AddressDetails) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/address.rs | crate: hyperswitch_domain_models
fn from(phone: PhoneDetails) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/address.rs | crate: hyperswitch_domain_models
fn from(address: AddressDetails) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/address.rs | crate: hyperswitch_domain_models
fn from(address: Address) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/address.rs | crate: hyperswitch_domain_models
fn from(phone: api_models::payments::PhoneDetails) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_domain_models/src/address.rs | crate: hyperswitch_domain_models
fn from(address: api_models::payments::AddressDetails) -> Self {
Self {
city: address.city,
country: address.country,
line1: address.line1,
line2: address.line2,
line3: address.line3,
zip: address.zip,
state: address.state,
first_name: address.first_name,
last_name: address.last_name,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/address.rs | crate: hyperswitch_domain_models
fn from(address: api_models::payments::Address) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/address.rs | crate: hyperswitch_domain_models
use masking::{PeekInterface, Secret};
pub fn get_optional_full_name(&self) -> Option<Secret<String>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
pub async fn crypto_operation<T: Clone + Send, S: masking::Strategy<T>>(
state: &KeyManagerState,
table_name: &str,
operation: CryptoOperation<T, S>,
identifier: Identifier,
key: &[u8],
) -> CustomResult<CryptoOutput<T, S>, CryptoError>
where
Secret<T, S>: Send,
crypto::Encryptable<Secret<T, S>>: TypeEncryption<T, crypto::GcmAes256, S>,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
use rustc_hash::FxHashMap;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn batch_decrypt<E: Clone, S>(
state: &KeyManagerState,
inner: FxHashMap<String, Encryption>,
identifier: Identifier,
key: &[u8],
) -> CustomResult<FxHashMap<String, crypto::Encryptable<Secret<E, S>>>, CryptoError>
where
S: masking::Strategy<E>,
crypto::Encryptable<Secret<E, S>>: TypeEncryption<E, crypto::GcmAes256, S>,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
use rustc_hash::FxHashMap;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn batch_encrypt<E: Clone, S>(
state: &KeyManagerState,
inner: FxHashMap<String, Secret<E, S>>,
identifier: Identifier,
key: &[u8],
) -> CustomResult<FxHashMap<String, crypto::Encryptable<Secret<E, S>>>, CryptoError>
where
S: masking::Strategy<E>,
crypto::Encryptable<Secret<E, S>>: TypeEncryption<E, crypto::GcmAes256, S>,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use rustc_hash::FxHashMap;
use errors::CryptoError;
async fn batch_decrypt_via_api(
state: &KeyManagerState,
encrypted_data: FxHashMap<String, Encryption>,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<FxHashMap<String, Self>, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
use rustc_hash::FxHashMap;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn batch_encrypt_via_api(
state: &KeyManagerState,
masked_data: FxHashMap<String, Secret<Vec<u8>, S>>,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<FxHashMap<String, Self>, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn encrypt_via_api(
state: &KeyManagerState,
masked_data: Secret<Vec<u8>, S>,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<Self, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
use rustc_hash::FxHashMap;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn batch_encrypt(
masked_data: FxHashMap<String, Secret<EncryptedJsonType<T>, S>>,
key: &[u8],
crypt_algo: V,
) -> CustomResult<FxHashMap<String, Self>, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
use rustc_hash::FxHashMap;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn batch_encrypt_via_api(
state: &KeyManagerState,
masked_data: FxHashMap<String, Secret<EncryptedJsonType<T>, S>>,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<FxHashMap<String, Self>, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
use rustc_hash::FxHashMap;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn batch_encrypt_via_api(
state: &KeyManagerState,
masked_data: FxHashMap<String, Secret<serde_json::Value, S>>,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<FxHashMap<String, Self>, errors::CryptoError> {
// If encryption service is not enabled, fall back to application encryption or else call encryption service
if !is_encryption_service_enabled(state) {
Self::batch_encrypt(masked_data, key, crypt_algo).await
} else {
let result: Result<
BatchEncryptDataResponse,
error_stack::Report<errors::KeyManagerClientError>,
> = call_encryption_service(
state,
Method::POST,
"data/encrypt",
BatchEncryptDataRequest::from((masked_data.clone(), identifier)),
)
.await;
match result {
Ok(response) => Ok(ForeignFrom::foreign_from((masked_data, response))),
Err(err) => {
metrics::ENCRYPTION_API_FAILURES.add(1, &[]);
logger::error!("Encryption error {:?}", err);
logger::info!("Fall back to Application Encryption");
Self::batch_encrypt(masked_data, key, crypt_algo).await
}
}
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use errors::CryptoError;
async fn decrypt_via_api(
state: &KeyManagerState,
encrypted_data: Encryption,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<Self, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn encrypt_via_api(
state: &KeyManagerState,
masked_data: Secret<serde_json::Value, S>,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<Self, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
use rustc_hash::FxHashMap;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn batch_encrypt_via_api(
state: &KeyManagerState,
masked_data: FxHashMap<String, Secret<String, S>>,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<FxHashMap<String, Self>, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn encrypt_via_api(
state: &KeyManagerState,
masked_data: Secret<String, S>,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<Self, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
pub async fn crypto_operation<T: Clone + Send, S: masking::Strategy<T>>(
state: &KeyManagerState,
table_name: &str,
operation: CryptoOperation<T, S>,
identifier: Identifier,
key: &[u8],
) -> CustomResult<CryptoOutput<T, S>, CryptoError>
where
Secret<T, S>: Send,
crypto::Encryptable<Secret<T, S>>: TypeEncryption<T, crypto::GcmAes256, S>,
{
{
CryptoOperation::Encrypt(data) => {
let data = encrypt(state, data, identifier, key).await?;
Ok(CryptoOutput::Operation(data))
}<|fim_suffix|>
<|fim_middle|>
CryptoOperation::BatchDecrypt(data) => {
let data = batch_decrypt(state, data, identifier, key).await?;
Ok(CryptoOutput::BatchOperation(data))
}
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use errors::CryptoError;
async fn decrypt_via_api(
state: &KeyManagerState,
encrypted_data: Encryption,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<Self, errors::CryptoError> {
{
Ok(decrypted_data) => {
ForeignTryFrom::foreign_try_from((encrypted_data.clone(), decrypted_data))
}<|fim_suffix|>
<|fim_middle|>
Err(err) => {
logger::error!("Decryption error {:?}", err);
Err(err.change_context(errors::CryptoError::DecodingFailed))
}
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn decrypt<T: Clone, S: masking::Strategy<T>>(
state: &KeyManagerState,
inner: Encryption,
identifier: Identifier,
key: &[u8],
) -> CustomResult<crypto::Encryptable<Secret<T, S>>, CryptoError>
where
crypto::Encryptable<Secret<T, S>>: TypeEncryption<T, crypto::GcmAes256, S>,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn decrypt_optional<T: Clone, S: masking::Strategy<T>>(
state: &KeyManagerState,
inner: Option<Encryption>,
identifier: Identifier,
key: &[u8],
) -> CustomResult<Option<crypto::Encryptable<Secret<T, S>>>, CryptoError>
where
crypto::Encryptable<Secret<T, S>>: TypeEncryption<T, crypto::GcmAes256, S>,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn encrypt_optional<E: Clone, S>(
state: &KeyManagerState,
inner: Option<Secret<E, S>>,
identifier: Identifier,
key: &[u8],
) -> CustomResult<Option<crypto::Encryptable<Secret<E, S>>>, CryptoError>
where
Secret<E, S>: Send,
S: masking::Strategy<E>,
crypto::Encryptable<Secret<E, S>>: TypeEncryption<E, crypto::GcmAes256, S>,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn encrypt<E: Clone, S>(
state: &KeyManagerState,
inner: Secret<E, S>,
identifier: Identifier,
key: &[u8],
) -> CustomResult<crypto::Encryptable<Secret<E, S>>, CryptoError>
where
S: masking::Strategy<E>,
crypto::Encryptable<Secret<E, S>>: TypeEncryption<E, crypto::GcmAes256, S>,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
async fn async_lift<Func, F, E, W>(self, func: Func) -> Self::OtherWrapper<W, E>
where
Func: Fn(Self::SelfWrapper<U>) -> F + Send + Sync,
F: futures::Future<Output = Self::OtherWrapper<W, E>> + Send,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
fn lift<Func, E, V>(self, func: Func) -> Self::OtherWrapper<V, E>
where
Func: Fn(Self::SelfWrapper<U>) -> Self::OtherWrapper<V, E>,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
pub fn into_inner(self) -> T {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
pub fn inner(&self) -> &T {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use rustc_hash::FxHashMap;
use errors::CryptoError;
async fn batch_decrypt(
encrypted_data: FxHashMap<String, Encryption>,
key: &[u8],
crypt_algo: V,
) -> CustomResult<FxHashMap<String, Self>, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use masking::Secret;
use rustc_hash::FxHashMap;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn batch_encrypt(
masked_data: FxHashMap<String, Secret<Vec<u8>, S>>,
key: &[u8],
crypt_algo: V,
) -> CustomResult<FxHashMap<String, Self>, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use errors::CryptoError;
async fn decrypt(
encrypted_data: Encryption,
key: &[u8],
crypt_algo: V,
) -> CustomResult<Self, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn encrypt(
masked_data: Secret<Vec<u8>, S>,
key: &[u8],
crypt_algo: V,
) -> CustomResult<Self, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn encrypt(
masked_data: Secret<EncryptedJsonType<T>, S>,
key: &[u8],
crypt_algo: V,
) -> CustomResult<Self, errors::CryptoError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn encrypt_via_api(
state: &KeyManagerState,
masked_data: Secret<EncryptedJsonType<T>, S>,
identifier: Identifier,
key: &[u8],
crypt_algo: V,
) -> CustomResult<Self, errors::CryptoError> {
let data_bytes = EncryptedJsonType::serialize_json_bytes(masked_data.peek())?;
let result: crypto::Encryptable<Secret<Vec<u8>>> =
TypeEncryption::encrypt_via_api(state, data_bytes, identifier, key, crypt_algo)
.await?;
Ok(Self::new(masked_data, result.into_encrypted()))
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
fn deserialize_json_bytes<S>(
bytes: Secret<Vec<u8>>,
) -> CustomResult<Secret<Self, S>, errors::ParsingError>
where
S: masking::Strategy<Self>,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
fn serialize_json_bytes(&self) -> CustomResult<Secret<Vec<u8>>, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use masking::Secret;
use rustc_hash::FxHashMap;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn batch_encrypt(
masked_data: FxHashMap<String, Secret<serde_json::Value, S>>,
key: &[u8],
crypt_algo: V,
) -> CustomResult<FxHashMap<String, Self>, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn encrypt(
masked_data: Secret<serde_json::Value, S>,
key: &[u8],
crypt_algo: V,
) -> CustomResult<Self, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use masking::Secret;
use rustc_hash::FxHashMap;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn batch_encrypt(
masked_data: FxHashMap<String, Secret<String, S>>,
key: &[u8],
crypt_algo: V,
) -> CustomResult<FxHashMap<String, Self>, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
use encrypt::TypeEncryption;
use masking::Secret;
pub type OptionalEncryptableJsonType<T> = Option<crypto::Encryptable<Secret<EncryptedJsonType<T>>>>;
use errors::CryptoError;
async fn encrypt(
masked_data: Secret<String, S>,
key: &[u8],
crypt_algo: V,
) -> CustomResult<Self, errors::CryptoError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/type_encryption.rs | crate: hyperswitch_domain_models
use common_utils::{
crypto,
encryption::Encryption,
errors::{self, CustomResult},
ext_traits::AsyncExt,
metrics::utils::record_operation_time,
types::keymanager::{Identifier, KeyManagerState},
};
fn is_encryption_service_enabled(_state: &KeyManagerState) -> bool {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_captured_amount(
&self,
payment_data: &payments::PaymentConfirmData<router_flow_types::SetupMandate>,
) -> Option<MinorUnit> {
{
common_enums::IntentStatus::Succeeded => {
let total_amount = payment_data.payment_attempt.amount_details.get_net_amount();
Some(total_amount)
}<|fim_suffix|>
<|fim_middle|>
common_enums::IntentStatus::PartiallyCaptured
| common_enums::IntentStatus::PartiallyCapturedAndCapturable => None,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_amount_capturable(
&self,
payment_data: &payments::PaymentConfirmData<router_flow_types::SetupMandate>,
) -> Option<MinorUnit> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_payment_intent_update(
&self,
payment_data: &payments::PaymentConfirmData<router_flow_types::SetupMandate>,
storage_scheme: common_enums::MerchantStorageScheme,
) -> PaymentIntentUpdate {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_captured_amount(
&self,
payment_data: &payments::PaymentStatusData<router_flow_types::PSync>,
) -> Option<MinorUnit> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_amount_capturable(
&self,
payment_data: &payments::PaymentStatusData<router_flow_types::PSync>,
) -> Option<MinorUnit> {
let payment_attempt = payment_data.payment_attempt.as_ref()?;
// Based on the status of the response, we can determine the amount capturable
let intent_status = common_enums::IntentStatus::from(self.status);
match intent_status {
// If the status is already succeeded / failed we cannot capture any more amount
common_enums::IntentStatus::Succeeded
| common_enums::IntentStatus::Failed
| common_enums::IntentStatus::Cancelled => Some(MinorUnit::zero()),
// For these statuses, update the capturable amount when it reaches terminal / capturable state
common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
| common_enums::IntentStatus::Processing => None,
// Invalid states for this flow
common_enums::IntentStatus::RequiresPaymentMethod
| common_enums::IntentStatus::RequiresConfirmation => None,
common_enums::IntentStatus::RequiresCapture => {
let total_amount = payment_attempt.amount_details.get_net_amount();
Some(total_amount)
}
// Invalid statues for this flow
common_enums::IntentStatus::PartiallyCaptured
| common_enums::IntentStatus::PartiallyCapturedAndCapturable => None,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_captured_amount(
&self,
payment_data: &payments::PaymentCaptureData<router_flow_types::Capture>,
) -> Option<MinorUnit> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_amount_capturable(
&self,
payment_data: &payments::PaymentCaptureData<router_flow_types::Capture>,
) -> Option<MinorUnit> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_captured_amount(
&self,
payment_data: &payments::PaymentConfirmData<router_flow_types::Authorize>,
) -> Option<MinorUnit> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_amount_capturable(
&self,
payment_data: &payments::PaymentConfirmData<router_flow_types::Authorize>,
) -> Option<MinorUnit> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_payment_intent_update(
&self,
payment_data: &payments::PaymentConfirmData<router_flow_types::Authorize>,
storage_scheme: common_enums::MerchantStorageScheme,
) -> PaymentIntentUpdate {
let amount_captured = self.get_captured_amount(payment_data);
let status = payment_data.payment_attempt.status.is_terminal_status();
let updated_feature_metadata =
payment_data
.payment_intent
.feature_metadata
.clone()
.map(|mut feature_metadata| {
if let Some(ref mut payment_revenue_recovery_metadata) =
feature_metadata.payment_revenue_recovery_metadata
{
payment_revenue_recovery_metadata.payment_connector_transmission = if self
.response
.is_ok()
{
common_enums::PaymentConnectorTransmission::ConnectorCallSucceeded
} else {
common_enums::PaymentConnectorTransmission::ConnectorCallUnsuccessful
};
}
Box::new(feature_metadata)
});
match self.response {
Ok(ref _response) => PaymentIntentUpdate::ConfirmIntentPostUpdate {
status: common_enums::IntentStatus::from(
self.get_attempt_status_for_db_update(payment_data),
),
amount_captured,
updated_by: storage_scheme.to_string(),
feature_metadata: updated_feature_metadata,
},
Err(ref error) => PaymentIntentUpdate::ConfirmIntentPostUpdate {
status: error
.attempt_status
.map(common_enums::IntentStatus::from)
.unwrap_or(common_enums::IntentStatus::Failed),
amount_captured,
updated_by: storage_scheme.to_string(),
feature_metadata: updated_feature_metadata,
},
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
pub fn get_masked_keys(&self) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_captured_amount(
&self,
payment_data: &payments::PaymentConfirmData<router_flow_types::SetupMandate>,
) -> Option<MinorUnit> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_amount_capturable(
&self,
payment_data: &payments::PaymentConfirmData<router_flow_types::SetupMandate>,
) -> Option<MinorUnit> {
{
common_enums::IntentStatus::Succeeded
| common_enums::IntentStatus::Failed
| common_enums::IntentStatus::Cancelled => Some(MinorUnit::zero()),<|fim_suffix|>
<|fim_middle|>
common_enums::IntentStatus::PartiallyCaptured
| common_enums::IntentStatus::PartiallyCapturedAndCapturable => None,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_attempt_status_for_db_update(
&self,
_payment_data: &payments::PaymentConfirmData<router_flow_types::SetupMandate>,
) -> common_enums::AttemptStatus {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_attempt_status_for_db_update(
&self,
payment_data: &payments::PaymentStatusData<router_flow_types::PSync>,
) -> common_enums::AttemptStatus {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_payment_intent_update(
&self,
payment_data: &payments::PaymentStatusData<router_flow_types::PSync>,
storage_scheme: common_enums::MerchantStorageScheme,
) -> PaymentIntentUpdate {
let amount_captured = self.get_captured_amount(payment_data);
match self.response {
Ok(ref _response) => PaymentIntentUpdate::SyncUpdate {
status: common_enums::IntentStatus::from(
self.get_attempt_status_for_db_update(payment_data),
),
amount_captured,
updated_by: storage_scheme.to_string(),
},
Err(ref error) => PaymentIntentUpdate::SyncUpdate {
status: error
.attempt_status
.map(common_enums::IntentStatus::from)
.unwrap_or(common_enums::IntentStatus::Failed),
amount_captured,
updated_by: storage_scheme.to_string(),
},
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_attempt_status_for_db_update(
&self,
payment_data: &payments::PaymentCaptureData<router_flow_types::Capture>,
) -> common_enums::AttemptStatus {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_payment_intent_update(
&self,
payment_data: &payments::PaymentCaptureData<router_flow_types::Capture>,
storage_scheme: common_enums::MerchantStorageScheme,
) -> PaymentIntentUpdate {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_attempt_status_for_db_update(
&self,
_payment_data: &payments::PaymentConfirmData<router_flow_types::Authorize>,
) -> common_enums::AttemptStatus {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
pub fn get_not_implemented() -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
pub fn get_extended_authorization_response_data(
&self,
) -> Option<&ExtendedAuthorizationResponseData> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
pub fn with_additional_payment_method_data(
additional_payment_method_data: AdditionalPaymentMethodConnectorResponse,
) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use masking::{ExposeInterface, Secret};
fn mask_key(&self, key: String) -> Secret<String> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
pub fn from_secret_value(
value: common_utils::pii::SecretSerdeValue,
) -> common_utils::errors::CustomResult<Self, common_utils::errors::ParsingError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use common_utils::{
errors::IntegrityCheckError,
ext_traits::{OptionExt, ValueExt},
id_type,
types::MinorUnit,
};
pub fn from_option_secret_value(
value: Option<common_utils::pii::SecretSerdeValue>,
) -> common_utils::errors::CustomResult<Self, common_utils::errors::ParsingError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use masking::{ExposeInterface, Secret};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_payment_attempt_update(
&self,
payment_data: &payments::PaymentConfirmData<router_flow_types::SetupMandate>,
storage_scheme: common_enums::MerchantStorageScheme,
) -> PaymentAttemptUpdate {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_payment_attempt_update(
&self,
payment_data: &payments::PaymentStatusData<router_flow_types::PSync>,
storage_scheme: common_enums::MerchantStorageScheme,
) -> PaymentAttemptUpdate {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_payment_attempt_update(
&self,
payment_data: &payments::PaymentCaptureData<router_flow_types::Capture>,
storage_scheme: common_enums::MerchantStorageScheme,
) -> PaymentAttemptUpdate {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_data.rs | crate: hyperswitch_domain_models
use masking::{ExposeInterface, Secret};
use crate::{
network_tokenization::NetworkTokenNumber, payment_address::PaymentAddress, payment_method_data,
payments,
};
use crate::{
payments::{
payment_attempt::{ErrorDetails, PaymentAttemptUpdate},
payment_intent::PaymentIntentUpdate,
},
router_flow_types, router_request_types, router_response_types,
};
fn get_payment_attempt_update(
&self,
payment_data: &payments::PaymentConfirmData<router_flow_types::Authorize>,
storage_scheme: common_enums::MerchantStorageScheme,
) -> PaymentAttemptUpdate {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_response_types.rs | crate: hyperswitch_domain_models
use common_utils::{request::Method, types::MinorUnit};
fn from(redirect_form: RedirectForm) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_response_types.rs | crate: hyperswitch_domain_models
pub use disputes::{AcceptDisputeResponse, DefendDisputeResponse, SubmitEvidenceResponse};
use crate::{
errors::api_error_response::ApiErrorResponse,
router_request_types::{authentication::AuthNFlowType, ResponseId},
};
pub type PaymentMethodTypeMetadata = HashMap<common_enums::PaymentMethodType, PaymentMethodDetails>;
pub type SupportedPaymentMethods = HashMap<common_enums::PaymentMethod, PaymentMethodTypeMetadata>;
pub fn merge_transaction_responses(
auth_response: &Self,
capture_response: &Self,
) -> Result<Self, error_stack::Report<ApiErrorResponse>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_response_types.rs | crate: hyperswitch_domain_models
use std::collections::HashMap;
use common_utils::{request::Method, types::MinorUnit};
pub type PaymentMethodTypeMetadata = HashMap<common_enums::PaymentMethodType, PaymentMethodDetails>;
pub type SupportedPaymentMethods = HashMap<common_enums::PaymentMethod, PaymentMethodTypeMetadata>;
fn from((mut redirect_url, method): (url::Url, Method)) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_response_types.rs | crate: hyperswitch_domain_models
pub use disputes::{AcceptDisputeResponse, DefendDisputeResponse, SubmitEvidenceResponse};
use crate::{
errors::api_error_response::ApiErrorResponse,
router_request_types::{authentication::AuthNFlowType, ResponseId},
};
pub type PaymentMethodTypeMetadata = HashMap<common_enums::PaymentMethodType, PaymentMethodDetails>;
pub type SupportedPaymentMethods = HashMap<common_enums::PaymentMethod, PaymentMethodTypeMetadata>;
pub fn get_connector_transaction_id(
&self,
) -> Result<String, error_stack::Report<ApiErrorResponse>> {
{
Self::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(txn_id),
..
} => Ok(txn_id.to_string()),<|fim_suffix|>
<|fim_middle|>
_ => Err(ApiErrorResponse::MissingRequiredField {
field_name: "ConnectorTransactionId",
}
.into()),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_response_types.rs | crate: hyperswitch_domain_models
pub type PaymentMethodTypeMetadata = HashMap<common_enums::PaymentMethodType, PaymentMethodDetails>;
pub type SupportedPaymentMethods = HashMap<common_enums::PaymentMethod, PaymentMethodTypeMetadata>;
fn add(
&mut self,
payment_method: common_enums::PaymentMethod,
payment_method_type: common_enums::PaymentMethodType,
payment_method_details: PaymentMethodDetails,
) {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_response_types.rs | crate: hyperswitch_domain_models
use std::collections::HashMap;
use common_utils::{request::Method, types::MinorUnit};
pub type PaymentMethodTypeMetadata = HashMap<common_enums::PaymentMethodType, PaymentMethodDetails>;
pub type SupportedPaymentMethods = HashMap<common_enums::PaymentMethod, PaymentMethodTypeMetadata>;
fn from((mut redirect_url, method): (url::Url, Method)) -> Self {
let form_fields = HashMap::from_iter(
redirect_url
.query_pairs()
.map(|(key, value)| (key.to_string(), value.to_string())),
);
// Do not include query params in the endpoint
redirect_url.set_query(None);
Self::Form {
endpoint: redirect_url.to_string(),
method,
form_fields,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_response_types.rs | crate: hyperswitch_domain_models
pub use disputes::{AcceptDisputeResponse, DefendDisputeResponse, SubmitEvidenceResponse};
pub type PaymentMethodTypeMetadata = HashMap<common_enums::PaymentMethodType, PaymentMethodDetails>;
pub type SupportedPaymentMethods = HashMap<common_enums::PaymentMethod, PaymentMethodTypeMetadata>;
pub fn get_updated_connector_token_details(
&self,
original_connector_mandate_request_reference_id: Option<String>,
) -> Option<diesel_models::ConnectorTokenDetails> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_response_types.rs | crate: hyperswitch_domain_models
pub use disputes::{AcceptDisputeResponse, DefendDisputeResponse, SubmitEvidenceResponse};
use crate::{
errors::api_error_response::ApiErrorResponse,
router_request_types::{authentication::AuthNFlowType, ResponseId},
};
pub type PaymentMethodTypeMetadata = HashMap<common_enums::PaymentMethodType, PaymentMethodDetails>;
pub type SupportedPaymentMethods = HashMap<common_enums::PaymentMethod, PaymentMethodTypeMetadata>;
pub fn get_connector_transaction_id(
&self,
) -> Result<String, error_stack::Report<ApiErrorResponse>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_response_types.rs | crate: hyperswitch_domain_models
pub use disputes::{AcceptDisputeResponse, DefendDisputeResponse, SubmitEvidenceResponse};
pub type PaymentMethodTypeMetadata = HashMap<common_enums::PaymentMethodType, PaymentMethodDetails>;
pub type SupportedPaymentMethods = HashMap<common_enums::PaymentMethod, PaymentMethodTypeMetadata>;
pub fn get_connector_metadata(&self) -> Option<masking::Secret<serde_json::Value>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_response_types.rs | crate: hyperswitch_domain_models
pub use disputes::{AcceptDisputeResponse, DefendDisputeResponse, SubmitEvidenceResponse};
pub type PaymentMethodTypeMetadata = HashMap<common_enums::PaymentMethodType, PaymentMethodDetails>;
pub type SupportedPaymentMethods = HashMap<common_enums::PaymentMethod, PaymentMethodTypeMetadata>;
pub fn get_connector_response_reference_id(&self) -> Option<String> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_response_types.rs | crate: hyperswitch_domain_models
use common_utils::{request::Method, types::MinorUnit};
pub use disputes::{AcceptDisputeResponse, DefendDisputeResponse, SubmitEvidenceResponse};
pub type PaymentMethodTypeMetadata = HashMap<common_enums::PaymentMethodType, PaymentMethodDetails>;
pub type SupportedPaymentMethods = HashMap<common_enums::PaymentMethod, PaymentMethodTypeMetadata>;
pub fn get_amount_captured(&self) -> Option<MinorUnit> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/router_response_types.rs | crate: hyperswitch_domain_models
fn from(redirect_form: diesel_models::payment_attempt::RedirectForm) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/revenue_recovery.rs | crate: hyperswitch_domain_models
use api_models::{payments as api_payments, webhooks};
use common_enums::enums as common_enums;
fn from(data: &RevenueRecoveryInvoiceData) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/revenue_recovery.rs | crate: hyperswitch_domain_models
use api_models::{payments as api_payments, webhooks};
use common_enums::enums as common_enums;
pub fn get_action(
event_type: webhooks::IncomingWebhookEvent,
attempt_triggered_by: Option<common_enums::TriggeredBy>,
) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/revenue_recovery.rs | crate: hyperswitch_domain_models
use api_models::{payments as api_payments, webhooks};
use common_enums::enums as common_enums;
pub fn get_action(
event_type: webhooks::IncomingWebhookEvent,
attempt_triggered_by: Option<common_enums::TriggeredBy>,
) -> Self {
{
Some(common_enums::TriggeredBy::Internal) => Self::NoAction,<|fim_suffix|>
<|fim_middle|>
Some(common_enums::TriggeredBy::External) | None => Self::SuccessPaymentExternal,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/revenue_recovery.rs | crate: hyperswitch_domain_models
use api_models::{payments as api_payments, webhooks};
fn from(data: &RevenueRecoveryAttemptData) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/revenue_recovery.rs | crate: hyperswitch_domain_models
use crate::router_response_types::revenue_recovery::BillingConnectorPaymentsSyncResponse;
fn from(data: &BillingConnectorPaymentsSyncResponse) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/revenue_recovery.rs | crate: hyperswitch_domain_models
use common_enums::enums as common_enums;
use crate::router_response_types::revenue_recovery::BillingConnectorPaymentsSyncResponse;
pub fn get_attempt_triggered_by(&self) -> Option<common_enums::TriggeredBy> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/hyperswitch_domain_models/src/payment_method_data.rs | crate: hyperswitch_domain_models
use api_models::{
mandates,
payment_methods::{self},
payments::{
additional_info as payment_additional_types, AmazonPayRedirectData, ExtendedCardInfo,
},
};
use common_enums::enums as api_enums;
use common_utils::{
id_type,
new_type::{
MaskedBankAccount, MaskedIban, MaskedRoutingNumber, MaskedSortCode, MaskedUpiVpaId,
},
pii::{self, Email},
};
fn get_payment_method_type(&self) -> api_enums::PaymentMethodType {
match self {
Self::AliPayQr(_) | Self::AliPayRedirect(_) => api_enums::PaymentMethodType::AliPay,
Self::AliPayHkRedirect(_) => api_enums::PaymentMethodType::AliPayHk,
Self::AmazonPayRedirect(_) => api_enums::PaymentMethodType::AmazonPay,
Self::MomoRedirect(_) => api_enums::PaymentMethodType::Momo,
Self::KakaoPayRedirect(_) => api_enums::PaymentMethodType::KakaoPay,
Self::GoPayRedirect(_) => api_enums::PaymentMethodType::GoPay,
Self::GcashRedirect(_) => api_enums::PaymentMethodType::Gcash,
Self::ApplePay(_) | Self::ApplePayRedirect(_) | Self::ApplePayThirdPartySdk(_) => {
api_enums::PaymentMethodType::ApplePay
}
Self::DanaRedirect {} => api_enums::PaymentMethodType::Dana,
Self::GooglePay(_) | Self::GooglePayRedirect(_) | Self::GooglePayThirdPartySdk(_) => {
api_enums::PaymentMethodType::GooglePay
}
Self::MbWayRedirect(_) => api_enums::PaymentMethodType::MbWay,
Self::MobilePayRedirect(_) => api_enums::PaymentMethodType::MobilePay,
Self::PaypalRedirect(_) | Self::PaypalSdk(_) => api_enums::PaymentMethodType::Paypal,
Self::Paze(_) => api_enums::PaymentMethodType::Paze,
Self::SamsungPay(_) => api_enums::PaymentMethodType::SamsungPay,
Self::TwintRedirect {} => api_enums::PaymentMethodType::Twint,
Self::VippsRedirect {} => api_enums::PaymentMethodType::Vipps,
Self::TouchNGoRedirect(_) => api_enums::PaymentMethodType::TouchNGo,
Self::WeChatPayRedirect(_) | Self::WeChatPayQr(_) => {
api_enums::PaymentMethodType::WeChatPay
}
Self::CashappQr(_) => api_enums::PaymentMethodType::Cashapp,
Self::SwishQr(_) => api_enums::PaymentMethodType::Swish,
Self::Mifinity(_) => api_enums::PaymentMethodType::Mifinity,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/payment_method_data.rs | crate: hyperswitch_domain_models
use api_models::{
mandates,
payment_methods::{self},
payments::{
additional_info as payment_additional_types, AmazonPayRedirectData, ExtendedCardInfo,
},
};
use common_utils::{
id_type,
new_type::{
MaskedBankAccount, MaskedIban, MaskedRoutingNumber, MaskedSortCode, MaskedUpiVpaId,
},
pii::{self, Email},
};
fn from(value: BankTransferData) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/payment_method_data.rs | crate: hyperswitch_domain_models
use api_models::{
mandates,
payment_methods::{self},
payments::{
additional_info as payment_additional_types, AmazonPayRedirectData, ExtendedCardInfo,
},
};
fn from(value: api_models::payments::BankTransferData) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/payment_method_data.rs | crate: hyperswitch_domain_models
use api_models::{
mandates,
payment_methods::{self},
payments::{
additional_info as payment_additional_types, AmazonPayRedirectData, ExtendedCardInfo,
},
};
use common_utils::{
id_type,
new_type::{
MaskedBankAccount, MaskedIban, MaskedRoutingNumber, MaskedSortCode, MaskedUpiVpaId,
},
pii::{self, Email},
};
fn from(value: BankDebitData) -> Self {
{
BankDebitData::AchBankDebit {
account_number,
routing_number,
bank_name,
bank_type,
bank_holder_type,
card_holder_name,
bank_account_holder_name,
} => Self::Ach(Box::new(
payment_additional_types::AchBankDebitAdditionalData {
account_number: MaskedBankAccount::from(account_number),
routing_number: MaskedRoutingNumber::from(routing_number),
bank_name,
bank_type,
bank_holder_type,
card_holder_name,
bank_account_holder_name,
},
)),<|fim_suffix|>
<|fim_middle|>
BankDebitData::BacsBankDebit {
account_number,
sort_code,
bank_account_holder_name,
} => Self::Bacs(Box::new(
payment_additional_types::BacsBankDebitAdditionalData {
account_number: MaskedBankAccount::from(account_number),
sort_code: MaskedSortCode::from(sort_code),
bank_account_holder_name,
},
)),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/payment_method_data.rs | crate: hyperswitch_domain_models
use api_models::{
mandates,
payment_methods::{self},
payments::{
additional_info as payment_additional_types, AmazonPayRedirectData, ExtendedCardInfo,
},
};
fn from(value: api_models::payments::BankDebitData) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hyperswitch_domain_models/src/payment_method_data.rs | crate: hyperswitch_domain_models
use api_models::{
mandates,
payment_methods::{self},
payments::{
additional_info as payment_additional_types, AmazonPayRedirectData, ExtendedCardInfo,
},
};
fn from(value: api_models::payments::VoucherData) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.