mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(router): collect billing details from wallet connector based on the collect_billing_details_from_wallet_connector field (#5065)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -456,6 +456,7 @@ pub async fn update_business_profile_cascade(
|
||||
extended_card_info_config: None,
|
||||
use_billing_as_payment_method_billing: None,
|
||||
collect_shipping_details_from_wallet_connector: None,
|
||||
collect_billing_details_from_wallet_connector: None,
|
||||
is_connector_agnostic_mit_enabled: None,
|
||||
};
|
||||
|
||||
@ -1723,6 +1724,8 @@ pub async fn update_business_profile(
|
||||
use_billing_as_payment_method_billing: request.use_billing_as_payment_method_billing,
|
||||
collect_shipping_details_from_wallet_connector: request
|
||||
.collect_shipping_details_from_wallet_connector,
|
||||
collect_billing_details_from_wallet_connector: request
|
||||
.collect_billing_details_from_wallet_connector,
|
||||
is_connector_agnostic_mit_enabled: request.is_connector_agnostic_mit_enabled,
|
||||
};
|
||||
|
||||
|
||||
@ -295,23 +295,29 @@ async fn create_applepay_session_token(
|
||||
router_data.request.to_owned(),
|
||||
)?;
|
||||
|
||||
let billing_variants = enums::FieldType::get_billing_variants();
|
||||
let required_billing_contact_fields = business_profile
|
||||
.collect_billing_details_from_wallet_connector
|
||||
.unwrap_or(false)
|
||||
.then_some({
|
||||
let billing_variants = enums::FieldType::get_billing_variants();
|
||||
is_dynamic_fields_required(
|
||||
&state.conf.required_fields,
|
||||
enums::PaymentMethod::Wallet,
|
||||
enums::PaymentMethodType::ApplePay,
|
||||
&connector.connector_name,
|
||||
billing_variants,
|
||||
)
|
||||
.then_some(payment_types::ApplePayBillingContactFields(vec![
|
||||
payment_types::ApplePayAddressParameters::PostalAddress,
|
||||
]))
|
||||
})
|
||||
.flatten();
|
||||
|
||||
let required_billing_contact_fields = is_dynamic_fields_required(
|
||||
&state.conf.required_fields,
|
||||
enums::PaymentMethod::Wallet,
|
||||
enums::PaymentMethodType::ApplePay,
|
||||
&connector.connector_name,
|
||||
billing_variants,
|
||||
)
|
||||
.then_some(payment_types::ApplePayBillingContactFields(vec![
|
||||
payment_types::ApplePayAddressParameters::PostalAddress,
|
||||
]));
|
||||
|
||||
let required_shipping_contact_fields =
|
||||
if business_profile.collect_shipping_details_from_wallet_connector == Some(true) {
|
||||
let required_shipping_contact_fields = business_profile
|
||||
.collect_shipping_details_from_wallet_connector
|
||||
.unwrap_or(false)
|
||||
.then_some({
|
||||
let shipping_variants = enums::FieldType::get_shipping_variants();
|
||||
|
||||
is_dynamic_fields_required(
|
||||
&state.conf.required_fields,
|
||||
enums::PaymentMethod::Wallet,
|
||||
@ -324,9 +330,8 @@ async fn create_applepay_session_token(
|
||||
payment_types::ApplePayAddressParameters::Phone,
|
||||
payment_types::ApplePayAddressParameters::Email,
|
||||
]))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
})
|
||||
.flatten();
|
||||
|
||||
// Get apple pay payment request
|
||||
let applepay_payment_request = get_apple_pay_payment_request(
|
||||
@ -562,15 +567,20 @@ fn create_gpay_session_token(
|
||||
expected_format: "gpay_metadata_format".to_string(),
|
||||
})?;
|
||||
|
||||
let billing_variants = enums::FieldType::get_billing_variants();
|
||||
let is_billing_details_required =
|
||||
if business_profile.collect_billing_details_from_wallet_connector == Some(true) {
|
||||
let billing_variants = enums::FieldType::get_billing_variants();
|
||||
|
||||
let is_billing_details_required = is_dynamic_fields_required(
|
||||
&state.conf.required_fields,
|
||||
enums::PaymentMethod::Wallet,
|
||||
enums::PaymentMethodType::GooglePay,
|
||||
&connector.connector_name,
|
||||
billing_variants,
|
||||
);
|
||||
is_dynamic_fields_required(
|
||||
&state.conf.required_fields,
|
||||
enums::PaymentMethod::Wallet,
|
||||
enums::PaymentMethodType::GooglePay,
|
||||
&connector.connector_name,
|
||||
billing_variants,
|
||||
)
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
let billing_address_parameters =
|
||||
is_billing_details_required.then_some(payment_types::GpayBillingAddressParameters {
|
||||
|
||||
@ -285,6 +285,7 @@ pub async fn update_business_profile_active_algorithm_ref(
|
||||
extended_card_info_config: None,
|
||||
use_billing_as_payment_method_billing: None,
|
||||
collect_shipping_details_from_wallet_connector: None,
|
||||
collect_billing_details_from_wallet_connector: None,
|
||||
is_connector_agnostic_mit_enabled: None,
|
||||
};
|
||||
|
||||
|
||||
@ -99,6 +99,8 @@ impl ForeignTryFrom<storage::business_profile::BusinessProfile> for BusinessProf
|
||||
.transpose()?,
|
||||
collect_shipping_details_from_wallet_connector: item
|
||||
.collect_shipping_details_from_wallet_connector,
|
||||
collect_billing_details_from_wallet_connector: item
|
||||
.collect_billing_details_from_wallet_connector,
|
||||
is_connector_agnostic_mit_enabled: item.is_connector_agnostic_mit_enabled,
|
||||
})
|
||||
}
|
||||
@ -211,7 +213,11 @@ impl ForeignTryFrom<(domain::MerchantAccount, BusinessProfileCreate)>
|
||||
.use_billing_as_payment_method_billing
|
||||
.or(Some(true)),
|
||||
collect_shipping_details_from_wallet_connector: request
|
||||
.collect_shipping_details_from_wallet_connector,
|
||||
.collect_shipping_details_from_wallet_connector
|
||||
.or(Some(false)),
|
||||
collect_billing_details_from_wallet_connector: request
|
||||
.collect_billing_details_from_wallet_connector
|
||||
.or(Some(false)),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user