Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(connector): [Stripe] implement Bancontact Bank Redirect for stripe (#1169)

AkshayaFoiger5b22e967981b
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index fa9f3f108a..1e2bb95d9c 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -590,18 +590,21 @@ pub enum BankRedirectData {
BancontactCard {
/// The card number
#[schema(value_type = String, example = "4242424242424242")]
- card_number: CardNumber,
+ card_number: Option<CardNumber>,
/// The card's expiry month
#[schema(value_type = String, example = "24")]
- card_exp_month: Secret<String>,
+ card_exp_month: Option<Secret<String>>,
/// The card's expiry year
#[schema(value_type = String, example = "24")]
- card_exp_year: Secret<String>,
+ card_exp_year: Option<Secret<String>>,
/// The card holder's name
#[schema(value_type = String, example = "John Test")]
- card_holder_name: Secret<String>,
+ card_holder_name: Option<Secret<String>>,
+
+ //Required by Stripes
+ billing_details: Option<BankRedirectBilling>,
},
Blik {
// Blik Code
@@ -698,7 +701,7 @@ pub struct BankRedirectBilling {
pub billing_name: Option<Secret<String>>,
/// The billing email for bank redirect
#[schema(value_type = String, example = "[email protected]")]
- pub email: Email,
+ pub email: Option<Email>,
}
#[derive(serde::Deserialize, serde::Serialize, Debug, Clone, ToSchema, Eq, PartialEq)]
diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rs
index 1b0757b86a..0561dc1b23 100644
--- a/crates/router/src/connector/aci/transformers.rs
+++ b/crates/router/src/connector/aci/transformers.rs
@@ -248,7 +248,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AciPaymentsRequest {
billing_country: None,
merchant_customer_id: None,
merchant_transaction_id: None,
- customer_email: Some(billing_details.email.clone()),
+ customer_email: billing_details.email.clone(),
shopper_result_url: item.request.router_return_url.clone(),
})),
diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs
index 3f176ecf79..ec1ba217fe 100644
--- a/crates/router/src/connector/adyen/transformers.rs
+++ b/crates/router/src/connector/adyen/transformers.rs
@@ -1116,14 +1116,35 @@ impl<'a> TryFrom<&api_models::payments::BankRedirectData> for AdyenPaymentMethod
card_exp_month,
card_exp_year,
card_holder_name,
+ ..
} => Ok(AdyenPaymentMethod::BancontactCard(Box::new(
BancontactCardData {
payment_type: PaymentType::Scheme,
brand: "bcmc".to_string(),
- number: card_number.clone(),
- expiry_month: card_exp_month.clone(),
- expiry_year: card_exp_year.clone(),
- holder_name: card_holder_name.clone(),
+ number: card_number
+ .as_ref()
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "bancontact_card.card_number",
+ })?
+ .clone(),
+ expiry_month: card_exp_month
+ .as_ref()
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "bancontact_card.card_exp_month",
+ })?
+ .clone(),
+ expiry_year: card_exp_year
+ .as_ref()
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "bancontact_card.card_exp_year",
+ })?
+ .clone(),
+ holder_name: card_holder_name
+ .as_ref()
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "bancontact_card.card_holder_name",
+ })?
+ .clone(),
},
))),
api_models::payments::BankRedirectData::Blik { blik_code } => {
diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs
index b105a21730..457d42925e 100644
--- a/crates/router/src/connector/stripe/transformers.rs
+++ b/crates/router/src/connector/stripe/transformers.rs
@@ -238,10 +238,16 @@ fn get_bank_name(
},
)?)?,
})),
- (StripePaymentMethodType::Sofort | StripePaymentMethodType::Giropay, _) => Ok(None),
+ (
+ StripePaymentMethodType::Sofort
+ | StripePaymentMethodType::Giropay
+ | StripePaymentMethodType::Bancontact,
+ _,
+ ) => Ok(None),
_ => Err(errors::ConnectorError::MismatchedPaymentData),
}
}
+
#[derive(Debug, Eq, PartialEq, Serialize)]
pub struct StripeBankRedirectData {
#[serde(rename = "payment_method_types[]")]
@@ -392,6 +398,7 @@ pub enum StripePaymentMethodType {
Becs,
#[serde(rename = "bacs_debit")]
Bacs,
+ Bancontact,
#[serde(rename = "wechat_pay")]
Wechatpay,
Alipay,
@@ -627,6 +634,10 @@ fn infer_stripe_bank_redirect_issuer(
Some(storage_models::enums::PaymentMethodType::Sofort) => {
Ok(StripePaymentMethodType::Sofort)
}
+
+ Some(storage_models::enums::PaymentMethodType::BancontactCard) => {
+ Ok(StripePaymentMethodType::Bancontact)
+ }
Some(storage_models::enums::PaymentMethodType::Przelewy24) => {
Ok(StripePaymentMethodType::Przelewy24)
}
@@ -732,7 +743,19 @@ impl TryFrom<&payments::BankRedirectData> for StripeBillingAddress {
payments::BankRedirectData::Przelewy24 {
billing_details, ..
} => Ok(Self {
- email: Some(billing_details.email.clone()),
+ email: billing_details.email.clone(),
+ ..Self::default()
+ }),
+ payments::BankRedirectData::BancontactCard {
+ billing_details, ..
+ } => Ok(Self {
+ name: billing_details
+ .as_ref()
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "bancontact_card.billing_name",
+ })?
+ .billing_name
+ .clone(),
..Self::default()
}),
_ => Ok(Self::default()),
@@ -876,6 +899,7 @@ fn create_stripe_payment_method(
let pm_type = infer_stripe_bank_redirect_issuer(pm_type)?;
let bank_specific_data = get_bank_specific_data(bank_redirect_data);
let bank_name = get_bank_name(&pm_type, bank_redirect_data)?;
+
Ok((
StripePaymentMethodData::BankRedirect(StripeBankRedirectData {
payment_method_types: pm_type,
@@ -1346,6 +1370,7 @@ impl ForeignFrom<(Option<StripePaymentMethodOptions>, String)> for types::Mandat
| StripePaymentMethodOptions::WechatPay {}
| StripePaymentMethodOptions::Alipay {}
| StripePaymentMethodOptions::Sepa {}
+ | StripePaymentMethodOptions::Bancontact {}
| StripePaymentMethodOptions::Przelewy24 {} => None,
}),
payment_method_id: Some(payment_method_id),
@@ -1758,6 +1783,7 @@ pub enum StripePaymentMethodOptions {
Becs {},
#[serde(rename = "bacs_debit")]
Bacs {},
+ Bancontact {},
WechatPay {},
Alipay {},
#[serde(rename = "p24")]