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
fix(connector): [CYBERSOURCE] Passing pares_status for MasterCard & Visa and transaction_type field (#8518)
Sayak Bhattacharya721f780c6baf
diff --git a/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rsindex 55528604a7..1cb0b88a13 100644--- a/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs@@ -215,7 +215,7 @@ impl TryFrom<&SetupMandateRouterData> for CybersourceZeroMandateRequest {cryptogram: Some(decrypt_data.payment_data.online_payment_cryptogram,),- transaction_type: TransactionType::ApplePay,+ transaction_type: TransactionType::InApp,expiration_year,expiration_month,},@@ -244,7 +244,7 @@ impl TryFrom<&SetupMandateRouterData> for CybersourceZeroMandateRequest {descriptor: Some(FLUID_DATA_DESCRIPTOR.to_string()),},tokenized_card: ApplePayTokenizedCard {- transaction_type: TransactionType::ApplePay,+ transaction_type: TransactionType::InApp,},},)),@@ -366,6 +366,18 @@ pub struct ProcessingInformation {payment_solution: Option<String>,}+#[derive(Debug, Serialize)]+pub enum CybersourceParesStatus {+ #[serde(rename = "Y")]+ AuthenticationSuccessful,+ #[serde(rename = "A")]+ AuthenticationAttempted,+ #[serde(rename = "N")]+ AuthenticationFailed,+ #[serde(rename = "U")]+ AuthenticationNotCompleted,+}+#[derive(Debug, Serialize)]#[serde(rename_all = "camelCase")]pub struct CybersourceConsumerAuthInformation {@@ -385,6 +397,9 @@ pub struct CybersourceConsumerAuthInformation {veres_enrolled: Option<String>,/// Raw electronic commerce indicator (ECI)eci_raw: Option<String>,+ /// This field is supported only on Asia, Middle East, and Africa Gateway+ /// This field is only applicable for Mastercard and Visa Transactions+ pares_status: Option<CybersourceParesStatus>,}#[derive(Debug, Serialize)]@@ -456,7 +471,7 @@ pub struct NetworkTokenizedCard {expiration_month: Secret<String>,expiration_year: Secret<String>,cryptogram: Option<Secret<String>>,- transaction_type: String,+ transaction_type: TransactionType,}#[derive(Debug, Serialize)]@@ -622,11 +637,11 @@ pub enum PaymentSolution {#[derive(Debug, Serialize)]pub enum TransactionType {#[serde(rename = "1")]- ApplePay,- #[serde(rename = "1")]- SamsungPay,- #[serde(rename = "1")]- GooglePay,+ InApp,+ #[serde(rename = "2")]+ ContactlessNFC,+ #[serde(rename = "3")]+ StoredCredentials,}impl From<PaymentSolution> for String {@@ -1263,6 +1278,13 @@ implNone => ccard.get_card_issuer().ok().map(String::from),};+ let pares_status =+ if card_type == Some("001".to_string()) || card_type == Some("002".to_string()) {+ Some(CybersourceParesStatus::AuthenticationSuccessful)+ } else {+ None+ };+let security_code = if item.router_data.request@@ -1324,6 +1346,7 @@ impl(None, Some(authn_data.cavv.clone()), None)};CybersourceConsumerAuthInformation {+ pares_status,ucaf_collection_indicator,cavv,ucaf_authentication_data,@@ -1375,6 +1398,14 @@ implOk(issuer) => Some(String::from(issuer)),Err(_) => None,};++ let pares_status =+ if card_type == Some("001".to_string()) || card_type == Some("002".to_string()) {+ Some(CybersourceParesStatus::AuthenticationSuccessful)+ } else {+ None+ };+let is_cobadged_card = ccard.card_number.clone()@@ -1421,6 +1452,7 @@ impl(None, Some(authn_data.cavv.clone()), None)};CybersourceConsumerAuthInformation {+ pares_status,ucaf_collection_indicator,cavv,ucaf_authentication_data,@@ -1460,6 +1492,12 @@ implNetworkTokenData,),) -> Result<Self, Self::Error> {+ let transaction_type = if item.router_data.request.off_session == Some(true) {+ TransactionType::StoredCredentials+ } else {+ TransactionType::InApp+ };+let email = 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, Some(bill_to)));@@ -1470,6 +1508,13 @@ implErr(_) => None,};+ let pares_status =+ if card_type == Some("001".to_string()) || card_type == Some("002".to_string()) {+ Some(CybersourceParesStatus::AuthenticationSuccessful)+ } else {+ None+ };+let payment_information =PaymentInformation::NetworkToken(Box::new(NetworkTokenPaymentInformation {tokenized_card: NetworkTokenizedCard {@@ -1477,7 +1522,7 @@ implexpiration_month: token_data.get_network_token_expiry_month(),expiration_year: token_data.get_network_token_expiry_year(),cryptogram: token_data.get_cryptogram().clone(),- transaction_type: "1".to_string(),+ transaction_type,},}));@@ -1503,6 +1548,7 @@ impl(None, Some(authn_data.cavv.clone()), None)};CybersourceConsumerAuthInformation {+ pares_status,ucaf_collection_indicator,cavv,ucaf_authentication_data,@@ -1542,6 +1588,12 @@ implBox<hyperswitch_domain_models::router_data::PazeDecryptedData>,),) -> Result<Self, Self::Error> {+ let transaction_type = if item.router_data.request.off_session == Some(true) {+ TransactionType::StoredCredentials+ } else {+ TransactionType::InApp+ };+let email = item.router_data.request.get_email()?;let (first_name, last_name) = match paze_data.billing_address.name {Some(name) => {@@ -1591,7 +1643,7 @@ implexpiration_month: paze_data.token.token_expiration_month,expiration_year: paze_data.token.token_expiration_year,cryptogram: Some(paze_data.token.payment_account_reference),- transaction_type: "1".to_string(),+ transaction_type,},}));@@ -1644,6 +1696,13 @@ implNone => ccard.get_card_issuer().ok().map(String::from),};+ let pares_status =+ if card_type == Some("001".to_string()) || card_type == Some("002".to_string()) {+ Some(CybersourceParesStatus::AuthenticationSuccessful)+ } else {+ None+ };+let is_cobadged_card = ccard.card_number.clone()@@ -1686,6 +1745,7 @@ implProcessingInformation::try_from((item, None, &three_ds_info.three_ds_data))?;let consumer_authentication_information = Some(CybersourceConsumerAuthInformation {+ pares_status,ucaf_collection_indicator: three_ds_info.three_ds_data.ucaf_collection_indicator,cavv: three_ds_info.three_ds_data.cavv,ucaf_authentication_data: three_ds_info.three_ds_data.ucaf_authentication_data,@@ -1732,6 +1792,12 @@ implApplePayWalletData,),) -> Result<Self, Self::Error> {+ let transaction_type = if item.router_data.request.off_session == Some(true) {+ TransactionType::StoredCredentials+ } else {+ TransactionType::InApp+ };+let email = item.router_data.get_billing_email()@@ -1751,7 +1817,7 @@ impltokenized_card: TokenizedCard {number: apple_pay_data.application_primary_account_number,cryptogram: Some(apple_pay_data.payment_data.online_payment_cryptogram),- transaction_type: TransactionType::ApplePay,+ transaction_type,expiration_year,expiration_month,},@@ -1777,6 +1843,7 @@ implorder_information,client_reference_information,consumer_authentication_information: Some(CybersourceConsumerAuthInformation {+ pares_status: None,ucaf_collection_indicator,cavv: None,ucaf_authentication_data: None,@@ -1857,6 +1924,11 @@ implGooglePayWalletData,),) -> Result<Self, Self::Error> {+ let transaction_type = if item.router_data.request.off_session == Some(true) {+ TransactionType::StoredCredentials+ } else {+ TransactionType::InApp+ };let email = item.router_data.get_billing_email()@@ -1874,7 +1946,7 @@ impl.get_card_no(),),cryptogram: google_pay_decrypted_data.payment_method_details.cryptogram,- transaction_type: TransactionType::GooglePay,+ transaction_type,expiration_year: Secret::new(google_pay_decrypted_data.payment_method_details@@ -1914,6 +1986,7 @@ implorder_information,client_reference_information,consumer_authentication_information: Some(CybersourceConsumerAuthInformation {+ pares_status: None,ucaf_collection_indicator,cavv: None,ucaf_authentication_data: None,@@ -1995,7 +2068,7 @@ fn get_samsung_pay_payment_information(),},tokenized_card: SamsungPayTokenizedCard {- transaction_type: TransactionType::SamsungPay,+ transaction_type: TransactionType::InApp,},}));@@ -2057,6 +2130,12 @@ impl TryFrom<&CybersourceRouterData<&PaymentsAuthorizeRouterData>> for Cybersour)?,},None => {+ let transaction_type =+ if item.router_data.request.off_session == Some(true) {+ TransactionType::StoredCredentials+ } else {+ TransactionType::InApp+ };let email = item.router_data.get_billing_email()@@ -2082,7 +2161,7 @@ impl TryFrom<&CybersourceRouterData<&PaymentsAuthorizeRouterData>> for Cybersourdescriptor: Some(FLUID_DATA_DESCRIPTOR.to_string()),},tokenized_card: ApplePayTokenizedCard {- transaction_type: TransactionType::ApplePay,+ transaction_type,},}),);@@ -2107,6 +2186,7 @@ impl TryFrom<&CybersourceRouterData<&PaymentsAuthorizeRouterData>> for Cybersourmerchant_defined_information,consumer_authentication_information: Some(CybersourceConsumerAuthInformation {+ pares_status: None,ucaf_collection_indicator,cavv: None,ucaf_authentication_data: None,