fix(core): update amount_capturable in update trackers (#2142)

This commit is contained in:
Hrithikesh
2023-09-13 14:44:31 +05:30
committed by GitHub
parent 9d74a75ddb
commit bed8326597
5 changed files with 23 additions and 1 deletions

View File

@ -216,6 +216,7 @@ pub enum PaymentAttemptUpdate {
payment_token: Option<String>, payment_token: Option<String>,
connector: Option<String>, connector: Option<String>,
straight_through_algorithm: Option<serde_json::Value>, straight_through_algorithm: Option<serde_json::Value>,
amount_capturable: Option<i64>,
}, },
AuthenticationTypeUpdate { AuthenticationTypeUpdate {
authentication_type: storage_enums::AuthenticationType, authentication_type: storage_enums::AuthenticationType,
@ -236,6 +237,7 @@ pub enum PaymentAttemptUpdate {
straight_through_algorithm: Option<serde_json::Value>, straight_through_algorithm: Option<serde_json::Value>,
error_code: Option<Option<String>>, error_code: Option<Option<String>>,
error_message: Option<Option<String>>, error_message: Option<Option<String>>,
amount_capturable: Option<i64>,
}, },
RejectUpdate { RejectUpdate {
status: storage_enums::AttemptStatus, status: storage_enums::AttemptStatus,

View File

@ -137,6 +137,7 @@ pub enum PaymentAttemptUpdate {
payment_token: Option<String>, payment_token: Option<String>,
connector: Option<String>, connector: Option<String>,
straight_through_algorithm: Option<serde_json::Value>, straight_through_algorithm: Option<serde_json::Value>,
amount_capturable: Option<i64>,
}, },
AuthenticationTypeUpdate { AuthenticationTypeUpdate {
authentication_type: storage_enums::AuthenticationType, authentication_type: storage_enums::AuthenticationType,
@ -157,6 +158,7 @@ pub enum PaymentAttemptUpdate {
straight_through_algorithm: Option<serde_json::Value>, straight_through_algorithm: Option<serde_json::Value>,
error_code: Option<Option<String>>, error_code: Option<Option<String>>,
error_message: Option<Option<String>>, error_message: Option<Option<String>>,
amount_capturable: Option<i64>,
}, },
VoidUpdate { VoidUpdate {
status: storage_enums::AttemptStatus, status: storage_enums::AttemptStatus,
@ -339,6 +341,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
straight_through_algorithm, straight_through_algorithm,
error_code, error_code,
error_message, error_message,
amount_capturable,
} => Self { } => Self {
amount: Some(amount), amount: Some(amount),
currency: Some(currency), currency: Some(currency),
@ -356,6 +359,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
straight_through_algorithm, straight_through_algorithm,
error_code, error_code,
error_message, error_message,
amount_capturable,
..Default::default() ..Default::default()
}, },
PaymentAttemptUpdate::VoidUpdate { PaymentAttemptUpdate::VoidUpdate {
@ -432,10 +436,12 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
payment_token, payment_token,
connector, connector,
straight_through_algorithm, straight_through_algorithm,
amount_capturable,
} => Self { } => Self {
payment_token, payment_token,
connector, connector,
straight_through_algorithm, straight_through_algorithm,
amount_capturable,
..Default::default() ..Default::default()
}, },
PaymentAttemptUpdate::UnresolvedResponseUpdate { PaymentAttemptUpdate::UnresolvedResponseUpdate {

View File

@ -513,7 +513,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
.take(); .take();
let order_details = payment_data.payment_intent.order_details.clone(); let order_details = payment_data.payment_intent.order_details.clone();
let metadata = payment_data.payment_intent.metadata.clone(); let metadata = payment_data.payment_intent.metadata.clone();
let authorized_amount = payment_data.payment_attempt.amount;
let payment_attempt_fut = db let payment_attempt_fut = db
.update_payment_attempt_with_attempt_id( .update_payment_attempt_with_attempt_id(
payment_data.payment_attempt, payment_data.payment_attempt,
@ -533,6 +533,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
straight_through_algorithm, straight_through_algorithm,
error_code, error_code,
error_message, error_message,
amount_capturable: Some(authorized_amount),
}, },
storage_scheme, storage_scheme,
) )

View File

@ -386,6 +386,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
.payment_attempt .payment_attempt
.straight_through_algorithm .straight_through_algorithm
.clone(); .clone();
let authorized_amount = payment_data.payment_attempt.amount;
payment_data.payment_attempt = db payment_data.payment_attempt = db
.update_payment_attempt_with_attempt_id( .update_payment_attempt_with_attempt_id(
@ -394,6 +395,10 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
payment_token, payment_token,
connector, connector,
straight_through_algorithm, straight_through_algorithm,
amount_capturable: match payment_data.confirm.unwrap_or(true) {
true => Some(authorized_amount),
false => None,
},
}, },
storage_scheme, storage_scheme,
) )

View File

@ -1089,10 +1089,12 @@ impl DataModelExt for PaymentAttemptUpdate {
payment_token, payment_token,
connector, connector,
straight_through_algorithm, straight_through_algorithm,
amount_capturable,
} => DieselPaymentAttemptUpdate::UpdateTrackers { } => DieselPaymentAttemptUpdate::UpdateTrackers {
payment_token, payment_token,
connector, connector,
straight_through_algorithm, straight_through_algorithm,
amount_capturable,
}, },
Self::AuthenticationTypeUpdate { Self::AuthenticationTypeUpdate {
authentication_type, authentication_type,
@ -1115,6 +1117,7 @@ impl DataModelExt for PaymentAttemptUpdate {
straight_through_algorithm, straight_through_algorithm,
error_code, error_code,
error_message, error_message,
amount_capturable,
} => DieselPaymentAttemptUpdate::ConfirmUpdate { } => DieselPaymentAttemptUpdate::ConfirmUpdate {
amount, amount,
currency, currency,
@ -1131,6 +1134,7 @@ impl DataModelExt for PaymentAttemptUpdate {
straight_through_algorithm, straight_through_algorithm,
error_code, error_code,
error_message, error_message,
amount_capturable,
}, },
Self::VoidUpdate { Self::VoidUpdate {
status, status,
@ -1275,10 +1279,12 @@ impl DataModelExt for PaymentAttemptUpdate {
payment_token, payment_token,
connector, connector,
straight_through_algorithm, straight_through_algorithm,
amount_capturable,
} => Self::UpdateTrackers { } => Self::UpdateTrackers {
payment_token, payment_token,
connector, connector,
straight_through_algorithm, straight_through_algorithm,
amount_capturable,
}, },
DieselPaymentAttemptUpdate::AuthenticationTypeUpdate { DieselPaymentAttemptUpdate::AuthenticationTypeUpdate {
authentication_type, authentication_type,
@ -1301,6 +1307,7 @@ impl DataModelExt for PaymentAttemptUpdate {
straight_through_algorithm, straight_through_algorithm,
error_code, error_code,
error_message, error_message,
amount_capturable,
} => Self::ConfirmUpdate { } => Self::ConfirmUpdate {
amount, amount,
currency, currency,
@ -1317,6 +1324,7 @@ impl DataModelExt for PaymentAttemptUpdate {
straight_through_algorithm, straight_through_algorithm,
error_code, error_code,
error_message, error_message,
amount_capturable,
}, },
DieselPaymentAttemptUpdate::VoidUpdate { DieselPaymentAttemptUpdate::VoidUpdate {
status, status,