feat(payment_methods): pass required shipping details field for wallets session call based on business_profile config (#4616)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Shankar Singh C
2024-05-14 20:25:52 +05:30
committed by GitHub
parent e43ae653a0
commit 650f3fa25c
30 changed files with 692 additions and 30 deletions

View File

@ -916,6 +916,9 @@ pub struct BusinessProfileCreate {
/// Whether to use the billing details passed when creating the intent as payment method billing
pub use_billing_as_payment_method_billing: Option<bool>,
/// A boolean value to indicate if cusomter shipping details needs to be sent for wallets payments
pub collect_shipping_details_from_wallet_connector: Option<bool>,
}
#[derive(Clone, Debug, ToSchema, Serialize)]
@ -1055,6 +1058,9 @@ pub struct BusinessProfileUpdate {
// Whether to use the billing details passed when creating the intent as payment method billing
pub use_billing_as_payment_method_billing: Option<bool>,
/// A boolean value to indicate if cusomter shipping details needs to be sent for wallets payments
pub collect_shipping_details_from_wallet_connector: Option<bool>,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]

View File

@ -422,6 +422,13 @@ pub enum FieldType {
UserAddressPincode,
UserAddressState,
UserAddressCountry { options: Vec<String> },
UserShippingName,
UserShippingAddressLine1,
UserShippingAddressLine2,
UserShippingAddressCity,
UserShippingAddressPincode,
UserShippingAddressState,
UserShippingAddressCountry { options: Vec<String> },
UserBlikCode,
UserBank,
Text,
@ -440,6 +447,18 @@ impl FieldType {
Self::UserAddressCountry { options: vec![] },
]
}
pub fn get_shipping_variants() -> Vec<Self> {
vec![
Self::UserShippingName,
Self::UserShippingAddressLine1,
Self::UserShippingAddressLine2,
Self::UserShippingAddressCity,
Self::UserShippingAddressPincode,
Self::UserShippingAddressState,
Self::UserShippingAddressCountry { options: vec![] },
]
}
}
/// This implementatiobn is to ignore the inner value of UserAddressCountry enum while comparing
@ -477,6 +496,15 @@ impl PartialEq for FieldType {
(Self::UserAddressPincode, Self::UserAddressPincode) => true,
(Self::UserAddressState, Self::UserAddressState) => true,
(Self::UserAddressCountry { .. }, Self::UserAddressCountry { .. }) => true,
(Self::UserShippingName, Self::UserShippingName) => true,
(Self::UserShippingAddressLine1, Self::UserShippingAddressLine1) => true,
(Self::UserShippingAddressLine2, Self::UserShippingAddressLine2) => true,
(Self::UserShippingAddressCity, Self::UserShippingAddressCity) => true,
(Self::UserShippingAddressPincode, Self::UserShippingAddressPincode) => true,
(Self::UserShippingAddressState, Self::UserShippingAddressState) => true,
(Self::UserShippingAddressCountry { .. }, Self::UserShippingAddressCountry { .. }) => {
true
}
(Self::UserBlikCode, Self::UserBlikCode) => true,
(Self::UserBank, Self::UserBank) => true,
(Self::Text, Self::Text) => true,

View File

@ -4098,6 +4098,12 @@ pub struct GooglePayThirdPartySdk {
pub struct GooglePaySessionResponse {
/// The merchant info
pub merchant_info: GpayMerchantInfo,
/// Is shipping address required
pub shipping_address_required: bool,
/// Is email required
pub email_required: bool,
/// Shipping address parameters
pub shipping_address_parameters: GpayShippingAddressParameters,
/// List of the allowed payment meythods
pub allowed_payment_methods: Vec<GpayAllowedPaymentMethods>,
/// The transaction info Google Pay requires
@ -4112,6 +4118,13 @@ pub struct GooglePaySessionResponse {
pub secrets: Option<SecretInfoToInitiateSdk>,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
#[serde(rename_all = "lowercase")]
pub struct GpayShippingAddressParameters {
/// Is shipping phone number required
pub phone_number_required: bool,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
#[serde(rename_all = "lowercase")]
pub struct KlarnaSessionTokenResponse {
@ -4234,7 +4247,22 @@ pub struct ApplePayPaymentRequest {
pub supported_networks: Option<Vec<String>>,
pub merchant_identifier: Option<String>,
/// The required billing contact fields for connector
pub required_billing_contact_fields: Option<Vec<String>>,
pub required_billing_contact_fields: Option<ApplePayBillingContactFields>,
/// The required shipping contacht fields for connector
pub required_shipping_contact_fields: Option<ApplePayShippingContactFields>,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema, serde::Deserialize)]
pub struct ApplePayBillingContactFields(pub Vec<ApplePayAddressParameters>);
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema, serde::Deserialize)]
pub struct ApplePayShippingContactFields(pub Vec<ApplePayAddressParameters>);
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum ApplePayAddressParameters {
PostalAddress,
Phone,
Email,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema, serde::Deserialize)]