Skip to content

Commit 40024b6

Browse files
committed
resolved comment and conflicts
1 parent 40aaf80 commit 40024b6

File tree

2 files changed

+20
-95
lines changed

2 files changed

+20
-95
lines changed

crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,82 +1659,6 @@ impl TryFrom<&GooglePayWalletData> for StripePaymentMethodData {
16591659
}
16601660
}
16611661

1662-
fn get_stripe_billing_address(
1663-
billing_details: Option<hyperswitch_domain_models::address::Address>,
1664-
) -> Option<StripeBillingAddress> {
1665-
match billing_details {
1666-
Some(bd) => {
1667-
let billing_address = bd.address.as_ref();
1668-
Some(StripeBillingAddress {
1669-
city: billing_address.and_then(|a| a.city.clone()),
1670-
country: billing_address.and_then(|a| a.country),
1671-
address_line1: billing_address.and_then(|a| a.line1.clone()),
1672-
address_line2: billing_address.and_then(|a| a.line2.clone()),
1673-
zip_code: billing_address.and_then(|a| a.zip.clone()),
1674-
state: billing_address.and_then(|a| a.state.clone()),
1675-
name: billing_address.and_then(|a| {
1676-
a.first_name.as_ref().map(|first_name| {
1677-
format!(
1678-
"{} {}",
1679-
first_name.clone().expose(),
1680-
a.last_name.clone().expose_option().unwrap_or_default()
1681-
)
1682-
.into()
1683-
})
1684-
}),
1685-
email: bd.email.clone(),
1686-
phone: bd.phone.as_ref().map(|p| {
1687-
format!(
1688-
"{}{}",
1689-
p.country_code.clone().unwrap_or_default(),
1690-
p.number.clone().expose_option().unwrap_or_default()
1691-
)
1692-
.into()
1693-
}),
1694-
})
1695-
}
1696-
None => None,
1697-
}
1698-
}
1699-
1700-
fn get_stripe_billing_address_card_token(
1701-
billing_details: Option<hyperswitch_domain_models::address::Address>,
1702-
) -> Option<StripeBillingAddressCardToken> {
1703-
let bd = billing_details?;
1704-
1705-
let billing_address = bd.address.as_ref()?;
1706-
1707-
let name = match (&billing_address.first_name, &billing_address.last_name) {
1708-
(Some(first_name), Some(last_name)) => Some(
1709-
format!(
1710-
"{} {}",
1711-
first_name.clone().expose(),
1712-
last_name.clone().expose()
1713-
)
1714-
.into(),
1715-
),
1716-
(Some(first_name), None) => Some(first_name.clone().expose().into()),
1717-
_ => None,
1718-
};
1719-
1720-
Some(StripeBillingAddressCardToken {
1721-
name,
1722-
email: bd.email.clone(),
1723-
phone: bd.phone.as_ref().map(|p| {
1724-
format!(
1725-
"{}{}",
1726-
p.country_code.clone().unwrap_or_default(),
1727-
p.number.clone().expose_option().unwrap_or_default()
1728-
)
1729-
.into()
1730-
}),
1731-
address_line1: billing_address.line1.clone(),
1732-
address_line2: billing_address.line2.clone(),
1733-
state: billing_address.state.clone(),
1734-
city: billing_address.city.clone(),
1735-
})
1736-
}
1737-
17381662
impl TryFrom<(&PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntentRequest {
17391663
type Error = error_stack::Report<ConnectorError>;
17401664
fn try_from(data: (&PaymentsAuthorizeRouterData, MinorUnit)) -> Result<Self, Self::Error> {

crates/router/src/core/payments/transformers.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{fmt::Debug, marker::PhantomData, str::FromStr};
22

33
use api_models::payments::{
44
Address, ConnectorMandateReferenceId, CustomerDetails, CustomerDetailsResponse, FrmMessage,
5-
RequestSurchargeDetails,
5+
MandateIds, RequestSurchargeDetails,
66
};
77
use common_enums::{Currency, RequestIncrementalAuthorization};
88
use common_utils::{
@@ -3388,6 +3388,17 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
33883388
}
33893389
}
33903390

3391+
fn get_off_session(
3392+
mandate_id: Option<&MandateIds>,
3393+
off_session_flag: Option<bool>,
3394+
) -> Option<bool> {
3395+
match (mandate_id, off_session_flag) {
3396+
(_, Some(false)) => Some(false),
3397+
(Some(_), _) | (_, Some(true)) => Some(true),
3398+
(None, None) => None,
3399+
}
3400+
}
3401+
33913402
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
33923403
impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthorizeData {
33933404
type Error = error_stack::Report<errors::ApiErrorResponse>;
@@ -3542,14 +3553,10 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
35423553
})
35433554
.transpose()?
35443555
.map(pii::SecretSerdeValue::new);
3545-
let is_off_session = match (
3556+
let is_off_session = get_off_session(
35463557
payment_data.mandate_id.as_ref(),
35473558
payment_data.payment_intent.off_session,
3548-
) {
3549-
(_, Some(false)) => Some(false),
3550-
(Some(_), _) | (_, Some(true)) => Some(true),
3551-
(None, None) => None,
3552-
};
3559+
);
35533560

35543561
Ok(Self {
35553562
payment_method_data: (payment_method_data.get_required_value("payment_method_data")?),
@@ -4392,14 +4399,11 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
43924399
})
43934400
.transpose()?
43944401
.map(pii::SecretSerdeValue::new);
4395-
let is_off_session = match (
4402+
4403+
let is_off_session = get_off_session(
43964404
payment_data.mandate_id.as_ref(),
43974405
payment_data.payment_intent.off_session,
4398-
) {
4399-
(_, Some(false)) => Some(false),
4400-
(Some(_), _) | (_, Some(true)) => Some(true),
4401-
(None, None) => None,
4402-
};
4406+
);
44034407

44044408
Ok(Self {
44054409
currency: payment_data.currency,
@@ -4545,14 +4549,11 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
45454549
.and_then(|braintree| braintree.merchant_account_id.clone());
45464550
let merchant_config_currency =
45474551
braintree_metadata.and_then(|braintree| braintree.merchant_config_currency);
4548-
let is_off_session = match (
4552+
4553+
let is_off_session = get_off_session(
45494554
payment_data.mandate_id.as_ref(),
45504555
payment_data.payment_intent.off_session,
4551-
) {
4552-
(_, Some(false)) => Some(false),
4553-
(Some(_), _) | (_, Some(true)) => Some(true),
4554-
(None, None) => None,
4555-
};
4556+
);
45564557

45574558
Ok(Self {
45584559
setup_future_usage: payment_data.payment_intent.setup_future_usage,

0 commit comments

Comments
 (0)