Skip to content
41 changes: 41 additions & 0 deletions api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3265,6 +3265,47 @@
]
}
},
"/v2/refunds/{id}": {
"get": {
"tags": [
"Refunds"
],
"summary": "Refunds - Retrieve",
"description": "Retrieves a Refund. This may be used to get the status of a previously initiated refund",
"operationId": "Retrieve a Refund",
"parameters": [
{
"name": "id",
"in": "path",
"description": "The identifier for refund",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Refund retrieved",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RefundResponse"
}
}
}
},
"404": {
"description": "Refund does not exist in our records"
}
},
"security": [
{
"api_key": []
}
]
}
},
"/v2/process_tracker/revenue_recovery_workflow/{revenue_recovery_id}": {
"get": {
"tags": [
Expand Down
7 changes: 7 additions & 0 deletions crates/api_models/src/events/refund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ impl ApiEventMetric for RefundsRetrieveRequest {
}
}

#[cfg(feature = "v2")]
impl ApiEventMetric for RefundsRetrieveRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
None
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for RefundUpdateRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Expand Down
16 changes: 16 additions & 0 deletions crates/api_models/src/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pub struct RefundsRetrieveBody {
pub force_sync: Option<bool>,
}

#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
#[derive(Default, Debug, ToSchema, Clone, Deserialize, Serialize)]
pub struct RefundsRetrieveRequest {
/// Unique Identifier for the Refund. This is to ensure idempotency for multiple partial refund initiated against the same payment. If the identifiers is not defined by the merchant, this filed shall be auto generated and provide in the API response. It is recommended to generate uuid(v4) as the refund_id.
Expand All @@ -128,6 +129,21 @@ pub struct RefundsRetrieveRequest {
pub merchant_connector_details: Option<admin::MerchantConnectorDetailsWrap>,
}

#[cfg(all(feature = "v2", feature = "refunds_v2"))]
#[derive(Debug, ToSchema, Clone, Deserialize, Serialize)]
pub struct RefundsRetrieveRequest {
/// Unique Identifier for the Refund. This is to ensure idempotency for multiple partial refund initiated against the same payment. If the identifiers is not defined by the merchant, this filed shall be auto generated and provide in the API response. It is recommended to generate uuid(v4) as the refund_id.
#[schema(value_type = String)]
pub refund_id: common_utils::id_type::GlobalRefundId,

/// `force_sync` with the connector to get refund details
/// (defaults to false)
pub force_sync: Option<bool>,

/// Merchant connector details used to make payments.
pub merchant_connector_details: Option<admin::MerchantConnectorDetailsWrap>,
}

#[derive(Default, Debug, ToSchema, Clone, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RefundUpdateRequest {
Expand Down
18 changes: 18 additions & 0 deletions crates/diesel_models/src/refund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,24 @@ impl RefundUpdate {
processor_refund_data: connector_refund_id.extract_hashed_data(),
}
}

pub fn build_error_update_for_refund_failure(
refund_status: Option<storage_enums::RefundStatus>,
refund_error_message: Option<String>,
refund_error_code: Option<String>,
storage_scheme: &storage_enums::MerchantStorageScheme,
) -> Self {
Self::ErrorUpdate {
refund_status,
refund_error_message,
refund_error_code,
updated_by: storage_scheme.to_string(),
connector_refund_id: None,
processor_refund_data: None,
unified_code: None,
unified_message: None,
}
}
}

#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
Expand Down
4 changes: 4 additions & 0 deletions crates/hyperswitch_domain_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,10 @@ impl PaymentIntent {
})
.transpose()
}

pub fn get_currency(&self) -> storage_enums::Currency {
self.amount_details.currency
}
}

#[cfg(feature = "v1")]
Expand Down
1 change: 1 addition & 0 deletions crates/openapi/src/openapi_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Never share your secret api keys. Keep them guarded and secure.

//Routes for refunds
routes::refunds::refunds_create,
routes::refunds::refunds_retrieve,

// Routes for Revenue Recovery flow under Process Tracker
routes::revenue_recovery::revenue_recovery_pt_retrieve_api
Expand Down
21 changes: 21 additions & 0 deletions crates/openapi/src/routes/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub async fn refunds_create() {}
operation_id = "Retrieve a Refund",
security(("api_key" = []))
)]
#[cfg(feature = "v1")]
pub async fn refunds_retrieve() {}

/// Refunds - Retrieve (POST)
Expand Down Expand Up @@ -212,3 +213,23 @@ pub async fn refunds_filter_list() {}
)]
#[cfg(feature = "v2")]
pub async fn refunds_create() {}

/// Refunds - Retrieve
///
/// Retrieves a Refund. This may be used to get the status of a previously initiated refund
#[utoipa::path(
get,
path = "/v2/refunds/{id}",
params(
("id" = String, Path, description = "The identifier for refund")
),
responses(
(status = 200, description = "Refund retrieved", body = RefundResponse),
(status = 404, description = "Refund does not exist in our records")
),
tag = "Refunds",
operation_id = "Retrieve a Refund",
security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn refunds_retrieve() {}
Loading
Loading