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(core): update amount_capturable in update trackers (#2142)
Hrithikeshbed8326597fe
diff --git a/crates/data_models/src/payments/payment_attempt.rs b/crates/data_models/src/payments/payment_attempt.rsindex 1538452e5a..d33e6dbfad 100644--- a/crates/data_models/src/payments/payment_attempt.rs+++ b/crates/data_models/src/payments/payment_attempt.rs@@ -216,6 +216,7 @@ pub enum PaymentAttemptUpdate {payment_token: Option<String>,connector: Option<String>,straight_through_algorithm: Option<serde_json::Value>,+ amount_capturable: Option<i64>,},AuthenticationTypeUpdate {authentication_type: storage_enums::AuthenticationType,@@ -236,6 +237,7 @@ pub enum PaymentAttemptUpdate {straight_through_algorithm: Option<serde_json::Value>,error_code: Option<Option<String>>,error_message: Option<Option<String>>,+ amount_capturable: Option<i64>,},RejectUpdate {status: storage_enums::AttemptStatus,diff --git a/crates/diesel_models/src/payment_attempt.rs b/crates/diesel_models/src/payment_attempt.rsindex dac9977d22..f42aa4e4df 100644--- a/crates/diesel_models/src/payment_attempt.rs+++ b/crates/diesel_models/src/payment_attempt.rs@@ -137,6 +137,7 @@ pub enum PaymentAttemptUpdate {payment_token: Option<String>,connector: Option<String>,straight_through_algorithm: Option<serde_json::Value>,+ amount_capturable: Option<i64>,},AuthenticationTypeUpdate {authentication_type: storage_enums::AuthenticationType,@@ -157,6 +158,7 @@ pub enum PaymentAttemptUpdate {straight_through_algorithm: Option<serde_json::Value>,error_code: Option<Option<String>>,error_message: Option<Option<String>>,+ amount_capturable: Option<i64>,},VoidUpdate {status: storage_enums::AttemptStatus,@@ -339,6 +341,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {straight_through_algorithm,error_code,error_message,+ amount_capturable,} => Self {amount: Some(amount),currency: Some(currency),@@ -356,6 +359,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {straight_through_algorithm,error_code,error_message,+ amount_capturable,..Default::default()},PaymentAttemptUpdate::VoidUpdate {@@ -432,10 +436,12 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {payment_token,connector,straight_through_algorithm,+ amount_capturable,} => Self {payment_token,connector,straight_through_algorithm,+ amount_capturable,..Default::default()},PaymentAttemptUpdate::UnresolvedResponseUpdate {diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex f8150283cb..09884deb67 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -513,7 +513,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen.take();let order_details = payment_data.payment_intent.order_details.clone();let metadata = payment_data.payment_intent.metadata.clone();-+ let authorized_amount = payment_data.payment_attempt.amount;let payment_attempt_fut = db.update_payment_attempt_with_attempt_id(payment_data.payment_attempt,@@ -533,6 +533,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymenstraight_through_algorithm,error_code,error_message,+ amount_capturable: Some(authorized_amount),},storage_scheme,)diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 6a3e4cb74e..b279941097 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -386,6 +386,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen.payment_attempt.straight_through_algorithm.clone();+ let authorized_amount = payment_data.payment_attempt.amount;payment_data.payment_attempt = db.update_payment_attempt_with_attempt_id(@@ -394,6 +395,10 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymenpayment_token,connector,straight_through_algorithm,+ amount_capturable: match payment_data.confirm.unwrap_or(true) {+ true => Some(authorized_amount),+ false => None,+ },},storage_scheme,)diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rsindex 7b64cd012f..1d2379d542 100644--- a/crates/storage_impl/src/payments/payment_attempt.rs+++ b/crates/storage_impl/src/payments/payment_attempt.rs@@ -1089,10 +1089,12 @@ impl DataModelExt for PaymentAttemptUpdate {payment_token,connector,straight_through_algorithm,+ amount_capturable,} => DieselPaymentAttemptUpdate::UpdateTrackers {payment_token,connector,straight_through_algorithm,+ amount_capturable,},Self::AuthenticationTypeUpdate {authentication_type,@@ -1115,6 +1117,7 @@ impl DataModelExt for PaymentAttemptUpdate {straight_through_algorithm,error_code,error_message,+ amount_capturable,} => DieselPaymentAttemptUpdate::ConfirmUpdate {amount,currency,@@ -1131,6 +1134,7 @@ impl DataModelExt for PaymentAttemptUpdate {straight_through_algorithm,error_code,error_message,+ amount_capturable,},Self::VoidUpdate {status,@@ -1275,10 +1279,12 @@ impl DataModelExt for PaymentAttemptUpdate {payment_token,connector,straight_through_algorithm,+ amount_capturable,} => Self::UpdateTrackers {payment_token,connector,straight_through_algorithm,+ amount_capturable,},DieselPaymentAttemptUpdate::AuthenticationTypeUpdate {authentication_type,@@ -1301,6 +1307,7 @@ impl DataModelExt for PaymentAttemptUpdate {straight_through_algorithm,error_code,error_message,+ amount_capturable,} => Self::ConfirmUpdate {amount,currency,@@ -1317,6 +1324,7 @@ impl DataModelExt for PaymentAttemptUpdate {straight_through_algorithm,error_code,error_message,+ amount_capturable,},DieselPaymentAttemptUpdate::VoidUpdate {status,