feat(core): add surcharge support for MIT#12715
Conversation
Changed Files
|
XyneSpaces
left a comment
There was a problem hiding this comment.
Automated Review Summary
PR: feat(core): add surcharge support for MIT
Reviewer: PR Reviewer Agent
Findings
File: crates/router/src/core/payments.rs
calculate_mit_external_surcharge returns Option and logs warnings for all error paths. While the "best-effort" semantics are documented, consider if any failure modes should surface to the caller rather than being silently ignored. For example:
- MCA fetch failure (configuration error that should alert operators)
- UCS timeout (may indicate service degradation)
Current behavior is acceptable for recurring payment UX, but ensure monitoring is in place for surcharge calculation failure rates.
🔍 2. Missing instrumentation on new async functions
Files: crates/router/src/core/payments.rs
The new async functions run_external_surcharge_ucs and calculate_mit_external_surcharge should have #[instrument(skip_all)] attributes for observability, consistent with other payment core functions.
🔍 3. Card IIN extraction fallback chain
File: crates/router/src/core/payments.rs
The fallback from payment_method_data.get_card_iin() to payment_attempt.payment_method_data JSON extraction is reasonable, but document why PSP-tokenized MIT flows don't have a Card variant available. This is subtle behavior that future maintainers may question.
Verdict: ✅ Approve with minor suggestions — Clean refactor with proper best-effort semantics for MIT surcharge. Add instrumentation attributes before merge.
Type of Change
Description
Additional Changes
Motivation and Context
How did you test it?
Checklist
cargo +nightly fmt --allcargo clippy