feat(connector): [Nexixpay] add Payment & Refunds flows for cards (#5864)

Co-authored-by: Mrudul Vajpayee <mrudul.vajpayee@mrudulvajpayee-XJWXCWP7HF.local>
Co-authored-by: Debarati <debarati.ghatak@juspay.in>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Mrudul Vajpayee
2024-10-02 21:34:37 +05:30
committed by GitHub
parent 3c500a1c85
commit 602f50b939
31 changed files with 1786 additions and 175 deletions

View File

@ -5086,6 +5086,98 @@ impl Default for super::settings::RequiredFields {
),
}
),
(
enums::Connector::Nexixpay,
RequiredFieldFinal {
mandate: HashMap::new(),
non_mandate: HashMap::new(),
common: HashMap::from(
[
(
"payment_method_data.card.card_number".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.card.card_number".to_string(),
display_name: "card_number".to_string(),
field_type: enums::FieldType::UserCardNumber,
value: None,
}
),
(
"payment_method_data.card.card_exp_month".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.card.card_exp_month".to_string(),
display_name: "card_exp_month".to_string(),
field_type: enums::FieldType::UserCardExpiryMonth,
value: None,
}
),
(
"payment_method_data.card.card_exp_year".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.card.card_exp_year".to_string(),
display_name: "card_exp_year".to_string(),
field_type: enums::FieldType::UserCardExpiryYear,
value: None,
}
),
(
"billing.address.line1".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.line1".to_string(),
display_name: "line1".to_string(),
field_type: enums::FieldType::UserAddressLine1,
value: None,
}
),
(
"billing.address.line2".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.line2".to_string(),
display_name: "line1".to_string(),
field_type: enums::FieldType::UserAddressLine2,
value: None,
}
),
(
"billing.address.city".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.city".to_string(),
display_name: "city".to_string(),
field_type: enums::FieldType::UserAddressCity,
value: None,
}
),
(
"billing.address.zip".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.zip".to_string(),
display_name: "zip".to_string(),
field_type: enums::FieldType::UserAddressPincode,
value: None,
}
),
(
"billing.address.first_name".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.first_name".to_string(),
display_name: "first_name".to_string(),
field_type: enums::FieldType::UserFullName,
value: None,
}
),
(
"billing.address.last_name".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.last_name".to_string(),
display_name: "last_name".to_string(),
field_type: enums::FieldType::UserFullName,
value: None,
}
)
]
),
}
),
(
enums::Connector::Nmi,
RequiredFieldFinal {

View File

@ -629,6 +629,7 @@ impl AddressData for api::Address {
}
pub trait PaymentsPreProcessingData {
fn get_redirect_response_payload(&self) -> Result<pii::SecretSerdeValue, Error>;
fn get_email(&self) -> Result<Email, Error>;
fn get_payment_method_type(&self) -> Result<enums::PaymentMethodType, Error>;
fn get_currency(&self) -> Result<enums::Currency, Error>;
@ -696,6 +697,17 @@ impl PaymentsPreProcessingData for types::PaymentsPreProcessingData {
.clone()
.ok_or_else(missing_field_err("complete_authorize_url"))
}
fn get_redirect_response_payload(&self) -> Result<pii::SecretSerdeValue, Error> {
self.redirect_response
.as_ref()
.and_then(|res| res.payload.to_owned())
.ok_or(
errors::ConnectorError::MissingConnectorRedirectionPayload {
field_name: "request.redirect_response.payload",
}
.into(),
)
}
fn connector_mandate_id(&self) -> Option<String> {
self.mandate_id
.as_ref()

View File

@ -1415,6 +1415,10 @@ impl<'a> ConnectorAuthTypeAndMetadataValidation<'a> {
nexinets::transformers::NexinetsAuthType::try_from(self.auth_type)?;
Ok(())
}
api_enums::Connector::Nexixpay => {
nexixpay::transformers::NexixpayAuthType::try_from(self.auth_type)?;
Ok(())
}
api_enums::Connector::Nmi => {
nmi::transformers::NmiAuthType::try_from(self.auth_type)?;
Ok(())

View File

@ -2314,10 +2314,12 @@ where
) && router_data.status
!= common_enums::AttemptStatus::AuthenticationFailed;
(router_data, should_continue)
} else if (connector.connector_name == router_types::Connector::Nuvei
|| connector.connector_name == router_types::Connector::Shift4)
&& router_data.auth_type == common_enums::AuthenticationType::ThreeDs
&& !is_operation_complete_authorize(&operation)
} else if router_data.auth_type == common_enums::AuthenticationType::ThreeDs
&& ((connector.connector_name == router_types::Connector::Nexixpay
&& is_operation_complete_authorize(&operation))
|| ((connector.connector_name == router_types::Connector::Nuvei
|| connector.connector_name == router_types::Connector::Shift4)
&& !is_operation_complete_authorize(&operation)))
{
router_data = router_data.preprocessing_steps(state, connector).await?;
(router_data, should_continue_payment)

View File

@ -2401,6 +2401,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProce
mandate_id: payment_data.mandate_id,
related_transaction_id: None,
enrolled_for_3ds: true,
metadata: payment_data.payment_intent.metadata.map(Secret::new),
})
}
}

View File

@ -496,7 +496,7 @@ pub async fn send_request(
))
};
// We cannot clone the request type, because it has Form trait which is not clonable. So we are cloning the request builder here.
// We cannot clone the request type, because it has Form trait which is not cloneable. So we are cloning the request builder here.
let cloned_send_request = request.try_clone().map(|cloned_request| async {
cloned_request
.send()
@ -570,7 +570,7 @@ pub async fn send_request(
.await
}
None => {
logger::info!("Retrying request due to connection closed before message could complete failed as request is not clonable");
logger::info!("Retrying request due to connection closed before message could complete failed as request is not cloneable");
Err(error)
}
}

View File

@ -430,6 +430,9 @@ impl ConnectorData {
}
enums::Connector::Klarna => Ok(ConnectorEnum::Old(Box::new(&connector::Klarna))),
enums::Connector::Mollie => Ok(ConnectorEnum::Old(Box::new(&connector::Mollie))),
enums::Connector::Nexixpay => {
Ok(ConnectorEnum::Old(Box::new(connector::Nexixpay::new())))
}
enums::Connector::Nmi => Ok(ConnectorEnum::Old(Box::new(connector::Nmi::new()))),
enums::Connector::Noon => Ok(ConnectorEnum::Old(Box::new(connector::Noon::new()))),
enums::Connector::Novalnet => {

View File

@ -289,7 +289,7 @@ impl ForeignTryFrom<api_enums::Connector> for common_enums::RoutableConnectors {
})?
}
api_enums::Connector::Nexinets => Self::Nexinets,
// api_enums::Connector::Nexixpay => Self::Nexixpay,
api_enums::Connector::Nexixpay => Self::Nexixpay,
api_enums::Connector::Nmi => Self::Nmi,
api_enums::Connector::Noon => Self::Noon,
api_enums::Connector::Novalnet => Self::Novalnet,