Skip to content

Commit

Permalink
Feat(connector): [BRAINTREE] Implement Card Mandates (#5204)
Browse files Browse the repository at this point in the history
  • Loading branch information
awasthi21 authored and Narayanbhat166 committed Jul 8, 2024
1 parent 14d9b54 commit 72e53a6
Show file tree
Hide file tree
Showing 13 changed files with 246 additions and 49 deletions.
4 changes: 2 additions & 2 deletions config/deployments/integration_test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ connectors_with_delayed_session_response = "trustpay,payme" # List of connec
bank_debit.ach.connector_list = "gocardless" # Mandate supported payment method type and connector for bank_debit
bank_debit.becs.connector_list = "gocardless" # Mandate supported payment method type and connector for bank_debit
bank_debit.sepa.connector_list = "gocardless" # Mandate supported payment method type and connector for bank_debit
card.credit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" # Mandate supported payment method type and connector for card
card.debit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" # Mandate supported payment method type and connector for card
card.credit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" # Mandate supported payment method type and connector for card
card.debit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" # Mandate supported payment method type and connector for card
pay_later.klarna.connector_list = "adyen" # Mandate supported payment method type and connector for pay_later
wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica" # Mandate supported payment method type and connector for wallets
wallet.google_pay.connector_list = "stripe,adyen,cybersource,bankofamerica" # Mandate supported payment method type and connector for wallets
Expand Down
4 changes: 2 additions & 2 deletions config/deployments/production.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ enabled = false
bank_debit.ach.connector_list = "gocardless" # Mandate supported payment method type and connector for bank_debit
bank_debit.becs.connector_list = "gocardless" # Mandate supported payment method type and connector for bank_debit
bank_debit.sepa.connector_list = "gocardless" # Mandate supported payment method type and connector for bank_debit
card.credit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" # Mandate supported payment method type and connector for card
card.debit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" # Mandate supported payment method type and connector for card
card.credit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" # Mandate supported payment method type and connector for card
card.debit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" # Mandate supported payment method type and connector for card
pay_later.klarna.connector_list = "adyen" # Mandate supported payment method type and connector for pay_later
wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica" # Mandate supported payment method type and connector for wallets
wallet.google_pay.connector_list = "stripe,adyen,cybersource,bankofamerica" # Mandate supported payment method type and connector for wallets
Expand Down
4 changes: 2 additions & 2 deletions config/deployments/sandbox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ enabled = true
bank_debit.ach.connector_list = "gocardless" # Mandate supported payment method type and connector for bank_debit
bank_debit.becs.connector_list = "gocardless" # Mandate supported payment method type and connector for bank_debit
bank_debit.sepa.connector_list = "gocardless" # Mandate supported payment method type and connector for bank_debit
card.credit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" # Mandate supported payment method type and connector for card
card.debit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" # Mandate supported payment method type and connector for card
card.credit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" # Mandate supported payment method type and connector for card
card.debit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" # Mandate supported payment method type and connector for card
pay_later.klarna.connector_list = "adyen" # Mandate supported payment method type and connector for pay_later
wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica" # Mandate supported payment method type and connector for wallets
wallet.google_pay.connector_list = "stripe,adyen,cybersource,bankofamerica" # Mandate supported payment method type and connector for wallets
Expand Down
6 changes: 2 additions & 4 deletions config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,6 @@ google_pay = { currency = "USD" }

[pm_filters.braintree]
paypal = { currency = "AUD,BRL,CAD,CNY,CZK,DKK,EUR,HKD,HUF,ILS,JPY,MYR,MXN,TWD,NZD,NOK,PHP,PLN,GBP,RUB,SGD,SEK,CHF,THB,USD" }
credit = { not_available_flows = { capture_method = "manual" } }
debit = { not_available_flows = { capture_method = "manual" } }

[pm_filters.helcim]
credit = { currency = "USD" }
Expand Down Expand Up @@ -536,8 +534,8 @@ pay_later.klarna = { connector_list = "adyen" }
wallet.google_pay = { connector_list = "stripe,adyen,cybersource,bankofamerica" }
wallet.apple_pay = { connector_list = "stripe,adyen,cybersource,noon,bankofamerica" }
wallet.paypal = { connector_list = "adyen" }
card.credit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" }
card.debit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" }
card.credit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" }
card.debit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" }
bank_debit.ach = { connector_list = "gocardless" }
bank_debit.becs = { connector_list = "gocardless" }
bank_debit.sepa = { connector_list = "gocardless" }
Expand Down
9 changes: 6 additions & 3 deletions crates/hyperswitch_domain_models/src/mandates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,29 @@ pub struct MandateData {
pub mandate_type: Option<MandateDataType>,
}

#[derive(Default, Eq, PartialEq, Debug, Clone)]
#[derive(Default, Eq, PartialEq, Debug, Clone, serde::Deserialize)]
pub struct CustomerAcceptance {
/// Type of acceptance provided by the
pub acceptance_type: AcceptanceType,
/// Specifying when the customer acceptance was provided
#[serde(with = "common_utils::custom_serde::iso8601::option")]
pub accepted_at: Option<PrimitiveDateTime>,
/// Information required for online mandate generation
pub online: Option<OnlineMandate>,
}

#[derive(Default, Debug, PartialEq, Eq, Clone)]
#[derive(Default, Debug, PartialEq, Eq, Clone, serde::Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum AcceptanceType {
Online,
#[default]
Offline,
}

#[derive(Default, Eq, PartialEq, Debug, Clone)]
#[derive(Default, Eq, PartialEq, Debug, Clone, serde::Deserialize)]
pub struct OnlineMandate {
/// Ip address of the customer machine from which the mandate was created
#[serde(skip_deserializing)]
pub ip_address: Option<Secret<String, pii::IpAddress>>,
/// The user-agent of the customer's browser
pub user_agent: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ pub struct CompleteAuthorizeData {
pub connector_meta: Option<serde_json::Value>,
pub complete_authorize_url: Option<String>,
pub metadata: Option<pii::SecretSerdeValue>,

pub customer_acceptance: Option<mandates::CustomerAcceptance>,
// New amount for amount frame work
pub minor_amount: MinorUnit,
}
Expand Down
10 changes: 10 additions & 0 deletions crates/router/src/connector/braintree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use self::transformers as braintree;
use super::utils::{self as connector_utils, PaymentsAuthorizeRequestData};
use crate::{
configs::settings,
connector::utils::PaymentMethodDataType,
consts,
core::{
errors::{self, CustomResult},
Expand Down Expand Up @@ -175,6 +176,15 @@ impl ConnectorValidation for Braintree {
),
}
}

fn validate_mandate_payment(
&self,
pm_type: Option<types::storage::enums::PaymentMethodType>,
pm_data: domain::payments::PaymentMethodData,
) -> CustomResult<(), errors::ConnectorError> {
let mandate_supported_pmd = std::collections::HashSet::from([PaymentMethodDataType::Card]);
connector_utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id())
}
}

impl api::Payment for Braintree {}
Expand Down
Loading

0 comments on commit 72e53a6

Please sign in to comment.