mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
fix(update_trackers): handle preprocessing steps status update (#1496)
Co-authored-by: Sangamesh <sangamesh.kulkarni@juspay.in>
This commit is contained in:
@ -950,6 +950,7 @@ impl<F, T>
|
|||||||
},
|
},
|
||||||
))),
|
))),
|
||||||
}),
|
}),
|
||||||
|
status: storage_models::enums::AttemptStatus::Pending,
|
||||||
..item.data
|
..item.data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -553,13 +553,15 @@ where
|
|||||||
payment_data.sessions_token.push(session_token);
|
payment_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 data
|
// Check if the actual flow specific request can be built with available data
|
||||||
router_data
|
router_data
|
||||||
.build_flow_specific_connector_request(state, &connector, call_connector_action.clone())
|
.build_flow_specific_connector_request(state, &connector, call_connector_action.clone())
|
||||||
.await?
|
.await?
|
||||||
} else {
|
} else {
|
||||||
None
|
(None, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update the payment trackers just before calling the connector
|
// Update the payment trackers just before calling the connector
|
||||||
@ -576,11 +578,12 @@ where
|
|||||||
)
|
)
|
||||||
.await?;
|
.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 {
|
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
|
router_data
|
||||||
.decide_flows(
|
.decide_flows(
|
||||||
state,
|
state,
|
||||||
|
|||||||
@ -97,13 +97,14 @@ pub trait Feature<F, T> {
|
|||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the connector request and a bool which specifies whether to proceed with further
|
||||||
async fn build_flow_specific_connector_request(
|
async fn build_flow_specific_connector_request(
|
||||||
&mut self,
|
&mut self,
|
||||||
_state: &AppState,
|
_state: &AppState,
|
||||||
_connector: &api::ConnectorData,
|
_connector: &api::ConnectorData,
|
||||||
_call_connector_action: payments::CallConnectorAction,
|
_call_connector_action: payments::CallConnectorAction,
|
||||||
) -> RouterResult<Option<services::Request>> {
|
) -> RouterResult<(Option<services::Request>, bool)> {
|
||||||
Ok(None)
|
Ok((None, true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -146,7 +146,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
|
|||||||
state: &AppState,
|
state: &AppState,
|
||||||
connector: &api::ConnectorData,
|
connector: &api::ConnectorData,
|
||||||
call_connector_action: payments::CallConnectorAction,
|
call_connector_action: payments::CallConnectorAction,
|
||||||
) -> RouterResult<Option<services::Request>> {
|
) -> RouterResult<(Option<services::Request>, bool)> {
|
||||||
match call_connector_action {
|
match call_connector_action {
|
||||||
payments::CallConnectorAction::Trigger => {
|
payments::CallConnectorAction::Trigger => {
|
||||||
let connector_integration: services::BoxedConnectorIntegration<
|
let connector_integration: services::BoxedConnectorIntegration<
|
||||||
@ -179,14 +179,17 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
|
|||||||
self.decide_authentication_type();
|
self.decide_authentication_type();
|
||||||
logger::debug!(auth_type=?self.auth_type);
|
logger::debug!(auth_type=?self.auth_type);
|
||||||
|
|
||||||
connector_integration
|
Ok((
|
||||||
.build_request(self, &state.conf.connectors)
|
connector_integration
|
||||||
.to_payment_failed_response()
|
.build_request(self, &state.conf.connectors)
|
||||||
|
.to_payment_failed_response()?,
|
||||||
|
true,
|
||||||
|
))
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok((None, false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => Ok(None),
|
_ => Ok((None, true)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,8 +89,8 @@ impl Feature<api::Void, types::PaymentsCancelData>
|
|||||||
state: &AppState,
|
state: &AppState,
|
||||||
connector: &api::ConnectorData,
|
connector: &api::ConnectorData,
|
||||||
call_connector_action: payments::CallConnectorAction,
|
call_connector_action: payments::CallConnectorAction,
|
||||||
) -> RouterResult<Option<services::Request>> {
|
) -> RouterResult<(Option<services::Request>, bool)> {
|
||||||
match call_connector_action {
|
let request = match call_connector_action {
|
||||||
payments::CallConnectorAction::Trigger => {
|
payments::CallConnectorAction::Trigger => {
|
||||||
let connector_integration: services::BoxedConnectorIntegration<
|
let connector_integration: services::BoxedConnectorIntegration<
|
||||||
'_,
|
'_,
|
||||||
@ -101,9 +101,11 @@ impl Feature<api::Void, types::PaymentsCancelData>
|
|||||||
|
|
||||||
connector_integration
|
connector_integration
|
||||||
.build_request(self, &state.conf.connectors)
|
.build_request(self, &state.conf.connectors)
|
||||||
.to_payment_failed_response()
|
.to_payment_failed_response()?
|
||||||
}
|
}
|
||||||
_ => Ok(None),
|
_ => None,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
Ok((request, true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,8 +81,8 @@ impl Feature<api::Capture, types::PaymentsCaptureData>
|
|||||||
state: &AppState,
|
state: &AppState,
|
||||||
connector: &api::ConnectorData,
|
connector: &api::ConnectorData,
|
||||||
call_connector_action: payments::CallConnectorAction,
|
call_connector_action: payments::CallConnectorAction,
|
||||||
) -> RouterResult<Option<services::Request>> {
|
) -> RouterResult<(Option<services::Request>, bool)> {
|
||||||
match call_connector_action {
|
let request = match call_connector_action {
|
||||||
payments::CallConnectorAction::Trigger => {
|
payments::CallConnectorAction::Trigger => {
|
||||||
let connector_integration: services::BoxedConnectorIntegration<
|
let connector_integration: services::BoxedConnectorIntegration<
|
||||||
'_,
|
'_,
|
||||||
@ -93,9 +93,11 @@ impl Feature<api::Capture, types::PaymentsCaptureData>
|
|||||||
|
|
||||||
connector_integration
|
connector_integration
|
||||||
.build_request(self, &state.conf.connectors)
|
.build_request(self, &state.conf.connectors)
|
||||||
.to_payment_failed_response()
|
.to_payment_failed_response()?
|
||||||
}
|
}
|
||||||
_ => Ok(None),
|
_ => None,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
Ok((request, true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,8 +97,8 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
|
|||||||
state: &AppState,
|
state: &AppState,
|
||||||
connector: &api::ConnectorData,
|
connector: &api::ConnectorData,
|
||||||
call_connector_action: payments::CallConnectorAction,
|
call_connector_action: payments::CallConnectorAction,
|
||||||
) -> RouterResult<Option<services::Request>> {
|
) -> RouterResult<(Option<services::Request>, bool)> {
|
||||||
match call_connector_action {
|
let request = match call_connector_action {
|
||||||
payments::CallConnectorAction::Trigger => {
|
payments::CallConnectorAction::Trigger => {
|
||||||
let connector_integration: services::BoxedConnectorIntegration<
|
let connector_integration: services::BoxedConnectorIntegration<
|
||||||
'_,
|
'_,
|
||||||
@ -109,9 +109,11 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
|
|||||||
|
|
||||||
connector_integration
|
connector_integration
|
||||||
.build_request(self, &state.conf.connectors)
|
.build_request(self, &state.conf.connectors)
|
||||||
.to_payment_failed_response()
|
.to_payment_failed_response()?
|
||||||
}
|
}
|
||||||
_ => Ok(None),
|
_ => None,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
Ok((request, true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,8 +81,8 @@ impl Feature<api::PSync, types::PaymentsSyncData>
|
|||||||
state: &AppState,
|
state: &AppState,
|
||||||
connector: &api::ConnectorData,
|
connector: &api::ConnectorData,
|
||||||
call_connector_action: payments::CallConnectorAction,
|
call_connector_action: payments::CallConnectorAction,
|
||||||
) -> RouterResult<Option<services::Request>> {
|
) -> RouterResult<(Option<services::Request>, bool)> {
|
||||||
match call_connector_action {
|
let request = match call_connector_action {
|
||||||
payments::CallConnectorAction::Trigger => {
|
payments::CallConnectorAction::Trigger => {
|
||||||
let connector_integration: services::BoxedConnectorIntegration<
|
let connector_integration: services::BoxedConnectorIntegration<
|
||||||
'_,
|
'_,
|
||||||
@ -93,9 +93,11 @@ impl Feature<api::PSync, types::PaymentsSyncData>
|
|||||||
|
|
||||||
connector_integration
|
connector_integration
|
||||||
.build_request(self, &state.conf.connectors)
|
.build_request(self, &state.conf.connectors)
|
||||||
.to_payment_failed_response()
|
.to_payment_failed_response()?
|
||||||
}
|
}
|
||||||
_ => Ok(None),
|
_ => None,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
Ok((request, true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,7 +118,7 @@ impl Feature<api::Verify, types::VerifyRequestData> for types::VerifyRouterData
|
|||||||
state: &AppState,
|
state: &AppState,
|
||||||
connector: &api::ConnectorData,
|
connector: &api::ConnectorData,
|
||||||
call_connector_action: payments::CallConnectorAction,
|
call_connector_action: payments::CallConnectorAction,
|
||||||
) -> RouterResult<Option<services::Request>> {
|
) -> RouterResult<(Option<services::Request>, bool)> {
|
||||||
match call_connector_action {
|
match call_connector_action {
|
||||||
payments::CallConnectorAction::Trigger => {
|
payments::CallConnectorAction::Trigger => {
|
||||||
let connector_integration: services::BoxedConnectorIntegration<
|
let connector_integration: services::BoxedConnectorIntegration<
|
||||||
@ -128,11 +128,14 @@ impl Feature<api::Verify, types::VerifyRequestData> for types::VerifyRouterData
|
|||||||
types::PaymentsResponseData,
|
types::PaymentsResponseData,
|
||||||
> = connector.connector.get_connector_integration();
|
> = connector.connector.get_connector_integration();
|
||||||
|
|
||||||
connector_integration
|
Ok((
|
||||||
.build_request(self, &state.conf.connectors)
|
connector_integration
|
||||||
.to_payment_failed_response()
|
.build_request(self, &state.conf.connectors)
|
||||||
|
.to_payment_failed_response()?,
|
||||||
|
true,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
_ => Ok(None),
|
_ => Ok((None, true)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user