Skip to content

Commit

Permalink
refactor(connector): [Square] remove default case handling (#2701)
Browse files Browse the repository at this point in the history
Co-authored-by: DEEPANSHU BANSAL <[email protected]>
  • Loading branch information
HeetVekariya and deepanshu-iiitu authored Oct 27, 2023
1 parent 78e5cd0 commit 05100ea
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions crates/router/src/connector/square/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ impl TryFrom<(&types::TokenizationRouterData, BankDebitData)> for SquareTokenReq
"Payment Method".to_string(),
))
.into_report(),
_ => Err(errors::ConnectorError::NotSupported {

BankDebitData::SepaBankDebit { .. }
| BankDebitData::BecsBankDebit { .. }
| BankDebitData::BacsBankDebit { .. } => Err(errors::ConnectorError::NotSupported {
message: format!("{:?}", item.request.payment_method_data),
connector: "Square",
})?,
Expand Down Expand Up @@ -85,7 +88,14 @@ impl TryFrom<(&types::TokenizationRouterData, PayLaterData)> for SquareTokenRequ
errors::ConnectorError::NotImplemented("Payment Method".to_string()),
)
.into_report(),
_ => Err(errors::ConnectorError::NotSupported {

PayLaterData::KlarnaRedirect { .. }
| PayLaterData::KlarnaSdk { .. }
| PayLaterData::AffirmRedirect { .. }
| PayLaterData::PayBrightRedirect { .. }
| PayLaterData::WalleyRedirect { .. }
| PayLaterData::AlmaRedirect { .. }
| PayLaterData::AtomeRedirect { .. } => Err(errors::ConnectorError::NotSupported {
message: format!("{:?}", item.request.payment_method_data),
connector: "Square",
})?,
Expand All @@ -106,7 +116,31 @@ impl TryFrom<(&types::TokenizationRouterData, WalletData)> for SquareTokenReques
"Payment Method".to_string(),
))
.into_report(),
_ => Err(errors::ConnectorError::NotSupported {

WalletData::AliPayQr(_)
| WalletData::AliPayRedirect(_)
| WalletData::AliPayHkRedirect(_)
| WalletData::MomoRedirect(_)
| WalletData::KakaoPayRedirect(_)
| WalletData::GoPayRedirect(_)
| WalletData::GcashRedirect(_)
| WalletData::ApplePayRedirect(_)
| WalletData::ApplePayThirdPartySdk(_)
| WalletData::DanaRedirect {}
| WalletData::GooglePayRedirect(_)
| WalletData::GooglePayThirdPartySdk(_)
| WalletData::MbWayRedirect(_)
| WalletData::MobilePayRedirect(_)
| WalletData::PaypalRedirect(_)
| WalletData::PaypalSdk(_)
| WalletData::SamsungPay(_)
| WalletData::TwintRedirect {}
| WalletData::VippsRedirect {}
| WalletData::TouchNGoRedirect(_)
| WalletData::WeChatPayRedirect(_)
| WalletData::WeChatPayQr(_)
| WalletData::CashappQr(_)
| WalletData::SwishQr(_) => Err(errors::ConnectorError::NotSupported {
message: format!("{:?}", item.request.payment_method_data),
connector: "Square",
})?,
Expand Down Expand Up @@ -295,7 +329,14 @@ impl TryFrom<&types::ConnectorAuthType> for SquareAuthType {
api_key: api_key.to_owned(),
key1: key1.to_owned(),
}),
_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),

types::ConnectorAuthType::HeaderKey { .. }
| types::ConnectorAuthType::SignatureKey { .. }
| types::ConnectorAuthType::MultiAuthKey { .. }
| types::ConnectorAuthType::CurrencyAuthKey { .. }
| types::ConnectorAuthType::NoKey { .. } => {
Err(errors::ConnectorError::FailedToObtainAuthType.into())
}
}
}
}
Expand Down

0 comments on commit 05100ea

Please sign in to comment.