use std::env; use router::types::ConnectorAuthType; use serde::Deserialize; #[derive(Debug, Deserialize, Clone)] pub(crate) struct ConnectorAuthentication { pub aci: Option, pub adyen: Option, pub airwallex: Option, pub authorizedotnet: Option, pub bambora: Option, pub bluesnap: Option, pub checkout: Option, pub cybersource: Option, pub dlocal: Option, pub fiserv: Option, pub globalpay: Option, pub mollie: Option, pub multisafepay: Option, pub nuvei: Option, pub paypal: Option, pub payu: Option, pub rapyd: Option, pub shift4: Option, pub stripe: Option, pub worldpay: Option, pub worldline: Option, pub trustpay: Option, } impl ConnectorAuthentication { #[allow(clippy::expect_used)] pub(crate) fn new() -> Self { let path = env::var("CONNECTOR_AUTH_FILE_PATH") .expect("connector authentication file path not set"); toml::from_str( &std::fs::read_to_string(path).expect("connector authentication config file not found"), ) .expect("Failed to read connector authentication config file") } } #[derive(Debug, Deserialize, Clone)] pub(crate) struct HeaderKey { pub api_key: String, } impl From for ConnectorAuthType { fn from(key: HeaderKey) -> Self { Self::HeaderKey { api_key: key.api_key, } } } #[derive(Debug, Deserialize, Clone)] pub(crate) struct BodyKey { pub api_key: String, pub key1: String, } impl From for ConnectorAuthType { fn from(key: BodyKey) -> Self { Self::BodyKey { api_key: key.api_key, key1: key.key1, } } } #[derive(Debug, Deserialize, Clone)] pub(crate) struct SignatureKey { pub api_key: String, pub key1: String, pub api_secret: String, } impl From for ConnectorAuthType { fn from(key: SignatureKey) -> Self { Self::SignatureKey { api_key: key.api_key, key1: key.key1, api_secret: key.api_secret, } } }