fix: introduce net_amount field in payment response (#3115)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Hrithikesh
2024-01-08 19:57:37 +05:30
committed by GitHub
parent 7d43c5a736
commit 23e0c63541
13 changed files with 104 additions and 6 deletions

View File

@ -331,6 +331,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
.await
}
MerchantStorageScheme::RedisKv => {
let payment_attempt = payment_attempt.populate_derived_fields();
let key = format!(
"mid_{}_pid_{}",
payment_attempt.merchant_id, payment_attempt.payment_id
@ -343,6 +344,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
attempt_id: payment_attempt.attempt_id.clone(),
status: payment_attempt.status,
amount: payment_attempt.amount,
net_amount: payment_attempt.net_amount,
currency: payment_attempt.currency,
save_to_locker: payment_attempt.save_to_locker,
connector: payment_attempt.connector.clone(),
@ -1035,6 +1037,7 @@ impl DataModelExt for PaymentAttempt {
attempt_id: self.attempt_id,
status: self.status,
amount: self.amount,
net_amount: Some(self.net_amount),
currency: self.currency,
save_to_locker: self.save_to_locker,
connector: self.connector,
@ -1081,6 +1084,7 @@ impl DataModelExt for PaymentAttempt {
fn from_storage_model(storage_model: Self::StorageModel) -> Self {
Self {
net_amount: storage_model.get_or_calculate_net_amount(),
id: storage_model.id,
payment_id: storage_model.payment_id,
merchant_id: storage_model.merchant_id,
@ -1139,6 +1143,7 @@ impl DataModelExt for PaymentAttemptNew {
fn to_storage_model(self) -> Self::StorageModel {
DieselPaymentAttemptNew {
net_amount: Some(self.net_amount),
payment_id: self.payment_id,
merchant_id: self.merchant_id,
attempt_id: self.attempt_id,
@ -1189,6 +1194,7 @@ impl DataModelExt for PaymentAttemptNew {
fn from_storage_model(storage_model: Self::StorageModel) -> Self {
Self {
net_amount: storage_model.get_or_calculate_net_amount(),
payment_id: storage_model.payment_id,
merchant_id: storage_model.merchant_id,
attempt_id: storage_model.attempt_id,