diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 1161049160dd..64893d291c47 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -14035,10 +14035,6 @@ }, "payment_id": { "type": "string" - }, - "locale": { - "type": "string", - "nullable": true } } }, diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index aa117841668c..7b9167a19d2d 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -5380,7 +5380,6 @@ pub struct PaymentLinkInitiateRequest { #[schema(value_type = String)] pub merchant_id: id_type::MerchantId, pub payment_id: String, - pub locale: Option, } #[derive(Debug, serde::Serialize)] diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rs index 6c00a1d59a7a..4298cbd65c4a 100644 --- a/crates/router/src/core/payment_link.rs +++ b/crates/router/src/core/payment_link.rs @@ -365,8 +365,22 @@ pub async fn initiate_payment_link_flow( key_store: domain::MerchantKeyStore, merchant_id: common_utils::id_type::MerchantId, payment_id: String, - locale: Option, + request_headers: &header::HeaderMap, ) -> RouterResponse { + let locale = request_headers + .get(header::ACCEPT_LANGUAGE) + .map(|value| { + value.to_str().map(|str| str.to_owned()).map_err(|err| { + logger::warn!( + "Could not convert accept-language header to string: {}", + err + ); + err + }) + }) + .transpose() + .ok() + .flatten(); let (_, payment_details, payment_link_config) = form_payment_link_data( &state, merchant_account, @@ -608,7 +622,6 @@ pub fn get_payment_link_config_based_on_priority( DEFAULT_ENABLE_SAVED_PAYMENT_METHOD ) ); - let payment_link_config = PaymentLinkConfig { theme, logo, @@ -618,6 +631,7 @@ pub fn get_payment_link_config_based_on_priority( enabled_saved_payment_method, allowed_domains, }; + router_env::logger::debug!("payment_link_config : {:?}", payment_link_config.clone()); Ok((payment_link_config, domain_name)) } @@ -648,8 +662,22 @@ pub async fn get_payment_link_status( key_store: domain::MerchantKeyStore, merchant_id: common_utils::id_type::MerchantId, payment_id: String, - locale: Option, + request_headers: &header::HeaderMap, ) -> RouterResponse { + let locale = request_headers + .get(header::ACCEPT_LANGUAGE) + .map(|value| { + value.to_str().map(|str| str.to_owned()).map_err(|err| { + logger::warn!( + "Could not convert accept-language header to string: {}", + err + ); + err + }) + }) + .transpose() + .ok() + .flatten(); let db = &*state.store; let payment_intent = db .find_payment_intent_by_payment_id_merchant_id( diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs index 4aa3b0c65ee1..fa22a2f5aeef 100644 --- a/crates/router/src/core/payments/operations/payment_create.rs +++ b/crates/router/src/core/payments/operations/payment_create.rs @@ -1243,15 +1243,16 @@ async fn create_payment_link( domain_name, merchant_id.get_string_repr(), payment_id.clone(), - locale_str, + locale_str.clone(), ); let secure_link = payment_link_config.allowed_domains.as_ref().map(|_| { format!( - "{}/payment_link/s/{}/{}", + "{}/payment_link/s/{}/{}?locale={}", domain_name, merchant_id.get_string_repr(), - payment_id.clone() + payment_id.clone(), + locale_str, ) }); diff --git a/crates/router/src/routes/payment_link.rs b/crates/router/src/routes/payment_link.rs index 794366b91d54..7e25156c9a64 100644 --- a/crates/router/src/routes/payment_link.rs +++ b/crates/router/src/routes/payment_link.rs @@ -1,4 +1,4 @@ -use actix_web::{http::header::ACCEPT_LANGUAGE, web, Responder}; +use actix_web::{web, Responder}; use router_env::{instrument, tracing, Flow}; use crate::{ @@ -58,27 +58,12 @@ pub async fn initiate_payment_link( ) -> impl Responder { let flow = Flow::PaymentLinkInitiate; let (merchant_id, payment_id) = path.into_inner(); - let locale = req - .headers() - .get(ACCEPT_LANGUAGE) - .map(|value| { - value.to_str().map(|str| str.to_owned()).map_err(|err| { - router_env::logger::warn!( - "Could not convert accept-language header to string: {}", - err - ); - err - }) - }) - .transpose() - .ok() - .flatten(); let payload = api_models::payments::PaymentLinkInitiateRequest { payment_id, merchant_id: merchant_id.clone(), - locale, }; + let headers = req.headers(); Box::pin(api::server_wrap( flow, state, @@ -91,7 +76,7 @@ pub async fn initiate_payment_link( auth.key_store, payload.merchant_id.clone(), payload.payment_id.clone(), - payload.locale.clone(), + headers, ) }, &crate::services::authentication::MerchantIdAuth(merchant_id), @@ -110,7 +95,6 @@ pub async fn initiate_secure_payment_link( let payload = api_models::payments::PaymentLinkInitiateRequest { payment_id, merchant_id: merchant_id.clone(), - locale: None, }; let headers = req.headers(); Box::pin(api::server_wrap( @@ -184,27 +168,12 @@ pub async fn payment_link_status( ) -> impl Responder { let flow = Flow::PaymentLinkStatus; let (merchant_id, payment_id) = path.into_inner(); - let locale = req - .headers() - .get(ACCEPT_LANGUAGE) - .map(|value| { - value.to_str().map(|str| str.to_owned()).map_err(|err| { - router_env::logger::warn!( - "Could not convert accept-language header to string: {}", - err - ); - err - }) - }) - .transpose() - .ok() - .flatten(); let payload = api_models::payments::PaymentLinkInitiateRequest { payment_id, merchant_id: merchant_id.clone(), - locale, }; + let headers = req.headers(); Box::pin(api::server_wrap( flow, state, @@ -217,7 +186,7 @@ pub async fn payment_link_status( auth.key_store, payload.merchant_id.clone(), payload.payment_id.clone(), - payload.locale.clone(), + headers, ) }, &crate::services::authentication::MerchantIdAuth(merchant_id),