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(update_trackers): handle preprocessing steps status update (#1496)
Narayan Bhatb45231468db1
diff --git a/crates/router/src/connector/trustpay/transformers.rs b/crates/router/src/connector/trustpay/transformers.rsindex e93c0358b8..ffb84059f1 100644--- a/crates/router/src/connector/trustpay/transformers.rs+++ b/crates/router/src/connector/trustpay/transformers.rs@@ -950,6 +950,7 @@ impl<F, T>},))),}),+ status: storage_models::enums::AttemptStatus::Pending,..item.data})}diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 90fbf07640..4c4c904958 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -553,13 +553,15 @@ wherepayment_data.sessions_token.push(session_token);};- let connector_request = if should_continue_further {+ // In case of authorize flow, pre-task and post-tasks are being called in build request+ // if we do not want to proceed further, then the function will return Ok(None, false)+ let (connector_request, should_continue_further) = if should_continue_further {// Check if the actual flow specific request can be built with available datarouter_data.build_flow_specific_connector_request(state, &connector, call_connector_action.clone()).await?} else {- None+ (None, false)};// Update the payment trackers just before calling the connector@@ -576,11 +578,12 @@ where).await?;- // The status of payment_attempt and intent will be updated in the previous step- // This field will be used by the connector- router_data.status = payment_data.payment_attempt.status;-let router_data_res = if should_continue_further {+ // The status of payment_attempt and intent will be updated in the previous step+ // update this in router_data.+ // This is added because few connector integrations do not update the status,+ // and rely on previous status set in router_data+ router_data.status = payment_data.payment_attempt.status;router_data.decide_flows(state,diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rsindex e128bcb895..39110a0805 100644--- a/crates/router/src/core/payments/flows.rs+++ b/crates/router/src/core/payments/flows.rs@@ -97,13 +97,14 @@ pub trait Feature<F, T> {Ok(None)}+ /// Returns the connector request and a bool which specifies whether to proceed with furtherasync fn build_flow_specific_connector_request(&mut self,_state: &AppState,_connector: &api::ConnectorData,_call_connector_action: payments::CallConnectorAction,- ) -> RouterResult<Option<services::Request>> {- Ok(None)+ ) -> RouterResult<(Option<services::Request>, bool)> {+ Ok((None, true))}}diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rsindex 36d40d7480..9d530a0a03 100644--- a/crates/router/src/core/payments/flows/authorize_flow.rs+++ b/crates/router/src/core/payments/flows/authorize_flow.rs@@ -146,7 +146,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAustate: &AppState,connector: &api::ConnectorData,call_connector_action: payments::CallConnectorAction,- ) -> RouterResult<Option<services::Request>> {+ ) -> RouterResult<(Option<services::Request>, bool)> {match call_connector_action {payments::CallConnectorAction::Trigger => {let connector_integration: services::BoxedConnectorIntegration<@@ -179,14 +179,17 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAuself.decide_authentication_type();logger::debug!(auth_type=?self.auth_type);- connector_integration- .build_request(self, &state.conf.connectors)- .to_payment_failed_response()+ Ok((+ connector_integration+ .build_request(self, &state.conf.connectors)+ .to_payment_failed_response()?,+ true,+ ))} else {- Ok(None)+ Ok((None, false))}}- _ => Ok(None),+ _ => Ok((None, true)),}}}diff --git a/crates/router/src/core/payments/flows/cancel_flow.rs b/crates/router/src/core/payments/flows/cancel_flow.rsindex 06c8c88f0f..6c590a9cf9 100644--- a/crates/router/src/core/payments/flows/cancel_flow.rs+++ b/crates/router/src/core/payments/flows/cancel_flow.rs@@ -89,8 +89,8 @@ impl Feature<api::Void, types::PaymentsCancelData>state: &AppState,connector: &api::ConnectorData,call_connector_action: payments::CallConnectorAction,- ) -> RouterResult<Option<services::Request>> {- match call_connector_action {+ ) -> RouterResult<(Option<services::Request>, bool)> {+ let request = match call_connector_action {payments::CallConnectorAction::Trigger => {let connector_integration: services::BoxedConnectorIntegration<'_,@@ -101,9 +101,11 @@ impl Feature<api::Void, types::PaymentsCancelData>connector_integration.build_request(self, &state.conf.connectors)- .to_payment_failed_response()+ .to_payment_failed_response()?}- _ => Ok(None),- }+ _ => None,+ };++ Ok((request, true))}}diff --git a/crates/router/src/core/payments/flows/capture_flow.rs b/crates/router/src/core/payments/flows/capture_flow.rsindex 937c3daec6..3c509d7df6 100644--- a/crates/router/src/core/payments/flows/capture_flow.rs+++ b/crates/router/src/core/payments/flows/capture_flow.rs@@ -81,8 +81,8 @@ impl Feature<api::Capture, types::PaymentsCaptureData>state: &AppState,connector: &api::ConnectorData,call_connector_action: payments::CallConnectorAction,- ) -> RouterResult<Option<services::Request>> {- match call_connector_action {+ ) -> RouterResult<(Option<services::Request>, bool)> {+ let request = match call_connector_action {payments::CallConnectorAction::Trigger => {let connector_integration: services::BoxedConnectorIntegration<'_,@@ -93,9 +93,11 @@ impl Feature<api::Capture, types::PaymentsCaptureData>connector_integration.build_request(self, &state.conf.connectors)- .to_payment_failed_response()+ .to_payment_failed_response()?}- _ => Ok(None),- }+ _ => None,+ };++ Ok((request, true))}}diff --git a/crates/router/src/core/payments/flows/complete_authorize_flow.rs b/crates/router/src/core/payments/flows/complete_authorize_flow.rsindex 6e2646f537..f78305de02 100644--- a/crates/router/src/core/payments/flows/complete_authorize_flow.rs+++ b/crates/router/src/core/payments/flows/complete_authorize_flow.rs@@ -97,8 +97,8 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>state: &AppState,connector: &api::ConnectorData,call_connector_action: payments::CallConnectorAction,- ) -> RouterResult<Option<services::Request>> {- match call_connector_action {+ ) -> RouterResult<(Option<services::Request>, bool)> {+ let request = match call_connector_action {payments::CallConnectorAction::Trigger => {let connector_integration: services::BoxedConnectorIntegration<'_,@@ -109,9 +109,11 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>connector_integration.build_request(self, &state.conf.connectors)- .to_payment_failed_response()+ .to_payment_failed_response()?}- _ => Ok(None),- }+ _ => None,+ };++ Ok((request, true))}}diff --git a/crates/router/src/core/payments/flows/psync_flow.rs b/crates/router/src/core/payments/flows/psync_flow.rsindex d4d593bd9b..4f1d877fea 100644--- a/crates/router/src/core/payments/flows/psync_flow.rs+++ b/crates/router/src/core/payments/flows/psync_flow.rs@@ -81,8 +81,8 @@ impl Feature<api::PSync, types::PaymentsSyncData>state: &AppState,connector: &api::ConnectorData,call_connector_action: payments::CallConnectorAction,- ) -> RouterResult<Option<services::Request>> {- match call_connector_action {+ ) -> RouterResult<(Option<services::Request>, bool)> {+ let request = match call_connector_action {payments::CallConnectorAction::Trigger => {let connector_integration: services::BoxedConnectorIntegration<'_,@@ -93,9 +93,11 @@ impl Feature<api::PSync, types::PaymentsSyncData>connector_integration.build_request(self, &state.conf.connectors)- .to_payment_failed_response()+ .to_payment_failed_response()?}- _ => Ok(None),- }+ _ => None,+ };++ Ok((request, true))}}diff --git a/crates/router/src/core/payments/flows/verify_flow.rs b/crates/router/src/core/payments/flows/verify_flow.rsindex a70e4419b3..bd30f1e786 100644--- a/crates/router/src/core/payments/flows/verify_flow.rs+++ b/crates/router/src/core/payments/flows/verify_flow.rs@@ -118,7 +118,7 @@ impl Feature<api::Verify, types::VerifyRequestData> for types::VerifyRouterDatastate: &AppState,connector: &api::ConnectorData,call_connector_action: payments::CallConnectorAction,- ) -> RouterResult<Option<services::Request>> {+ ) -> RouterResult<(Option<services::Request>, bool)> {match call_connector_action {payments::CallConnectorAction::Trigger => {let connector_integration: services::BoxedConnectorIntegration<@@ -128,11 +128,14 @@ impl Feature<api::Verify, types::VerifyRequestData> for types::VerifyRouterDatatypes::PaymentsResponseData,> = connector.connector.get_connector_integration();- connector_integration- .build_request(self, &state.conf.connectors)- .to_payment_failed_response()+ Ok((+ connector_integration+ .build_request(self, &state.conf.connectors)+ .to_payment_failed_response()?,+ true,+ ))}- _ => Ok(None),+ _ => Ok((None, true)),}}}