mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
fix(router): fix webhooks flow for checkout connector (#1126)
This commit is contained in:
@ -1075,11 +1075,16 @@ impl api::IncomingWebhook for Checkout {
|
||||
merchant_id: &str,
|
||||
) -> CustomResult<Vec<u8>, errors::ConnectorError> {
|
||||
let key = format!("whsec_verification_{}_{}", self.id(), merchant_id);
|
||||
let secret = db
|
||||
.find_config_by_key(&key)
|
||||
.await
|
||||
.change_context(errors::ConnectorError::WebhookVerificationSecretNotFound)?;
|
||||
Ok(secret.config.into_bytes())
|
||||
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(
|
||||
&self,
|
||||
@ -1143,7 +1148,7 @@ impl api::IncomingWebhook for Checkout {
|
||||
&self,
|
||||
request: &api::IncomingWebhookRequestDetails<'_>,
|
||||
) -> CustomResult<api::disputes::DisputePayload, errors::ConnectorError> {
|
||||
let dispute_details: checkout::CheckoutWebhookBody = request
|
||||
let dispute_details: checkout::CheckoutDisputeWebhookBody = request
|
||||
.body
|
||||
.parse_struct("CheckoutWebhookBody")
|
||||
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
|
||||
|
||||
@ -710,15 +710,33 @@ pub struct CheckoutWebhookData {
|
||||
pub action_id: Option<String>,
|
||||
pub amount: i32,
|
||||
pub currency: String,
|
||||
pub evidence_required_by: Option<PrimitiveDateTime>,
|
||||
pub reason_code: Option<String>,
|
||||
pub date: Option<PrimitiveDateTime>,
|
||||
}
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct CheckoutWebhookBody {
|
||||
#[serde(rename = "type")]
|
||||
pub transaction_type: CheckoutTransactionType,
|
||||
pub data: CheckoutWebhookData,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct CheckoutDisputeWebhookData {
|
||||
pub id: String,
|
||||
pub payment_id: Option<String>,
|
||||
pub action_id: Option<String>,
|
||||
pub amount: i32,
|
||||
pub currency: String,
|
||||
#[serde(with = "common_utils::custom_serde::iso8601::option")]
|
||||
pub evidence_required_by: Option<PrimitiveDateTime>,
|
||||
pub reason_code: Option<String>,
|
||||
#[serde(with = "common_utils::custom_serde::iso8601::option")]
|
||||
pub date: Option<PrimitiveDateTime>,
|
||||
}
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct CheckoutDisputeWebhookBody {
|
||||
#[serde(rename = "type")]
|
||||
pub transaction_type: CheckoutTransactionType,
|
||||
pub data: CheckoutDisputeWebhookData,
|
||||
#[serde(with = "common_utils::custom_serde::iso8601::option")]
|
||||
pub created_on: Option<PrimitiveDateTime>,
|
||||
}
|
||||
#[derive(Debug, Deserialize, strum::Display, Clone)]
|
||||
|
||||
Reference in New Issue
Block a user