Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

refactor(connector): [KLARNA] Add dynamic fields for klarna payment method (#4891)

Swangi Kumaridae14139604b
diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs
index ce039c1156..7ee39a33d3 100644
--- a/crates/api_models/src/enums.rs
+++ b/crates/api_models/src/enums.rs
@@ -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
@@ -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,
diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs
index 6f1ce4458e..1639963188 100644
--- a/crates/router/src/configs/defaults.rs
+++ b/crates/router/src/configs/defaults.rs
@@ -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,
+ }
+ ),
+ ]),
+ }
+ )
]),
},
),
diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json
index a12df1d916..434e6e2678 100644
--- a/openapi/openapi_spec.json
+++ b/openapi/openapi_spec.json
@@ -9262,7 +9262,7 @@
{
"type": "string",
"enum": [
- "user_country_code"
+ "user_phone_number_country_code"
]
},
{