refactor(disputes): resolve incorrect 5xx error mappings for disputes (#1360)

Co-authored-by: Kritik Modi <61862301+kritikmodi@users.noreply.github.com>
Co-authored-by: kritikmodi <kritik.modi@juspay.in>
Co-authored-by: Sai Harsha Vardhan <56996463+sai-harsha-vardhan@users.noreply.github.com>
This commit is contained in:
Abhishek Marrivagu
2023-06-14 18:31:31 +05:30
committed by GitHub
parent 5535159d5c
commit c9b400e186
4 changed files with 53 additions and 6 deletions

View File

@ -40,6 +40,9 @@ pub enum StripeErrorCode {
#[error(error_type = StripeErrorType::ApiError, code = "payment_intent_payment_attempt_failed", message = "Capture attempt failed while processing with connector.")]
PaymentIntentPaymentAttemptFailed { data: Option<serde_json::Value> },
#[error(error_type = StripeErrorType::ApiError, code = "dispute_failure", message = "Dispute failed while processing with connector. Retry operation.")]
DisputeFailed { data: Option<serde_json::Value> },
#[error(error_type = StripeErrorType::CardError, code = "expired_card", message = "Card Expired. Please use another card")]
ExpiredCard,
@ -405,6 +408,7 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
errors::ApiErrorResponse::PaymentCaptureFailed { data } => {
Self::PaymentIntentPaymentAttemptFailed { data }
}
errors::ApiErrorResponse::DisputeFailed { data } => Self::DisputeFailed { data },
errors::ApiErrorResponse::InvalidCardData { data } => Self::InvalidCardType, // Maybe it is better to de generalize this router error
errors::ApiErrorResponse::CardExpired { data } => Self::ExpiredCard,
errors::ApiErrorResponse::RefundNotPossible { connector } => Self::RefundFailed,
@ -548,6 +552,7 @@ impl actix_web::ResponseError for StripeErrorCode {
| Self::DuplicatePaymentMethod
| Self::PaymentFailed
| Self::VerificationFailed { .. }
| Self::DisputeFailed { .. }
| Self::MaximumRefundCount
| Self::PaymentIntentInvalidParameter { .. }
| Self::SerdeQsError { .. }