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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(modular_payment_method): pass the app request ID for internal service calls (#11385)
Shankar Singh C87c03283b95c
diff --git a/crates/payment_methods/src/client.rs b/crates/payment_methods/src/client.rsindex 96603794f3..779e52a81d 100644--- a/crates/payment_methods/src/client.rs+++ b/crates/payment_methods/src/client.rs@@ -39,7 +39,7 @@ pub struct PaymentMethodClient<'a> {/// Parent headers to propagate to the microservice.pub parent_headers: &'a Headers,/// Trace configuration for request correlation.- pub trace: &'a RequestIdentifier,+ pub trace: RequestIdentifier,}impl<'a> PaymentMethodClient<'a> {@@ -47,8 +47,11 @@ impl<'a> PaymentMethodClient<'a> {pub fn new(base_url: &'a ModularPaymentMethodServiceUrl,parent_headers: &'a Headers,- trace: &'a RequestIdentifier,+ trace_header_name: &'a str,) -> Self {+ // For internal service calls, use the same request ID generated by the application.+ let trace = RequestIdentifier::new(trace_header_name)+ .use_incoming_id(router_env::IdReuse::UseIncoming);Self {base_url,parent_headers,@@ -67,6 +70,6 @@ impl MicroserviceClient for PaymentMethodClient<'_> {}fn trace(&self) -> &RequestIdentifier {- self.trace+ &self.trace}}diff --git a/crates/router/src/core/payment_methods/transformers.rs b/crates/router/src/core/payment_methods/transformers.rsindex e0ee249f48..527f993f31 100644--- a/crates/router/src/core/payment_methods/transformers.rs+++ b/crates/router/src/core/payment_methods/transformers.rs@@ -25,9 +25,9 @@ use payment_methods::client::{retrieve::{RetrievePaymentMethodResponse, RetrievePaymentMethodV1Request},UpdatePaymentMethod, UpdatePaymentMethodV1Payload, UpdatePaymentMethodV1Request,};-use router_env::RequestId;#[cfg(feature = "v1")]-use router_env::{logger, RequestIdentifier};+use router_env::logger;+use router_env::RequestId;use serde::{Deserialize, Serialize};use crate::{@@ -1173,12 +1173,10 @@ pub async fn call_modular_payment_method_update(.to_string().into_masked(),));- let trace = RequestIdentifier::new(&state.conf.trace_header.header_name)- .use_incoming_id(state.conf.trace_header.id_reuse_strategy);let client = pm_client::PaymentMethodClient::new(&state.conf.micro_services.payment_methods_base_url,&parent_headers,- &trace,+ &state.conf.trace_header.header_name,);UpdatePaymentMethod::call(@@ -1669,14 +1667,11 @@ pub async fn retrieve_pm_modular_service_call(.into_masked(),));- let trace = RequestIdentifier::new(&state.conf.trace_header.header_name)- .use_incoming_id(state.conf.trace_header.id_reuse_strategy);-//pm client constructionlet client = pm_client::PaymentMethodClient::new(&state.conf.micro_services.payment_methods_base_url,&parent_headers,- &trace,+ &state.conf.trace_header.header_name,);//Modular service call@@ -1759,14 +1754,11 @@ pub async fn create_pm_modular_service_call(merchant_id.get_string_repr().to_string().into_masked(),));- let trace = RequestIdentifier::new(&state.conf.trace_header.header_name)- .use_incoming_id(state.conf.trace_header.id_reuse_strategy);-//pm client constructionlet client = pm_client::PaymentMethodClient::new(&state.conf.micro_services.payment_methods_base_url,&parent_headers,- &trace,+ &state.conf.trace_header.header_name,);//Modular service call