feat(router): added incoming dispute webhooks flow (#769)

Co-authored-by: Sangamesh <sangamesh.kulkarni@juspay.in>
Co-authored-by: sai harsha <sai.harsha@sai.harsha-MacBookPro>
Co-authored-by: Arun Raj M <jarnura47@gmail.com>
This commit is contained in:
saiharsha-juspay
2023-03-30 04:25:54 +05:30
committed by GitHub
parent fb66a0e0f2
commit a733eafbbe
28 changed files with 1139 additions and 32 deletions

View File

@ -2,7 +2,7 @@ use common_utils::custom_serde;
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;
use crate::{enums as api_enums, payments, refunds};
use crate::{disputes, enums as api_enums, payments, refunds};
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
@ -11,12 +11,22 @@ pub enum IncomingWebhookEvent {
PaymentIntentSuccess,
RefundFailure,
RefundSuccess,
DisputeOpened,
DisputeExpired,
DisputeAccepted,
DisputeCancelled,
DisputeChallenged,
// dispute has been successfully challenged by the merchant
DisputeWon,
// dispute has been unsuccessfully challenged
DisputeLost,
EndpointVerification,
}
pub enum WebhookFlow {
Payment,
Refund,
Dispute,
Subscription,
ReturnResponse,
}
@ -28,6 +38,13 @@ impl From<IncomingWebhookEvent> for WebhookFlow {
IncomingWebhookEvent::PaymentIntentSuccess => Self::Payment,
IncomingWebhookEvent::RefundSuccess => Self::Refund,
IncomingWebhookEvent::RefundFailure => Self::Refund,
IncomingWebhookEvent::DisputeOpened => Self::Dispute,
IncomingWebhookEvent::DisputeAccepted => Self::Dispute,
IncomingWebhookEvent::DisputeExpired => Self::Dispute,
IncomingWebhookEvent::DisputeCancelled => Self::Dispute,
IncomingWebhookEvent::DisputeChallenged => Self::Dispute,
IncomingWebhookEvent::DisputeWon => Self::Dispute,
IncomingWebhookEvent::DisputeLost => Self::Dispute,
IncomingWebhookEvent::EndpointVerification => Self::ReturnResponse,
}
}
@ -73,6 +90,7 @@ pub struct OutgoingWebhook {
pub enum OutgoingWebhookContent {
PaymentDetails(payments::PaymentsResponse),
RefundDetails(refunds::RefundResponse),
DisputeDetails(Box<disputes::DisputeResponse>),
}
pub trait OutgoingWebhookType: Serialize + From<OutgoingWebhook> + Sync + Send {}