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
feat(ucs): added upi_source in payment_method_data in sync response for v2 (#11019)
Kanika Chaudharyf7fc1fe626c9
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 55ade85863..8cb7649be9 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -38910,6 +38910,11 @@}],"nullable": true+ },+ "app_name": {+ "type": "string",+ "description": "App name for UPI intent payment",+ "nullable": true}}},@@ -38948,7 +38953,9 @@"UPI_CC","UPI_CL","UPI_ACCOUNT",- "UPI_CC_CL"+ "UPI_CC_CL",+ "UPI_PPI",+ "UPI_VOUCHER"]},"ValueType": {diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 76ba117518..0c1d9448b5 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -29776,6 +29776,11 @@}],"nullable": true+ },+ "app_name": {+ "type": "string",+ "description": "App name for UPI intent payment",+ "nullable": true}}},@@ -29814,7 +29819,9 @@"UPI_CC","UPI_CL","UPI_ACCOUNT",- "UPI_CC_CL"+ "UPI_CC_CL",+ "UPI_PPI",+ "UPI_VOUCHER"]},"ValueType": {diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 6efd7c67cd..1e93009ade 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -4676,6 +4676,10 @@ pub enum UpiSource {UpiAccount,/// UPI payment using a combination of credit card and credit lineUpiCcCl,+ /// UPI payment using a prepaid payment instrument+ UpiPpi,+ /// UPI payment using a voucher+ UpiVoucher,}#[derive(@@ -4714,6 +4718,8 @@ pub struct UpiIntentData {#[schema(value_type = Option<UpiSource>)]#[smithy(value_type = "Option<UpiSource>")]pub upi_source: Option<UpiSource>,+ /// App name for UPI intent payment+ pub app_name: Option<String>,}#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]diff --git a/crates/diesel_models/src/payment_attempt.rs b/crates/diesel_models/src/payment_attempt.rsindex e23cbe57c2..be84ed26f4 100644--- a/crates/diesel_models/src/payment_attempt.rs+++ b/crates/diesel_models/src/payment_attempt.rs@@ -979,7 +979,7 @@ pub struct PaymentAttemptUpdateInternal {// payment_token: Option<String>,pub error_code: Option<String>,pub connector_metadata: Option<pii::SecretSerdeValue>,- // payment_method_data: Option<serde_json::Value>,+ pub payment_method_data: Option<pii::SecretSerdeValue>,// payment_experience: Option<storage_enums::PaymentExperience>,// preprocessing_step_id: Option<String>,pub error_reason: Option<String>,@@ -1028,6 +1028,7 @@ impl PaymentAttemptUpdateInternal {error_code,cancellation_reason,connector_metadata,+ payment_method_data,error_reason,amount_capturable,amount_to_capture,@@ -1071,7 +1072,7 @@ impl PaymentAttemptUpdateInternal {payment_token: source.payment_token,connector_metadata: connector_metadata.or(source.connector_metadata),payment_experience: source.payment_experience,- payment_method_data: source.payment_method_data,+ payment_method_data: payment_method_data.or(source.payment_method_data),preprocessing_step_id: source.preprocessing_step_id,error_reason: error_reason.or(source.error_reason),multiple_capture_count: source.multiple_capture_count,@@ -1554,6 +1555,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {connector_request_reference_id: None,cancellation_reason: None,amount_captured,+ payment_method_data: None,}}PaymentAttemptUpdate::ErrorUpdate {@@ -1605,6 +1607,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {connector_response_reference_id,cancellation_reason: None,amount_captured,+ payment_method_data: None,}}PaymentAttemptUpdate::UnresolvedResponseUpdate {@@ -1652,6 +1655,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {connector_request_reference_id: None,cancellation_reason: None,amount_captured: None,+ payment_method_data: None,}}PaymentAttemptUpdate::PreprocessingUpdate {@@ -1697,6 +1701,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {connector_request_reference_id: None,cancellation_reason: None,amount_captured: None,+ payment_method_data: None,}}PaymentAttemptUpdate::ConnectorResponse {@@ -1738,6 +1743,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {connector_response_reference_id: None,cancellation_reason: None,amount_captured: None,+ payment_method_data: None,}}PaymentAttemptUpdate::ManualUpdate {@@ -1785,6 +1791,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {connector_response_reference_id: None,cancellation_reason: None,amount_captured: None,+ payment_method_data: None,}}}diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rsindex 1ae45e214f..357f6f564e 100644--- a/crates/hyperswitch_domain_models/src/payment_method_data.rs+++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs@@ -894,6 +894,8 @@ pub enum UpiSource {UpiCl, // UPI Credit LineUpiAccount, // UPI Bank Account (Savings)UpiCcCl, // UPI Credit Card + Credit Line+ UpiPpi, // UPI Prepaid Payment Instrument+ UpiVoucher, // UPI Voucher}impl From<api_models::payments::UpiSource> for UpiSource {@@ -903,6 +905,8 @@ impl From<api_models::payments::UpiSource> for UpiSource {api_models::payments::UpiSource::UpiCl => Self::UpiCl,api_models::payments::UpiSource::UpiAccount => Self::UpiAccount,api_models::payments::UpiSource::UpiCcCl => Self::UpiCcCl,+ api_models::payments::UpiSource::UpiPpi => Self::UpiPpi,+ api_models::payments::UpiSource::UpiVoucher => Self::UpiVoucher,}}}@@ -914,6 +918,8 @@ impl From<UpiSource> for api_models::payments::UpiSource {UpiSource::UpiCl => Self::UpiCl,UpiSource::UpiAccount => Self::UpiAccount,UpiSource::UpiCcCl => Self::UpiCcCl,+ UpiSource::UpiPpi => Self::UpiPpi,+ UpiSource::UpiVoucher => Self::UpiVoucher,}}}@@ -928,6 +934,7 @@ pub struct UpiCollectData {#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]pub struct UpiIntentData {pub upi_source: Option<UpiSource>,+ pub app_name: Option<String>,}#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]@@ -1863,6 +1870,7 @@ impl From<api_models::payments::UpiData> for UpiData {}),api_models::payments::UpiData::UpiIntent(upi) => Self::UpiIntent(UpiIntentData {upi_source: upi.upi_source.map(UpiSource::from),+ app_name: upi.app_name,}),api_models::payments::UpiData::UpiQr(upi) => Self::UpiQr(UpiQrData {upi_source: upi.upi_source.map(UpiSource::from),@@ -1883,6 +1891,7 @@ impl From<UpiData> for api_models::payments::additional_info::UpiAdditionalDataUpiData::UpiIntent(upi) => {Self::UpiIntent(Box::new(api_models::payments::UpiIntentData {upi_source: upi.upi_source.map(api_models::payments::UpiSource::from),+ app_name: upi.app_name,}))}UpiData::UpiQr(upi) => Self::UpiQr(Box::new(api_models::payments::UpiQrData {diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rsindex 62ddae7560..9d4fd0b3d0 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs@@ -1,5 +1,7 @@#[cfg(all(feature = "v1", feature = "olap"))]use api_models::enums::Connector;+#[cfg(feature = "v2")]+use api_models::payments::{additional_info::UpiAdditionalData, AdditionalPaymentData};use common_enums as storage_enums;#[cfg(feature = "v2")]use common_types::payments as common_payments_types;@@ -34,6 +36,8 @@ use diesel_models::{PaymentAttemptRecoveryData as DieselPassiveChurnRecoveryData,};use error_stack::ResultExt;+#[cfg(feature = "v2")]+use masking::ExposeInterface;use masking::{PeekInterface, Secret};#[cfg(feature = "v1")]use router_env::logger;@@ -48,7 +52,9 @@ use url::Url;#[cfg(all(feature = "v1", feature = "olap"))]use super::PaymentIntent;#[cfg(feature = "v2")]-use crate::{address::Address, consts, router_response_types};+use crate::{+ address::Address, consts, payment_method_data::PaymentMethodData, router_response_types,+};use crate::{behaviour, errors,merchant_key_store::MerchantKeyStore,@@ -866,6 +872,32 @@ impl PaymentAttempt {self.connector_payment_id.as_deref()}+ /// Extract and encode additional_payment_method_data (only non-sensitive data like upi_source, masked vpa_id)+ /// We should NOT store raw payment_method_data as it may contain sensitive info+ #[cfg(feature = "v2")]+ fn get_additional_payment_method_data(+ payment_method_data: Option<api_models::payments::PaymentMethodData>,+ ) -> CustomResult<Option<pii::SecretSerdeValue>, errors::api_error_response::ApiErrorResponse>+ {+ let additional_data: Option<AdditionalPaymentData> =+ payment_method_data.and_then(|api_pmd| {+ let domain_pmd = PaymentMethodData::from(api_pmd);+ match domain_pmd {+ PaymentMethodData::Upi(upi) => Some(AdditionalPaymentData::Upi {+ details: Some(UpiAdditionalData::from(upi)),+ }),+ _ => None,+ }+ });++ Ok(additional_data+ .map(|data| data.encode_to_value())+ .transpose()+ .change_context(errors::api_error_response::ApiErrorResponse::InternalServerError)+ .attach_printable("Failed to encode additional payment method data")?+ .map(pii::SecretSerdeValue::new))+ }+/// Construct the domain model from the ConfirmIntentRequest and PaymentIntent#[cfg(feature = "v2")]pub async fn create_domain_model(@@ -902,6 +934,10 @@ impl PaymentAttempt {let authentication_type = payment_intent.authentication_type.unwrap_or_default();+ let payment_method_data = Self::get_additional_payment_method_data(+ request.payment_method_data.payment_method_data.clone(),+ )?;+Ok(Self {payment_id: payment_intent.id.clone(),merchant_id: payment_intent.merchant_id.clone(),@@ -920,7 +956,7 @@ impl PaymentAttempt {payment_token: request.payment_token.clone(),connector_metadata: None,payment_experience: None,- payment_method_data: None,+ payment_method_data,routing_result: None,preprocessing_step_id: None,multiple_capture_count: None,@@ -1556,6 +1592,25 @@ impl PaymentAttempt {.map(|metadata| metadata.peek())}+ /// Get the additional payment method data from the payment attempt+ pub fn get_payment_method_data(+ &self,+ ) -> CustomResult<Option<AdditionalPaymentData>, errors::api_error_response::ApiErrorResponse>+ {+ self.payment_method_data+ .as_ref()+ .and_then(|data| {+ let value = data.clone().expose();+ match value {+ Value::Null => None,+ _ => Some(value.parse_value("AdditionalPaymentData")),+ }+ })+ .transpose()+ .change_context(errors::api_error_response::ApiErrorResponse::InternalServerError)+ .attach_printable("Failed to parse AdditionalPaymentData from payment_method_data")+ }+pub fn get_upi_next_action(&self,) -> CustomResult<@@ -2616,6 +2671,7 @@ pub struct ConfirmIntentResponseUpdate {pub connector_token_details: Option<diesel_models::ConnectorTokenDetails>,pub connector_response_reference_id: Option<String>,pub amount_captured: Option<MinorUnit>,+ pub payment_method_data: Option<pii::SecretSerdeValue>,}#[cfg(feature = "v2")]@@ -2649,6 +2705,7 @@ pub enum PaymentAttemptUpdate {amount_capturable: Option<MinorUnit>,updated_by: String,amount_captured: Option<MinorUnit>,+ payment_method_data: Option<Value>,},PreCaptureUpdate {amount_to_capture: Option<MinorUnit>,@@ -2664,10 +2721,11 @@ pub enum PaymentAttemptUpdate {ErrorUpdate {status: storage_enums::AttemptStatus,amount_capturable: Option<MinorUnit>,- error: ErrorDetails,+ error: Box<ErrorDetails>,updated_by: String,connector_payment_id: Option<String>,connector_response_reference_id: Option<String>,+ payment_method_data: Option<pii::SecretSerdeValue>,},VoidUpdate {status: storage_enums::AttemptStatus,@@ -3548,6 +3606,7 @@ impl From<PaymentAttemptUpdate> for diesel_models::PaymentAttemptUpdateInternalconnector_response_reference_id,cancellation_reason: None,amount_captured: None,+ payment_method_data: None,},PaymentAttemptUpdate::ErrorUpdate {status,@@ -3556,6 +3615,7 @@ impl From<PaymentAttemptUpdate> for diesel_models::PaymentAttemptUpdateInternalconnector_response_reference_id,amount_capturable,updated_by,+ payment_method_data,} => {// Apply automatic hashing for long connector payment IDslet (connector_payment_id, connector_payment_data) = connector_payment_id@@ -3592,6 +3652,7 @@ impl From<PaymentAttemptUpdate> for diesel_models::PaymentAttemptUpdateInternalconnector_response_reference_id,cancellation_reason: None,amount_captured: None,+ payment_method_data,}}PaymentAttemptUpdate::ConfirmIntentResponse(confirm_intent_response_update) => {@@ -3605,6 +3666,7 @@ impl From<PaymentAttemptUpdate> for diesel_models::PaymentAttemptUpdateInternalconnector_token_details,connector_response_reference_id,amount_captured,+ payment_method_data,} = *confirm_intent_response_update;// Apply automatic hashing for long connector payment IDs@@ -3642,6 +3704,7 @@ impl From<PaymentAttemptUpdate> for diesel_models::PaymentAttemptUpdateInternalconnector_response_reference_id,cancellation_reason: None,amount_captured: None,+ payment_method_data,}}PaymentAttemptUpdate::SyncUpdate {@@ -3649,6 +3712,7 @@ impl From<PaymentAttemptUpdate> for diesel_models::PaymentAttemptUpdateInternalamount_capturable,updated_by,amount_captured,+ payment_method_data,} => Self {status: Some(status),payment_method_id: None,@@ -3678,6 +3742,7 @@ impl From<PaymentAttemptUpdate> for diesel_models::PaymentAttemptUpdateInternalconnector_response_reference_id: None,cancellation_reason: None,amount_captured,+ payment_method_data: payment_method_data.map(pii::SecretSerdeValue::new),},PaymentAttemptUpdate::CaptureUpdate {status,@@ -3712,6 +3777,7 @@ impl From<PaymentAttemptUpdate> for diesel_models::PaymentAttemptUpdateInternalconnector_response_reference_id: None,cancellation_reason: None,amount_captured: None,+ payment_method_data: None,},PaymentAttemptUpdate::PreCaptureUpdate {amount_to_capture,@@ -3745,6 +3811,7 @@ impl From<PaymentAttemptUpdate> for diesel_models::PaymentAttemptUpdateInternalconnector_response_reference_id: None,cancellation_reason: None,amount_captured: None,+ payment_method_data: None,},PaymentAttemptUpdate::ConfirmIntentTokenized {status,@@ -3783,6 +3850,7 @@ impl From<PaymentAttemptUpdate> for diesel_models::PaymentAttemptUpdateInternalconnector_response_reference_id: None,cancellation_reason: None,amount_captured: None,+ payment_method_data: None,},PaymentAttemptUpdate::VoidUpdate {status,@@ -3817,6 +3885,7 @@ impl From<PaymentAttemptUpdate> for diesel_models::PaymentAttemptUpdateInternalconnector_response_reference_id: None,payment_method_id: None,amount_captured: None,+ payment_method_data: None,},}}diff --git a/crates/hyperswitch_domain_models/src/router_data.rs b/crates/hyperswitch_domain_models/src/router_data.rsindex c772aeca07..84f4e111fc 100644--- a/crates/hyperswitch_domain_models/src/router_data.rs+++ b/crates/hyperswitch_domain_models/src/router_data.rs@@ -725,6 +725,10 @@ pub enum AdditionalPaymentMethodConnectorResponse {BankRedirect {interac: Option<InteracCustomerInfo>,},+ Upi {+ /// UPI mode detected from the connector response+ upi_mode: Option<payment_method_data::UpiSource>,+ },GooglePay {auth_code: Option<String>,},@@ -962,6 +966,10 @@ implconnector_response_reference_id: connector_response_reference_id.clone(),amount_captured,+ payment_method_data: payment_data+ .payment_attempt+ .payment_method_data+ .clone(),},))}@@ -1034,11 +1042,12 @@ implPaymentAttemptUpdate::ErrorUpdate {status: attempt_status,- error: error_details,+ error: Box::new(error_details),amount_capturable,connector_payment_id: connector_transaction_id,connector_response_reference_id,updated_by: storage_scheme.to_string(),+ payment_method_data: payment_data.payment_attempt.payment_method_data.clone(),}}}@@ -1354,11 +1363,12 @@ implPaymentAttemptUpdate::ErrorUpdate {status: attempt_status,- error: error_details,+ error: Box::new(error_details),amount_capturable,connector_payment_id: connector_transaction_id,connector_response_reference_id,updated_by: storage_scheme.to_string(),+ payment_method_data: payment_data.payment_attempt.payment_method_data.clone(),}}}@@ -1600,11 +1610,19 @@ implrouter_response_types::PaymentsResponseData::TransactionResponse { .. } => {let attempt_status = self.get_attempt_status_for_db_update(payment_data);+ // Extract payment_method_data from payment_attempt (already updated with connector response data in PostUpdateTracker)+ let payment_method_data = payment_data+ .payment_attempt+ .payment_method_data+ .as_ref()+ .map(|data| data.clone().expose());+PaymentAttemptUpdate::SyncUpdate {status: attempt_status,amount_capturable,updated_by: storage_scheme.to_string(),amount_captured,+ payment_method_data,}}router_response_types::PaymentsResponseData::MultipleCaptureResponse { .. } => {@@ -1677,11 +1695,12 @@ implPaymentAttemptUpdate::ErrorUpdate {status: attempt_status,- error: error_details,+ error: Box::new(error_details),amount_capturable,connector_payment_id: connector_transaction_id,connector_response_reference_id,updated_by: storage_scheme.to_string(),+ payment_method_data: payment_data.payment_attempt.payment_method_data.clone(),}}}@@ -1890,6 +1909,10 @@ implconnector_response_reference_id: connector_response_reference_id.clone(),amount_captured,+ payment_method_data: payment_data+ .payment_attempt+ .payment_method_data+ .clone(),},))}@@ -1962,11 +1985,12 @@ implPaymentAttemptUpdate::ErrorUpdate {status: attempt_status,- error: error_details,+ error: Box::new(error_details),amount_capturable,connector_payment_id: connector_transaction_id,connector_response_reference_id,updated_by: storage_scheme.to_string(),+ payment_method_data: payment_data.payment_attempt.payment_method_data.clone(),}}}@@ -2139,6 +2163,10 @@ impl),connector_response_reference_id: None,amount_captured,+ payment_method_data: payment_data+ .payment_attempt+ .payment_method_data+ .clone(),},))}@@ -2204,11 +2232,12 @@ implPaymentAttemptUpdate::ErrorUpdate {status: attempt_status,- error: error_details,+ error: Box::new(error_details),amount_capturable,connector_payment_id: connector_transaction_id,connector_response_reference_id,updated_by: storage_scheme.to_string(),+ payment_method_data: payment_data.payment_attempt.payment_method_data.clone(),}}}@@ -2387,10 +2416,11 @@ implPaymentAttemptUpdate::ErrorUpdate {status,amount_capturable: Some(MinorUnit::zero()),- error: error_details,+ error: Box::new(error_details),updated_by: storage_scheme.to_string(),connector_payment_id: connector_transaction_id,connector_response_reference_id,+ payment_method_data: payment_data.payment_attempt.payment_method_data.clone(),}}Ok(ref _response) => PaymentAttemptUpdate::VoidUpdate {diff --git a/crates/hyperswitch_interfaces/src/helpers.rs b/crates/hyperswitch_interfaces/src/helpers.rsindex 0d0d5b0b12..4f80e2ab4e 100644--- a/crates/hyperswitch_interfaces/src/helpers.rs+++ b/crates/hyperswitch_interfaces/src/helpers.rs@@ -16,6 +16,12 @@ pub trait ForeignTryFrom<F>: Sized {fn foreign_try_from(from: F) -> Result<Self, Self::Error>;}+/// Trait for infallibly converting from one foreign type to another+pub trait ForeignFrom<F>: Sized {+ /// Convert from a foreign type to the current type+ fn foreign_from(from: F) -> Self;+}+/// Data structure to hold comparison data between Hyperswitch and UCS#[derive(serde::Serialize, Debug)]pub struct ComparisonData {diff --git a/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs b/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rsindex beacd2cec4..10b628377d 100644--- a/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs+++ b/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs@@ -10,7 +10,10 @@ use hyperswitch_domain_models::{router_response_types::{PaymentsResponseData, RedirectForm},};-use crate::{helpers::ForeignTryFrom, unified_connector_service::payments_grpc};+use crate::{+ helpers::{ForeignFrom, ForeignTryFrom},+ unified_connector_service::payments_grpc,+};/// Unified Connector Service error variants#[derive(Debug, Clone, thiserror::Error)]@@ -401,16 +404,17 @@ impl ForeignTryFrom<payments_grpc::AdditionalPaymentMethodConnectorResponse>domestic_network: card_data.domestic_network,auth_code: card_data.auth_code,}),- Some(- payments_grpc::additional_payment_method_connector_response::PaymentMethodData::Upi(- _,- ),- ) => {- // Upi variant to be updated during #11019 PR merge- Err(UnifiedConnectorServiceError::NotImplemented(- "UPI payment method data deserialization".to_string(),- )- .into())+ Some(payments_grpc::additional_payment_method_connector_response::PaymentMethodData::Upi(upi_data)) => {+ let upi_mode = upi_data+ .upi_mode+ .map(|mode| {+ payments_grpc::UpiSource::try_from(mode)+ .change_context(UnifiedConnectorServiceError::ParsingFailed)+ .attach_printable("Failed to parse upi_mode from UCS connector response")+ })+ .transpose()?+ .map(hyperswitch_domain_models::payment_method_data::UpiSource::foreign_from);+ Ok(Self::Upi { upi_mode })}Some(payments_grpc::additional_payment_method_connector_response::PaymentMethodData::GooglePay(@@ -727,3 +731,18 @@ impl ForeignTryFrom<payments_grpc::HttpMethod> for Method {}}}++impl ForeignFrom<payments_grpc::UpiSource>+ for hyperswitch_domain_models::payment_method_data::UpiSource+{+ fn foreign_from(upi_source: payments_grpc::UpiSource) -> Self {+ match upi_source {+ payments_grpc::UpiSource::UpiCc => Self::UpiCc,+ payments_grpc::UpiSource::UpiCl => Self::UpiCl,+ payments_grpc::UpiSource::UpiAccount => Self::UpiAccount,+ payments_grpc::UpiSource::UpiCcCl => Self::UpiCcCl,+ payments_grpc::UpiSource::UpiPpi => Self::UpiPpi,+ payments_grpc::UpiSource::UpiVoucher => Self::UpiVoucher,+ }+ }+}diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rsindex 80b707ef28..8c0a16e3c0 100644--- a/crates/router/src/compatibility/stripe/payment_intents/types.rs+++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs@@ -959,7 +959,10 @@ fn get_pmd_based_on_payment_method_type() -> Option<payments::PaymentMethodData> {match payment_method_type {Some(api_enums::PaymentMethodType::UpiIntent) => Some(payments::PaymentMethodData::Upi(- payments::UpiData::UpiIntent(payments::UpiIntentData { upi_source: None }),+ payments::UpiData::UpiIntent(payments::UpiIntentData {+ upi_source: None,+ app_name: None,+ }),)),Some(api_enums::PaymentMethodType::Fps) => {Some(payments::PaymentMethodData::RealTimePayment(Box::new(diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 1fc2a17f85..867ef3c9d7 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -6,6 +6,8 @@ pub use ::payment_methods::helpers::{};#[cfg(feature = "v2")]use api_models::ephemeral_key::ClientSecretResponse;+#[cfg(feature = "v2")]+use api_models::payments::{additional_info::UpiAdditionalData, UpiSource};use api_models::{customers::CustomerDocumentDetails,mandates::RecurringDetails,@@ -7621,6 +7623,39 @@ pub fn add_connector_response_to_additional_payment_data(}),samsung_pay: samsung_pay.clone(),},+ #[cfg(feature = "v2")]+ (+ api_models::payments::AdditionalPaymentData::Upi {+ details: Some(details),+ },+ AdditionalPaymentMethodConnectorResponse::Upi {+ upi_mode: Some(upi_mode),+ },+ ) => {+ let upi_source = Some(UpiSource::from(upi_mode));+ let updated_details = match details {+ UpiAdditionalData::UpiCollect(_) => UpiAdditionalData::UpiCollect(Box::new(+ api_models::payments::additional_info::UpiCollectAdditionalData {+ vpa_id: None,+ upi_source,+ },+ )),+ UpiAdditionalData::UpiIntent(_) => {+ UpiAdditionalData::UpiIntent(Box::new(api_models::payments::UpiIntentData {+ upi_source,+ app_name: None,+ }))+ }+ UpiAdditionalData::UpiQr(_) => {+ UpiAdditionalData::UpiQr(Box::new(api_models::payments::UpiQrData {+ upi_source,+ }))+ }+ };+ api_models::payments::AdditionalPaymentData::Upi {+ details: Some(updated_details),+ }+ }_ => additional_payment_data,}diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rsindex 2754a646d5..dbf9aa1ca3 100644--- a/crates/router/src/core/payments/operations/payment_response.rs+++ b/crates/router/src/core/payments/operations/payment_response.rs@@ -25,7 +25,7 @@ use hyperswitch_domain_models::payments::{};use hyperswitch_domain_models::{behaviour::Conversion, payments::payment_attempt::PaymentAttempt};#[cfg(feature = "v2")]-use masking::PeekInterface;+use masking::{ExposeInterface, PeekInterface};use router_derive;use router_env::{instrument, logger, tracing};#[cfg(feature = "v1")]@@ -1938,13 +1938,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>().await?;- router_data.payment_method_status.and_then(|status| {- payment_data- .payment_method_info- .as_mut()- .map(|info| info.status = status)- });- payment_data.whole_connector_response = router_data.raw_connector_response.clone();+ let payment_method_status = router_data.payment_method_status;// TODO: refactor of gsm_error_category with respective feature flag#[allow(unused_variables)]@@ -2790,7 +2784,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(payment_data.payment_intent = payment_intent;payment_data.payment_attempt = payment_attempt;- router_data.payment_method_status.and_then(|status| {+ payment_method_status.and_then(|status| {payment_data.payment_method_info.as_mut()@@ -3239,6 +3233,27 @@ impl<F: Clone> PostUpdateTracker<F, PaymentStatusData<F>, types::PaymentsSyncDatlet response_router_data = response;+ // Get updated additional payment method data from connector response+ let updated_payment_method_data = payment_data+ .payment_attempt+ .payment_method_data+ .as_ref()+ .map(|existing_payment_method_data| {+ let additional_payment_data_value =+ Some(existing_payment_method_data.clone().expose());+ update_additional_payment_data_with_connector_response_pm_data(+ additional_payment_data_value,+ response_router_data.connector_response.as_ref().and_then(+ |connector_response| {+ connector_response.additional_payment_method_data.clone()+ },+ ),+ )+ })+ .transpose()?+ .flatten()+ .map(common_utils::pii::SecretSerdeValue::new);+let payment_intent_update = response_router_data.get_payment_intent_update(&payment_data, processor.get_account().storage_scheme);let payment_attempt_update = response_router_datadiff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex ab631301be..2d8ff85e19 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -3089,15 +3089,24 @@ where.collect()});- let payment_method_data =- Some(api_models::payments::PaymentMethodDataResponseWithBilling {- payment_method_data: None,- billing: self- .payment_address- .get_request_payment_method_billing()- .cloned()- .map(From::from),- });+ let additional_payment_method_data = payment_attempt.get_payment_method_data()?;++ let payment_method_data_inner =+ additional_payment_method_data.map(api::PaymentMethodDataResponse::from);++ let payment_method_data = (payment_method_data_inner.is_some()+ || self+ .payment_address+ .get_request_payment_method_billing()+ .is_some())+ .then_some(api_models::payments::PaymentMethodDataResponseWithBilling {+ payment_method_data: payment_method_data_inner,+ billing: self+ .payment_address+ .get_request_payment_method_billing()+ .cloned()+ .map(From::from),+ });let raw_connector_response =connector_response_data.and_then(|data| data.raw_connector_response);diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rsindex 3e43f91230..e69c58f42d 100644--- a/crates/router/src/core/unified_connector_service.rs+++ b/crates/router/src/core/unified_connector_service.rs@@ -694,7 +694,7 @@ pub fn build_unified_connector_service_payment_method(}hyperswitch_domain_models::payment_method_data::UpiData::UpiIntent(upi_intent_data) => {let upi_details = payments_grpc::UpiIntent {- app_name: None,+ app_name: upi_intent_data.app_name,upi_source: upi_intent_data.upi_source.map(payments_grpc::UpiSource::foreign_try_from)diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rsindex e0cf790868..4cbf635e2d 100644--- a/crates/router/src/core/unified_connector_service/transformers.rs+++ b/crates/router/src/core/unified_connector_service/transformers.rs@@ -3097,6 +3097,10 @@ impl transformers::ForeignTryFrom<hyperswitch_domain_models::payment_method_dataOk(Self::UpiAccount)}hyperswitch_domain_models::payment_method_data::UpiSource::UpiCcCl => Ok(Self::UpiCcCl),+ hyperswitch_domain_models::payment_method_data::UpiSource::UpiPpi => Ok(Self::UpiPpi),+ hyperswitch_domain_models::payment_method_data::UpiSource::UpiVoucher => {+ Ok(Self::UpiVoucher)+ }}}}