Skip to content

Commit

Permalink
refactor(connector): [Square] change error message from NotSupported …
Browse files Browse the repository at this point in the history
…to NotImplemented (#2875)

Co-authored-by: SamraatBansal <[email protected]>
  • Loading branch information
nain-F49FF806 and SamraatBansal authored Feb 27, 2024
1 parent 5b8c261 commit 0626ca9
Showing 1 changed file with 30 additions and 56 deletions.
86 changes: 30 additions & 56 deletions crates/router/src/connector/square/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use masking::{ExposeInterface, PeekInterface, Secret};
use serde::{Deserialize, Serialize};

use crate::{
connector::utils::{CardData, PaymentsAuthorizeRequestData, RouterData},
connector::utils::{self, CardData, PaymentsAuthorizeRequestData, RouterData},
core::errors,
types::{
self, api,
Expand All @@ -17,19 +17,14 @@ impl TryFrom<(&types::TokenizationRouterData, BankDebitData)> for SquareTokenReq
fn try_from(
value: (&types::TokenizationRouterData, BankDebitData),
) -> Result<Self, Self::Error> {
let (item, bank_debit_data) = value;
let (_item, bank_debit_data) = value;
match bank_debit_data {
BankDebitData::AchBankDebit { .. } => Err(errors::ConnectorError::NotImplemented(
"Payment Method".to_string(),
))
.into_report(),

BankDebitData::SepaBankDebit { .. }
BankDebitData::AchBankDebit { .. }
| BankDebitData::SepaBankDebit { .. }
| BankDebitData::BecsBankDebit { .. }
| BankDebitData::BacsBankDebit { .. } => Err(errors::ConnectorError::NotSupported {
message: format!("{:?}", item.request.payment_method_data),
connector: "Square",
})?,
| BankDebitData::BacsBankDebit { .. } => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Square"),
))?,
}
}
}
Expand Down Expand Up @@ -82,42 +77,30 @@ impl TryFrom<(&types::TokenizationRouterData, PayLaterData)> for SquareTokenRequ
fn try_from(
value: (&types::TokenizationRouterData, PayLaterData),
) -> Result<Self, Self::Error> {
let (item, pay_later_data) = value;
let (_item, pay_later_data) = value;
match pay_later_data {
PayLaterData::AfterpayClearpayRedirect { .. } => Err(
errors::ConnectorError::NotImplemented("Payment Method".to_string()),
)
.into_report(),

PayLaterData::KlarnaRedirect { .. }
PayLaterData::AfterpayClearpayRedirect { .. }
| 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",
})?,
| PayLaterData::AtomeRedirect { .. } => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Square"),
))?,
}
}
}

impl TryFrom<(&types::TokenizationRouterData, WalletData)> for SquareTokenRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(value: (&types::TokenizationRouterData, WalletData)) -> Result<Self, Self::Error> {
let (item, wallet_data) = value;
let (_item, wallet_data) = value;
match wallet_data {
WalletData::ApplePay(_) => Err(errors::ConnectorError::NotImplemented(
"Payment Method".to_string(),
))
.into_report(),
WalletData::GooglePay(_) => Err(errors::ConnectorError::NotImplemented(
"Payment Method".to_string(),
))
.into_report(),

WalletData::AliPayQr(_)
WalletData::ApplePay(_)
| WalletData::GooglePay(_)
| WalletData::AliPayQr(_)
| WalletData::AliPayRedirect(_)
| WalletData::AliPayHkRedirect(_)
| WalletData::MomoRedirect(_)
Expand All @@ -140,10 +123,9 @@ impl TryFrom<(&types::TokenizationRouterData, WalletData)> for SquareTokenReques
| WalletData::WeChatPayRedirect(_)
| WalletData::WeChatPayQr(_)
| WalletData::CashappQr(_)
| WalletData::SwishQr(_) => Err(errors::ConnectorError::NotSupported {
message: format!("{:?}", item.request.payment_method_data),
connector: "Square",
})?,
| WalletData::SwishQr(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Square"),
))?,
}
}
}
Expand Down Expand Up @@ -180,22 +162,18 @@ impl TryFrom<&types::TokenizationRouterData> for SquareTokenRequest {
api::PaymentMethodData::PayLater(pay_later_data) => {
Self::try_from((item, pay_later_data))
}
api::PaymentMethodData::GiftCard(_) => Err(errors::ConnectorError::NotImplemented(
"Payment Method".to_string(),
))
.into_report(),
api::PaymentMethodData::BankRedirect(_)
api::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::BankRedirect(_)
| api::PaymentMethodData::BankTransfer(_)
| api::PaymentMethodData::CardRedirect(_)
| api::PaymentMethodData::Crypto(_)
| api::PaymentMethodData::MandatePayment
| api::PaymentMethodData::Reward
| api::PaymentMethodData::Upi(_)
| api::PaymentMethodData::Voucher(_)
| api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotSupported {
message: format!("{:?}", item.request.payment_method_data),
connector: "Square",
})?,
| api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Square"),
))?,
}
}
}
Expand Down Expand Up @@ -297,22 +275,18 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for SquarePaymentsRequest {
api::PaymentMethodData::BankDebit(_)
| api::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::PayLater(_)
| api::PaymentMethodData::Wallet(_) => Err(errors::ConnectorError::NotImplemented(
"Payment Method".to_string(),
))
.into_report(),
api::PaymentMethodData::BankRedirect(_)
| api::PaymentMethodData::Wallet(_)
| api::PaymentMethodData::BankRedirect(_)
| api::PaymentMethodData::BankTransfer(_)
| api::PaymentMethodData::CardRedirect(_)
| api::PaymentMethodData::Crypto(_)
| api::PaymentMethodData::MandatePayment
| api::PaymentMethodData::Reward
| api::PaymentMethodData::Upi(_)
| api::PaymentMethodData::Voucher(_)
| api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotSupported {
message: format!("{:?}", item.request.payment_method_data),
connector: "Square",
})?,
| api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Square"),
))?,
}
}
}
Expand Down

0 comments on commit 0626ca9

Please sign in to comment.