feat: SEPA and BACS bank transfers through stripe (#930)

This commit is contained in:
Sangamesh Kulkarni
2023-05-19 18:05:10 +05:30
committed by GitHub
parent 53aa5ac92d
commit cf000599dd
9 changed files with 422 additions and 81 deletions

View File

@ -205,6 +205,8 @@ pub struct ResponsePaymentMethodTypes {
/// The Bank debit payment method information, if applicable for a payment method type.
pub bank_debits: Option<BankDebitTypes>,
/// The Bank transfer payment method information, if applicable for a payment method type.
pub bank_transfers: Option<BankTransferTypes>,
}
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
@ -217,6 +219,13 @@ pub struct ResponsePaymentMethodsEnabled {
pub payment_method_types: Vec<ResponsePaymentMethodTypes>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema, PartialEq, Eq)]
pub struct BankTransferTypes {
/// The list of eligible connectors for a given payment experience
#[schema(example = json!(["stripe", "adyen"]))]
pub eligible_connectors: Vec<String>,
}
#[derive(Clone, Debug)]
pub struct ResponsePaymentMethodIntermediate {
pub payment_method_type: api_enums::PaymentMethodType,

View File

@ -724,13 +724,14 @@ pub enum BankRedirectData {
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct AchBankTransferData {
pub billing_details: AchBillingDetails,
pub struct AchBillingDetails {
pub email: Email,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct AchBillingDetails {
pub struct SepaAndBacsBillingDetails {
pub email: Email,
pub name: Secret<String>,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
@ -757,7 +758,16 @@ pub struct BankRedirectBilling {
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum BankTransferData {
AchBankTransfer(AchBankTransferData),
AchBankTransfer {
billing_details: AchBillingDetails,
},
SepaBankTransfer {
billing_details: SepaAndBacsBillingDetails,
country: api_enums::CountryAlpha2,
},
BacsBankTransfer {
billing_details: SepaAndBacsBillingDetails,
},
}
#[derive(serde::Deserialize, serde::Serialize, Debug, Clone, ToSchema, Eq, PartialEq)]
@ -878,6 +888,7 @@ pub struct CardResponse {
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize)]
#[serde(rename_all = "snake_case")]
pub enum PaymentMethodDataResponse {
#[serde(rename = "card")]
Card(CardResponse),
@ -1071,10 +1082,34 @@ pub struct NextAction {
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct NextStepsRequirements {
pub ach_credit_transfer: AchTransfer,
#[serde(flatten)]
pub bank_transfer_instructions: BankTransferInstructions,
pub receiver: ReceiverDetails,
}
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum BankTransferInstructions {
AchCreditTransfer(Box<AchTransfer>),
SepaBankInstructions(Box<SepaBankTransferInstructions>),
BacsBankInstructions(Box<BacsBankTransferInstructions>),
}
#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct SepaBankTransferInstructions {
pub account_holder_name: Secret<String>,
pub bic: Secret<String>,
pub country: String,
pub iban: Secret<String>,
}
#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct BacsBankTransferInstructions {
pub account_holder_name: Secret<String>,
pub account_number: Secret<String>,
pub sort_code: Secret<String>,
}
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct AchTransfer {
pub account_number: Secret<String>,
@ -1085,8 +1120,9 @@ pub struct AchTransfer {
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ReceiverDetails {
pub amount_received: i64,
pub amount_charged: i64,
amount_received: i64,
amount_charged: Option<i64>,
amount_remaining: Option<i64>,
}
#[derive(Setter, Clone, Default, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]

View File

@ -10,6 +10,7 @@ pub enum IncomingWebhookEvent {
PaymentIntentFailure,
PaymentIntentSuccess,
PaymentIntentProcessing,
PaymentIntentPartiallyFunded,
PaymentActionRequired,
EventNotSupported,
SourceChargeable,
@ -45,6 +46,7 @@ impl From<IncomingWebhookEvent> for WebhookFlow {
IncomingWebhookEvent::PaymentIntentSuccess => Self::Payment,
IncomingWebhookEvent::PaymentIntentProcessing => Self::Payment,
IncomingWebhookEvent::PaymentActionRequired => Self::Payment,
IncomingWebhookEvent::PaymentIntentPartiallyFunded => Self::Payment,
IncomingWebhookEvent::EventNotSupported => Self::ReturnResponse,
IncomingWebhookEvent::RefundSuccess => Self::Refund,
IncomingWebhookEvent::RefundFailure => Self::Refund,