Skip to content

Commit

Permalink
chore(config): [Multisafepay] Add configs for card mandates for Mult…
Browse files Browse the repository at this point in the history
…isafepay (#2372)
  • Loading branch information
AkshayaFoiger authored Sep 26, 2023
1 parent f47a5d4 commit af3b9e9
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions crates/router/src/connector/multisafepay/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub struct ShoppingCart {
pub struct MultisafepayPaymentsRequest {
#[serde(rename = "type")]
pub payment_type: Type,
pub gateway: Gateway,
pub gateway: Option<Gateway>,
pub order_id: String,
pub currency: String,
pub amount: i64,
Expand All @@ -210,7 +210,7 @@ pub struct MultisafepayPaymentsRequest {
pub checkout_options: Option<CheckoutOptions>,
pub shopping_cart: Option<ShoppingCart>,
pub items: Option<String>,
pub recurring_model: Option<String>,
pub recurring_model: Option<MandateType>,
pub recurring_id: Option<String>,
pub capture: Option<String>,
pub days_active: Option<i32>,
Expand Down Expand Up @@ -243,6 +243,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques
fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
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,
Expand All @@ -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(),
))?,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -367,6 +371,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques
}),
}))
}
api::PaymentMethodData::MandatePayment => None,
_ => Err(errors::ConnectorError::NotImplemented(
"Payment method".to_string(),
))?,
Expand All @@ -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
},
Expand Down Expand Up @@ -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<MultisafepayPaymentStatus> for enums::AttemptStatus {
fn from(item: MultisafepayPaymentStatus) -> Self {
match item {
Expand Down

0 comments on commit af3b9e9

Please sign in to comment.