mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
feat(core): allow setting up status across payments, refunds and payouts for triggering webhooks in core resource flows (#8433)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -2292,6 +2292,7 @@ pub enum FrmTransactionType {
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumIter,
|
||||
strum::EnumString,
|
||||
ToSchema,
|
||||
)]
|
||||
@ -6959,6 +6960,7 @@ pub enum BrazilStatesAbbreviation {
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
strum::Display,
|
||||
strum::EnumIter,
|
||||
strum::EnumString,
|
||||
)]
|
||||
#[router_derive::diesel_enum(storage_type = "db_enum")]
|
||||
|
||||
@ -2,9 +2,11 @@ use std::fmt::{Display, Formatter};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "payouts")]
|
||||
use crate::enums::PayoutStatus;
|
||||
use crate::enums::{
|
||||
AttemptStatus, Country, CountryAlpha2, CountryAlpha3, IntentStatus, PaymentMethod,
|
||||
PaymentMethodType,
|
||||
AttemptStatus, Country, CountryAlpha2, CountryAlpha3, DisputeStatus, EventType, IntentStatus,
|
||||
MandateStatus, PaymentMethod, PaymentMethodType, RefundStatus,
|
||||
};
|
||||
|
||||
impl Display for NumericCountryCodeParseError {
|
||||
@ -2119,6 +2121,82 @@ impl From<AttemptStatus> for IntentStatus {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IntentStatus> for Option<EventType> {
|
||||
fn from(value: IntentStatus) -> Self {
|
||||
match value {
|
||||
IntentStatus::Succeeded => Some(EventType::PaymentSucceeded),
|
||||
IntentStatus::Failed => Some(EventType::PaymentFailed),
|
||||
IntentStatus::Processing => Some(EventType::PaymentProcessing),
|
||||
IntentStatus::RequiresMerchantAction
|
||||
| IntentStatus::RequiresCustomerAction
|
||||
| IntentStatus::Conflicted => Some(EventType::ActionRequired),
|
||||
IntentStatus::Cancelled => Some(EventType::PaymentCancelled),
|
||||
IntentStatus::PartiallyCaptured | IntentStatus::PartiallyCapturedAndCapturable => {
|
||||
Some(EventType::PaymentCaptured)
|
||||
}
|
||||
IntentStatus::RequiresCapture => Some(EventType::PaymentAuthorized),
|
||||
IntentStatus::RequiresPaymentMethod | IntentStatus::RequiresConfirmation => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RefundStatus> for Option<EventType> {
|
||||
fn from(value: RefundStatus) -> Self {
|
||||
match value {
|
||||
RefundStatus::Success => Some(EventType::RefundSucceeded),
|
||||
RefundStatus::Failure => Some(EventType::RefundFailed),
|
||||
RefundStatus::ManualReview
|
||||
| RefundStatus::Pending
|
||||
| RefundStatus::TransactionFailure => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "payouts")]
|
||||
impl From<PayoutStatus> for Option<EventType> {
|
||||
fn from(value: PayoutStatus) -> Self {
|
||||
match value {
|
||||
PayoutStatus::Success => Some(EventType::PayoutSuccess),
|
||||
PayoutStatus::Failed => Some(EventType::PayoutFailed),
|
||||
PayoutStatus::Cancelled => Some(EventType::PayoutCancelled),
|
||||
PayoutStatus::Initiated => Some(EventType::PayoutInitiated),
|
||||
PayoutStatus::Expired => Some(EventType::PayoutExpired),
|
||||
PayoutStatus::Reversed => Some(EventType::PayoutReversed),
|
||||
PayoutStatus::Ineligible
|
||||
| PayoutStatus::Pending
|
||||
| PayoutStatus::RequiresCreation
|
||||
| PayoutStatus::RequiresFulfillment
|
||||
| PayoutStatus::RequiresPayoutMethodData
|
||||
| PayoutStatus::RequiresVendorAccountCreation
|
||||
| PayoutStatus::RequiresConfirmation => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DisputeStatus> for EventType {
|
||||
fn from(value: DisputeStatus) -> Self {
|
||||
match value {
|
||||
DisputeStatus::DisputeOpened => Self::DisputeOpened,
|
||||
DisputeStatus::DisputeExpired => Self::DisputeExpired,
|
||||
DisputeStatus::DisputeAccepted => Self::DisputeAccepted,
|
||||
DisputeStatus::DisputeCancelled => Self::DisputeCancelled,
|
||||
DisputeStatus::DisputeChallenged => Self::DisputeChallenged,
|
||||
DisputeStatus::DisputeWon => Self::DisputeWon,
|
||||
DisputeStatus::DisputeLost => Self::DisputeLost,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MandateStatus> for Option<EventType> {
|
||||
fn from(value: MandateStatus) -> Self {
|
||||
match value {
|
||||
MandateStatus::Active => Some(EventType::MandateActive),
|
||||
MandateStatus::Revoked => Some(EventType::MandateRevoked),
|
||||
MandateStatus::Inactive | MandateStatus::Pending => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
Reference in New Issue
Block a user