Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(ManualUpdate): [refunds] add support for connector refund id update (#13606)

Nithin Nb301983d7095
diff --git a/crates/api_models/src/refunds.rs b/crates/api_models/src/refunds.rs
index 210efb8c95..704ff82058 100644
--- a/crates/api_models/src/refunds.rs
+++ b/crates/api_models/src/refunds.rs
@@ -235,6 +235,8 @@ pub struct RefundManualUpdateRequest {
/// Merchant ID
#[schema(value_type = String)]
pub merchant_id: common_utils::id_type::MerchantId,
+ /// A unique identifier for a refund provided by the connector
+ pub connector_refund_id: Option<String>,
/// The status for refund
pub status: Option<RefundStatus>,
/// The code for the error
diff --git a/crates/diesel_models/src/refund.rs b/crates/diesel_models/src/refund.rs
index 73dd31da49..6a3caa73e4 100644
--- a/crates/diesel_models/src/refund.rs
+++ b/crates/diesel_models/src/refund.rs
@@ -295,6 +295,7 @@ pub enum RefundUpdate {
issuer_error_message: Option<String>,
},
ManualUpdate {
+ connector_refund_id: Option<ConnectorTransactionId>,
refund_status: Option<storage_enums::RefundStatus>,
refund_error_message: Option<Option<String>>,
refund_error_code: Option<Option<String>>,
@@ -337,6 +338,7 @@ pub enum RefundUpdate {
unified_message: Option<String>,
},
ManualUpdate {
+ connector_refund_id: Option<ConnectorTransactionId>,
refund_status: Option<storage_enums::RefundStatus>,
refund_error_message: Option<Option<String>>,
refund_error_code: Option<Option<String>>,
@@ -532,6 +534,7 @@ impl From<RefundUpdate> for RefundUpdateInternal {
issuer_error_message,
},
RefundUpdate::ManualUpdate {
+ connector_refund_id,
refund_status,
refund_error_message,
refund_error_code,
@@ -541,7 +544,7 @@ impl From<RefundUpdate> for RefundUpdateInternal {
refund_error_message,
refund_error_code,
updated_by,
- connector_refund_id: None,
+ connector_refund_id,
sent_to_gateway: None,
refund_arn: None,
metadata: None,
@@ -649,6 +652,7 @@ impl From<RefundUpdate> for RefundUpdateInternal {
unified_message,
},
RefundUpdate::ManualUpdate {
+ connector_refund_id,
refund_status,
refund_error_message,
refund_error_code,
@@ -658,7 +662,7 @@ impl From<RefundUpdate> for RefundUpdateInternal {
refund_error_message,
refund_error_code,
updated_by,
- connector_refund_id: None,
+ connector_refund_id,
sent_to_gateway: None,
refund_arn: None,
metadata: None,
diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs
index baa915b9ee..71c50d86c4 100644
--- a/crates/router/src/core/refunds.rs
+++ b/crates/router/src/core/refunds.rs
@@ -1657,6 +1657,7 @@ pub async fn refund_manual_update(
.await
.to_not_found_response(errors::ApiErrorResponse::RefundNotFound)?;
let refund_update = diesel_refund::RefundUpdate::ManualUpdate {
+ connector_refund_id: req.connector_refund_id.map(ConnectorTransactionId::from),
refund_status: req.status.map(common_enums::RefundStatus::from),
refund_error_message: req.error_message.map(|msg| match msg {
api_enums::SetOrUnset::Set(value) => Some(value),