mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
feat: ACH transfers (#905)
This commit is contained in:
committed by
GitHub
parent
39405bb478
commit
23bca66b81
@ -468,6 +468,7 @@ pub enum PaymentMethod {
|
||||
PayLater,
|
||||
Wallet,
|
||||
BankRedirect,
|
||||
BankTransfer,
|
||||
Crypto,
|
||||
BankDebit,
|
||||
}
|
||||
|
||||
@ -608,3 +608,13 @@ pub struct TokenizedWalletValue1 {
|
||||
pub struct TokenizedWalletValue2 {
|
||||
pub customer_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct TokenizedBankTransferValue1 {
|
||||
pub data: payments::BankTransferData,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct TokenizedBankTransferValue2 {
|
||||
pub customer_id: Option<String>,
|
||||
}
|
||||
|
||||
@ -547,6 +547,7 @@ pub enum PaymentMethodData {
|
||||
PayLater(PayLaterData),
|
||||
BankRedirect(BankRedirectData),
|
||||
BankDebit(BankDebitData),
|
||||
BankTransfer(Box<BankTransferData>),
|
||||
Crypto(CryptoData),
|
||||
MandatePayment,
|
||||
}
|
||||
@ -563,6 +564,7 @@ pub enum AdditionalPaymentData {
|
||||
},
|
||||
Wallet {},
|
||||
PayLater {},
|
||||
BankTransfer {},
|
||||
Crypto {},
|
||||
BankDebit {},
|
||||
MandatePayment {},
|
||||
@ -589,6 +591,7 @@ impl From<&PaymentMethodData> for AdditionalPaymentData {
|
||||
},
|
||||
PaymentMethodData::Wallet(_) => Self::Wallet {},
|
||||
PaymentMethodData::PayLater(_) => Self::PayLater {},
|
||||
PaymentMethodData::BankTransfer(_) => Self::BankTransfer {},
|
||||
PaymentMethodData::Crypto(_) => Self::Crypto {},
|
||||
PaymentMethodData::BankDebit(_) => Self::BankDebit {},
|
||||
PaymentMethodData::MandatePayment => Self::MandatePayment {},
|
||||
@ -695,6 +698,16 @@ pub enum BankRedirectData {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
|
||||
pub struct AchBankTransferData {
|
||||
pub billing_details: AchBillingDetails,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
|
||||
pub struct AchBillingDetails {
|
||||
pub email: Email,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct CryptoData {}
|
||||
@ -716,6 +729,12 @@ pub struct BankRedirectBilling {
|
||||
pub email: Option<Email>,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum BankTransferData {
|
||||
AchBankTransfer(AchBankTransferData),
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, serde::Serialize, Debug, Clone, ToSchema, Eq, PartialEq)]
|
||||
pub struct BankDebitBilling {
|
||||
/// The billing name for bank debits
|
||||
@ -836,8 +855,7 @@ pub struct CardResponse {
|
||||
pub enum PaymentMethodDataResponse {
|
||||
#[serde(rename = "card")]
|
||||
Card(CardResponse),
|
||||
#[serde(rename(deserialize = "bank_transfer"))]
|
||||
BankTransfer,
|
||||
BankTransfer(BankTransferData),
|
||||
Wallet(WalletData),
|
||||
PayLater(PayLaterData),
|
||||
Paypal,
|
||||
@ -855,6 +873,8 @@ pub enum PaymentIdType {
|
||||
ConnectorTransactionId(String),
|
||||
/// The identifier for payment attempt
|
||||
PaymentAttemptId(String),
|
||||
/// The identifier for preprocessing step
|
||||
PreprocessingId(String),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for PaymentIdType {
|
||||
@ -870,6 +890,9 @@ impl std::fmt::Display for PaymentIdType {
|
||||
Self::PaymentAttemptId(payment_attempt_id) => {
|
||||
write!(f, "payment_attempt_id = \"{payment_attempt_id}\"")
|
||||
}
|
||||
Self::PreprocessingId(preprocessing_id) => {
|
||||
write!(f, "preprocessing_id = \"{preprocessing_id}\"")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1004,15 +1027,39 @@ pub enum NextActionType {
|
||||
DisplayQrCode,
|
||||
InvokeSdkClient,
|
||||
TriggerApi,
|
||||
DisplayBankTransferInformation,
|
||||
}
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
pub struct NextAction {
|
||||
/// Specifying the action type to be performed next
|
||||
#[serde(rename = "type")]
|
||||
pub next_action_type: NextActionType,
|
||||
//TODO: Make an enum having redirect_to_url and bank_transfer_steps_and_charges_details and use here
|
||||
/// Contains the url for redirection flow
|
||||
#[schema(example = "https://router.juspay.io/redirect/fakushdfjlksdfasklhdfj")]
|
||||
pub redirect_to_url: Option<String>,
|
||||
/// Informs the next steps for bank transfer and also contains the charges details (ex: amount received, amount charged etc)
|
||||
pub bank_transfer_steps_and_charges_details: Option<NextStepsRequirements>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct NextStepsRequirements {
|
||||
pub ach_credit_transfer: AchTransfer,
|
||||
pub receiver: ReceiverDetails,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct AchTransfer {
|
||||
pub account_number: Secret<String>,
|
||||
pub bank_name: String,
|
||||
pub routing_number: Secret<String>,
|
||||
pub swift_code: Secret<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ReceiverDetails {
|
||||
pub amount_received: i64,
|
||||
pub amount_charged: i64,
|
||||
}
|
||||
|
||||
#[derive(Setter, Clone, Default, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
@ -1391,6 +1438,9 @@ impl From<PaymentMethodData> for PaymentMethodDataResponse {
|
||||
PaymentMethodData::BankRedirect(bank_redirect_data) => {
|
||||
Self::BankRedirect(bank_redirect_data)
|
||||
}
|
||||
PaymentMethodData::BankTransfer(bank_transfer_data) => {
|
||||
Self::BankTransfer(*bank_transfer_data)
|
||||
}
|
||||
PaymentMethodData::Crypto(crpto_data) => Self::Crypto(crpto_data),
|
||||
PaymentMethodData::BankDebit(bank_debit_data) => Self::BankDebit(bank_debit_data),
|
||||
PaymentMethodData::MandatePayment => Self::MandatePayment,
|
||||
|
||||
@ -12,6 +12,9 @@ pub enum IncomingWebhookEvent {
|
||||
PaymentIntentProcessing,
|
||||
PaymentActionRequired,
|
||||
EventNotSupported,
|
||||
SourceChargeable,
|
||||
SourceTransactionCreated,
|
||||
ChargeSucceeded,
|
||||
RefundFailure,
|
||||
RefundSuccess,
|
||||
DisputeOpened,
|
||||
@ -32,6 +35,7 @@ pub enum WebhookFlow {
|
||||
Dispute,
|
||||
Subscription,
|
||||
ReturnResponse,
|
||||
BankTransfer,
|
||||
}
|
||||
|
||||
impl From<IncomingWebhookEvent> for WebhookFlow {
|
||||
@ -52,6 +56,9 @@ impl From<IncomingWebhookEvent> for WebhookFlow {
|
||||
IncomingWebhookEvent::DisputeWon => Self::Dispute,
|
||||
IncomingWebhookEvent::DisputeLost => Self::Dispute,
|
||||
IncomingWebhookEvent::EndpointVerification => Self::ReturnResponse,
|
||||
IncomingWebhookEvent::SourceChargeable
|
||||
| IncomingWebhookEvent::SourceTransactionCreated => Self::BankTransfer,
|
||||
IncomingWebhookEvent::ChargeSucceeded => Self::Payment,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user