fix: null fields in payments respose (#2745)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Kartikeya Hegde
2023-10-31 19:56:45 +05:30
committed by GitHub
parent 09c3e170d1
commit 42261a5306
3 changed files with 15 additions and 35 deletions

View File

@ -11,6 +11,7 @@ use diesel_models::enums as storage_enums;
use error_stack::{IntoReport, ResultExt};
use super::MockDb;
use crate::DataModelExt;
#[async_trait::async_trait]
impl PaymentIntentInterface for MockDb {
@ -123,7 +124,11 @@ impl PaymentIntentInterface for MockDb {
.iter_mut()
.find(|item| item.id == this.id)
.unwrap();
*payment_intent = update.apply_changeset(this);
*payment_intent = PaymentIntent::from_storage_model(
update
.to_storage_model()
.apply_changeset(this.to_storage_model()),
);
Ok(payment_intent.clone())
}

View File

@ -146,8 +146,12 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
let key = format!("mid_{}_pid_{}", this.merchant_id, this.payment_id);
let field = format!("pi_{}", this.payment_id);
let updated_intent = payment_intent_update.clone().apply_changeset(this.clone());
let diesel_intent = updated_intent.clone().to_storage_model();
let diesel_intent_update = payment_intent_update.to_storage_model();
let origin_diesel_intent = this.to_storage_model();
let diesel_intent = diesel_intent_update
.clone()
.apply_changeset(origin_diesel_intent.clone());
// Check for database presence as well Maybe use a read replica here ?
let redis_value =
@ -158,8 +162,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
op: kv::DBOperation::Update {
updatable: kv::Updateable::PaymentIntentUpdate(
kv::PaymentIntentUpdateMems {
orig: this.to_storage_model(),
update_data: payment_intent_update.to_storage_model(),
orig: origin_diesel_intent,
update_data: diesel_intent_update,
},
),
},
@ -175,7 +179,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
.try_into_hset()
.change_context(StorageError::KVError)?;
Ok(updated_intent)
Ok(PaymentIntent::from_storage_model(diesel_intent))
}
}
}