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(payments): handle reward surcharge lookup (#13120)

Hrithikeshe3875de47d4e
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 0f081f40da..828596840f 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -2419,9 +2419,15 @@ where
D: OperationSessionGetters<F>,
{
logger::debug!("payment_intent.surcharge_applicable = true");
+ let payment_method_type_option = payment_data.get_payment_attempt().payment_method_type;
let raw_card_key = payment_data
.get_payment_method_data()
- .and_then(helpers::get_key_params_for_surcharge_details)
+ .and_then(|payment_method_data| {
+ helpers::get_key_params_for_surcharge_details(
+ payment_method_data,
+ payment_method_type_option,
+ )
+ })
.map(|(payment_method, payment_method_type, card_network)| {
types::SurchargeKey::PaymentMethodData(
payment_method,
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index da6fc2caee..2c5b71d67e 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -7790,6 +7790,7 @@ pub struct JwsBody {
pub fn get_key_params_for_surcharge_details(
payment_method_data: &domain::PaymentMethodData,
+ payment_method_type_option: Option<common_enums::PaymentMethodType>,
) -> Option<(
common_enums::PaymentMethod,
common_enums::PaymentMethodType,
@@ -7856,7 +7857,15 @@ pub fn get_key_params_for_surcharge_details(
None,
)),
domain::PaymentMethodData::MandatePayment => None,
- domain::PaymentMethodData::Reward => None,
+ domain::PaymentMethodData::Reward => {
+ payment_method_type_option.map(|payment_method_type| {
+ (
+ common_enums::PaymentMethod::Reward,
+ payment_method_type,
+ None,
+ )
+ })
+ }
domain::PaymentMethodData::RealTimePayment(real_time_payment) => Some((
common_enums::PaymentMethod::RealTimePayment,
real_time_payment.get_payment_method_type(),