feat(payment_methods_v2): Added Ephemeral auth for v2 (#6813)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sarthak Soni
2024-12-22 23:04:45 +05:30
committed by GitHub
parent 7540b74347
commit 24401bc16f
23 changed files with 688 additions and 126 deletions

View File

@ -102,6 +102,9 @@ pub enum ApiEventsType {
poll_id: String,
},
Analytics,
EphemeralKey {
key_id: id_type::EphemeralKeyId,
},
}
impl ApiEventMetric for serde_json::Value {}

View File

@ -3,6 +3,7 @@
mod api_key;
mod customer;
mod ephemeral_key;
#[cfg(feature = "v2")]
mod global_id;
mod merchant;
@ -38,6 +39,7 @@ pub use self::global_id::{
pub use self::{
api_key::ApiKeyId,
customer::CustomerId,
ephemeral_key::EphemeralKeyId,
merchant::MerchantId,
merchant_connector_account::MerchantConnectorAccountId,
organization::OrganizationId,

View File

@ -0,0 +1,31 @@
crate::id_type!(
EphemeralKeyId,
"A type for key_id that can be used for Ephemeral key IDs"
);
crate::impl_id_type_methods!(EphemeralKeyId, "key_id");
// This is to display the `EphemeralKeyId` as EphemeralKeyId(abcd)
crate::impl_debug_id_type!(EphemeralKeyId);
crate::impl_try_from_cow_str_id_type!(EphemeralKeyId, "key_id");
crate::impl_generate_id_id_type!(EphemeralKeyId, "eki");
crate::impl_serializable_secret_id_type!(EphemeralKeyId);
crate::impl_queryable_id_type!(EphemeralKeyId);
crate::impl_to_sql_from_sql_id_type!(EphemeralKeyId);
impl crate::events::ApiEventMetric for EphemeralKeyId {
fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> {
Some(crate::events::ApiEventsType::EphemeralKey {
key_id: self.clone(),
})
}
}
crate::impl_default_id_type!(EphemeralKeyId, "key");
impl EphemeralKeyId {
/// Generate a key for redis
pub fn generate_redis_key(&self) -> String {
format!("epkey_{}", self.get_string_repr())
}
}