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:
Sanchith Hegde
2023-01-05 17:31:08 +05:30
committed by GitHub
parent 3c1406787e
commit 3174c43b24

View File

@ -564,10 +564,24 @@ mod storage {
async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(
&self,
connector_transaction_id: &str,
_payment_id: &str,
payment_id: &str,
merchant_id: &str,
_storage_scheme: enums::MerchantStorageScheme,
storage_scheme: enums::MerchantStorageScheme,
) -> 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
let lookup_id = format!("{merchant_id}_{connector_transaction_id}");
let lookup = self
@ -585,6 +599,8 @@ mod storage {
.await
.map_err(|error| error.to_redis_failed_response(key))
}
}
}
async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(
&self,