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

fix(core): condition to do refund sync (#11725)

Sakil Mostak4e0be5876713
diff --git a/crates/hyperswitch_connectors/src/connectors/adyen.rs b/crates/hyperswitch_connectors/src/connectors/adyen.rs
index 208fbdb020..7a5498ef8e 100644
--- a/crates/hyperswitch_connectors/src/connectors/adyen.rs
+++ b/crates/hyperswitch_connectors/src/connectors/adyen.rs
@@ -1961,7 +1961,18 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Adyen {
}
}
-impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Adyen {}
+impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Adyen {
+ fn build_request(
+ &self,
+ _req: &RefundsRouterData<RSync>,
+ _connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Err(
+ errors::ConnectorError::NotImplemented("Refund Sync flow not Implemented".to_string())
+ .into(),
+ )
+ }
+}
fn get_webhook_object_from_body(
body: &[u8],
diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs
index cf23258981..74e824a19d 100644
--- a/crates/router/src/core/refunds.rs
+++ b/crates/router/src/core/refunds.rs
@@ -836,15 +836,14 @@ fn should_call_refund(
// doesn't exist
let predicate1 = refund.connector_refund_id.is_some();
- // This allows refund sync at connector level if all_keys_required or force_sync is enabled, or
- // checks if the refund has failed
+ // This allows refund sync at connector level if all_keys_required or force_sync is enabled for non terminal refund statuses (i.e. not success or failure)
let predicate2 = all_keys_required
- || force_sync
- || !matches!(
- refund.refund_status,
- diesel_models::enums::RefundStatus::Failure
- | diesel_models::enums::RefundStatus::Success
- );
+ || (force_sync
+ && !matches!(
+ refund.refund_status,
+ diesel_models::enums::RefundStatus::Failure
+ | diesel_models::enums::RefundStatus::Success
+ ));
predicate1 && predicate2
}