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(platform): implement processor context to poll functions (#12163)

Ankit Kumar Gupta154dde37eaa1
diff --git a/crates/router/src/core/poll.rs b/crates/router/src/core/poll.rs
index 2281c3c9ea..d6a558bf8c 100644
--- a/crates/router/src/core/poll.rs
+++ b/crates/router/src/core/poll.rs
@@ -12,7 +12,7 @@ use crate::{
pub async fn retrieve_poll_status(
state: SessionState,
req: crate::types::api::PollId,
- platform: domain::Platform,
+ processor: domain::Processor,
) -> RouterResponse<PollResponse> {
let redis_conn = state
.store
@@ -20,11 +20,9 @@ pub async fn retrieve_poll_status(
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to get redis connection")?;
let request_poll_id = req.poll_id;
- // prepend 'poll_{merchant_id}_' to restrict access to only fetching Poll IDs, as this is a freely passed string in the request
- let poll_id = super::utils::get_poll_id(
- platform.get_processor().get_account().get_id(),
- request_poll_id.clone(),
- );
+ // prepend 'poll_{processor_merchant_id}_' to restrict access to only fetching Poll IDs, as this is a freely passed string in the request
+ let poll_id =
+ super::utils::get_poll_id(processor.get_account().get_id(), request_poll_id.clone());
let redis_value = redis_conn
.get_key::<Option<String>>(&poll_id.as_str().into())
.await
diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rs
index 983bfbf9a6..866fecdff4 100644
--- a/crates/router/src/core/utils.rs
+++ b/crates/router/src/core/utils.rs
@@ -2252,8 +2252,11 @@ pub async fn get_profile_id_from_business_details(
}
}
-pub fn get_poll_id(merchant_id: &common_utils::id_type::MerchantId, unique_id: String) -> String {
- merchant_id.get_poll_id(&unique_id)
+pub fn get_poll_id(
+ processor_merchant_id: &common_utils::id_type::MerchantId,
+ unique_id: String,
+) -> String {
+ processor_merchant_id.get_poll_id(&unique_id)
}
pub fn get_external_authentication_request_poll_id(
diff --git a/crates/router/src/routes/poll.rs b/crates/router/src/routes/poll.rs
index a4d2a4cd44..bf6197bde2 100644
--- a/crates/router/src/routes/poll.rs
+++ b/crates/router/src/routes/poll.rs
@@ -39,12 +39,12 @@ pub async fn retrieve_poll_status(
match req.headers().get(actix_web::http::header::AUTHORIZATION) {
// If Authorization header is present, use SdkAuthorizationAuth
Some(_) => Box::new(auth::SdkAuthorizationAuth {
- allow_connected_scope_operation: false,
+ allow_connected_scope_operation: true,
allow_platform_self_operation: false,
}),
// If Authorization header is not present, use PublishableKeyAuth
None => Box::new(auth::HeaderAuth(auth::PublishableKeyAuth {
- allow_connected_scope_operation: false,
+ allow_connected_scope_operation: true,
allow_platform_self_operation: false,
})),
};
@@ -53,7 +53,9 @@ pub async fn retrieve_poll_status(
state,
&req,
poll_id,
- |state, auth, req, _| poll::retrieve_poll_status(state, req, auth.platform),
+ |state, auth, req, _| {
+ poll::retrieve_poll_status(state, req, auth.platform.get_processor().clone())
+ },
&*auth,
api_locking::LockAction::NotApplicable,
))