mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
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:
@ -164,10 +164,23 @@ fn get_pm_and_subsequent_auth_detail(
|
||||
});
|
||||
Ok((payment_details, processing_options, subseuent_auth_info))
|
||||
}
|
||||
_ => Err(errors::ConnectorError::NotSupported {
|
||||
message: format!("{:?}", item.router_data.request.payment_method_data),
|
||||
connector: "AuthorizeDotNet",
|
||||
})?,
|
||||
api::PaymentMethodData::CardRedirect(_)
|
||||
| api::PaymentMethodData::Wallet(_)
|
||||
| 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 {
|
||||
@ -193,10 +206,20 @@ fn get_pm_and_subsequent_auth_detail(
|
||||
None,
|
||||
None,
|
||||
)),
|
||||
_ => Err(errors::ConnectorError::NotSupported {
|
||||
message: format!("{:?}", item.router_data.request.payment_method_data),
|
||||
connector: "AuthorizeDotNet",
|
||||
})?,
|
||||
api::PaymentMethodData::CardRedirect(_)
|
||||
| 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"),
|
||||
))?,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -289,11 +312,16 @@ pub enum AuthorizationType {
|
||||
Pre,
|
||||
}
|
||||
|
||||
impl From<enums::CaptureMethod> for AuthorizationType {
|
||||
fn from(item: enums::CaptureMethod) -> Self {
|
||||
match item {
|
||||
enums::CaptureMethod::Manual => Self::Pre,
|
||||
_ => Self::Final,
|
||||
impl TryFrom<enums::CaptureMethod> for AuthorizationType {
|
||||
type Error = error_stack::Report<errors::ConnectorError>;
|
||||
|
||||
fn try_from(capture_method: enums::CaptureMethod) -> Result<Self, Self::Error> {
|
||||
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> {
|
||||
let (payment_details, processing_options, subsequent_auth_information) =
|
||||
get_pm_and_subsequent_auth_detail(item)?;
|
||||
let authorization_indicator_type =
|
||||
item.router_data
|
||||
.request
|
||||
.capture_method
|
||||
.map(|c| AuthorizationIndicator {
|
||||
authorization_indicator: c.into(),
|
||||
});
|
||||
let authorization_indicator_type = match item.router_data.request.capture_method {
|
||||
Some(capture_method) => Some(AuthorizationIndicator {
|
||||
authorization_indicator: capture_method.try_into()?,
|
||||
}),
|
||||
None => None,
|
||||
};
|
||||
|
||||
let transaction_request = TransactionRequest {
|
||||
transaction_type: TransactionType::from(item.router_data.request.capture_method),
|
||||
amount: item.amount,
|
||||
@ -904,6 +932,7 @@ pub enum SyncStatus {
|
||||
#[serde(rename = "FDSPendingReview")]
|
||||
FDSPendingReview,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SyncTransactionResponse {
|
||||
@ -938,7 +967,9 @@ impl From<SyncStatus> for enums::AttemptStatus {
|
||||
SyncStatus::Voided => Self::Voided,
|
||||
SyncStatus::CouldNotVoid => Self::VoidFailed,
|
||||
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(),
|
||||
}))
|
||||
}
|
||||
_ => Err(errors::ConnectorError::NotImplemented(
|
||||
"Payment method".to_string(),
|
||||
))?,
|
||||
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::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"),
|
||||
))?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -129,15 +129,53 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BraintreePaymentsRequest {
|
||||
api_models::payments::WalletData::PaypalSdk(wallet_data) => {
|
||||
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(),
|
||||
}))
|
||||
}
|
||||
_ => Err(errors::ConnectorError::NotImplemented(format!(
|
||||
"Current Payment Method - {:?}",
|
||||
item.request.payment_method_data
|
||||
))),
|
||||
api::PaymentMethodData::PayLater(_)
|
||||
| api::PaymentMethodData::BankRedirect(_)
|
||||
| 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 {
|
||||
amount,
|
||||
@ -211,7 +249,9 @@ impl From<BraintreePaymentStatus> for enums::AttemptStatus {
|
||||
| BraintreePaymentStatus::SettlementDeclined => Self::Failure,
|
||||
BraintreePaymentStatus::Authorized => Self::Authorized,
|
||||
BraintreePaymentStatus::Voided => Self::Voided,
|
||||
_ => Self::Pending,
|
||||
BraintreePaymentStatus::SubmittedForSettlement
|
||||
| BraintreePaymentStatus::SettlementPending
|
||||
| BraintreePaymentStatus::SettlementConfirmed => Self::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,9 +182,23 @@ impl TryFrom<&FiservRouterData<&types::PaymentsAuthorizeRouterData>> for FiservP
|
||||
};
|
||||
Source::PaymentCard { card }
|
||||
}
|
||||
_ => Err(errors::ConnectorError::NotImplemented(
|
||||
"Payment Methods".to_string(),
|
||||
))?,
|
||||
api::PaymentMethodData::Wallet(_)
|
||||
| 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 {
|
||||
amount,
|
||||
@ -306,7 +320,7 @@ impl From<FiservPaymentStatus> for enums::RefundStatus {
|
||||
| FiservPaymentStatus::Authorized
|
||||
| FiservPaymentStatus::Captured => Self::Success,
|
||||
FiservPaymentStatus::Declined | FiservPaymentStatus::Failed => Self::Failure,
|
||||
_ => Self::Pending,
|
||||
FiservPaymentStatus::Voided | FiservPaymentStatus::Processing => Self::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user