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
fix(core): fetch customer id from customer object during MIT (#5218)
chikke srujana79437d5f078
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 2db808722a..f367762c99 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -505,10 +505,7 @@ pub async fn get_token_pm_type_mandate_details(.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound,)?;-- let customer_id = request- .customer_id- .clone()+ let customer_id = get_customer_id_from_payment_request(request).get_required_value("customer_id")?;verify_mandate_details_for_recurring_payments(@@ -555,8 +552,10 @@ pub async fn get_token_pm_type_mandate_details(|| request.payment_method_type== Some(api_models::enums::PaymentMethodType::GooglePay){+ let payment_request_customer_id =+ get_customer_id_from_payment_request(request);if let Some(customer_id) =- &request.customer_id.clone().or(customer_id.clone())+ &payment_request_customer_id.or(customer_id.clone()){let customer_saved_pm_option = match state.store@@ -712,8 +711,7 @@ pub async fn get_token_for_recurring_mandate(.map(|pi| pi.amount.get_amount_as_i64());let original_payment_authorized_currency =original_payment_intent.clone().and_then(|pi| pi.currency);-- let customer = req.customer_id.clone().get_required_value("customer_id")?;+ let customer = get_customer_id_from_payment_request(req).get_required_value("customer_id")?;let payment_method_id = {if mandate.customer_id != customer {@@ -1578,6 +1576,16 @@ pub fn get_customer_details_from_request(}}+fn get_customer_id_from_payment_request(+ request: &api_models::payments::PaymentsRequest,+) -> Option<id_type::CustomerId> {+ request+ .customer+ .as_ref()+ .map(|customer| customer.id.clone())+ .or(request.customer_id.clone())+}+pub async fn get_connector_default(_state: &SessionState,request_connector: Option<serde_json::Value>,