fix(webhooks): fix database queries in webhook (#2139)

This commit is contained in:
Narayan Bhat
2023-09-12 20:12:42 +05:30
committed by GitHub
parent 341163b481
commit eff280f2fb
3 changed files with 18 additions and 11 deletions

View File

@ -103,7 +103,7 @@ pub trait IncomingWebhook: ConnectorCommon + Sync {
let merchant_connector_account_result = db let merchant_connector_account_result = db
.find_merchant_connector_account_by_profile_id_connector_name( .find_merchant_connector_account_by_profile_id_connector_name(
&profile_id, &profile_id,
&merchant_account.merchant_id, connector_name,
key_store, key_store,
) )
.await; .await;

View File

@ -27,7 +27,10 @@ use uuid::Uuid;
pub use self::ext_traits::{OptionExt, ValidateCall}; pub use self::ext_traits::{OptionExt, ValidateCall};
use crate::{ use crate::{
consts, consts,
core::errors::{self, CustomResult, RouterResult, StorageErrorExt}, core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
utils,
},
db::StorageInterface, db::StorageInterface,
logger, logger,
routes::metrics, routes::metrics,
@ -305,14 +308,18 @@ pub async fn get_profile_id_using_object_reference_id(
.await? .await?
} }
}; };
let profile_id = payment_intent
.profile_id let profile_id = utils::get_profile_id_from_business_details(
.ok_or(errors::ApiErrorResponse::MissingRequiredField { payment_intent.business_country,
field_name: "business_profile", payment_intent.business_label.as_ref(),
}) merchant_account,
.into_report() payment_intent.profile_id.as_ref(),
.change_context(errors::ApiErrorResponse::InternalServerError) db,
.attach_printable("profile_id is not set in payment_intent")?; )
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("profile_id is not set in payment_intent")?;
Ok(profile_id) Ok(profile_id)
} }
} }

View File

@ -226,8 +226,8 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
async fn find_payment_attempt_by_attempt_id_merchant_id( async fn find_payment_attempt_by_attempt_id_merchant_id(
&self, &self,
merchant_id: &str,
attempt_id: &str, attempt_id: &str,
merchant_id: &str,
_storage_scheme: MerchantStorageScheme, _storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> { ) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_read(self).await?; let conn = pg_connection_read(self).await?;