mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 17:47:54 +08:00
fix(payment_attempt): consider merchant storage scheme when finding payment attempt by connector txn ID, payment ID, merchant ID (#291)
This commit is contained in:
@ -564,10 +564,24 @@ mod storage {
|
|||||||
async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(
|
async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(
|
||||||
&self,
|
&self,
|
||||||
connector_transaction_id: &str,
|
connector_transaction_id: &str,
|
||||||
_payment_id: &str,
|
payment_id: &str,
|
||||||
merchant_id: &str,
|
merchant_id: &str,
|
||||||
_storage_scheme: enums::MerchantStorageScheme,
|
storage_scheme: enums::MerchantStorageScheme,
|
||||||
) -> CustomResult<PaymentAttempt, errors::StorageError> {
|
) -> CustomResult<PaymentAttempt, errors::StorageError> {
|
||||||
|
match storage_scheme {
|
||||||
|
enums::MerchantStorageScheme::PostgresOnly => {
|
||||||
|
let conn = pg_connection(&self.master_pool).await;
|
||||||
|
PaymentAttempt::find_by_connector_transaction_id_payment_id_merchant_id(
|
||||||
|
&conn,
|
||||||
|
connector_transaction_id,
|
||||||
|
payment_id,
|
||||||
|
merchant_id,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(Into::into)
|
||||||
|
.into_report()
|
||||||
|
}
|
||||||
|
enums::MerchantStorageScheme::RedisKv => {
|
||||||
// We assume that PaymentAttempt <=> PaymentIntent is a one-to-one relation for now
|
// We assume that PaymentAttempt <=> PaymentIntent is a one-to-one relation for now
|
||||||
let lookup_id = format!("{merchant_id}_{connector_transaction_id}");
|
let lookup_id = format!("{merchant_id}_{connector_transaction_id}");
|
||||||
let lookup = self
|
let lookup = self
|
||||||
@ -585,6 +599,8 @@ mod storage {
|
|||||||
.await
|
.await
|
||||||
.map_err(|error| error.to_redis_failed_response(key))
|
.map_err(|error| error.to_redis_failed_response(key))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(
|
async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
Reference in New Issue
Block a user