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): add new next_action type and wait screen instructions for upi payments (#10323)
kanikac199fc26034ffcbd
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex e2e9f8e724..127cddc2f8 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -22808,19 +22808,68 @@},{"type": "object",- "description": "Contains the SDK UPI intent URI for payment processing","required": ["sdk_uri",+ "display_from_timestamp","type"],"properties": {"sdk_uri": {"type": "string"},+ "display_from_timestamp": {+ "type": "integer"+ },+ "display_to_timestamp": {+ "type": "integer",+ "nullable": true+ },+ "poll_config": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PollConfig"+ }+ ],+ "nullable": true+ },+ "type": {+ "type": "string",+ "enum": [+ "invoke_upi_intent_sdk"+ ]+ }+ }+ },+ {+ "type": "object",+ "required": [+ "qr_code_url",+ "display_from_timestamp",+ "type"+ ],+ "properties": {+ "qr_code_url": {+ "type": "string"+ },+ "display_from_timestamp": {+ "type": "integer"+ },+ "display_to_timestamp": {+ "type": "integer",+ "nullable": true+ },+ "poll_config": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PollConfig"+ }+ ],+ "nullable": true+ },"type": {"type": "string","enum": [- "sdk_upi_intent_information"+ "invoke_upi_qr_flow"]}}@@ -22965,7 +23014,9 @@"display_bank_transfer_information","display_wait_screen","collect_otp",- "redirect_inside_popup"+ "redirect_inside_popup",+ "invoke_upi_intent_sdk",+ "invoke_upi_qr_flow"]},"NoThirdPartySdkSessionResponse": {diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 35f40f9998..798a87b5ac 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -16133,19 +16133,68 @@},{"type": "object",- "description": "Contains the SDK UPI intent URI for payment processing","required": ["sdk_uri",+ "display_from_timestamp","type"],"properties": {"sdk_uri": {"type": "string"},+ "display_from_timestamp": {+ "type": "integer"+ },+ "display_to_timestamp": {+ "type": "integer",+ "nullable": true+ },+ "poll_config": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PollConfig"+ }+ ],+ "nullable": true+ },+ "type": {+ "type": "string",+ "enum": [+ "invoke_upi_intent_sdk"+ ]+ }+ }+ },+ {+ "type": "object",+ "required": [+ "qr_code_url",+ "display_from_timestamp",+ "type"+ ],+ "properties": {+ "qr_code_url": {+ "type": "string"+ },+ "display_from_timestamp": {+ "type": "integer"+ },+ "display_to_timestamp": {+ "type": "integer",+ "nullable": true+ },+ "poll_config": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PollConfig"+ }+ ],+ "nullable": true+ },"type": {"type": "string","enum": [- "sdk_upi_intent_information"+ "invoke_upi_qr_flow"]}}@@ -16290,7 +16339,9 @@"display_bank_transfer_information","display_wait_screen","collect_otp",- "redirect_inside_popup"+ "redirect_inside_popup",+ "invoke_upi_intent_sdk",+ "invoke_upi_qr_flow"]},"NoThirdPartySdkSessionResponse": {diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 2cc3bcf022..3124331976 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -6300,6 +6300,8 @@ pub enum NextActionType {DisplayWaitScreen,CollectOtp,RedirectInsidePopup,+ InvokeUpiIntentSdk,+ InvokeUpiQrFlow,}#[derive(@@ -6360,10 +6362,25 @@ pub enum NextActionData {#[smithy(value_type = "String")]qr_code_fetch_url: Url,},- /// Contains the SDK UPI intent URI for payment processing- SdkUpiIntentInformation {+ InvokeUpiIntentSdk {#[schema(value_type = String)]sdk_uri: Url,+ #[smithy(value_type = "i128")]+ display_from_timestamp: i128,+ #[smithy(value_type = "Option<i128>")]+ display_to_timestamp: Option<i128>,+ #[smithy(value_type = "Option<PollConfig>")]+ poll_config: Option<PollConfig>,+ },+ InvokeUpiQrFlow {+ #[schema(value_type = String)]+ qr_code_url: Url,+ #[smithy(value_type = "i128")]+ display_from_timestamp: i128,+ #[smithy(value_type = "Option<i128>")]+ display_to_timestamp: Option<i128>,+ #[smithy(value_type = "Option<PollConfig>")]+ poll_config: Option<PollConfig>,},/// Contains the download url and the reference number for transactionDisplayVoucherInformation {@@ -6559,11 +6576,6 @@ pub struct FetchQrCodeInformation {pub qr_code_fetch_url: Url,}-#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]-pub struct SdkUpiIntentInformation {- pub sdk_uri: Url,-}-#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel,)]@@ -6627,13 +6639,46 @@ pub struct QrCodeNextStepsInstruction {pub qr_code_url: Option<Url>,}-#[derive(Clone, Debug, serde::Deserialize)]+#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]pub struct WaitScreenInstructions {pub display_from_timestamp: i128,pub display_to_timestamp: Option<i128>,pub poll_config: Option<PollConfig>,}+#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]+pub struct SdkUpiUriInformation {+ pub sdk_uri: String,+}++impl NextActionData {+ pub fn from_upi_intent(sdk_uri: Url, wait_info: WaitScreenInstructions) -> Self {+ Self::InvokeUpiIntentSdk {+ sdk_uri,+ display_from_timestamp: wait_info.display_from_timestamp,+ display_to_timestamp: wait_info.display_to_timestamp,+ poll_config: wait_info.poll_config,+ }+ }++ pub fn from_upi_qr(qr_code_url: Url, wait_info: WaitScreenInstructions) -> Self {+ Self::InvokeUpiQrFlow {+ qr_code_url,+ display_from_timestamp: wait_info.display_from_timestamp,+ display_to_timestamp: wait_info.display_to_timestamp,+ poll_config: wait_info.poll_config,+ }+ }++ pub fn from_wait_screen(wait_info: WaitScreenInstructions) -> Self {+ Self::WaitScreenInformation {+ display_from_timestamp: wait_info.display_from_timestamp,+ display_to_timestamp: wait_info.display_to_timestamp,+ poll_config: wait_info.poll_config,+ }+ }+}+#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel,)]diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rsindex cd277af5fc..359f7c0d14 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs@@ -47,6 +47,7 @@ use serde::Serialize;#[cfg(feature = "v2")]use serde_json::Value;use time::PrimitiveDateTime;+use url::Url;#[cfg(all(feature = "v1", feature = "olap"))]use super::PaymentIntent;@@ -1208,6 +1209,75 @@ impl PaymentAttempt {pub fn extract_card_network(&self) -> Option<common_enums::CardNetwork> {todo!()}++ fn get_connector_metadata_value(&self) -> Option<&Value> {+ self.connector_metadata+ .as_ref()+ .map(|metadata| metadata.peek())+ }++ pub fn get_upi_next_action(+ &self,+ ) -> CustomResult<+ Option<api_models::payments::NextActionData>,+ errors::api_error_response::ApiErrorResponse,+ > {+ let sdk_uri_opt = self+ .get_connector_metadata_value()+ .and_then(|metadata| metadata.get("SdkUpiUriInformation"))+ .map(|uri_info_value| {+ serde_json::from_value::<api_models::payments::SdkUpiUriInformation>(+ uri_info_value.clone(),+ )+ .change_context(errors::api_error_response::ApiErrorResponse::InternalServerError)+ .and_then(|uri_info| {+ Url::parse(&uri_info.sdk_uri).change_context(+ errors::api_error_response::ApiErrorResponse::InternalServerError,+ )+ })+ })+ .transpose()+ .attach_printable("Failed to parse SdkUpiUriInformation from connector_metadata")?;++ let wait_screen_info = self+ .get_connector_metadata_value()+ .and_then(|metadata| metadata.get("WaitScreenInstructions"))+ .map(|wait_screen_value| {+ serde_json::from_value::<api_models::payments::WaitScreenInstructions>(+ wait_screen_value.clone(),+ )+ })+ .transpose()+ .change_context(errors::api_error_response::ApiErrorResponse::InternalServerError)+ .attach_printable(+ "Failed to deserialize WaitScreenInstructions from connector_metadata",+ )?;++ Ok(+ match (self.payment_method_type, self.payment_method_subtype) {+ (+ storage_enums::PaymentMethod::Upi,+ storage_enums::PaymentMethodType::UpiIntent,+ ) => sdk_uri_opt+ .zip(wait_screen_info)+ .map(|(sdk_uri, wait_info)| {+ api_models::payments::NextActionData::from_upi_intent(sdk_uri, wait_info)+ }),+ (storage_enums::PaymentMethod::Upi, storage_enums::PaymentMethodType::UpiQr) => {+ sdk_uri_opt+ .zip(wait_screen_info)+ .map(|(sdk_uri, wait_info)| {+ api_models::payments::NextActionData::from_upi_qr(sdk_uri, wait_info)+ })+ }+ (+ storage_enums::PaymentMethod::Upi,+ storage_enums::PaymentMethodType::UpiCollect,+ ) => wait_screen_info.map(api_models::payments::NextActionData::from_wait_screen),+ _ => None,+ },+ )+ }}#[cfg(feature = "v1")]@@ -1263,6 +1333,71 @@ impl PaymentAttempt {),}}++ fn get_connector_metadata_value(&self) -> Option<&serde_json::Value> {+ self.connector_metadata.as_ref()+ }+ pub fn get_upi_next_action(+ &self,+ ) -> CustomResult<+ Option<api_models::payments::NextActionData>,+ errors::api_error_response::ApiErrorResponse,+ > {+ let sdk_uri_opt = self+ .get_connector_metadata_value()+ .and_then(|metadata| metadata.get("SdkUpiUriInformation"))+ .map(|uri_info_value| {+ serde_json::from_value::<api_models::payments::SdkUpiUriInformation>(+ uri_info_value.clone(),+ )+ .change_context(errors::api_error_response::ApiErrorResponse::InternalServerError)+ .and_then(|uri_info| {+ Url::parse(&uri_info.sdk_uri).change_context(+ errors::api_error_response::ApiErrorResponse::InternalServerError,+ )+ })+ })+ .transpose()+ .attach_printable("Failed to parse SdkUpiUriInformation from connector_metadata")?;++ let wait_screen_info = self+ .get_connector_metadata_value()+ .and_then(|metadata| metadata.get("WaitScreenInstructions"))+ .map(|wait_screen_value| {+ serde_json::from_value::<api_models::payments::WaitScreenInstructions>(+ wait_screen_value.clone(),+ )+ })+ .transpose()+ .change_context(errors::api_error_response::ApiErrorResponse::InternalServerError)+ .attach_printable(+ "Failed to deserialize WaitScreenInstructions from connector_metadata",+ )?;++ Ok(match (self.payment_method, self.payment_method_type) {+ (+ Some(storage_enums::PaymentMethod::Upi),+ Some(storage_enums::PaymentMethodType::UpiIntent),+ ) => sdk_uri_opt+ .zip(wait_screen_info)+ .map(|(sdk_uri, wait_info)| {+ api_models::payments::NextActionData::from_upi_intent(sdk_uri, wait_info)+ }),+ (+ Some(storage_enums::PaymentMethod::Upi),+ Some(storage_enums::PaymentMethodType::UpiQr),+ ) => sdk_uri_opt+ .zip(wait_screen_info)+ .map(|(sdk_uri, wait_info)| {+ api_models::payments::NextActionData::from_upi_qr(sdk_uri, wait_info)+ }),+ (+ Some(storage_enums::PaymentMethod::Upi),+ Some(storage_enums::PaymentMethodType::UpiCollect),+ ) => wait_screen_info.map(api_models::payments::NextActionData::from_wait_screen),+ _ => None,+ })+ }}#[derive(Clone, Debug, Eq, PartialEq)]diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rsindex ae1258d103..f0685dfd5b 100644--- a/crates/router/src/compatibility/stripe/payment_intents/types.rs+++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs@@ -851,7 +851,10 @@ pub enum StripeNextAction {InvokeHiddenIframe {iframe_data: payments::IframeData,},- SdkUpiIntentInformation {+ InvokeUpiIntentSdk {+ sdk_uri: url::Url,+ },+ InvokeUpiQrFlow {sdk_uri: url::Url,},}@@ -931,8 +934,13 @@ pub(crate) fn into_stripe_next_action(payments::NextActionData::InvokeHiddenIframe { iframe_data } => {StripeNextAction::InvokeHiddenIframe { iframe_data }}- payments::NextActionData::SdkUpiIntentInformation { sdk_uri } => {- StripeNextAction::SdkUpiIntentInformation { sdk_uri }+ payments::NextActionData::InvokeUpiIntentSdk { sdk_uri, .. } => {+ StripeNextAction::InvokeUpiIntentSdk { sdk_uri }+ }+ payments::NextActionData::InvokeUpiQrFlow { qr_code_url, .. } => {+ StripeNextAction::InvokeUpiQrFlow {+ sdk_uri: qr_code_url,+ }}})}diff --git a/crates/router/src/compatibility/stripe/setup_intents/types.rs b/crates/router/src/compatibility/stripe/setup_intents/types.rsindex 316835c720..201a5aac81 100644--- a/crates/router/src/compatibility/stripe/setup_intents/types.rs+++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs@@ -400,7 +400,10 @@ pub enum StripeNextAction {InvokeHiddenIframe {iframe_data: payments::IframeData,},- SdkUpiIntentInformation {+ InvokeUpiIntentSdk {+ sdk_uri: url::Url,+ },+ InvokeUpiQrFlow {sdk_uri: url::Url,},}@@ -480,8 +483,13 @@ pub(crate) fn into_stripe_next_action(payments::NextActionData::InvokeHiddenIframe { iframe_data } => {StripeNextAction::InvokeHiddenIframe { iframe_data }}- payments::NextActionData::SdkUpiIntentInformation { sdk_uri } => {- StripeNextAction::SdkUpiIntentInformation { sdk_uri }+ payments::NextActionData::InvokeUpiIntentSdk { sdk_uri, .. } => {+ StripeNextAction::InvokeUpiIntentSdk { sdk_uri }+ }+ payments::NextActionData::InvokeUpiQrFlow { qr_code_url, .. } => {+ StripeNextAction::InvokeUpiQrFlow {+ sdk_uri: qr_code_url,+ }}})}diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 3245cb834d..34601958ba 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -3365,7 +3365,8 @@ impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize {api_models::payments::NextActionData::InvokeSdkClient{..} => None,api_models::payments::NextActionData::CollectOtp{ .. } => None,api_models::payments::NextActionData::InvokeHiddenIframe{ .. } => None,- api_models::payments::NextActionData::SdkUpiIntentInformation{ .. } => None,+ api_models::payments::NextActionData::InvokeUpiIntentSdk{ .. } => None,+ api_models::payments::NextActionData::InvokeUpiQrFlow{ .. } => None,}).ok_or(errors::ApiErrorResponse::InternalServerError)diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 9da558d990..425b2f74c2 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -2743,18 +2743,13 @@ wherelet next_action_containing_wait_screen =wait_screen_next_steps_check(payment_attempt.clone())?;- let next_action_containing_sdk_upi_intent =- extract_sdk_uri_information(payment_attempt.clone())?;+ let upi_next_action = payment_attempt.get_upi_next_action()?;payment_attempt.redirection_data.as_ref().map(|_| api_models::payments::NextActionData::RedirectToUrl { redirect_to_url })- .or(next_action_containing_sdk_upi_intent.map(|sdk_uri_data| {- api_models::payments::NextActionData::SdkUpiIntentInformation {- sdk_uri: sdk_uri_data.sdk_uri,- }- }))+ .or(upi_next_action).or(next_action_containing_wait_screen.map(|wait_screen_data| {api_models::payments::NextActionData::WaitScreenInformation {display_from_timestamp: wait_screen_data.display_from_timestamp,@@ -2903,18 +2898,10 @@ impl GenerateResponse<api_models::payments::PaymentsResponse>let next_action_containing_wait_screen =wait_screen_next_steps_check(payment_attempt.clone())?;- let next_action_containing_sdk_upi_intent =- extract_sdk_uri_information(payment_attempt.clone())?;-payment_attempt.redirection_data.as_ref().map(|_| api_models::payments::NextActionData::RedirectToUrl { redirect_to_url })- .or(next_action_containing_sdk_upi_intent.map(|sdk_uri_data| {- api_models::payments::NextActionData::SdkUpiIntentInformation {- sdk_uri: sdk_uri_data.sdk_uri,- }- })).or(next_action_containing_wait_screen.map(|wait_screen_data| {api_models::payments::NextActionData::WaitScreenInformation {display_from_timestamp: wait_screen_data.display_from_timestamp,@@ -3655,8 +3642,7 @@ wherelet next_action_containing_wait_screen =wait_screen_next_steps_check(payment_attempt.clone())?;- let next_action_containing_sdk_upi_intent =- extract_sdk_uri_information(payment_attempt.clone())?;+ let upi_next_action = payment_attempt.get_upi_next_action()?;let next_action_invoke_hidden_frame =next_action_invoke_hidden_frame(&payment_attempt)?;@@ -3666,7 +3652,7 @@ where|| next_action_voucher.is_some()|| next_action_containing_qr_code_url.is_some()|| next_action_containing_wait_screen.is_some()- || next_action_containing_sdk_upi_intent.is_some()+ || upi_next_action.is_some()|| papal_sdk_next_action.is_some()|| next_action_containing_fetch_qr_code_url.is_some()|| payment_data.get_authentication().is_some()@@ -3700,11 +3686,7 @@ wherenext_action_data: paypal_next_action_data}}))- .or(next_action_containing_sdk_upi_intent.map(|sdk_uri_data| {- api_models::payments::NextActionData::SdkUpiIntentInformation {- sdk_uri: sdk_uri_data.sdk_uri,- }- }))+ .or(upi_next_action).or(next_action_containing_wait_screen.map(|wait_screen_data| {api_models::payments::NextActionData::WaitScreenInformation {display_from_timestamp: wait_screen_data.display_from_timestamp,@@ -4134,18 +4116,6 @@ pub fn fetch_qr_code_url_next_steps_check(Ok(qr_code_fetch_url)}-pub fn extract_sdk_uri_information(- payment_attempt: storage::PaymentAttempt,-) -> RouterResult<Option<api_models::payments::SdkUpiIntentInformation>> {- let sdk_uri_steps: Option<Result<api_models::payments::SdkUpiIntentInformation, _>> =- payment_attempt- .connector_metadata- .map(|metadata| metadata.parse_value("SdkUpiIntentInformation"));-- let sdk_uri_information = sdk_uri_steps.transpose().ok().flatten();- Ok(sdk_uri_information)-}-pub fn wait_screen_next_steps_check(payment_attempt: storage::PaymentAttempt,) -> RouterResult<Option<api_models::payments::WaitScreenInstructions>> {diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rsindex 6bd5ef906c..9ff71ec2ef 100644--- a/crates/router/src/core/unified_connector_service/transformers.rs+++ b/crates/router/src/core/unified_connector_service/transformers.rs@@ -29,12 +29,12 @@ pub use hyperswitch_interfaces::{};use masking::{ExposeInterface, PeekInterface, Secret};use router_env::tracing;+use time::{Duration, OffsetDateTime};use unified_connector_service_cards::CardNumber;use unified_connector_service_client::payments::{self as payments_grpc, ConnectorState, Identifier, PaymentServiceTransformRequest,PaymentServiceTransformResponse,};-use url::Url;use crate::{core::{errors, unified_connector_service},@@ -44,6 +44,31 @@ use crate::{},};+const UPI_WAIT_SCREEN_DISPLAY_DURATION_MINUTES: i64 = 5;+const UPI_POLL_DELAY_IN_SECS: u16 = 5;+const UPI_POLL_FREQUENCY: u16 = 60;++pub fn build_upi_wait_screen_data(+) -> Result<serde_json::Value, error_stack::Report<UnifiedConnectorServiceError>> {+ let current_time = OffsetDateTime::now_utc().unix_timestamp_nanos();++ let wait_screen_data = api_models::payments::WaitScreenInstructions {+ display_from_timestamp: current_time,+ display_to_timestamp: Some(+ current_time+ + Duration::minutes(UPI_WAIT_SCREEN_DISPLAY_DURATION_MINUTES).whole_nanoseconds(),+ ),+ poll_config: Some(api_models::payments::PollConfig {+ delay_in_secs: UPI_POLL_DELAY_IN_SECS,+ frequency: UPI_POLL_FREQUENCY,+ }),+ };++ serde_json::to_value(wait_screen_data)+ .change_context(UnifiedConnectorServiceError::ParsingFailed)+ .attach_printable("Failed to serialize WaitScreenInstructions to JSON value")+}+impl ForeignFrom<&payments_grpc::AccessToken> for AccessToken {fn foreign_from(grpc_token: &payments_grpc::AccessToken) -> Self {Self {@@ -1662,15 +1687,18 @@ impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceAuthorizeResponseSome(redirection_data) => match redirection_data.form_type {Some(ref form_type) => match form_type {payments_grpc::redirect_form::FormType::Uri(uri) => {- // For UPI intent, store the URI in connector_metadata for SDK UPI intent pattern- let sdk_uri_info = api_models::payments::SdkUpiIntentInformation {- sdk_uri: Url::parse(&uri.uri)- .change_context(UnifiedConnectorServiceError::ParsingFailed)?,+ let sdk_uri_info = api_models::payments::SdkUpiUriInformation {+ sdk_uri: uri.uri.clone(),};(- Some(sdk_uri_info.encode_to_value())- .transpose()- .change_context(UnifiedConnectorServiceError::ParsingFailed)?,+ Some(+ sdk_uri_info+ .encode_to_value()+ .change_context(UnifiedConnectorServiceError::ParsingFailed)+ .attach_printable(+ "Failed to serialize SdkUpiUriInformation to JSON value",+ )?,+ ),None,)}@@ -1684,7 +1712,46 @@ impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceAuthorizeResponseNone => (None, None),};- // Extract connector_metadata from response if present and not already set by UPI intent handling+ connector_metadata = if response+ .connector_metadata+ .get("nextActionData")+ .filter(|&next_action_data| next_action_data == "WaitScreenInstructions")+ .is_some()+ {+ let wait_screen_metadata = build_upi_wait_screen_data()?;++ let mut metadata_map = connector_metadata+ .as_ref()+ .and_then(|meta| meta.as_object())+ .cloned()+ .unwrap_or_else(serde_json::Map::new);++ metadata_map.insert("WaitScreenInstructions".to_string(), wait_screen_metadata);++ // For UPI Intent/QR, also preserve URI information from redirection data+ if let Some(redirection_data) = response.redirection_data.as_ref() {+ if let Some(payments_grpc::redirect_form::FormType::Uri(uri)) =+ &redirection_data.form_type+ {+ let sdk_uri_info = api_models::payments::SdkUpiUriInformation {+ sdk_uri: uri.uri.clone(),+ };+ let uri_data = sdk_uri_info+ .encode_to_value()+ .change_context(UnifiedConnectorServiceError::ParsingFailed)+ .attach_printable(+ "Failed to serialize SdkUpiUriInformation to JSON value",+ )?;+ metadata_map.insert("SdkUpiUriInformation".to_string(), uri_data);+ }+ }++ Some(serde_json::Value::Object(metadata_map))+ } else {+ connector_metadata+ };++ // Extract connector_metadata from response if present and not already setif connector_metadata.is_none() && !response.connector_metadata.is_empty() {connector_metadata = serde_json::to_value(&response.connector_metadata).map_err(|e| {@@ -2624,15 +2691,18 @@ impl transformers::ForeignTryFrom<payments_grpc::PaymentServicePostAuthenticateRSome(redirection_data) => match redirection_data.form_type {Some(ref form_type) => match form_type {payments_grpc::redirect_form::FormType::Uri(uri) => {- // For UPI intent, store the URI in connector_metadata for SDK UPI intent pattern- let sdk_uri_info = api_models::payments::SdkUpiIntentInformation {- sdk_uri: Url::parse(&uri.uri)- .change_context(UnifiedConnectorServiceError::ParsingFailed)?,+ let sdk_uri_info = api_models::payments::SdkUpiUriInformation {+ sdk_uri: uri.uri.clone(),};(- Some(sdk_uri_info.encode_to_value())- .transpose()- .change_context(UnifiedConnectorServiceError::ParsingFailed)?,+ Some(+ sdk_uri_info+ .encode_to_value()+ .change_context(UnifiedConnectorServiceError::ParsingFailed)+ .attach_printable(+ "Failed to serialize SdkUpiUriInformation to JSON value",+ )?,+ ),None,)}@@ -2903,15 +2973,18 @@ impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceAuthenticateRespoSome(redirection_data) => match redirection_data.form_type {Some(ref form_type) => match form_type {payments_grpc::redirect_form::FormType::Uri(uri) => {- // For UPI intent, store the URI in connector_metadata for SDK UPI intent pattern- let sdk_uri_info = api_models::payments::SdkUpiIntentInformation {- sdk_uri: Url::parse(&uri.uri)- .change_context(UnifiedConnectorServiceError::ParsingFailed)?,+ let sdk_uri_info = api_models::payments::SdkUpiUriInformation {+ sdk_uri: uri.uri.clone(),};(- Some(sdk_uri_info.encode_to_value())- .transpose()- .change_context(UnifiedConnectorServiceError::ParsingFailed)?,+ Some(+ sdk_uri_info+ .encode_to_value()+ .change_context(UnifiedConnectorServiceError::ParsingFailed)+ .attach_printable(+ "Failed to serialize SdkUpiUriInformation to JSON value",+ )?,+ ),None,)}@@ -3153,7 +3226,7 @@ pub fn build_webhook_transform_request("{}_{}_{}",merchant_id,connector_id,- time::OffsetDateTime::now_utc().unix_timestamp()+ OffsetDateTime::now_utc().unix_timestamp()))),}),request_details: Some(request_details_grpc),