mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 11:06:50 +08:00
fix(core): add should_call_connector_customer function to connector specification (#9569)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -534,8 +534,6 @@ pub struct TempLockerEnableConfig(pub HashMap<String, TempLockerEnablePaymentMet
|
||||
|
||||
#[derive(Debug, Deserialize, Clone, Default)]
|
||||
pub struct ConnectorCustomer {
|
||||
#[serde(deserialize_with = "deserialize_hashset")]
|
||||
pub connector_list: HashSet<enums::Connector>,
|
||||
#[cfg(feature = "payouts")]
|
||||
#[serde(deserialize_with = "deserialize_hashset")]
|
||||
pub payout_connector_list: HashSet<enums::PayoutConnectors>,
|
||||
|
||||
@ -6434,7 +6434,10 @@ where
|
||||
|
||||
let (should_call_connector, existing_connector_customer_id) =
|
||||
customers::should_call_connector_create_customer(
|
||||
state, &connector, customer, &label,
|
||||
&connector,
|
||||
customer,
|
||||
payment_data.get_payment_attempt(),
|
||||
&label,
|
||||
);
|
||||
|
||||
if should_call_connector {
|
||||
@ -6512,9 +6515,9 @@ where
|
||||
|
||||
let (should_call_connector, existing_connector_customer_id) =
|
||||
customers::should_call_connector_create_customer(
|
||||
state,
|
||||
&connector,
|
||||
customer,
|
||||
payment_data.get_payment_attempt(),
|
||||
merchant_connector_account,
|
||||
);
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use common_utils::pii;
|
||||
use hyperswitch_interfaces::api::ConnectorSpecifications;
|
||||
use masking::ExposeOptionInterface;
|
||||
use router_env::{instrument, tracing};
|
||||
|
||||
@ -76,17 +77,15 @@ pub async fn create_connector_customer<F: Clone, T: Clone>(
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
pub fn should_call_connector_create_customer<'a>(
|
||||
state: &SessionState,
|
||||
connector: &api::ConnectorData,
|
||||
customer: &'a Option<domain::Customer>,
|
||||
payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
|
||||
connector_label: &str,
|
||||
) -> (bool, Option<&'a str>) {
|
||||
// Check if create customer is required for the connector
|
||||
let connector_needs_customer = state
|
||||
.conf
|
||||
.connector_customer
|
||||
.connector_list
|
||||
.contains(&connector.connector_name);
|
||||
let connector_needs_customer = connector
|
||||
.connector
|
||||
.should_call_connector_customer(payment_attempt);
|
||||
let connector_customer_details = customer
|
||||
.as_ref()
|
||||
.and_then(|customer| customer.get_connector_customer_id(connector_label));
|
||||
@ -102,19 +101,17 @@ pub fn should_call_connector_create_customer<'a>(
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
pub fn should_call_connector_create_customer<'a>(
|
||||
state: &SessionState,
|
||||
connector: &api::ConnectorData,
|
||||
customer: &'a Option<domain::Customer>,
|
||||
payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
|
||||
merchant_connector_account: &domain::MerchantConnectorAccountTypeDetails,
|
||||
) -> (bool, Option<&'a str>) {
|
||||
// Check if create customer is required for the connector
|
||||
match merchant_connector_account {
|
||||
domain::MerchantConnectorAccountTypeDetails::MerchantConnectorAccount(_) => {
|
||||
let connector_needs_customer = state
|
||||
.conf
|
||||
.connector_customer
|
||||
.connector_list
|
||||
.contains(&connector.connector_name);
|
||||
let connector_needs_customer = connector
|
||||
.connector
|
||||
.should_call_connector_customer(payment_attempt);
|
||||
|
||||
if connector_needs_customer {
|
||||
let connector_customer_details = customer
|
||||
|
||||
@ -165,9 +165,9 @@ where
|
||||
|
||||
let (should_call_connector, existing_connector_customer_id) =
|
||||
customers::should_call_connector_create_customer(
|
||||
state,
|
||||
&connector,
|
||||
customer,
|
||||
payment_data.get_payment_attempt(),
|
||||
merchant_connector_account_type,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user