fix(revenue_recovery): Daily Retry History is being wrongly updated when its an expiry update #10501
+93
−33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
When account updater is done on a particular card token it may result in new token with new details(
New Token) or old token with new details(Expiry Update). The bug is that when we were updating the token in case of Expiry update we were copying the daily retry history of the token and sending it toupsert_payment_processor_tokenfunction that function get the daily retry history with the new token and get the token from redis and update the redis with the same retry histry which results in count to be doubledBefore doing account updater details
Redis -> Token1 ( daily_retry_history : {"02-12-25": 1} )
after getting
updated old token -> upsert_payment_processor_token ( In this we fetch the existing Token1 daily retry history which is this : ( daily_retry_history : {"02-12-25": 1} ) and we will get updated Token1 which will be same : ( daily_retry_history : {"02-12-25": 1} ) The upset function iterates through the daily_retry_history of the updated Old token and make the net daily retry history as ( daily_retry_history : {"02-12-25": 2} ) .
And second bug is that we shouldn't update the
is_hard_declinefield just after the expiry update and give it chance to do one more retry. If the hard decline flag is updated to true just after the expiry update then the token wont be picked up again. So there is no point of account updater and we didn't do any retry with the updated expiry details.Additional Changes
Motivation and Context
How did you test it?
Can follow the steps mentioned in #10112 to test this.
Checklist
cargo +nightly fmt --allcargo clippy