feat(router): add merchant_id check for manual_retry_allowed flag sent in payments response (#1785)

This commit is contained in:
Sai Harsha Vardhan
2023-07-25 14:42:59 +05:30
committed by GitHub
parent af9a4585b2
commit 435c939576
3 changed files with 22 additions and 4 deletions

View File

@ -19,7 +19,7 @@ use super::{
CustomerDetails, PaymentData,
};
use crate::{
configs::settings::Server,
configs::settings::{ConnectorRequestReferenceIdConfig, Server},
consts,
core::{
errors::{self, CustomResult, RouterResult, StorageErrorExt},
@ -2431,8 +2431,10 @@ impl AttemptType {
pub fn is_manual_retry_allowed(
intent_status: &storage_enums::IntentStatus,
attempt_status: &storage_enums::AttemptStatus,
connector_request_reference_id_config: &ConnectorRequestReferenceIdConfig,
merchant_id: &str,
) -> Option<bool> {
match intent_status {
let is_payment_status_eligible_for_retry = match intent_status {
enums::IntentStatus::Failed => match attempt_status {
enums::AttemptStatus::Started
| enums::AttemptStatus::AuthenticationPending
@ -2472,7 +2474,12 @@ pub fn is_manual_retry_allowed(
| enums::IntentStatus::RequiresMerchantAction
| enums::IntentStatus::RequiresPaymentMethod
| enums::IntentStatus::RequiresConfirmation => None,
}
};
let is_merchant_id_enabled_for_retries = !connector_request_reference_id_config
.merchant_ids_send_payment_id_as_connector_request_id
.contains(merchant_id);
is_payment_status_eligible_for_retry
.map(|payment_status_check| payment_status_check && is_merchant_id_enabled_for_retries)
}
#[cfg(test)]