feat(router): add support for partial authorization (#8833)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sai Harsha Vardhan
2025-08-06 19:38:09 +05:30
committed by GitHub
parent 654c15ee19
commit c354e62f9d
67 changed files with 537 additions and 79 deletions

View File

@ -148,6 +148,7 @@ pub enum AttemptStatus {
VoidFailed,
AutoRefunded,
PartialCharged,
PartiallyAuthorized,
PartialChargedAndChargeable,
Unresolved,
#[default]
@ -178,6 +179,7 @@ impl AttemptStatus {
| Self::AuthenticationPending
| Self::AuthenticationSuccessful
| Self::Authorized
| Self::PartiallyAuthorized
| Self::AuthorizationFailed
| Self::Authorizing
| Self::CodInitiated
@ -1560,6 +1562,7 @@ pub enum EventType {
PaymentCancelled,
PaymentCancelledPostCapture,
PaymentAuthorized,
PaymentPartiallyAuthorized,
PaymentCaptured,
PaymentExpired,
ActionRequired,
@ -1683,6 +1686,8 @@ pub enum IntentStatus {
PartiallyCaptured,
/// The payment has been captured partially and the remaining amount is capturable
PartiallyCapturedAndCapturable,
/// The payment has been authorized for a partial amount and requires capture
PartiallyAuthorizedAndRequiresCapture,
/// There has been a discrepancy between the amount/currency sent in the request and the amount/currency received by the processor
Conflicted,
/// The payment expired before it could be captured.
@ -1706,6 +1711,7 @@ impl IntentStatus {
| Self::RequiresConfirmation
| Self::RequiresCapture
| Self::PartiallyCapturedAndCapturable
| Self::PartiallyAuthorizedAndRequiresCapture
| Self::Conflicted => false,
}
}
@ -1727,7 +1733,7 @@ impl IntentStatus {
| Self::RequiresCustomerAction
| Self::RequiresMerchantAction
| Self::PartiallyCapturedAndCapturable
=> true,
| Self::PartiallyAuthorizedAndRequiresCapture => true,
}
}
}
@ -1853,6 +1859,7 @@ impl From<AttemptStatus> for PaymentMethodStatus {
| AttemptStatus::AutoRefunded
| AttemptStatus::PartialCharged
| AttemptStatus::PartialChargedAndChargeable
| AttemptStatus::PartiallyAuthorized
| AttemptStatus::ConfirmationAwaited
| AttemptStatus::DeviceDataCollectionPending
| AttemptStatus::IntegrityFailure

View File

@ -2125,6 +2125,7 @@ impl From<AttemptStatus> for IntentStatus {
AttemptStatus::Voided => Self::Cancelled,
AttemptStatus::VoidedPostCharge => Self::CancelledPostCapture,
AttemptStatus::Expired => Self::Expired,
AttemptStatus::PartiallyAuthorized => Self::PartiallyAuthorizedAndRequiresCapture,
}
}
}
@ -2146,6 +2147,9 @@ impl From<IntentStatus> for Option<EventType> {
}
IntentStatus::RequiresCapture => Some(EventType::PaymentAuthorized),
IntentStatus::RequiresPaymentMethod | IntentStatus::RequiresConfirmation => None,
IntentStatus::PartiallyAuthorizedAndRequiresCapture => {
Some(EventType::PaymentPartiallyAuthorized)
}
}
}
}