Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(router): add support for relay refund incoming webhooks #6974

Merged
merged 16 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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> {
ShankarSinghC marked this conversation as resolved.
Show resolved Hide resolved
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
Loading