Files
Arun Raj M f3224cc4df chore: merging back release v0.3.0 back to main (#636) (#655)
Co-authored-by: Sangamesh Kulkarni <59434228+Sangamesh26@users.noreply.github.com>
Co-authored-by: ItsMeShashank <shashank.attarde@juspay.in>
Co-authored-by: Abhishek <abhishek.marrivagu@juspay.in>
Co-authored-by: Jagan <jaganelavarasan@gmail.com>
Co-authored-by: SamraatBansal <55536657+SamraatBansal@users.noreply.github.com>
Co-authored-by: Sampras Lopes <lsampras@protonmail.com>
2023-02-26 08:25:17 +00:00

80 lines
2.0 KiB
Rust

use router::types::ConnectorAuthType;
use serde::Deserialize;
#[derive(Debug, Deserialize, Clone)]
pub(crate) struct ConnectorAuthentication {
pub dlocal: Option<SignatureKey>,
pub aci: Option<BodyKey>,
pub adyen: Option<BodyKey>,
pub airwallex: Option<BodyKey>,
pub authorizedotnet: Option<BodyKey>,
pub bluesnap: Option<BodyKey>,
pub checkout: Option<BodyKey>,
pub cybersource: Option<SignatureKey>,
pub fiserv: Option<SignatureKey>,
pub globalpay: Option<HeaderKey>,
pub nuvei: Option<SignatureKey>,
pub payu: Option<BodyKey>,
pub rapyd: Option<BodyKey>,
pub shift4: Option<HeaderKey>,
pub stripe: Option<HeaderKey>,
pub worldpay: Option<HeaderKey>,
pub worldline: Option<SignatureKey>,
}
impl ConnectorAuthentication {
pub(crate) fn new() -> Self {
#[allow(clippy::expect_used)]
toml::from_str(
&std::fs::read_to_string("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,
}
}
}
#[derive(Debug, Deserialize, Clone)]
pub(crate) struct SignatureKey {
pub api_key: String,
pub key1: String,
pub api_secret: String,
}
impl From<SignatureKey> for ConnectorAuthType {
fn from(key: SignatureKey) -> Self {
Self::SignatureKey {
api_key: key.api_key,
key1: key.key1,
api_secret: key.api_secret,
}
}
}