Skip to content

Commit

Permalink
feat(pm_list): add required fields for eps (#3169)
Browse files Browse the repository at this point in the history
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
AkshayaFoiger and hyperswitch-bot[bot] authored Jan 8, 2024
1 parent ac5349c commit bfd8a5a
Show file tree
Hide file tree
Showing 10 changed files with 46,352 additions and 45,290 deletions.
2 changes: 1 addition & 1 deletion crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ pub enum BankRedirectData {
},
Eps {
/// The billing details for bank redirection
billing_details: BankRedirectBilling,
billing_details: Option<BankRedirectBilling>,

/// The hyperswitch bank code for eps
#[schema(value_type = BankNames, example = "triodos_bank")]
Expand Down
228 changes: 227 additions & 1 deletion crates/router/src/configs/defaults.rs

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions crates/router/src/connector/aci/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,14 @@ impl
) -> Result<Self, Self::Error> {
let (item, bank_redirect_data) = value;
let payment_data = match bank_redirect_data {
api_models::payments::BankRedirectData::Eps { .. } => {
api_models::payments::BankRedirectData::Eps { country, .. } => {
Self::BankRedirect(Box::new(BankRedirectionPMData {
payment_brand: PaymentBrand::Eps,
bank_account_country: Some(api_models::enums::CountryAlpha2::AT),
bank_account_country: Some(country.ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "eps.country",
},
)?),
bank_account_bank_name: None,
bank_account_bic: None,
bank_account_iban: None,
Expand Down
12 changes: 8 additions & 4 deletions crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2164,10 +2164,14 @@ impl<'a> TryFrom<&api_models::payments::BankRedirectData> for AdyenPaymentMethod
api_models::payments::BankRedirectData::Eps { bank_name, .. } => Ok(
AdyenPaymentMethod::Eps(Box::new(BankRedirectionWithIssuer {
payment_type: PaymentType::Eps,
issuer: bank_name
.map(|bank_name| AdyenTestBankNames::try_from(&bank_name))
.transpose()?
.map(|adyen_bank_name| adyen_bank_name.0),
issuer: Some(
AdyenTestBankNames::try_from(&bank_name.ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "eps.bank_name",
},
)?)?
.0,
),
})),
),
api_models::payments::BankRedirectData::Giropay { .. } => Ok(
Expand Down
7 changes: 6 additions & 1 deletion crates/router/src/connector/paypal/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,12 @@ fn get_payment_source(
bank_name: _,
country,
} => Ok(PaymentSourceItem::Eps(RedirectRequest {
name: billing_details.get_billing_name()?,
name: billing_details
.clone()
.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "eps.billing_details",
})?
.get_billing_name()?,
country_code: country.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "eps.country",
})?,
Expand Down
17 changes: 13 additions & 4 deletions crates/router/src/connector/stripe/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,15 +1083,24 @@ impl From<&payments::BankDebitBilling> for StripeBillingAddress {
}

impl TryFrom<&payments::BankRedirectData> for StripeBillingAddress {
type Error = errors::ConnectorError;
type Error = error_stack::Report<errors::ConnectorError>;

fn try_from(bank_redirection_data: &payments::BankRedirectData) -> Result<Self, Self::Error> {
match bank_redirection_data {
payments::BankRedirectData::Eps {
billing_details, ..
} => Ok(Self {
name: billing_details.billing_name.clone(),
..Self::default()
} => Ok({
let billing_data = billing_details.clone().ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "billing_details",
},
)?;
Self {
name: Some(connector_util::BankRedirectBillingData::get_billing_name(
&billing_data,
)?),
..Self::default()
}
}),
payments::BankRedirectData::Giropay {
billing_details, ..
Expand Down
8 changes: 6 additions & 2 deletions openapi/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3413,13 +3413,17 @@
"eps": {
"type": "object",
"required": [
"billing_details",
"bank_name",
"country"
],
"properties": {
"billing_details": {
"$ref": "#/components/schemas/BankRedirectBilling"
"allOf": [
{
"$ref": "#/components/schemas/BankRedirectBilling"
}
],
"nullable": true
},
"bank_name": {
"$ref": "#/components/schemas/BankNames"
Expand Down
Loading

0 comments on commit bfd8a5a

Please sign in to comment.