mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-04 22:19:10 +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 {
 | 
					pub struct MultisafepayPaymentsRequest {
 | 
				
			||||||
    #[serde(rename = "type")]
 | 
					    #[serde(rename = "type")]
 | 
				
			||||||
    pub payment_type: Type,
 | 
					    pub payment_type: Type,
 | 
				
			||||||
    pub gateway: Gateway,
 | 
					    pub gateway: Option<Gateway>,
 | 
				
			||||||
    pub order_id: String,
 | 
					    pub order_id: String,
 | 
				
			||||||
    pub currency: String,
 | 
					    pub currency: String,
 | 
				
			||||||
    pub amount: i64,
 | 
					    pub amount: i64,
 | 
				
			||||||
@ -210,7 +210,7 @@ pub struct MultisafepayPaymentsRequest {
 | 
				
			|||||||
    pub checkout_options: Option<CheckoutOptions>,
 | 
					    pub checkout_options: Option<CheckoutOptions>,
 | 
				
			||||||
    pub shopping_cart: Option<ShoppingCart>,
 | 
					    pub shopping_cart: Option<ShoppingCart>,
 | 
				
			||||||
    pub items: Option<String>,
 | 
					    pub items: Option<String>,
 | 
				
			||||||
    pub recurring_model: Option<String>,
 | 
					    pub recurring_model: Option<MandateType>,
 | 
				
			||||||
    pub recurring_id: Option<String>,
 | 
					    pub recurring_id: Option<String>,
 | 
				
			||||||
    pub capture: Option<String>,
 | 
					    pub capture: Option<String>,
 | 
				
			||||||
    pub days_active: Option<i32>,
 | 
					    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> {
 | 
					    fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
 | 
				
			||||||
        let payment_type = match item.request.payment_method_data {
 | 
					        let payment_type = match item.request.payment_method_data {
 | 
				
			||||||
            api::PaymentMethodData::Card(ref _ccard) => Type::Direct,
 | 
					            api::PaymentMethodData::Card(ref _ccard) => Type::Direct,
 | 
				
			||||||
 | 
					            api::PaymentMethodData::MandatePayment => Type::Direct,
 | 
				
			||||||
            api::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data {
 | 
					            api::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data {
 | 
				
			||||||
                api::WalletData::GooglePay(_) => Type::Direct,
 | 
					                api::WalletData::GooglePay(_) => Type::Direct,
 | 
				
			||||||
                api::WalletData::PaypalRedirect(_) => Type::Redirect,
 | 
					                api::WalletData::PaypalRedirect(_) => Type::Redirect,
 | 
				
			||||||
@ -255,20 +256,23 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques
 | 
				
			|||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let gateway = match item.request.payment_method_data {
 | 
					        let gateway = match item.request.payment_method_data {
 | 
				
			||||||
            api::PaymentMethodData::Card(ref ccard) => Gateway::try_from(ccard.get_card_issuer()?)?,
 | 
					            api::PaymentMethodData::Card(ref ccard) => {
 | 
				
			||||||
            api::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data {
 | 
					                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::GooglePay(_) => Gateway::Googlepay,
 | 
				
			||||||
                api::WalletData::PaypalRedirect(_) => Gateway::Paypal,
 | 
					                api::WalletData::PaypalRedirect(_) => Gateway::Paypal,
 | 
				
			||||||
                _ => Err(errors::ConnectorError::NotImplemented(
 | 
					                _ => Err(errors::ConnectorError::NotImplemented(
 | 
				
			||||||
                    "Payment method".to_string(),
 | 
					                    "Payment method".to_string(),
 | 
				
			||||||
                ))?,
 | 
					                ))?,
 | 
				
			||||||
            },
 | 
					            }),
 | 
				
			||||||
            api::PaymentMethodData::PayLater(
 | 
					            api::PaymentMethodData::PayLater(
 | 
				
			||||||
                api_models::payments::PayLaterData::KlarnaRedirect {
 | 
					                api_models::payments::PayLaterData::KlarnaRedirect {
 | 
				
			||||||
                    billing_email: _,
 | 
					                    billing_email: _,
 | 
				
			||||||
                    billing_country: _,
 | 
					                    billing_country: _,
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            ) => Gateway::Klarna,
 | 
					            ) => Some(Gateway::Klarna),
 | 
				
			||||||
 | 
					            api::PaymentMethodData::MandatePayment => None,
 | 
				
			||||||
            _ => Err(errors::ConnectorError::NotImplemented(
 | 
					            _ => Err(errors::ConnectorError::NotImplemented(
 | 
				
			||||||
                "Payment method".to_string(),
 | 
					                "Payment method".to_string(),
 | 
				
			||||||
            ))?,
 | 
					            ))?,
 | 
				
			||||||
@ -305,7 +309,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques
 | 
				
			|||||||
            email: item.request.email.clone(),
 | 
					            email: item.request.email.clone(),
 | 
				
			||||||
            user_agent: None,
 | 
					            user_agent: None,
 | 
				
			||||||
            referrer: None,
 | 
					            referrer: None,
 | 
				
			||||||
            reference: None,
 | 
					            reference: Some(item.connector_request_reference_id.clone()),
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let billing_address = item
 | 
					        let billing_address = item
 | 
				
			||||||
@ -367,6 +371,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques
 | 
				
			|||||||
                    }),
 | 
					                    }),
 | 
				
			||||||
                }))
 | 
					                }))
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            api::PaymentMethodData::MandatePayment => None,
 | 
				
			||||||
            _ => Err(errors::ConnectorError::NotImplemented(
 | 
					            _ => Err(errors::ConnectorError::NotImplemented(
 | 
				
			||||||
                "Payment method".to_string(),
 | 
					                "Payment method".to_string(),
 | 
				
			||||||
            ))?,
 | 
					            ))?,
 | 
				
			||||||
@ -387,10 +392,8 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MultisafepayPaymentsReques
 | 
				
			|||||||
            shopping_cart: None,
 | 
					            shopping_cart: None,
 | 
				
			||||||
            capture: None,
 | 
					            capture: None,
 | 
				
			||||||
            items: None,
 | 
					            items: None,
 | 
				
			||||||
            recurring_model: if item.request.setup_future_usage
 | 
					            recurring_model: if item.request.is_mandate_payment() {
 | 
				
			||||||
                == Some(enums::FutureUsage::OffSession)
 | 
					                Some(MandateType::Unscheduled)
 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Some("Unscheduled".to_string())
 | 
					 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                None
 | 
					                None
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
@ -441,6 +444,12 @@ pub enum MultisafepayPaymentStatus {
 | 
				
			|||||||
    Void,
 | 
					    Void,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[derive(Debug, Clone, Eq, Serialize, Deserialize, PartialEq)]
 | 
				
			||||||
 | 
					#[serde(rename_all = "lowercase")]
 | 
				
			||||||
 | 
					pub enum MandateType {
 | 
				
			||||||
 | 
					    Unscheduled,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl From<MultisafepayPaymentStatus> for enums::AttemptStatus {
 | 
					impl From<MultisafepayPaymentStatus> for enums::AttemptStatus {
 | 
				
			||||||
    fn from(item: MultisafepayPaymentStatus) -> Self {
 | 
					    fn from(item: MultisafepayPaymentStatus) -> Self {
 | 
				
			||||||
        match item {
 | 
					        match item {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user