mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 21:07:58 +08:00
chore(config): [Multisafepay] Add configs for card mandates for Multisafepay (#2372)
This commit is contained in:
@ -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,
|
||||
@ -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>,
|
||||
@ -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,
|
||||
@ -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<MultisafepayPaymentStatus> for enums::AttemptStatus {
|
||||
fn from(item: MultisafepayPaymentStatus) -> Self {
|
||||
match item {
|
||||
|
||||
Reference in New Issue
Block a user