mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
feat(core): enable payment refund when payment is partially captured (#2991)
Co-authored-by: Gnanasundari24 <118818938+Gnanasundari24@users.noreply.github.com>
This commit is contained in:
@ -205,4 +205,24 @@ impl PaymentAttemptInterface for MockDb {
|
||||
.cloned()
|
||||
.unwrap())
|
||||
}
|
||||
#[allow(clippy::unwrap_used)]
|
||||
async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(
|
||||
&self,
|
||||
payment_id: &str,
|
||||
merchant_id: &str,
|
||||
_storage_scheme: storage_enums::MerchantStorageScheme,
|
||||
) -> CustomResult<PaymentAttempt, StorageError> {
|
||||
let payment_attempts = self.payment_attempts.lock().await;
|
||||
|
||||
Ok(payment_attempts
|
||||
.iter()
|
||||
.find(|payment_attempt| {
|
||||
payment_attempt.payment_id == payment_id
|
||||
&& payment_attempt.merchant_id == merchant_id
|
||||
&& (payment_attempt.status == storage_enums::AttemptStatus::PartialCharged
|
||||
|| payment_attempt.status == storage_enums::AttemptStatus::Charged)
|
||||
})
|
||||
.cloned()
|
||||
.unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user