From af3b9e90dbc733b436f84e47ebd62ef0b467c39c Mon Sep 17 00:00:00 2001 From: AkshayaFoiger <131388445+AkshayaFoiger@users.noreply.github.com> Date: Tue, 26 Sep 2023 20:08:34 +0530 Subject: [PATCH] chore(config): [Multisafepay] Add configs for card mandates for Multisafepay (#2372) --- .../connector/multisafepay/transformers.rs | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/crates/router/src/connector/multisafepay/transformers.rs b/crates/router/src/connector/multisafepay/transformers.rs index 8e3e17533dfd..2fa8a4c90300 100644 --- a/crates/router/src/connector/multisafepay/transformers.rs +++ b/crates/router/src/connector/multisafepay/transformers.rs @@ -198,7 +198,7 @@ pub struct ShoppingCart { pub struct MultisafepayPaymentsRequest { #[serde(rename = "type")] pub payment_type: Type, - pub gateway: Gateway, + pub gateway: Option, pub order_id: String, pub currency: String, pub amount: i64, @@ -210,7 +210,7 @@ pub struct MultisafepayPaymentsRequest { pub checkout_options: Option, pub shopping_cart: Option, pub items: Option, - pub recurring_model: Option, + pub recurring_model: Option, pub recurring_id: Option, pub capture: Option, pub days_active: Option, @@ -243,6 +243,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { let payment_type = match item.request.payment_method_data { api::PaymentMethodData::Card(ref _ccard) => Type::Direct, + api::PaymentMethodData::MandatePayment => Type::Direct, api::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data { api::WalletData::GooglePay(_) => Type::Direct, api::WalletData::PaypalRedirect(_) => Type::Redirect, @@ -255,20 +256,23 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques }; let gateway = match item.request.payment_method_data { - api::PaymentMethodData::Card(ref ccard) => Gateway::try_from(ccard.get_card_issuer()?)?, - api::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data { + api::PaymentMethodData::Card(ref ccard) => { + Some(Gateway::try_from(ccard.get_card_issuer()?)?) + } + api::PaymentMethodData::Wallet(ref wallet_data) => Some(match wallet_data { api::WalletData::GooglePay(_) => Gateway::Googlepay, api::WalletData::PaypalRedirect(_) => Gateway::Paypal, _ => Err(errors::ConnectorError::NotImplemented( "Payment method".to_string(), ))?, - }, + }), api::PaymentMethodData::PayLater( api_models::payments::PayLaterData::KlarnaRedirect { billing_email: _, billing_country: _, }, - ) => Gateway::Klarna, + ) => Some(Gateway::Klarna), + api::PaymentMethodData::MandatePayment => None, _ => Err(errors::ConnectorError::NotImplemented( "Payment method".to_string(), ))?, @@ -305,7 +309,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques email: item.request.email.clone(), user_agent: None, referrer: None, - reference: None, + reference: Some(item.connector_request_reference_id.clone()), }; let billing_address = item @@ -367,6 +371,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques }), })) } + api::PaymentMethodData::MandatePayment => None, _ => Err(errors::ConnectorError::NotImplemented( "Payment method".to_string(), ))?, @@ -387,10 +392,8 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques shopping_cart: None, capture: None, items: None, - recurring_model: if item.request.setup_future_usage - == Some(enums::FutureUsage::OffSession) - { - Some("Unscheduled".to_string()) + recurring_model: if item.request.is_mandate_payment() { + Some(MandateType::Unscheduled) } else { None }, @@ -441,6 +444,12 @@ pub enum MultisafepayPaymentStatus { Void, } +#[derive(Debug, Clone, Eq, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "lowercase")] +pub enum MandateType { + Unscheduled, +} + impl From for enums::AttemptStatus { fn from(item: MultisafepayPaymentStatus) -> Self { match item {