mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 17:47:54 +08:00
fix(refunds): removed payment_id as mandatory parameter in refund update (#338)
This commit is contained in:
@ -45,6 +45,14 @@ pub struct RefundRequest {
|
||||
pub metadata: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
#[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<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]
|
||||
pub metadata: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, ToSchema, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum RefundType {
|
||||
|
||||
@ -78,11 +78,11 @@ pub async fn refund_update(
|
||||
state: web::Data<routes::AppState>,
|
||||
req: HttpRequest,
|
||||
path: web::Path<String>,
|
||||
form_payload: web::Form<types::StripeCreateRefundRequest>,
|
||||
form_payload: web::Form<types::StripeUpdateRefundRequest>,
|
||||
) -> 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::<
|
||||
_,
|
||||
|
||||
@ -11,6 +11,11 @@ pub struct StripeCreateRefundRequest {
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct StripeUpdateRefundRequest {
|
||||
pub metadata: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, PartialEq, Eq)]
|
||||
pub struct StripeCreateRefundResponse {
|
||||
pub id: String,
|
||||
@ -40,6 +45,14 @@ impl From<StripeCreateRefundRequest> for refunds::RefundRequest {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StripeUpdateRefundRequest> for refunds::RefundUpdateRequest {
|
||||
fn from(req: StripeUpdateRefundRequest) -> Self {
|
||||
Self {
|
||||
metadata: req.metadata,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<refunds::RefundStatus> for StripeRefundStatus {
|
||||
fn from(status: refunds::RefundStatus) -> Self {
|
||||
match status {
|
||||
|
||||
@ -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<refunds::RefundResponse> {
|
||||
let refund = db
|
||||
.find_refund_by_merchant_id_refund_id(
|
||||
|
||||
@ -63,7 +63,7 @@ pub async fn refunds_retrieve(
|
||||
pub async fn refunds_update(
|
||||
state: web::Data<AppState>,
|
||||
req: HttpRequest,
|
||||
json_payload: web::Json<refunds::RefundRequest>,
|
||||
json_payload: web::Json<refunds::RefundUpdateRequest>,
|
||||
path: web::Path<String>,
|
||||
) -> HttpResponse {
|
||||
let refund_id = path.into_inner();
|
||||
|
||||
@ -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::{
|
||||
|
||||
Reference in New Issue
Block a user