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

feat(payments): add offer engine foundation and connectivity check (#13433)

Apoorv Dixitdd4260d5ef73
diff --git a/config/config.example.toml b/config/config.example.toml
index beef36182a..c3b4344b11 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -1512,6 +1512,11 @@ polling_interval = 15 # Polling interval in seconds fo
request_timeout = 60 # Request timeout in seconds for Superposition API calls (optional, default: none)
backup_file_path = "./config/superposition_seed.toml" # Path to a local file for fallback configuration. Used when the Superposition HTTP service is unavailable. If set, the client will fall back to reading configuration from this file instead of failing completely. This ensures graceful degradation during network outages or service disruptions.
+[offer_engine]
+base_url = "https://offer-engine.example.com/" # Base URL of the Offer Engine service
+api_key = "" # API key for API-key authenticated Offer Engine calls
+merchant_id = "" # Offer Engine merchant id sent in request bodies
+
[micro_services]
# Base URLs for modular microservices
# (e.g., payment-methods, customers, routing, etc.)
diff --git a/config/superposition_seed.toml b/config/superposition_seed.toml
index 5782813a0c..cf8f584a46 100644
--- a/config/superposition_seed.toml
+++ b/config/superposition_seed.toml
@@ -15,6 +15,8 @@
[default-configs]
deja_record = { value = false, schema = { type = "boolean" }, description = "Deja per-request recording decision — default SKIP (false). The deja_dimension cohort override (seeded by scripts/seed_superposition.sh) sets this true for the recordable endpoint bucket; /health and other probe traffic fall through to false.", change_reason = "Deja recording sampler"}
+offer_engine_enabled = { value = false, schema = { type = "boolean" }, description = "Master gate for the Offer Engine integration. When false (default) Offer Engine is never called, regardless of offer_engine_credential_source. Set true (per tenant/env override) to allow Offer Engine calls.", change_reason = "Offer Engine disabled by default; enable via Superposition override"}
+offer_engine_credential_source = { value = "none", schema = { type = "string", enum = ["none", "application"] }, description = "Source of Offer Engine credentials once offer_engine_enabled is true: 'none' skips Offer Engine; 'application' uses the static offer_engine application config. Future org/merchant/profile sources will extend the enum alongside their credential storage.", change_reason = "Offer Engine credential source is a string enum: 'none' disables, 'application' enables; extensible to org/merchant/profile sources"}
client_session_validation_enabled = { value = true, schema = { type = "boolean" } }
"dynamic_fields.bank_debit.ach_bank_debit.account_number._confirm_request_write_path" = { value = "payment_method_data.bank_debit.ach_bank_debit.account_number", schema = { type = "string" } }
"dynamic_fields.bank_debit.ach_bank_debit.account_number._default_label_text" = { value = "Account Number", schema = { type = "string" } }
diff --git a/crates/router/src/configs/secrets_transformers.rs b/crates/router/src/configs/secrets_transformers.rs
index 860f65ac04..39e79ee8b7 100644
--- a/crates/router/src/configs/secrets_transformers.rs
+++ b/crates/router/src/configs/secrets_transformers.rs
@@ -699,6 +699,7 @@ pub(crate) async fn fetch_raw_secrets(
internal_services: conf.internal_services,
micro_services: conf.micro_services,
superposition,
+ offer_engine: conf.offer_engine,
comparison_service: conf.comparison_service,
authentication_service_enabled_connectors: conf.authentication_service_enabled_connectors,
save_payment_method_on_session: conf.save_payment_method_on_session,
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index 1fec74ff9a..4c9c15e918 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -33,7 +33,7 @@ pub use hyperswitch_interfaces::{
},
types::{ComparisonServiceConfig, Proxy},
};
-use hyperswitch_masking::{Maskable, Secret};
+use hyperswitch_masking::{Maskable, PeekInterface, Secret};
pub use payment_methods::configs::{
settings::{
BankRedirectConfig, BanksVector, ConnectorBankNames, ConnectorFields,
@@ -194,6 +194,7 @@ pub struct Settings<S: SecretState> {
#[serde(default)]
pub enhancement: Option<HashMap<String, String>>,
pub superposition: SecretStateContainer<SuperpositionClientConfig, S>,
+ pub offer_engine: Option<OfferEngineConfig>,
pub proxy_status_mapping: ProxyStatusMapping,
pub trace_header: TraceHeaderConfig,
pub internal_services: InternalServicesConfig,
@@ -647,6 +648,35 @@ pub struct ForexApi {
pub redis_ttl_in_seconds: u32,
}
+#[derive(Debug, Deserialize, Clone)]
+pub struct OfferEngineConfig {
+ pub base_url: url::Url,
+ pub api_key: Secret<String>,
+ pub merchant_id: String,
+}
+
+impl OfferEngineConfig {
+ pub fn validate(&self) -> ApplicationResult<()> {
+ common_utils::fp_utils::when(!self.base_url.path().ends_with('/'), || {
+ Err(ApplicationError::InvalidConfigurationValueError(
+ "offer_engine.base_url must end with a trailing slash".into(),
+ ))
+ })?;
+ common_utils::fp_utils::when(self.api_key.peek().is_empty(), || {
+ Err(ApplicationError::InvalidConfigurationValueError(
+ "offer_engine.api_key must not be empty".into(),
+ ))
+ })?;
+ common_utils::fp_utils::when(self.merchant_id.is_empty(), || {
+ Err(error_stack::Report::from(
+ ApplicationError::InvalidConfigurationValueError(
+ "offer_engine.merchant_id must not be empty".into(),
+ ),
+ ))
+ })
+ }
+}
+
#[derive(Debug, Deserialize, Clone, Default)]
pub struct DefaultExchangeRates {
pub base_currency: String,
@@ -1450,6 +1480,11 @@ impl Settings<SecuredSecret> {
.map(|x| x.get_inner().validate())
.transpose()?;
+ self.offer_engine
+ .as_ref()
+ .map(|offer_engine| offer_engine.validate())
+ .transpose()?;
+
self.paze_decrypt_keys
.as_ref()
.map(|x| x.get_inner().validate())
diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs
index e9def7713a..b045336020 100644
--- a/crates/router/src/consts.rs
+++ b/crates/router/src/consts.rs
@@ -367,6 +367,10 @@ pub const CREQ_CHALLENGE_REQUEST_KEY: &str = "creq";
/// Superposition configuration keys
pub mod superposition {
+ /// Offer Engine master gate key: boolean, `false` (default) disables all Offer Engine calls.
+ pub const OFFER_ENGINE_ENABLED: &str = "offer_engine_enabled";
+ /// Offer Engine credential source key: `"none"` skips Offer Engine, `"application"` uses the static app config.
+ pub const OFFER_ENGINE_CREDENTIAL_SOURCE: &str = "offer_engine_credential_source";
/// CVV requirement configuration key
pub const REQUIRES_CVV: &str = "requires_cvv";
/// implicit customer update configuration key
diff --git a/crates/router/src/core.rs b/crates/router/src/core.rs
index fdc8cce083..ce25204622 100644
--- a/crates/router/src/core.rs
+++ b/crates/router/src/core.rs
@@ -35,6 +35,7 @@ pub mod health_check;
pub mod mandate;
pub mod merchant_connector_webhook_management;
pub mod metrics;
+pub mod offer_engine;
pub mod payment_link;
#[cfg(feature = "v2")]
pub mod payment_method_balance;
diff --git a/crates/router/src/core/configs/dimension_config.rs b/crates/router/src/core/configs/dimension_config.rs
index a7bcfb7b92..73337d78ba 100644
--- a/crates/router/src/core/configs/dimension_config.rs
+++ b/crates/router/src/core/configs/dimension_config.rs
@@ -773,3 +773,28 @@ impl DatabaseBackedConfig for SaveWalletDecryptedData {
.map(|id| format!("{}_{}", Self::KEY, id.get_string_repr()))
}
}
+
+config! {
+ superposition_key = OFFER_ENGINE_ENABLED,
+ output = bool,
+ default = false,
+ requires = dimension_state::DimensionsGlobal,
+ targeting_key = id_type::PaymentId
+}
+
+impl DatabaseBackedConfig for OfferEngineEnabled {
+ const KEY: &'static str = "offer_engine_enabled";
+}
+
+config! {
+ superposition_key = OFFER_ENGINE_CREDENTIAL_SOURCE,
+ output = crate::core::offer_engine::types::OfferEngineCredentialSource,
+ default = crate::core::offer_engine::types::OfferEngineCredentialSource::None,
+ string_enum = true,
+ requires = dimension_state::DimensionsGlobal,
+ targeting_key = id_type::PaymentId
+}
+
+impl DatabaseBackedConfig for OfferEngineCredentialSource {
+ const KEY: &'static str = "offer_engine_credential_source";
+}
diff --git a/crates/router/src/core/configs/dimension_state.rs b/crates/router/src/core/configs/dimension_state.rs
index 44b47ad0a3..d129b56237 100644
--- a/crates/router/src/core/configs/dimension_state.rs
+++ b/crates/router/src/core/configs/dimension_state.rs
@@ -556,6 +556,18 @@ impl<Pm, M, O, P, Cn, PRT, Ev> DimensionsBase for Dimensions<Pm, M, O, P, Cn, PR
}
// Type aliases
+
+// Global config scope: no Superposition dimensions are required.
+pub type DimensionsGlobal = Dimensions<
+ NoProviderMerchantId,
+ NoProcessorMerchantId,
+ NoOrgId,
+ NoProfileId,
+ NoConnector,
+ NoPayoutRetryType,
+ NoWebhookEvent,
+>;
+
pub type DimensionsWithProviderMerchantId = Dimensions<
HasProviderMerchantId,
NoProcessorMerchantId,
diff --git a/crates/router/src/core/offer_engine.rs b/crates/router/src/core/offer_engine.rs
new file mode 100644
index 0000000000..5a0bd16158
--- /dev/null
+++ b/crates/router/src/core/offer_engine.rs
@@ -0,0 +1,8 @@
+pub mod client;
+pub mod config;
+pub mod connectivity;
+pub mod types;
+
+pub use client::OfferEngineClient;
+pub use config::resolve_offer_engine_config;
+pub use types::{OfferEngineCredentialSource, OfferEngineError, ResolvedOfferEngineConfig};
diff --git a/crates/router/src/core/offer_engine/client.rs b/crates/router/src/core/offer_engine/client.rs
new file mode 100644
index 0000000000..34e69da723
--- /dev/null
+++ b/crates/router/src/core/offer_engine/client.rs
@@ -0,0 +1,130 @@
+use base64::Engine;
+use common_utils::request::{Headers, Method, RequestContent};
+use hyperswitch_interfaces::micro_service::{
+ MicroserviceClient, MicroserviceClientError, MicroserviceClientErrorKind,
+};
+use hyperswitch_masking::{Mask, PeekInterface};
+use router_env::{IdReuse, RequestIdentifier};
+
+use super::types::ResolvedOfferEngineConfig;
+use crate::{consts::BASE64_ENGINE, routes::SessionState};
+
+const OFFERS_LIST_PATH: &str = "v1/offers/list";
+
+#[derive(Debug)]
+pub struct OfferEngineClient {
+ base_url: url::Url,
+ parent_headers: Headers,
+ trace: RequestIdentifier,
+ merchant_id: String,
+}
+
+impl OfferEngineClient {
+ pub fn new(config: ResolvedOfferEngineConfig, trace_header_name: &str) -> Self {
+ let auth_value = format!(
+ "Basic {}",
+ BASE64_ENGINE.encode(format!("{}:", config.api_key.peek()))
+ );
+ let mut parent_headers = Headers::new();
+ parent_headers.insert(("Authorization".to_string(), auth_value.into_masked()));
+
+ let trace = RequestIdentifier::new(trace_header_name).use_incoming_id(IdReuse::UseIncoming);
+
+ Self {
+ base_url: config.base_url,
+ parent_headers,
+ trace,
+ merchant_id: config.merchant_id,
+ }
+ }
+
+ pub fn merchant_id(&self) -> &str {
+ &self.merchant_id
+ }
+
+ pub async fn check_connectivity(&self, state: &SessionState) -> ConnectivityResult {
+ match OfferConnectivity::call(state, self, OfferConnectivityRequest).await {
+ Ok(_) => ConnectivityResult {
+ reachable: true,
+ status_code: None,
+ detail: "Reached Offer Engine".to_string(),
+ },
+ Err(err) => match err.kind {
+ MicroserviceClientErrorKind::Upstream { status, .. } => {
+ let detail = match status {
+ 401 | 403 => "Reached Offer Engine, but authentication failed".to_string(),
+ _ => format!("Reached Offer Engine (HTTP {status})"),
+ };
+ ConnectivityResult {
+ reachable: true,
+ status_code: Some(status),
+ detail,
+ }
+ }
+ MicroserviceClientErrorKind::Deserialize(_) => ConnectivityResult {
+ reachable: true,
+ status_code: None,
+ detail: "Reached Offer Engine".to_string(),
+ },
+ other => ConnectivityResult {
+ reachable: false,
+ status_code: None,
+ detail: format!("Could not reach Offer Engine: {other}"),
+ },
+ },
+ }
+ }
+}
+
+impl MicroserviceClient for OfferEngineClient {
+ fn base_url(&self) -> &url::Url {
+ &self.base_url
+ }
+
+ fn parent_headers(&self) -> &Headers {
+ &self.parent_headers
+ }
+
+ fn trace(&self) -> &RequestIdentifier {
+ &self.trace
+ }
+}
+
+pub struct OfferConnectivity;
+pub struct OfferConnectivityRequest;
+pub struct OfferConnectivityResponse;
+
+impl TryFrom<&Self> for OfferConnectivityRequest {
+ type Error = MicroserviceClientError;
+ fn try_from(_: &Self) -> Result<Self, Self::Error> {
+ Ok(Self)
+ }
+}
+
+impl TryFrom<serde_json::Value> for OfferConnectivityResponse {
+ type Error = MicroserviceClientError;
+ fn try_from(_: serde_json::Value) -> Result<Self, Self::Error> {
+ Ok(Self)
+ }
+}
+
+hyperswitch_interfaces::impl_microservice_flow!(
+ OfferConnectivity,
+ method = Method::Post,
+ path = OFFERS_LIST_PATH,
+ v1_request = OfferConnectivityRequest,
+ v2_request = OfferConnectivityRequest,
+ v2_response = serde_json::Value,
+ v1_response = OfferConnectivityResponse,
+ client = OfferEngineClient,
+ body = |_: &OfferConnectivity, _: OfferConnectivityRequest| Some(RequestContent::Json(
+ Box::new(serde_json::json!({}))
+ ))
+);
+
+#[derive(Debug, Clone, serde::Serialize)]
+pub struct ConnectivityResult {
+ pub reachable: bool,
+ pub status_code: Option<u16>,
+ pub detail: String,
+}
diff --git a/crates/router/src/core/offer_engine/config.rs b/crates/router/src/core/offer_engine/config.rs
new file mode 100644
index 0000000000..07d3c6a10f
--- /dev/null
+++ b/crates/router/src/core/offer_engine/config.rs
@@ -0,0 +1,45 @@
+use common_utils::errors::CustomResult;
+
+use super::types::{OfferEngineCredentialSource, OfferEngineError, ResolvedOfferEngineConfig};
+use crate::{core::configs::dimension_state, routes::SessionState};
+
+pub async fn resolve_offer_engine_config(
+ state: &SessionState,
+ dimensions: &dimension_state::DimensionsGlobal,
+) -> CustomResult<Option<ResolvedOfferEngineConfig>, OfferEngineError> {
+ let store = state.store.as_ref();
+ let superposition = state.superposition_service.as_ref();
+
+ let enabled = dimensions
+ .get_offer_engine_enabled(store, superposition, None)
+ .await;
+
+ if enabled {
+ let source = dimensions
+ .get_offer_engine_credential_source(store, superposition, None)
+ .await;
+
+ match source {
+ OfferEngineCredentialSource::None => Ok(None),
+ OfferEngineCredentialSource::Application => resolve_application_config(state).map(Some),
+ }
+ } else {
+ Ok(None)
+ }
+}
+
+fn resolve_application_config(
+ state: &SessionState,
+) -> CustomResult<ResolvedOfferEngineConfig, OfferEngineError> {
+ let app_config = state.conf.offer_engine.as_ref().ok_or_else(|| {
+ error_stack::report!(OfferEngineError::MissingApplicationConfig(
+ "offer_engine application config is not set".to_string()
+ ))
+ })?;
+
+ Ok(ResolvedOfferEngineConfig {
+ base_url: app_config.base_url.clone(),
+ api_key: app_config.api_key.clone(),
+ merchant_id: app_config.merchant_id.clone(),
+ })
+}
diff --git a/crates/router/src/core/offer_engine/connectivity.rs b/crates/router/src/core/offer_engine/connectivity.rs
new file mode 100644
index 0000000000..f33df96955
--- /dev/null
+++ b/crates/router/src/core/offer_engine/connectivity.rs
@@ -0,0 +1,56 @@
+use super::{client::OfferEngineClient, config::resolve_offer_engine_config};
+use crate::{
+ core::{configs::dimension_state, errors::RouterResponse},
+ routes::SessionState,
+ services::ApplicationResponse,
+};
+
+impl common_utils::events::ApiEventMetric for OfferEngineConnectivityResponse {}
+
+/// Response of the Offer Engine connectivity check.
+#[derive(Debug, Clone, serde::Serialize)]
+pub struct OfferEngineConnectivityResponse {
+ /// Whether Offer Engine is enabled (credential source resolved) for this context.
+ pub enabled: bool,
+ /// Whether Offer Engine was reachable over the network. `None` when disabled.
+ pub reachable: Option<bool>,
+ /// HTTP status code Offer Engine returned, if reachable.
+ pub status_code: Option<u16>,
+ /// Human-readable outcome (config error / disabled / reachable / blocked / auth-failed).
+ pub detail: String,
+}
+
+pub async fn check_offer_engine_connectivity(
+ state: SessionState,
+) -> RouterResponse<OfferEngineConnectivityResponse> {
+ let dimensions: dimension_state::DimensionsGlobal = dimension_state::Dimensions::new();
+ let response = match resolve_offer_engine_config(&state, &dimensions).await {
+ Err(err) => OfferEngineConnectivityResponse {
+ enabled: false,
+ reachable: None,
+ status_code: None,
+ detail: format!("Offer Engine config could not be resolved: {err:?}"),
+ },
+ Ok(None) => OfferEngineConnectivityResponse {
+ enabled: false,
+ reachable: None,
+ status_code: None,
+ detail: "Offer Engine is not enabled in global config \
+ (offer_engine_enabled is false or credential source is none)"
+ .to_string(),
+ },
+ Ok(Some(config)) => {
+ let result = OfferEngineClient::new(config, &state.conf.trace_header.header_name)
+ .check_connectivity(&state)
+ .await;
+ OfferEngineConnectivityResponse {
+ enabled: true,
+ reachable: Some(result.reachable),
+ status_code: result.status_code,
+ detail: result.detail,
+ }
+ }
+ };
+
+ Ok(ApplicationResponse::Json(response))
+}
diff --git a/crates/router/src/core/offer_engine/types.rs b/crates/router/src/core/offer_engine/types.rs
new file mode 100644
index 0000000000..1e91890613
--- /dev/null
+++ b/crates/router/src/core/offer_engine/types.rs
@@ -0,0 +1,36 @@
+use hyperswitch_masking::Secret;
+
+#[derive(
+ Debug,
+ Clone,
+ Copy,
+ PartialEq,
+ Eq,
+ serde::Serialize,
+ serde::Deserialize,
+ strum::Display,
+ strum::EnumString,
+)]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+pub enum OfferEngineCredentialSource {
+ None,
+ Application,
+}
+
+#[derive(Debug, Clone)]
+pub struct ResolvedOfferEngineConfig {
+ pub base_url: url::Url,
+ pub api_key: Secret<String>,
+ pub merchant_id: String,
+}
+
+#[derive(Debug, thiserror::Error)]
+pub enum OfferEngineError {
+ #[error("Offer Engine application config is missing or invalid: {0}")]
+ MissingApplicationConfig(String),
+ #[error("Offer Engine request failed")]
+ RequestFailed,
+ #[error("Failed to parse Offer Engine response")]
+ ResponseParseFailed,
+}
diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rs
index 298990bc18..5eee82e495 100644
--- a/crates/router/src/lib.rs
+++ b/crates/router/src/lib.rs
@@ -358,6 +358,7 @@ pub fn mk_app(
server_app = server_app.service(routes::Cache::server(state.clone()));
server_app = server_app.service(routes::Health::server(state.clone()));
+ server_app = server_app.service(routes::OfferEngine::server(state.clone()));
// Registered at the end because this entry has an empty scope
#[cfg(feature = "olap")]
{
diff --git a/crates/router/src/routes.rs b/crates/router/src/routes.rs
index ded3707dc0..489f5bbe28 100644
--- a/crates/router/src/routes.rs
+++ b/crates/router/src/routes.rs
@@ -29,6 +29,7 @@ pub mod hypersense;
pub mod lock_utils;
pub mod mandates;
pub mod metrics;
+pub mod offer_engine;
pub mod oidc;
#[cfg(feature = "v1")]
pub mod payment_link;
@@ -93,9 +94,10 @@ pub use self::app::{
ApiKeys, AppState, ApplePayCertificatesMigration, Authentication, Cache, CardIssuers, Cards,
Chat, Configs, ConnectorOnboarding, Customers, Disputes, Embedded, EphemeralKey, FeatureMatrix,
Files, Forex, Gsm, Health, Hypersense, Mandates, MerchantAccount, MerchantConnectorAccount,
- Oidc, PaymentLink, PaymentMethods, Payments, Poll, ProcessTracker, ProcessTrackerDeprecated,
- Profile, ProfileAcquirer, ProfileNew, Refunds, Relay, RelayWebhooks, SdkConfig, SessionState,
- SuperpositionProxy, ThreeDsDecisionRule, User, UserDeprecated, Webhooks,
+ OfferEngine, Oidc, PaymentLink, PaymentMethods, Payments, Poll, ProcessTracker,
+ ProcessTrackerDeprecated, Profile, ProfileAcquirer, ProfileNew, Refunds, Relay, RelayWebhooks,
+ SdkConfig, SessionState, SuperpositionProxy, ThreeDsDecisionRule, User, UserDeprecated,
+ Webhooks,
};
#[cfg(feature = "olap")]
pub use self::app::{Blocklist, Organization, Routing, Subscription, Verify, WebhookEvents};
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index a97f1b1c93..eeda7ca32f 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -68,7 +68,7 @@ use super::verification::{apple_pay_merchant_registration, retrieve_apple_pay_ve
use super::webhooks::*;
use super::{
admin, api_keys, cache::*, card_issuer, chat, connector_onboarding, disputes, files, gsm,
- health::*, oidc, profiles, relay, user, user_role,
+ health::*, offer_engine, oidc, profiles, relay, user, user_role,
};
#[cfg(feature = "v1")]
use super::{
@@ -733,6 +733,19 @@ impl Health {
}
}
+pub struct OfferEngine;
+
+impl OfferEngine {
+ pub fn server(state: AppState) -> Scope {
+ web::scope("/offer_engine")
+ .app_data(web::Data::new(state))
+ .service(
+ web::resource("/connectivity")
+ .route(web::post().to(offer_engine::offer_engine_connectivity_check)),
+ )
+ }
+}
+
#[cfg(feature = "dummy_connector")]
pub struct DummyConnector;
diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs
index 38e720e526..1f38a74b9d 100644
--- a/crates/router/src/routes/lock_utils.rs
+++ b/crates/router/src/routes/lock_utils.rs
@@ -130,6 +130,7 @@ impl From<Flow> for ApiIdentifier {
| Flow::CustomersListWithConstraints => Self::Customers,
Flow::EphemeralKeyCreate | Flow::EphemeralKeyDelete => Self::Ephemeral,
Flow::DeepHealthCheck | Flow::HealthCheck => Self::Health,
+ Flow::OfferEngineConnectivityCheck => Self::Health,
Flow::MandatesRetrieve | Flow::MandatesRevoke | Flow::MandatesList => Self::Mandates,
Flow::PaymentMethodsCreate
| Flow::PaymentMethodsMigrate
diff --git a/crates/router/src/routes/offer_engine.rs b/crates/router/src/routes/offer_engine.rs
new file mode 100644
index 0000000000..6e59cd4773
--- /dev/null
+++ b/crates/router/src/routes/offer_engine.rs
@@ -0,0 +1,26 @@
+use actix_web::{web, HttpRequest, HttpResponse};
+use router_env::{instrument, tracing, Flow};
+
+use super::app;
+use crate::{
+ core::{api_locking, offer_engine},
+ services::{api, authentication as auth},
+};
+
+#[instrument(skip_all, fields(flow = ?Flow::OfferEngineConnectivityCheck))]
+pub async fn offer_engine_connectivity_check(
+ state: web::Data<app::AppState>,
+ req: HttpRequest,
+) -> HttpResponse {
+ let flow = Flow::OfferEngineConnectivityCheck;
+ Box::pin(api::server_wrap(
+ flow,
+ state,
+ &req,
+ (),
+ |state, _, _, _| offer_engine::connectivity::check_offer_engine_connectivity(state),
+ &auth::AdminApiAuth,
+ api_locking::LockAction::NotApplicable,
+ ))
+ .await
+}
diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rs
index bce3be7eb1..40b103567b 100644
--- a/crates/router_env/src/logger/types.rs
+++ b/crates/router_env/src/logger/types.rs
@@ -56,6 +56,8 @@ pub enum Flow {
HealthCheck,
/// Deep health Check
DeepHealthCheck,
+ /// Offer Engine connectivity check (dev/admin only)
+ OfferEngineConnectivityCheck,
/// OIDC Discovery endpoint
OidcDiscovery,
/// OIDC JWKS endpoint