Skip to content

Commit

Permalink
feat(connector): [Nexixpay] add mandates flow for cards (#6259)
Browse files Browse the repository at this point in the history
Co-authored-by: Mrudul Vajpayee <[email protected]>
  • Loading branch information
mrudulvajpayee4935 and Mrudul Vajpayee authored Dec 5, 2024
1 parent c2646d7 commit 62521f3
Show file tree
Hide file tree
Showing 5 changed files with 974 additions and 143 deletions.
21 changes: 18 additions & 3 deletions crates/hyperswitch_connectors/src/connectors/nexixpay.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod transformers;
use std::collections::HashSet;

use common_enums::enums;
use common_utils::{
Expand All @@ -9,6 +10,7 @@ use common_utils::{
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData,
router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::{
access_token_auth::AccessTokenAuth,
Expand Down Expand Up @@ -46,7 +48,7 @@ use uuid::Uuid;
use crate::{
constants::headers,
types::ResponseRouterData,
utils::{self, RefundsRequestData},
utils::{self, PaymentMethodDataType, RefundsRequestData},
};

#[derive(Clone)]
Expand Down Expand Up @@ -212,6 +214,15 @@ impl ConnectorValidation for Nexixpay {
),
}
}
fn validate_mandate_payment(
&self,
pm_type: Option<enums::PaymentMethodType>,
pm_data: PaymentMethodData,
) -> CustomResult<(), errors::ConnectorError> {
let mandate_supported_pmd: HashSet<PaymentMethodDataType> =
HashSet::from([PaymentMethodDataType::Card]);
utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id())
}
}

impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Nexixpay {}
Expand Down Expand Up @@ -415,10 +426,14 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData

fn get_url(
&self,
_req: &PaymentsAuthorizeRouterData,
req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!("{}/orders/3steps/init", self.base_url(connectors)))
if req.request.off_session == Some(true) {
Ok(format!("{}/orders/mit", self.base_url(connectors)))
} else {
Ok(format!("{}/orders/3steps/init", self.base_url(connectors)))
}
}

fn get_request_body(
Expand Down
Loading

0 comments on commit 62521f3

Please sign in to comment.