fix: update connector_mandate_id column in generate mandate flow (#2472)

This commit is contained in:
Arjun Karthik
2023-10-06 13:00:48 +05:30
committed by GitHub
parent f364a069b9
commit 61288d541f
2 changed files with 8 additions and 2 deletions

View File

@ -207,6 +207,7 @@ where
}; };
let mandate_ids = mandate_reference let mandate_ids = mandate_reference
.as_ref()
.map(|md| { .map(|md| {
Encode::<types::MandateReference>::encode_to_value(&md) Encode::<types::MandateReference>::encode_to_value(&md)
.change_context( .change_context(
@ -226,6 +227,7 @@ where
mandate_ids, mandate_ids,
network_txn_id, network_txn_id,
get_insensitive_payment_method_data_if_exists(&resp), get_insensitive_payment_method_data_if_exists(&resp),
mandate_reference,
)? { )? {
let connector = new_mandate_data.connector.clone(); let connector = new_mandate_data.connector.clone();
logger::debug!("{:?}", new_mandate_data); logger::debug!("{:?}", new_mandate_data);

View File

@ -50,7 +50,7 @@ use crate::{
}, },
storage::{self, enums as storage_enums, ephemeral_key, CustomerUpdate::Update}, storage::{self, enums as storage_enums, ephemeral_key, CustomerUpdate::Update},
transformers::{ForeignFrom, ForeignTryFrom}, transformers::{ForeignFrom, ForeignTryFrom},
ErrorResponse, RouterData, ErrorResponse, MandateReference, RouterData,
}, },
utils::{ utils::{
self, self,
@ -2123,6 +2123,7 @@ pub fn generate_mandate(
connector_mandate_id: Option<pii::SecretSerdeValue>, connector_mandate_id: Option<pii::SecretSerdeValue>,
network_txn_id: Option<String>, network_txn_id: Option<String>,
payment_method_data_option: Option<api_models::payments::PaymentMethodData>, payment_method_data_option: Option<api_models::payments::PaymentMethodData>,
mandate_reference: Option<MandateReference>,
) -> CustomResult<Option<storage::MandateNew>, errors::ApiErrorResponse> { ) -> CustomResult<Option<storage::MandateNew>, errors::ApiErrorResponse> {
match (setup_mandate_details, customer) { match (setup_mandate_details, customer) {
(Some(data), Some(cus)) => { (Some(data), Some(cus)) => {
@ -2155,7 +2156,10 @@ pub fn generate_mandate(
pii::SecretSerdeValue::new( pii::SecretSerdeValue::new(
serde_json::to_value(payment_method_data).unwrap_or_default(), 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( Ok(Some(
match data.mandate_type.get_required_value("mandate_type")? { match data.mandate_type.get_required_value("mandate_type")? {