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

feat(core): add surcharge_percentage in surcharge_details in eligibility response (#14544)

Swangi Kumaria07c63dc1d60
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 499891efcb..71b40641f9 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -48335,6 +48335,12 @@
"type": "number",
"format": "double",
"description": "sum of display_surcharge_amount and display_tax_on_surcharge_amount"
+ },
+ "surcharge_percentage": {
+ "type": "number",
+ "format": "double",
+ "description": "Surcharge percentage returned by the external surcharge connector, if provided.",
+ "nullable": true
}
}
},
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index f17d52e4c1..cc713a35f6 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -34410,6 +34410,12 @@
"type": "number",
"format": "double",
"description": "sum of display_surcharge_amount and display_tax_on_surcharge_amount"
+ },
+ "surcharge_percentage": {
+ "type": "number",
+ "format": "double",
+ "description": "Surcharge percentage returned by the external surcharge connector, if provided.",
+ "nullable": true
}
}
},
diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs
index da97be9232..a6f9bb921b 100644
--- a/crates/api_models/src/payment_methods.rs
+++ b/crates/api_models/src/payment_methods.rs
@@ -2549,6 +2549,8 @@ pub struct SurchargeDetailsResponse {
pub display_tax_on_surcharge_amount: f64,
/// sum of display_surcharge_amount and display_tax_on_surcharge_amount
pub display_total_surcharge_amount: f64,
+ /// Surcharge percentage returned by the external surcharge connector, if provided.
+ pub surcharge_percentage: Option<f64>,
}
#[derive(Clone, Debug, PartialEq, serde::Serialize, ToSchema)]
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 927e02821c..8e33c990eb 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -14666,6 +14666,7 @@ async fn store_external_surcharge_in_redis(
fn build_surcharge_response(
surcharge_amount: MinorUnit,
currency: storage_enums::Currency,
+ surcharge_percentage: Option<f64>,
) -> api_models::payment_methods::SurchargeDetailsResponse {
let surcharge_f64 = currency
.to_currency_base_unit_asf64(surcharge_amount.get_amount_as_i64())
@@ -14676,6 +14677,7 @@ fn build_surcharge_response(
display_surcharge_amount: surcharge_f64,
display_tax_on_surcharge_amount: 0.0,
display_total_surcharge_amount: surcharge_f64,
+ surcharge_percentage,
}
}
@@ -14758,7 +14760,11 @@ async fn calculate_external_surcharge(
.attach_printable(
"eligibility: failed to set external_surcharge_applicable on payment_intent",
)?;
- Some(build_surcharge_response(surcharge_amount, currency))
+ Some(build_surcharge_response(
+ surcharge_amount,
+ currency,
+ surcharge_percentage,
+ ))
}
None => None,
}
diff --git a/crates/router/src/core/payments/types.rs b/crates/router/src/core/payments/types.rs
index a1f30e9049..a45668c614 100644
--- a/crates/router/src/core/payments/types.rs
+++ b/crates/router/src/core/payments/types.rs
@@ -225,6 +225,7 @@ impl ForeignTryFrom<(&SurchargeDetails, &PaymentAttempt)> for SurchargeDetailsRe
display_surcharge_amount,
display_tax_on_surcharge_amount,
display_total_surcharge_amount,
+ surcharge_percentage: None,
})
}
}