feat(connector) : add Cards(3ds & non3ds),bank_redirects ,wallets(Paypal,Applepay) and Mandates support to nexinets (#898)

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-05-03 13:47:42 +05:30
committed by GitHub
parent 2cff019a1b
commit eea05f5c31
11 changed files with 1148 additions and 252 deletions

View File

@ -244,7 +244,7 @@ impl PaymentsCompleteAuthorizeRequestData for types::CompleteAuthorizeData {
pub trait PaymentsSyncRequestData {
fn is_auto_capture(&self) -> Result<bool, Error>;
fn get_connector_transaction_id(&self) -> CustomResult<String, errors::ValidationError>;
fn get_connector_transaction_id(&self) -> CustomResult<String, errors::ConnectorError>;
}
impl PaymentsSyncRequestData for types::PaymentsSyncData {
@ -255,14 +255,15 @@ impl PaymentsSyncRequestData for types::PaymentsSyncData {
Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()),
}
}
fn get_connector_transaction_id(&self) -> CustomResult<String, errors::ValidationError> {
fn get_connector_transaction_id(&self) -> CustomResult<String, errors::ConnectorError> {
match self.connector_transaction_id.clone() {
ResponseId::ConnectorTransactionId(txn_id) => Ok(txn_id),
_ => Err(errors::ValidationError::IncorrectValueProvided {
field_name: "connector_transaction_id",
})
.into_report()
.attach_printable("Expected connector transaction ID not found"),
.attach_printable("Expected connector transaction ID not found")
.change_context(errors::ConnectorError::MissingConnectorTransactionID)?,
}
}
}
@ -400,7 +401,7 @@ impl WalletData for api::WalletData {
fn get_wallet_token(&self) -> Result<String, Error> {
match self {
Self::GooglePay(data) => Ok(data.tokenization_data.token.clone()),
Self::ApplePay(data) => Ok(data.payment_data.clone()),
Self::ApplePay(data) => Ok(data.get_applepay_decoded_payment_data()?),
Self::PaypalSdk(data) => Ok(data.token.clone()),
_ => Err(errors::ConnectorError::InvalidWallet.into()),
}
@ -415,6 +416,23 @@ impl WalletData for api::WalletData {
}
}
pub trait ApplePay {
fn get_applepay_decoded_payment_data(&self) -> Result<String, Error>;
}
impl ApplePay for payments::ApplePayWalletData {
fn get_applepay_decoded_payment_data(&self) -> Result<String, Error> {
let token = String::from_utf8(
consts::BASE64_ENGINE
.decode(&self.payment_data)
.into_report()
.change_context(errors::ConnectorError::InvalidWalletToken)?,
)
.into_report()
.change_context(errors::ConnectorError::InvalidWalletToken)?;
Ok(token)
}
}
pub trait PhoneDetailsData {
fn get_number(&self) -> Result<Secret<String>, Error>;
fn get_country_code(&self) -> Result<String, Error>;