mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
feat(router): add payment incoming webhooks support for v2 (#6551)
Co-authored-by: Narayan Bhat <narayan.bhat@juspay.in> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: hrithikesh026 <hrithikesh.vm@juspay.in>
This commit is contained in:
committed by
GitHub
parent
65bf75a75e
commit
8e9c3ec893
@ -76,25 +76,45 @@ pub enum WebhookFlow {
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
/// This enum tells about the affect a webhook had on an object
|
||||
pub enum WebhookResponseTracker {
|
||||
#[cfg(feature = "v1")]
|
||||
Payment {
|
||||
payment_id: common_utils::id_type::PaymentId,
|
||||
status: common_enums::IntentStatus,
|
||||
},
|
||||
#[cfg(feature = "v2")]
|
||||
Payment {
|
||||
payment_id: common_utils::id_type::GlobalPaymentId,
|
||||
status: common_enums::IntentStatus,
|
||||
},
|
||||
#[cfg(feature = "payouts")]
|
||||
Payout {
|
||||
payout_id: String,
|
||||
status: common_enums::PayoutStatus,
|
||||
},
|
||||
#[cfg(feature = "v1")]
|
||||
Refund {
|
||||
payment_id: common_utils::id_type::PaymentId,
|
||||
refund_id: String,
|
||||
status: common_enums::RefundStatus,
|
||||
},
|
||||
#[cfg(feature = "v2")]
|
||||
Refund {
|
||||
payment_id: common_utils::id_type::GlobalPaymentId,
|
||||
refund_id: String,
|
||||
status: common_enums::RefundStatus,
|
||||
},
|
||||
#[cfg(feature = "v1")]
|
||||
Dispute {
|
||||
dispute_id: String,
|
||||
payment_id: common_utils::id_type::PaymentId,
|
||||
status: common_enums::DisputeStatus,
|
||||
},
|
||||
#[cfg(feature = "v2")]
|
||||
Dispute {
|
||||
dispute_id: String,
|
||||
payment_id: common_utils::id_type::GlobalPaymentId,
|
||||
status: common_enums::DisputeStatus,
|
||||
},
|
||||
Mandate {
|
||||
mandate_id: String,
|
||||
status: common_enums::MandateStatus,
|
||||
@ -103,6 +123,7 @@ pub enum WebhookResponseTracker {
|
||||
}
|
||||
|
||||
impl WebhookResponseTracker {
|
||||
#[cfg(feature = "v1")]
|
||||
pub fn get_payment_id(&self) -> Option<common_utils::id_type::PaymentId> {
|
||||
match self {
|
||||
Self::Payment { payment_id, .. }
|
||||
@ -113,6 +134,18 @@ impl WebhookResponseTracker {
|
||||
Self::Payout { .. } => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
pub fn get_payment_id(&self) -> Option<common_utils::id_type::GlobalPaymentId> {
|
||||
match self {
|
||||
Self::Payment { payment_id, .. }
|
||||
| Self::Refund { payment_id, .. }
|
||||
| Self::Dispute { payment_id, .. } => Some(payment_id.to_owned()),
|
||||
Self::NoEffect | Self::Mandate { .. } => None,
|
||||
#[cfg(feature = "payouts")]
|
||||
Self::Payout { .. } => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IncomingWebhookEvent> for WebhookFlow {
|
||||
@ -227,6 +260,7 @@ pub struct OutgoingWebhook {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, ToSchema)]
|
||||
#[serde(tag = "type", content = "object", rename_all = "snake_case")]
|
||||
#[cfg(feature = "v1")]
|
||||
pub enum OutgoingWebhookContent {
|
||||
#[schema(value_type = PaymentsResponse, title = "PaymentsResponse")]
|
||||
PaymentDetails(Box<payments::PaymentsResponse>),
|
||||
@ -241,6 +275,23 @@ pub enum OutgoingWebhookContent {
|
||||
PayoutDetails(Box<payouts::PayoutCreateResponse>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, ToSchema)]
|
||||
#[serde(tag = "type", content = "object", rename_all = "snake_case")]
|
||||
#[cfg(feature = "v2")]
|
||||
pub enum OutgoingWebhookContent {
|
||||
#[schema(value_type = PaymentsResponse, title = "PaymentsResponse")]
|
||||
PaymentDetails(Box<payments::PaymentsRetrieveResponse>),
|
||||
#[schema(value_type = RefundResponse, title = "RefundResponse")]
|
||||
RefundDetails(Box<refunds::RefundResponse>),
|
||||
#[schema(value_type = DisputeResponse, title = "DisputeResponse")]
|
||||
DisputeDetails(Box<disputes::DisputeResponse>),
|
||||
#[schema(value_type = MandateResponse, title = "MandateResponse")]
|
||||
MandateDetails(Box<mandates::MandateResponse>),
|
||||
#[cfg(feature = "payouts")]
|
||||
#[schema(value_type = PayoutCreateResponse, title = "PayoutCreateResponse")]
|
||||
PayoutDetails(Box<payouts::PayoutCreateResponse>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct ConnectorWebhookSecrets {
|
||||
pub secret: Vec<u8>,
|
||||
|
||||
Reference in New Issue
Block a user