Skip to content

Commit

Permalink
fix: update connector_mandate_id column in generate mandate flow (#2472)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArjunKarthik authored Oct 6, 2023
1 parent f364a06 commit 61288d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crates/router/src/core/mandate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ where
};

let mandate_ids = mandate_reference
.as_ref()
.map(|md| {
Encode::<types::MandateReference>::encode_to_value(&md)
.change_context(
Expand All @@ -226,6 +227,7 @@ where
mandate_ids,
network_txn_id,
get_insensitive_payment_method_data_if_exists(&resp),
mandate_reference,
)? {
let connector = new_mandate_data.connector.clone();
logger::debug!("{:?}", new_mandate_data);
Expand Down
8 changes: 6 additions & 2 deletions crates/router/src/core/payments/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use crate::{
},
storage::{self, enums as storage_enums, ephemeral_key, CustomerUpdate::Update},
transformers::{ForeignFrom, ForeignTryFrom},
ErrorResponse, RouterData,
ErrorResponse, MandateReference, RouterData,
},
utils::{
self,
Expand Down Expand Up @@ -2123,6 +2123,7 @@ pub fn generate_mandate(
connector_mandate_id: Option<pii::SecretSerdeValue>,
network_txn_id: Option<String>,
payment_method_data_option: Option<api_models::payments::PaymentMethodData>,
mandate_reference: Option<MandateReference>,
) -> CustomResult<Option<storage::MandateNew>, errors::ApiErrorResponse> {
match (setup_mandate_details, customer) {
(Some(data), Some(cus)) => {
Expand Down Expand Up @@ -2155,7 +2156,10 @@ pub fn generate_mandate(
pii::SecretSerdeValue::new(
serde_json::to_value(payment_method_data).unwrap_or_default(),
)
}));
}))
.set_connector_mandate_id(
mandate_reference.and_then(|reference| reference.connector_mandate_id),
);

Ok(Some(
match data.mandate_type.get_required_value("mandate_type")? {
Expand Down

0 comments on commit 61288d5

Please sign in to comment.