fix(router/webhooks): correct webhook error mapping and make source verification optional for all connectors (#1333)

This commit is contained in:
ItsMeShashank
2023-06-02 15:30:37 +05:30
committed by GitHub
parent b681f78d96
commit 71315097dd
23 changed files with 191 additions and 114 deletions

View File

@ -9,6 +9,7 @@ use transformers as opennode;
use self::opennode::OpennodeWebhookDetails;
use crate::{
configs::settings,
connector::utils as conn_utils,
core::errors::{self, CustomResult},
db, headers,
services::{self, ConnectorIntegration},
@ -527,13 +528,17 @@ impl api::IncomingWebhook for Opennode {
db: &dyn db::StorageInterface,
merchant_id: &str,
) -> CustomResult<Vec<u8>, errors::ConnectorError> {
let key = format!("whsec_verification_{}_{}", self.id(), merchant_id);
let secret = db
.get_key(&key)
.await
.change_context(errors::ConnectorError::WebhookVerificationSecretNotFound)?;
Ok(secret)
let key = conn_utils::get_webhook_merchant_secret_key(self.id(), merchant_id);
let secret = match db.find_config_by_key(&key).await {
Ok(config) => Some(config),
Err(e) => {
crate::logger::warn!("Unable to fetch merchant webhook secret from DB: {:#?}", e);
None
}
};
Ok(secret
.map(|conf| conf.config.into_bytes())
.unwrap_or_default())
}
fn get_webhook_object_reference_id(