Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(connector): [BRAINTREE] Implement Card Mandates #5204

Merged
merged 3 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the same changes in config/docker_compose.toml as well?

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 @@ -325,7 +325,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
Loading