mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 01:57:45 +08:00 
			
		
		
		
	feat(connector): [Stripe] implement Multibanco Bank Transfer for stripe (#1420)
Co-authored-by: Jagan <jaganelavarasan@gmail.com> Co-authored-by: Arjun Karthik <m.arjunkarthik@gmail.com>
This commit is contained in:
		| @ -436,6 +436,7 @@ pub enum PaymentMethodType { | |||||||
|     Klarna, |     Klarna, | ||||||
|     MbWay, |     MbWay, | ||||||
|     MobilePay, |     MobilePay, | ||||||
|  |     Multibanco, | ||||||
|     OnlineBankingCzechRepublic, |     OnlineBankingCzechRepublic, | ||||||
|     OnlineBankingFinland, |     OnlineBankingFinland, | ||||||
|     OnlineBankingPoland, |     OnlineBankingPoland, | ||||||
|  | |||||||
| @ -807,6 +807,12 @@ pub struct AchBillingDetails { | |||||||
|     pub email: Email, |     pub email: Email, | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] | ||||||
|  | pub struct MultibancoBillingDetails { | ||||||
|  |     #[schema(value_type = String, example = "example@me.com")] | ||||||
|  |     pub email: Email, | ||||||
|  | } | ||||||
|  |  | ||||||
| #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] | #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] | ||||||
| pub struct SepaAndBacsBillingDetails { | pub struct SepaAndBacsBillingDetails { | ||||||
|     /// The Email ID for SEPA and BACS billing |     /// The Email ID for SEPA and BACS billing | ||||||
| @ -866,6 +872,10 @@ pub enum BankTransferData { | |||||||
|         /// The billing details for SEPA |         /// The billing details for SEPA | ||||||
|         billing_details: SepaAndBacsBillingDetails, |         billing_details: SepaAndBacsBillingDetails, | ||||||
|     }, |     }, | ||||||
|  |     MultibancoBankTransfer { | ||||||
|  |         /// The billing details for Multibanco | ||||||
|  |         billing_details: MultibancoBillingDetails, | ||||||
|  |     }, | ||||||
| } | } | ||||||
|  |  | ||||||
| #[derive(serde::Deserialize, serde::Serialize, Debug, Clone, ToSchema, Eq, PartialEq)] | #[derive(serde::Deserialize, serde::Serialize, Debug, Clone, ToSchema, Eq, PartialEq)] | ||||||
| @ -1241,6 +1251,8 @@ pub enum BankTransferInstructions { | |||||||
|     SepaBankInstructions(Box<SepaBankTransferInstructions>), |     SepaBankInstructions(Box<SepaBankTransferInstructions>), | ||||||
|     /// The instructions for BACS bank transactions |     /// The instructions for BACS bank transactions | ||||||
|     BacsBankInstructions(Box<BacsBankTransferInstructions>), |     BacsBankInstructions(Box<BacsBankTransferInstructions>), | ||||||
|  |     /// The instructions for Multibanco bank transactions | ||||||
|  |     Multibanco(Box<MultibancoTransferInstructions>), | ||||||
| } | } | ||||||
|  |  | ||||||
| #[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] | #[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] | ||||||
| @ -1264,6 +1276,14 @@ pub struct BacsBankTransferInstructions { | |||||||
|     pub sort_code: Secret<String>, |     pub sort_code: Secret<String>, | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)] | ||||||
|  | pub struct MultibancoTransferInstructions { | ||||||
|  |     #[schema(value_type = String, example = "122385736258")] | ||||||
|  |     pub reference: Secret<String>, | ||||||
|  |     #[schema(value_type = String, example = "12345")] | ||||||
|  |     pub entity: String, | ||||||
|  | } | ||||||
|  |  | ||||||
| #[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)] | #[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)] | ||||||
| pub struct AchTransfer { | pub struct AchTransfer { | ||||||
|     #[schema(value_type = String, example = "122385736258")] |     #[schema(value_type = String, example = "122385736258")] | ||||||
|  | |||||||
| @ -130,12 +130,13 @@ impl | |||||||
|         &self, |         &self, | ||||||
|         req: &types::PaymentsPreProcessingRouterData, |         req: &types::PaymentsPreProcessingRouterData, | ||||||
|     ) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> { |     ) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> { | ||||||
|         let req = stripe::StripeAchSourceRequest::try_from(req)?; |         let req = stripe::StripeCreditTransferSourceRequest::try_from(req)?; | ||||||
|         let pre_processing_request = types::RequestBody::log_and_get_request_body( |         let pre_processing_request = types::RequestBody::log_and_get_request_body( | ||||||
|             &req, |             &req, | ||||||
|             utils::Encode::<stripe::StripeAchSourceRequest>::url_encode, |             utils::Encode::<stripe::StripeCreditTransferSourceRequest>::url_encode, | ||||||
|         ) |         ) | ||||||
|         .change_context(errors::ConnectorError::RequestEncodingFailed)?; |         .change_context(errors::ConnectorError::RequestEncodingFailed)?; | ||||||
|  |  | ||||||
|         Ok(Some(pre_processing_request)) |         Ok(Some(pre_processing_request)) | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -721,7 +722,8 @@ impl | |||||||
|         match &req.request.payment_method_data { |         match &req.request.payment_method_data { | ||||||
|             api_models::payments::PaymentMethodData::BankTransfer(bank_transfer_data) => { |             api_models::payments::PaymentMethodData::BankTransfer(bank_transfer_data) => { | ||||||
|                 match bank_transfer_data.deref() { |                 match bank_transfer_data.deref() { | ||||||
|                     api_models::payments::BankTransferData::AchBankTransfer { .. } => { |                     api_models::payments::BankTransferData::AchBankTransfer { .. } | ||||||
|  |                     | api_models::payments::BankTransferData::MultibancoBankTransfer { .. } => { | ||||||
|                         Ok(format!("{}{}", self.base_url(connectors), "v1/charges")) |                         Ok(format!("{}{}", self.base_url(connectors), "v1/charges")) | ||||||
|                     } |                     } | ||||||
|                     _ => Ok(format!( |                     _ => Ok(format!( | ||||||
| @ -1772,7 +1774,9 @@ impl api::IncomingWebhook for Stripe { | |||||||
|             } |             } | ||||||
|             stripe::WebhookEventType::ChargeSucceeded => { |             stripe::WebhookEventType::ChargeSucceeded => { | ||||||
|                 if let Some(stripe::WebhookPaymentMethodDetails { |                 if let Some(stripe::WebhookPaymentMethodDetails { | ||||||
|                     payment_method: stripe::WebhookPaymentMethodType::AchCreditTransfer, |                     payment_method: | ||||||
|  |                         stripe::WebhookPaymentMethodType::AchCreditTransfer | ||||||
|  |                         | stripe::WebhookPaymentMethodType::MultibancoBankTransfers, | ||||||
|                 }) = details.event_data.event_object.payment_method_details |                 }) = details.event_data.event_object.payment_method_details | ||||||
|                 { |                 { | ||||||
|                     api::IncomingWebhookEvent::PaymentIntentSuccess |                     api::IncomingWebhookEvent::PaymentIntentSuccess | ||||||
|  | |||||||
| @ -15,10 +15,7 @@ use uuid::Uuid; | |||||||
|  |  | ||||||
| use crate::{ | use crate::{ | ||||||
|     collect_missing_value_keys, |     collect_missing_value_keys, | ||||||
|     connector::{ |     connector::utils::{ApplePay, PaymentsPreProcessingData, RouterData}, | ||||||
|         self, |  | ||||||
|         utils::{ApplePay, RouterData}, |  | ||||||
|     }, |  | ||||||
|     core::errors, |     core::errors, | ||||||
|     services, |     services, | ||||||
|     types::{self, api, storage::enums, transformers::ForeignFrom}, |     types::{self, api, storage::enums, transformers::ForeignFrom}, | ||||||
| @ -292,7 +289,13 @@ pub struct StripeBankRedirectData { | |||||||
| } | } | ||||||
|  |  | ||||||
| #[derive(Debug, Eq, PartialEq, Serialize)] | #[derive(Debug, Eq, PartialEq, Serialize)] | ||||||
| pub struct AchBankTransferData { | pub struct AchTransferData { | ||||||
|  |     #[serde(rename = "owner[email]")] | ||||||
|  |     pub email: Email, | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #[derive(Debug, Eq, PartialEq, Serialize)] | ||||||
|  | pub struct MultibancoTransferData { | ||||||
|     #[serde(rename = "owner[email]")] |     #[serde(rename = "owner[email]")] | ||||||
|     pub email: Email, |     pub email: Email, | ||||||
| } | } | ||||||
| @ -326,12 +329,31 @@ pub struct SepaBankTransferData { | |||||||
| } | } | ||||||
|  |  | ||||||
| #[derive(Debug, Eq, PartialEq, Serialize)] | #[derive(Debug, Eq, PartialEq, Serialize)] | ||||||
| pub struct StripeAchSourceRequest { | #[serde(untagged)] | ||||||
|  | pub enum StripeCreditTransferSourceRequest { | ||||||
|  |     AchBankTansfer(AchCreditTransferSourceRequest), | ||||||
|  |     MultibancoBankTansfer(MultibancoCreditTransferSourceRequest), | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #[derive(Debug, Eq, PartialEq, Serialize)] | ||||||
|  | pub struct AchCreditTransferSourceRequest { | ||||||
|     #[serde(rename = "type")] |     #[serde(rename = "type")] | ||||||
|     pub transfer_type: StripePaymentMethodType, |     pub transfer_type: StripePaymentMethodType, | ||||||
|     #[serde(flatten)] |     #[serde(flatten)] | ||||||
|     pub payment_method_data: AchBankTransferData, |     pub payment_method_data: AchTransferData, | ||||||
|     pub currency: String, |     pub currency: enums::Currency, | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #[derive(Debug, Eq, PartialEq, Serialize)] | ||||||
|  | pub struct MultibancoCreditTransferSourceRequest { | ||||||
|  |     #[serde(rename = "type")] | ||||||
|  |     pub transfer_type: StripePaymentMethodType, | ||||||
|  |     #[serde(flatten)] | ||||||
|  |     pub payment_method_data: MultibancoTransferData, | ||||||
|  |     pub currency: enums::Currency, | ||||||
|  |     pub amount: Option<i64>, | ||||||
|  |     #[serde(rename = "redirect[return_url]")] | ||||||
|  |     pub return_url: Option<String>, | ||||||
| } | } | ||||||
|  |  | ||||||
| // Remove untagged when Deserialize is added | // Remove untagged when Deserialize is added | ||||||
| @ -395,9 +417,10 @@ pub struct BankTransferData { | |||||||
| #[derive(Debug, Eq, PartialEq, Serialize)] | #[derive(Debug, Eq, PartialEq, Serialize)] | ||||||
| #[serde(untagged)] | #[serde(untagged)] | ||||||
| pub enum StripeBankTransferData { | pub enum StripeBankTransferData { | ||||||
|     AchBankTransfer(Box<AchBankTransferData>), |     AchBankTransfer(Box<AchTransferData>), | ||||||
|     SepaBankTransfer(Box<SepaBankTransferData>), |     SepaBankTransfer(Box<SepaBankTransferData>), | ||||||
|     BacsBankTransfers(Box<BacsBankTransferData>), |     BacsBankTransfers(Box<BacsBankTransferData>), | ||||||
|  |     MultibancoBankTransfers(Box<MultibancoTransferData>), | ||||||
| } | } | ||||||
|  |  | ||||||
| #[derive(Debug, Eq, PartialEq, Serialize)] | #[derive(Debug, Eq, PartialEq, Serialize)] | ||||||
| @ -494,6 +517,7 @@ pub enum StripePaymentMethodType { | |||||||
|     #[serde(rename = "p24")] |     #[serde(rename = "p24")] | ||||||
|     Przelewy24, |     Przelewy24, | ||||||
|     CustomerBalance, |     CustomerBalance, | ||||||
|  |     Multibanco, | ||||||
| } | } | ||||||
|  |  | ||||||
| #[derive(Debug, Eq, PartialEq, Serialize, Clone)] | #[derive(Debug, Eq, PartialEq, Serialize, Clone)] | ||||||
| @ -1078,13 +1102,24 @@ fn create_stripe_payment_method( | |||||||
|             match bank_transfer_data.deref() { |             match bank_transfer_data.deref() { | ||||||
|                 payments::BankTransferData::AchBankTransfer { billing_details } => Ok(( |                 payments::BankTransferData::AchBankTransfer { billing_details } => Ok(( | ||||||
|                     StripePaymentMethodData::BankTransfer(StripeBankTransferData::AchBankTransfer( |                     StripePaymentMethodData::BankTransfer(StripeBankTransferData::AchBankTransfer( | ||||||
|                         Box::new(AchBankTransferData { |                         Box::new(AchTransferData { | ||||||
|                             email: billing_details.email.to_owned(), |                             email: billing_details.email.to_owned(), | ||||||
|                         }), |                         }), | ||||||
|                     )), |                     )), | ||||||
|                     StripePaymentMethodType::AchCreditTransfer, |                     StripePaymentMethodType::AchCreditTransfer, | ||||||
|                     StripeBillingAddress::default(), |                     StripeBillingAddress::default(), | ||||||
|                 )), |                 )), | ||||||
|  |                 payments::BankTransferData::MultibancoBankTransfer { billing_details } => Ok(( | ||||||
|  |                     StripePaymentMethodData::BankTransfer( | ||||||
|  |                         StripeBankTransferData::MultibancoBankTransfers(Box::new( | ||||||
|  |                             MultibancoTransferData { | ||||||
|  |                                 email: billing_details.email.to_owned(), | ||||||
|  |                             }, | ||||||
|  |                         )), | ||||||
|  |                     ), | ||||||
|  |                     StripePaymentMethodType::Multibanco, | ||||||
|  |                     StripeBillingAddress::default(), | ||||||
|  |                 )), | ||||||
|                 payments::BankTransferData::SepaBankTransfer { |                 payments::BankTransferData::SepaBankTransfer { | ||||||
|                     billing_details, |                     billing_details, | ||||||
|                     country, |                     country, | ||||||
| @ -1444,7 +1479,10 @@ pub struct PaymentIntentResponse { | |||||||
| #[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)] | #[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)] | ||||||
| pub struct StripeSourceResponse { | pub struct StripeSourceResponse { | ||||||
|     pub id: String, |     pub id: String, | ||||||
|     pub ach_credit_transfer: AchCreditTransferResponse, |     #[serde(skip_serializing_if = "Option::is_none")] | ||||||
|  |     pub ach_credit_transfer: Option<AchCreditTransferResponse>, | ||||||
|  |     #[serde(skip_serializing_if = "Option::is_none")] | ||||||
|  |     pub multibanco: Option<MultibancoCreditTansferResponse>, | ||||||
|     pub receiver: AchReceiverDetails, |     pub receiver: AchReceiverDetails, | ||||||
|     pub status: StripePaymentStatus, |     pub status: StripePaymentStatus, | ||||||
| } | } | ||||||
| @ -1457,6 +1495,12 @@ pub struct AchCreditTransferResponse { | |||||||
|     pub swift_code: Secret<String>, |     pub swift_code: Secret<String>, | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)] | ||||||
|  | pub struct MultibancoCreditTansferResponse { | ||||||
|  |     pub reference: Secret<String>, | ||||||
|  |     pub entity: Secret<String>, | ||||||
|  | } | ||||||
|  |  | ||||||
| #[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)] | #[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)] | ||||||
| pub struct AchReceiverDetails { | pub struct AchReceiverDetails { | ||||||
|     pub amount_received: i64, |     pub amount_received: i64, | ||||||
| @ -1597,7 +1641,8 @@ impl ForeignFrom<(Option<StripePaymentMethodOptions>, String)> for types::Mandat | |||||||
|                 | StripePaymentMethodOptions::Sepa {} |                 | StripePaymentMethodOptions::Sepa {} | ||||||
|                 | StripePaymentMethodOptions::Bancontact {} |                 | StripePaymentMethodOptions::Bancontact {} | ||||||
|                 | StripePaymentMethodOptions::Przelewy24 {} |                 | StripePaymentMethodOptions::Przelewy24 {} | ||||||
|                 | StripePaymentMethodOptions::CustomerBalance {} => None, |                 | StripePaymentMethodOptions::CustomerBalance {} | ||||||
|  |                 | StripePaymentMethodOptions::Multibanco {} => None, | ||||||
|             }), |             }), | ||||||
|             payment_method_id: Some(payment_method_id), |             payment_method_id: Some(payment_method_id), | ||||||
|         } |         } | ||||||
| @ -2088,6 +2133,7 @@ pub enum StripePaymentMethodOptions { | |||||||
|     #[serde(rename = "p24")] |     #[serde(rename = "p24")] | ||||||
|     Przelewy24 {}, |     Przelewy24 {}, | ||||||
|     CustomerBalance {}, |     CustomerBalance {}, | ||||||
|  |     Multibanco {}, | ||||||
| } | } | ||||||
|  |  | ||||||
| #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] | #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] | ||||||
| @ -2127,23 +2173,42 @@ impl TryFrom<&types::PaymentsCaptureRouterData> for CaptureRequest { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| impl TryFrom<&types::PaymentsPreProcessingRouterData> for StripeAchSourceRequest { | impl TryFrom<&types::PaymentsPreProcessingRouterData> for StripeCreditTransferSourceRequest { | ||||||
|     type Error = error_stack::Report<errors::ConnectorError>; |     type Error = error_stack::Report<errors::ConnectorError>; | ||||||
|     fn try_from(item: &types::PaymentsPreProcessingRouterData) -> Result<Self, Self::Error> { |     fn try_from(item: &types::PaymentsPreProcessingRouterData) -> Result<Self, Self::Error> { | ||||||
|         Ok(Self { |         let currency = item.request.get_currency()?; | ||||||
|             transfer_type: StripePaymentMethodType::AchCreditTransfer, |  | ||||||
|             payment_method_data: AchBankTransferData { |         match &item.request.payment_method_data { | ||||||
|                 email: connector::utils::PaymentsPreProcessingData::get_email(&item.request)?, |             Some(payments::PaymentMethodData::BankTransfer(bank_transfer_data)) => { | ||||||
|             }, |                 match **bank_transfer_data { | ||||||
|             currency: item |                     payments::BankTransferData::MultibancoBankTransfer { .. } => Ok( | ||||||
|                 .request |                         Self::MultibancoBankTansfer(MultibancoCreditTransferSourceRequest { | ||||||
|                 .currency |                             transfer_type: StripePaymentMethodType::Multibanco, | ||||||
|                 .get_required_value("currency") |                             currency, | ||||||
|                 .change_context(errors::ConnectorError::MissingRequiredField { |                             payment_method_data: MultibancoTransferData { | ||||||
|                     field_name: "currency", |                                 email: item.request.get_email()?, | ||||||
|                 })? |                             }, | ||||||
|                 .to_string(), |                             amount: Some(item.request.get_amount()?), | ||||||
|         }) |                             return_url: Some(item.get_return_url()?), | ||||||
|  |                         }), | ||||||
|  |                     ), | ||||||
|  |                     payments::BankTransferData::AchBankTransfer { .. } => { | ||||||
|  |                         Ok(Self::AchBankTansfer(AchCreditTransferSourceRequest { | ||||||
|  |                             transfer_type: StripePaymentMethodType::AchCreditTransfer, | ||||||
|  |                             payment_method_data: AchTransferData { | ||||||
|  |                                 email: item.request.get_email()?, | ||||||
|  |                             }, | ||||||
|  |                             currency, | ||||||
|  |                         })) | ||||||
|  |                     } | ||||||
|  |                     _ => Err(errors::ConnectorError::NotImplemented( | ||||||
|  |                         "Bank Transfer Method".to_string(), | ||||||
|  |                     ) | ||||||
|  |                     .into()), | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             _ => Err(errors::ConnectorError::NotImplemented("Payment Method".to_string()).into()), | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -2342,6 +2407,7 @@ pub struct WebhookStatusObjectData { | |||||||
| #[serde(rename_all = "snake_case")] | #[serde(rename_all = "snake_case")] | ||||||
| pub enum WebhookPaymentMethodType { | pub enum WebhookPaymentMethodType { | ||||||
|     AchCreditTransfer, |     AchCreditTransfer, | ||||||
|  |     MultibancoBankTransfers, | ||||||
|     #[serde(other)] |     #[serde(other)] | ||||||
|     Unknown, |     Unknown, | ||||||
| } | } | ||||||
| @ -2546,11 +2612,18 @@ impl | |||||||
|                 match bank_transfer_data.deref() { |                 match bank_transfer_data.deref() { | ||||||
|                     payments::BankTransferData::AchBankTransfer { billing_details } => { |                     payments::BankTransferData::AchBankTransfer { billing_details } => { | ||||||
|                         Ok(Self::BankTransfer(StripeBankTransferData::AchBankTransfer( |                         Ok(Self::BankTransfer(StripeBankTransferData::AchBankTransfer( | ||||||
|                             Box::new(AchBankTransferData { |                             Box::new(AchTransferData { | ||||||
|                                 email: billing_details.email.to_owned(), |                                 email: billing_details.email.to_owned(), | ||||||
|                             }), |                             }), | ||||||
|                         ))) |                         ))) | ||||||
|                     } |                     } | ||||||
|  |                     payments::BankTransferData::MultibancoBankTransfer { billing_details } => Ok( | ||||||
|  |                         Self::BankTransfer(StripeBankTransferData::MultibancoBankTransfers( | ||||||
|  |                             Box::new(MultibancoTransferData { | ||||||
|  |                                 email: billing_details.email.to_owned(), | ||||||
|  |                             }), | ||||||
|  |                         )), | ||||||
|  |                     ), | ||||||
|                     payments::BankTransferData::SepaBankTransfer { country, .. } => Ok( |                     payments::BankTransferData::SepaBankTransfer { country, .. } => Ok( | ||||||
|                         Self::BankTransfer(StripeBankTransferData::SepaBankTransfer(Box::new( |                         Self::BankTransfer(StripeBankTransferData::SepaBankTransfer(Box::new( | ||||||
|                             SepaBankTransferData { |                             SepaBankTransferData { | ||||||
| @ -2594,7 +2667,8 @@ pub fn get_bank_transfer_request_data( | |||||||
|     bank_transfer_data: &api_models::payments::BankTransferData, |     bank_transfer_data: &api_models::payments::BankTransferData, | ||||||
| ) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> { | ) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> { | ||||||
|     match bank_transfer_data { |     match bank_transfer_data { | ||||||
|         api_models::payments::BankTransferData::AchBankTransfer { .. } => { |         api_models::payments::BankTransferData::AchBankTransfer { .. } | ||||||
|  |         | api_models::payments::BankTransferData::MultibancoBankTransfer { .. } => { | ||||||
|             let req = ChargesRequest::try_from(req)?; |             let req = ChargesRequest::try_from(req)?; | ||||||
|             let request = types::RequestBody::log_and_get_request_body( |             let request = types::RequestBody::log_and_get_request_body( | ||||||
|                 &req, |                 &req, | ||||||
| @ -2621,7 +2695,8 @@ pub fn get_bank_transfer_authorize_response( | |||||||
|     bank_transfer_data: &api_models::payments::BankTransferData, |     bank_transfer_data: &api_models::payments::BankTransferData, | ||||||
| ) -> CustomResult<types::PaymentsAuthorizeRouterData, errors::ConnectorError> { | ) -> CustomResult<types::PaymentsAuthorizeRouterData, errors::ConnectorError> { | ||||||
|     match bank_transfer_data { |     match bank_transfer_data { | ||||||
|         api_models::payments::BankTransferData::AchBankTransfer { .. } => { |         api_models::payments::BankTransferData::AchBankTransfer { .. } | ||||||
|  |         | api_models::payments::BankTransferData::MultibancoBankTransfer { .. } => { | ||||||
|             let response: ChargesResponse = res |             let response: ChargesResponse = res | ||||||
|                 .response |                 .response | ||||||
|                 .parse_struct("ChargesResponse") |                 .parse_struct("ChargesResponse") | ||||||
|  | |||||||
| @ -171,6 +171,8 @@ impl<Flow, Request, Response> RouterData for types::RouterData<Flow, Request, Re | |||||||
| pub trait PaymentsPreProcessingData { | pub trait PaymentsPreProcessingData { | ||||||
|     fn get_email(&self) -> Result<Email, Error>; |     fn get_email(&self) -> Result<Email, Error>; | ||||||
|     fn get_payment_method_type(&self) -> Result<storage_models::enums::PaymentMethodType, Error>; |     fn get_payment_method_type(&self) -> Result<storage_models::enums::PaymentMethodType, Error>; | ||||||
|  |     fn get_currency(&self) -> Result<storage_models::enums::Currency, Error>; | ||||||
|  |     fn get_amount(&self) -> Result<i64, Error>; | ||||||
| } | } | ||||||
|  |  | ||||||
| impl PaymentsPreProcessingData for types::PaymentsPreProcessingData { | impl PaymentsPreProcessingData for types::PaymentsPreProcessingData { | ||||||
| @ -182,6 +184,12 @@ impl PaymentsPreProcessingData for types::PaymentsPreProcessingData { | |||||||
|             .to_owned() |             .to_owned() | ||||||
|             .ok_or_else(missing_field_err("payment_method_type")) |             .ok_or_else(missing_field_err("payment_method_type")) | ||||||
|     } |     } | ||||||
|  |     fn get_currency(&self) -> Result<storage_models::enums::Currency, Error> { | ||||||
|  |         self.currency.ok_or_else(missing_field_err("currency")) | ||||||
|  |     } | ||||||
|  |     fn get_amount(&self) -> Result<i64, Error> { | ||||||
|  |         self.amount.ok_or_else(missing_field_err("amount")) | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| pub trait PaymentsAuthorizeRequestData { | pub trait PaymentsAuthorizeRequestData { | ||||||
|  | |||||||
| @ -838,7 +838,8 @@ where | |||||||
|     //TODO: For ACH transfers, if preprocessing_step is not required for connectors encountered in future, add the check |     //TODO: For ACH transfers, if preprocessing_step is not required for connectors encountered in future, add the check | ||||||
|     let router_data_and_should_continue_payment = match payment_data.payment_method_data.clone() { |     let router_data_and_should_continue_payment = match payment_data.payment_method_data.clone() { | ||||||
|         Some(api_models::payments::PaymentMethodData::BankTransfer(data)) => match data.deref() { |         Some(api_models::payments::PaymentMethodData::BankTransfer(data)) => match data.deref() { | ||||||
|             api_models::payments::BankTransferData::AchBankTransfer { .. } => { |             api_models::payments::BankTransferData::AchBankTransfer { .. } | ||||||
|  |             | api_models::payments::BankTransferData::MultibancoBankTransfer { .. } => { | ||||||
|                 if payment_data.payment_attempt.preprocessing_step_id.is_none() { |                 if payment_data.payment_attempt.preprocessing_step_id.is_none() { | ||||||
|                     ( |                     ( | ||||||
|                         router_data.preprocessing_steps(state, connector).await?, |                         router_data.preprocessing_steps(state, connector).await?, | ||||||
|  | |||||||
| @ -342,9 +342,10 @@ impl TryFrom<types::PaymentsAuthorizeData> for types::PaymentsPreProcessingData | |||||||
|  |  | ||||||
|     fn try_from(data: types::PaymentsAuthorizeData) -> Result<Self, Self::Error> { |     fn try_from(data: types::PaymentsAuthorizeData) -> Result<Self, Self::Error> { | ||||||
|         Ok(Self { |         Ok(Self { | ||||||
|  |             payment_method_data: Some(data.payment_method_data), | ||||||
|  |             amount: Some(data.amount), | ||||||
|             email: data.email, |             email: data.email, | ||||||
|             currency: Some(data.currency), |             currency: Some(data.currency), | ||||||
|             amount: Some(data.amount), |  | ||||||
|             payment_method_type: data.payment_method_type, |             payment_method_type: data.payment_method_type, | ||||||
|         }) |         }) | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -951,7 +951,10 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProce | |||||||
|  |  | ||||||
|     fn try_from(additional_data: PaymentAdditionalData<'_, F>) -> Result<Self, Self::Error> { |     fn try_from(additional_data: PaymentAdditionalData<'_, F>) -> Result<Self, Self::Error> { | ||||||
|         let payment_data = additional_data.payment_data; |         let payment_data = additional_data.payment_data; | ||||||
|  |         let payment_method_data = payment_data.payment_method_data; | ||||||
|  |  | ||||||
|         Ok(Self { |         Ok(Self { | ||||||
|  |             payment_method_data, | ||||||
|             email: payment_data.email, |             email: payment_data.email, | ||||||
|             currency: Some(payment_data.currency), |             currency: Some(payment_data.currency), | ||||||
|             amount: Some(payment_data.amount.into()), |             amount: Some(payment_data.amount.into()), | ||||||
|  | |||||||
| @ -244,9 +244,11 @@ Never share your secret api keys. Keep them guarded and secure. | |||||||
|         api_models::payments::BankTransferNextStepsData, |         api_models::payments::BankTransferNextStepsData, | ||||||
|         api_models::payments::SepaAndBacsBillingDetails, |         api_models::payments::SepaAndBacsBillingDetails, | ||||||
|         api_models::payments::AchBillingDetails, |         api_models::payments::AchBillingDetails, | ||||||
|  |         api_models::payments::MultibancoBillingDetails, | ||||||
|         api_models::payments::BankTransferInstructions, |         api_models::payments::BankTransferInstructions, | ||||||
|         api_models::payments::ReceiverDetails, |         api_models::payments::ReceiverDetails, | ||||||
|         api_models::payments::AchTransfer, |         api_models::payments::AchTransfer, | ||||||
|  |         api_models::payments::MultibancoTransferInstructions, | ||||||
|         api_models::payments::ApplePayRedirectData, |         api_models::payments::ApplePayRedirectData, | ||||||
|         api_models::payments::ApplePayThirdPartySdkData, |         api_models::payments::ApplePayThirdPartySdkData, | ||||||
|         api_models::payments::GooglePayRedirectData, |         api_models::payments::GooglePayRedirectData, | ||||||
|  | |||||||
| @ -268,9 +268,10 @@ pub struct PaymentMethodTokenizationData { | |||||||
|  |  | ||||||
| #[derive(Debug, Clone)] | #[derive(Debug, Clone)] | ||||||
| pub struct PaymentsPreProcessingData { | pub struct PaymentsPreProcessingData { | ||||||
|  |     pub payment_method_data: Option<payments::PaymentMethodData>, | ||||||
|  |     pub amount: Option<i64>, | ||||||
|     pub email: Option<Email>, |     pub email: Option<Email>, | ||||||
|     pub currency: Option<storage_enums::Currency>, |     pub currency: Option<storage_enums::Currency>, | ||||||
|     pub amount: Option<i64>, |  | ||||||
|     pub payment_method_type: Option<storage_enums::PaymentMethodType>, |     pub payment_method_type: Option<storage_enums::PaymentMethodType>, | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -696,6 +696,7 @@ pub enum PaymentMethodType { | |||||||
|     Klarna, |     Klarna, | ||||||
|     MbWay, |     MbWay, | ||||||
|     MobilePay, |     MobilePay, | ||||||
|  |     Multibanco, | ||||||
|     OnlineBankingCzechRepublic, |     OnlineBankingCzechRepublic, | ||||||
|     OnlineBankingFinland, |     OnlineBankingFinland, | ||||||
|     OnlineBankingPoland, |     OnlineBankingPoland, | ||||||
|  | |||||||
| @ -2648,6 +2648,25 @@ | |||||||
|                 } |                 } | ||||||
|               } |               } | ||||||
|             } |             } | ||||||
|  |           }, | ||||||
|  |           { | ||||||
|  |             "type": "object", | ||||||
|  |             "required": [ | ||||||
|  |               "multibanco_bank_transfer" | ||||||
|  |             ], | ||||||
|  |             "properties": { | ||||||
|  |               "multibanco_bank_transfer": { | ||||||
|  |                 "type": "object", | ||||||
|  |                 "required": [ | ||||||
|  |                   "billing_details" | ||||||
|  |                 ], | ||||||
|  |                 "properties": { | ||||||
|  |                   "billing_details": { | ||||||
|  |                     "$ref": "#/components/schemas/MultibancoBillingDetails" | ||||||
|  |                   } | ||||||
|  |                 } | ||||||
|  |               } | ||||||
|  |             } | ||||||
|           } |           } | ||||||
|         ] |         ] | ||||||
|       }, |       }, | ||||||
| @ -2685,6 +2704,17 @@ | |||||||
|                 "$ref": "#/components/schemas/BacsBankTransferInstructions" |                 "$ref": "#/components/schemas/BacsBankTransferInstructions" | ||||||
|               } |               } | ||||||
|             } |             } | ||||||
|  |           }, | ||||||
|  |           { | ||||||
|  |             "type": "object", | ||||||
|  |             "required": [ | ||||||
|  |               "multibanco" | ||||||
|  |             ], | ||||||
|  |             "properties": { | ||||||
|  |               "multibanco": { | ||||||
|  |                 "$ref": "#/components/schemas/MultibancoTransferInstructions" | ||||||
|  |               } | ||||||
|  |             } | ||||||
|           } |           } | ||||||
|         ] |         ] | ||||||
|       }, |       }, | ||||||
| @ -5422,6 +5452,35 @@ | |||||||
|       "MobilePayRedirection": { |       "MobilePayRedirection": { | ||||||
|         "type": "object" |         "type": "object" | ||||||
|       }, |       }, | ||||||
|  |       "MultibancoBillingDetails": { | ||||||
|  |         "type": "object", | ||||||
|  |         "required": [ | ||||||
|  |           "email" | ||||||
|  |         ], | ||||||
|  |         "properties": { | ||||||
|  |           "email": { | ||||||
|  |             "type": "string", | ||||||
|  |             "example": "example@me.com" | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |       }, | ||||||
|  |       "MultibancoTransferInstructions": { | ||||||
|  |         "type": "object", | ||||||
|  |         "required": [ | ||||||
|  |           "reference", | ||||||
|  |           "entity" | ||||||
|  |         ], | ||||||
|  |         "properties": { | ||||||
|  |           "reference": { | ||||||
|  |             "type": "string", | ||||||
|  |             "example": "122385736258" | ||||||
|  |           }, | ||||||
|  |           "entity": { | ||||||
|  |             "type": "string", | ||||||
|  |             "example": "12345" | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |       }, | ||||||
|       "NextActionCall": { |       "NextActionCall": { | ||||||
|         "type": "string", |         "type": "string", | ||||||
|         "enum": [ |         "enum": [ | ||||||
| @ -6304,6 +6363,7 @@ | |||||||
|           "klarna", |           "klarna", | ||||||
|           "mb_way", |           "mb_way", | ||||||
|           "mobile_pay", |           "mobile_pay", | ||||||
|  |           "multibanco", | ||||||
|           "online_banking_czech_republic", |           "online_banking_czech_republic", | ||||||
|           "online_banking_finland", |           "online_banking_finland", | ||||||
|           "online_banking_poland", |           "online_banking_poland", | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 AkshayaFoiger
					AkshayaFoiger