feat(payments_v2): payment intent diesel and domain models changes v2 (#5783)

Co-authored-by: hrithikesh026 <hrithikesh.vm@juspay.in>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Narayan Bhat
2024-09-13 13:11:38 +05:30
committed by GitHub
parent 71bf627fbc
commit 10ac089449
59 changed files with 2893 additions and 762 deletions

View File

@ -11,7 +11,7 @@ use crate::{
id_type::{AlphaNumericId, AlphaNumericIdError, LengthId, LengthIdError},
};
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize)]
/// A global id that can be used to identify any entity
/// This id will have information about the entity and cell in a distributed system architecture
pub(crate) struct GlobalId(LengthId<MAX_GLOBAL_ID_LENGTH, MIN_GLOBAL_ID_LENGTH>);

View File

@ -1,7 +1,7 @@
use crate::{
errors::{CustomResult, ValidationError},
generate_id_with_default_len,
id_type::{AlphaNumericId, LengthId},
id_type::{global_id, AlphaNumericId, LengthId},
};
crate::id_type!(
@ -18,6 +18,20 @@ crate::impl_try_from_cow_str_id_type!(PaymentId, "payment_id");
crate::impl_queryable_id_type!(PaymentId);
crate::impl_to_sql_from_sql_id_type!(PaymentId);
/// A global id that can be used to identify a payment
#[derive(
Debug,
Clone,
Hash,
PartialEq,
Eq,
serde::Serialize,
serde::Deserialize,
diesel::expression::AsExpression,
)]
#[diesel(sql_type = diesel::sql_types::Text)]
pub struct PaymentGlobalId(global_id::GlobalId);
impl PaymentId {
/// Get the hash key to be stored in redis
pub fn get_hash_key_for_kv_store(&self) -> String {
@ -75,12 +89,3 @@ impl From<PaymentId> for router_env::opentelemetry::Value {
Self::String(router_env::opentelemetry::StringValue::from(string_value))
}
}
// #[cfg(feature = "metrics")]
// /// This is implemented so that we can use payment id directly as attribute in metrics
// impl router_env::tracing::Value for PaymentId {
// fn record(&self, key: &router_env::types::Field, visitor: &mut dyn router_env::types::Visit) {
// let string_value = self.get_string_repr();
// visitor.record_str(key, &string_value);
// }
// }