feat(router): Add webhooks for network tokenization (#6695)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Prasunna Soppa
2025-06-26 14:43:04 +05:30
committed by GitHub
parent 9e435929f0
commit ec6d0e4d62
25 changed files with 903 additions and 26 deletions

View File

@ -1065,6 +1065,23 @@ pub struct Card {
pub nick_name: Option<String>,
}
#[cfg(feature = "v1")]
impl From<(Card, Option<common_enums::CardNetwork>)> for CardDetail {
fn from((card, card_network): (Card, Option<common_enums::CardNetwork>)) -> Self {
Self {
card_number: card.card_number.clone(),
card_exp_month: card.card_exp_month.clone(),
card_exp_year: card.card_exp_year.clone(),
card_holder_name: card.name_on_card.clone(),
nick_name: card.nick_name.map(masking::Secret::new),
card_issuing_country: None,
card_network,
card_issuer: None,
card_type: None,
}
}
}
#[cfg(feature = "v1")]
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
pub struct CardDetailFromLocker {

View File

@ -129,6 +129,11 @@ pub enum WebhookResponseTracker {
mandate_id: String,
status: common_enums::MandateStatus,
},
#[cfg(feature = "v1")]
PaymentMethod {
payment_method_id: String,
status: common_enums::PaymentMethodStatus,
},
NoEffect,
Relay {
relay_id: common_utils::id_type::RelayId,
@ -143,13 +148,30 @@ impl WebhookResponseTracker {
Self::Payment { payment_id, .. }
| Self::Refund { payment_id, .. }
| Self::Dispute { payment_id, .. } => Some(payment_id.to_owned()),
Self::NoEffect | Self::Mandate { .. } => None,
Self::NoEffect | Self::Mandate { .. } | Self::PaymentMethod { .. } => None,
#[cfg(feature = "payouts")]
Self::Payout { .. } => None,
Self::Relay { .. } => None,
}
}
#[cfg(feature = "v1")]
pub fn get_payment_method_id(&self) -> Option<String> {
match self {
Self::PaymentMethod {
payment_method_id, ..
} => Some(payment_method_id.to_owned()),
Self::Payment { .. }
| Self::Refund { .. }
| Self::Dispute { .. }
| Self::NoEffect
| Self::Mandate { .. }
| Self::Relay { .. } => None,
#[cfg(feature = "payouts")]
Self::Payout { .. } => None,
}
}
#[cfg(feature = "v2")]
pub fn get_payment_id(&self) -> Option<common_utils::id_type::GlobalPaymentId> {
match self {