mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
fix(core): Add column mandate_data for storing the details of a mandate in PaymentAttempt (#3606)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -147,6 +147,7 @@ impl PaymentAttemptInterface for MockDb {
|
||||
merchant_connector_id: payment_attempt.merchant_connector_id,
|
||||
unified_code: payment_attempt.unified_code,
|
||||
unified_message: payment_attempt.unified_message,
|
||||
mandate_data: payment_attempt.mandate_data,
|
||||
};
|
||||
payment_attempts.push(payment_attempt.clone());
|
||||
Ok(payment_attempt)
|
||||
|
||||
@ -2,7 +2,7 @@ use api_models::enums::{AuthenticationType, Connector, PaymentMethod, PaymentMet
|
||||
use common_utils::{errors::CustomResult, fallback_reverse_lookup_not_found};
|
||||
use data_models::{
|
||||
errors,
|
||||
mandates::{MandateAmountData, MandateDataType, MandateDetails, MandateTypeDetails},
|
||||
mandates::{MandateAmountData, MandateDataType, MandateDetails},
|
||||
payments::{
|
||||
payment_attempt::{
|
||||
PaymentAttempt, PaymentAttemptInterface, PaymentAttemptNew, PaymentAttemptUpdate,
|
||||
@ -14,8 +14,7 @@ use data_models::{
|
||||
use diesel_models::{
|
||||
enums::{
|
||||
MandateAmountData as DieselMandateAmountData, MandateDataType as DieselMandateType,
|
||||
MandateDetails as DieselMandateDetails, MandateTypeDetails as DieselMandateTypeOrDetails,
|
||||
MerchantStorageScheme,
|
||||
MandateDetails as DieselMandateDetails, MerchantStorageScheme,
|
||||
},
|
||||
kv,
|
||||
payment_attempt::{
|
||||
@ -391,6 +390,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
|
||||
merchant_connector_id: payment_attempt.merchant_connector_id.clone(),
|
||||
unified_code: payment_attempt.unified_code.clone(),
|
||||
unified_message: payment_attempt.unified_message.clone(),
|
||||
mandate_data: payment_attempt.mandate_data.clone(),
|
||||
};
|
||||
|
||||
let field = format!("pa_{}", created_attempt.attempt_id);
|
||||
@ -1016,42 +1016,11 @@ impl DataModelExt for MandateDetails {
|
||||
fn to_storage_model(self) -> Self::StorageModel {
|
||||
DieselMandateDetails {
|
||||
update_mandate_id: self.update_mandate_id,
|
||||
mandate_type: self
|
||||
.mandate_type
|
||||
.map(|mand_type| mand_type.to_storage_model()),
|
||||
}
|
||||
}
|
||||
fn from_storage_model(storage_model: Self::StorageModel) -> Self {
|
||||
Self {
|
||||
update_mandate_id: storage_model.update_mandate_id,
|
||||
mandate_type: storage_model
|
||||
.mandate_type
|
||||
.map(MandateDataType::from_storage_model),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl DataModelExt for MandateTypeDetails {
|
||||
type StorageModel = DieselMandateTypeOrDetails;
|
||||
|
||||
fn to_storage_model(self) -> Self::StorageModel {
|
||||
match self {
|
||||
Self::MandateType(mandate_type) => {
|
||||
DieselMandateTypeOrDetails::MandateType(mandate_type.to_storage_model())
|
||||
}
|
||||
Self::MandateDetails(mandate_details) => {
|
||||
DieselMandateTypeOrDetails::MandateDetails(mandate_details.to_storage_model())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn from_storage_model(storage_model: Self::StorageModel) -> Self {
|
||||
match storage_model {
|
||||
DieselMandateTypeOrDetails::MandateType(data) => {
|
||||
Self::MandateType(MandateDataType::from_storage_model(data))
|
||||
}
|
||||
DieselMandateTypeOrDetails::MandateDetails(data) => {
|
||||
Self::MandateDetails(MandateDetails::from_storage_model(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1124,7 +1093,7 @@ impl DataModelExt for PaymentAttempt {
|
||||
business_sub_label: self.business_sub_label,
|
||||
straight_through_algorithm: self.straight_through_algorithm,
|
||||
preprocessing_step_id: self.preprocessing_step_id,
|
||||
mandate_details: self.mandate_details.map(|md| md.to_storage_model()),
|
||||
mandate_details: self.mandate_details.map(|d| d.to_storage_model()),
|
||||
error_reason: self.error_reason,
|
||||
multiple_capture_count: self.multiple_capture_count,
|
||||
connector_response_reference_id: self.connector_response_reference_id,
|
||||
@ -1135,6 +1104,7 @@ impl DataModelExt for PaymentAttempt {
|
||||
merchant_connector_id: self.merchant_connector_id,
|
||||
unified_code: self.unified_code,
|
||||
unified_message: self.unified_message,
|
||||
mandate_data: self.mandate_data.map(|d| d.to_storage_model()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1179,7 +1149,7 @@ impl DataModelExt for PaymentAttempt {
|
||||
preprocessing_step_id: storage_model.preprocessing_step_id,
|
||||
mandate_details: storage_model
|
||||
.mandate_details
|
||||
.map(MandateTypeDetails::from_storage_model),
|
||||
.map(MandateDataType::from_storage_model),
|
||||
error_reason: storage_model.error_reason,
|
||||
multiple_capture_count: storage_model.multiple_capture_count,
|
||||
connector_response_reference_id: storage_model.connector_response_reference_id,
|
||||
@ -1190,6 +1160,9 @@ impl DataModelExt for PaymentAttempt {
|
||||
merchant_connector_id: storage_model.merchant_connector_id,
|
||||
unified_code: storage_model.unified_code,
|
||||
unified_message: storage_model.unified_message,
|
||||
mandate_data: storage_model
|
||||
.mandate_data
|
||||
.map(MandateDetails::from_storage_model),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1245,6 +1218,7 @@ impl DataModelExt for PaymentAttemptNew {
|
||||
merchant_connector_id: self.merchant_connector_id,
|
||||
unified_code: self.unified_code,
|
||||
unified_message: self.unified_message,
|
||||
mandate_data: self.mandate_data.map(|d| d.to_storage_model()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1287,7 +1261,7 @@ impl DataModelExt for PaymentAttemptNew {
|
||||
preprocessing_step_id: storage_model.preprocessing_step_id,
|
||||
mandate_details: storage_model
|
||||
.mandate_details
|
||||
.map(MandateTypeDetails::from_storage_model),
|
||||
.map(MandateDataType::from_storage_model),
|
||||
error_reason: storage_model.error_reason,
|
||||
connector_response_reference_id: storage_model.connector_response_reference_id,
|
||||
multiple_capture_count: storage_model.multiple_capture_count,
|
||||
@ -1298,6 +1272,9 @@ impl DataModelExt for PaymentAttemptNew {
|
||||
merchant_connector_id: storage_model.merchant_connector_id,
|
||||
unified_code: storage_model.unified_code,
|
||||
unified_message: storage_model.unified_message,
|
||||
mandate_data: storage_model
|
||||
.mandate_data
|
||||
.map(MandateDetails::from_storage_model),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user