feat(connector): [Authorizedotnet] Add Wallet support (#1223)

Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
Co-authored-by: Arjun Karthik <m.arjunkarthik@gmail.com>
This commit is contained in:
chikke srujan
2023-07-14 15:23:48 +05:30
committed by GitHub
parent 8832dd60b9
commit 05540ea17e
6 changed files with 386 additions and 74 deletions

View File

@ -581,6 +581,7 @@ pub trait WalletData {
fn get_wallet_token_as_json<T>(&self) -> Result<T, Error>
where
T: serde::de::DeserializeOwned;
fn get_encoded_wallet_token(&self) -> Result<String, Error>;
}
impl WalletData for api::WalletData {
@ -600,6 +601,20 @@ impl WalletData for api::WalletData {
.into_report()
.change_context(errors::ConnectorError::InvalidWalletToken)
}
fn get_encoded_wallet_token(&self) -> Result<String, Error> {
match self {
Self::GooglePay(_) => {
let json_token: serde_json::Value = self.get_wallet_token_as_json()?;
let token_as_vec = serde_json::to_vec(&json_token)
.into_report()
.change_context(errors::ConnectorError::InvalidWalletToken)?;
let encoded_token = consts::BASE64_ENGINE.encode(token_as_vec);
Ok(encoded_token)
}
_ => Err(errors::ConnectorError::InvalidWalletToken.into()),
}
}
}
pub trait ApplePay {