feat(webhooks): webhooks effect tracker (#2260)

This commit is contained in:
Narayan Bhat
2023-10-03 14:57:34 +05:30
committed by GitHub
parent abfdea20b0
commit 5048d248e5
4 changed files with 103 additions and 31 deletions

View File

@ -5,7 +5,7 @@ use utoipa::ToSchema;
use crate::{disputes, enums as api_enums, payments, refunds};
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Copy)]
#[serde(rename_all = "snake_case")]
pub enum IncomingWebhookEvent {
PaymentIntentFailure,
@ -39,6 +39,26 @@ pub enum WebhookFlow {
BankTransfer,
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
/// This enum tells about the affect a webhook had on an object
pub enum WebhookResponseTracker {
Payment {
payment_id: String,
status: common_enums::IntentStatus,
},
Refund {
payment_id: String,
refund_id: String,
status: common_enums::RefundStatus,
},
Dispute {
dispute_id: String,
payment_id: String,
status: common_enums::DisputeStatus,
},
NoEffect,
}
impl From<IncomingWebhookEvent> for WebhookFlow {
fn from(evt: IncomingWebhookEvent) -> Self {
match evt {