Skip to content

Commit

Permalink
refactor(connector): [KLARNA] Add dynamic fields for klarna payment m…
Browse files Browse the repository at this point in the history
…ethod (#4891)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
swangi-kumari and hyperswitch-bot[bot] authored Jun 5, 2024
1 parent 3d53fd0 commit dae1413
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/api_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ pub enum FieldType {
UserFullName,
UserEmailAddress,
UserPhoneNumber,
UserCountryCode, //phone number's country code
UserPhoneNumberCountryCode, //phone number's country code
UserCountry { options: Vec<String> }, //for country inside payment method data ex- bank redirect
UserCurrency { options: Vec<String> },
UserCryptoCurrencyNetwork, //for crypto network associated with the cryptopcurrency
Expand Down Expand Up @@ -494,7 +494,7 @@ impl PartialEq for FieldType {
(Self::UserFullName, Self::UserFullName) => true,
(Self::UserEmailAddress, Self::UserEmailAddress) => true,
(Self::UserPhoneNumber, Self::UserPhoneNumber) => true,
(Self::UserCountryCode, Self::UserCountryCode) => true,
(Self::UserPhoneNumberCountryCode, Self::UserPhoneNumberCountryCode) => true,
(
Self::UserCountry {
options: options_self,
Expand Down
133 changes: 133 additions & 0 deletions crates/router/src/configs/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8243,6 +8243,139 @@ impl Default for super::settings::RequiredFields {
common : HashMap::new(),
}
),
(
enums::Connector::Klarna,
RequiredFieldFinal {
mandate: HashMap::new(),
non_mandate: HashMap::new(),
common: HashMap::from([
(
"shipping.address.first_name".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.first_name".to_string(),
display_name: "shipping_first_name".to_string(),
field_type: enums::FieldType::UserShippingName,
value: None,
}
),
(
"shipping.address.last_name".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.last_name".to_string(),
display_name: "shipping_last_name".to_string(),
field_type: enums::FieldType::UserShippingName,
value: None,
}
),
(
"shipping.address.city".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.city".to_string(),
display_name: "city".to_string(),
field_type: enums::FieldType::UserShippingAddressCity,
value: None,
}
),
(
"shipping.address.line1".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.line1".to_string(),
display_name: "line1".to_string(),
field_type: enums::FieldType::UserShippingAddressLine1,
value: None,
}
),
(
"shipping.address.line2".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.line2".to_string(),
display_name: "line2".to_string(),
field_type: enums::FieldType::UserShippingAddressLine2,
value: None,
}
),
(
"shipping.address.zip".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.zip".to_string(),
display_name: "zip".to_string(),
field_type: enums::FieldType::UserShippingAddressPincode,
value: None,
}
),
(
"shipping.address.state".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.state".to_string(),
display_name: "state".to_string(),
field_type: enums::FieldType::UserShippingAddressState,
value: None,
}
),
(
"shipping.email".to_string(),
RequiredFieldInfo {
required_field: "shipping.email".to_string(),
display_name: "email".to_string(),
field_type: enums::FieldType::UserEmailAddress,
value: None,
}
),
(
"shipping.phone.number".to_string(),
RequiredFieldInfo {
required_field: "shipping.phone.number".to_string(),
display_name: "phone_number".to_string(),
field_type: enums::FieldType::UserPhoneNumber,
value: None,
}
),
(
"shipping.phone.country_code".to_string(),
RequiredFieldInfo {
required_field: "shipping.phone.country_code".to_string(),
display_name: "phone_country_code".to_string(),
field_type: enums::FieldType::UserPhoneNumberCountryCode,
value: None,
}
),
(
"shipping.address.country".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.country".to_string(),
display_name: "country".to_string(),
field_type: enums::FieldType::UserShippingAddressCountry{
options: vec![
"AU".to_string(),
"AT".to_string(),
"BE".to_string(),
"CA".to_string(),
"CZ".to_string(),
"DK".to_string(),
"FI".to_string(),
"FR".to_string(),
"DE".to_string(),
"GR".to_string(),
"IE".to_string(),
"IT".to_string(),
"NL".to_string(),
"NZ".to_string(),
"NO".to_string(),
"PL".to_string(),
"PT".to_string(),
"ES".to_string(),
"SE".to_string(),
"CH".to_string(),
"GB".to_string(),
"US".to_string(),
]
},
value: None,
}
),
]),
}
)
]),
},
),
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -9262,7 +9262,7 @@
{
"type": "string",
"enum": [
"user_country_code"
"user_phone_number_country_code"
]
},
{
Expand Down

0 comments on commit dae1413

Please sign in to comment.