diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index a56be91cf932..391575e88835 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -3955,9 +3955,9 @@ pub enum NextActionData { InvokeSdkClient { next_action_data: SdkNextActionData, }, - /// Contains url to collect otp for mobile payment + /// Contains consent to collect otp for mobile payment CollectOtp { - collect_otp_url: String, + consent_data_required: MobilePaymentConsent, }, } @@ -4056,8 +4056,16 @@ pub struct VoucherNextStepData { #[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)] pub struct MobilePaymentNextStepData { - /// Url to collect OTP - pub collect_otp_url: String, + /// is consent details required to be shown by sdk + pub consent_data_required: MobilePaymentConsent, +} + +#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)] +#[serde(rename_all = "snake_case")] +pub enum MobilePaymentConsent { + ConsentRequired, + ConsentNotRequired, + ConsentOptional, } #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] diff --git a/crates/hyperswitch_connectors/src/connectors/digitalvirgo/transformers.rs b/crates/hyperswitch_connectors/src/connectors/digitalvirgo/transformers.rs index 6cd2e460520c..a9408e4e1c52 100644 --- a/crates/hyperswitch_connectors/src/connectors/digitalvirgo/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/digitalvirgo/transformers.rs @@ -6,7 +6,7 @@ use hyperswitch_domain_models::{ router_data::{ConnectorAuthType, RouterData}, router_flow_types::refunds::{Execute, RSync}, router_request_types::ResponseId, - router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData}, + router_response_types::{PaymentsResponseData, RefundsResponseData}, types::{PaymentsAuthorizeRouterData, PaymentsCompleteAuthorizeRouterData, RefundsRouterData}, }; use hyperswitch_interfaces::errors; @@ -122,6 +122,12 @@ impl From for common_enums::AttemptStatus { pub struct DigitalvirgoPaymentsResponse { state: DigitalvirgoPaymentStatus, transaction_id: String, + consent: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct DigitalvirgoConsentStatus { + required: Option, } impl TryFrom> @@ -131,18 +137,33 @@ impl TryFrom, ) -> Result { - let status = common_enums::AttemptStatus::from(item.response.state); - let redirection_data = Box::new(match status { - common_enums::AttemptStatus::AuthenticationPending => Some(RedirectForm::DigitalVirgo), - _ => None, - }); + // show if consent is required in next action + let connector_metadata = item + .response + .consent + .and_then(|consent_status| { + consent_status.required.map(|consent_required| { + if consent_required { + serde_json::json!({ + "consent_data_required": "consent_required", + }) + } else { + serde_json::json!({ + "consent_data_required": "consent_not_required", + }) + } + }) + }) + .or(Some(serde_json::json!({ + "consent_data_required": "consent_not_required", + }))); Ok(Self { - status, + status: common_enums::AttemptStatus::from(item.response.state), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.transaction_id), - redirection_data, + redirection_data: Box::new(None), mandate_reference: Box::new(None), - connector_metadata: None, + connector_metadata, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs index 0892629f1903..6356301c7264 100644 --- a/crates/hyperswitch_domain_models/src/router_response_types.rs +++ b/crates/hyperswitch_domain_models/src/router_response_types.rs @@ -170,7 +170,6 @@ pub enum RedirectForm { form_fields: HashMap, collection_id: Option, }, - DigitalVirgo, } impl From<(url::Url, Method)> for RedirectForm { diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs index 79a6e515a6f3..55516eeb3bcf 100644 --- a/crates/router/src/compatibility/stripe/payment_intents/types.rs +++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs @@ -838,7 +838,7 @@ pub enum StripeNextAction { next_action_data: payments::SdkNextActionData, }, CollectOtp { - collect_otp_url: String, + consent_data_required: payments::MobilePaymentConsent, }, } @@ -895,9 +895,11 @@ pub(crate) fn into_stripe_next_action( payments::NextActionData::InvokeSdkClient { next_action_data } => { StripeNextAction::InvokeSdkClient { next_action_data } } - payments::NextActionData::CollectOtp { collect_otp_url } => { - StripeNextAction::CollectOtp { collect_otp_url } - } + payments::NextActionData::CollectOtp { + consent_data_required, + } => StripeNextAction::CollectOtp { + consent_data_required, + }, }) } diff --git a/crates/router/src/compatibility/stripe/setup_intents/types.rs b/crates/router/src/compatibility/stripe/setup_intents/types.rs index 9c483fc2fc59..03cf9742f704 100644 --- a/crates/router/src/compatibility/stripe/setup_intents/types.rs +++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs @@ -392,7 +392,7 @@ pub enum StripeNextAction { next_action_data: payments::SdkNextActionData, }, CollectOtp { - collect_otp_url: String, + consent_data_required: payments::MobilePaymentConsent, }, } @@ -449,9 +449,11 @@ pub(crate) fn into_stripe_next_action( payments::NextActionData::InvokeSdkClient { next_action_data } => { StripeNextAction::InvokeSdkClient { next_action_data } } - payments::NextActionData::CollectOtp { collect_otp_url } => { - StripeNextAction::CollectOtp { collect_otp_url } - } + payments::NextActionData::CollectOtp { + consent_data_required, + } => StripeNextAction::CollectOtp { + consent_data_required, + }, }) } diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 69b19084b3f7..94d40f68eded 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -1349,8 +1349,7 @@ where let next_action_voucher = voucher_next_steps_check(payment_attempt.clone())?; - let next_action_mobile_payment = - mobile_payment_next_steps_check(base_url, &payment_attempt, &payment_intent)?; + let next_action_mobile_payment = mobile_payment_next_steps_check(&payment_attempt)?; let next_action_containing_qr_code_url = qr_code_next_steps_check(payment_attempt.clone())?; @@ -1384,7 +1383,7 @@ where })) .or(next_action_mobile_payment.map(|mobile_payment_data| { api_models::payments::NextActionData::CollectOtp { - collect_otp_url: mobile_payment_data.collect_otp_url, + consent_data_required: mobile_payment_data.consent_data_required, } })) .or(next_action_containing_qr_code_url.map(|qr_code_data| { @@ -2003,24 +2002,18 @@ pub fn voucher_next_steps_check( #[cfg(feature = "v1")] pub fn mobile_payment_next_steps_check( - base_url: &str, payment_attempt: &storage::PaymentAttempt, - payment_intent: &storage::PaymentIntent, ) -> RouterResult> { - let mobile_payment_next_step = if let Some(diesel_models::enums::PaymentMethod::MobilePayment) = - payment_attempt.payment_method - { - Some(api_models::payments::MobilePaymentNextStepData { - collect_otp_url: helpers::create_startpay_url( - base_url, - payment_attempt, - payment_intent, - ), + payment_attempt + .connector_metadata + .clone() + .map(|metadata| { + metadata + .parse_value("MobilePaymentNextStepData") + .change_context(errors::ApiErrorResponse::InternalServerError) + .attach_printable("Failed to parse the Value to NextRequirements struct") }) - } else { - None - }; - Ok(mobile_payment_next_step) + .transpose() } pub fn change_order_details_to_new_type( diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs index dbdeb9d481c6..2cf8b721a057 100644 --- a/crates/router/src/services/api.rs +++ b/crates/router/src/services/api.rs @@ -1933,29 +1933,6 @@ pub fn build_redirection_form( } } }, - RedirectForm::DigitalVirgo => { - maud::html! { - (maud::DOCTYPE) - head { - meta name="viewport" content="width=device-width, initial-scale=1"; - } - - (PreEscaped(format!("
- - -
- "))) - } - } } }