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(core): added payment method type in uas for modular auth and payments api (#9852)
Sahkal Poddar0fe4f230c167
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex d41aa307da..6367908a06 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -8389,6 +8389,14 @@"payment_method": {"$ref": "#/components/schemas/PaymentMethod"},+ "payment_method_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentMethodType"+ }+ ],+ "nullable": true+ },"client_secret": {"type": "string","description": "Optional secret value used to identify and authorize the client making the request.\nThis can help ensure that the payment session is secure and valid.",diff --git a/crates/api_models/src/authentication.rs b/crates/api_models/src/authentication.rsindex 6704920c4d..bd3d222560 100644--- a/crates/api_models/src/authentication.rs+++ b/crates/api_models/src/authentication.rs@@ -171,6 +171,10 @@ pub struct AuthenticationEligibilityRequest {#[schema(value_type = PaymentMethod)]pub payment_method: common_enums::PaymentMethod,+ /// Can be used to specify the Payment Method Type+ #[schema(value_type = Option<PaymentMethodType>, example = "debit")]+ pub payment_method_type: Option<enums::PaymentMethodType>,+/// Optional secret value used to identify and authorize the client making the request./// This can help ensure that the payment session is secure and valid.#[schema(value_type = Option<String>)]diff --git a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rsindex 19c50cd07b..9b39eaaf86 100644--- a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs@@ -108,7 +108,7 @@ impl<F, T>pub struct PaymentDetails {pub pan: cards::CardNumber,pub digital_card_id: Option<String>,- pub payment_data_type: Option<String>,+ pub payment_data_type: Option<common_enums::PaymentMethodType>,pub encrypted_src_card_details: Option<String>,pub card_expiry_month: Secret<String>,pub card_expiry_year: Secret<String>,diff --git a/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs b/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rsindex 40b4739724..2629735769 100644--- a/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs+++ b/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs@@ -63,7 +63,7 @@ pub struct CtpServiceDetails {pub struct PaymentDetails {pub pan: cards::CardNumber,pub digital_card_id: Option<String>,- pub payment_data_type: Option<String>,+ pub payment_data_type: Option<common_enums::PaymentMethodType>,pub encrypted_src_card_details: Option<String>,pub card_expiry_month: Secret<String>,pub card_expiry_year: Secret<String>,diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex 4799b88ea7..2f4a574d46 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -1293,6 +1293,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for&payment_data.payment_attempt.merchant_id,Some(&payment_data.payment_intent.payment_id),payment_data.payment_method_data.as_ref(),+ payment_data.payment_attempt.payment_method_type,&helpers::MerchantConnectorAccountType::DbVal(Box::new(connector_mca.clone())),&connector_mca.connector_name,&authentication_id,@@ -1479,6 +1480,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for&payment_data.payment_attempt.merchant_id,Some(&payment_data.payment_intent.payment_id),payment_data.payment_method_data.as_ref(),+ payment_data.payment_attempt.payment_method_type,&three_ds_connector_account,&authentication_connector_name,&authentication.authentication_id,diff --git a/crates/router/src/core/unified_authentication_service.rs b/crates/router/src/core/unified_authentication_service.rsindex 7863285458..339ef74e3c 100644--- a/crates/router/src/core/unified_authentication_service.rs+++ b/crates/router/src/core/unified_authentication_service.rs@@ -70,6 +70,7 @@ impl UnifiedAuthenticationService for ClickToPay {billing_address: Option<&hyperswitch_domain_models::address::Address>,acquirer_bin: Option<String>,acquirer_merchant_id: Option<String>,+ _payment_method_type: Option<common_enums::PaymentMethodType>,) -> RouterResult<UasPreAuthenticationRequestData> {let domain_service_details = hyperswitch_domain_models::router_request_types::unified_authentication_service::CtpServiceDetails {service_session_ids: Some(ServiceSessionIds {@@ -121,6 +122,7 @@ impl UnifiedAuthenticationService for ClickToPay {merchant_id: &common_utils::id_type::MerchantId,payment_id: Option<&common_utils::id_type::PaymentId>,payment_method_data: Option<&domain::PaymentMethodData>,+ payment_method_type: Option<common_enums::PaymentMethodType>,merchant_connector_account: &MerchantConnectorAccountType,connector_name: &str,authentication_id: &common_utils::id_type::AuthenticationId,@@ -142,6 +144,7 @@ impl UnifiedAuthenticationService for ClickToPay {billing_address,acquirer_bin,acquirer_merchant_id,+ payment_method_type,)?;let pre_auth_router_data: UasPreAuthenticationRouterData =@@ -289,6 +292,7 @@ impl UnifiedAuthenticationService for ExternalAuthentication {billing_address: Option<&hyperswitch_domain_models::address::Address>,acquirer_bin: Option<String>,acquirer_merchant_id: Option<String>,+ payment_method_type: Option<common_enums::PaymentMethodType>,) -> RouterResult<UasPreAuthenticationRequestData> {let payment_method_data = payment_method_data.ok_or(ApiErrorResponse::InternalServerError)@@ -298,13 +302,13 @@ impl UnifiedAuthenticationService for ExternalAuthentication {Some(PaymentDetails {pan: card.card_number.clone(),digital_card_id: None,- payment_data_type: None,+ payment_data_type: payment_method_type,encrypted_src_card_details: None,card_expiry_month: card.card_exp_month.clone(),card_expiry_year: card.card_exp_year.clone(),cardholder_name: card.card_holder_name.clone(),card_token_number: None,- account_type: None,+ account_type: payment_method_type,card_cvc: Some(card.card_cvc.clone()),})} else {@@ -334,6 +338,7 @@ impl UnifiedAuthenticationService for ExternalAuthentication {merchant_id: &common_utils::id_type::MerchantId,payment_id: Option<&common_utils::id_type::PaymentId>,payment_method_data: Option<&domain::PaymentMethodData>,+ payment_method_type: Option<common_enums::PaymentMethodType>,merchant_connector_account: &MerchantConnectorAccountType,connector_name: &str,authentication_id: &common_utils::id_type::AuthenticationId,@@ -355,6 +360,7 @@ impl UnifiedAuthenticationService for ExternalAuthentication {billing_address,acquirer_bin,acquirer_merchant_id,+ payment_method_type,)?;let pre_auth_router_data: UasPreAuthenticationRouterData =@@ -1014,6 +1020,7 @@ pub async fn authentication_eligibility_core(merchant_id,None,Some(&payment_method_data),+ req.payment_method_type,&three_ds_connector_account,&authentication_connector_name,&authentication_id,diff --git a/crates/router/src/core/unified_authentication_service/types.rs b/crates/router/src/core/unified_authentication_service/types.rsindex 49a24ce022..027bc41f56 100644--- a/crates/router/src/core/unified_authentication_service/types.rs+++ b/crates/router/src/core/unified_authentication_service/types.rs@@ -43,6 +43,7 @@ pub trait UnifiedAuthenticationService {_billing_address: Option<&hyperswitch_domain_models::address::Address>,_acquirer_bin: Option<String>,_acquirer_merchant_id: Option<String>,+ _payment_method_type: Option<common_enums::PaymentMethodType>,) -> RouterResult<UasPreAuthenticationRequestData> {Err(errors::ApiErrorResponse::NotImplemented {message: NotImplementedMessage::Reason(@@ -58,6 +59,7 @@ pub trait UnifiedAuthenticationService {_merchant_id: &common_utils::id_type::MerchantId,_payment_id: Option<&common_utils::id_type::PaymentId>,_payment_method_data: Option<&domain::PaymentMethodData>,+ _payment_method_type: Option<common_enums::PaymentMethodType>,_merchant_connector_account: &MerchantConnectorAccountType,_connector_name: &str,_authentication_id: &common_utils::id_type::AuthenticationId,