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(payouts): Mapped Default Values to Unified Error Code and Message (#9262)

Sayak Bhattacharya4ab54f3c835d
diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rs
index dee0d3f130..300fca5293 100644
--- a/crates/router/src/core/payouts.rs
+++ b/crates/router/src/core/payouts.rs
@@ -1473,7 +1473,13 @@ pub async fn check_payout_eligibility(
consts::PAYOUT_FLOW_STR,
)
.await
- .map_or((None, None), |gsm| (gsm.unified_code, gsm.unified_message));
+ .map_or(
+ (
+ Some(crate::consts::DEFAULT_UNIFIED_ERROR_CODE.to_string()),
+ Some(crate::consts::DEFAULT_UNIFIED_ERROR_MESSAGE.to_string()),
+ ),
+ |gsm| (gsm.unified_code, gsm.unified_message),
+ );
let updated_payout_attempt = storage::PayoutAttemptUpdate::StatusUpdate {
connector_payout_id: payout_data.payout_attempt.connector_payout_id.to_owned(),
status,
@@ -1689,7 +1695,13 @@ pub async fn create_payout(
consts::PAYOUT_FLOW_STR,
)
.await
- .map_or((None, None), |gsm| (gsm.unified_code, gsm.unified_message));
+ .map_or(
+ (
+ Some(crate::consts::DEFAULT_UNIFIED_ERROR_CODE.to_string()),
+ Some(crate::consts::DEFAULT_UNIFIED_ERROR_MESSAGE.to_string()),
+ ),
+ |gsm| (gsm.unified_code, gsm.unified_message),
+ );
let updated_payout_attempt = storage::PayoutAttemptUpdate::StatusUpdate {
connector_payout_id: payout_data.payout_attempt.connector_payout_id.to_owned(),
status,
@@ -1888,7 +1900,13 @@ pub async fn update_retrieve_payout_tracker<F, T>(
consts::PAYOUT_FLOW_STR,
)
.await
- .map_or((None, None), |gsm| (gsm.unified_code, gsm.unified_message));
+ .map_or(
+ (
+ Some(crate::consts::DEFAULT_UNIFIED_ERROR_CODE.to_string()),
+ Some(crate::consts::DEFAULT_UNIFIED_ERROR_MESSAGE.to_string()),
+ ),
+ |gsm| (gsm.unified_code, gsm.unified_message),
+ );
storage::PayoutAttemptUpdate::StatusUpdate {
connector_payout_id: payout_response_data.connector_payout_id.clone(),
status,
@@ -2132,7 +2150,13 @@ pub async fn create_recipient_disburse_account(
consts::PAYOUT_FLOW_STR,
)
.await
- .map_or((None, None), |gsm| (gsm.unified_code, gsm.unified_message));
+ .map_or(
+ (
+ Some(crate::consts::DEFAULT_UNIFIED_ERROR_CODE.to_string()),
+ Some(crate::consts::DEFAULT_UNIFIED_ERROR_MESSAGE.to_string()),
+ ),
+ |gsm| (gsm.unified_code, gsm.unified_message),
+ );
let updated_payout_attempt = storage::PayoutAttemptUpdate::StatusUpdate {
connector_payout_id: payout_data.payout_attempt.connector_payout_id.to_owned(),
status: storage_enums::PayoutStatus::Failed,
@@ -2250,7 +2274,13 @@ pub async fn cancel_payout(
consts::PAYOUT_FLOW_STR,
)
.await
- .map_or((None, None), |gsm| (gsm.unified_code, gsm.unified_message));
+ .map_or(
+ (
+ Some(crate::consts::DEFAULT_UNIFIED_ERROR_CODE.to_string()),
+ Some(crate::consts::DEFAULT_UNIFIED_ERROR_MESSAGE.to_string()),
+ ),
+ |gsm| (gsm.unified_code, gsm.unified_message),
+ );
let updated_payout_attempt = storage::PayoutAttemptUpdate::StatusUpdate {
connector_payout_id: payout_data.payout_attempt.connector_payout_id.to_owned(),
status,
@@ -2421,7 +2451,13 @@ pub async fn fulfill_payout(
consts::PAYOUT_FLOW_STR,
)
.await
- .map_or((None, None), |gsm| (gsm.unified_code, gsm.unified_message));
+ .map_or(
+ (
+ Some(crate::consts::DEFAULT_UNIFIED_ERROR_CODE.to_string()),
+ Some(crate::consts::DEFAULT_UNIFIED_ERROR_MESSAGE.to_string()),
+ ),
+ |gsm| (gsm.unified_code, gsm.unified_message),
+ );
let updated_payout_attempt = storage::PayoutAttemptUpdate::StatusUpdate {
connector_payout_id: payout_data.payout_attempt.connector_payout_id.to_owned(),
status,