Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(connector): add MIT category mapping for Checkout.com mandate payments (#11624)
awasthi21cebab222eeee
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 905cbb1c45..1360c5f0e7 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -24160,6 +24160,7 @@},"MitCategory": {"type": "string",+ "description": "Specifies the category of a Merchant Initiated Transaction (MIT). In the case of MIT, `mit_category` tells what kind of MIT is being processed. In the case of CIT, it tells the future intended MIT type.","enum": ["installment","unscheduled",diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 805301df09..1f23a8c1ca 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -1567,7 +1567,7 @@ pub struct PaymentsRequest {#[smithy(value_type = "Option<bool>")]pub is_stored_credential: Option<bool>,- /// The category of the MIT transaction+ /// Specifies the category of a Merchant Initiated Transaction (MIT). In the case of MIT, `mit_category` tells what kind of MIT is being processed. In the case of CIT, it tells the future intended MIT type.#[schema(value_type = Option<MitCategory>, example = "recurring")]#[smithy(value_type = "Option<MitCategory>")]pub mit_category: Option<api_enums::MitCategory>,@@ -1782,19 +1782,6 @@ impl PaymentsRequest {}}- pub fn validate_mit_request(&self) -> common_utils::errors::CustomResult<(), ValidationError> {- if self.mit_category.is_some()- && (!matches!(self.off_session, Some(true)) || self.recurring_details.is_none())- {- return Err(ValidationError::InvalidValue {- message: "`mit_category` requires both: (1) `off_session = true`, and (2) `recurring_details`.".to_string(),- }- .into());- }-- Ok(())- }-pub fn validate_installment_options(&self,) -> common_utils::errors::CustomResult<(), ValidationError> {@@ -7718,7 +7705,7 @@ pub struct PaymentsResponse {#[smithy(value_type = "Option<bool>")]pub is_stored_credential: Option<bool>,- /// The category of the MIT transaction+ /// Specifies the category of a Merchant Initiated Transaction (MIT). In the case of MIT, `mit_category` tells what kind of MIT is being processed. In the case of CIT, it tells the future intended MIT type.#[schema(value_type = Option<MitCategory>, example = "recurring")]#[smithy(value_type = "Option<MitCategory>")]pub mit_category: Option<api_enums::MitCategory>,diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex 21d3a42823..c15524364c 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -10576,6 +10576,7 @@ pub enum TriggeredBy {#[serde(rename_all = "snake_case")]#[strum(serialize_all = "snake_case")]#[smithy(namespace = "com.hyperswitch.smithy.types")]+/// Specifies the category of a Merchant Initiated Transaction (MIT). In the case of MIT, `mit_category` tells what kind of MIT is being processed. In the case of CIT, it tells the future intended MIT type.pub enum MitCategory {/// A fixed purchase amount split into multiple scheduled payments until the total is paid.Installment,diff --git a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rsindex 228f79a832..621312a184 100644--- a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs@@ -555,7 +555,12 @@ impl TryFrom<&CheckoutRouterData<&PaymentsAuthorizeRouterData>> for PaymentsRequ) {CheckoutPaymentType::Moto} else if item.router_data.request.is_mandate_payment() {- CheckoutPaymentType::Unscheduled+ match item.router_data.request.mit_category {+ Some(MitCategory::Installment) => CheckoutPaymentType::Installment,+ Some(MitCategory::Recurring) => CheckoutPaymentType::Recurring,+ Some(MitCategory::Unscheduled) | None => CheckoutPaymentType::Unscheduled,+ _ => CheckoutPaymentType::Unscheduled,+ }} else {CheckoutPaymentType::Regular};diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 864e322c0e..27ba6fd926 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -1151,13 +1151,6 @@ impl<F: Send + Clone + Sync> ValidateRequest<F, api::PaymentsRequest, PaymentDat&request.enable_overcapture,&request.capture_method,)?;- request.validate_mit_request().change_context(- errors::ApiErrorResponse::InvalidRequestData {- message:- "`mit_category` requires both: (1) `off_session = true`, and (2) `recurring_details`."- .to_string(),- },- )?;request.validate_installment_options().map_err(|err| {let message = format!("invalid installment options: {err}");