mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(connector): [Adyen] implement BACS Direct Debits for Adyen (#1159)
Co-authored-by: Arjun Karthik <m.arjunkarthik@gmail.com>
This commit is contained in:
@ -524,6 +524,9 @@ pub enum BankDebitData {
|
||||
/// Sort code for Bacs payment method
|
||||
#[schema(value_type = String, example = "108800")]
|
||||
sort_code: Secret<String>,
|
||||
/// holder name for bank debit
|
||||
#[schema(value_type = String, example = "A. Schneider")]
|
||||
bank_account_holder_name: Option<Secret<String>>,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -282,6 +282,7 @@ pub enum AdyenPaymentMethod<'a> {
|
||||
AchDirectDebit(Box<AchDirectDebitData>),
|
||||
#[serde(rename = "sepadirectdebit")]
|
||||
SepaDirectDebit(Box<SepaDirectDebitData>),
|
||||
BacsDirectDebit(Box<BacsDirectDebitData>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
@ -303,6 +304,16 @@ pub struct SepaDirectDebitData {
|
||||
iban_number: Secret<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BacsDirectDebitData {
|
||||
#[serde(rename = "type")]
|
||||
payment_type: PaymentType,
|
||||
bank_account_number: Secret<String>,
|
||||
bank_location_id: Secret<String>,
|
||||
holder_name: Secret<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct MandateData {
|
||||
@ -676,6 +687,8 @@ pub enum PaymentType {
|
||||
#[serde(rename = "ach")]
|
||||
AchDirectDebit,
|
||||
SepaDirectDebit,
|
||||
#[serde(rename = "directdebit_GB")]
|
||||
BacsDirectDebit,
|
||||
}
|
||||
|
||||
pub struct AdyenTestBankNames<'a>(&'a str);
|
||||
@ -982,6 +995,23 @@ impl<'a> TryFrom<&api_models::payments::BankDebitData> for AdyenPaymentMethod<'a
|
||||
iban_number: iban.clone(),
|
||||
},
|
||||
))),
|
||||
payments::BankDebitData::BacsBankDebit {
|
||||
account_number,
|
||||
sort_code,
|
||||
bank_account_holder_name,
|
||||
..
|
||||
} => Ok(AdyenPaymentMethod::BacsDirectDebit(Box::new(
|
||||
BacsDirectDebitData {
|
||||
payment_type: PaymentType::BacsDirectDebit,
|
||||
bank_account_number: account_number.clone(),
|
||||
bank_location_id: sort_code.clone(),
|
||||
holder_name: bank_account_holder_name.clone().ok_or(
|
||||
errors::ConnectorError::MissingRequiredField {
|
||||
field_name: "bank_account_holder_name",
|
||||
},
|
||||
)?,
|
||||
},
|
||||
))),
|
||||
_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -827,6 +827,7 @@ fn get_bank_debit_data(
|
||||
billing_details,
|
||||
account_number,
|
||||
sort_code,
|
||||
..
|
||||
} => {
|
||||
let bacs_data = BankDebitData::Bacs {
|
||||
account_number: account_number.to_owned(),
|
||||
|
||||
Reference in New Issue
Block a user