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(payments): Add feature_metadata in the payments response for v2 (#8667)
Amisha Prabhatdcf867d96ed8
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 285a21ba04..7b4f04a229 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -10838,7 +10838,7 @@],"nullable": true},- "payment_revenue_recovery_metadata": {+ "revenue_recovery": {"allOf": [{"$ref": "#/components/schemas/PaymentRevenueRecoveryMetadata"@@ -19319,6 +19319,14 @@"type": "string","description": "Stringified connector raw response body. Only returned if `return_raw_connector_response` is true","nullable": true+ },+ "feature_metadata": {+ "allOf": [+ {+ "$ref": "#/components/schemas/FeatureMetadata"+ }+ ],+ "nullable": true}}},diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex f3d7d9b675..cef094a98d 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -5808,6 +5808,9 @@ pub struct PaymentsResponse {/// Stringified connector raw response body. Only returned if `return_raw_connector_response` is true#[schema(value_type = Option<String>)]pub raw_connector_response: Option<Secret<String>>,++ /// Additional data that might be required by hyperswitch based on the additional features.+ pub feature_metadata: Option<FeatureMetadata>,}#[cfg(feature = "v2")]@@ -7823,13 +7826,13 @@ pub struct FeatureMetadata {/// Recurring payment details required for apple pay Merchant Tokenpub apple_pay_recurring_details: Option<ApplePayRecurringDetails>,/// revenue recovery data for payment intent- pub payment_revenue_recovery_metadata: Option<PaymentRevenueRecoveryMetadata>,+ pub revenue_recovery: Option<PaymentRevenueRecoveryMetadata>,}#[cfg(feature = "v2")]impl FeatureMetadata {pub fn get_retry_count(&self) -> Option<u16> {- self.payment_revenue_recovery_metadata+ self.revenue_recovery.as_ref().map(|metadata| metadata.total_retry_count)}@@ -7842,7 +7845,7 @@ impl FeatureMetadata {redirect_response: self.redirect_response,search_tags: self.search_tags,apple_pay_recurring_details: self.apple_pay_recurring_details,- payment_revenue_recovery_metadata: Some(payment_revenue_recovery_metadata),+ revenue_recovery: Some(payment_revenue_recovery_metadata),}}}diff --git a/crates/hyperswitch_domain_models/src/lib.rs b/crates/hyperswitch_domain_models/src/lib.rsindex 35f619334c..fd24c3d9f4 100644--- a/crates/hyperswitch_domain_models/src/lib.rs+++ b/crates/hyperswitch_domain_models/src/lib.rs@@ -145,7 +145,7 @@ impl ApiModelToDieselModelConvertor<ApiFeatureMetadata> for FeatureMetadata {redirect_response,search_tags,apple_pay_recurring_details,- payment_revenue_recovery_metadata,+ revenue_recovery: payment_revenue_recovery_metadata,} = from;Self {@@ -172,8 +172,7 @@ impl ApiModelToDieselModelConvertor<ApiFeatureMetadata> for FeatureMetadata {search_tags,apple_pay_recurring_details: apple_pay_recurring_details.map(|value| value.convert_back()),- payment_revenue_recovery_metadata: payment_revenue_recovery_metadata- .map(|value| value.convert_back()),+ revenue_recovery: payment_revenue_recovery_metadata.map(|value| value.convert_back()),}}}diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 1df3b6ef29..6785e42998 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -1989,6 +1989,7 @@ whereis_iframe_redirection_enabled: None,merchant_reference_id: payment_intent.merchant_reference_id.clone(),raw_connector_response,+ feature_metadata: None,};Ok(services::ApplicationResponse::JsonWithHeaders((@@ -2089,6 +2090,7 @@ whereis_iframe_redirection_enabled: payment_intent.is_iframe_redirection_enabled,merchant_reference_id: payment_intent.merchant_reference_id.clone(),raw_connector_response,+ feature_metadata: None,};Ok(services::ApplicationResponse::JsonWithHeaders((@@ -5215,7 +5217,7 @@ impl ForeignFrom<&diesel_models::types::FeatureMetadata> for api_models::payment.clone().map(api_models::payments::RedirectResponse::foreign_from);Self {- payment_revenue_recovery_metadata: revenue_recovery,+ revenue_recovery,apple_pay_recurring_details: apple_pay_details,redirect_response: redirect_res,search_tags: feature_metadata.search_tags.clone(),