Skip to content

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

feat(connector): [CYBERSOURCE] Implement step_up 3ds for GooglePay PAN_ONLY & CommerceIndicator for GooglePay (#13876)

Sayak Bhattacharyafef24c82b8f1
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 885c3c487a..18e46bd164 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -24666,6 +24666,14 @@
"token": {
"type": "string",
"description": "Token generated for the wallet"
+ },
+ "auth_method": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/GooglePayAuthMethod"
+ }
+ ],
+ "nullable": true
}
}
},
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index cf016981c2..3e7c1d20db 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -17141,6 +17141,14 @@
"token": {
"type": "string",
"description": "Token generated for the wallet"
+ },
+ "auth_method": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/GooglePayAuthMethod"
+ }
+ ],
+ "nullable": true
}
}
},
diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rs
index 50c9d3c8c0..39975122b3 100644
--- a/crates/common_enums/src/connector_enums.rs
+++ b/crates/common_enums/src/connector_enums.rs
@@ -3,7 +3,7 @@ use std::collections::HashSet;
use smithy::SmithyModel;
use utoipa::ToSchema;
-pub use super::enums::{PaymentMethod, PayoutType};
+pub use super::enums::{AuthenticationType, PaymentMethod, PayoutType};
pub use crate::PaymentMethodType;
// A connector is an integration to fulfill payments
@@ -493,6 +493,19 @@ impl Connector {
matches!(self, Self::Adyenplatform | Self::Adyen)
}
+ pub fn should_store_google_pay_pan_only_for_three_ds(
+ self,
+ payment_method: PaymentMethod,
+ authentication_type: Option<AuthenticationType>,
+ is_google_pay_transaction_pan_only: bool,
+ ) -> bool {
+ // Add connectors in the future as required
+ matches!(self, Self::Cybersource)
+ && payment_method == PaymentMethod::Wallet
+ && authentication_type.is_some_and(|auth_type| auth_type.is_three_ds())
+ && is_google_pay_transaction_pan_only
+ }
+
/// Validates if dummy connector can be created
/// Dummy connectors can be created only if dummy_connector feature is enabled in the configs
#[cfg(feature = "dummy_connector")]
diff --git a/crates/common_types/src/payments.rs b/crates/common_types/src/payments.rs
index 9d0b1874ae..6a3cb2aeb4 100644
--- a/crates/common_types/src/payments.rs
+++ b/crates/common_types/src/payments.rs
@@ -655,6 +655,11 @@ pub struct GpayEcryptedTokenizationData {
/// Token generated for the wallet
#[smithy(value_type = "String")]
pub token: String,
+ /// The authentication method used by Google Pay (PAN_ONLY or CRYPTOGRAM_3DS)
+ #[serde(skip_serializing_if = "Option::is_none")]
+ #[schema(value_type = Option<GooglePayAuthMethod>)]
+ #[smithy(value_type = "Option<GooglePayAuthMethod>")]
+ pub auth_method: Option<common_enums::GooglePayAuthMethod>,
}
#[derive(
@@ -731,6 +736,14 @@ impl GpayTokenizationData {
.token_type
.clone())
}
+
+ /// Get the Google Pay auth method (PAN_ONLY or CRYPTOGRAM_3DS)
+ pub fn get_encrypted_auth_method(&self) -> Option<common_enums::GooglePayAuthMethod> {
+ match self {
+ Self::Encrypted(encrypted) => encrypted.auth_method,
+ Self::Decrypted(_) => None,
+ }
+ }
}
impl GPayPredecryptData {
/// Bin of the decrypted PAN, when it is a tokenized DPAN (`auth_method` is `CRYPTOGRAM_3DS`)
diff --git a/crates/hyperswitch_connectors/src/connectors/cybersource.rs b/crates/hyperswitch_connectors/src/connectors/cybersource.rs
index f9a313a43e..6a1817a361 100644
--- a/crates/hyperswitch_connectors/src/connectors/cybersource.rs
+++ b/crates/hyperswitch_connectors/src/connectors/cybersource.rs
@@ -12,6 +12,7 @@ use common_utils::{
};
use error_stack::{report, Report, ResultExt};
use hyperswitch_domain_models::{
+ payment_method_data::{PaymentMethodData, WalletData},
router_data::{AccessToken, ErrorResponse, RouterData},
router_flow_types::{
access_token_auth::AccessTokenAuth,
@@ -81,7 +82,7 @@ use crate::{
types::ResponseRouterData,
utils::{
self, convert_amount, PaymentsAuthorizeRequestData, PaymentsPreAuthenticateRequestData,
- RefundsRequestData, RouterData as OtherRouterData,
+ RefundsRequestData,
},
};
@@ -1275,12 +1276,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- if req.is_three_ds()
- && req.request.is_card()
- && (req.request.connector_mandate_id().is_none()
- && req.request.get_optional_network_transaction_id().is_none())
- && req.request.authentication_data.is_none()
- {
+ if self.is_3ds_setup_required(&req.request, req.auth_type) {
Ok(format!(
"{}risk/v1/authentication-setups",
ConnectorCommon::base_url(self, connectors)
@@ -1304,12 +1300,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
req.request.currency,
)?;
let connector_router_data = cybersource::CybersourceRouterData::from((amount, req));
- if req.is_three_ds()
- && req.request.is_card()
- && (req.request.connector_mandate_id().is_none()
- && req.request.get_optional_network_transaction_id().is_none())
- && req.request.authentication_data.is_none()
- {
+ if self.is_3ds_setup_required(&req.request, req.auth_type) {
let connector_req =
cybersource::CybersourceAuthSetupRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
@@ -1342,12 +1333,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
- if data.is_three_ds()
- && data.request.is_card()
- && (data.request.connector_mandate_id().is_none()
- && data.request.get_optional_network_transaction_id().is_none())
- && data.request.authentication_data.is_none()
- {
+ if self.is_3ds_setup_required(&data.request, data.auth_type) {
let response: cybersource::CybersourceAuthSetupResponse = res
.response
.parse_struct("Cybersource AuthSetupResponse")
@@ -2612,11 +2598,19 @@ impl Cybersource {
request: &PaymentsAuthorizeData,
auth_type: common_enums::AuthenticationType,
) -> bool {
- router_env::logger::info!(router_data_request=?request, auth_type=?auth_type, "Checking if 3DS setup is required for Cybersource");
auth_type.is_three_ds()
- && request.is_card()
+ && (request.is_card() || Self::is_google_pay_pan_only(request))
&& (request.connector_mandate_id().is_none()
&& request.get_optional_network_transaction_id().is_none())
&& request.authentication_data.is_none()
}
+
+ pub fn is_google_pay_pan_only(request: &PaymentsAuthorizeData) -> bool {
+ let PaymentMethodData::Wallet(WalletData::GooglePay(gpay_data)) =
+ &request.payment_method_data
+ else {
+ return false;
+ };
+ gpay_data.is_pan_only()
+ }
}
diff --git a/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
index 2304eb2912..2fe396e0bb 100644
--- a/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
@@ -34,9 +34,9 @@ use hyperswitch_domain_models::{
SetupMandate,
},
router_request_types::{
- authentication::MessageExtensionAttribute, CompleteAuthorizeData, PaymentsAuthenticateData,
- PaymentsAuthorizeData, PaymentsPostAuthenticateData, PaymentsPreAuthenticateData,
- ResponseId, SetupMandateRequestData, UcsAuthenticationData,
+ authentication::MessageExtensionAttribute, BrowserInformation, CompleteAuthorizeData,
+ PaymentsAuthenticateData, PaymentsAuthorizeData, PaymentsPostAuthenticateData,
+ PaymentsPreAuthenticateData, ResponseId, SetupMandateRequestData, UcsAuthenticationData,
},
router_response_types::{
MandateReference, PaymentsResponseData, RedirectForm, RefundsResponseData,
@@ -68,8 +68,8 @@ use crate::{
},
unimplemented_payment_method,
utils::{
- self, AddressDetailsData, CardData, CardIssuer, NetworkTokenData as _,
- PaymentsAuthorizeRequestData, PaymentsCompleteAuthorizeRequestData,
+ self, AddressDetailsData, BrowserInformationData, CardData, CardIssuer,
+ NetworkTokenData as _, PaymentsAuthorizeRequestData, PaymentsCompleteAuthorizeRequestData,
PaymentsPreProcessingRequestData, PaymentsSetupMandateRequestData, PaymentsSyncRequestData,
RecurringMandateData, RouterData as OtherRouterData,
},
@@ -254,7 +254,6 @@ impl TryFrom<&SetupMandateRouterData> for CybersourceZeroMandateRequest {
ucaf_collection_indicator,
cavv,
ucaf_authentication_data,
- xid: None,
directory_server_transaction_id: authn_data
.ds_trans_id
.clone()
@@ -273,6 +272,7 @@ impl TryFrom<&SetupMandateRouterData> for CybersourceZeroMandateRequest {
network_score,
acs_transaction_id: authn_data.acs_trans_id.clone(),
cavv_algorithm,
+ ..Default::default()
}
});
@@ -473,7 +473,14 @@ impl TryFrom<&SetupMandateRouterData> for CybersourceZeroMandateRequest {
)
})
})
- .unwrap_or_else(|| "internet".to_string());
+ .or_else(|| {
+ get_commerce_indicator_for_wallet_payment(
+ solution.as_ref(),
+ &item.request.payment_method_data,
+ item.auth_type,
+ network.as_deref(),
+ )
+ });
let processing_information = ProcessingInformation {
capture: Some(false),
@@ -513,7 +520,8 @@ pub struct ProcessingInformation {
action_list: Option<Vec<CybersourceActionsList>>,
action_token_types: Option<Vec<CybersourceActionsTokenType>>,
authorization_options: Option<CybersourceAuthorizationOptions>,
- commerce_indicator: String,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ commerce_indicator: Option<String>,
capture: Option<bool>,
capture_options: Option<CaptureOptions>,
payment_solution: Option<String>,
@@ -531,7 +539,7 @@ pub enum CybersourceParesStatus {
AuthenticationNotCompleted,
}
-#[derive(Debug, Serialize)]
+#[derive(Debug, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CybersourceConsumerAuthInformation {
ucaf_collection_indicator: Option<String>,
@@ -571,6 +579,14 @@ pub struct CybersourceConsumerAuthInformation {
acs_transaction_id: Option<String>,
/// This is the algorithm for generating a cardholder authentication verification value (CAVV) or universal cardholder authentication field (UCAF) data.
cavv_algorithm: Option<String>,
+ /// The URL to which the cardholder's browser is redirected after the 3DS challenge is completed.
+ /// Required when requesting Cybersource to perform payer authentication inline (e.g. Google Pay PAN_ONLY with 3DS).
+ #[serde(skip_serializing_if = "Option::is_none")]
+ return_url: Option<String>,
+ /// Reference ID used to correlate the payer authentication request
+ /// (the Cardinal device-data-collection session id for 3DS).
+ #[serde(skip_serializing_if = "Option::is_none")]
+ reference_id: Option<String>,
}
#[derive(Debug, Serialize)]
@@ -590,6 +606,7 @@ pub struct MerchantDefinedInformation {
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum CybersourceActionsList {
TokenCreate,
+ ConsumerAuthentication,
}
#[derive(Debug, Serialize)]
@@ -921,23 +938,12 @@ impl
Option<String>,
),
) -> Result<Self, Self::Error> {
- let mut commerce_indicator = solution
- .as_ref()
- .map(|pm_solution| match pm_solution {
- PaymentSolution::ApplePay | PaymentSolution::SamsungPay => network
- .as_ref()
- .map(|card_network| match card_network.to_lowercase().as_str() {
- "amex" => "internet",
- "discover" => "internet",
- "mastercard" => "spa",
- "visa" => "internet",
- _ => "internet",
- })
- .unwrap_or("internet"),
- PaymentSolution::GooglePay => "internet",
- })
- .unwrap_or("internet")
- .to_string();
+ let mut commerce_indicator = get_commerce_indicator_for_wallet_payment(
+ solution.as_ref(),
+ &item.router_data.request.payment_method_data,
+ item.router_data.auth_type,
+ network.as_deref(),
+ );
let connector_merchant_config =
CybersourceConnectorMetadataObject::try_from(&item.router_data.connector_meta_data)?;
@@ -1097,7 +1103,7 @@ impl
),
None => None,
};
- commerce_indicator = "recurring".to_string();
+ commerce_indicator = Some("recurring".to_string());
(
None,
None,
@@ -1167,7 +1173,7 @@ impl
),
None => None,
};
- commerce_indicator = "recurring".to_string(); //
+ commerce_indicator = Some("recurring".to_string());
(
None,
None,
@@ -1232,7 +1238,7 @@ impl
authorization_options,
capture_options: None,
commerce_indicator: commerce_indicator_for_external_authentication
- .unwrap_or(commerce_indicator),
+ .or(commerce_indicator),
})
}
}
@@ -1334,6 +1340,48 @@ fn normalize_cybersource_card_network(card_network: Option<&str>) -> Option<&'st
})
}
+fn get_commerce_indicator_for_wallet_payment(
+ payment_solution: Option<&PaymentSolution>,
+ payment_method_data: &PaymentMethodData,
+ authentication_type: enums::AuthenticationType,
+ card_network: Option<&str>,
+) -> Option<String> {
+ let commerce_indicator = match payment_solution {
+ Some(PaymentSolution::GooglePay) => {
+ if payment_method_data.is_google_pay_pan_only() {
+ if authentication_type.is_three_ds() {
+ Some(match normalize_cybersource_card_network(card_network) {
+ Some("diners") => "pb",
+ Some("mastercard") => "spa",
+ Some("maestro") => "spa",
+ Some("visa") => "vbv",
+ Some("amex") => "aesk",
+ Some("discover") => "dipb",
+ Some("jcb") => "js",
+ _ => "internet",
+ })
+ } else {
+ Some("internet")
+ }
+ } else {
+ // CRYPTOGRAM_3DS token already carry the cryptogram and ECI as part
+ // of the network token, so the commerce_indicator field is omitted.
+ None
+ }
+ }
+ Some(PaymentSolution::ApplePay) | Some(PaymentSolution::SamsungPay) => Some(
+ card_network
+ .map(|card_network| match card_network.to_lowercase().as_str() {
+ "mastercard" => "spa",
+ _ => "internet",
+ })
+ .unwrap_or("internet"),
+ ),
+ None => Some("internet"),
+ };
+ commerce_indicator.map(String::from)
+}
+
impl
TryFrom<(
&CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>,
@@ -1408,10 +1456,12 @@ impl
action_token_types,
authorization_options,
capture_options: None,
- commerce_indicator: three_ds_data
- .indicator
- .to_owned()
- .unwrap_or(String::from("internet")),
+ commerce_indicator: Some(
+ three_ds_data
+ .indicator
+ .to_owned()
+ .unwrap_or(String::from("internet")),
+ ),
})
}
}
@@ -1756,7 +1806,6 @@ impl
ucaf_collection_indicator,
cavv,
ucaf_authentication_data,
- xid: None,
directory_server_transaction_id: authn_data
.ds_trans_id
.clone()
@@ -1773,6 +1822,7 @@ impl
network_score,
acs_transaction_id: authn_data.acs_trans_id.clone(),
cavv_algorithm,
+ ..Default::default()
}
});
@@ -1878,7 +1928,6 @@ impl
ucaf_collection_indicator,
cavv,
ucaf_authentication_data,
- xid: None,
directory_server_transaction_id: authn_data
.ds_trans_id
.clone()
@@ -1895,6 +1944,7 @@ impl
network_score,
acs_transaction_id: authn_data.acs_trans_id.clone(),
cavv_algorithm,
+ ..Default::default()
}
});
@@ -2004,7 +2054,6 @@ impl
ucaf_collection_indicator,
cavv,
ucaf_authentication_data,
- xid: None,
directory_server_transaction_id: authn_data
.ds_trans_id
.clone()
@@ -2021,6 +2070,7 @@ impl
network_score,
acs_transaction_id: authn_data.acs_trans_id.clone(),
cavv_algorithm,
+ ..Default::default()
}
});
@@ -2198,16 +2248,7 @@ impl
.directory_server_transaction_id,
specification_version: three_ds_info.three_ds_data.specification_version.clone(),
pa_specification_version: three_ds_info.three_ds_data.specification_version.clone(),
- veres_enrolled: None,
- eci_raw: None,
- authentication_date: None,
- effective_authentication_type: None,
- challenge_code: None,
- signed_pares_status_reason: None,
- challenge_cancel_code: None,
- network_score: None,
- acs_transaction_id: None,
- cavv_algorithm: None,
+ ..Default::default()
});
let merchant_defined_information = convert_metadata_to_merchant_defined_info(
@@ -2295,24 +2336,8 @@ impl
order_information,
client_reference_information,
consumer_authentication_information: Some(CybersourceConsumerAuthInformation {
- pares_status: None,
ucaf_collection_indicator,
- cavv: None,
- ucaf_authentication_data: None,
- xid: None,
- directory_server_transaction_id: None,
- specification_version: None,
- pa_specification_version: None,
- veres_enrolled: None,
- eci_raw: None,
- authentication_date: None,
- effective_authentication_type: None,
- challenge_code: None,
- signed_pares_status_reason: None,
- challenge_cancel_code: None,
- network_score: None,
- acs_transaction_id: None,
- cavv_algorithm: None,
+ ..Default::default()
}),
merchant_defined_information,
})
@@ -2358,8 +2383,11 @@ impl
transaction_type: TransactionType::InApp,
},
}));
- let processing_information =
- ProcessingInformation::try_from((item, Some(PaymentSolution::GooglePay), None))?;
+ let processing_information = ProcessingInformation::try_from((
+ item,
+ Some(PaymentSolution::GooglePay),
+ Some(google_pay_data.info.card_network.clone()),
+ ))?;
let client_reference_information = ClientReferenceInformation::from(item);
let merchant_defined_information = convert_metadata_to_merchant_defined_info(
item.router_data.request.metadata.clone(),
@@ -2447,24 +2475,8 @@ impl
order_information,
client_reference_information,
consumer_authentication_information: Some(CybersourceConsumerAuthInformation {
- pares_status: None,
ucaf_collection_indicator,
- cavv: None,
- ucaf_authentication_data: None,
- xid: None,
- directory_server_transaction_id: None,
- specification_version: None,
- pa_specification_version: None,
- veres_enrolled: None,
- eci_raw: None,
- authentication_date: None,
- effective_authentication_type: None,
- challenge_code: None,
- signed_pares_status_reason: None,
- challenge_cancel_code: None,
- network_score: None,
- acs_transaction_id: None,
- cavv_algorithm: None,
+ ..Default::default()
}),
merchant_defined_information,
})
@@ -2668,24 +2680,8 @@ impl TryFrom<&CybersourceRouterData<&PaymentsAuthorizeRouterData>> for Cybersour
merchant_defined_information,
consumer_authentication_information: Some(
CybersourceConsumerAuthInformation {
- pares_status: None,
ucaf_collection_indicator,
- cavv: None,
- ucaf_authentication_data: None,
- xid: None,
- directory_server_transaction_id: None,
- specification_version: None,
- pa_specification_version: None,
- veres_enrolled: None,
- eci_raw: None,
- authentication_date: None,
- effective_authentication_type: None,
- challenge_code: None,
- signed_pares_status_reason: None,
- challenge_cancel_code: None,
- network_score: None,
- acs_transaction_id: None,
- cavv_algorithm: None,
+ ..Default::default()
},
),
})
@@ -2876,11 +2872,68 @@ impl TryFrom<(&CybersourceRouterData<&PaymentsAuthorizeRouterData>, String)>
}
}
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct CybersourcePayerAuthProcessingInformation {
+ payment_solution: Option<String>,
+}
+
+impl TryFrom<&GooglePayWalletData> for PaymentInformation {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(gpay_data: &GooglePayWalletData) -> Result<Self, Self::Error> {
+ match &gpay_data.tokenization_data {
+ common_types::payments::GpayTokenizationData::Encrypted(_) => Ok(Self::GooglePayToken(
+ Box::new(GooglePayTokenPaymentInformation {
+ fluid_data: FluidData {
+ value: Secret::from(
+ consts::BASE64_ENGINE.encode(
+ gpay_data
+ .tokenization_data
+ .get_encrypted_google_pay_token()
+ .change_context(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "gpay wallet_token".into(),
+ },
+ )?,
+ ),
+ ),
+ descriptor: None,
+ },
+ tokenized_card: GooglePayTokenizedCard {
+ transaction_type: TransactionType::InApp,
+ },
+ }),
+ )),
+ common_types::payments::GpayTokenizationData::Decrypted(predecrypt_data) => {
+ Ok(Self::GooglePay(Box::new(GooglePayPaymentInformation {
+ tokenized_card: TokenizedCard {
+ number: predecrypt_data.application_primary_account_number.clone(),
+ expiration_year: predecrypt_data
+ .get_four_digit_expiry_year()
+ .change_context(errors::ConnectorError::InvalidDataFormat {
+ field_name: "expiration_year".into(),
+ })?,
+ expiration_month: predecrypt_data.get_expiry_month().change_context(
+ errors::ConnectorError::InvalidDataFormat {
+ field_name: "expiration_month".into(),
+ },
+ )?,
+ cryptogram: predecrypt_data.cryptogram.clone(),
+ transaction_type: TransactionType::InApp,
+ },
+ })))
+ }
+ }
+ }
+}
+
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CybersourceAuthSetupRequest {
payment_information: PaymentInformation,
client_reference_information: ClientReferenceInformation,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ processing_information: Option<CybersourcePayerAuthProcessingInformation>,
}
impl TryFrom<&CybersourceRouterData<&PaymentsAuthorizeRouterData>> for CybersourceAuthSetupRequest {
@@ -2914,6 +2967,18 @@ impl TryFrom<&CybersourceRouterData<&PaymentsAuthorizeRouterData>> for Cybersour
Ok(Self {
payment_information,
client_reference_information,
+ processing_information: None,
+ })
+ }
+ PaymentMethodData::Wallet(WalletData::GooglePay(gpay_data)) => {
+ let payment_information = PaymentInformation::try_from(&gpay_data)?;
+ let client_reference_information = ClientReferenceInformation::from(item);
+ Ok(Self {
+ payment_information,
+ client_reference_information,
+ processing_information: Some(CybersourcePayerAuthProcessingInformation {
+ payment_solution: Some(PaymentSolution::GooglePay.into()),
+ }),
})
}
PaymentMethodData::Wallet(_)
@@ -2983,6 +3048,18 @@ impl TryFrom<&CybersourceRouterData<&PaymentsPreAuthenticateRouterData>>
Ok(Self {
payment_information,
client_reference_information,
+ processing_information: None,
+ })
+ }
+ PaymentMethodData::Wallet(WalletData::GooglePay(gpay_data)) => {
+ let payment_information = PaymentInformation::try_from(&gpay_data)?;
+ let client_reference_information = ClientReferenceInformation::from(item);
+ Ok(Self {
+ payment_information,
+ client_reference_information,
+ processing_information: Some(CybersourcePayerAuthProcessingInformation {
+ payment_solution: Some(PaymentSolution::GooglePay.into()),
+ }),
})
}
PaymentMethodData::Wallet(_)
@@ -3063,7 +3140,7 @@ impl TryFrom<&CybersourceRouterData<&PaymentsCaptureRouterData>>
action_token_types: None,
authorization_options: None,
capture: None,
- commerce_indicator: String::from("internet"),
+ commerce_indicator: Some(String::from("internet")),
payment_solution: None,
},
order_information: OrderInformationWithBill {
@@ -3109,7 +3186,7 @@ impl TryFrom<&CybersourceRouterData<&PaymentsIncrementalAuthorizationRouterData>
ignore_avs_result: connector_merchant_config.disable_avs,
ignore_cv_result: connector_merchant_config.disable_cvn,
}),
- commerce_indicator: String::from("internet"),
+ commerce_indicator: Some(String::from("internet")),
capture: None,
capture_options: None,
payment_solution: None,
@@ -3618,12 +3695,81 @@ impl TryFrom<PaymentsResponseRouterData<CybersourceAuthSetupResponse>>
}
}
+#[derive(Debug, Clone, Serialize)]
+pub enum CybersourceDeviceChannel {
+ Browser,
+ #[serde(rename = "SDK")]
+ Sdk,
+}
+
+impl From<&api_models::payments::DeviceChannel> for CybersourceDeviceChannel {
+ fn from(channel: &api_models::payments::DeviceChannel) -> Self {
+ match channel {
+ api_models::payments::DeviceChannel::Browser => Self::Browser,
+ api_models::payments::DeviceChannel::App => Self::Sdk,
+ }
+ }
+}
+
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CybersourceConsumerAuthInformationRequest {
return_url: String,
reference_id: String,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ challenge_code: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ device_channel: Option<CybersourceDeviceChannel>,
+}
+
+fn get_payer_auth_challenge_code(force_3ds_challenge: Option<bool>) -> Option<String> {
+ force_3ds_challenge
+ .unwrap_or(false)
+ .then(|| "04".to_string())
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct CybersourceDeviceInformation {
+ http_accept_content: String,
+ http_browser_color_depth: String,
+ http_browser_java_enabled: bool,
+ http_browser_java_script_enabled: bool,
+ http_browser_language: String,
+ http_browser_screen_height: String,
+ http_browser_screen_width: String,
+ http_browser_time_difference: String,
+ ip_address: Secret<String, pii::IpAddress>,
+ user_agent_browser_value: String,
+}
+
+impl TryFrom<&BrowserInformation> for CybersourceDeviceInformation {
+ type Error = error_stack::Report<errors::ConnectorError>;
+
+ fn try_from(browser_info: &BrowserInformation) -> Result<Self, Self::Error> {
+ Ok(Self {
+ http_accept_content: browser_info.get_accept_header()?,
+ http_browser_color_depth: browser_info.get_color_depth()?.to_string(),
+ http_browser_java_enabled: browser_info.get_java_enabled()?,
+ http_browser_java_script_enabled: browser_info.get_java_script_enabled()?,
+ http_browser_language: browser_info.get_language()?,
+ http_browser_screen_height: browser_info.get_screen_height()?.to_string(),
+ http_browser_screen_width: browser_info.get_screen_width()?.to_string(),
+ http_browser_time_difference: browser_info.get_time_zone()?.to_string(),
+ ip_address: browser_info.get_ip_address()?,
+ user_agent_browser_value: browser_info.get_user_agent()?,
+ })
+ }
+}
+
+fn get_cybersource_device_information(
+ browser_info: Option<&BrowserInformation>,
+) -> Result<Option<CybersourceDeviceInformation>, error_stack::Report<errors::ConnectorError>> {
+ browser_info
+ .map(CybersourceDeviceInformation::try_from)
+ .transpose()
}
+
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CybersourceAuthEnrollmentRequest {
@@ -3631,6 +3777,10 @@ pub struct CybersourceAuthEnrollmentRequest {
client_reference_information: ClientReferenceInformation,
consumer_authentication_information: CybersourceConsumerAuthInformationRequest,
order_information: OrderInformationWithBill,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ processing_information: Option<CybersourcePayerAuthProcessingInformation>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ device_information: Option<CybersourceDeviceInformation>,
}
#[derive(Debug, Deserialize)]
@@ -3652,6 +3802,8 @@ pub struct CybersourceAuthValidateRequest {
client_reference_information: ClientReferenceInformation,
consumer_authentication_information: CybersourceConsumerAuthInformationValidateRequest,
order_information: OrderInformation,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ processing_information: Option<CybersourcePayerAuthProcessingInformation>,
}
#[derive(Debug, Serialize)]
@@ -3676,7 +3828,7 @@ impl TryFrom<&CybersourceRouterData<&PaymentsPreProcessingRouterData>>
field_name: "payment_method_data".into(),
},
)?;
- let payment_information = match payment_method_data {
+ let (payment_information, payment_solution) = match payment_method_data {
PaymentMethodData::Card(ccard) => {
let card_type = match ccard
.card_network
@@ -3687,8 +3839,8 @@ impl TryFrom<&CybersourceRouterData<&PaymentsPreProcessingRouterData>>
None => ccard.get_card_issuer().ok().map(String::from),
};
- Ok(PaymentInformation::Cards(Box::new(
- CardPaymentInformation {
+ Ok((
+ PaymentInformation::Cards(Box::new(CardPaymentInformation {
card: Card {
number: ccard.card_number,
expiration_month: ccard.card_exp_month,
@@ -3697,9 +3849,14 @@ impl TryFrom<&CybersourceRouterData<&PaymentsPreProcessingRouterData>>
card_type,
type_selection_indicator: Some("1".to_owned()),
},
- },
- )))
+ })),
+ None,
+ ))
}
+ PaymentMethodData::Wallet(WalletData::GooglePay(gpay_data)) => Ok((
+ PaymentInformation::try_from(&gpay_data)?,
+ Some(String::from(PaymentSolution::GooglePay)),
+ )),
PaymentMethodData::Wallet(_)
| PaymentMethodData::CardRedirect(_)
| PaymentMethodData::PayLater(_)
@@ -3764,6 +3921,26 @@ impl TryFrom<&CybersourceRouterData<&PaymentsPreProcessingRouterData>>
amount_details,
bill_to: Some(bill_to),
};
+ let is_wallet_payer_auth = payment_solution.is_some();
+ let processing_information =
+ payment_solution.map(|solution| CybersourcePayerAuthProcessingInformation {
+ payment_solution: Some(solution),
+ });
+ let (device_information, challenge_code, device_channel) = if is_wallet_payer_auth {
+ (
+ get_cybersource_device_information(
+ item.router_data.request.browser_info.as_ref(),
+ )?,
+ get_payer_auth_challenge_code(item.router_data.request.force_3ds_challenge),
+ item.router_data
+ .request
+ .device_channel
+ .as_ref()
+ .map(CybersourceDeviceChannel::from),
+ )
+ } else {
+ (None, None, None)
+ };
Ok(Self::AuthEnrollment(Box::new(
CybersourceAuthEnrollmentRequest {
payment_information,
@@ -3775,8 +3952,12 @@ impl TryFrom<&CybersourceRouterData<&PaymentsPreProcessingRouterData>>
.request
.get_complete_authorize_url()?,
reference_id,
+ challenge_code,
+ device_channel,
},
order_information,
+ processing_information,
+ device_information,
},
)))
}
@@ -3791,6 +3972,10 @@ impl TryFrom<&CybersourceRouterData<&PaymentsPreProcessingRouterData>>
.parse_value("CybersourceRedirectionAuthResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
let order_information = OrderInformation { amount_details };
+ let processing_information =
+ payment_solution.map(|solution| CybersourcePayerAuthProcessingInformation {
+ payment_solution: Some(solution),
+ });
Ok(Self::AuthValidate(Box::new(
CybersourceAuthValidateRequest {
payment_information,
@@ -3800,6 +3985,7 @@ impl TryFrom<&CybersourceRouterData<&PaymentsPreProcessingRouterData>>
authentication_transaction_id: redirect_payload.transaction_id,
},
order_information,
+ processing_information,
},
)))
}
@@ -3822,7 +4008,9 @@ impl TryFrom<&CybersourceRouterData<&PaymentsAuthenticateRouterData>>
field_name: "payment_method_data".into(),
},
)?;
- let payment_information = match payment_method_data {
+ let challenge_code =
+ get_payer_auth_challenge_code(item.router_data.request.force_3ds_challenge);
+ let (payment_information, payment_solution) = match payment_method_data {
PaymentMethodData::Card(ccard) => {
let card_type = match ccard
.card_network
@@ -3833,8 +4021,8 @@ impl TryFrom<&CybersourceRouterData<&PaymentsAuthenticateRouterData>>
None => ccard.get_card_issuer().ok().map(String::from),
};
- Ok(PaymentInformation::Cards(Box::new(
- CardPaymentInformation {
+ Ok((
+ PaymentInformation::Cards(Box::new(CardPaymentInformation {
card: Card {
number: ccard.card_number,
expiration_month: ccard.card_exp_month,
@@ -3843,9 +4031,14 @@ impl TryFrom<&CybersourceRouterData<&PaymentsAuthenticateRouterData>>
card_type,
type_selection_indicator: Some("1".to_owned()),
},
- },
- )))
+ })),
+ None,
+ ))
}
+ PaymentMethodData::Wallet(WalletData::GooglePay(gpay_data)) => Ok((
+ PaymentInformation::try_from(&gpay_data)?,
+ Some(String::from(PaymentSolution::GooglePay)),
+ )),
PaymentMethodData::Wallet(_)
| PaymentMethodData::CardRedirect(_)
| PaymentMethodData::PayLater(_)
@@ -3916,6 +4109,14 @@ impl TryFrom<&CybersourceRouterData<&PaymentsAuthenticateRouterData>>
amount_details,
bill_to: Some(bill_to),
};
+ let device_information =
+ get_cybersource_device_information(item.router_data.request.browser_info.as_ref())?;
+ let device_channel = item
+ .router_data
+ .request
+ .device_channel
+ .as_ref()
+ .map(CybersourceDeviceChannel::from);
Ok(Self {
payment_information,
client_reference_information,
@@ -3927,8 +4128,16 @@ impl TryFrom<&CybersourceRouterData<&PaymentsAuthenticateRouterData>>
.clone()
.ok_or_else(utils::missing_field_err("complete_authorize_url"))?,
reference_id,
+ challenge_code,
+ device_channel,
},
order_information,
+ processing_information: payment_solution.map(|solution| {
+ CybersourcePayerAuthProcessingInformation {
+ payment_solution: Some(solution),
+ }
+ }),
+ device_information,
})
}
}
@@ -3948,7 +4157,7 @@ impl TryFrom<&CybersourceRouterData<&PaymentsPostAuthenticateRouterData>>
field_name: "payment_method_data".into(),
},
)?;
- let payment_information = match payment_method_data {
+ let (payment_information, payment_solution) = match payment_method_data {
PaymentMethodData::Card(ccard) => {
let card_type = match ccard
.card_network
@@ -3959,8 +4168,8 @@ impl TryFrom<&CybersourceRouterData<&PaymentsPostAuthenticateRouterData>>
None => ccard.get_card_issuer().ok().map(String::from),
};
- Ok(PaymentInformation::Cards(Box::new(
- CardPaymentInformation {
+ Ok((
+ PaymentInformation::Cards(Box::new(CardPaymentInformation {
card: Card {
number: ccard.card_number,
expiration_month: ccard.card_exp_month,
@@ -3969,9 +4178,14 @@ impl TryFrom<&CybersourceRouterData<&PaymentsPostAuthenticateRouterData>>
card_type,
type_selection_indicator: Some("1".to_owned()),
},
- },
- )))
+ })),
+ None,
+ ))
}
+ PaymentMethodData::Wallet(WalletData::GooglePay(gpay_data)) => Ok((
+ PaymentInformation::try_from(&gpay_data)?,
+ Some(String::from(PaymentSolution::GooglePay)),
+ )),
PaymentMethodData::Wallet(_)
| PaymentMethodData::CardRedirect(_)
| PaymentMethodData::PayLater(_)
@@ -4034,6 +4248,11 @@ impl TryFrom<&CybersourceRouterData<&PaymentsPostAuthenticateRouterData>>
authentication_transaction_id: redirect_payload.transaction_id,
},
order_information,
+ processing_information: payment_solution.map(|solution| {
+ CybersourcePayerAuthProcessingInformation {
+ payment_solution: Some(solution),
+ }
+ }),
})
}
}
@@ -4052,6 +4271,9 @@ impl TryFrom<&CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>>
)?;
match payment_method_data {
PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)),
+ PaymentMethodData::Wallet(WalletData::GooglePay(gpay_data)) => {
+ Self::try_from((item, gpay_data))
+ }
PaymentMethodData::Wallet(_)
| PaymentMethodData::CardRedirect(_)
| PaymentMethodData::PayLater(_)
@@ -4084,6 +4306,80 @@ impl TryFrom<&CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>>
}
}
+impl
+ TryFrom<(
+ &CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>,
+ GooglePayWalletData,
+ )> for CybersourcePaymentsRequest
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ (item, gpay_data): (
+ &CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>,
+ GooglePayWalletData,
+ ),
+ ) -> Result<Self, Self::Error> {
+ let email = item
+ .router_data
+ .get_billing_email()
+ .or(item.router_data.request.get_email())?;
+ let bill_to = build_bill_to(item.router_data.get_optional_billing(), email)?;
+ let order_information = OrderInformationWithBill::from((item, bill_to));
+ let payment_information = PaymentInformation::try_from(&gpay_data)?;
+
+ let three_ds_info: CybersourceThreeDSMetadata = item
+ .router_data
+ .request
+ .connector_meta
+ .clone()
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "connector_meta".into(),
+ })?
+ .parse_value("CybersourceThreeDSMetadata")
+ .change_context(errors::ConnectorError::InvalidConnectorConfig {
+ config: "metadata",
+ })?;
+
+ let processing_information = ProcessingInformation::try_from((
+ item,
+ Some(PaymentSolution::GooglePay),
+ &three_ds_info.three_ds_data,
+ ))?;
+ let client_reference_information = ClientReferenceInformation::from(item);
+
+ let consumer_authentication_information = Some(CybersourceConsumerAuthInformation {
+ ucaf_collection_indicator: three_ds_info
+ .three_ds_data
+ .ucaf_collection_indicator
+ .clone(),
+ cavv: three_ds_info.three_ds_data.cavv.clone(),
+ ucaf_authentication_data: three_ds_info.three_ds_data.ucaf_authentication_data.clone(),
+ xid: three_ds_info.three_ds_data.xid.clone(),
+ directory_server_transaction_id: three_ds_info
+ .three_ds_data
+ .directory_server_transaction_id
+ .clone(),
+ specification_version: three_ds_info.three_ds_data.specification_version.clone(),
+ pa_specification_version: three_ds_info.three_ds_data.specification_version.clone(),
+ ..Default::default()
+ });
+
+ let merchant_defined_information = convert_metadata_to_merchant_defined_info(
+ item.router_data.request.metadata.clone(),
+ item.router_data.request.merchant_order_reference_id.clone(),
+ );
+
+ Ok(Self {
+ processing_information,
+ payment_information,
+ order_information,
+ client_reference_information,
+ consumer_authentication_information,
+ merchant_defined_information,
+ })
+ }
+}
+
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum CybersourceAuthEnrollmentStatus {
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index 7502a4fc34..52d36f0ade 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -296,6 +296,7 @@ impl TryFrom<payment_method_data::GooglePayWalletData> for GooglePayWalletData {
common_types::payments::GpayEcryptedTokenizationData {
token_type: encrypted_data.token_type,
token: encrypted_data.token,
+ auth_method: encrypted_data.auth_method,
},
)
}
diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rs
index d623ce2e1c..52ed4ae195 100644
--- a/crates/hyperswitch_domain_models/src/payment_method_data.rs
+++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs
@@ -330,6 +330,14 @@ impl PaymentMethodData {
matches!(self, Self::NetworkToken(_))
}
+ pub fn is_google_pay_pan_only(&self) -> bool {
+ if let Self::Wallet(WalletData::GooglePay(gpay_data)) = self {
+ gpay_data.is_pan_only()
+ } else {
+ false
+ }
+ }
+
pub fn get_co_badged_card_data(&self) -> Option<&payment_methods::CoBadgedCardData> {
match self {
Self::Card(card) => card.co_badged_card_data.as_ref(),
@@ -1181,6 +1189,20 @@ pub struct GooglePayWalletData {
pub tokenization_data: common_types::payments::GpayTokenizationData,
}
+impl GooglePayWalletData {
+ pub fn is_pan_only(&self) -> bool {
+ self.tokenization_data
+ .get_encrypted_auth_method()
+ .map(|auth_method| auth_method == common_enums::GooglePayAuthMethod::PanOnly)
+ .unwrap_or_else(|| {
+ self.info
+ .assurance_details
+ .as_ref()
+ .is_some_and(|assurance_details| !assurance_details.card_holder_authenticated)
+ })
+ }
+}
+
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct ApplePayRedirectData {}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize)]
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs
index c167754d21..c96e93ad07 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs
@@ -428,6 +428,9 @@ impl TryFrom<SetupMandateRequestData> for PaymentsPreProcessingData {
type Error = error_stack::Report<ApiErrorResponse>;
fn try_from(data: SetupMandateRequestData) -> Result<Self, Self::Error> {
+ let device_channel = Some(BrowserInformation::resolve_device_channel(
+ data.browser_info.as_ref(),
+ ));
Ok(Self {
payment_method_data: Some(data.payment_method_data),
amount: data.amount,
@@ -442,6 +445,7 @@ impl TryFrom<SetupMandateRequestData> for PaymentsPreProcessingData {
webhook_url: data.webhook_url,
complete_authorize_url: data.complete_authorize_url,
browser_info: data.browser_info,
+ device_channel,
surcharge_details: None,
connector_transaction_id: None,
mandate_id: data.mandate_id,
@@ -453,6 +457,7 @@ impl TryFrom<SetupMandateRequestData> for PaymentsPreProcessingData {
customer_acceptance: data.customer_acceptance,
setup_future_usage: data.setup_future_usage,
is_stored_credential: data.is_stored_credential,
+ force_3ds_challenge: None,
})
}
}
@@ -769,6 +774,7 @@ pub struct PaymentsPreProcessingData {
pub complete_authorize_url: Option<String>,
pub surcharge_details: Option<SurchargeDetails>,
pub browser_info: Option<BrowserInformation>,
+ pub device_channel: Option<api_models::payments::DeviceChannel>,
pub connector_transaction_id: Option<String>,
pub enrolled_for_3ds: bool,
pub mandate_id: Option<mandates::MandateIds>,
@@ -781,6 +787,7 @@ pub struct PaymentsPreProcessingData {
// New amount for amount frame work
pub minor_amount: MinorUnit,
pub is_stored_credential: Option<bool>,
+ pub force_3ds_challenge: Option<bool>,
}
#[derive(Debug, Clone, Serialize)]
@@ -832,6 +839,9 @@ impl TryFrom<PaymentsAuthorizeData> for PaymentsPreProcessingData {
type Error = error_stack::Report<ApiErrorResponse>;
fn try_from(data: PaymentsAuthorizeData) -> Result<Self, Self::Error> {
+ let device_channel = Some(BrowserInformation::resolve_device_channel(
+ data.browser_info.as_ref(),
+ ));
Ok(Self {
payment_method_data: Some(data.payment_method_data),
amount: data.amount,
@@ -846,6 +856,7 @@ impl TryFrom<PaymentsAuthorizeData> for PaymentsPreProcessingData {
webhook_url: data.webhook_url,
complete_authorize_url: data.complete_authorize_url,
browser_info: data.browser_info,
+ device_channel,
surcharge_details: data.surcharge_details,
connector_transaction_id: None,
mandate_id: data.mandate_id,
@@ -857,6 +868,7 @@ impl TryFrom<PaymentsAuthorizeData> for PaymentsPreProcessingData {
customer_acceptance: data.customer_acceptance,
setup_future_usage: data.setup_future_usage,
is_stored_credential: data.is_stored_credential,
+ force_3ds_challenge: None,
})
}
}
@@ -930,6 +942,9 @@ impl TryFrom<PaymentsAuthorizeData> for PaymentsAuthenticateData {
type Error = error_stack::Report<ApiErrorResponse>;
fn try_from(data: PaymentsAuthorizeData) -> Result<Self, Self::Error> {
+ let device_channel = Some(BrowserInformation::resolve_device_channel(
+ data.browser_info.as_ref(),
+ ));
Ok(Self {
payment_method_data: Some(data.payment_method_data),
payment_method_type: data.payment_method_type,
@@ -945,8 +960,9 @@ impl TryFrom<PaymentsAuthorizeData> for PaymentsAuthenticateData {
// This is handled within authentication_step function in authorize_flow.rs
authentication_data: None,
sdk_information: None,
- device_channel: None,
+ device_channel,
webhook_url: data.webhook_url,
+ force_3ds_challenge: data.force_3ds_challenge,
})
}
}
@@ -967,12 +983,16 @@ pub struct PaymentsAuthenticateData {
pub sdk_information: Option<api_models::payments::SdkInformation>,
pub device_channel: Option<api_models::payments::DeviceChannel>,
pub webhook_url: Option<String>,
+ pub force_3ds_challenge: Option<bool>,
}
impl TryFrom<CompleteAuthorizeData> for PaymentsAuthenticateData {
type Error = error_stack::Report<ApiErrorResponse>;
fn try_from(data: CompleteAuthorizeData) -> Result<Self, Self::Error> {
+ let device_channel = Some(BrowserInformation::resolve_device_channel(
+ data.browser_info.as_ref(),
+ ));
Ok(Self {
payment_method_data: data.payment_method_data,
payment_method_type: data.payment_method_type,
@@ -986,8 +1006,9 @@ impl TryFrom<CompleteAuthorizeData> for PaymentsAuthenticateData {
capture_method: data.capture_method,
authentication_data: data.authentication_data,
sdk_information: None,
- device_channel: None,
+ device_channel,
webhook_url: None,
+ force_3ds_challenge: data.force_3ds_challenge,
})
}
}
@@ -1034,6 +1055,9 @@ impl TryFrom<CompleteAuthorizeData> for PaymentsPreProcessingData {
type Error = error_stack::Report<ApiErrorResponse>;
fn try_from(data: CompleteAuthorizeData) -> Result<Self, Self::Error> {
+ let device_channel = Some(BrowserInformation::resolve_device_channel(
+ data.browser_info.as_ref(),
+ ));
Ok(Self {
payment_method_data: data.payment_method_data,
amount: data.amount,
@@ -1048,6 +1072,7 @@ impl TryFrom<CompleteAuthorizeData> for PaymentsPreProcessingData {
webhook_url: None,
complete_authorize_url: data.complete_authorize_url,
browser_info: data.browser_info,
+ device_channel,
surcharge_details: None,
connector_transaction_id: data.connector_transaction_id,
mandate_id: data.mandate_id,
@@ -1059,6 +1084,7 @@ impl TryFrom<CompleteAuthorizeData> for PaymentsPreProcessingData {
customer_acceptance: data.customer_acceptance,
setup_future_usage: data.setup_future_usage,
is_stored_credential: data.is_stored_credential,
+ force_3ds_challenge: data.force_3ds_challenge,
})
}
}
@@ -1138,6 +1164,7 @@ pub struct CompleteAuthorizeData {
pub recipient_details: Option<api_models::payments::RecipientDetails>,
pub business_country: Option<common_enums::CountryAlpha2>,
pub connector_intent_metadata: Option<ConnectorMetadata>,
+ pub force_3ds_challenge: Option<bool>,
}
#[derive(Debug, Clone, Serialize)]
@@ -1260,6 +1287,17 @@ pub struct BrowserInformation {
pub referer: Option<String>,
}
+impl BrowserInformation {
+ pub fn resolve_device_channel(
+ browser_info: Option<&Self>,
+ ) -> api_models::payments::DeviceChannel {
+ match browser_info {
+ Some(_) => api_models::payments::DeviceChannel::Browser,
+ None => api_models::payments::DeviceChannel::App,
+ }
+ }
+}
+
#[cfg(feature = "v2")]
impl From<common_utils::types::BrowserInformation> for BrowserInformation {
fn from(value: common_utils::types::BrowserInformation) -> Self {
diff --git a/crates/router/src/core/authentication.rs b/crates/router/src/core/authentication.rs
index 3eaf9d3c2a..24b77ea5ef 100644
--- a/crates/router/src/core/authentication.rs
+++ b/crates/router/src/core/authentication.rs
@@ -1336,6 +1336,7 @@ async fn call_ucs_authenticate_proxy(
sdk_information: sdk_information.clone(),
device_channel: Some(device_channel.clone()),
webhook_url: None,
+ force_3ds_challenge: None,
};
let payment_address = hyperswitch_domain_models::payment_address::PaymentAddress::new(
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index d2c7f6c8c7..81cd35d6fa 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -3951,11 +3951,24 @@ pub async fn store_payment_method_data_in_vault(
merchant_key_store: &domain::MerchantKeyStore,
business_profile: Option<&domain::Profile>,
) -> RouterResult<Option<String>> {
+ let should_store_google_pay_pan_only_for_three_ds = payment_attempt
+ .connector
+ .as_deref()
+ .and_then(|connector| api_enums::Connector::from_str(connector).ok())
+ .is_some_and(|connector| {
+ connector.should_store_google_pay_pan_only_for_three_ds(
+ payment_method,
+ payment_attempt.authentication_type,
+ payment_method_data.is_google_pay_pan_only(),
+ )
+ });
+
if should_store_payment_method_data_in_vault(
&state.conf.temp_locker_enable_config,
payment_attempt.connector.clone(),
payment_method,
) || payment_intent.request_external_three_ds_authentication == Some(true)
+ || should_store_google_pay_pan_only_for_three_ds
{
let parent_payment_method_token = store_in_vault_and_generate_ppmt(
state,
@@ -3973,6 +3986,7 @@ pub async fn store_payment_method_data_in_vault(
Ok(None)
}
+
pub fn should_store_payment_method_data_in_vault(
temp_locker_enable_config: &TempLockerEnableConfig,
option_connector: Option<String>,
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 851339dc32..f7735d8be1 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -7426,6 +7426,11 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
recipient_details,
business_country: payment_data.payment_intent.business_country,
connector_intent_metadata,
+ force_3ds_challenge: payment_data
+ .payment_intent
+ .force_3ds_challenge_trigger
+ .filter(|trigger| *trigger)
+ .or(payment_data.payment_intent.force_3ds_challenge),
})
}
}
@@ -7508,6 +7513,9 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProce
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "browser_info".into(),
})?;
+ let device_channel = Some(types::BrowserInformation::resolve_device_channel(
+ browser_info.as_ref(),
+ ));
let amount = payment_data.payment_attempt.get_total_amount();
Ok(Self {
payment_method_data,
@@ -7523,6 +7531,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProce
webhook_url,
complete_authorize_url,
browser_info,
+ device_channel,
surcharge_details: payment_data.surcharge_details,
connector_transaction_id: payment_data
.payment_attempt
@@ -7540,6 +7549,11 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProce
.setup_future_usage_applied
.or(payment_data.payment_intent.setup_future_usage),
is_stored_credential: payment_data.payment_attempt.is_stored_credential,
+ force_3ds_challenge: payment_data
+ .payment_intent
+ .force_3ds_challenge_trigger
+ .filter(|trigger| *trigger)
+ .or(payment_data.payment_intent.force_3ds_challenge),
})
}
}
diff --git a/crates/router/tests/connectors/payu.rs b/crates/router/tests/connectors/payu.rs
index 0994dd4954..b6d3ea94f8 100644
--- a/crates/router/tests/connectors/payu.rs
+++ b/crates/router/tests/connectors/payu.rs
@@ -104,6 +104,7 @@ async fn should_authorize_gpay_payment() {
common_types::payments::GpayEcryptedTokenizationData {
token_type: "worldpay".to_string(),
token: "someToken".to_string(),
+ auth_method: None,
},
),
}),
diff --git a/crates/router/tests/connectors/worldpay.rs b/crates/router/tests/connectors/worldpay.rs
index 022d0862cb..600a6e9d20 100644
--- a/crates/router/tests/connectors/worldpay.rs
+++ b/crates/router/tests/connectors/worldpay.rs
@@ -77,6 +77,7 @@ async fn should_authorize_gpay_payment() {
common_types::payments::GpayEcryptedTokenizationData {
token_type: "worldpay".to_string(),
token: "someToken".to_string(),
+ auth_method: None,
},
),
}),