New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(connector): [Multisafepay] Add support for Ideal and Giropay #4398
base: main
Are you sure you want to change the base?
Changes from 1 commit
0824c5d
b729cdd
5cff0ad
c495c6a
d125f9a
7ad9ab8
ee0b441
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
use api_models::enums::BankNames; | ||
use common_utils::pii::{Email, IpAddress}; | ||
use masking::ExposeInterface; | ||
use serde::{Deserialize, Serialize}; | ||
|
@@ -63,6 +64,8 @@ pub enum Gateway { | |
Klarna, | ||
Googlepay, | ||
Paypal, | ||
Ideal, | ||
Giropay, | ||
} | ||
|
||
#[serde_with::skip_serializing_none] | ||
|
@@ -173,6 +176,7 @@ pub enum GatewayInfo { | |
Card(CardInfo), | ||
Wallet(WalletInfo), | ||
PayLater(PayLaterInfo), | ||
BankRedirect(BankRedirectInfo), | ||
} | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq, Serialize)] | ||
|
@@ -181,6 +185,46 @@ pub enum WalletInfo { | |
GooglePay(GpayInfo), | ||
} | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq, Serialize)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these all derives required? If not please remove the redundant ones from all the enums and structs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please point to the code where you are comparing different bank's info? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SamraatBansal on line no. 760. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
#[serde(untagged)] | ||
pub enum BankRedirectInfo { | ||
Ideal(IdealInfo), | ||
} | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq, Serialize)] | ||
pub struct IdealInfo { | ||
pub issuer_id: Option<String>, | ||
} | ||
|
||
pub struct MultisafepayBankNames<'a>(&'a str); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you convert this to an enum. You can use serde rename here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Completed the change @srujanchikke |
||
|
||
impl<'a> TryFrom<&BankNames> for MultisafepayBankNames<'a> { | ||
type Error = error_stack::Report<errors::ConnectorError>; | ||
fn try_from(bank: &BankNames) -> Result<Self, Self::Error> { | ||
Ok(match bank { | ||
BankNames::AbnAmro => Self("0031"), | ||
BankNames::AsnBank => Self("0761"), | ||
BankNames::Bunq => Self("4371"), | ||
BankNames::Ing => Self("0721"), | ||
BankNames::Knab => Self("0801"), | ||
BankNames::N26 => Self("9926"), | ||
BankNames::NationaleNederlanden => Self("9927"), | ||
BankNames::Rabobank => Self("0021"), | ||
BankNames::Regiobank => Self("0771"), | ||
BankNames::Revolut => Self("1099"), | ||
BankNames::SnsBank => Self("0751"), | ||
BankNames::TriodosBank => Self("0511"), | ||
BankNames::VanLanschot => Self("0161"), | ||
BankNames::Yoursafe => Self("0806"), | ||
BankNames::Handelsbanken => Self("1235"), | ||
_ => Err(errors::ConnectorError::NotSupported { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't use default here, rather mention all the enums. It will help us easily debug any issues when new enum is added. |
||
message: String::from("BankRedirect"), | ||
connector: "Multisafepay", | ||
})?, | ||
}) | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)] | ||
pub struct DeliveryObject { | ||
first_name: Secret<String>, | ||
|
@@ -311,6 +355,13 @@ impl TryFrom<&MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>> | |
))?, | ||
}, | ||
api::PaymentMethodData::PayLater(ref _paylater) => Type::Redirect, | ||
api::PaymentMethodData::BankRedirect(ref bank_data) => match bank_data { | ||
api::BankRedirectData::Giropay { .. } => Type::Redirect, | ||
api::BankRedirectData::Ideal { .. } => Type::Direct, | ||
_ => Err(errors::ConnectorError::NotImplemented( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, don't use defaults |
||
utils::get_unimplemented_payment_method_error_message("multisafepay"), | ||
))?, | ||
}, | ||
_ => Type::Redirect, | ||
}; | ||
|
||
|
@@ -355,9 +406,15 @@ impl TryFrom<&MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>> | |
}, | ||
) => Some(Gateway::Klarna), | ||
api::PaymentMethodData::MandatePayment => None, | ||
api::PaymentMethodData::BankRedirect(ref bank_data) => Some(match bank_data { | ||
api::BankRedirectData::Giropay { .. } => Gateway::Giropay, | ||
api::BankRedirectData::Ideal { .. } => Gateway::Ideal, | ||
_ => Err(errors::ConnectorError::NotImplemented( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
utils::get_unimplemented_payment_method_error_message("multisafepay"), | ||
))?, | ||
}), | ||
api::PaymentMethodData::CardRedirect(_) | ||
| api::PaymentMethodData::PayLater(_) | ||
| api::PaymentMethodData::BankRedirect(_) | ||
| api::PaymentMethodData::BankDebit(_) | ||
| api::PaymentMethodData::BankTransfer(_) | ||
| api::PaymentMethodData::Crypto(_) | ||
|
@@ -503,8 +560,29 @@ impl TryFrom<&MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>> | |
})) | ||
} | ||
api::PaymentMethodData::MandatePayment => None, | ||
api::PaymentMethodData::BankRedirect(ref bank_redirect_data) => { | ||
match bank_redirect_data { | ||
api::BankRedirectData::Ideal { | ||
billing_details: _, | ||
bank_name, | ||
country: _, | ||
} => Some(GatewayInfo::BankRedirect(BankRedirectInfo::Ideal( | ||
IdealInfo { | ||
issuer_id: Some( | ||
MultisafepayBankNames::try_from(&bank_name.ok_or( | ||
errors::ConnectorError::MissingRequiredField { | ||
field_name: "eps.bank_name", | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be ideal.bank_name . |
||
)?)? | ||
.0 | ||
.to_string(), | ||
), | ||
}, | ||
))), | ||
_ => None, | ||
} | ||
} | ||
api::PaymentMethodData::CardRedirect(_) | ||
| api::PaymentMethodData::BankRedirect(_) | ||
| api::PaymentMethodData::BankDebit(_) | ||
| api::PaymentMethodData::BankTransfer(_) | ||
| api::PaymentMethodData::Crypto(_) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add Currency and Country configs for both Ideal and Giropay in
config/development.toml
,config/deployments/sandbox.toml
,config/deployments/integration_test.toml
,config/deployments/production.toml
for Multisafepay