Skip to content

feat(revenue_recovery): Add token active status filtering and account update history tracking#10056

Merged
Gnanasundari24 merged 5 commits intomainfrom
filter-out-tokens
Oct 31, 2025
Merged

feat(revenue_recovery): Add token active status filtering and account update history tracking#10056
Gnanasundari24 merged 5 commits intomainfrom
filter-out-tokens

Conversation

@sagarnaikjuspay
Copy link
Contributor

@sagarnaikjuspay sagarnaikjuspay commented Oct 29, 2025

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

This pull request introduces support for the active status and update history of payment processor tokens in the revenue recovery flow to deactive a token and update the history of the particular token . It adds new fields and parsing logic to handle these attributes.

The most important changes are:

API Model and Data Structure Enhancements:

  • Added is_active and account_update_history fields to RevenueRecoveryBackfillRequest and ComprehensiveCardData structs, and introduced a new AccountUpdateHistoryRecord struct to represent token update history.
  • Updated PaymentProcessorTokenStatus in storage models to include is_active and account_update_history fields, enabling storage of these new attributes.

Parsing and Data Processing Logic:

  • Implemented parse_is_active and parse_account_update_history helper functions to extract and validate these fields from incoming data, and integrated them into resid update through csv function.

Redis Storage and Retrieval Updates:

  • Modified RedisTokenManager methods to store and retrieve the new fields, including logic to filter tokens by their active status and to persist update history. Added a new method to optionally include inactive tokens in retrievals.

Default and Example Data Adjustments:

  • Updated test and default data creation to initialize the new fields, ensuring backward compatibility and correct behavior in existing flows.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

  1. Populating new fields when token are inserted into the system
    "payment_method_data": {
        "primary_processor_payment_method_token": "2711792313070574",
        "additional_payment_method_info": {
            "card_exp_month": "12",
            "card_exp_year": "25",
            "last_four_digits": 1997,
            "card_network": "VISA",
            "card_issuer": "Wells Fargo NA",
            "card_type": "credit"
        }
    },
image image
  1. Update the fields of this is_active thorugh back fill api
curl --location 'http://localhost:8080/v2/recovery/data-backfill' \
--header 'Authorization: admin-api-key=****' \
--header 'x-profile-id: ***** \
--header 'api-key: ********' \
--form 'file=@"file"'

file content

"customer_id_resp","token","is_active"
853818,2711792313070574,false
image image
  1. Filter outing the active tokens
    when the token is active
Screenshot 2025-10-30 at 5 47 25 PM when the token is in-active Screenshot 2025-10-30 at 5 49 07 PM

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

@sagarnaikjuspay sagarnaikjuspay self-assigned this Oct 29, 2025
@sagarnaikjuspay sagarnaikjuspay requested a review from a team as a code owner October 29, 2025 18:32
@sagarnaikjuspay sagarnaikjuspay added the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Oct 29, 2025
@sagarnaikjuspay sagarnaikjuspay requested a review from a team as a code owner October 29, 2025 18:32
@semanticdiff-com
Copy link

semanticdiff-com bot commented Oct 29, 2025

@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

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

Files with missing lines Patch % Lines
.../types/storage/revenue_recovery_redis_operation.rs 0.00% 13 Missing ⚠️
...s/api_models/src/revenue_recovery_data_backfill.rs 0.00% 12 Missing ⚠️
crates/router/src/workflows/revenue_recovery.rs 0.00% 5 Missing ⚠️
.../router/src/core/revenue_recovery_data_backfill.rs 0.00% 4 Missing ⚠️
...ates/router/src/core/webhooks/recovery_incoming.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10056   +/-   ##
=======================================
  Coverage        ?    3.91%           
=======================================
  Files           ?     1223           
  Lines           ?   301687           
  Branches        ?        0           
=======================================
  Hits            ?    11803           
  Misses          ?   289884           
  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.

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Oct 31, 2025
Merged via the queue into main with commit 8043027 Oct 31, 2025
25 of 27 checks passed
@Gnanasundari24 Gnanasundari24 deleted the filter-out-tokens branch October 31, 2025 09:11
@hyperswitch-bot hyperswitch-bot bot removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Nov 9, 2025
aadityaguptaa pushed a commit that referenced this pull request Nov 10, 2025
… update history tracking (#10056)

Co-authored-by: sagarnaikjuspay <sagar.naik@juspay.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] filter out no active tokens in the calculate flow and ability to update is_active and account_update_history through api

6 participants