Skip to content

Commit

Permalink
feat(connector): [Adyen] Implement SEPA Direct debits for Adyen (#1055)
Browse files Browse the repository at this point in the history
Co-authored-by: Jagan Elavarasan <[email protected]>
  • Loading branch information
swangi-kumari and jagan-jaya authored May 9, 2023
1 parent 2ab7f83 commit 7f796a6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
6 changes: 6 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,9 @@ pub enum BankDebitData {
routing_number: Secret<String>,

#[schema(value_type = String, example = "John Test")]
card_holder_name: Option<Secret<String>>,

#[schema(value_type = String, example = "John Doe")]
bank_account_holder_name: Option<Secret<String>>,
},
SepaBankDebit {
Expand All @@ -498,6 +501,9 @@ pub enum BankDebitData {
/// International bank account number (iban) for SEPA
#[schema(value_type = String, example = "DE89370400440532013000")]
iban: Secret<String>,
/// Owner name for bank debit
#[schema(value_type = String, example = "A. Schneider")]
bank_account_holder_name: Option<Secret<String>>,
},
BecsBankDebit {
/// Billing details for bank debit
Expand Down
31 changes: 28 additions & 3 deletions crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ pub enum AdyenPaymentMethod<'a> {
Walley(Box<WalleyData>),
WeChatPayWeb(Box<WeChatPayWebData>),
AchDirectDebit(Box<AchDirectDebitData>),
#[serde(rename = "sepadirectdebit")]
SepaDirectDebit(Box<SepaDirectDebitData>),
}

#[derive(Debug, Clone, Serialize)]
Expand All @@ -291,6 +293,15 @@ pub struct AchDirectDebitData {
owner_name: Secret<String>,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SepaDirectDebitData {
#[serde(rename = "sepa.ownerName")]
owner_name: Secret<String>,
#[serde(rename = "sepa.ibanNumber")]
iban_number: Secret<String>,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct MandateData {
Expand Down Expand Up @@ -663,6 +674,7 @@ pub enum PaymentType {
WeChatPayWeb,
#[serde(rename = "ach")]
AchDirectDebit,
SepaDirectDebit,
}

pub struct AdyenTestBankNames<'a>(&'a str);
Expand Down Expand Up @@ -928,21 +940,34 @@ impl<'a> TryFrom<&api_models::payments::BankDebitData> for AdyenPaymentMethod<'a
payments::BankDebitData::AchBankDebit {
account_number,
routing_number,
billing_details: _,
bank_account_holder_name,
card_holder_name,
..
} => Ok(AdyenPaymentMethod::AchDirectDebit(Box::new(
AchDirectDebitData {
payment_type: PaymentType::AchDirectDebit,
bank_account_number: account_number.clone(),
bank_location_id: routing_number.clone(),
owner_name: card_holder_name.clone().ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "card_holder_name",
},
)?,
},
))),
payments::BankDebitData::SepaBankDebit {
iban,
bank_account_holder_name,
..
} => Ok(AdyenPaymentMethod::SepaDirectDebit(Box::new(
SepaDirectDebitData {
owner_name: bank_account_holder_name.clone().ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "bank_account_holder_name",
},
)?,
iban_number: iban.clone(),
},
))),

_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/stripe/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ fn get_bank_debit_data(
payments::BankDebitData::SepaBankDebit {
billing_details,
iban,
..
} => {
let sepa_data = BankDebitData::Sepa {
iban: iban.to_owned(),
Expand Down

0 comments on commit 7f796a6

Please sign in to comment.