mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(refunds_v2): Add refund create core flow (#7619)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,9 +1,13 @@
|
||||
use common_utils::events::{ApiEventMetric, ApiEventsType};
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
use crate::refunds::RefundRequest;
|
||||
#[cfg(feature = "v2")]
|
||||
use crate::refunds::RefundsCreateRequest;
|
||||
use crate::refunds::{
|
||||
RefundAggregateResponse, RefundListFilters, RefundListMetaData, RefundListRequest,
|
||||
RefundListResponse, RefundManualUpdateRequest, RefundRequest, RefundResponse,
|
||||
RefundUpdateRequest, RefundsRetrieveRequest,
|
||||
RefundListResponse, RefundManualUpdateRequest, RefundResponse, RefundUpdateRequest,
|
||||
RefundsRetrieveRequest,
|
||||
};
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
@ -19,6 +23,13 @@ impl ApiEventMetric for RefundRequest {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl ApiEventMetric for RefundsCreateRequest {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
impl ApiEventMetric for RefundResponse {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
|
||||
@ -12,6 +12,7 @@ use crate::{
|
||||
enums,
|
||||
};
|
||||
|
||||
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
|
||||
#[derive(Default, Debug, ToSchema, Clone, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct RefundRequest {
|
||||
@ -61,7 +62,7 @@ pub struct RefundRequest {
|
||||
pub split_refunds: Option<common_types::refunds::SplitRefund>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[cfg(all(feature = "v2", feature = "refunds_v2"))]
|
||||
#[derive(Debug, ToSchema, Clone, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct RefundsCreateRequest {
|
||||
@ -74,14 +75,18 @@ pub struct RefundsCreateRequest {
|
||||
)]
|
||||
pub payment_id: common_utils::id_type::GlobalPaymentId,
|
||||
|
||||
/// Unique Identifier for the Refund. This is to ensure idempotency for multiple partial refunds initiated against the same payment.
|
||||
/// Unique Identifier for the Refund given by the Merchant.
|
||||
#[schema(
|
||||
max_length = 30,
|
||||
min_length = 30,
|
||||
max_length = 64,
|
||||
min_length = 1,
|
||||
example = "ref_mbabizu24mvu3mela5njyhpit4",
|
||||
value_type = Option<String>,
|
||||
value_type = String,
|
||||
)]
|
||||
pub merchant_reference_id: Option<common_utils::id_type::RefundReferenceId>,
|
||||
pub merchant_reference_id: common_utils::id_type::RefundReferenceId,
|
||||
|
||||
/// The identifier for the Merchant Account
|
||||
#[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = Option<String>)]
|
||||
pub merchant_id: Option<common_utils::id_type::MerchantId>,
|
||||
|
||||
/// Total amount for which the refund is to be initiated. Amount for the payment in lowest denomination of the currency. (i.e) in cents for USD denomination, in paisa for INR denomination etc., If not provided, this will default to the amount_captured of the payment
|
||||
#[schema(value_type = Option<i64> , minimum = 100, example = 6540)]
|
||||
@ -153,6 +158,7 @@ pub struct RefundManualUpdateRequest {
|
||||
pub error_message: Option<String>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
/// To indicate whether to refund needs to be instant or scheduled
|
||||
#[derive(
|
||||
Default, Debug, Clone, Copy, ToSchema, Deserialize, Serialize, Eq, PartialEq, strum::Display,
|
||||
@ -164,6 +170,18 @@ pub enum RefundType {
|
||||
Instant,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
/// To indicate whether the refund needs to be instant or scheduled
|
||||
#[derive(
|
||||
Default, Debug, Clone, Copy, ToSchema, Deserialize, Serialize, Eq, PartialEq, strum::Display,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum RefundType {
|
||||
Scheduled,
|
||||
#[default]
|
||||
Instant,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema)]
|
||||
pub struct RefundResponse {
|
||||
|
||||
Reference in New Issue
Block a user