Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(connector): [SQUARE] Add uri authority in Webhooks (#2138)

DEEPANSHU BANSALdaa07598922d
diff --git a/crates/router/src/connector/square.rs b/crates/router/src/connector/square.rs
index 8f8e693bd3..2e54677a1d 100644
--- a/crates/router/src/connector/square.rs
+++ b/crates/router/src/connector/square.rs
@@ -844,7 +844,22 @@ impl api::IncomingWebhook for Square {
_merchant_id: &str,
_secret: &[u8],
) -> CustomResult<Vec<u8>, errors::ConnectorError> {
- Ok(format!("{}{}", request.uri, String::from_utf8_lossy(request.body)).into_bytes())
+ let header_value = request
+ .headers
+ .get(actix_web::http::header::HOST)
+ .ok_or(errors::ConnectorError::WebhookSourceVerificationFailed)?;
+ let authority = header_value
+ .to_str()
+ .into_report()
+ .change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
+
+ Ok(format!(
+ "https://{}{}{}",
+ authority,
+ request.uri,
+ String::from_utf8_lossy(request.body)
+ )
+ .into_bytes())
}
fn get_webhook_object_reference_id(