mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 18:17:13 +08:00 
			
		
		
		
	fix(core): Error propagation for not supporting partial refund (#2976)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
		| @ -583,10 +583,7 @@ impl<F> TryFrom<&ProphetpayRouterData<&types::RefundsRouterData<F>>> for Prophet | |||||||
|                 action_type: ProphetpayActionType::get_action_type(&ProphetpayActionType::Refund), |                 action_type: ProphetpayActionType::get_action_type(&ProphetpayActionType::Refund), | ||||||
|             }) |             }) | ||||||
|         } else { |         } else { | ||||||
|             Err(errors::ConnectorError::NotImplemented( |             Err(errors::ConnectorError::NotImplemented("Partial Refund".to_string()).into()) | ||||||
|                 "Partial Refund is Not Supported".to_string(), |  | ||||||
|             ) |  | ||||||
|             .into()) |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -136,11 +136,10 @@ pub trait ConnectorErrorExt<T> { | |||||||
|  |  | ||||||
| impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError> { | impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError> { | ||||||
|     fn to_refund_failed_response(self) -> error_stack::Result<T, errors::ApiErrorResponse> { |     fn to_refund_failed_response(self) -> error_stack::Result<T, errors::ApiErrorResponse> { | ||||||
|         self.map_err(|err| { |         self.map_err(|err| match err.current_context() { | ||||||
|             let data = match err.current_context() { |  | ||||||
|             errors::ConnectorError::ProcessingStepFailed(Some(bytes)) => { |             errors::ConnectorError::ProcessingStepFailed(Some(bytes)) => { | ||||||
|                 let response_str = std::str::from_utf8(bytes); |                 let response_str = std::str::from_utf8(bytes); | ||||||
|                     match response_str { |                 let data = match response_str { | ||||||
|                     Ok(s) => serde_json::from_str(s) |                     Ok(s) => serde_json::from_str(s) | ||||||
|                         .map_err( |                         .map_err( | ||||||
|                             |error| logger::error!(%error,"Failed to convert response to JSON"), |                             |error| logger::error!(%error,"Failed to convert response to JSON"), | ||||||
| @ -150,11 +149,68 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError> | |||||||
|                         logger::error!(%error,"Failed to convert response to UTF8 string"); |                         logger::error!(%error,"Failed to convert response to UTF8 string"); | ||||||
|                         None |                         None | ||||||
|                     } |                     } | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|                 _ => None, |  | ||||||
|                 }; |                 }; | ||||||
|                 err.change_context(errors::ApiErrorResponse::RefundFailed { data }) |                 err.change_context(errors::ApiErrorResponse::RefundFailed { data }) | ||||||
|  |             } | ||||||
|  |             errors::ConnectorError::NotImplemented(reason) => { | ||||||
|  |                 errors::ApiErrorResponse::NotImplemented { | ||||||
|  |                     message: errors::api_error_response::NotImplementedMessage::Reason( | ||||||
|  |                         reason.to_string(), | ||||||
|  |                     ), | ||||||
|  |                 } | ||||||
|  |                 .into() | ||||||
|  |             } | ||||||
|  |             errors::ConnectorError::FailedToObtainIntegrationUrl | ||||||
|  |             | errors::ConnectorError::RequestEncodingFailed | ||||||
|  |             | errors::ConnectorError::RequestEncodingFailedWithReason(_) | ||||||
|  |             | errors::ConnectorError::ParsingFailed | ||||||
|  |             | errors::ConnectorError::ResponseDeserializationFailed | ||||||
|  |             | errors::ConnectorError::UnexpectedResponseError(_) | ||||||
|  |             | errors::ConnectorError::RoutingRulesParsingError | ||||||
|  |             | errors::ConnectorError::FailedToObtainPreferredConnector | ||||||
|  |             | errors::ConnectorError::ProcessingStepFailed(_) | ||||||
|  |             | errors::ConnectorError::InvalidConnectorName | ||||||
|  |             | errors::ConnectorError::InvalidWallet | ||||||
|  |             | errors::ConnectorError::ResponseHandlingFailed | ||||||
|  |             | errors::ConnectorError::MissingRequiredField { .. } | ||||||
|  |             | errors::ConnectorError::MissingRequiredFields { .. } | ||||||
|  |             | errors::ConnectorError::FailedToObtainAuthType | ||||||
|  |             | errors::ConnectorError::FailedToObtainCertificate | ||||||
|  |             | errors::ConnectorError::NoConnectorMetaData | ||||||
|  |             | errors::ConnectorError::FailedToObtainCertificateKey | ||||||
|  |             | errors::ConnectorError::NotSupported { .. } | ||||||
|  |             | errors::ConnectorError::FlowNotSupported { .. } | ||||||
|  |             | errors::ConnectorError::CaptureMethodNotSupported | ||||||
|  |             | errors::ConnectorError::MissingConnectorMandateID | ||||||
|  |             | errors::ConnectorError::MissingConnectorTransactionID | ||||||
|  |             | errors::ConnectorError::MissingConnectorRefundID | ||||||
|  |             | errors::ConnectorError::MissingApplePayTokenData | ||||||
|  |             | errors::ConnectorError::WebhooksNotImplemented | ||||||
|  |             | errors::ConnectorError::WebhookBodyDecodingFailed | ||||||
|  |             | errors::ConnectorError::WebhookSignatureNotFound | ||||||
|  |             | errors::ConnectorError::WebhookSourceVerificationFailed | ||||||
|  |             | errors::ConnectorError::WebhookVerificationSecretNotFound | ||||||
|  |             | errors::ConnectorError::WebhookVerificationSecretInvalid | ||||||
|  |             | errors::ConnectorError::WebhookReferenceIdNotFound | ||||||
|  |             | errors::ConnectorError::WebhookEventTypeNotFound | ||||||
|  |             | errors::ConnectorError::WebhookResourceObjectNotFound | ||||||
|  |             | errors::ConnectorError::WebhookResponseEncodingFailed | ||||||
|  |             | errors::ConnectorError::InvalidDateFormat | ||||||
|  |             | errors::ConnectorError::DateFormattingFailed | ||||||
|  |             | errors::ConnectorError::InvalidDataFormat { .. } | ||||||
|  |             | errors::ConnectorError::MismatchedPaymentData | ||||||
|  |             | errors::ConnectorError::InvalidWalletToken | ||||||
|  |             | errors::ConnectorError::MissingConnectorRelatedTransactionID { .. } | ||||||
|  |             | errors::ConnectorError::FileValidationFailed { .. } | ||||||
|  |             | errors::ConnectorError::MissingConnectorRedirectionPayload { .. } | ||||||
|  |             | errors::ConnectorError::FailedAtConnector { .. } | ||||||
|  |             | errors::ConnectorError::MissingPaymentMethodType | ||||||
|  |             | errors::ConnectorError::InSufficientBalanceInPaymentMethod | ||||||
|  |             | errors::ConnectorError::RequestTimeoutReceived | ||||||
|  |             | errors::ConnectorError::CurrencyNotSupported { .. } | ||||||
|  |             | errors::ConnectorError::InvalidConnectorConfig { .. } => { | ||||||
|  |                 err.change_context(errors::ApiErrorResponse::RefundFailed { data: None }) | ||||||
|  |             } | ||||||
|         }) |         }) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Sakil Mostak
					Sakil Mostak