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(connector): Change Refund Reason Type in Adyen (#8849)
Anurag3547eac397fa
diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.tomlindex 90faf93dbf..1acf01279f 100644--- a/crates/connector_configs/toml/production.toml+++ b/crates/connector_configs/toml/production.toml@@ -114,6 +114,8 @@ payment_method_type = "apple_pay"payment_method_type = "google_pay"[[adyen.wallet]]payment_method_type = "paypal"+[[adyen.voucher]]+ payment_method_type = "boleto"[adyen.connector_auth.BodyKey]api_key = "Adyen API Key"key1 = "Adyen Account Id"diff --git a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rsindex df4ab2f497..c744cf5074 100644--- a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs@@ -1,3 +1,5 @@+use std::str::FromStr;+#[cfg(feature = "payouts")]use api_models::payouts::{self, PayoutMethodData};use api_models::{@@ -1390,12 +1392,37 @@ pub struct DokuBankData {pub struct AdyenRefundRequest {merchant_account: Secret<String>,amount: Amount,- merchant_refund_reason: Option<String>,+ merchant_refund_reason: Option<AdyenRefundRequestReason>,reference: String,splits: Option<Vec<AdyenSplitData>>,store: Option<String>,}+#[derive(Debug, Serialize, Deserialize)]+pub enum AdyenRefundRequestReason {+ FRAUD,+ #[serde(rename = "CUSTOMER REQUEST")]+ CUSTOMERREQUEST,+ RETURN,+ DUPLICATE,+ OTHER,+}++impl FromStr for AdyenRefundRequestReason {+ type Err = error_stack::Report<errors::ConnectorError>;++ fn from_str(s: &str) -> Result<Self, Self::Err> {+ match s.to_uppercase().as_str() {+ "FRAUD" => Ok(Self::FRAUD),+ "CUSTOMER REQUEST" => Ok(Self::CUSTOMERREQUEST),+ "RETURN" => Ok(Self::RETURN),+ "DUPLICATE" => Ok(Self::DUPLICATE),+ "OTHER" => Ok(Self::OTHER),+ _ => Ok(Self::OTHER),+ }+ }+}+#[derive(Default, Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct AdyenRefundResponse {@@ -4709,7 +4736,13 @@ impl<F> TryFrom<&AdyenRouterData<&RefundsRouterData<F>>> for AdyenRefundRequestcurrency: item.router_data.request.currency,value: item.amount,},- merchant_refund_reason: item.router_data.request.reason.clone(),+ merchant_refund_reason: item+ .router_data+ .request+ .reason+ .as_ref()+ .map(|reason| AdyenRefundRequestReason::from_str(reason))+ .transpose()?,reference: item.router_data.request.refund_id.clone(),store,splits,