Skip to content

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

fix(webhooks): include setup payment ID in outgoing mandate bodies (#14875)

Aniket Burmanc380760bc93f
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index fc61c33107..6a43b297eb 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -27809,6 +27809,11 @@
"type": "string",
"description": "The identifier for mandate"
},
+ "payment_id": {
+ "type": "string",
+ "description": "The original setup payment associated with this mandate, when known.",
+ "nullable": true
+ },
"status": {
"$ref": "#/components/schemas/MandateStatus"
},
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index c235173218..146b1888cb 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -18763,6 +18763,11 @@
"type": "string",
"description": "The identifier for mandate"
},
+ "payment_id": {
+ "type": "string",
+ "description": "The original setup payment associated with this mandate, when known.",
+ "nullable": true
+ },
"status": {
"$ref": "#/components/schemas/MandateStatus"
},
diff --git a/crates/api_models/src/mandates.rs b/crates/api_models/src/mandates.rs
index 79464a9986..1b0ac0a4fc 100644
--- a/crates/api_models/src/mandates.rs
+++ b/crates/api_models/src/mandates.rs
@@ -38,6 +38,11 @@ pub struct MandateResponse {
/// The identifier for mandate
#[smithy(value_type = "String")]
pub mandate_id: String,
+ /// The original setup payment associated with this mandate, when known.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[schema(value_type = Option<String>)]
+ #[smithy(value_type = "Option<String>")]
+ pub payment_id: Option<common_utils::id_type::PaymentId>,
/// The status for mandates
#[schema(value_type = MandateStatus)]
#[smithy(value_type = "MandateStatus")]
diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rs
index 0c9696cdec..6a2ac33be0 100644
--- a/crates/router/src/core/webhooks/incoming.rs
+++ b/crates/router/src/core/webhooks/incoming.rs
@@ -2611,6 +2611,7 @@ async fn update_payment_method_mandate_status(
.await?;
let mandate_response = api::mandates::MandateResponse {
mandate_id: connector_mandate_id.clone(),
+ payment_id: Some(payment_id.clone()),
status: mandate_status,
payment_method_id: payment_method_id.to_string(),
payment_method: payment_method_name,
diff --git a/crates/router/src/types/api/mandates.rs b/crates/router/src/types/api/mandates.rs
index 624bf75104..c2b3c56a88 100644
--- a/crates/router/src/types/api/mandates.rs
+++ b/crates/router/src/types/api/mandates.rs
@@ -109,6 +109,7 @@ impl MandateResponseExt for MandateResponse {
let user_agent = mandate.get_user_agent_extended().unwrap_or_default();
Ok(Self {
mandate_id: mandate.mandate_id,
+ payment_id: mandate.original_payment_id,
customer_acceptance: Some(api::payments::CustomerAcceptance {
acceptance_type: if mandate.customer_ip_address.is_some() {
api::payments::AcceptanceType::Online