-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix(revenue_recovery): Daily Retry History is being wrongly updated when its an expiry update #10501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NISHANTH1221
wants to merge
16
commits into
main
Choose a base branch
from
account_updater_bugs_resolve
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+66
−33
Open
fix(revenue_recovery): Daily Retry History is being wrongly updated when its an expiry update #10501
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d1dc4cd
introduce a new function to handle the account updater token details
1f8b4fd
bug fixes
092c110
remove print statement
fe8125b
chore: run formatter
hyperswitch-bot[bot] e51787b
Merge branch 'main' into account_updater_bugs_resolve
1d816f4
remove the unnecessary function
030bd18
chore: run formatter
hyperswitch-bot[bot] 38b6f4a
add bool to update function where decision needs to be taken based on…
14dfc88
chore: run formatter
hyperswitch-bot[bot] 346660f
when its an expiry update set the hard decline to false
38a84c3
Donot make changes to the new token when it is in redis
d2ffcc3
formatter runs
c4829c1
Merge branch 'main' into account_updater_bugs_resolve
8c23a3d
clippy fixes
2f1d21a
move the hard_decline_update_flag to out side the function to a variable
61a0e51
formatter run
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -579,6 +579,7 @@ impl RedisTokenManager { | |
| state: &SessionState, | ||
| connector_customer_id: &str, | ||
| token_data: PaymentProcessorTokenStatus, | ||
| is_account_updater: bool, | ||
| ) -> CustomResult<bool, errors::StorageError> { | ||
| let mut token_map = | ||
| Self::get_connector_customer_payment_processor_tokens(state, connector_customer_id) | ||
|
|
@@ -612,9 +613,9 @@ impl RedisTokenManager { | |
| .and_modify(|v| *v += value) | ||
| .or_insert(value); | ||
| } | ||
| existing_token.account_update_history = token_data.account_update_history.clone(); | ||
| existing_token.payment_processor_token_details = | ||
| token_data.payment_processor_token_details.clone(); | ||
| is_account_updater.then(|| existing_token.is_active = token_data.is_active); | ||
|
|
||
| existing_token | ||
| .modified_at | ||
|
|
@@ -634,9 +635,6 @@ impl RedisTokenManager { | |
| existing_token.modified_at = Some(last_external_attempt_at); | ||
| existing_token.error_code = error_code; | ||
| existing_token.is_hard_decline = token_data.is_hard_decline; | ||
| token_data | ||
| .is_active | ||
| .map(|is_active| existing_token.is_active = Some(is_active)); | ||
| }); | ||
| }) | ||
| .or_else(|| { | ||
|
|
@@ -1326,16 +1324,26 @@ impl AccountUpdaterAction { | |
| OffsetDateTime::now_utc().date(), | ||
| OffsetDateTime::now_utc().time(), | ||
| )); | ||
| updated_token.daily_retry_history = HashMap::new(); | ||
|
|
||
| RedisTokenManager::upsert_payment_processor_token( | ||
| state, | ||
| customer_id, | ||
| updated_token, | ||
| true, | ||
| ) | ||
| .await?; | ||
|
|
||
| logger::info!("Successfully deactivated old token."); | ||
|
|
||
| let is_existing_token = | ||
| RedisTokenManager::get_payment_processor_token_using_token_id( | ||
| state, | ||
| customer_id, | ||
| new_token.to_owned().as_str(), | ||
| ) | ||
| .await?; | ||
|
|
||
| let new_token = PaymentProcessorTokenStatus { | ||
| payment_processor_token_details: PaymentProcessorTokenDetails { | ||
| payment_processor_token: new_token.to_owned(), | ||
|
|
@@ -1377,9 +1385,19 @@ impl AccountUpdaterAction { | |
| decision_threshold: None, | ||
| }; | ||
|
|
||
| RedisTokenManager::upsert_payment_processor_token(state, customer_id, new_token) | ||
| /// Check whether we got have the new token in redis or not. If we have it we dont have to anything. If it dosent we have to insert it inton Redis. | ||
| if is_existing_token.is_some() { | ||
| logger::info!("New token already exists. Skipping the insertion into Redis."); | ||
| } else { | ||
| RedisTokenManager::upsert_payment_processor_token( | ||
| state, | ||
| customer_id, | ||
| new_token, | ||
| true, | ||
| ) | ||
| .await?; | ||
| logger::info!("Successfully updated token with new token information.") | ||
| logger::info!("Successfully updated token with new token information."); | ||
|
Comment on lines
+1389
to
+1399
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we write match here |
||
| } | ||
| } | ||
| Self::ExpiryUpdate(updated_mandate_details) => { | ||
| logger::info!("Handling ExpiryUpdate action"); | ||
|
|
@@ -1398,6 +1416,8 @@ impl AccountUpdaterAction { | |
| OffsetDateTime::now_utc().date(), | ||
| OffsetDateTime::now_utc().time(), | ||
| )); | ||
| updated_token.is_active = Some(true); | ||
| updated_token.daily_retry_history = HashMap::new(); | ||
| updated_token | ||
| .account_update_history | ||
| .get_or_insert_with(Vec::new) | ||
|
|
@@ -1426,6 +1446,7 @@ impl AccountUpdaterAction { | |
| state, | ||
| customer_id, | ||
| updated_token, | ||
| true, | ||
| ) | ||
| .await?; | ||
|
|
||
|
|
@@ -1443,4 +1464,8 @@ impl AccountUpdaterAction { | |
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| pub fn is_expiry_update(&self) -> bool { | ||
| matches!(self, Self::ExpiryUpdate(_)) | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add comment here