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

refactor(connector): [Adyen] handle redirection error response (#4862)

Swangi Kumari8096d5e577d8
diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs
index bed99a9fb6..2489afd94d 100644
--- a/crates/router/src/connector/adyen/transformers.rs
+++ b/crates/router/src/connector/adyen/transformers.rs
@@ -394,8 +394,9 @@ pub struct AdyenWebhookResponse {
#[serde(rename_all = "camelCase")]
pub struct RedirectionErrorResponse {
result_code: AdyenStatus,
- refusal_reason: String,
+ refusal_reason: Option<String>,
psp_reference: Option<String>,
+ merchant_reference: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
@@ -3566,8 +3567,11 @@ pub fn get_redirection_error_response(
storage_enums::AttemptStatus::foreign_from((is_manual_capture, response.result_code, pmt));
let error = Some(types::ErrorResponse {
code: status.to_string(),
- message: response.refusal_reason.clone(),
- reason: Some(response.refusal_reason),
+ message: response
+ .refusal_reason
+ .clone()
+ .unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
+ reason: response.refusal_reason,
status_code,
attempt_status: None,
connector_transaction_id: response.psp_reference.clone(),
@@ -3579,7 +3583,10 @@ pub fn get_redirection_error_response(
mandate_reference: None,
connector_metadata: None,
network_txn_id: None,
- connector_response_reference_id: None,
+ connector_response_reference_id: response
+ .merchant_reference
+ .clone()
+ .or(response.psp_reference),
incremental_authorization_allowed: None,
charge_id: None,
};