Skip to content

Commit b0c4ee2

Browse files
refactor(connector): [Zen] refactor Zen payment methods not implemented errors (#1955)
1 parent f2df2d6 commit b0c4ee2

File tree

1 file changed

+161
-23
lines changed

1 file changed

+161
-23
lines changed

crates/router/src/connector/zen/transformers.rs

Lines changed: 161 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,12 @@ impl
253253
| api_models::payments::VoucherData::MiniStop { .. }
254254
| api_models::payments::VoucherData::FamilyMart { .. }
255255
| api_models::payments::VoucherData::Seicomart { .. }
256-
| api_models::payments::VoucherData::PayEasy { .. } => Err(
257-
errors::ConnectorError::NotImplemented("payment method".to_string()),
258-
)?,
256+
| api_models::payments::VoucherData::PayEasy { .. } => {
257+
Err(errors::ConnectorError::NotSupported {
258+
message: utils::SELECTED_PAYMENT_METHOD.to_string(),
259+
connector: "Zen",
260+
})?
261+
}
259262
};
260263
Ok(Self::ApiRequest(Box::new(ApiRequest {
261264
merchant_transaction_id: item.connector_request_reference_id.clone(),
@@ -303,8 +306,12 @@ impl
303306
api_models::payments::BankTransferData::Pse { .. } => {
304307
ZenPaymentChannels::PclBoacompraPse
305308
}
309+
api_models::payments::BankTransferData::SepaBankTransfer { .. } => {
310+
Err(errors::ConnectorError::NotImplemented(
311+
utils::get_unimplemented_payment_method_error_message("Zen"),
312+
))?
313+
}
306314
api_models::payments::BankTransferData::AchBankTransfer { .. }
307-
| api_models::payments::BankTransferData::SepaBankTransfer { .. }
308315
| api_models::payments::BankTransferData::BacsBankTransfer { .. }
309316
| api_models::payments::BankTransferData::PermataBankTransfer { .. }
310317
| api_models::payments::BankTransferData::BcaBankTransfer { .. }
@@ -313,9 +320,10 @@ impl
313320
| api_models::payments::BankTransferData::CimbVaBankTransfer { .. }
314321
| api_models::payments::BankTransferData::DanamonVaBankTransfer { .. }
315322
| api_models::payments::BankTransferData::MandiriVaBankTransfer { .. } => {
316-
Err(errors::ConnectorError::NotImplemented(
317-
utils::get_unimplemented_payment_method_error_message("zen"),
318-
))?
323+
Err(errors::ConnectorError::NotSupported {
324+
message: utils::SELECTED_PAYMENT_METHOD.to_string(),
325+
connector: "Zen",
326+
})?
319327
}
320328
};
321329
Ok(Self::ApiRequest(Box::new(ApiRequest {
@@ -442,33 +450,38 @@ impl
442450
.google_pay
443451
.ok_or(errors::ConnectorError::RequestEncodingFailed)?,
444452
),
453+
api_models::payments::WalletData::WeChatPayRedirect(_)
454+
| api_models::payments::WalletData::PaypalRedirect(_)
455+
| api_models::payments::WalletData::ApplePay(_)
456+
| api_models::payments::WalletData::GooglePay(_) => {
457+
Err(errors::ConnectorError::NotImplemented(
458+
utils::get_unimplemented_payment_method_error_message("Zen"),
459+
))?
460+
}
445461
api_models::payments::WalletData::AliPayQr(_)
446462
| api_models::payments::WalletData::AliPayRedirect(_)
447463
| api_models::payments::WalletData::AliPayHkRedirect(_)
448464
| api_models::payments::WalletData::MomoRedirect(_)
449465
| api_models::payments::WalletData::KakaoPayRedirect(_)
450466
| api_models::payments::WalletData::GoPayRedirect(_)
451467
| api_models::payments::WalletData::GcashRedirect(_)
452-
| api_models::payments::WalletData::ApplePay(_)
453468
| api_models::payments::WalletData::ApplePayThirdPartySdk(_)
454469
| api_models::payments::WalletData::DanaRedirect {}
455-
| api_models::payments::WalletData::GooglePay(_)
456470
| api_models::payments::WalletData::GooglePayThirdPartySdk(_)
457471
| api_models::payments::WalletData::MbWayRedirect(_)
458472
| api_models::payments::WalletData::MobilePayRedirect(_)
459-
| api_models::payments::WalletData::PaypalRedirect(_)
460473
| api_models::payments::WalletData::PaypalSdk(_)
461474
| api_models::payments::WalletData::SamsungPay(_)
462475
| api_models::payments::WalletData::TwintRedirect {}
463476
| api_models::payments::WalletData::VippsRedirect {}
464477
| api_models::payments::WalletData::TouchNGoRedirect(_)
465-
| api_models::payments::WalletData::WeChatPayRedirect(_)
466478
| api_models::payments::WalletData::CashappQr(_)
467479
| api_models::payments::WalletData::SwishQr(_)
468480
| api_models::payments::WalletData::WeChatPayQr(_) => {
469-
Err(errors::ConnectorError::NotImplemented(
470-
utils::get_unimplemented_payment_method_error_message("zen"),
471-
))?
481+
Err(errors::ConnectorError::NotSupported {
482+
message: utils::SELECTED_PAYMENT_METHOD.to_string(),
483+
connector: "Zen",
484+
})?
472485
}
473486
};
474487
let terminal_uuid = session_data
@@ -650,18 +663,143 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for ZenPaymentsRequest {
650663
api_models::payments::PaymentMethodData::BankTransfer(bank_transfer_data) => {
651664
Self::try_from((item, bank_transfer_data))
652665
}
653-
api_models::payments::PaymentMethodData::PayLater(_)
654-
| api_models::payments::PaymentMethodData::BankRedirect(_)
655-
| api_models::payments::PaymentMethodData::BankDebit(_)
656-
| api_models::payments::PaymentMethodData::Crypto(_)
666+
api_models::payments::PaymentMethodData::BankRedirect(bank_redirect_data) => {
667+
Self::try_from(bank_redirect_data)
668+
}
669+
api_models::payments::PaymentMethodData::PayLater(paylater_data) => {
670+
Self::try_from(paylater_data)
671+
}
672+
api_models::payments::PaymentMethodData::BankDebit(bank_debit_data) => {
673+
Self::try_from(bank_debit_data)
674+
}
675+
api_models::payments::PaymentMethodData::CardRedirect(car_redirect_data) => {
676+
Self::try_from(car_redirect_data)
677+
}
678+
api_models::payments::PaymentMethodData::GiftCard(gift_card_data) => {
679+
Self::try_from(gift_card_data.as_ref())
680+
}
681+
api_models::payments::PaymentMethodData::Crypto(_)
657682
| api_models::payments::PaymentMethodData::MandatePayment
658683
| api_models::payments::PaymentMethodData::Reward
659-
| api_models::payments::PaymentMethodData::Upi(_)
660-
| api_models::payments::PaymentMethodData::CardRedirect(_)
661-
| api_models::payments::PaymentMethodData::GiftCard(_) => {
684+
| api_models::payments::PaymentMethodData::Upi(_) => {
685+
Err(errors::ConnectorError::NotSupported {
686+
message: utils::SELECTED_PAYMENT_METHOD.to_string(),
687+
connector: "Zen",
688+
})?
689+
}
690+
}
691+
}
692+
}
693+
694+
impl TryFrom<&api_models::payments::BankRedirectData> for ZenPaymentsRequest {
695+
type Error = error_stack::Report<errors::ConnectorError>;
696+
fn try_from(value: &api_models::payments::BankRedirectData) -> Result<Self, Self::Error> {
697+
match value {
698+
api_models::payments::BankRedirectData::Ideal { .. }
699+
| api_models::payments::BankRedirectData::Sofort { .. }
700+
| api_models::payments::BankRedirectData::BancontactCard { .. }
701+
| api_models::payments::BankRedirectData::Blik { .. }
702+
| api_models::payments::BankRedirectData::Trustly { .. } => {
662703
Err(errors::ConnectorError::NotImplemented(
663-
utils::get_unimplemented_payment_method_error_message("zen"),
664-
))?
704+
utils::get_unimplemented_payment_method_error_message("Zen"),
705+
)
706+
.into())
707+
}
708+
api_models::payments::BankRedirectData::Eps { .. }
709+
| api_models::payments::BankRedirectData::Giropay { .. }
710+
| api_models::payments::BankRedirectData::Przelewy24 { .. }
711+
| api_models::payments::BankRedirectData::Bizum {}
712+
| api_models::payments::BankRedirectData::Interac { .. }
713+
| api_models::payments::BankRedirectData::OnlineBankingCzechRepublic { .. }
714+
| api_models::payments::BankRedirectData::OnlineBankingFinland { .. }
715+
| api_models::payments::BankRedirectData::OnlineBankingPoland { .. }
716+
| api_models::payments::BankRedirectData::OnlineBankingSlovakia { .. }
717+
| api_models::payments::BankRedirectData::OpenBankingUk { .. }
718+
| api_models::payments::BankRedirectData::OnlineBankingFpx { .. }
719+
| api_models::payments::BankRedirectData::OnlineBankingThailand { .. } => {
720+
Err(errors::ConnectorError::NotSupported {
721+
message: utils::SELECTED_PAYMENT_METHOD.to_string(),
722+
connector: "Zen",
723+
}
724+
.into())
725+
}
726+
}
727+
}
728+
}
729+
730+
impl TryFrom<&api_models::payments::PayLaterData> for ZenPaymentsRequest {
731+
type Error = error_stack::Report<errors::ConnectorError>;
732+
fn try_from(value: &api_models::payments::PayLaterData) -> Result<Self, Self::Error> {
733+
match value {
734+
api_models::payments::PayLaterData::KlarnaRedirect { .. }
735+
| api_models::payments::PayLaterData::KlarnaSdk { .. }
736+
| api_models::payments::PayLaterData::AffirmRedirect {}
737+
| api_models::payments::PayLaterData::AfterpayClearpayRedirect { .. }
738+
| api_models::payments::PayLaterData::PayBrightRedirect {}
739+
| api_models::payments::PayLaterData::WalleyRedirect {}
740+
| api_models::payments::PayLaterData::AlmaRedirect {}
741+
| api_models::payments::PayLaterData::AtomeRedirect {} => {
742+
Err(errors::ConnectorError::NotSupported {
743+
message: utils::SELECTED_PAYMENT_METHOD.to_string(),
744+
connector: "Zen",
745+
}
746+
.into())
747+
}
748+
}
749+
}
750+
}
751+
752+
impl TryFrom<&api_models::payments::BankDebitData> for ZenPaymentsRequest {
753+
type Error = error_stack::Report<errors::ConnectorError>;
754+
fn try_from(value: &api_models::payments::BankDebitData) -> Result<Self, Self::Error> {
755+
match value {
756+
api_models::payments::BankDebitData::AchBankDebit { .. }
757+
| api_models::payments::BankDebitData::SepaBankDebit { .. }
758+
| api_models::payments::BankDebitData::BecsBankDebit { .. }
759+
| api_models::payments::BankDebitData::BacsBankDebit { .. } => {
760+
Err(errors::ConnectorError::NotSupported {
761+
message: utils::SELECTED_PAYMENT_METHOD.to_string(),
762+
connector: "Zen",
763+
}
764+
.into())
765+
}
766+
}
767+
}
768+
}
769+
770+
impl TryFrom<&api_models::payments::CardRedirectData> for ZenPaymentsRequest {
771+
type Error = error_stack::Report<errors::ConnectorError>;
772+
fn try_from(value: &api_models::payments::CardRedirectData) -> Result<Self, Self::Error> {
773+
match value {
774+
api_models::payments::CardRedirectData::Knet {}
775+
| api_models::payments::CardRedirectData::Benefit {}
776+
| api_models::payments::CardRedirectData::MomoAtm {} => {
777+
Err(errors::ConnectorError::NotSupported {
778+
message: utils::SELECTED_PAYMENT_METHOD.to_string(),
779+
connector: "Zen",
780+
}
781+
.into())
782+
}
783+
}
784+
}
785+
}
786+
787+
impl TryFrom<&api_models::payments::GiftCardData> for ZenPaymentsRequest {
788+
type Error = error_stack::Report<errors::ConnectorError>;
789+
fn try_from(value: &api_models::payments::GiftCardData) -> Result<Self, Self::Error> {
790+
match value {
791+
api_models::payments::GiftCardData::PaySafeCard {} => {
792+
Err(errors::ConnectorError::NotImplemented(
793+
utils::get_unimplemented_payment_method_error_message("Zen"),
794+
)
795+
.into())
796+
}
797+
api_models::payments::GiftCardData::Givex(_) => {
798+
Err(errors::ConnectorError::NotSupported {
799+
message: utils::SELECTED_PAYMENT_METHOD.to_string(),
800+
connector: "Zen",
801+
}
802+
.into())
665803
}
666804
}
667805
}

0 commit comments

Comments
 (0)