| { |
| "number": 10056, |
| "title": "feat(revenue_recovery): Add token active status filtering and account update history tracking", |
| "description": "## Type of Change\r\n<!-- Put an `x` in the boxes that apply -->\r\n\r\n- [ ] Bugfix\r\n- [x] New feature\r\n- [ ] Enhancement\r\n- [ ] Refactoring\r\n- [ ] Dependency updates\r\n- [ ] Documentation\r\n- [ ] CI/CD\r\n\r\n## Description\r\n<!-- Describe your changes in detail -->\r\nThis 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.\r\n\r\nThe most important changes are:\r\n\r\n**API Model and Data Structure Enhancements:**\r\n* Added `is_active` and `account_update_history` fields to `RevenueRecoveryBackfillRequest` and `ComprehensiveCardData` structs, and introduced a new `AccountUpdateHistoryRecord` struct to represent token update history.\r\n* Updated `PaymentProcessorTokenStatus` in storage models to include `is_active` and `account_update_history` fields, enabling storage of these new attributes.\r\n\r\n**Parsing and Data Processing Logic:**\r\n* 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.\r\n\r\n**Redis Storage and Retrieval Updates:**\r\n* 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.\r\n\r\n**Default and Example Data Adjustments:**\r\n* Updated test and default data creation to initialize the new fields, ensuring backward compatibility and correct behavior in existing flows. \r\n* \r\n### Additional Changes\r\n\r\n- [ ] This PR modifies the API contract\r\n- [ ] This PR modifies the database schema\r\n- [ ] This PR modifies application configuration/environment variables\r\n\r\n<!--\r\nProvide links to the files with corresponding changes.\r\n\r\nFollowing are the paths where you can find config files:\r\n1. `config`\r\n2. `crates/router/src/configs`\r\n3. `loadtest/config`\r\n-->\r\n\r\n\r\n## Motivation and Context\r\n<!--\r\nWhy is this change required? What problem does it solve?\r\nIf it fixes an open issue, please link to the issue here.\r\n\r\nIf you don't have an issue, we'd recommend starting with one first so the PR\r\ncan focus on the implementation (unless it is an obvious bug or documentation fix\r\nthat will have little conversation).\r\n-->\r\n\r\n\r\n## How did you test it?\r\n<!--\r\nDid you write an integration/unit/API test to verify the code changes?\r\nOr did you test this change manually (provide relevant screenshots)?\r\n-->\r\n\r\n1. Populating new fields when token are inserted into the system \r\n```\r\n \"payment_method_data\": {\r\n \"primary_processor_payment_method_token\": \"2711792313070574\",\r\n \"additional_payment_method_info\": {\r\n \"card_exp_month\": \"12\",\r\n \"card_exp_year\": \"25\",\r\n \"last_four_digits\": 1997,\r\n \"card_network\": \"VISA\",\r\n \"card_issuer\": \"Wells Fargo NA\",\r\n \"card_type\": \"credit\"\r\n }\r\n },\r\n```\r\n<img width=\"1728\" height=\"102\" alt=\"image\" src=\"https://github.com/user-attachments/assets/0bb1a644-2c6a-487d-b7c1-7150789b5832\" />\r\n<img width=\"1265\" height=\"98\" alt=\"image\" src=\"https://github.com/user-attachments/assets/9b2d5a84-24c0-4ed0-b620-8eb49c721010\" />\r\n\r\n\r\n\r\n2. Update the fields of this is_active thorugh back fill api \r\n```\r\ncurl --location 'http://localhost:8080/v2/recovery/data-backfill' \\\r\n--header 'Authorization: admin-api-key=****' \\\r\n--header 'x-profile-id: ***** \\\r\n--header 'api-key: ********' \\\r\n--form 'file=@\"file\"'\r\n```\r\nfile content\r\n```\r\n\"customer_id_resp\",\"token\",\"is_active\"\r\n853818,2711792313070574,false\r\n```\r\n<img width=\"714\" height=\"129\" alt=\"image\" src=\"https://github.com/user-attachments/assets/bc9fd02c-ea4b-43cf-9fc4-ebcfae97ea57\" />\r\n<img width=\"1271\" height=\"64\" alt=\"image\" src=\"https://github.com/user-attachments/assets/f3a98961-f094-4653-9f46-92cf4b6e22b1\" />\r\n\r\n3. Filter outing the active tokens \r\nwhen the token is active \r\n<img width=\"1728\" height=\"251\" alt=\"Screenshot 2025-10-30 at 5 47 25\u202fPM\" src=\"https://github.com/user-attachments/assets/70e2c490-7cbe-47e2-83ab-b5fb8770bfb0\" />\r\nwhen the token is in-active \r\n<img width=\"1722\" height=\"191\" alt=\"Screenshot 2025-10-30 at 5 49 07\u202fPM\" src=\"https://github.com/user-attachments/assets/3e8c927b-270b-442e-a766-96a810308fac\" />\r\n\r\n\r\n## Checklist\r\n<!-- Put an `x` in the boxes that apply -->\r\n\r\n- [x] I formatted the code `cargo +nightly fmt --all`\r\n- [x] I addressed lints thrown by `cargo clippy`\r\n- [x] I reviewed the submitted code\r\n- [ ] I added unit tests for my changes where possible\r\n", |
| "author": "sagarnaikjuspay", |
| "created_at": "2025-10-29T18:32:53+00:00", |
| "merged_at": "2025-10-31T09:11:51+00:00", |
| "base_branch": "main", |
| "labels": [], |
| "url": "https://github.com/juspay/hyperswitch/pull/10056", |
| "commits": [ |
| { |
| "sha": "fee7de574012f3935bb32469919567fecdc32496", |
| "message": "chore: filter redis token based on boolean flag", |
| "author": "sagarnaikjuspay", |
| "date": "2025-10-29T16:45:00+00:00", |
| "url": "https://github.com/juspay/hyperswitch/commit/fee7de574012f3935bb32469919567fecdc32496" |
| }, |
| { |
| "sha": "4cc6fb815072f45854eaef5d3ff180c926daec1c", |
| "message": "Merge branch 'main' into filter-out-tokens", |
| "author": "sagarnaikjuspay", |
| "date": "2025-10-29T16:45:17+00:00", |
| "url": "https://github.com/juspay/hyperswitch/commit/4cc6fb815072f45854eaef5d3ff180c926daec1c" |
| }, |
| { |
| "sha": "5987d780af66ba5d599bf1352d26a4b131fbf107", |
| "message": "feat: filter function to filter out the tokens", |
| "author": "sagarnaikjuspay", |
| "date": "2025-10-29T18:26:44+00:00", |
| "url": "https://github.com/juspay/hyperswitch/commit/5987d780af66ba5d599bf1352d26a4b131fbf107" |
| }, |
| { |
| "sha": "31714129f181a9e373f2c04e4d8c7ebe6c656c22", |
| "message": "chore: pr comments changes", |
| "author": "sagarnaikjuspay", |
| "date": "2025-10-30T12:34:59+00:00", |
| "url": "https://github.com/juspay/hyperswitch/commit/31714129f181a9e373f2c04e4d8c7ebe6c656c22" |
| }, |
| { |
| "sha": "d276e3f8cd7cfaa9271cd7132e77f9dd416ed784", |
| "message": "chore: ipml addition", |
| "author": "sagarnaikjuspay", |
| "date": "2025-10-30T15:23:44+00:00", |
| "url": "https://github.com/juspay/hyperswitch/commit/d276e3f8cd7cfaa9271cd7132e77f9dd416ed784" |
| } |
| ] |
| } |