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(core): update trackers for preprocessing steps (#1481)

Narayan Bhat8fffc161ea90
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index ebac8bb0d2..cfad9583b5 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -551,26 +551,34 @@ where
payment_data.sessions_token.push(session_token);
};
- let router_data_res = if should_continue_further {
+ let connector_request = if should_continue_further {
// Check if the actual flow specific request can be built with available data
- let request = router_data
+ router_data
.build_flow_specific_connector_request(state, &connector, call_connector_action.clone())
- .await?;
+ .await?
+ } else {
+ None
+ };
- // Update the payment trackers just before calling the connector
- // Since the request is already built in the previous step,
- // there should be no error in request construction from hyperswitch end
- operation
- .to_update_tracker()?
- .update_trackers(
- &*state.store,
- payment_data.clone(),
- customer.clone(),
- merchant_account.storage_scheme,
- updated_customer,
- )
- .await?;
+ // Update the payment trackers just before calling the connector
+ // Since the request is already built in the previous step,
+ // there should be no error in request construction from hyperswitch end
+ (_, *payment_data) = operation
+ .to_update_tracker()?
+ .update_trackers(
+ &*state.store,
+ payment_data.clone(),
+ customer.clone(),
+ merchant_account.storage_scheme,
+ updated_customer,
+ )
+ .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 {
router_data
.decide_flows(
state,
@@ -578,7 +586,7 @@ where
customer,
call_connector_action,
merchant_account,
- request,
+ connector_request,
)
.await
} else {