refactor(fix): [Mollie] Add support for both HeaderKey and BodyKey AuthType (#1761)

This commit is contained in:
Swangi Kumari
2023-07-25 18:30:18 +05:30
committed by GitHub
parent 9ba8ec348b
commit 07c60f8abf

View File

@ -253,7 +253,9 @@ impl TryFrom<&types::TokenizationRouterData> for MollieCardTokenRequest {
.ok_or(errors::ConnectorError::MissingRequiredField { .ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "test_mode", field_name: "test_mode",
})?; })?;
let profile_token = auth.key1; let profile_token = auth
.profile_token
.ok_or(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(Self { Ok(Self {
card_holder, card_holder,
card_number, card_number,
@ -434,19 +436,22 @@ pub struct BankDetails {
pub struct MollieAuthType { pub struct MollieAuthType {
pub(super) api_key: Secret<String>, pub(super) api_key: Secret<String>,
pub(super) key1: Secret<String>, pub(super) profile_token: Option<Secret<String>>,
} }
impl TryFrom<&types::ConnectorAuthType> for MollieAuthType { impl TryFrom<&types::ConnectorAuthType> for MollieAuthType {
type Error = Error; type Error = Error;
fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> { fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
if let types::ConnectorAuthType::BodyKey { api_key, key1 } = auth_type { match auth_type {
Ok(Self { types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self {
api_key: Secret::new(api_key.to_owned()), api_key: Secret::new(api_key.to_owned()),
key1: Secret::new(key1.to_owned()), profile_token: None,
}) }),
} else { types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {
Err(errors::ConnectorError::FailedToObtainAuthType.into()) api_key: Secret::new(api_key.to_owned()),
profile_token: Some(Secret::new(key1.to_owned())),
}),
_ => Err(errors::ConnectorError::FailedToObtainAuthType)?,
} }
} }
} }