refactor(connector): remove default cases for Authorizedotnet, Braintree and Fiserv Connector (#2796)

Co-authored-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
This commit is contained in:
Swangi Kumari
2024-03-05 19:03:45 +05:30
committed by GitHub
parent 19c502398f
commit dbac55683a
3 changed files with 143 additions and 34 deletions

View File

@ -164,10 +164,23 @@ fn get_pm_and_subsequent_auth_detail(
}); });
Ok((payment_details, processing_options, subseuent_auth_info)) Ok((payment_details, processing_options, subseuent_auth_info))
} }
_ => Err(errors::ConnectorError::NotSupported { api::PaymentMethodData::CardRedirect(_)
message: format!("{:?}", item.router_data.request.payment_method_data), | api::PaymentMethodData::Wallet(_)
connector: "AuthorizeDotNet", | api::PaymentMethodData::PayLater(_)
})?, | api::PaymentMethodData::BankRedirect(_)
| api::PaymentMethodData::BankDebit(_)
| api::PaymentMethodData::BankTransfer(_)
| api::PaymentMethodData::Crypto(_)
| api::PaymentMethodData::MandatePayment
| api::PaymentMethodData::Reward
| api::PaymentMethodData::Upi(_)
| api::PaymentMethodData::Voucher(_)
| api::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::CardToken(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("authorizedotnet"),
))?
}
} }
} }
_ => match item.router_data.request.payment_method_data { _ => match item.router_data.request.payment_method_data {
@ -193,10 +206,20 @@ fn get_pm_and_subsequent_auth_detail(
None, None,
None, None,
)), )),
_ => Err(errors::ConnectorError::NotSupported { api::PaymentMethodData::CardRedirect(_)
message: format!("{:?}", item.router_data.request.payment_method_data), | api::PaymentMethodData::PayLater(_)
connector: "AuthorizeDotNet", | api::PaymentMethodData::BankRedirect(_)
})?, | api::PaymentMethodData::BankDebit(_)
| api::PaymentMethodData::BankTransfer(_)
| api::PaymentMethodData::Crypto(_)
| api::PaymentMethodData::MandatePayment
| api::PaymentMethodData::Reward
| api::PaymentMethodData::Upi(_)
| api::PaymentMethodData::Voucher(_)
| api::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("authorizedotnet"),
))?,
}, },
} }
} }
@ -289,11 +312,16 @@ pub enum AuthorizationType {
Pre, Pre,
} }
impl From<enums::CaptureMethod> for AuthorizationType { impl TryFrom<enums::CaptureMethod> for AuthorizationType {
fn from(item: enums::CaptureMethod) -> Self { type Error = error_stack::Report<errors::ConnectorError>;
match item {
enums::CaptureMethod::Manual => Self::Pre, fn try_from(capture_method: enums::CaptureMethod) -> Result<Self, Self::Error> {
_ => Self::Final, match capture_method {
enums::CaptureMethod::Manual => Ok(Self::Pre),
enums::CaptureMethod::Automatic => Ok(Self::Final),
enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err(
utils::construct_not_supported_error_report(capture_method, "authorizedotnet"),
)?,
} }
} }
} }
@ -307,13 +335,13 @@ impl TryFrom<&AuthorizedotnetRouterData<&types::PaymentsAuthorizeRouterData>>
) -> Result<Self, Self::Error> { ) -> Result<Self, Self::Error> {
let (payment_details, processing_options, subsequent_auth_information) = let (payment_details, processing_options, subsequent_auth_information) =
get_pm_and_subsequent_auth_detail(item)?; get_pm_and_subsequent_auth_detail(item)?;
let authorization_indicator_type = let authorization_indicator_type = match item.router_data.request.capture_method {
item.router_data Some(capture_method) => Some(AuthorizationIndicator {
.request authorization_indicator: capture_method.try_into()?,
.capture_method }),
.map(|c| AuthorizationIndicator { None => None,
authorization_indicator: c.into(), };
});
let transaction_request = TransactionRequest { let transaction_request = TransactionRequest {
transaction_type: TransactionType::from(item.router_data.request.capture_method), transaction_type: TransactionType::from(item.router_data.request.capture_method),
amount: item.amount, amount: item.amount,
@ -904,6 +932,7 @@ pub enum SyncStatus {
#[serde(rename = "FDSPendingReview")] #[serde(rename = "FDSPendingReview")]
FDSPendingReview, FDSPendingReview,
} }
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct SyncTransactionResponse { pub struct SyncTransactionResponse {
@ -938,7 +967,9 @@ impl From<SyncStatus> for enums::AttemptStatus {
SyncStatus::Voided => Self::Voided, SyncStatus::Voided => Self::Voided,
SyncStatus::CouldNotVoid => Self::VoidFailed, SyncStatus::CouldNotVoid => Self::VoidFailed,
SyncStatus::GeneralError => Self::Failure, SyncStatus::GeneralError => Self::Failure,
_ => Self::Pending, SyncStatus::RefundSettledSuccessfully
| SyncStatus::RefundPendingSettlement
| SyncStatus::FDSPendingReview => Self::Pending,
} }
} }
} }
@ -1190,9 +1221,33 @@ fn get_wallet_data(
cancel_url: return_url.to_owned(), cancel_url: return_url.to_owned(),
})) }))
} }
_ => Err(errors::ConnectorError::NotImplemented( api_models::payments::WalletData::AliPayQr(_)
"Payment method".to_string(), | api_models::payments::WalletData::AliPayRedirect(_)
))?, | api_models::payments::WalletData::AliPayHkRedirect(_)
| api_models::payments::WalletData::MomoRedirect(_)
| api_models::payments::WalletData::KakaoPayRedirect(_)
| api_models::payments::WalletData::GoPayRedirect(_)
| api_models::payments::WalletData::GcashRedirect(_)
| api_models::payments::WalletData::ApplePayRedirect(_)
| api_models::payments::WalletData::ApplePayThirdPartySdk(_)
| api_models::payments::WalletData::DanaRedirect {}
| api_models::payments::WalletData::GooglePayRedirect(_)
| api_models::payments::WalletData::GooglePayThirdPartySdk(_)
| api_models::payments::WalletData::MbWayRedirect(_)
| api_models::payments::WalletData::MobilePayRedirect(_)
| api_models::payments::WalletData::PaypalSdk(_)
| api_models::payments::WalletData::SamsungPay(_)
| api_models::payments::WalletData::TwintRedirect {}
| api_models::payments::WalletData::VippsRedirect {}
| api_models::payments::WalletData::TouchNGoRedirect(_)
| api_models::payments::WalletData::WeChatPayRedirect(_)
| api_models::payments::WalletData::WeChatPayQr(_)
| api_models::payments::WalletData::CashappQr(_)
| api_models::payments::WalletData::SwishQr(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("authorizedotnet"),
))?
}
} }
} }

View File

@ -129,15 +129,53 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BraintreePaymentsRequest {
api_models::payments::WalletData::PaypalSdk(wallet_data) => { api_models::payments::WalletData::PaypalSdk(wallet_data) => {
Ok(wallet_data.token.to_owned()) Ok(wallet_data.token.to_owned())
} }
_ => Err(errors::ConnectorError::InvalidWallet), api_models::payments::WalletData::ApplePay(_)
| api_models::payments::WalletData::GooglePay(_)
| api_models::payments::WalletData::SamsungPay(_)
| api_models::payments::WalletData::AliPayQr(_)
| api_models::payments::WalletData::AliPayRedirect(_)
| api_models::payments::WalletData::AliPayHkRedirect(_)
| api_models::payments::WalletData::MomoRedirect(_)
| api_models::payments::WalletData::KakaoPayRedirect(_)
| api_models::payments::WalletData::GoPayRedirect(_)
| api_models::payments::WalletData::GcashRedirect(_)
| api_models::payments::WalletData::ApplePayRedirect(_)
| api_models::payments::WalletData::ApplePayThirdPartySdk(_)
| api_models::payments::WalletData::DanaRedirect {}
| api_models::payments::WalletData::GooglePayRedirect(_)
| api_models::payments::WalletData::GooglePayThirdPartySdk(_)
| api_models::payments::WalletData::MbWayRedirect(_)
| api_models::payments::WalletData::MobilePayRedirect(_)
| api_models::payments::WalletData::PaypalRedirect(_)
| api_models::payments::WalletData::TwintRedirect {}
| api_models::payments::WalletData::VippsRedirect {}
| api_models::payments::WalletData::TouchNGoRedirect(_)
| api_models::payments::WalletData::WeChatPayRedirect(_)
| api_models::payments::WalletData::WeChatPayQr(_)
| api_models::payments::WalletData::CashappQr(_)
| api_models::payments::WalletData::SwishQr(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("braintree"),
))
}
}? }?
.into(), .into(),
})) }))
} }
_ => Err(errors::ConnectorError::NotImplemented(format!( api::PaymentMethodData::PayLater(_)
"Current Payment Method - {:?}", | api::PaymentMethodData::BankRedirect(_)
item.request.payment_method_data | api::PaymentMethodData::BankDebit(_)
))), | api::PaymentMethodData::BankTransfer(_)
| api::PaymentMethodData::Crypto(_)
| api::PaymentMethodData::CardRedirect(_)
| api::PaymentMethodData::MandatePayment
| api::PaymentMethodData::Reward
| api::PaymentMethodData::Upi(_)
| api::PaymentMethodData::Voucher(_)
| api::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("braintree"),
)),
}?; }?;
let braintree_transaction_body = TransactionBody { let braintree_transaction_body = TransactionBody {
amount, amount,
@ -211,7 +249,9 @@ impl From<BraintreePaymentStatus> for enums::AttemptStatus {
| BraintreePaymentStatus::SettlementDeclined => Self::Failure, | BraintreePaymentStatus::SettlementDeclined => Self::Failure,
BraintreePaymentStatus::Authorized => Self::Authorized, BraintreePaymentStatus::Authorized => Self::Authorized,
BraintreePaymentStatus::Voided => Self::Voided, BraintreePaymentStatus::Voided => Self::Voided,
_ => Self::Pending, BraintreePaymentStatus::SubmittedForSettlement
| BraintreePaymentStatus::SettlementPending
| BraintreePaymentStatus::SettlementConfirmed => Self::Pending,
} }
} }
} }

View File

@ -182,9 +182,23 @@ impl TryFrom<&FiservRouterData<&types::PaymentsAuthorizeRouterData>> for FiservP
}; };
Source::PaymentCard { card } Source::PaymentCard { card }
} }
_ => Err(errors::ConnectorError::NotImplemented( api::PaymentMethodData::Wallet(_)
"Payment Methods".to_string(), | api::PaymentMethodData::PayLater(_)
))?, | api::PaymentMethodData::BankRedirect(_)
| api::PaymentMethodData::BankDebit(_)
| api::PaymentMethodData::CardRedirect(_)
| api::PaymentMethodData::BankTransfer(_)
| api::PaymentMethodData::Crypto(_)
| api::PaymentMethodData::MandatePayment
| api::PaymentMethodData::Reward
| api::PaymentMethodData::Upi(_)
| api::PaymentMethodData::Voucher(_)
| api::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::CardToken(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("fiserv"),
))
}?,
}; };
Ok(Self { Ok(Self {
amount, amount,
@ -306,7 +320,7 @@ impl From<FiservPaymentStatus> for enums::RefundStatus {
| FiservPaymentStatus::Authorized | FiservPaymentStatus::Authorized
| FiservPaymentStatus::Captured => Self::Success, | FiservPaymentStatus::Captured => Self::Success,
FiservPaymentStatus::Declined | FiservPaymentStatus::Failed => Self::Failure, FiservPaymentStatus::Declined | FiservPaymentStatus::Failed => Self::Failure,
_ => Self::Pending, FiservPaymentStatus::Voided | FiservPaymentStatus::Processing => Self::Pending,
} }
} }
} }