mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +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:
@ -50,10 +50,16 @@ pub async fn refund_create_core(
|
||||
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
|
||||
|
||||
utils::when(
|
||||
payment_intent.status != enums::IntentStatus::Succeeded,
|
||||
!(payment_intent.status == enums::IntentStatus::Succeeded
|
||||
|| payment_intent.status == enums::IntentStatus::PartiallyCaptured),
|
||||
|| {
|
||||
Err(report!(errors::ApiErrorResponse::PaymentNotSucceeded)
|
||||
.attach_printable("unable to refund for a unsuccessful payment intent"))
|
||||
Err(report!(errors::ApiErrorResponse::PaymentUnexpectedState {
|
||||
current_flow: "refund".into(),
|
||||
field_name: "status".into(),
|
||||
current_value: payment_intent.status.to_string(),
|
||||
states: "succeeded, partially_captured".to_string()
|
||||
})
|
||||
.attach_printable("unable to refund for a unsuccessful payment intent"))
|
||||
},
|
||||
)?;
|
||||
|
||||
@ -75,7 +81,7 @@ pub async fn refund_create_core(
|
||||
})?;
|
||||
|
||||
payment_attempt = db
|
||||
.find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(
|
||||
.find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(
|
||||
&req.payment_id,
|
||||
merchant_id,
|
||||
merchant_account.storage_scheme,
|
||||
|
||||
Reference in New Issue
Block a user