mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
53 lines
1.3 KiB
Rust
53 lines
1.3 KiB
Rust
use router::types::ConnectorAuthType;
|
|
use serde::Deserialize;
|
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
|
pub(crate) struct ConnectorAuthentication {
|
|
pub aci: Option<BodyKey>,
|
|
pub authorizedotnet: Option<BodyKey>,
|
|
pub checkout: Option<BodyKey>,
|
|
pub globalpay: Option<HeaderKey>,
|
|
pub payu: Option<BodyKey>,
|
|
pub shift4: Option<HeaderKey>,
|
|
pub worldpay: Option<HeaderKey>,
|
|
}
|
|
|
|
impl ConnectorAuthentication {
|
|
pub(crate) fn new() -> Self {
|
|
#[allow(clippy::expect_used)]
|
|
toml::de::from_slice(
|
|
&std::fs::read("tests/connectors/auth.toml")
|
|
.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<HeaderKey> 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<BodyKey> for ConnectorAuthType {
|
|
fn from(key: BodyKey) -> Self {
|
|
Self::BodyKey {
|
|
api_key: key.api_key,
|
|
key1: key.key1,
|
|
}
|
|
}
|
|
}
|