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(payment_methods): pass required shipping details field for wallets session call based on business_profile config #4616

Merged
merged 50 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a0788dc
feat(payment_methods): pass field in apple pay seesion call based on…
ShankarSinghC May 9, 2024
fce78e1
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 9, 2024
706ae12
check for mandate and common dynamic fields as well
ShankarSinghC May 9, 2024
f1d8698
address pr comment
ShankarSinghC May 9, 2024
015b6a9
chore: run formatter
hyperswitch-bot[bot] May 9, 2024
d98c377
Merge branch 'main' into apple_pay/billing-dynamic-fields
ShankarSinghC May 9, 2024
704130d
address failing checks
ShankarSinghC May 9, 2024
4695eac
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 9, 2024
10cc11c
address pr comment
ShankarSinghC May 9, 2024
1b9bd5b
Merge branch 'apple_pay/billing-dynamic-fields' of https://github.com…
ShankarSinghC May 9, 2024
7751a00
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 9, 2024
7f6be7f
add business profile config to send shipping address
ShankarSinghC May 9, 2024
1d42b63
Merge branch 'apple_pay/billing-dynamic-fields' of https://github.com…
ShankarSinghC May 9, 2024
c62bddc
feat(payment_methods): pass field in apple pay seesion call based on…
ShankarSinghC May 9, 2024
ea976a3
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 9, 2024
218da2d
pass required_shipping_contact_fields field in google pay seesion cal…
ShankarSinghC May 10, 2024
5f499c7
Merge branch 'apple_pay/shipping-dynamic-fields' of https://github.co…
ShankarSinghC May 10, 2024
a2c02bf
address failing checks
ShankarSinghC May 10, 2024
d4e7145
feat(payment_methods): pass field in gpay pay seesion call based on …
ShankarSinghC May 10, 2024
00a0a07
Merge branch 'apple_pay/billing-dynamic-fields' of https://github.com…
ShankarSinghC May 10, 2024
7927eff
address pr comments
ShankarSinghC May 10, 2024
e765890
Merge branch 'main' into apple_pay/billing-dynamic-fields
ShankarSinghC May 10, 2024
fe7ac8a
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 10, 2024
5d6c7e3
Merge branch 'apple_pay/billing-dynamic-fields' of https://github.com…
ShankarSinghC May 10, 2024
9704096
fix conflicts errors
ShankarSinghC May 10, 2024
06200bf
Merge branch 'apple_pay/billing-dynamic-fields' of https://github.com…
ShankarSinghC May 10, 2024
0e666c7
filter out the shipping field from the dynamic fileds im payment_meth…
ShankarSinghC May 13, 2024
67dbf20
add a tests case
ShankarSinghC May 13, 2024
69d38df
Merge branch 'main' of https://github.com/juspay/hyperswitch into app…
ShankarSinghC May 13, 2024
57a48e9
Merge branch 'apple_pay/billing-dynamic-fields' into apple_pay/shippi…
ShankarSinghC May 13, 2024
d3fb873
fix typos
ShankarSinghC May 13, 2024
65352ac
fix typos
ShankarSinghC May 13, 2024
46cac85
Merge branch 'apple_pay/billing-dynamic-fields' into apple_pay/shippi…
ShankarSinghC May 13, 2024
f824032
fix clippy errors
ShankarSinghC May 13, 2024
b806539
Merge branch 'apple_pay/billing-dynamic-fields' into apple_pay/shippi…
ShankarSinghC May 13, 2024
c5a4157
fix typos
ShankarSinghC May 13, 2024
7658591
make format firld as enum
ShankarSinghC May 13, 2024
6172632
Merge branch 'main' of https://github.com/juspay/hyperswitch into app…
ShankarSinghC May 13, 2024
c71977b
address failing checks
ShankarSinghC May 13, 2024
39b6ad2
Merge branch 'apple_pay/billing-dynamic-fields' into apple_pay/shippi…
ShankarSinghC May 13, 2024
41b7bc5
make the postaladdress as enum
ShankarSinghC May 13, 2024
7a919d7
resolve merge conflicts
ShankarSinghC May 13, 2024
0f124a9
use then_some()
ShankarSinghC May 14, 2024
b69b018
address failing checks
ShankarSinghC May 14, 2024
d7f0590
undo the previous commit
ShankarSinghC May 14, 2024
abcf55b
add a new line
ShankarSinghC May 14, 2024
2ca5fed
Merge branch 'main' into apple_pay/shipping-dynamic-fields
ShankarSinghC May 14, 2024
4e3c527
remove the payment_method_data path from shipping required fields
ShankarSinghC May 14, 2024
c60b888
Merge branch 'apple_pay/shipping-dynamic-fields' of https://github.co…
ShankarSinghC May 14, 2024
6ef3e05
rename display_name for shipping.address.first_name
ShankarSinghC May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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)]
Expand Down
28 changes: 28 additions & 0 deletions crates/api_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
30 changes: 29 additions & 1 deletion crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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)]
Expand Down
10 changes: 10 additions & 0 deletions crates/diesel_models/src/business_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub struct BusinessProfile {
pub extended_card_info_config: Option<pii::SecretSerdeValue>,
pub is_connector_agnostic_mit_enabled: Option<bool>,
pub use_billing_as_payment_method_billing: Option<bool>,
pub collect_shipping_details_from_wallet_connector: Option<bool>,
}

#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
Expand Down Expand Up @@ -69,6 +70,7 @@ pub struct BusinessProfileNew {
pub extended_card_info_config: Option<pii::SecretSerdeValue>,
pub is_connector_agnostic_mit_enabled: Option<bool>,
pub use_billing_as_payment_method_billing: Option<bool>,
pub collect_shipping_details_from_wallet_connector: Option<bool>,
}

#[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)]
Expand Down Expand Up @@ -96,6 +98,7 @@ pub struct BusinessProfileUpdateInternal {
pub extended_card_info_config: Option<pii::SecretSerdeValue>,
pub is_connector_agnostic_mit_enabled: Option<bool>,
pub use_billing_as_payment_method_billing: Option<bool>,
pub collect_shipping_details_from_wallet_connector: Option<bool>,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
Expand All @@ -120,6 +123,7 @@ pub enum BusinessProfileUpdate {
authentication_connector_details: Option<serde_json::Value>,
extended_card_info_config: Option<pii::SecretSerdeValue>,
use_billing_as_payment_method_billing: Option<bool>,
collect_shipping_details_from_wallet_connector: Option<bool>,
},
ExtendedCardInfoUpdate {
is_extended_card_info_enabled: Option<bool>,
Expand Down Expand Up @@ -152,6 +156,7 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
authentication_connector_details,
extended_card_info_config,
use_billing_as_payment_method_billing,
collect_shipping_details_from_wallet_connector,
} => Self {
profile_name,
modified_at,
Expand All @@ -172,6 +177,7 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
authentication_connector_details,
extended_card_info_config,
use_billing_as_payment_method_billing,
collect_shipping_details_from_wallet_connector,
..Default::default()
},
BusinessProfileUpdate::ExtendedCardInfoUpdate {
Expand Down Expand Up @@ -217,6 +223,8 @@ impl From<BusinessProfileNew> for BusinessProfile {
is_extended_card_info_enabled: new.is_extended_card_info_enabled,
extended_card_info_config: new.extended_card_info_config,
use_billing_as_payment_method_billing: new.use_billing_as_payment_method_billing,
collect_shipping_details_from_wallet_connector: new
.collect_shipping_details_from_wallet_connector,
}
}
}
Expand Down Expand Up @@ -245,6 +253,7 @@ impl BusinessProfileUpdate {
extended_card_info_config,
is_connector_agnostic_mit_enabled,
use_billing_as_payment_method_billing,
collect_shipping_details_from_wallet_connector,
} = self.into();
BusinessProfile {
profile_name: profile_name.unwrap_or(source.profile_name),
Expand All @@ -270,6 +279,7 @@ impl BusinessProfileUpdate {
is_connector_agnostic_mit_enabled,
extended_card_info_config,
use_billing_as_payment_method_billing,
collect_shipping_details_from_wallet_connector,
..source
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ diesel::table! {
extended_card_info_config -> Nullable<Jsonb>,
is_connector_agnostic_mit_enabled -> Nullable<Bool>,
use_billing_as_payment_method_billing -> Nullable<Bool>,
collect_shipping_details_from_wallet_connector -> Nullable<Bool>,
}
}

Expand Down
4 changes: 4 additions & 0 deletions crates/openapi/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::NoThirdPartySdkSessionResponse,
api_models::payments::SecretInfoToInitiateSdk,
api_models::payments::ApplePayPaymentRequest,
api_models::payments::ApplePayBillingContactFields,
api_models::payments::ApplePayShippingContactFields,
api_models::payments::ApplePayAddressParameters,
api_models::payments::AmountInfo,
api_models::payments::ProductType,
api_models::payments::GooglePayWalletData,
Expand Down Expand Up @@ -388,6 +391,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::GooglePayRedirectData,
api_models::payments::GooglePayThirdPartySdk,
api_models::payments::GooglePaySessionResponse,
api_models::payments::GpayShippingAddressParameters,
api_models::payments::GpayBillingAddressParameters,
api_models::payments::GpayBillingAddressFormat,
api_models::payments::SepaBankTransferInstructions,
Expand Down