Skip to content

Commit

Permalink
fix: status goes from pending to partially captured in psync
Browse files Browse the repository at this point in the history
  • Loading branch information
hrithikesh026 committed Nov 17, 2023
1 parent 1d48a83 commit 351ea53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions crates/router/src/connector/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};

Expand Down Expand Up @@ -109,10 +112,15 @@ 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
} else {
enums::AttemptStatus::PartialCharged
if let Some(captured_amount) = captured_amount {
let amount_capturable = payment_data.payment_attempt.get_total_amount();
if captured_amount == amount_capturable {
enums::AttemptStatus::Charged
} else {
enums::AttemptStatus::PartialCharged
}
}else{
self.status
}
}
_ => self.status,
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ pub struct AccessTokenRequestData {

pub trait Capturable {
fn get_capture_amount(&self) -> Option<i64> {
Some(0)
None
}
fn get_surcharge_amount(&self) -> Option<i64> {
None
Expand Down

0 comments on commit 351ea53

Please sign in to comment.