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): [NMI] Added enum for Void Reason (#7221)
Debarshi Gupta90321653ba5e
diff --git a/crates/router/src/connector/nmi/transformers.rs b/crates/router/src/connector/nmi/transformers.rsindex 1e8b745107..d6f1cb1962 100644--- a/crates/router/src/connector/nmi/transformers.rs+++ b/crates/router/src/connector/nmi/transformers.rs@@ -783,19 +783,43 @@ pub struct NmiCancelRequest {pub transaction_type: TransactionType,pub security_key: Secret<String>,pub transactionid: String,- pub void_reason: Option<String>,+ pub void_reason: NmiVoidReason,+}++#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]+#[serde(rename_all = "snake_case")]+pub enum NmiVoidReason {+ Fraud,+ UserCancel,+ IccRejected,+ IccCardRemoved,+ IccNoConfirmation,+ PosTimeout,}impl TryFrom<&types::PaymentsCancelRouterData> for NmiCancelRequest {type Error = Error;fn try_from(item: &types::PaymentsCancelRouterData) -> Result<Self, Self::Error> {let auth = NmiAuthType::try_from(&item.connector_auth_type)?;- Ok(Self {- transaction_type: TransactionType::Void,- security_key: auth.api_key,- transactionid: item.request.connector_transaction_id.clone(),- void_reason: item.request.cancellation_reason.clone(),- })+ match &item.request.cancellation_reason {+ Some(cancellation_reason) => {+ let void_reason: NmiVoidReason = serde_json::from_str(&format!("\"{}\"", cancellation_reason))+ .map_err(|_| errors::ConnectorError::NotSupported {+ message: format!("Json deserialise error: unknown variant `{}` expected to be one of `fraud`, `user_cancel`, `icc_rejected`, `icc_card_removed`, `icc_no_confirmation`, `pos_timeout`. This cancellation_reason", cancellation_reason),+ connector: "nmi"+ })?;+ Ok(Self {+ transaction_type: TransactionType::Void,+ security_key: auth.api_key,+ transactionid: item.request.connector_transaction_id.clone(),+ void_reason,+ })+ }+ None => Err(errors::ConnectorError::MissingRequiredField {+ field_name: "cancellation_reason",+ }+ .into()),+ }}}