Skip to content

Commit

Permalink
refactor: use original connector mandate reference ID in case PSync d…
Browse files Browse the repository at this point in the history
…oes not return back the mandate details
  • Loading branch information
kashif-m committed Nov 7, 2024
1 parent 394d075 commit 2470e84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2364,7 +2364,7 @@ fn update_connector_mandate_details_for_the_flow<F: Clone>(
))
}
} else {
None
original_connector_mandate_reference_id
};

payment_data.payment_attempt.connector_mandate_detail = connector_mandate_reference_id
Expand Down
31 changes: 8 additions & 23 deletions crates/router/src/core/payments/operations/payment_status.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::marker::PhantomData;

use api_models::{enums::FrmSuggestion, payments::MandateReferenceId};
use api_models::enums::FrmSuggestion;
use async_trait::async_trait;
use common_utils::{ext_traits::AsyncExt, types::keymanager::KeyManagerState};
use error_stack::ResultExt;
Expand All @@ -21,7 +21,6 @@ use crate::{
types::{
api, domain,
storage::{self, enums},
transformers::ForeignFrom,
},
utils::OptionExt,
};
Expand Down Expand Up @@ -452,33 +451,19 @@ async fn get_tracker_for_sync<
}).await
.transpose()?;

let mandate_reference_id =
payment_attempt
.connector_mandate_detail
.as_ref()
.map(|connector_mandate_detail| {
MandateReferenceId::ConnectorMandateId(ForeignFrom::foreign_from(
connector_mandate_detail.clone(),
))
});
let mandate_ids = match (
payment_attempt.mandate_id.clone(),
mandate_reference_id.as_ref(),
) {
(None, None) => None,
(mandate_id, _) => Some(api_models::payments::MandateIds {
mandate_id,
mandate_reference_id,
}),
};

let payment_data = PaymentData {
flow: PhantomData,
payment_intent,
currency,
amount,
email: None,
mandate_id: mandate_ids,
mandate_id: payment_attempt
.mandate_id
.clone()
.map(|id| api_models::payments::MandateIds {
mandate_id: Some(id),
mandate_reference_id: None,
}),
mandate_connector: None,
setup_mandate: None,
customer_acceptance: None,
Expand Down

0 comments on commit 2470e84

Please sign in to comment.