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(revenue_recovery): set recurring mit category on recovery payment intents (#14995)
balakrishnab3b0ca710dcf
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex c972b1c747..5199f20008 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -20421,6 +20421,16 @@"format": "int64","description": "This Unit struct represents MinorUnit in which core amount works"},+ "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",+ "recurring",+ "resubmission"+ ]+ },"MitExemptionRequest": {"type": "string","enum": [@@ -26229,6 +26239,14 @@"default": false,"example": true,"nullable": true+ },+ "mit_category": {+ "allOf": [+ {+ "$ref": "#/components/schemas/MitCategory"+ }+ ],+ "nullable": true}},"additionalProperties": false@@ -31520,6 +31538,14 @@"default": false,"example": false},+ "mit_category": {+ "allOf": [+ {+ "$ref": "#/components/schemas/MitCategory"+ }+ ],+ "nullable": true+ },"billing": {"allOf": [{diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex aa7bfa102c..1fa2bc47a7 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -389,6 +389,10 @@ pub struct PaymentsCreateIntentRequest {/// Request address verification using the billing address for supported card payments.#[schema(default = false, example = true)]pub enable_avs_check: Option<bool>,++ /// 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")]+ pub mit_category: Option<api_enums::MitCategory>,}#[cfg(feature = "v2")]#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]@@ -8762,6 +8766,7 @@ impl From<&PaymentsRequest> for PaymentsCreateIntentRequest {is_account_funded_transaction: request.is_account_funded_transaction,recipient_details: request.recipient_details.clone(),enable_avs_check: request.enable_avs_check,+ mit_category: None,}}}@@ -14842,6 +14847,11 @@ pub struct RecoveryPaymentsCreate {#[schema(default = false, example = false)]pub customer_present: bool,+ /// Category of the merchant initiated transactions made to recover this invoice. Defaults to+ /// `recurring`.+ #[schema(value_type = Option<MitCategory>, example = "recurring")]+ pub mit_category: Option<api_enums::MitCategory>,+/// The billing details of the transaction.pub billing: Option<Address>,diff --git a/crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs b/crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rsindex 86612477af..93f40c35fd 100644--- a/crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs@@ -1098,6 +1098,8 @@ impl TryFrom<ChargebeeInvoiceBody> for revenue_recovery::RevenueRecoveryInvoiceD// TODO! This field should be handled for billing connnector integrationsenable_partial_authorization: None,customer_present: common_enums::PresenceOfCustomerDuringPayment::Absent,+ // Chargebee invoices come from subscriptions, so recovery retries are sent as recurring merchant initiated transactions+ mit_category: Some(common_enums::MitCategory::Recurring),})}}diff --git a/crates/hyperswitch_connectors/src/connectors/stripebilling/transformers.rs b/crates/hyperswitch_connectors/src/connectors/stripebilling/transformers.rsindex e98a99095a..72a8d3a647 100644--- a/crates/hyperswitch_connectors/src/connectors/stripebilling/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/stripebilling/transformers.rs@@ -430,6 +430,8 @@ impl TryFrom<StripebillingInvoiceBody> for revenue_recovery::RevenueRecoveryInvo// TODO! This field should be handled for billing connnector integrationsenable_partial_authorization: None,customer_present: common_enums::PresenceOfCustomerDuringPayment::Absent,+ // Not set since Stripe Billing recovers only through Stripe, which doesn't use the mit category+ mit_category: None,})}}diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rsindex 11e3ebe7e9..8769e5f9b8 100644--- a/crates/hyperswitch_domain_models/src/payments.rs+++ b/crates/hyperswitch_domain_models/src/payments.rs@@ -1062,6 +1062,8 @@ pub struct PaymentIntent {#[encrypt]pub recipient_details: Option<Encryptable<Secret<Value>>>,pub enable_avs_check: Option<bool>,+ /// Denotes the category of the merchant initiated transactions made on this intent.+ pub mit_category: Option<common_enums::MitCategory>,}#[cfg(feature = "v2")]@@ -1275,6 +1277,7 @@ impl PaymentIntent {is_account_funded_transaction: request.is_account_funded_transaction,recipient_details: decrypted_payment_intent.recipient_details,enable_avs_check: request.enable_avs_check,+ mit_category: request.mit_category,})}diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rsindex a2155691d0..ba9ae39b23 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs@@ -2299,6 +2299,7 @@ impl behaviour::Conversion for PaymentIntent {is_account_funded_transaction,recipient_details,enable_avs_check,+ mit_category,} = self;Ok(DieselPaymentIntent {skip_external_tax_calculation: Some(amount_details.get_external_tax_action_as_bool()),@@ -2404,7 +2405,7 @@ impl behaviour::Conversion for PaymentIntent {order_date: None,enable_partial_authorization: Some(enable_partial_authorization),enable_overcapture: None,- mit_category: None,+ mit_category,billing_descriptor: None,tokenization: None,partner_merchant_identifier_details: None,@@ -2576,6 +2577,7 @@ impl behaviour::Conversion for PaymentIntent {is_account_funded_transaction: storage_model.is_account_funded_transaction,recipient_details: data.recipient_details,enable_avs_check: storage_model.enable_avs_check,+ mit_category: storage_model.mit_category,})}.await@@ -2677,7 +2679,7 @@ impl behaviour::Conversion for PaymentIntent {payment_channel: None,tax_status: None,discount_amount: None,- mit_category: None,+ mit_category: self.mit_category,shipping_amount_tax: None,duty_amount: None,order_date: None,diff --git a/crates/hyperswitch_domain_models/src/revenue_recovery.rs b/crates/hyperswitch_domain_models/src/revenue_recovery.rsindex 016e234631..c3652647fd 100644--- a/crates/hyperswitch_domain_models/src/revenue_recovery.rs+++ b/crates/hyperswitch_domain_models/src/revenue_recovery.rs@@ -94,6 +94,8 @@ pub struct RevenueRecoveryInvoiceData {/// Whether the customer was present during the payment. Billing connectors only report/// merchant initiated transactions, so they always set this to absent.pub customer_present: common_enums::PresenceOfCustomerDuringPayment,+ /// Category of the merchant initiated transactions made to recover this invoice.+ pub mit_category: Option<common_enums::MitCategory>,}#[derive(Clone, Debug)]@@ -187,6 +189,7 @@ impl From<&RevenueRecoveryInvoiceData> for api_payments::PaymentsCreateIntentReqis_account_funded_transaction: None,recipient_details: None,enable_avs_check: None,+ mit_category: data.mit_category,}}}@@ -205,6 +208,7 @@ impl From<&BillingConnectorInvoiceSyncResponse> for RevenueRecoveryInvoiceData {metadata: None,enable_partial_authorization: None,customer_present: common_enums::PresenceOfCustomerDuringPayment::Absent,+ mit_category: None,}}}diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex bf1c3a49e4..341f9e2c6a 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -857,6 +857,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::enums::TransactionType,api_models::enums::PresenceOfCustomerDuringPayment,api_models::enums::MitExemptionRequest,+ api_models::enums::MitCategory,api_models::enums::EnablePaymentLinkRequest,api_models::enums::RequestIncrementalAuthorization,api_models::enums::SplitTxnsEnabled,diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 242158f2f3..5ff135b253 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -519,7 +519,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>(connector_testing_data: None,order_id: None,locale: None,- mit_category: None,+ mit_category: payment_data.payment_intent.mit_category,tokenization: None,payment_channel: None,enable_partial_authorization: Some(diff --git a/crates/router/src/core/revenue_recovery/transformers.rs b/crates/router/src/core/revenue_recovery/transformers.rsindex 07eaa1ec7d..7eae09a121 100644--- a/crates/router/src/core/revenue_recovery/transformers.rs+++ b/crates/router/src/core/revenue_recovery/transformers.rs@@ -64,6 +64,11 @@ impl ForeignFrom<api_models::payments::RecoveryPaymentsCreate>} else {common_enums::PresenceOfCustomerDuringPayment::Absent},+ // Defaults to recurring since recovery retries are merchant initiated transactions on a saved card for a recurring invoice+ mit_category: Some(+ data.mit_category+ .unwrap_or(common_enums::MitCategory::Recurring),+ ),}}}diff --git a/crates/router/src/services/kafka/payment_intent.rs b/crates/router/src/services/kafka/payment_intent.rsindex cd20f055aa..0c837bb677 100644--- a/crates/router/src/services/kafka/payment_intent.rs+++ b/crates/router/src/services/kafka/payment_intent.rs@@ -256,6 +256,7 @@ impl<'a> KafkaPaymentIntent<'a> {is_account_funded_transaction: _,recipient_details: _,enable_avs_check: _,+ mit_category: _,} = intent;let revenue_recovery_algorithm_type = feature_metadatadiff --git a/crates/router/src/services/kafka/payment_intent_event.rs b/crates/router/src/services/kafka/payment_intent_event.rsindex 568a8292f4..ce5b964978 100644--- a/crates/router/src/services/kafka/payment_intent_event.rs+++ b/crates/router/src/services/kafka/payment_intent_event.rs@@ -270,6 +270,7 @@ impl<'a> KafkaPaymentIntentEvent<'a> {is_account_funded_transaction: _,recipient_details: _,enable_avs_check: _,+ mit_category: _,} = intent;let revenue_recovery_algorithm_type = feature_metadata