From f345e6b31f76e3edd14c7f407d1415abd65e96ec Mon Sep 17 00:00:00 2001 From: Prasunna Soppa Date: Wed, 27 Sep 2023 17:39:44 +0530 Subject: [PATCH 1/3] add required field for blik pm for adyen and stripe --- crates/api_models/src/payments.rs | 2 +- crates/router/src/configs/defaults.rs | 51 +++++++++++++++++++ .../src/connector/adyen/transformers.rs | 4 +- .../src/connector/stripe/transformers.rs | 6 ++- 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 6a06b76d0e47..3b01d73e74eb 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -868,7 +868,7 @@ pub enum BankRedirectData { Bizum {}, Blik { // Blik Code - blik_code: String, + blik_code: Option, }, Eps { /// The billing details for bank redirection diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index cebb0014064e..74792464e6ac 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -3840,6 +3840,57 @@ impl Default for super::settings::RequiredFields { ]), }, ), + ( + enums::PaymentMethodType::Blik, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "payment_method_data.bank_redirect.blik.blik_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.blik.blik_code".to_string(), + display_name: "blik_code".to_string(), + field_type: enums::FieldType::UserBlikCode, + value: None, + } + ) + ]), + } + ), + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "payment_method_data.bank_redirect.blik.blik_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.blik.blik_code".to_string(), + display_name: "blik_code".to_string(), + field_type: enums::FieldType::UserBlikCode, + value: None, + } + ) + ]), + } + ), + // ( + // enums::Connector::Trustpay, + // RequiredFieldFinal { + // mandate: HashMap::new(), + // non_mandate: HashMap::new(), + // common: HashMap::new(), + // } + // ) + ]), + }, + ), ])), ), ( diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index 708d795db0e1..d56a296ef47b 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -2034,7 +2034,9 @@ impl<'a> TryFrom<&api_models::payments::BankRedirectData> for AdyenPaymentMethod api_models::payments::BankRedirectData::Blik { blik_code } => { Ok(AdyenPaymentMethod::Blik(Box::new(BlikRedirectionData { payment_type: PaymentType::Blik, - blik_code: blik_code.to_string(), + blik_code: blik_code.clone().ok_or(errors::ConnectorError::MissingRequiredField { + field_name: "blik_code", + })?, }))) } api_models::payments::BankRedirectData::Eps { bank_name, .. } => Ok( diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index 962bfe52f097..1904c6f8f825 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -1582,7 +1582,7 @@ impl TryFrom<&payments::BankRedirectData> for StripePaymentMethodData { type Error = error_stack::Report; fn try_from(bank_redirect_data: &payments::BankRedirectData) -> Result { let payment_method_data_type = StripePaymentMethodType::try_from(bank_redirect_data)?; - match bank_redirect_data.deref() { + match bank_redirect_data { payments::BankRedirectData::BancontactCard { .. } => Ok(Self::BankRedirect( StripeBankRedirectData::StripeBancontactCard(Box::new(StripeBancontactCard { payment_method_data_type, @@ -1591,7 +1591,9 @@ impl TryFrom<&payments::BankRedirectData> for StripePaymentMethodData { payments::BankRedirectData::Blik { blik_code } => Ok(Self::BankRedirect( StripeBankRedirectData::StripeBlik(Box::new(StripeBlik { payment_method_data_type, - code: blik_code.to_owned(), + code: blik_code.clone().ok_or(errors::ConnectorError::MissingRequiredField { + field_name: "blik_code", + })?, })), )), payments::BankRedirectData::Eps { bank_name, .. } => Ok(Self::BankRedirect( From d03e0d76a19fa3d7e3abcfc15219bf86f8dba3b9 Mon Sep 17 00:00:00 2001 From: Prasunna Soppa Date: Thu, 28 Sep 2023 21:44:21 +0530 Subject: [PATCH 2/3] add mandatory fields for blik pm for trustpay --- crates/router/src/configs/defaults.rs | 44 +++++++++++++++---- .../src/connector/adyen/transformers.rs | 8 ++-- .../src/connector/stripe/transformers.rs | 8 ++-- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index 74792464e6ac..ec06a6d7078f 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -3880,14 +3880,42 @@ impl Default for super::settings::RequiredFields { ]), } ), - // ( - // enums::Connector::Trustpay, - // RequiredFieldFinal { - // mandate: HashMap::new(), - // non_mandate: HashMap::new(), - // common: HashMap::new(), - // } - // ) + ( + enums::Connector::Trustpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ]), + } + ) ]), }, ), diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index d56a296ef47b..94c7f0c58778 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -2034,9 +2034,11 @@ impl<'a> TryFrom<&api_models::payments::BankRedirectData> for AdyenPaymentMethod api_models::payments::BankRedirectData::Blik { blik_code } => { Ok(AdyenPaymentMethod::Blik(Box::new(BlikRedirectionData { payment_type: PaymentType::Blik, - blik_code: blik_code.clone().ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "blik_code", - })?, + blik_code: blik_code.clone().ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "blik_code", + }, + )?, }))) } api_models::payments::BankRedirectData::Eps { bank_name, .. } => Ok( diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index d424efdd9488..488a7a295bd2 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -1591,9 +1591,11 @@ impl TryFrom<&payments::BankRedirectData> for StripePaymentMethodData { payments::BankRedirectData::Blik { blik_code } => Ok(Self::BankRedirect( StripeBankRedirectData::StripeBlik(Box::new(StripeBlik { payment_method_data_type, - code: blik_code.clone().ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "blik_code", - })?, + code: blik_code.clone().ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "blik_code", + }, + )?, })), )), payments::BankRedirectData::Eps { bank_name, .. } => Ok(Self::BankRedirect( From 50d0df4d831dfa9bc802964d41751f250af56161 Mon Sep 17 00:00:00 2001 From: Prasunna Soppa Date: Sun, 1 Oct 2023 22:50:33 +0530 Subject: [PATCH 3/3] generate openapi spec --- openapi/openapi_spec.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index 2bce9585fdf4..18d93628aaa4 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -2911,12 +2911,10 @@ "properties": { "blik": { "type": "object", - "required": [ - "blik_code" - ], "properties": { "blik_code": { - "type": "string" + "type": "string", + "nullable": true } } }