feat(connector): [BANKOFAMERICA] Implement Apple Pay (#3061)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
DEEPANSHU BANSAL
2023-12-06 15:26:38 +05:30
committed by GitHub
parent 84decd8126
commit 47c038300a
5 changed files with 205 additions and 45 deletions

View File

@ -28,7 +28,7 @@ use crate::{
pii::PeekInterface,
types::{
self, api, storage::payment_attempt::PaymentAttemptExt, transformers::ForeignTryFrom,
PaymentsCancelData, ResponseId,
ApplePayPredecryptData, PaymentsCancelData, ResponseId,
},
utils::{OptionExt, ValueExt},
};
@ -855,6 +855,33 @@ impl ApplePay for payments::ApplePayWalletData {
}
}
pub trait ApplePayDecrypt {
fn get_expiry_month(&self) -> Result<Secret<String>, Error>;
fn get_four_digit_expiry_year(&self) -> Result<Secret<String>, Error>;
}
impl ApplePayDecrypt for Box<ApplePayPredecryptData> {
fn get_four_digit_expiry_year(&self) -> Result<Secret<String>, Error> {
Ok(Secret::new(format!(
"20{}",
self.application_expiration_date
.peek()
.get(0..2)
.ok_or(errors::ConnectorError::RequestEncodingFailed)?
)))
}
fn get_expiry_month(&self) -> Result<Secret<String>, Error> {
Ok(Secret::new(
self.application_expiration_date
.peek()
.get(2..4)
.ok_or(errors::ConnectorError::RequestEncodingFailed)?
.to_owned(),
))
}
}
pub trait CryptoData {
fn get_pay_currency(&self) -> Result<String, Error>;
}