WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@VenuMadhav2541
Copy link
Contributor

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Breaking change
  • Refactor

Description

This PR enhances audit trail visibility by adding new API flow types in payment audit trail and improves webhook traceability by including refund identifiers in webhook event tracking. It also strengthens type safety across refund-related flows.

Key Changes

  1. Added new API flow tracking in analytics/audit trail:

    • PaymentMethodsList
    • CustomerPaymentMethodsList
    • PaymentsSessionToken
    • IncomingWebhookReceive
  2. Added refund_id support in webhook audit events:

    • v1: String
    • v2: GlobalRefundId
  3. Webhook handlers (v1 & v2) enriched to include refund_id
    Ensures refund webhook events can be linked to specific refund transactions.

  4. Improved type safety:

    • Updated WebhookResponseTracker::Refund in v2 to use GlobalRefundId
    • Added helper methods to read refund_id consistently across v1/v2 flows

Motivation and Context

Several API flows were previously missing in the audit trail, making debugging and monitoring difficult. Refund webhook events also lacked refund_id, preventing full traceability of refund operations.
This PR introduces the missing audit events and adds refund identifiers to webhook logs to close these gaps.

Use Cases

  • Audit trail now shows payment method–related API calls (PaymentMethodsList, CustomerPaymentMethodsList)
  • PaymentsSessionToken generation is now fully tracked
  • Incoming webhook events include refund_id when applicable
  • Refund-related issues can be traced end-to-end in the audit trail

How did you test it?

  • Verified audit trail entries for new flow types in payment:
Screenshot 2025-12-05 at 2 32 55 PM
  • Verified refund webhook events calling api call for the IncomingWebhookReceive
Screenshot 2025-12-05 at 2 35 51 PM

Impact

  • Improved audit trail completeness for key payment flows
  • Refund webhooks now provide full traceability with refund_id
  • Stronger type guarantees with GlobalRefundId in v2
  • Backward compatible through v1/v2 feature-gating

Checklist

  • I formatted the code (cargo +nightly fmt --all)
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

…tracking and IncomingWebhookReceive flow to refunds analytics filter
@VenuMadhav2541 VenuMadhav2541 self-assigned this Dec 5, 2025
@VenuMadhav2541 VenuMadhav2541 requested a review from a team as a code owner December 5, 2025 09:15
@VenuMadhav2541 VenuMadhav2541 added the C-feature Category: Feature request or enhancement label Dec 5, 2025
@VenuMadhav2541 VenuMadhav2541 requested review from a team as code owners December 5, 2025 09:15
@VenuMadhav2541 VenuMadhav2541 added the enhancement New feature or request label Dec 5, 2025
@semanticdiff-com
Copy link

semanticdiff-com bot commented Dec 5, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/analytics/src/api_event/events.rs  67% smaller
  crates/api_models/src/webhooks.rs  0% smaller
  crates/common_utils/src/events.rs  0% smaller
  crates/router/src/core/webhooks/incoming.rs  0% smaller
  crates/router/src/core/webhooks/incoming_v2.rs  0% smaller

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@a1b0151). Learn more about missing BASE report.

Files with missing lines Patch % Lines
crates/analytics/src/api_event/events.rs 0.00% 9 Missing ⚠️
crates/api_models/src/webhooks.rs 0.00% 5 Missing ⚠️
crates/router/src/core/webhooks/incoming_v2.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10549   +/-   ##
=======================================
  Coverage        ?    6.46%           
=======================================
  Files           ?     1251           
  Lines           ?   311810           
  Branches        ?        0           
=======================================
  Hits            ?    20163           
  Misses          ?   291647           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-feature Category: Feature request or enhancement enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add audit trail tracking for missing API flows and enable refund webhook traceability

2 participants