diff --git a/crates/router/src/connector/braintree.rs b/crates/router/src/connector/braintree.rs index ea0b7aa72ed5..4494055af60d 100644 --- a/crates/router/src/connector/braintree.rs +++ b/crates/router/src/connector/braintree.rs @@ -1424,10 +1424,6 @@ impl api::IncomingWebhook for Braintree { let response = decode_webhook_payload(notif.bt_payload.replace('\n', "").as_bytes())?; - // let res_json = serde_json::to_value(response) - // .into_report() - // .change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?; - Ok(Box::new(response)) } diff --git a/crates/router/src/connector/cashtocode.rs b/crates/router/src/connector/cashtocode.rs index 1381d5f3408d..88be55ad920c 100644 --- a/crates/router/src/connector/cashtocode.rs +++ b/crates/router/src/connector/cashtocode.rs @@ -396,9 +396,6 @@ impl api::IncomingWebhook for Cashtocode { .body .parse_struct("CashtocodeIncomingWebhook") .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; - // let res_json = - // utils::Encode::::encode_to_value(&webhook) - // .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(Box::new(webhook)) } diff --git a/crates/router/src/connector/coinbase.rs b/crates/router/src/connector/coinbase.rs index 853267d20a84..93d659563e3d 100644 --- a/crates/router/src/connector/coinbase.rs +++ b/crates/router/src/connector/coinbase.rs @@ -431,8 +431,7 @@ impl api::IncomingWebhook for Coinbase { .body .parse_struct("CoinbaseWebhookDetails") .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; - // Encode::::encode_to_value(¬if.event) - // .change_context(errors::ConnectorError::WebhookBodyDecodingFailed) + Ok(Box::new(notif.event)) } } diff --git a/crates/router/src/connector/cryptopay.rs b/crates/router/src/connector/cryptopay.rs index 00dd221428dc..854939697c72 100644 --- a/crates/router/src/connector/cryptopay.rs +++ b/crates/router/src/connector/cryptopay.rs @@ -461,8 +461,7 @@ impl api::IncomingWebhook for Cryptopay { .body .parse_struct("CryptopayWebhookDetails") .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; - // Encode::::encode_to_value(¬if) - // .change_context(errors::ConnectorError::WebhookBodyDecodingFailed) + Ok(Box::new(notif)) } } diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rs index 68aff8e561c0..da96efeb8685 100644 --- a/crates/router/src/connector/globalpay.rs +++ b/crates/router/src/connector/globalpay.rs @@ -936,10 +936,11 @@ impl api::IncomingWebhook for Globalpay { let details = std::str::from_utf8(request.body) .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; - let res_json = serde_json::from_str(details) - .into_report() - .change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?; - Ok(Box::new(res_json)) + Ok(Box::new( + serde_json::from_str(details) + .into_report() + .change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?, + )) } } diff --git a/crates/router/src/connector/iatapay.rs b/crates/router/src/connector/iatapay.rs index c78542a98e82..a843c173ca91 100644 --- a/crates/router/src/connector/iatapay.rs +++ b/crates/router/src/connector/iatapay.rs @@ -697,8 +697,7 @@ impl api::IncomingWebhook for Iatapay { .body .parse_struct("IatapayPaymentsResponse") .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; - // Encode::::encode_to_value(¬if) - // .change_context(errors::ConnectorError::WebhookBodyDecodingFailed) + Ok(Box::new(notif)) } } diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rs index 95465e7a2d57..2f0b0d5823a3 100644 --- a/crates/router/src/connector/noon.rs +++ b/crates/router/src/connector/noon.rs @@ -742,10 +742,6 @@ impl api::IncomingWebhook for Noon { .parse_struct("NoonWebhookObject") .change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?; - // let res_json = serde_json::to_value(noon::NoonPaymentsResponse::from(resource)) - // .into_report() - // .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; - Ok(Box::new(noon::NoonPaymentsResponse::from(resource))) } } diff --git a/crates/router/src/connector/nuvei.rs b/crates/router/src/connector/nuvei.rs index ebc0ba5996d4..ce47cbb39c67 100644 --- a/crates/router/src/connector/nuvei.rs +++ b/crates/router/src/connector/nuvei.rs @@ -968,7 +968,7 @@ impl api::IncomingWebhook for Nuvei { .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; let payment_response = nuvei::NuveiPaymentsResponse::from(body); - // Encode::::encode_to_value(&payment_response).switch() + Ok(Box::new(payment_response)) } } diff --git a/crates/router/src/connector/opennode.rs b/crates/router/src/connector/opennode.rs index 6a8f6ddd6ae9..fc4f4bf4f7ba 100644 --- a/crates/router/src/connector/opennode.rs +++ b/crates/router/src/connector/opennode.rs @@ -424,8 +424,7 @@ impl api::IncomingWebhook for Opennode { let notif = serde_urlencoded::from_bytes::(request.body) .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; - // Encode::::encode_to_value(¬if.status) - // .change_context(errors::ConnectorError::WebhookBodyDecodingFailed) + Ok(Box::new(notif.status)) } } diff --git a/crates/router/src/connector/payme.rs b/crates/router/src/connector/payme.rs index 7ca67e0ef0b9..337a70c96c3d 100644 --- a/crates/router/src/connector/payme.rs +++ b/crates/router/src/connector/payme.rs @@ -1087,27 +1087,13 @@ impl api::IncomingWebhook for Payme { transformers::NotifyType::SaleComplete | transformers::NotifyType::SaleAuthorized | transformers::NotifyType::SaleFailure => { - // serde_json::to_value(payme::PaymePaySaleResponse::from(resource)) - // .into_report() - // .change_context(errors::ConnectorError::WebhookBodyDecodingFailed) Ok(Box::new(payme::PaymePaySaleResponse::from(resource))) } - transformers::NotifyType::Refund => { - // serde_json::to_value(payme::PaymeQueryTransactionResponse::from(resource)) - // .into_report() - // .change_context(errors::ConnectorError::WebhookBodyDecodingFailed) - Ok(Box::new(payme::PaymeQueryTransactionResponse::from( - resource, - ))) - } + transformers::NotifyType::Refund => Ok(Box::new( + payme::PaymeQueryTransactionResponse::from(resource), + )), transformers::NotifyType::SaleChargeback - | transformers::NotifyType::SaleChargebackRefund => - // serde_json::to_value(resource) - // .into_report() - // .change_context(errors::ConnectorError::WebhookBodyDecodingFailed), - { - Ok(Box::new(resource)) - } + | transformers::NotifyType::SaleChargebackRefund => Ok(Box::new(resource)), } } diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rs index 9706efa87d4c..53f9701eb24d 100644 --- a/crates/router/src/connector/trustpay.rs +++ b/crates/router/src/connector/trustpay.rs @@ -911,10 +911,6 @@ impl api::IncomingWebhook for Trustpay { .body .parse_struct("TrustpayWebhookResponse") .switch()?; - // let res_json = utils::Encode::::encode_to_value( - // &details.payment_information, - // ) - // .change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?; Ok(Box::new(details.payment_information)) } diff --git a/crates/router/src/connector/worldpay.rs b/crates/router/src/connector/worldpay.rs index d914bf25e4dc..3d1294ac63e5 100644 --- a/crates/router/src/connector/worldpay.rs +++ b/crates/router/src/connector/worldpay.rs @@ -760,9 +760,6 @@ impl api::IncomingWebhook for Worldpay { .parse_struct("WorldpayWebhookEventType") .change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?; let psync_body = WorldpayEventResponse::try_from(body)?; - // let res_json = serde_json::to_value(psync_body) - // .into_report() - // .change_context(errors::ConnectorError::WebhookResponseEncodingFailed)?; Ok(Box::new(psync_body)) } } diff --git a/crates/router/src/core/webhooks.rs b/crates/router/src/core/webhooks.rs index dad192f1b9bd..cf7e3402ef8f 100644 --- a/crates/router/src/core/webhooks.rs +++ b/crates/router/src/core/webhooks.rs @@ -873,11 +873,7 @@ pub async fn webhooks_wrapper = body.to_vec(); - // let serialized_request: serde_json::Value = serde_json::from_slice(&body_vec) - // .into_report() - // .change_context(errors::ApiErrorResponse::WebhookProcessingFailure)?; - let serialized_request = serde_json::to_value(&serialized_req) + let serialized_request = masking::masked_serialize(&serialized_req) .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Could not convert webhook effect to string")?; @@ -1127,7 +1123,9 @@ pub async fn webhooks_core