Skip to content

Commit

Permalink
feat(router): add support for relay refund incoming webhooks (#6974)
Browse files Browse the repository at this point in the history
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
ShankarSinghC and hyperswitch-bot[bot] authored Jan 10, 2025
1 parent 15fd4de commit d850f17
Show file tree
Hide file tree
Showing 16 changed files with 485 additions and 94 deletions.
6 changes: 6 additions & 0 deletions crates/api_models/src/webhooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ pub enum WebhookResponseTracker {
status: common_enums::MandateStatus,
},
NoEffect,
Relay {
relay_id: common_utils::id_type::RelayId,
status: common_enums::RelayStatus,
},
}

impl WebhookResponseTracker {
Expand All @@ -132,6 +136,7 @@ impl WebhookResponseTracker {
Self::NoEffect | Self::Mandate { .. } => None,
#[cfg(feature = "payouts")]
Self::Payout { .. } => None,
Self::Relay { .. } => None,
}
}

Expand All @@ -144,6 +149,7 @@ impl WebhookResponseTracker {
Self::NoEffect | Self::Mandate { .. } => None,
#[cfg(feature = "payouts")]
Self::Payout { .. } => None,
Self::Relay { .. } => None,
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions crates/common_utils/src/id_type/relay.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::str::FromStr;

crate::id_type!(
RelayId,
"A type for relay_id that can be used for relay ids"
Expand All @@ -11,3 +13,12 @@ crate::impl_queryable_id_type!(RelayId);
crate::impl_to_sql_from_sql_id_type!(RelayId);

crate::impl_debug_id_type!(RelayId);

impl FromStr for RelayId {
type Err = error_stack::Report<crate::errors::ValidationError>;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let cow_string = std::borrow::Cow::Owned(s.to_string());
Self::try_from(cow_string)
}
}
16 changes: 15 additions & 1 deletion crates/diesel_models/src/query/relay.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use diesel::{associations::HasTable, ExpressionMethods};
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};

use super::generics;
use crate::{
Expand Down Expand Up @@ -46,4 +46,18 @@ impl Relay {
)
.await
}

pub async fn find_by_profile_id_connector_reference_id(
conn: &PgPooledConn,
profile_id: &common_utils::id_type::ProfileId,
connector_reference_id: &str,
) -> StorageResult<Self> {
generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
conn,
dsl::profile_id
.eq(profile_id.to_owned())
.and(dsl::connector_reference_id.eq(connector_reference_id.to_owned())),
)
.await
}
}
2 changes: 1 addition & 1 deletion crates/hyperswitch_domain_models/src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl RelayUpdate {
match response {
Err(error) => Self::ErrorUpdate {
error_code: error.code,
error_message: error.message,
error_message: error.reason.unwrap_or(error.message),
status: common_enums::RelayStatus::Failure,
},
Ok(response) => Self::StatusUpdate {
Expand Down
Loading

0 comments on commit d850f17

Please sign in to comment.