Skip to content

Commit

Permalink
feat: add sca_exemption to netcetera
Browse files Browse the repository at this point in the history
  • Loading branch information
Sakilmostak committed Nov 19, 2024
1 parent 8c38956 commit 2edd4ff
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 5 deletions.
61 changes: 57 additions & 4 deletions crates/router/src/connector/netcetera/netcetera_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,38 @@ impl From<crate::types::BrowserInformation> for Browser {
}
}

impl From<common_enums::ScaExemptionType> for MessageExtensionAttribute {
fn from(value: common_enums::ScaExemptionType) -> Self {
Self {
id: None,
name: None,
criticality_indicator: None,
data: MessageDataAttribute::from(value),
}
}
}

impl From<common_enums::ScaExemptionType> for MessageDataAttribute {
fn from(value: common_enums::ScaExemptionType) -> Self {
match value {
common_enums::ScaExemptionType::LowRiskExemption => Self {
sca_exemptions: Some(ScaExemptions::LowRiskExemption),
secure_corporate_payment: None,
},
common_enums::ScaExemptionType::SecureCorporateExemption => Self {
sca_exemptions: None,
secure_corporate_payment: Some(SecureCorporatePayment::Yes),
},
common_enums::ScaExemptionType::LowValueExemption
| common_enums::ScaExemptionType::TrustedBeneficiaryExemption
| common_enums::ScaExemptionType::MerchantInitiatedTransactionExemption => Self {
sca_exemptions: None,
secure_corporate_payment: None,
},
}
}
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum ChallengeWindowSizeEnum {
#[serde(rename = "01")]
Expand Down Expand Up @@ -1591,10 +1623,31 @@ pub struct SplitSdkType {
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct MessageExtensionAttribute {
id: String,
name: String,
criticality_indicator: bool,
data: String,
pub id: Option<String>,
pub name: Option<String>,
pub criticality_indicator: Option<bool>,
pub data: MessageDataAttribute,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct MessageDataAttribute {
pub sca_exemptions: Option<ScaExemptions>,
pub secure_corporate_payment: Option<SecureCorporatePayment>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum ScaExemptions {
#[serde(rename = "05")]
LowRiskExemption,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum SecureCorporatePayment {
#[serde(rename = "Y")]
Yes,
#[serde(rename = "N")]
No,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
6 changes: 5 additions & 1 deletion crates/router/src/connector/netcetera/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,10 @@ impl TryFrom<&NetceteraRouterData<&types::authentication::ConnectorAuthenticatio
}
api_models::payments::DeviceChannel::Browser => None,
};
let message_extension = item
.router_data
.sca_exemption_required
.map(netcetera_types::MessageExtensionAttribute::from);
Ok(Self {
preferred_protocol_version: Some(pre_authn_data.message_version),
enforce_preferred_protocol_version: None,
Expand All @@ -589,7 +593,7 @@ impl TryFrom<&NetceteraRouterData<&types::authentication::ConnectorAuthenticatio
merchant: Some(merchant_data),
broad_info: None,
device_render_options,
message_extension: None,
message_extension: message_extension.map(|message_extension| vec![message_extension]),
challenge_message_extension: None,
browser_information,
three_ri_ind: None,
Expand Down

0 comments on commit 2edd4ff

Please sign in to comment.