diff --git a/crates/api_models/src/refunds.rs b/crates/api_models/src/refunds.rs index 0a7aab99e5..02a92f3037 100644 --- a/crates/api_models/src/refunds.rs +++ b/crates/api_models/src/refunds.rs @@ -45,6 +45,14 @@ pub struct RefundRequest { pub metadata: Option, } +#[derive(Default, Debug, ToSchema, Clone, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct RefundUpdateRequest { + /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object. + #[schema(value_type = Option, example = r#"{ "city": "NY", "unit": "245" }"#)] + pub metadata: Option, +} + #[derive(Default, Debug, Clone, ToSchema, Deserialize)] #[serde(rename_all = "snake_case")] pub enum RefundType { diff --git a/crates/router/src/compatibility/stripe/refunds.rs b/crates/router/src/compatibility/stripe/refunds.rs index f498893df2..38e766ddee 100644 --- a/crates/router/src/compatibility/stripe/refunds.rs +++ b/crates/router/src/compatibility/stripe/refunds.rs @@ -78,11 +78,11 @@ pub async fn refund_update( state: web::Data, req: HttpRequest, path: web::Path, - form_payload: web::Form, + form_payload: web::Form, ) -> HttpResponse { let refund_id = path.into_inner(); let payload = form_payload.into_inner(); - let create_refund_update_req: refund_types::RefundRequest = payload.into(); + let create_refund_update_req: refund_types::RefundUpdateRequest = payload.into(); wrap::compatibility_api_wrap::< _, diff --git a/crates/router/src/compatibility/stripe/refunds/types.rs b/crates/router/src/compatibility/stripe/refunds/types.rs index 4c30d26ec4..94c4fb1769 100644 --- a/crates/router/src/compatibility/stripe/refunds/types.rs +++ b/crates/router/src/compatibility/stripe/refunds/types.rs @@ -11,6 +11,11 @@ pub struct StripeCreateRefundRequest { pub reason: Option, } +#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)] +pub struct StripeUpdateRefundRequest { + pub metadata: Option, +} + #[derive(Clone, Serialize, PartialEq, Eq)] pub struct StripeCreateRefundResponse { pub id: String, @@ -40,6 +45,14 @@ impl From for refunds::RefundRequest { } } +impl From for refunds::RefundUpdateRequest { + fn from(req: StripeUpdateRefundRequest) -> Self { + Self { + metadata: req.metadata, + } + } +} + impl From for StripeRefundStatus { fn from(status: refunds::RefundStatus) -> Self { match status { diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs index 78f9cac31b..1ed2563199 100644 --- a/crates/router/src/core/refunds.rs +++ b/crates/router/src/core/refunds.rs @@ -314,7 +314,7 @@ pub async fn refund_update_core( db: &dyn db::StorageInterface, merchant_account: storage::MerchantAccount, refund_id: &str, - req: refunds::RefundRequest, + req: refunds::RefundUpdateRequest, ) -> RouterResponse { let refund = db .find_refund_by_merchant_id_refund_id( diff --git a/crates/router/src/routes/refunds.rs b/crates/router/src/routes/refunds.rs index 3514720132..a11065a31d 100644 --- a/crates/router/src/routes/refunds.rs +++ b/crates/router/src/routes/refunds.rs @@ -63,7 +63,7 @@ pub async fn refunds_retrieve( pub async fn refunds_update( state: web::Data, req: HttpRequest, - json_payload: web::Json, + json_payload: web::Json, path: web::Path, ) -> HttpResponse { let refund_id = path.into_inner(); diff --git a/crates/router/src/types/api/refunds.rs b/crates/router/src/types/api/refunds.rs index 2dd28ae117..3b5dfaece0 100644 --- a/crates/router/src/types/api/refunds.rs +++ b/crates/router/src/types/api/refunds.rs @@ -1,4 +1,6 @@ -pub use api_models::refunds::{RefundRequest, RefundResponse, RefundStatus, RefundType}; +pub use api_models::refunds::{ + RefundRequest, RefundResponse, RefundStatus, RefundType, RefundUpdateRequest, +}; use super::ConnectorCommon; use crate::{