feat: add updated_by to tracker tables (#2604)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Kartikeya Hegde
2023-10-17 11:26:56 +00:00
committed by GitHub
parent 274a78343e
commit 6a74e8cba9
46 changed files with 549 additions and 176 deletions

View File

@ -10,10 +10,12 @@ use data_models::{
},
PaymentIntent,
},
MerchantStorageScheme,
};
use diesel_models::{
enums::{MandateAmountData as DieselMandateAmountData, MandateDataType as DieselMandateType},
enums::{
MandateAmountData as DieselMandateAmountData, MandateDataType as DieselMandateType,
MerchantStorageScheme,
},
kv,
payment_attempt::{
PaymentAttempt as DieselPaymentAttempt, PaymentAttemptNew as DieselPaymentAttemptNew,
@ -359,6 +361,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
connector_response_reference_id: None,
amount_capturable: payment_attempt.amount_capturable,
surcharge_metadata: payment_attempt.surcharge_metadata.clone(),
updated_by: storage_scheme.to_string(),
};
let field = format!("pa_{}", created_attempt.attempt_id);
@ -399,6 +402,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
pk_id: key,
sk_id: field,
source: "payment_attempt".to_string(),
updated_by: storage_scheme.to_string(),
};
self.insert_reverse_lookup(reverse_lookup, storage_scheme)
.await?;
@ -953,6 +957,7 @@ impl DataModelExt for PaymentAttempt {
connector_response_reference_id: self.connector_response_reference_id,
amount_capturable: self.amount_capturable,
surcharge_metadata: self.surcharge_metadata,
updated_by: self.updated_by,
}
}
@ -1002,6 +1007,7 @@ impl DataModelExt for PaymentAttempt {
connector_response_reference_id: storage_model.connector_response_reference_id,
amount_capturable: storage_model.amount_capturable,
surcharge_metadata: storage_model.surcharge_metadata,
updated_by: storage_model.updated_by,
}
}
}
@ -1051,6 +1057,7 @@ impl DataModelExt for PaymentAttemptNew {
multiple_capture_count: self.multiple_capture_count,
amount_capturable: self.amount_capturable,
surcharge_metadata: self.surcharge_metadata,
updated_by: self.updated_by,
}
}
@ -1098,6 +1105,7 @@ impl DataModelExt for PaymentAttemptNew {
multiple_capture_count: storage_model.multiple_capture_count,
amount_capturable: storage_model.amount_capturable,
surcharge_metadata: storage_model.surcharge_metadata,
updated_by: storage_model.updated_by,
}
}
}
@ -1120,6 +1128,7 @@ impl DataModelExt for PaymentAttemptUpdate {
business_sub_label,
amount_to_capture,
capture_method,
updated_by,
} => DieselPaymentAttemptUpdate::Update {
amount,
currency,
@ -1133,22 +1142,27 @@ impl DataModelExt for PaymentAttemptUpdate {
business_sub_label,
amount_to_capture,
capture_method,
updated_by,
},
Self::UpdateTrackers {
payment_token,
connector,
straight_through_algorithm,
amount_capturable,
updated_by,
} => DieselPaymentAttemptUpdate::UpdateTrackers {
payment_token,
connector,
straight_through_algorithm,
amount_capturable,
updated_by,
},
Self::AuthenticationTypeUpdate {
authentication_type,
updated_by,
} => DieselPaymentAttemptUpdate::AuthenticationTypeUpdate {
authentication_type,
updated_by,
},
Self::ConfirmUpdate {
amount,
@ -1167,6 +1181,7 @@ impl DataModelExt for PaymentAttemptUpdate {
error_code,
error_message,
amount_capturable,
updated_by,
} => DieselPaymentAttemptUpdate::ConfirmUpdate {
amount,
currency,
@ -1184,13 +1199,16 @@ impl DataModelExt for PaymentAttemptUpdate {
error_code,
error_message,
amount_capturable,
updated_by,
},
Self::VoidUpdate {
status,
cancellation_reason,
updated_by,
} => DieselPaymentAttemptUpdate::VoidUpdate {
status,
cancellation_reason,
updated_by,
},
Self::ResponseUpdate {
status,
@ -1206,6 +1224,7 @@ impl DataModelExt for PaymentAttemptUpdate {
error_reason,
connector_response_reference_id,
amount_capturable,
updated_by,
} => DieselPaymentAttemptUpdate::ResponseUpdate {
status,
connector,
@ -1220,6 +1239,7 @@ impl DataModelExt for PaymentAttemptUpdate {
error_reason,
connector_response_reference_id,
amount_capturable,
updated_by,
},
Self::UnresolvedResponseUpdate {
status,
@ -1230,6 +1250,7 @@ impl DataModelExt for PaymentAttemptUpdate {
error_message,
error_reason,
connector_response_reference_id,
updated_by,
} => DieselPaymentAttemptUpdate::UnresolvedResponseUpdate {
status,
connector,
@ -1239,8 +1260,11 @@ impl DataModelExt for PaymentAttemptUpdate {
error_message,
error_reason,
connector_response_reference_id,
updated_by,
},
Self::StatusUpdate { status } => DieselPaymentAttemptUpdate::StatusUpdate { status },
Self::StatusUpdate { status, updated_by } => {
DieselPaymentAttemptUpdate::StatusUpdate { status, updated_by }
}
Self::ErrorUpdate {
connector,
status,
@ -1248,6 +1272,7 @@ impl DataModelExt for PaymentAttemptUpdate {
error_message,
error_reason,
amount_capturable,
updated_by,
} => DieselPaymentAttemptUpdate::ErrorUpdate {
connector,
status,
@ -1255,11 +1280,14 @@ impl DataModelExt for PaymentAttemptUpdate {
error_message,
error_reason,
amount_capturable,
updated_by,
},
Self::MultipleCaptureCountUpdate {
multiple_capture_count,
updated_by,
} => DieselPaymentAttemptUpdate::MultipleCaptureCountUpdate {
multiple_capture_count,
updated_by,
},
Self::PreprocessingUpdate {
status,
@ -1268,6 +1296,7 @@ impl DataModelExt for PaymentAttemptUpdate {
preprocessing_step_id,
connector_transaction_id,
connector_response_reference_id,
updated_by,
} => DieselPaymentAttemptUpdate::PreprocessingUpdate {
status,
payment_method_id,
@ -1275,32 +1304,43 @@ impl DataModelExt for PaymentAttemptUpdate {
preprocessing_step_id,
connector_transaction_id,
connector_response_reference_id,
updated_by,
},
Self::RejectUpdate {
status,
error_code,
error_message,
updated_by,
} => DieselPaymentAttemptUpdate::RejectUpdate {
status,
error_code,
error_message,
updated_by,
},
Self::AmountToCaptureUpdate {
status,
amount_capturable,
updated_by,
} => DieselPaymentAttemptUpdate::AmountToCaptureUpdate {
status,
amount_capturable,
updated_by,
},
Self::SurchargeMetadataUpdate {
surcharge_metadata,
updated_by,
} => DieselPaymentAttemptUpdate::SurchargeMetadataUpdate {
surcharge_metadata,
updated_by,
},
Self::SurchargeMetadataUpdate { surcharge_metadata } => {
DieselPaymentAttemptUpdate::SurchargeMetadataUpdate { surcharge_metadata }
}
Self::SurchargeAmountUpdate {
surcharge_amount,
tax_amount,
updated_by,
} => DieselPaymentAttemptUpdate::SurchargeAmountUpdate {
surcharge_amount,
tax_amount,
updated_by,
},
}
}
@ -1320,6 +1360,7 @@ impl DataModelExt for PaymentAttemptUpdate {
business_sub_label,
amount_to_capture,
capture_method,
updated_by,
} => Self::Update {
amount,
currency,
@ -1333,22 +1374,27 @@ impl DataModelExt for PaymentAttemptUpdate {
business_sub_label,
amount_to_capture,
capture_method,
updated_by,
},
DieselPaymentAttemptUpdate::UpdateTrackers {
payment_token,
connector,
straight_through_algorithm,
amount_capturable,
updated_by,
} => Self::UpdateTrackers {
payment_token,
connector,
straight_through_algorithm,
amount_capturable,
updated_by,
},
DieselPaymentAttemptUpdate::AuthenticationTypeUpdate {
authentication_type,
updated_by,
} => Self::AuthenticationTypeUpdate {
authentication_type,
updated_by,
},
DieselPaymentAttemptUpdate::ConfirmUpdate {
amount,
@ -1367,6 +1413,7 @@ impl DataModelExt for PaymentAttemptUpdate {
error_code,
error_message,
amount_capturable,
updated_by,
} => Self::ConfirmUpdate {
amount,
currency,
@ -1384,13 +1431,16 @@ impl DataModelExt for PaymentAttemptUpdate {
error_code,
error_message,
amount_capturable,
updated_by,
},
DieselPaymentAttemptUpdate::VoidUpdate {
status,
cancellation_reason,
updated_by,
} => Self::VoidUpdate {
status,
cancellation_reason,
updated_by,
},
DieselPaymentAttemptUpdate::ResponseUpdate {
status,
@ -1406,6 +1456,7 @@ impl DataModelExt for PaymentAttemptUpdate {
error_reason,
connector_response_reference_id,
amount_capturable,
updated_by,
} => Self::ResponseUpdate {
status,
connector,
@ -1420,6 +1471,7 @@ impl DataModelExt for PaymentAttemptUpdate {
error_reason,
connector_response_reference_id,
amount_capturable,
updated_by,
},
DieselPaymentAttemptUpdate::UnresolvedResponseUpdate {
status,
@ -1430,6 +1482,7 @@ impl DataModelExt for PaymentAttemptUpdate {
error_message,
error_reason,
connector_response_reference_id,
updated_by,
} => Self::UnresolvedResponseUpdate {
status,
connector,
@ -1439,8 +1492,11 @@ impl DataModelExt for PaymentAttemptUpdate {
error_message,
error_reason,
connector_response_reference_id,
updated_by,
},
DieselPaymentAttemptUpdate::StatusUpdate { status } => Self::StatusUpdate { status },
DieselPaymentAttemptUpdate::StatusUpdate { status, updated_by } => {
Self::StatusUpdate { status, updated_by }
}
DieselPaymentAttemptUpdate::ErrorUpdate {
connector,
status,
@ -1448,6 +1504,7 @@ impl DataModelExt for PaymentAttemptUpdate {
error_message,
error_reason,
amount_capturable,
updated_by,
} => Self::ErrorUpdate {
connector,
status,
@ -1455,11 +1512,14 @@ impl DataModelExt for PaymentAttemptUpdate {
error_message,
error_reason,
amount_capturable,
updated_by,
},
DieselPaymentAttemptUpdate::MultipleCaptureCountUpdate {
multiple_capture_count,
updated_by,
} => Self::MultipleCaptureCountUpdate {
multiple_capture_count,
updated_by,
},
DieselPaymentAttemptUpdate::PreprocessingUpdate {
status,
@ -1468,6 +1528,7 @@ impl DataModelExt for PaymentAttemptUpdate {
preprocessing_step_id,
connector_transaction_id,
connector_response_reference_id,
updated_by,
} => Self::PreprocessingUpdate {
status,
payment_method_id,
@ -1475,32 +1536,43 @@ impl DataModelExt for PaymentAttemptUpdate {
preprocessing_step_id,
connector_transaction_id,
connector_response_reference_id,
updated_by,
},
DieselPaymentAttemptUpdate::RejectUpdate {
status,
error_code,
error_message,
updated_by,
} => Self::RejectUpdate {
status,
error_code,
error_message,
updated_by,
},
DieselPaymentAttemptUpdate::AmountToCaptureUpdate {
status,
amount_capturable,
updated_by,
} => Self::AmountToCaptureUpdate {
status,
amount_capturable,
updated_by,
},
DieselPaymentAttemptUpdate::SurchargeMetadataUpdate {
surcharge_metadata,
updated_by,
} => Self::SurchargeMetadataUpdate {
surcharge_metadata,
updated_by,
},
DieselPaymentAttemptUpdate::SurchargeMetadataUpdate { surcharge_metadata } => {
Self::SurchargeMetadataUpdate { surcharge_metadata }
}
DieselPaymentAttemptUpdate::SurchargeAmountUpdate {
surcharge_amount,
tax_amount,
updated_by,
} => Self::SurchargeAmountUpdate {
surcharge_amount,
tax_amount,
updated_by,
},
}
}
@ -1521,6 +1593,7 @@ async fn add_connector_txn_id_to_reverse_lookup<T: DatabaseStore>(
pk_id: key.to_owned(),
sk_id: field.clone(),
source: "payment_attempt".to_string(),
updated_by: storage_scheme.to_string(),
};
store
.insert_reverse_lookup(reverse_lookup_new, storage_scheme)
@ -1542,6 +1615,7 @@ async fn add_preprocessing_id_to_reverse_lookup<T: DatabaseStore>(
pk_id: key.to_owned(),
sk_id: field.clone(),
source: "payment_attempt".to_string(),
updated_by: storage_scheme.to_string(),
};
store
.insert_reverse_lookup(reverse_lookup_new, storage_scheme)

View File

@ -10,11 +10,12 @@ use data_models::{
payment_intent::{PaymentIntentInterface, PaymentIntentNew, PaymentIntentUpdate},
PaymentIntent,
},
MerchantStorageScheme, RemoteStorageObject,
RemoteStorageObject,
};
#[cfg(feature = "olap")]
use diesel::{associations::HasTable, ExpressionMethods, JoinOnDsl, QueryDsl};
use diesel_models::{
enums::MerchantStorageScheme,
kv,
payment_attempt::PaymentAttempt as DieselPaymentAttempt,
payment_intent::{
@ -92,6 +93,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
merchant_decision: new.merchant_decision.clone(),
payment_link_id: new.payment_link_id.clone(),
payment_confirm_source: new.payment_confirm_source,
updated_by: storage_scheme.to_string(),
};
let redis_entry = kv::TypedSql {
op: kv::DBOperation::Insert {
@ -740,6 +742,7 @@ impl DataModelExt for PaymentIntentNew {
merchant_decision: self.merchant_decision,
payment_link_id: self.payment_link_id,
payment_confirm_source: self.payment_confirm_source,
updated_by: self.updated_by,
}
}
@ -778,6 +781,7 @@ impl DataModelExt for PaymentIntentNew {
merchant_decision: storage_model.merchant_decision,
payment_link_id: storage_model.payment_link_id,
payment_confirm_source: storage_model.payment_confirm_source,
updated_by: storage_model.updated_by,
}
}
}
@ -821,6 +825,7 @@ impl DataModelExt for PaymentIntent {
merchant_decision: self.merchant_decision,
payment_link_id: self.payment_link_id,
payment_confirm_source: self.payment_confirm_source,
updated_by: self.updated_by,
}
}
@ -860,6 +865,7 @@ impl DataModelExt for PaymentIntent {
merchant_decision: storage_model.merchant_decision,
payment_link_id: storage_model.payment_link_id,
payment_confirm_source: storage_model.payment_confirm_source,
updated_by: storage_model.updated_by,
}
}
}
@ -873,37 +879,49 @@ impl DataModelExt for PaymentIntentUpdate {
status,
amount_captured,
return_url,
updated_by,
} => DieselPaymentIntentUpdate::ResponseUpdate {
status,
amount_captured,
return_url,
updated_by,
},
Self::MetadataUpdate {
metadata,
updated_by,
} => DieselPaymentIntentUpdate::MetadataUpdate {
metadata,
updated_by,
},
Self::MetadataUpdate { metadata } => {
DieselPaymentIntentUpdate::MetadataUpdate { metadata }
}
Self::ReturnUrlUpdate {
return_url,
status,
customer_id,
shipping_address_id,
billing_address_id,
updated_by,
} => DieselPaymentIntentUpdate::ReturnUrlUpdate {
return_url,
status,
customer_id,
shipping_address_id,
billing_address_id,
updated_by,
},
Self::MerchantStatusUpdate {
status,
shipping_address_id,
billing_address_id,
updated_by,
} => DieselPaymentIntentUpdate::MerchantStatusUpdate {
status,
shipping_address_id,
billing_address_id,
updated_by,
},
Self::PGStatusUpdate { status } => DieselPaymentIntentUpdate::PGStatusUpdate { status },
Self::PGStatusUpdate { status, updated_by } => {
DieselPaymentIntentUpdate::PGStatusUpdate { status, updated_by }
}
Self::Update {
amount,
currency,
@ -921,6 +939,7 @@ impl DataModelExt for PaymentIntentUpdate {
order_details,
metadata,
payment_confirm_source,
updated_by,
} => DieselPaymentIntentUpdate::Update {
amount,
currency,
@ -938,32 +957,43 @@ impl DataModelExt for PaymentIntentUpdate {
order_details,
metadata,
payment_confirm_source,
updated_by,
},
Self::PaymentAttemptAndAttemptCountUpdate {
active_attempt_id,
attempt_count,
updated_by,
} => DieselPaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {
active_attempt_id,
attempt_count,
updated_by,
},
Self::StatusAndAttemptUpdate {
status,
active_attempt_id,
attempt_count,
updated_by,
} => DieselPaymentIntentUpdate::StatusAndAttemptUpdate {
status,
active_attempt_id,
attempt_count,
updated_by,
},
Self::ApproveUpdate {
merchant_decision,
updated_by,
} => DieselPaymentIntentUpdate::ApproveUpdate {
merchant_decision,
updated_by,
},
Self::ApproveUpdate { merchant_decision } => {
DieselPaymentIntentUpdate::ApproveUpdate { merchant_decision }
}
Self::RejectUpdate {
status,
merchant_decision,
updated_by,
} => DieselPaymentIntentUpdate::RejectUpdate {
status,
merchant_decision,
updated_by,
},
}
}