Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix: null fields in payments respose (#2745)
Kartikeya Hegde42261a5306bb
diff --git a/crates/data_models/src/payments/payment_intent.rs b/crates/data_models/src/payments/payment_intent.rsindex 5b41c74bd6..2c5914f5b3 100644--- a/crates/data_models/src/payments/payment_intent.rs+++ b/crates/data_models/src/payments/payment_intent.rs@@ -215,35 +215,6 @@ pub struct PaymentIntentUpdateInternal {pub surcharge_applicable: Option<bool>,}-impl PaymentIntentUpdate {- pub fn apply_changeset(self, source: PaymentIntent) -> PaymentIntent {- let internal_update: PaymentIntentUpdateInternal = self.into();- PaymentIntent {- amount: internal_update.amount.unwrap_or(source.amount),- currency: internal_update.currency.or(source.currency),- status: internal_update.status.unwrap_or(source.status),- amount_captured: internal_update.amount_captured.or(source.amount_captured),- customer_id: internal_update.customer_id.or(source.customer_id),- return_url: internal_update.return_url.or(source.return_url),- setup_future_usage: internal_update- .setup_future_usage- .or(source.setup_future_usage),- off_session: internal_update.off_session.or(source.off_session),- metadata: internal_update.metadata.or(source.metadata),- billing_address_id: internal_update- .billing_address_id- .or(source.billing_address_id),- shipping_address_id: internal_update- .shipping_address_id- .or(source.shipping_address_id),- modified_at: common_utils::date_time::now(),- order_details: internal_update.order_details.or(source.order_details),- updated_by: internal_update.updated_by,- ..source- }- }-}-impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {fn from(payment_intent_update: PaymentIntentUpdate) -> Self {match payment_intent_update {diff --git a/crates/storage_impl/src/mock_db/payment_intent.rs b/crates/storage_impl/src/mock_db/payment_intent.rsindex d1979cba01..08a4a2aabe 100644--- a/crates/storage_impl/src/mock_db/payment_intent.rs+++ b/crates/storage_impl/src/mock_db/payment_intent.rs@@ -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())}diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rsindex 7c0939414a..2dc5cdd1c0 100644--- a/crates/storage_impl/src/payments/payment_intent.rs+++ b/crates/storage_impl/src/payments/payment_intent.rs@@ -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))}}}