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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(payments): add error_reason field to PaymentsResponse and constants (#10338)
Ayush Anand58ba7e5916ed
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 69d2f97101..d479150b0c 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -27556,6 +27556,11 @@"example": "Failed while verifying the card","nullable": true},+ "error_reason": {+ "type": "string",+ "example": "Insufficient Funds",+ "nullable": true+ },"payment_experience": {"allOf": [{@@ -29108,6 +29113,11 @@"example": "Failed while verifying the card","nullable": true},+ "error_reason": {+ "type": "string",+ "example": "Insufficient Funds",+ "nullable": true+ },"unified_code": {"type": "string","description": "error code unified across the connectors is received here if there was an error while calling connector",diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 1f919811ab..54c6940140 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -6853,6 +6853,10 @@ pub struct PaymentsResponse {#[smithy(value_type = "Option<String>")]pub error_message: Option<String>,+ #[schema(example = "Insufficient Funds")]+ #[smithy(value_type = "Option<String>")]+ pub error_reason: Option<String>,+/// error code unified across the connectors is received here if there was an error while calling connector#[remove_in(PaymentsCreateResponseOpenApi)]#[smithy(value_type = "Option<String>")]diff --git a/crates/hyperswitch_interfaces/src/consts.rs b/crates/hyperswitch_interfaces/src/consts.rsindex f5214b4db7..79eb822dc7 100644--- a/crates/hyperswitch_interfaces/src/consts.rs+++ b/crates/hyperswitch_interfaces/src/consts.rs@@ -6,6 +6,9 @@ pub const NO_ERROR_MESSAGE: &str = "No error message";/// No error code string constpub const NO_ERROR_CODE: &str = "No error code";+/// No error reason string const+pub const NO_ERROR_REASON: &str = "No error reason";+/// Accepted format for requestpub const ACCEPT_HEADER: &str = "text/html,application/json";diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex e53167ffb2..7aa574e0f6 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -3324,7 +3324,7 @@ where{use std::ops::Not;- use hyperswitch_interfaces::consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE};+ use hyperswitch_interfaces::consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE, NO_ERROR_REASON};let payment_attempt = payment_data.get_payment_attempt().clone();let payment_intent = payment_data.get_payment_intent().clone();@@ -3856,9 +3856,11 @@ where.error_code.filter(|code| code != NO_ERROR_CODE),error_message: payment_attempt- .error_reason- .or(payment_attempt.error_message)+ .error_message.filter(|message| message != NO_ERROR_MESSAGE),+ error_reason: payment_attempt+ .error_reason+ .filter(|reason| reason != NO_ERROR_REASON),unified_code: payment_attempt.unified_code,unified_message: payment_attempt.unified_message,payment_experience: payment_attempt.payment_experience,@@ -4195,6 +4197,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Paycancellation_reason: None,error_code: None,error_message: None,+ error_reason: None,unified_code: None,unified_message: None,payment_experience: None,diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rsindex 7a5a674a35..ef01adf8fb 100644--- a/crates/router/src/db/events.rs+++ b/crates/router/src/db/events.rs@@ -1367,6 +1367,7 @@ mod tests {cancellation_reason: None,error_code: None,error_message: None,+ error_reason: None,unified_code: None,unified_message: None,payment_experience: None,diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rsindex fb781781e7..9a23ab8d1c 100644--- a/crates/router/tests/payments.rs+++ b/crates/router/tests/payments.rs@@ -413,6 +413,7 @@ async fn payments_create_core() {cancellation_reason: None,error_code: None,error_message: None,+ error_reason: None,unified_code: None,unified_message: None,payment_experience: None,@@ -705,6 +706,7 @@ async fn payments_create_core_adyen_no_redirect() {cancellation_reason: None,error_code: None,error_message: None,+ error_reason: None,unified_code: None,unified_message: None,payment_experience: None,diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rsindex 98f0daf05b..18386f5731 100644--- a/crates/router/tests/payments2.rs+++ b/crates/router/tests/payments2.rs@@ -173,6 +173,7 @@ async fn payments_create_core() {cancellation_reason: None,error_code: None,error_message: None,+ error_reason: None,unified_code: None,unified_message: None,payment_experience: None,@@ -474,6 +475,7 @@ async fn payments_create_core_adyen_no_redirect() {cancellation_reason: None,error_code: None,error_message: None,+ error_reason: None,unified_code: None,unified_message: None,payment_experience: None,