feat(payouts): Implement Smart Retries for Payout (#3580)

Co-authored-by: Kashif <kashif.dev@protonmail.com>
Co-authored-by: Kashif <mohammed.kashif@juspay.in>
This commit is contained in:
Sakil Mostak
2024-02-28 15:08:20 +05:30
committed by GitHub
parent 15b367eb79
commit 8b32dffe32
13 changed files with 685 additions and 83 deletions

View File

@ -29,6 +29,7 @@ pub struct Payouts {
pub created_at: PrimitiveDateTime,
#[serde(with = "common_utils::custom_serde::iso8601")]
pub last_modified_at: PrimitiveDateTime,
pub attempt_count: i16,
}
impl Default for Payouts {
@ -53,6 +54,7 @@ impl Default for Payouts {
metadata: Option::default(),
created_at: now,
last_modified_at: now,
attempt_count: i16::default(),
}
}
}
@ -90,6 +92,7 @@ pub struct PayoutsNew {
pub created_at: Option<PrimitiveDateTime>,
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub last_modified_at: Option<PrimitiveDateTime>,
pub attempt_count: i16,
}
#[derive(Debug)]
@ -114,6 +117,9 @@ pub enum PayoutsUpdate {
recurring: bool,
last_modified_at: Option<PrimitiveDateTime>,
},
AttemptCountUpdate {
attempt_count: i16,
},
}
#[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)]
@ -130,6 +136,7 @@ pub struct PayoutsUpdateInternal {
pub metadata: Option<pii::SecretSerdeValue>,
pub last_modified_at: Option<PrimitiveDateTime>,
pub payout_method_id: Option<String>,
pub attempt_count: Option<i16>,
}
impl From<PayoutsUpdate> for PayoutsUpdateInternal {
@ -175,6 +182,10 @@ impl From<PayoutsUpdate> for PayoutsUpdateInternal {
recurring: Some(recurring),
..Default::default()
},
PayoutsUpdate::AttemptCountUpdate { attempt_count } => Self {
attempt_count: Some(attempt_count),
..Default::default()
},
}
}
}