feat(core): add referer field to browser_info (#9474)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Aishwariyaa Anand
2025-09-24 19:05:24 +05:30
committed by GitHub
parent e0fa7e9b6c
commit 46d483d87c
12 changed files with 35 additions and 12 deletions

18
Cargo.lock generated
View File

@ -3553,14 +3553,14 @@ dependencies = [
[[package]]
name = "grpc-api-types"
version = "0.1.0"
source = "git+https://github.com/juspay/connector-service?rev=142cb5a23d302e5d39c4da8d280edababe0691fe#142cb5a23d302e5d39c4da8d280edababe0691fe"
source = "git+https://github.com/juspay/connector-service?rev=f719688943adf7bc17bb93dcb43f27485c17a96e#f719688943adf7bc17bb93dcb43f27485c17a96e"
dependencies = [
"axum 0.8.4",
"error-stack 0.5.0",
"g2h",
"heck 0.5.0",
"http 1.3.1",
"masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=v1.116.0)",
"masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=2025.09.17.0)",
"prost",
"prost-build",
"prost-types",
@ -4865,7 +4865,7 @@ dependencies = [
[[package]]
name = "masking"
version = "0.1.0"
source = "git+https://github.com/juspay/hyperswitch?tag=v1.116.0#672d749e20bec7800613878e36a0ab3885177326"
source = "git+https://github.com/juspay/hyperswitch?tag=2025.09.17.0#15406557c11041bab6358f2b4b916d7333fc0a0f"
dependencies = [
"bytes 1.10.1",
"diesel",
@ -6988,7 +6988,7 @@ dependencies = [
[[package]]
name = "rust-grpc-client"
version = "0.1.0"
source = "git+https://github.com/juspay/connector-service?rev=142cb5a23d302e5d39c4da8d280edababe0691fe#142cb5a23d302e5d39c4da8d280edababe0691fe"
source = "git+https://github.com/juspay/connector-service?rev=f719688943adf7bc17bb93dcb43f27485c17a96e#f719688943adf7bc17bb93dcb43f27485c17a96e"
dependencies = [
"grpc-api-types",
]
@ -9395,11 +9395,11 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
[[package]]
name = "ucs_cards"
version = "0.1.0"
source = "git+https://github.com/juspay/connector-service?rev=142cb5a23d302e5d39c4da8d280edababe0691fe#142cb5a23d302e5d39c4da8d280edababe0691fe"
source = "git+https://github.com/juspay/connector-service?rev=f719688943adf7bc17bb93dcb43f27485c17a96e#f719688943adf7bc17bb93dcb43f27485c17a96e"
dependencies = [
"bytes 1.10.1",
"error-stack 0.4.1",
"masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=v1.116.0)",
"masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=2025.09.17.0)",
"prost",
"regex",
"serde",
@ -9411,7 +9411,7 @@ dependencies = [
[[package]]
name = "ucs_common_enums"
version = "0.1.0"
source = "git+https://github.com/juspay/connector-service?rev=142cb5a23d302e5d39c4da8d280edababe0691fe#142cb5a23d302e5d39c4da8d280edababe0691fe"
source = "git+https://github.com/juspay/connector-service?rev=f719688943adf7bc17bb93dcb43f27485c17a96e#f719688943adf7bc17bb93dcb43f27485c17a96e"
dependencies = [
"serde",
"strum 0.26.3",
@ -9422,7 +9422,7 @@ dependencies = [
[[package]]
name = "ucs_common_utils"
version = "0.1.0"
source = "git+https://github.com/juspay/connector-service?rev=142cb5a23d302e5d39c4da8d280edababe0691fe#142cb5a23d302e5d39c4da8d280edababe0691fe"
source = "git+https://github.com/juspay/connector-service?rev=f719688943adf7bc17bb93dcb43f27485c17a96e#f719688943adf7bc17bb93dcb43f27485c17a96e"
dependencies = [
"anyhow",
"blake3",
@ -9431,7 +9431,7 @@ dependencies = [
"error-stack 0.4.1",
"hex",
"http 1.3.1",
"masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=v1.116.0)",
"masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=2025.09.17.0)",
"md5",
"nanoid",
"once_cell",

View File

@ -7522,6 +7522,11 @@
"type": "string",
"description": "Accept-language of the browser",
"nullable": true
},
"referer": {
"type": "string",
"description": "Identifier of the source that initiated the request.",
"nullable": true
}
}
},

View File

@ -1232,6 +1232,9 @@ pub struct BrowserInformation {
/// Accept-language of the browser
pub accept_language: Option<String>,
/// Identifier of the source that initiated the request.
pub referer: Option<String>,
}
#[cfg(feature = "v2")]

View File

@ -68,7 +68,7 @@ reqwest = { version = "0.11.27", features = ["rustls-tls"] }
http = "0.2.12"
url = { version = "2.5.4", features = ["serde"] }
quick-xml = { version = "0.31.0", features = ["serialize"] }
unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "142cb5a23d302e5d39c4da8d280edababe0691fe", package = "rust-grpc-client" }
unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "f719688943adf7bc17bb93dcb43f27485c17a96e", package = "rust-grpc-client" }
# First party crates

View File

@ -529,6 +529,7 @@ impl TryFrom<&TrustpayRouterData<&PaymentsAuthorizeRouterData>> for TrustpayPaym
os_version: None,
device_model: None,
accept_language: Some(browser_info.accept_language.unwrap_or("en".to_string())),
referer: None,
};
let params = get_mandatory_fields(item.router_data)?;
let amount = item.amount.to_owned();

View File

@ -906,6 +906,7 @@ pub struct BrowserInformation {
pub os_version: Option<String>,
pub device_model: Option<String>,
pub accept_language: Option<String>,
pub referer: Option<String>,
}
#[cfg(feature = "v2")]
@ -926,6 +927,7 @@ impl From<common_utils::types::BrowserInformation> for BrowserInformation {
os_version: value.os_version,
device_model: value.device_model,
accept_language: value.accept_language,
referer: value.referer,
}
}
}

View File

@ -89,8 +89,8 @@ reqwest = { version = "0.11.27", features = ["json", "rustls-tls", "gzip", "mult
ring = "0.17.14"
rust_decimal = { version = "1.37.1", features = ["serde-with-float", "serde-with-str"] }
rust-i18n = { git = "https://github.com/kashif-m/rust-i18n", rev = "f2d8096aaaff7a87a847c35a5394c269f75e077a" }
unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "142cb5a23d302e5d39c4da8d280edababe0691fe", package = "rust-grpc-client" }
unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "142cb5a23d302e5d39c4da8d280edababe0691fe", package = "ucs_cards" }
unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "f719688943adf7bc17bb93dcb43f27485c17a96e", package = "rust-grpc-client" }
unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "f719688943adf7bc17bb93dcb43f27485c17a96e", package = "ucs_cards" }
rustc-hash = "1.1.0"
rustls = "0.22"
rustls-pemfile = "2"

View File

@ -76,6 +76,9 @@ impl ForeignTryFrom<&RouterData<PSync, PaymentsSyncData, PaymentsResponseData>>
Ok(Self {
transaction_id: connector_transaction_id.or(encoded_data),
request_ref_id: connector_ref_id,
access_token: None,
capture_method: None,
handle_response: None,
})
}
}
@ -507,6 +510,7 @@ impl ForeignTryFrom<&RouterData<Authorize, PaymentsAuthorizeData, PaymentsRespon
browser_info,
test_mode: None,
payment_method_type: None,
access_token: None,
})
}
}
@ -1040,6 +1044,7 @@ impl ForeignTryFrom<hyperswitch_domain_models::router_request_types::BrowserInfo
device_model: browser_info.device_model,
accept_language: browser_info.accept_language,
time_zone_offset_minutes: browser_info.time_zone,
referer: browser_info.referer,
})
}
}
@ -1305,6 +1310,7 @@ pub fn build_webhook_transform_request(
}),
request_details: Some(request_details_grpc),
webhook_secrets,
access_token: None,
})
}

View File

@ -36,6 +36,7 @@ pub fn populate_browser_info(
os_version: None,
device_model: None,
accept_language: None,
referer: None,
});
let ip_address = req

View File

@ -164,6 +164,9 @@ where
Some(unified_connector_service_client::payments::webhook_response_content::Content::DisputesResponse(_)) => {
Err(errors::ConnectorError::ProcessingStepFailed(Some("UCS webhook contains dispute response but payment processing was expected".to_string().into())).into())
},
Some(unified_connector_service_client::payments::webhook_response_content::Content::IncompleteTransformation(_)) => {
Err(errors::ConnectorError::ProcessingStepFailed(Some("UCS webhook contains incomplete transformation but payment processing was expected".to_string().into())).into())
},
None => {
Err(errors::ConnectorError::ResponseDeserializationFailed)
.attach_printable("UCS webhook content missing payments_response")

View File

@ -53,6 +53,7 @@ fn get_default_browser_info() -> BrowserInformation {
os_version: None,
device_model: None,
accept_language: Some("en".to_string()),
referer: None,
}
}

View File

@ -1048,6 +1048,7 @@ impl Default for BrowserInfoType {
os_type: Some("IOS or ANDROID".to_string()),
os_version: Some("IOS 14.5".to_string()),
accept_language: Some("en".to_string()),
referer: None,
};
Self(data)
}