Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

refactor(connector): use utility function to raise payment method not implemented errors (#1871)

Swangi Kumari66cd5b2fc9a3
diff --git a/crates/router/src/connector/boku/transformers.rs b/crates/router/src/connector/boku/transformers.rs
index c671560765..6d830f8511 100644
--- a/crates/router/src/connector/boku/transformers.rs
+++ b/crates/router/src/connector/boku/transformers.rs
@@ -6,7 +6,7 @@ use url::Url;
use uuid::Uuid;
use crate::{
- connector::utils::{AddressDetailsData, RouterData},
+ connector::utils::{self, AddressDetailsData, RouterData},
core::errors,
services::{self, RedirectForm},
types::{self, api, storage::enums},
@@ -81,10 +81,23 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BokuPaymentsRequest {
api_models::payments::PaymentMethodData::Wallet(wallet_data) => {
Self::try_from((item, &wallet_data))
}
- _ => Err(errors::ConnectorError::NotSupported {
- message: format!("{:?}", item.request.payment_method_type),
- connector: "Boku",
- })?,
+ api_models::payments::PaymentMethodData::Card(_)
+ | api_models::payments::PaymentMethodData::CardRedirect(_)
+ | api_models::payments::PaymentMethodData::PayLater(_)
+ | api_models::payments::PaymentMethodData::BankRedirect(_)
+ | api_models::payments::PaymentMethodData::BankDebit(_)
+ | api_models::payments::PaymentMethodData::BankTransfer(_)
+ | api_models::payments::PaymentMethodData::Crypto(_)
+ | api_models::payments::PaymentMethodData::MandatePayment
+ | api_models::payments::PaymentMethodData::Reward
+ | api_models::payments::PaymentMethodData::Upi(_)
+ | api_models::payments::PaymentMethodData::Voucher(_)
+ | api_models::payments::PaymentMethodData::GiftCard(_)
+ | api_models::payments::PaymentMethodData::CardToken(_) => {
+ Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("boku"),
+ ))?
+ }
}
}
}
@@ -136,9 +149,31 @@ fn get_wallet_type(wallet_data: &api::WalletData) -> Result<String, errors::Conn
api_models::payments::WalletData::KakaoPayRedirect { .. } => {
Ok(BokuPaymentType::Kakaopay.to_string())
}
- _ => 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::ApplePay(_)
+ | api_models::payments::WalletData::ApplePayRedirect(_)
+ | api_models::payments::WalletData::ApplePayThirdPartySdk(_)
+ | api_models::payments::WalletData::GooglePay(_)
+ | 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::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("boku"),
+ ))
+ }
}
}
diff --git a/crates/router/src/connector/globepay/transformers.rs b/crates/router/src/connector/globepay/transformers.rs
index f6adacb814..a874fc21d2 100644
--- a/crates/router/src/connector/globepay/transformers.rs
+++ b/crates/router/src/connector/globepay/transformers.rs
@@ -3,7 +3,7 @@ use masking::Secret;
use serde::{Deserialize, Serialize};
use crate::{
- connector::utils::RouterData,
+ connector::utils::{self, RouterData},
consts,
core::errors,
types::{self, api, storage::enums},
@@ -31,12 +31,47 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for GlobepayPaymentsRequest {
api::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data {
api::WalletData::AliPayQr(_) => GlobepayChannel::Alipay,
api::WalletData::WeChatPayQr(_) => GlobepayChannel::Wechat,
- _ => Err(errors::ConnectorError::NotImplemented(
- "Payment method".to_string(),
+ api::WalletData::AliPayRedirect(_)
+ | api::WalletData::AliPayHkRedirect(_)
+ | api::WalletData::MomoRedirect(_)
+ | api::WalletData::KakaoPayRedirect(_)
+ | api::WalletData::GoPayRedirect(_)
+ | api::WalletData::GcashRedirect(_)
+ | api::WalletData::ApplePay(_)
+ | api::WalletData::ApplePayRedirect(_)
+ | api::WalletData::ApplePayThirdPartySdk(_)
+ | api::WalletData::DanaRedirect {}
+ | api::WalletData::GooglePay(_)
+ | api::WalletData::GooglePayRedirect(_)
+ | api::WalletData::GooglePayThirdPartySdk(_)
+ | api::WalletData::MbWayRedirect(_)
+ | api::WalletData::MobilePayRedirect(_)
+ | api::WalletData::PaypalRedirect(_)
+ | api::WalletData::PaypalSdk(_)
+ | api::WalletData::SamsungPay(_)
+ | api::WalletData::TwintRedirect {}
+ | api::WalletData::VippsRedirect {}
+ | api::WalletData::TouchNGoRedirect(_)
+ | api::WalletData::WeChatPayRedirect(_)
+ | api::WalletData::CashappQr(_)
+ | api::WalletData::SwishQr(_) => Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("globepay"),
))?,
},
- _ => Err(errors::ConnectorError::NotImplemented(
- "Payment method".to_string(),
+ api::PaymentMethodData::Card(_)
+ | 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("globepay"),
))?,
};
let description = item.get_description()?;
diff --git a/crates/router/src/connector/iatapay.rs b/crates/router/src/connector/iatapay.rs
index 72d7b70b06..c5ac0f4383 100644
--- a/crates/router/src/connector/iatapay.rs
+++ b/crates/router/src/connector/iatapay.rs
@@ -685,12 +685,18 @@ impl api::IncomingWebhook for Iatapay {
&self,
request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
- let notif: IatapayPaymentsResponse =
- request
- .body
- .parse_struct("IatapayPaymentsResponse")
- .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
+ let notif: iatapay::IatapayWebhookResponse = request
+ .body
+ .parse_struct("IatapayWebhookResponse")
+ .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
- Ok(Box::new(notif))
+ match notif {
+ iatapay::IatapayWebhookResponse::IatapayPaymentWebhookBody(wh_body) => {
+ Ok(Box::new(wh_body))
+ }
+ iatapay::IatapayWebhookResponse::IatapayRefundWebhookBody(refund_wh_body) => {
+ Ok(Box::new(refund_wh_body))
+ }
+ }
}
}
diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rs
index 14b37d1418..4557fda039 100644
--- a/crates/router/src/connector/iatapay/transformers.rs
+++ b/crates/router/src/connector/iatapay/transformers.rs
@@ -265,9 +265,6 @@ pub struct IatapayPaymentsResponse {
pub merchant_payment_id: Option<String>,
pub amount: f64,
pub currency: String,
- pub country: Option<String>,
- pub locale: Option<String>,
- pub bank_transfer_description: Option<String>,
pub checkout_methods: Option<CheckoutMethod>,
pub failure_code: Option<String>,
pub failure_details: Option<String>,
@@ -532,6 +529,9 @@ pub struct IatapayPaymentWebhookBody {
pub merchant_payment_id: Option<String>,
pub failure_code: Option<String>,
pub failure_details: Option<String>,
+ pub amount: f64,
+ pub currency: String,
+ pub checkout_methods: Option<CheckoutMethod>,
}
#[derive(Debug, Serialize, Deserialize)]
@@ -542,9 +542,12 @@ pub struct IatapayRefundWebhookBody {
pub merchant_refund_id: Option<String>,
pub failure_code: Option<String>,
pub failure_details: Option<String>,
+ pub amount: f64,
+ pub currency: String,
}
#[derive(Debug, Serialize, Deserialize)]
+#[serde(untagged)]
pub enum IatapayWebhookResponse {
IatapayPaymentWebhookBody(IatapayPaymentWebhookBody),
IatapayRefundWebhookBody(IatapayRefundWebhookBody),