use common_utils::new_type::{ MaskedBankAccount, MaskedIban, MaskedRoutingNumber, MaskedSortCode, MaskedUpiVpaId, }; use masking::Secret; use utoipa::ToSchema; use crate::enums as api_enums; #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] #[serde(rename_all = "snake_case")] pub enum BankDebitAdditionalData { Ach(Box), Bacs(Box), Becs(Box), Sepa(Box), } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] pub struct AchBankDebitAdditionalData { /// Partially masked account number for ach bank debit payment #[schema(value_type = String, example = "0001****3456")] pub account_number: MaskedBankAccount, /// Partially masked routing number for ach bank debit payment #[schema(value_type = String, example = "110***000")] pub routing_number: MaskedRoutingNumber, /// Card holder's name #[schema(value_type = Option, example = "John Doe")] pub card_holder_name: Option>, /// Bank account's owner name #[schema(value_type = Option, example = "John Doe")] pub bank_account_holder_name: Option>, /// Name of the bank #[schema(value_type = Option, example = "ach")] pub bank_name: Option, /// Bank account type #[schema(value_type = Option, example = "checking")] pub bank_type: Option, /// Bank holder entity type #[schema(value_type = Option, example = "personal")] pub bank_holder_type: Option, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] pub struct BacsBankDebitAdditionalData { /// Partially masked account number for Bacs payment method #[schema(value_type = String, example = "0001****3456")] pub account_number: MaskedBankAccount, /// Partially masked sort code for Bacs payment method #[schema(value_type = String, example = "108800")] pub sort_code: MaskedSortCode, /// Bank account's owner name #[schema(value_type = Option, example = "John Doe")] pub bank_account_holder_name: Option>, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] pub struct BecsBankDebitAdditionalData { /// Partially masked account number for Becs payment method #[schema(value_type = String, example = "0001****3456")] pub account_number: MaskedBankAccount, /// Bank-State-Branch (bsb) number #[schema(value_type = String, example = "000000")] pub bsb_number: Secret, /// Bank account's owner name #[schema(value_type = Option, example = "John Doe")] pub bank_account_holder_name: Option>, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] pub struct SepaBankDebitAdditionalData { /// Partially masked international bank account number (iban) for SEPA #[schema(value_type = String, example = "DE8937******013000")] pub iban: MaskedIban, /// Bank account's owner name #[schema(value_type = Option, example = "John Doe")] pub bank_account_holder_name: Option>, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] pub enum BankRedirectDetails { BancontactCard(Box), Blik(Box), Giropay(Box), } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] pub struct BancontactBankRedirectAdditionalData { /// Last 4 digits of the card number #[schema(value_type = Option, example = "4242")] pub last4: Option, /// The card's expiry month #[schema(value_type = Option, example = "12")] pub card_exp_month: Option>, /// The card's expiry year #[schema(value_type = Option, example = "24")] pub card_exp_year: Option>, /// The card holder's name #[schema(value_type = Option, example = "John Test")] pub card_holder_name: Option>, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] pub struct BlikBankRedirectAdditionalData { #[schema(value_type = Option, example = "3GD9MO")] pub blik_code: Option, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] pub struct GiropayBankRedirectAdditionalData { #[schema(value_type = Option)] /// Masked bank account bic code pub bic: Option, /// Partially masked international bank account number (iban) for SEPA #[schema(value_type = Option)] pub iban: Option, /// Country for bank payment #[schema(value_type = Option, example = "US")] pub country: Option, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] #[serde(rename_all = "snake_case")] pub enum BankTransferAdditionalData { Ach {}, Sepa {}, Bacs {}, Multibanco {}, Permata {}, Bca {}, BniVa {}, BriVa {}, CimbVa {}, DanamonVa {}, MandiriVa {}, Pix(Box), Pse {}, LocalBankTransfer(Box), InstantBankTransfer {}, InstantBankTransferFinland {}, InstantBankTransferPoland {}, IndonesianBankTransfer { #[schema(value_type = Option, example = "bri")] bank_name: Option, }, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] pub struct PixBankTransferAdditionalData { /// Partially masked unique key for pix transfer #[schema(value_type = Option, example = "a1f4102e ****** 6fa48899c1d1")] pub pix_key: Option, /// Partially masked CPF - CPF is a Brazilian tax identification number #[schema(value_type = Option, example = "**** 124689")] pub cpf: Option, /// Partially masked CNPJ - CNPJ is a Brazilian company tax identification number #[schema(value_type = Option, example = "**** 417312")] pub cnpj: Option, /// Partially masked source bank account number #[schema(value_type = Option, example = "********-****-4073-****-9fa964d08bc5")] pub source_bank_account_id: Option, /// Partially masked destination bank account number _Deprecated: Will be removed in next stable release._ #[schema(value_type = Option, example = "********-****-460b-****-f23b4e71c97b", deprecated)] pub destination_bank_account_id: Option, /// The expiration date and time for the Pix QR code in ISO 8601 format #[schema(value_type = Option, example = "2025-09-10T10:11:12Z")] #[serde(default, with = "common_utils::custom_serde::iso8601::option")] pub expiry_date: Option, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] pub struct LocalBankTransferAdditionalData { /// Partially masked bank code #[schema(value_type = Option, example = "**** OA2312")] pub bank_code: Option, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] #[serde(rename_all = "snake_case")] pub enum GiftCardAdditionalData { Givex(Box), PaySafeCard {}, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] pub struct GivexGiftCardAdditionalData { /// Last 4 digits of the gift card number #[schema(value_type = String, example = "4242")] pub last4: Secret, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] pub struct CardTokenAdditionalData { /// The card holder's name #[schema(value_type = String, example = "John Test")] pub card_holder_name: Option>, } #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] #[serde(rename_all = "snake_case")] pub enum UpiAdditionalData { UpiCollect(Box), #[schema(value_type = UpiIntentData)] UpiIntent(Box), } #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] pub struct UpiCollectAdditionalData { /// Masked VPA ID #[schema(value_type = Option, example = "ab********@okhdfcbank")] pub vpa_id: Option, } #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] pub struct WalletAdditionalDataForCard { /// Last 4 digits of the card number pub last4: String, /// The information of the payment method pub card_network: String, /// The type of payment method #[serde(rename = "type")] pub card_type: Option, }