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

chore(payment_attempt): drop preprocessing_step_id_index (#14415)

Hrithikesh1d71d94d2e2e
diff --git a/crates/diesel_models/src/query/payment_attempt.rs b/crates/diesel_models/src/query/payment_attempt.rs
index eb6c736bfd..e3f2ea595f 100644
--- a/crates/diesel_models/src/query/payment_attempt.rs
+++ b/crates/diesel_models/src/query/payment_attempt.rs
@@ -291,21 +291,6 @@ impl PaymentAttempt {
.await
}
- #[cfg(feature = "v1")]
- pub async fn find_by_processor_merchant_id_preprocessing_id(
- conn: &DatabaseConnectionWithContext<'_>,
- processor_merchant_id: &common_utils::id_type::MerchantId,
- preprocessing_id: &str,
- ) -> StorageResult<Self> {
- generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
- conn,
- dsl::processor_merchant_id
- .eq(processor_merchant_id.to_owned())
- .and(dsl::preprocessing_step_id.eq(preprocessing_id.to_owned())),
- )
- .await
- }
-
#[cfg(feature = "v1")]
pub async fn find_by_payment_id_processor_merchant_id_attempt_id(
conn: &DatabaseConnectionWithContext<'_>,
diff --git a/crates/hyperswitch_connectors/src/connectors/stripe.rs b/crates/hyperswitch_connectors/src/connectors/stripe.rs
index b3bafaa863..43462ac468 100644
--- a/crates/hyperswitch_connectors/src/connectors/stripe.rs
+++ b/crates/hyperswitch_connectors/src/connectors/stripe.rs
@@ -2869,11 +2869,7 @@ impl IncomingWebhook for Stripe {
))
}
stripe::WebhookEventObjectType::Source => {
- Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
- api_models::payments::PaymentIdType::PreprocessingId(
- details.event_data.event_object.id,
- ),
- ))
+ Err(ConnectorError::WebhookReferenceIdNotFound)?
}
stripe::WebhookEventObjectType::Refund => {
match details
diff --git a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs
index aecb2b621d..0bfb622a09 100644
--- a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs
@@ -631,34 +631,6 @@ pub struct SepaBankTransferData {
pub country: enums::CountryAlpha2,
}
-#[derive(Debug, Eq, PartialEq, Serialize)]
-#[serde(untagged)]
-pub enum StripeCreditTransferSourceRequest {
- AchBankTansfer(AchCreditTransferSourceRequest),
- MultibancoBankTansfer(MultibancoCreditTransferSourceRequest),
-}
-
-#[derive(Debug, Eq, PartialEq, Serialize)]
-pub struct AchCreditTransferSourceRequest {
- #[serde(rename = "type")]
- pub transfer_type: StripeCreditTransferTypes,
- #[serde(flatten)]
- pub payment_method_data: AchTransferData,
- pub currency: enums::Currency,
-}
-
-#[derive(Debug, Eq, PartialEq, Serialize)]
-pub struct MultibancoCreditTransferSourceRequest {
- #[serde(rename = "type")]
- pub transfer_type: StripeCreditTransferTypes,
- #[serde(flatten)]
- pub payment_method_data: MultibancoTransferData,
- pub currency: enums::Currency,
- pub amount: Option<MinorUnit>,
- #[serde(rename = "redirect[return_url]")]
- pub return_url: Option<String>,
-}
-
// Remove untagged when Deserialize is added
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(untagged)]
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
index cc3327dcb3..ad00f24e93 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
@@ -178,15 +178,6 @@ pub trait PaymentAttemptInterface {
storage_scheme: common_enums::MerchantStorageScheme,
) -> error_stack::Result<Vec<PaymentAttempt>, Self::Error>;
- #[cfg(feature = "v1")]
- async fn find_payment_attempt_by_preprocessing_id_processor_merchant_id(
- &self,
- preprocessing_id: &str,
- processor_merchant_id: &id_type::MerchantId,
- storage_scheme: storage_enums::MerchantStorageScheme,
- merchant_key_store: &MerchantKeyStore,
- ) -> error_stack::Result<PaymentAttempt, Self::Error>;
-
#[cfg(feature = "v1")]
async fn find_attempts_by_processor_merchant_id_payment_id(
&self,
diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs
index d9ed682011..77963eed72 100644
--- a/crates/router/src/core/payments/operations/payment_status.rs
+++ b/crates/router/src/core/payments/operations/payment_status.rs
@@ -718,24 +718,11 @@ pub async fn get_payment_intent_payment_attempt(
)
.await?;
}
- api_models::payments::PaymentIdType::PreprocessingId(ref id) => {
- pa = db
- .find_payment_attempt_by_preprocessing_id_processor_merchant_id(
- id,
- processor_merchant_id,
- storage_scheme,
- key_store,
- )
- .await?;
-
- pi = db
- .find_payment_intent_by_payment_id_processor_merchant_id(
- &pa.payment_id,
- processor_merchant_id,
- key_store,
- storage_scheme,
- )
- .await?;
+ api_models::payments::PaymentIdType::PreprocessingId(_) => {
+ return Err(errors::StorageError::ValueNotFound(
+ "no payment found for the given preprocessing_id".to_string(),
+ )
+ .into());
}
}
error_stack::Result::<_, errors::StorageError>::Ok((pi, pa))
diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rs
index 7cb38ad593..e9d2c4d1e3 100644
--- a/crates/router/src/core/webhooks/incoming.rs
+++ b/crates/router/src/core/webhooks/incoming.rs
@@ -1796,15 +1796,9 @@ pub async fn get_payment_attempt_from_object_reference_id(
)
.await
.to_not_found_response(errors::ApiErrorResponse::WebhookResourceNotFound),
- api::ObjectReferenceId::PaymentId(api::PaymentIdType::PreprocessingId(ref id)) => db
- .find_payment_attempt_by_preprocessing_id_processor_merchant_id(
- id,
- processor.get_account().get_id(),
- processor.get_account().storage_scheme,
- processor.get_key_store(),
- )
- .await
- .to_not_found_response(errors::ApiErrorResponse::WebhookResourceNotFound),
+ api::ObjectReferenceId::PaymentId(api::PaymentIdType::PreprocessingId(_)) => {
+ Err(errors::ApiErrorResponse::WebhookResourceNotFound)?
+ }
_ => Err(errors::ApiErrorResponse::WebhookProcessingFailure)
.attach_printable("received a non-payment id for retrieving payment")?,
}
diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rs
index 5bf1454809..8d91856b10 100644
--- a/crates/router/src/db/kafka_store.rs
+++ b/crates/router/src/db/kafka_store.rs
@@ -2003,24 +2003,6 @@ impl PaymentAttemptInterface for KafkaStore {
.await
}
- #[cfg(feature = "v1")]
- async fn find_payment_attempt_by_preprocessing_id_processor_merchant_id(
- &self,
- preprocessing_id: &str,
- processor_merchant_id: &id_type::MerchantId,
- storage_scheme: MerchantStorageScheme,
- key_store: &domain::MerchantKeyStore,
- ) -> CustomResult<storage::PaymentAttempt, errors::StorageError> {
- self.diesel_store
- .find_payment_attempt_by_preprocessing_id_processor_merchant_id(
- preprocessing_id,
- processor_merchant_id,
- storage_scheme,
- key_store,
- )
- .await
- }
-
#[cfg(feature = "v1")]
async fn get_filters_for_payments(
&self,
diff --git a/crates/storage_impl/src/mock_db/payment_attempt.rs b/crates/storage_impl/src/mock_db/payment_attempt.rs
index 6c4797a9db..b4debf9601 100644
--- a/crates/storage_impl/src/mock_db/payment_attempt.rs
+++ b/crates/storage_impl/src/mock_db/payment_attempt.rs
@@ -109,18 +109,6 @@ impl PaymentAttemptInterface for MockDb {
Err(StorageError::MockDbError)?
}
- #[cfg(feature = "v1")]
- async fn find_payment_attempt_by_preprocessing_id_processor_merchant_id(
- &self,
- _preprocessing_id: &str,
- _processor_merchant_id: &common_utils::id_type::MerchantId,
- _storage_scheme: storage_enums::MerchantStorageScheme,
- _merchant_key_store: &MerchantKeyStore,
- ) -> CustomResult<PaymentAttempt, StorageError> {
- // [#172]: Implement function for `MockDb`
- Err(StorageError::MockDbError)?
- }
-
#[cfg(feature = "v1")]
async fn find_payment_attempt_by_processor_merchant_id_connector_txn_id(
&self,
diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rs
index 809eb700da..dd391c8d7c 100644
--- a/crates/storage_impl/src/payments/payment_attempt.rs
+++ b/crates/storage_impl/src/payments/payment_attempt.rs
@@ -443,43 +443,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
)
}
- #[cfg(feature = "v1")]
- #[instrument(skip_all)]
- async fn find_payment_attempt_by_preprocessing_id_processor_merchant_id(
- &self,
- preprocessing_id: &str,
- processor_merchant_id: &common_utils::id_type::MerchantId,
- _storage_scheme: MerchantStorageScheme,
- merchant_key_store: &MerchantKeyStore,
- ) -> CustomResult<PaymentAttempt, errors::StorageError> {
- let conn = pg_connection_read(self).await?;
- let key_manager_state = self
- .get_keymanager_state()
- .attach_printable("Missing KeyManagerState")?;
-
- DieselPaymentAttempt::find_by_processor_merchant_id_preprocessing_id(
- &conn,
- processor_merchant_id,
- preprocessing_id,
- )
- .await
- .map_err(|er| {
- let new_err = diesel_error_to_data_error(*er.current_context());
- er.change_context(new_err)
- })
- .async_map(|diesel_payment_attempt| async {
- PaymentAttempt::convert_back(
- key_manager_state,
- diesel_payment_attempt,
- merchant_key_store.key.get_inner(),
- merchant_key_store.merchant_id.clone().into(),
- )
- .await
- .change_context(errors::StorageError::DecryptionError)
- })
- .await?
- }
-
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn find_attempts_by_processor_merchant_id_payment_id(
@@ -1728,91 +1691,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
.await
}
- #[cfg(feature = "v1")]
- #[instrument(skip_all)]
- async fn find_payment_attempt_by_preprocessing_id_processor_merchant_id(
- &self,
- preprocessing_id: &str,
- processor_merchant_id: &common_utils::id_type::MerchantId,
- storage_scheme: MerchantStorageScheme,
- merchant_key_store: &MerchantKeyStore,
- ) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
- let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
- self,
- storage_scheme,
- Op::Find,
- ))
- .await;
- match storage_scheme {
- MerchantStorageScheme::PostgresOnly => {
- self.router_store
- .find_payment_attempt_by_preprocessing_id_processor_merchant_id(
- preprocessing_id,
- processor_merchant_id,
- storage_scheme,
- merchant_key_store,
- )
- .await
- }
- MerchantStorageScheme::RedisKv => {
- let lookup_id = format!(
- "pa_preprocessing_{}_{preprocessing_id}",
- processor_merchant_id.get_string_repr()
- );
- let lookup = fallback_reverse_lookup_not_found!(
- self.get_lookup_by_lookup_id(&lookup_id, storage_scheme)
- .await,
- self.router_store
- .find_payment_attempt_by_preprocessing_id_processor_merchant_id(
- preprocessing_id,
- processor_merchant_id,
- storage_scheme,
- merchant_key_store,
- )
- .await
- );
- let key = PartitionKey::CombinationKey {
- combination: &lookup.pk_id,
- };
- let key_manager_state = self
- .get_keymanager_state()
- .attach_printable("Missing KeyManagerState")?;
-
- Box::pin(try_redis_get_else_try_database_get(
- async {
- let diesel_payment_attempt = Box::pin(kv_wrapper(
- self,
- KvOperation::<DieselPaymentAttempt>::HGet(&lookup.sk_id),
- key,
- ))
- .await?
- .try_into_hget()?;
- PaymentAttempt::convert_back(
- key_manager_state,
- diesel_payment_attempt,
- merchant_key_store.key.get_inner(),
- processor_merchant_id.clone().into(),
- )
- .await
- .change_context(redis_interface::errors::RedisError::UnknownResult)
- .attach_printable("Error while constructing domain model")
- },
- || async {
- self.router_store
- .find_payment_attempt_by_preprocessing_id_processor_merchant_id(
- preprocessing_id,
- processor_merchant_id,
- storage_scheme,
- merchant_key_store,
- )
- .await
- },
- ))
- .await
- }
- }
- }
-
#[cfg(feature = "v1")]
#[instrument(skip_all)]
async fn find_attempts_by_processor_merchant_id_payment_id(
diff --git a/migrations/2026-09-24-073107_drop_preprocessing_step_id_index/down.sql b/migrations/2026-09-24-073107_drop_preprocessing_step_id_index/down.sql
new file mode 100644
index 0000000000..c499022b7d
--- /dev/null
+++ b/migrations/2026-09-24-073107_drop_preprocessing_step_id_index/down.sql
@@ -0,0 +1,2 @@
+-- This file should undo anything in `up.sql`
+CREATE INDEX preprocessing_step_id_index ON payment_attempt (preprocessing_step_id);
diff --git a/migrations/2026-09-24-073107_drop_preprocessing_step_id_index/up.sql b/migrations/2026-09-24-073107_drop_preprocessing_step_id_index/up.sql
new file mode 100644
index 0000000000..3d8998eeb4
--- /dev/null
+++ b/migrations/2026-09-24-073107_drop_preprocessing_step_id_index/up.sql
@@ -0,0 +1,4 @@
+-- Your SQL goes here
+-- No query in the codebase filters payment_attempt by preprocessing_step_id anymore
+-- (see find_by_processor_merchant_id_preprocessing_id, removed alongside this migration).
+DROP INDEX IF EXISTS preprocessing_step_id_index;