Skip to content

Commit

Permalink
feat(core): Add uas framework support (#6743)
Browse files Browse the repository at this point in the history
Co-authored-by: sai-harsha-vardhan <[email protected]>
  • Loading branch information
sahkal and sai-harsha-vardhan authored Dec 11, 2024
1 parent cd20537 commit 9466ced
Show file tree
Hide file tree
Showing 55 changed files with 1,284 additions and 94 deletions.
12 changes: 12 additions & 0 deletions crates/diesel_models/src/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ pub enum AuthenticationUpdate {
PostAuthorizationUpdate {
authentication_lifecycle_status: common_enums::AuthenticationLifecycleStatus,
},
AuthenticationStatusUpdate {
trans_status: common_enums::TransactionStatus,
authentication_status: common_enums::AuthenticationStatus,
},
}

#[derive(Clone, Debug, Eq, PartialEq, AsChangeset, Serialize, Deserialize)]
Expand Down Expand Up @@ -418,6 +422,14 @@ impl From<AuthenticationUpdate> for AuthenticationUpdateInternal {
connector_metadata,
..Default::default()
},
AuthenticationUpdate::AuthenticationStatusUpdate {
trans_status,
authentication_status,
} => Self {
trans_status: Some(trans_status),
authentication_status: Some(authentication_status),
..Default::default()
},
}
}
}
1 change: 1 addition & 0 deletions crates/hyperswitch_domain_models/src/router_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ pub struct RouterData<Flow, Request, Response> {

pub connector_mandate_request_reference_id: Option<String>,

pub authentication_id: Option<String>,
/// Contains the type of sca exemption required for the transaction
pub psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/hyperswitch_domain_models/src/router_data_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub use flow_common_types::FrmFlowData;
pub use flow_common_types::PayoutFlowData;
pub use flow_common_types::{
AccessTokenFlowData, DisputesFlowData, ExternalAuthenticationFlowData, FilesFlowData,
MandateRevokeFlowData, PaymentFlowData, RefundFlowData, WebhookSourceVerifyData,
MandateRevokeFlowData, PaymentFlowData, RefundFlowData, UasFlowData, WebhookSourceVerifyData,
};

use crate::router_data::{ConnectorAuthType, ErrorResponse};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,9 @@ pub struct FilesFlowData {
pub connector_meta_data: Option<pii::SecretSerdeValue>,
pub connector_request_reference_id: String,
}

#[derive(Debug, Clone)]
pub struct UasFlowData {
pub authenticate_by: String,
pub source_authentication_id: String,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod authentication;
pub mod fraud_check;
pub mod unified_authentication_service;
use api_models::payments::{AdditionalPaymentData, RequestSurchargeDetails};
use common_utils::{
consts, errors,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
use masking::Secret;

#[derive(Clone, serde::Deserialize, Debug, serde::Serialize)]
pub struct UasPreAuthenticationRequestData {
pub service_details: Option<ServiceDetails>,
pub transaction_details: Option<TransactionDetails>,
}

#[derive(Clone, serde::Deserialize, Debug, serde::Serialize)]
pub struct ServiceDetails {
pub service_session_ids: Option<ServiceSessionIds>,
}

#[derive(Clone, serde::Deserialize, Debug, serde::Serialize)]
pub struct ServiceSessionIds {
pub correlation_id: Option<String>,
pub merchant_transaction_id: Option<String>,
pub x_src_flow_id: Option<String>,
}

#[derive(Debug, serde::Serialize, serde::Deserialize, Clone)]
pub struct TransactionDetails {
pub amount: common_utils::types::MinorUnit,
pub currency: common_enums::Currency,
}

#[derive(Clone, Debug)]
pub struct UasPostAuthenticationRequestData;

#[derive(Debug, Clone)]
pub enum UasAuthenticationResponseData {
PreAuthentication {},
PostAuthentication {
authentication_details: PostAuthenticationDetails,
},
}

#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
pub struct PostAuthenticationDetails {
pub eci: Option<String>,
pub token_details: TokenDetails,
pub dynamic_data_details: Option<DynamicData>,
}

#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
pub struct TokenDetails {
pub payment_token: cards::CardNumber,
pub payment_account_reference: String,
pub token_expiration_month: Secret<String>,
pub token_expiration_year: Secret<String>,
}

#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
pub struct DynamicData {
pub dynamic_data_value: Option<Secret<String>>,
pub dynamic_data_type: String,
pub ds_trans_id: Option<String>,
}
2 changes: 2 additions & 0 deletions crates/router/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ pub mod verification;
#[cfg(feature = "olap")]
pub mod verify_connector;
pub mod webhooks;

pub mod unified_authentication_service;
1 change: 1 addition & 0 deletions crates/router/src/core/authentication/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ pub fn construct_router_data<F: Clone, Req, Res>(
additional_merchant_data: None,
header_payload: None,
connector_mandate_request_reference_id: None,
authentication_id: None,
psd2_sca_exemption_type,
})
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/fraud_check/flows/checkout_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ impl ConstructFlowSpecificData<frm_api::Checkout, FraudCheckCheckoutData, FraudC
additional_merchant_data: None,
header_payload,
connector_mandate_request_reference_id: None,
authentication_id: None,
psd2_sca_exemption_type: None,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pub async fn construct_fulfillment_router_data<'a>(
additional_merchant_data: None,
header_payload: None,
connector_mandate_request_reference_id: None,
authentication_id: None,
psd2_sca_exemption_type: None,
};
Ok(router_data)
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/fraud_check/flows/record_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ impl ConstructFlowSpecificData<RecordReturn, FraudCheckRecordReturnData, FraudCh
additional_merchant_data: None,
header_payload,
connector_mandate_request_reference_id: None,
authentication_id: None,
psd2_sca_exemption_type: None,
};

Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/fraud_check/flows/sale_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ impl ConstructFlowSpecificData<frm_api::Sale, FraudCheckSaleData, FraudCheckResp
additional_merchant_data: None,
header_payload,
connector_mandate_request_reference_id: None,
authentication_id: None,
psd2_sca_exemption_type: None,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ impl
additional_merchant_data: None,
header_payload,
connector_mandate_request_reference_id: None,
authentication_id: None,
psd2_sca_exemption_type: None,
};

Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/mandate/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub async fn construct_mandate_revoke_router_data(
additional_merchant_data: None,
header_payload: None,
connector_mandate_request_reference_id: None,
authentication_id: None,
psd2_sca_exemption_type: None,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4327,7 +4327,7 @@ pub fn if_not_create_change_operation<'a, Op, F>(
current: &'a Op,
) -> BoxedOperation<'a, F, api::PaymentsRequest, PaymentData<F>>
where
F: Send + Clone,
F: Send + Clone + Sync,
Op: Operation<F, api::PaymentsRequest, Data = PaymentData<F>> + Send + Sync,
&'a Op: Operation<F, api::PaymentsRequest, Data = PaymentData<F>>,
PaymentStatus: Operation<F, api::PaymentsRequest, Data = PaymentData<F>>,
Expand Down
111 changes: 111 additions & 0 deletions crates/router/src/core/payments/connector_integration_v2_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2226,3 +2226,114 @@ default_imp_for_new_connector_integration_connector_authentication!(
connector::Zsl,
connector::Plaid
);

macro_rules! default_imp_for_new_connector_integration_uas {
($($path:ident::$connector:ident),*) => {
$( impl api::UnifiedAuthenticationServiceV2 for $path::$connector {}
impl api::UasPreAuthenticationV2 for $path::$connector {}
impl api::UasPostAuthenticationV2 for $path::$connector {}
impl
services::ConnectorIntegrationV2<
api::PreAuthenticate,
types::UasFlowData,
types::UasPreAuthenticationRequestData,
types::UasAuthenticationResponseData,
> for $path::$connector
{}
impl
services::ConnectorIntegrationV2<
api::PostAuthenticate,
types::UasFlowData,
types::UasPostAuthenticationRequestData,
types::UasAuthenticationResponseData,
> for $path::$connector
{}
)*
};
}

default_imp_for_new_connector_integration_uas!(
connector::Aci,
connector::Adyen,
connector::Adyenplatform,
connector::Airwallex,
connector::Amazonpay,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
connector::Bluesnap,
connector::Boku,
connector::Braintree,
connector::Cashtocode,
connector::Checkout,
connector::Cryptopay,
connector::Coinbase,
connector::Cybersource,
connector::Datatrans,
connector::Deutschebank,
connector::Digitalvirgo,
connector::Dlocal,
connector::Ebanx,
connector::Elavon,
connector::Fiserv,
connector::Fiservemea,
connector::Forte,
connector::Fiuu,
connector::Globalpay,
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
connector::Helcim,
connector::Iatapay,
connector::Inespay,
connector::Itaubank,
connector::Jpmorgan,
connector::Klarna,
connector::Mifinity,
connector::Mollie,
connector::Multisafepay,
connector::Netcetera,
connector::Nexinets,
connector::Nexixpay,
connector::Nmi,
connector::Nomupay,
connector::Noon,
connector::Novalnet,
connector::Nuvei,
connector::Opayo,
connector::Opennode,
connector::Paybox,
connector::Payeezy,
connector::Payme,
connector::Payone,
connector::Paypal,
connector::Payu,
connector::Placetopay,
connector::Powertranz,
connector::Prophetpay,
connector::Rapyd,
connector::Razorpay,
connector::Redsys,
connector::Riskified,
connector::Signifyd,
connector::Square,
connector::Stax,
connector::Stripe,
connector::Shift4,
connector::Taxjar,
connector::Trustpay,
connector::Threedsecureio,
connector::Thunes,
connector::Tsys,
connector::Volt,
connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
connector::Zen,
connector::Zsl,
connector::Plaid
);
Loading

0 comments on commit 9466ced

Please sign in to comment.