mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 09:38:33 +08:00
feat(router): [cybersource] add disable_avs and disable_cvn flag in connector metadata (#5667)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -1217,6 +1217,9 @@ key1="Merchant ID"
|
|||||||
api_secret="Shared Secret"
|
api_secret="Shared Secret"
|
||||||
[cybersource.connector_webhook_details]
|
[cybersource.connector_webhook_details]
|
||||||
merchant_secret="Source verification key"
|
merchant_secret="Source verification key"
|
||||||
|
[cybersource.metadata]
|
||||||
|
disable_avs = "Disable AVS check"
|
||||||
|
disable_cvn = "Disable CVN check"
|
||||||
|
|
||||||
[[cybersource.metadata.apple_pay]]
|
[[cybersource.metadata.apple_pay]]
|
||||||
name="certificate"
|
name="certificate"
|
||||||
|
|||||||
@ -1032,6 +1032,9 @@ key1="Merchant ID"
|
|||||||
api_secret="Shared Secret"
|
api_secret="Shared Secret"
|
||||||
[cybersource.connector_webhook_details]
|
[cybersource.connector_webhook_details]
|
||||||
merchant_secret="Source verification key"
|
merchant_secret="Source verification key"
|
||||||
|
[cybersource.metadata]
|
||||||
|
disable_avs = "Disable AVS check"
|
||||||
|
disable_cvn = "Disable CVN check"
|
||||||
|
|
||||||
[[cybersource.metadata.apple_pay]]
|
[[cybersource.metadata.apple_pay]]
|
||||||
name="certificate"
|
name="certificate"
|
||||||
|
|||||||
@ -1217,6 +1217,9 @@ key1="Merchant ID"
|
|||||||
api_secret="Shared Secret"
|
api_secret="Shared Secret"
|
||||||
[cybersource.connector_webhook_details]
|
[cybersource.connector_webhook_details]
|
||||||
merchant_secret="Source verification key"
|
merchant_secret="Source verification key"
|
||||||
|
[cybersource.metadata]
|
||||||
|
disable_avs = "Disable AVS check"
|
||||||
|
disable_cvn = "Disable CVN check"
|
||||||
|
|
||||||
[[cybersource.metadata.apple_pay]]
|
[[cybersource.metadata.apple_pay]]
|
||||||
name="certificate"
|
name="certificate"
|
||||||
|
|||||||
@ -54,6 +54,23 @@ impl<T> TryFrom<(&api::CurrencyUnit, enums::Currency, i64, T)> for CybersourceRo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||||
|
pub struct CybersourceConnectorMetadataObject {
|
||||||
|
pub disable_avs: Option<bool>,
|
||||||
|
pub disable_cvn: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<&Option<pii::SecretSerdeValue>> for CybersourceConnectorMetadataObject {
|
||||||
|
type Error = error_stack::Report<errors::ConnectorError>;
|
||||||
|
fn try_from(meta_data: &Option<pii::SecretSerdeValue>) -> Result<Self, Self::Error> {
|
||||||
|
let metadata = utils::to_connector_meta_from_secret::<Self>(meta_data.clone())
|
||||||
|
.change_context(errors::ConnectorError::InvalidConnectorConfig {
|
||||||
|
config: "metadata",
|
||||||
|
})?;
|
||||||
|
Ok(metadata)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct CybersourceZeroMandateRequest {
|
pub struct CybersourceZeroMandateRequest {
|
||||||
@ -76,6 +93,9 @@ impl TryFrom<&types::SetupMandateRouterData> for CybersourceZeroMandateRequest {
|
|||||||
},
|
},
|
||||||
bill_to: Some(bill_to),
|
bill_to: Some(bill_to),
|
||||||
};
|
};
|
||||||
|
let connector_merchant_config =
|
||||||
|
CybersourceConnectorMetadataObject::try_from(&item.connector_meta_data)?;
|
||||||
|
|
||||||
let (action_list, action_token_types, authorization_options) = (
|
let (action_list, action_token_types, authorization_options) = (
|
||||||
Some(vec![CybersourceActionsList::TokenCreate]),
|
Some(vec![CybersourceActionsList::TokenCreate]),
|
||||||
Some(vec![
|
Some(vec![
|
||||||
@ -89,6 +109,8 @@ impl TryFrom<&types::SetupMandateRouterData> for CybersourceZeroMandateRequest {
|
|||||||
stored_credential_used: None,
|
stored_credential_used: None,
|
||||||
}),
|
}),
|
||||||
merchant_intitiated_transaction: None,
|
merchant_intitiated_transaction: None,
|
||||||
|
ignore_avs_result: connector_merchant_config.disable_avs,
|
||||||
|
ignore_cv_result: connector_merchant_config.disable_cvn,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -310,6 +332,8 @@ pub enum CybersourceActionsTokenType {
|
|||||||
pub struct CybersourceAuthorizationOptions {
|
pub struct CybersourceAuthorizationOptions {
|
||||||
initiator: Option<CybersourcePaymentInitiator>,
|
initiator: Option<CybersourcePaymentInitiator>,
|
||||||
merchant_intitiated_transaction: Option<MerchantInitiatedTransaction>,
|
merchant_intitiated_transaction: Option<MerchantInitiatedTransaction>,
|
||||||
|
ignore_avs_result: Option<bool>,
|
||||||
|
ignore_cv_result: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
@ -548,6 +572,9 @@ impl
|
|||||||
.unwrap_or("internet")
|
.unwrap_or("internet")
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
|
let connector_merchant_config =
|
||||||
|
CybersourceConnectorMetadataObject::try_from(&item.router_data.connector_meta_data)?;
|
||||||
|
|
||||||
let (action_list, action_token_types, authorization_options) = if item
|
let (action_list, action_token_types, authorization_options) = if item
|
||||||
.router_data
|
.router_data
|
||||||
.request
|
.request
|
||||||
@ -576,6 +603,8 @@ impl
|
|||||||
credential_stored_on_file: Some(true),
|
credential_stored_on_file: Some(true),
|
||||||
stored_credential_used: None,
|
stored_credential_used: None,
|
||||||
}),
|
}),
|
||||||
|
ignore_avs_result: connector_merchant_config.disable_avs,
|
||||||
|
ignore_cv_result: connector_merchant_config.disable_cvn,
|
||||||
merchant_intitiated_transaction: None,
|
merchant_intitiated_transaction: None,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@ -624,6 +653,8 @@ impl
|
|||||||
original_authorized_amount,
|
original_authorized_amount,
|
||||||
previous_transaction_id: None,
|
previous_transaction_id: None,
|
||||||
}),
|
}),
|
||||||
|
ignore_avs_result: connector_merchant_config.disable_avs,
|
||||||
|
ignore_cv_result: connector_merchant_config.disable_cvn,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -690,13 +721,24 @@ impl
|
|||||||
original_authorized_amount,
|
original_authorized_amount,
|
||||||
previous_transaction_id: Some(Secret::new(network_transaction_id)),
|
previous_transaction_id: Some(Secret::new(network_transaction_id)),
|
||||||
}),
|
}),
|
||||||
|
ignore_avs_result: connector_merchant_config.disable_avs,
|
||||||
|
ignore_cv_result: connector_merchant_config.disable_cvn,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
None => (None, None, None),
|
None => (None, None, None),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(None, None, None)
|
(
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
Some(CybersourceAuthorizationOptions {
|
||||||
|
initiator: None,
|
||||||
|
merchant_intitiated_transaction: None,
|
||||||
|
ignore_avs_result: connector_merchant_config.disable_avs,
|
||||||
|
ignore_cv_result: connector_merchant_config.disable_cvn,
|
||||||
|
}),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
// this logic is for external authenticated card
|
// this logic is for external authenticated card
|
||||||
let commerce_indicator_for_external_authentication = item
|
let commerce_indicator_for_external_authentication = item
|
||||||
@ -778,19 +820,23 @@ fn get_commerce_indicator_for_external_authentication(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl
|
impl
|
||||||
From<(
|
TryFrom<(
|
||||||
&CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>,
|
&CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>,
|
||||||
Option<PaymentSolution>,
|
Option<PaymentSolution>,
|
||||||
&CybersourceConsumerAuthValidateResponse,
|
&CybersourceConsumerAuthValidateResponse,
|
||||||
)> for ProcessingInformation
|
)> for ProcessingInformation
|
||||||
{
|
{
|
||||||
fn from(
|
type Error = error_stack::Report<errors::ConnectorError>;
|
||||||
|
fn try_from(
|
||||||
(item, solution, three_ds_data): (
|
(item, solution, three_ds_data): (
|
||||||
&CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>,
|
&CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>,
|
||||||
Option<PaymentSolution>,
|
Option<PaymentSolution>,
|
||||||
&CybersourceConsumerAuthValidateResponse,
|
&CybersourceConsumerAuthValidateResponse,
|
||||||
),
|
),
|
||||||
) -> Self {
|
) -> Result<Self, Self::Error> {
|
||||||
|
let connector_merchant_config =
|
||||||
|
CybersourceConnectorMetadataObject::try_from(&item.router_data.connector_meta_data)?;
|
||||||
|
|
||||||
let (action_list, action_token_types, authorization_options) = if item
|
let (action_list, action_token_types, authorization_options) = if item
|
||||||
.router_data
|
.router_data
|
||||||
.request
|
.request
|
||||||
@ -813,12 +859,14 @@ impl
|
|||||||
stored_credential_used: None,
|
stored_credential_used: None,
|
||||||
}),
|
}),
|
||||||
merchant_intitiated_transaction: None,
|
merchant_intitiated_transaction: None,
|
||||||
|
ignore_avs_result: connector_merchant_config.disable_avs,
|
||||||
|
ignore_cv_result: connector_merchant_config.disable_cvn,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
(None, None, None)
|
(None, None, None)
|
||||||
};
|
};
|
||||||
Self {
|
Ok(Self {
|
||||||
capture: Some(matches!(
|
capture: Some(matches!(
|
||||||
item.router_data.request.capture_method,
|
item.router_data.request.capture_method,
|
||||||
Some(enums::CaptureMethod::Automatic) | None
|
Some(enums::CaptureMethod::Automatic) | None
|
||||||
@ -832,7 +880,7 @@ impl
|
|||||||
.indicator
|
.indicator
|
||||||
.to_owned()
|
.to_owned()
|
||||||
.unwrap_or(String::from("internet")),
|
.unwrap_or(String::from("internet")),
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1100,7 +1148,7 @@ impl
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
let processing_information =
|
let processing_information =
|
||||||
ProcessingInformation::from((item, None, &three_ds_info.three_ds_data));
|
ProcessingInformation::try_from((item, None, &three_ds_info.three_ds_data))?;
|
||||||
|
|
||||||
let consumer_authentication_information = Some(CybersourceConsumerAuthInformation {
|
let consumer_authentication_information = Some(CybersourceConsumerAuthInformation {
|
||||||
ucaf_collection_indicator: three_ds_info.three_ds_data.ucaf_collection_indicator,
|
ucaf_collection_indicator: three_ds_info.three_ds_data.ucaf_collection_indicator,
|
||||||
@ -1585,6 +1633,9 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsIncrementalAuthorizationRout
|
|||||||
fn try_from(
|
fn try_from(
|
||||||
item: &CybersourceRouterData<&types::PaymentsIncrementalAuthorizationRouterData>,
|
item: &CybersourceRouterData<&types::PaymentsIncrementalAuthorizationRouterData>,
|
||||||
) -> Result<Self, Self::Error> {
|
) -> Result<Self, Self::Error> {
|
||||||
|
let connector_merchant_config =
|
||||||
|
CybersourceConnectorMetadataObject::try_from(&item.router_data.connector_meta_data)?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
processing_information: ProcessingInformation {
|
processing_information: ProcessingInformation {
|
||||||
action_list: None,
|
action_list: None,
|
||||||
@ -1600,6 +1651,8 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsIncrementalAuthorizationRout
|
|||||||
previous_transaction_id: None,
|
previous_transaction_id: None,
|
||||||
original_authorized_amount: None,
|
original_authorized_amount: None,
|
||||||
}),
|
}),
|
||||||
|
ignore_avs_result: connector_merchant_config.disable_avs,
|
||||||
|
ignore_cv_result: connector_merchant_config.disable_cvn,
|
||||||
}),
|
}),
|
||||||
commerce_indicator: String::from("internet"),
|
commerce_indicator: String::from("internet"),
|
||||||
capture: None,
|
capture: None,
|
||||||
|
|||||||
@ -1329,6 +1329,9 @@ impl<'a> ConnectorAuthTypeAndMetadataValidation<'a> {
|
|||||||
}
|
}
|
||||||
api_enums::Connector::Cybersource => {
|
api_enums::Connector::Cybersource => {
|
||||||
cybersource::transformers::CybersourceAuthType::try_from(self.auth_type)?;
|
cybersource::transformers::CybersourceAuthType::try_from(self.auth_type)?;
|
||||||
|
cybersource::transformers::CybersourceConnectorMetadataObject::try_from(
|
||||||
|
self.connector_meta_data,
|
||||||
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
api_enums::Connector::Datatrans => {
|
api_enums::Connector::Datatrans => {
|
||||||
|
|||||||
Reference in New Issue
Block a user