mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 05:17:02 +08:00
fix: status goes from pending to partially captured in psync (#2915)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -24,7 +24,10 @@ use crate::{
|
||||
payments::PaymentData,
|
||||
},
|
||||
pii::PeekInterface,
|
||||
types::{self, api, transformers::ForeignTryFrom, PaymentsCancelData, ResponseId},
|
||||
types::{
|
||||
self, api, storage::payment_attempt::PaymentAttemptExt, transformers::ForeignTryFrom,
|
||||
PaymentsCancelData, ResponseId,
|
||||
},
|
||||
utils::{OptionExt, ValueExt},
|
||||
};
|
||||
|
||||
@ -108,11 +111,20 @@ where
|
||||
}
|
||||
}
|
||||
enums::AttemptStatus::Charged => {
|
||||
let captured_amount = types::Capturable::get_capture_amount(&self.request);
|
||||
if Some(payment_data.payment_intent.amount) == captured_amount {
|
||||
enums::AttemptStatus::Charged
|
||||
let captured_amount = if self.request.is_psync() {
|
||||
payment_data
|
||||
.payment_attempt
|
||||
.amount_to_capture
|
||||
.or(Some(payment_data.payment_attempt.get_total_amount()))
|
||||
} else {
|
||||
types::Capturable::get_capture_amount(&self.request)
|
||||
};
|
||||
if Some(payment_data.payment_attempt.get_total_amount()) == captured_amount {
|
||||
enums::AttemptStatus::Charged
|
||||
} else if captured_amount.is_some() {
|
||||
enums::AttemptStatus::PartialCharged
|
||||
} else {
|
||||
self.status
|
||||
}
|
||||
}
|
||||
_ => self.status,
|
||||
|
||||
Reference in New Issue
Block a user