mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
Docs: Updating Error codes for documentation purposes (#5314)
Co-authored-by: Gorakhnath Yadav <gorakhcodes@gmail.com> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -19,9 +19,145 @@ pub enum ErrorType {
|
||||
LockTimeout,
|
||||
}
|
||||
|
||||
// CE Connector Error Errors originating from connector's end
|
||||
// HE Hyperswitch Error Errors originating from Hyperswitch's end
|
||||
// IR Invalid Request Error Error caused due to invalid fields and values in API request
|
||||
// WE Webhook Error Errors related to Webhooks
|
||||
#[derive(Debug, Clone, router_derive::ApiError)]
|
||||
#[error(error_type_enum = ErrorType)]
|
||||
pub enum ApiErrorResponse {
|
||||
#[error(error_type = ErrorType::ConnectorError, code = "CE_00", message = "{code}: {message}", ignore = "status_code")]
|
||||
ExternalConnectorError {
|
||||
code: String,
|
||||
message: String,
|
||||
connector: String,
|
||||
status_code: u16,
|
||||
reason: Option<String>,
|
||||
},
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_01", message = "Payment failed during authorization with connector. Retry payment")]
|
||||
PaymentAuthorizationFailed { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_02", message = "Payment failed during authentication with connector. Retry payment")]
|
||||
PaymentAuthenticationFailed { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_03", message = "Capture attempt failed while processing with connector")]
|
||||
PaymentCaptureFailed { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_04", message = "The card data is invalid")]
|
||||
InvalidCardData { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_05", message = "The card has expired")]
|
||||
CardExpired { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_06", message = "Refund failed while processing with connector. Retry refund")]
|
||||
RefundFailed { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_07", message = "Verification failed while processing with connector. Retry operation")]
|
||||
VerificationFailed { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_08", message = "Dispute operation failed while processing with connector. Retry operation")]
|
||||
DisputeFailed { data: Option<serde_json::Value> },
|
||||
|
||||
#[error(error_type = ErrorType::LockTimeout, code = "HE_00", message = "Resource is busy. Please try again later.")]
|
||||
ResourceBusy,
|
||||
#[error(error_type = ErrorType::ServerNotAvailable, code = "HE_00", message = "Something went wrong")]
|
||||
InternalServerError,
|
||||
#[error(error_type = ErrorType::ServerNotAvailable, code= "HE_00", message = "{component} health check is failing with error: {message}")]
|
||||
HealthCheckError {
|
||||
component: &'static str,
|
||||
message: String,
|
||||
},
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_00", message = "Failed to convert currency to minor unit")]
|
||||
CurrencyConversionFailed,
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "Duplicate refund request. Refund already attempted with the refund ID")]
|
||||
DuplicateRefundRequest,
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "Duplicate mandate request. Mandate already attempted with the Mandate ID")]
|
||||
DuplicateMandate,
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The merchant account with the specified details already exists in our records")]
|
||||
DuplicateMerchantAccount,
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The merchant connector account with the specified profile_id '{profile_id}' and connector_label '{connector_label}' already exists in our records")]
|
||||
DuplicateMerchantConnectorAccount {
|
||||
profile_id: String,
|
||||
connector_label: String,
|
||||
},
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The payment method with the specified details already exists in our records")]
|
||||
DuplicatePaymentMethod,
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The payment with the specified payment_id already exists in our records")]
|
||||
DuplicatePayment { payment_id: String },
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The payout with the specified payout_id '{payout_id}' already exists in our records")]
|
||||
DuplicatePayout { payout_id: String },
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The config with the specified key already exists in our records")]
|
||||
DuplicateConfig,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Refund does not exist in our records")]
|
||||
RefundNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payment Link does not exist in our records")]
|
||||
PaymentLinkNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Customer does not exist in our records")]
|
||||
CustomerNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Config key does not exist in our records.")]
|
||||
ConfigNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payment does not exist in our records")]
|
||||
PaymentNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payment method does not exist in our records")]
|
||||
PaymentMethodNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Merchant account does not exist in our records")]
|
||||
MerchantAccountNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Merchant connector account does not exist in our records")]
|
||||
MerchantConnectorAccountNotFound { id: String },
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Business profile with the given id '{id}' does not exist in our records")]
|
||||
BusinessProfileNotFound { id: String },
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Poll with the given id '{id}' does not exist in our records")]
|
||||
PollNotFound { id: String },
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Resource ID does not exist in our records")]
|
||||
ResourceIdNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Mandate does not exist in our records")]
|
||||
MandateNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Authentication does not exist in our records")]
|
||||
AuthenticationNotFound { id: String },
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Failed to update mandate")]
|
||||
MandateUpdateFailed,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "API Key does not exist in our records")]
|
||||
ApiKeyNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payout does not exist in our records")]
|
||||
PayoutNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Event does not exist in our records")]
|
||||
EventNotFound,
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Invalid mandate id passed from connector")]
|
||||
MandateSerializationFailed,
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Unable to parse the mandate identifier passed from connector")]
|
||||
MandateDeserializationFailed,
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Return URL is not configured and not passed in payments request")]
|
||||
ReturnUrlUnavailable,
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "This refund is not possible through Hyperswitch. Please raise the refund through {connector} dashboard")]
|
||||
RefundNotPossible { connector: String },
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Mandate Validation Failed" )]
|
||||
MandateValidationFailed { reason: String },
|
||||
#[error(error_type= ErrorType::ValidationError, code = "HE_03", message = "The payment has not succeeded yet. Please pass a successful payment to initiate refund")]
|
||||
PaymentNotSucceeded,
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "The specified merchant connector account is disabled")]
|
||||
MerchantConnectorAccountDisabled,
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "{code}: {message}")]
|
||||
PaymentBlockedError {
|
||||
code: u16,
|
||||
message: String,
|
||||
status: String,
|
||||
reason: String,
|
||||
},
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "File validation failed")]
|
||||
FileValidationFailed { reason: String },
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Dispute status validation failed")]
|
||||
DisputeStatusValidationFailed { reason: String },
|
||||
#[error(error_type= ErrorType::ObjectNotFound, code = "HE_04", message = "Successful payment not found for the given payment id")]
|
||||
SuccessfulPaymentNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "The connector provided in the request is incorrect or not available")]
|
||||
IncorrectConnectorNameGiven,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "Address does not exist in our records")]
|
||||
AddressNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "Dispute does not exist in our records")]
|
||||
DisputeNotFound { dispute_id: String },
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "File does not exist in our records")]
|
||||
FileNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "File not available")]
|
||||
FileNotAvailable,
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "HE_05", message = "Missing tenant id")]
|
||||
MissingTenantId,
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "HE_05", message = "Invalid tenant id: {tenant_id}")]
|
||||
InvalidTenant { tenant_id: String },
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_06", message = "Failed to convert amount to {amount_type} type")]
|
||||
AmountConversionFailed { amount_type: &'static str },
|
||||
#[error(error_type = ErrorType::ServerNotAvailable, code = "IR_00", message = "{message:?}")]
|
||||
NotImplemented { message: NotImplementedMessage },
|
||||
#[error(
|
||||
@ -94,174 +230,11 @@ pub enum ApiErrorResponse {
|
||||
AccessForbidden { resource: String },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_23", message = "{message}")]
|
||||
FileProviderNotSupported { message: String },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_23", message = "{message}")]
|
||||
UnprocessableEntity { message: String },
|
||||
#[error(
|
||||
error_type = ErrorType::ProcessingError, code = "IR_24",
|
||||
message = "Invalid {wallet_name} wallet token"
|
||||
)]
|
||||
InvalidWalletToken { wallet_name: String },
|
||||
#[error(error_type = ErrorType::ConnectorError, code = "CE_00", message = "{code}: {message}", ignore = "status_code")]
|
||||
ExternalConnectorError {
|
||||
code: String,
|
||||
message: String,
|
||||
connector: String,
|
||||
status_code: u16,
|
||||
reason: Option<String>,
|
||||
},
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_01", message = "Payment failed during authorization with connector. Retry payment")]
|
||||
PaymentAuthorizationFailed { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_02", message = "Payment failed during authentication with connector. Retry payment")]
|
||||
PaymentAuthenticationFailed { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_03", message = "Capture attempt failed while processing with connector")]
|
||||
PaymentCaptureFailed { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_04", message = "The card data is invalid")]
|
||||
InvalidCardData { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "CE_04", message = "Payout validation failed")]
|
||||
PayoutFailed { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_05", message = "The card has expired")]
|
||||
CardExpired { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_06", message = "Refund failed while processing with connector. Retry refund")]
|
||||
RefundFailed { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_07", message = "Verification failed while processing with connector. Retry operation")]
|
||||
VerificationFailed { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "CE_08", message = "Dispute operation failed while processing with connector. Retry operation")]
|
||||
DisputeFailed { data: Option<serde_json::Value> },
|
||||
#[error(error_type = ErrorType::ServerNotAvailable, code = "HE_00", message = "Something went wrong")]
|
||||
InternalServerError,
|
||||
#[error(error_type = ErrorType::LockTimeout, code = "HE_00", message = "Resource is busy. Please try again later.")]
|
||||
ResourceBusy,
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "Duplicate refund request. Refund already attempted with the refund ID")]
|
||||
DuplicateRefundRequest,
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "Duplicate mandate request. Mandate already attempted with the Mandate ID")]
|
||||
DuplicateMandate,
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The merchant account with the specified details already exists in our records")]
|
||||
DuplicateMerchantAccount,
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The merchant connector account with the specified profile_id '{profile_id}' and connector_label '{connector_label}' already exists in our records")]
|
||||
DuplicateMerchantConnectorAccount {
|
||||
profile_id: String,
|
||||
connector_label: String,
|
||||
},
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The payment method with the specified details already exists in our records")]
|
||||
DuplicatePaymentMethod,
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The payment with the specified payment_id already exists in our records")]
|
||||
DuplicatePayment { payment_id: String },
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The payout with the specified payout_id '{payout_id}' already exists in our records")]
|
||||
DuplicatePayout { payout_id: String },
|
||||
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The config with the specified key already exists in our records")]
|
||||
DuplicateConfig,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Refund does not exist in our records")]
|
||||
RefundNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Customer does not exist in our records")]
|
||||
CustomerNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "RE_02", message = "Config key does not exist in our records.")]
|
||||
ConfigNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payment does not exist in our records")]
|
||||
PaymentNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payment method does not exist in our records")]
|
||||
PaymentMethodNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Merchant account does not exist in our records")]
|
||||
MerchantAccountNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Merchant connector account does not exist in our records")]
|
||||
MerchantConnectorAccountNotFound { id: String },
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Business profile with the given id '{id}' does not exist in our records")]
|
||||
BusinessProfileNotFound { id: String },
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Poll with the given id '{id}' does not exist in our records")]
|
||||
PollNotFound { id: String },
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Resource ID does not exist in our records")]
|
||||
ResourceIdNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Mandate does not exist in our records")]
|
||||
MandateNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Authentication does not exist in our records")]
|
||||
AuthenticationNotFound { id: String },
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Failed to update mandate")]
|
||||
MandateUpdateFailed,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "API Key does not exist in our records")]
|
||||
ApiKeyNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payout does not exist in our records")]
|
||||
PayoutNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Event does not exist in our records")]
|
||||
EventNotFound,
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Invalid mandate id passed from connector")]
|
||||
MandateSerializationFailed,
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Unable to parse the mandate identifier passed from connector")]
|
||||
MandateDeserializationFailed,
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Return URL is not configured and not passed in payments request")]
|
||||
ReturnUrlUnavailable,
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "This refund is not possible through Hyperswitch. Please raise the refund through {connector} dashboard")]
|
||||
RefundNotPossible { connector: String },
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Mandate Validation Failed" )]
|
||||
MandateValidationFailed { reason: String },
|
||||
#[error(error_type= ErrorType::ValidationError, code = "HE_03", message = "The payment has not succeeded yet. Please pass a successful payment to initiate refund")]
|
||||
PaymentNotSucceeded,
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "The specified merchant connector account is disabled")]
|
||||
MerchantConnectorAccountDisabled,
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "{code}: {message}")]
|
||||
PaymentBlockedError {
|
||||
code: u16,
|
||||
message: String,
|
||||
status: String,
|
||||
reason: String,
|
||||
},
|
||||
#[error(error_type= ErrorType::ObjectNotFound, code = "HE_04", message = "Successful payment not found for the given payment id")]
|
||||
SuccessfulPaymentNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "The connector provided in the request is incorrect or not available")]
|
||||
IncorrectConnectorNameGiven,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "Address does not exist in our records")]
|
||||
AddressNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "Dispute does not exist in our records")]
|
||||
DisputeNotFound { dispute_id: String },
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "File does not exist in our records")]
|
||||
FileNotFound,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "File not available")]
|
||||
FileNotAvailable,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "HE_04", message = "Dispute status validation failed")]
|
||||
DisputeStatusValidationFailed { reason: String },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "HE_04", message = "Card with the provided iin does not exist")]
|
||||
InvalidCardIin,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "HE_04", message = "The provided card IIN length is invalid, please provide an iin with 6 or 8 digits")]
|
||||
InvalidCardIinLength,
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "File validation failed")]
|
||||
FileValidationFailed { reason: String },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "HE_04", message = "File not found / valid in the request")]
|
||||
MissingFile,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "HE_04", message = "Dispute id not found in the request")]
|
||||
MissingDisputeId,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "HE_04", message = "File purpose not found in the request or is invalid")]
|
||||
MissingFilePurpose,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "HE_04", message = "File content type not found / valid")]
|
||||
MissingFileContentType,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "HE_05", message = "{message}")]
|
||||
GenericNotFoundError { message: String },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "HE_01", message = "{message}")]
|
||||
GenericDuplicateError { message: String },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_01", message = "Failed to authenticate the webhook")]
|
||||
WebhookAuthenticationFailed,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "WE_04", message = "Webhook resource not found")]
|
||||
WebhookResourceNotFound,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_02", message = "Bad request received in webhook")]
|
||||
WebhookBadRequest,
|
||||
#[error(error_type = ErrorType::RouterError, code = "WE_03", message = "There was some issue processing the webhook")]
|
||||
WebhookProcessingFailure,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "HE_04", message = "required payment method is not configured or configured incorrectly for all configured connectors")]
|
||||
IncorrectPaymentMethodConfiguration,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_05", message = "Unable to process the webhook body")]
|
||||
WebhookUnprocessableEntity,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payment Link does not exist in our records")]
|
||||
PaymentLinkNotFound,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_05", message = "Merchant Secret set my merchant for webhook source verification is invalid")]
|
||||
WebhookInvalidMerchantSecret,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_19", message = "{message}")]
|
||||
CurrencyNotSupported { message: String },
|
||||
#[error(error_type = ErrorType::ServerNotAvailable, code= "HE_00", message = "{component} health check is failing with error: {message}")]
|
||||
HealthCheckError {
|
||||
component: &'static str,
|
||||
message: String,
|
||||
},
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_24", message = "Merchant connector account is configured with invalid {config}")]
|
||||
InvalidConnectorConfiguration { config: String },
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_01", message = "Failed to convert currency to minor unit")]
|
||||
CurrencyConversionFailed,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_25", message = "Cannot delete the default payment method")]
|
||||
PaymentMethodDeleteFailed,
|
||||
#[error(
|
||||
@ -272,19 +245,52 @@ pub enum ApiErrorResponse {
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_27", message = "Extended card info does not exist")]
|
||||
ExtendedCardInfoNotFound,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_28", message = "{message}")]
|
||||
CurrencyNotSupported { message: String },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_29", message = "{message}")]
|
||||
UnprocessableEntity { message: String },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_30", message = "Merchant connector account is configured with invalid {config}")]
|
||||
InvalidConnectorConfiguration { config: String },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_31", message = "Card with the provided iin does not exist")]
|
||||
InvalidCardIin,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_32", message = "The provided card IIN length is invalid, please provide an iin with 6 or 8 digits")]
|
||||
InvalidCardIinLength,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_33", message = "File not found / valid in the request")]
|
||||
MissingFile,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_34", message = "Dispute id not found in the request")]
|
||||
MissingDisputeId,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_35", message = "File purpose not found in the request or is invalid")]
|
||||
MissingFilePurpose,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_36", message = "File content type not found / valid")]
|
||||
MissingFileContentType,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_37", message = "{message}")]
|
||||
GenericNotFoundError { message: String },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_38", message = "{message}")]
|
||||
GenericDuplicateError { message: String },
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_39", message = "required payment method is not configured or configured incorrectly for all configured connectors")]
|
||||
IncorrectPaymentMethodConfiguration,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_40", message = "{message}")]
|
||||
LinkConfigurationError { message: String },
|
||||
#[error(error_type = ErrorType::ServerNotAvailable, code = "IE", message = "{reason} as data mismatched for {field_names}", ignore = "status_code")]
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_41", message = "Payout validation failed")]
|
||||
PayoutFailed { data: Option<serde_json::Value> },
|
||||
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_01", message = "Failed to authenticate the webhook")]
|
||||
WebhookAuthenticationFailed,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_02", message = "Bad request received in webhook")]
|
||||
WebhookBadRequest,
|
||||
#[error(error_type = ErrorType::RouterError, code = "WE_03", message = "There was some issue processing the webhook")]
|
||||
WebhookProcessingFailure,
|
||||
#[error(error_type = ErrorType::ObjectNotFound, code = "WE_04", message = "Webhook resource not found")]
|
||||
WebhookResourceNotFound,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_05", message = "Unable to process the webhook body")]
|
||||
WebhookUnprocessableEntity,
|
||||
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_06", message = "Merchant Secret set my merchant for webhook source verification is invalid")]
|
||||
WebhookInvalidMerchantSecret,
|
||||
#[error(error_type = ErrorType::ServerNotAvailable, code = "IE", message = "{reason} as data mismatched for {field_names}")]
|
||||
IntegrityCheckFailed {
|
||||
reason: String,
|
||||
field_names: String,
|
||||
connector_transaction_id: Option<String>,
|
||||
},
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "HE_06", message = "Missing tenant id")]
|
||||
MissingTenantId,
|
||||
#[error(error_type = ErrorType::ProcessingError, code = "HE_06", message = "Invalid tenant id: {tenant_id}")]
|
||||
InvalidTenant { tenant_id: String },
|
||||
#[error(error_type = ErrorType::ValidationError, code = "HE_01", message = "Failed to convert amount to {amount_type} type")]
|
||||
AmountConversionFailed { amount_type: &'static str },
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -322,6 +328,164 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorRespon
|
||||
use api_models::errors::types::{ApiError, ApiErrorResponse as AER};
|
||||
|
||||
match self {
|
||||
Self::ExternalConnectorError {
|
||||
code,
|
||||
message,
|
||||
connector,
|
||||
reason,
|
||||
status_code,
|
||||
} => AER::ConnectorError(ApiError::new("CE", 0, format!("{code}: {message}"), Some(Extra {connector: Some(connector.clone()), reason: reason.to_owned().map(Into::into), ..Default::default()})), StatusCode::from_u16(*status_code).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)),
|
||||
Self::PaymentAuthorizationFailed { data } => {
|
||||
AER::BadRequest(ApiError::new("CE", 1, "Payment failed during authorization with connector. Retry payment", Some(Extra { data: data.clone(), ..Default::default()})))
|
||||
}
|
||||
Self::PaymentAuthenticationFailed { data } => {
|
||||
AER::BadRequest(ApiError::new("CE", 2, "Payment failed during authentication with connector. Retry payment", Some(Extra { data: data.clone(), ..Default::default()})))
|
||||
}
|
||||
Self::PaymentCaptureFailed { data } => {
|
||||
AER::BadRequest(ApiError::new("CE", 3, "Capture attempt failed while processing with connector", Some(Extra { data: data.clone(), ..Default::default()})))
|
||||
}
|
||||
Self::InvalidCardData { data } => AER::BadRequest(ApiError::new("CE", 4, "The card data is invalid", Some(Extra { data: data.clone(), ..Default::default()}))),
|
||||
Self::CardExpired { data } => AER::BadRequest(ApiError::new("CE", 5, "The card has expired", Some(Extra { data: data.clone(), ..Default::default()}))),
|
||||
Self::RefundFailed { data } => AER::BadRequest(ApiError::new("CE", 6, "Refund failed while processing with connector. Retry refund", Some(Extra { data: data.clone(), ..Default::default()}))),
|
||||
Self::VerificationFailed { data } => {
|
||||
AER::BadRequest(ApiError::new("CE", 7, "Verification failed while processing with connector. Retry operation", Some(Extra { data: data.clone(), ..Default::default()})))
|
||||
},
|
||||
Self::DisputeFailed { data } => {
|
||||
AER::BadRequest(ApiError::new("CE", 8, "Dispute operation failed while processing with connector. Retry operation", Some(Extra { data: data.clone(), ..Default::default()})))
|
||||
}
|
||||
|
||||
Self::ResourceBusy => {
|
||||
AER::Unprocessable(ApiError::new("HE", 0, "There was an issue processing the webhook body", None))
|
||||
}
|
||||
Self::CurrencyConversionFailed => {
|
||||
AER::Unprocessable(ApiError::new("HE", 0, "Failed to convert currency to minor unit", None))
|
||||
}
|
||||
Self::InternalServerError => {
|
||||
AER::InternalServerError(ApiError::new("HE", 0, "Something went wrong", None))
|
||||
},
|
||||
Self::HealthCheckError { message,component } => {
|
||||
AER::InternalServerError(ApiError::new("HE",0,format!("{} health check failed with error: {}",component,message),None))
|
||||
},
|
||||
Self::DuplicateRefundRequest => AER::BadRequest(ApiError::new("HE", 1, "Duplicate refund request. Refund already attempted with the refund ID", None)),
|
||||
Self::DuplicateMandate => AER::BadRequest(ApiError::new("HE", 1, "Duplicate mandate request. Mandate already attempted with the Mandate ID", None)),
|
||||
Self::DuplicateMerchantAccount => AER::BadRequest(ApiError::new("HE", 1, "The merchant account with the specified details already exists in our records", None)),
|
||||
Self::DuplicateMerchantConnectorAccount { profile_id, connector_label: connector_name } => {
|
||||
AER::BadRequest(ApiError::new("HE", 1, format!("The merchant connector account with the specified profile_id '{profile_id}' and connector_label '{connector_name}' already exists in our records"), None))
|
||||
}
|
||||
Self::DuplicatePaymentMethod => AER::BadRequest(ApiError::new("HE", 1, "The payment method with the specified details already exists in our records", None)),
|
||||
Self::DuplicatePayment { payment_id } => {
|
||||
AER::BadRequest(ApiError::new("HE", 1, "The payment with the specified payment_id already exists in our records", Some(Extra {reason: Some(format!("{payment_id} already exists")), ..Default::default()})))
|
||||
}
|
||||
Self::DuplicatePayout { payout_id } => {
|
||||
AER::BadRequest(ApiError::new("HE", 1, format!("The payout with the specified payout_id '{payout_id}' already exists in our records"), None))
|
||||
}
|
||||
Self::DuplicateConfig => {
|
||||
AER::BadRequest(ApiError::new("HE", 1, "The config with the specified key already exists in our records", None))
|
||||
}
|
||||
Self::RefundNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Refund does not exist in our records.", None))
|
||||
}
|
||||
Self::PaymentLinkNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Payment Link does not exist in our records", None))
|
||||
}
|
||||
Self::CustomerNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Customer does not exist in our records", None))
|
||||
}
|
||||
Self::ConfigNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Config key does not exist in our records.", None))
|
||||
},
|
||||
Self::PaymentNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Payment does not exist in our records", None))
|
||||
}
|
||||
Self::PaymentMethodNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Payment method does not exist in our records", None))
|
||||
}
|
||||
Self::MerchantAccountNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Merchant account does not exist in our records", None))
|
||||
}
|
||||
Self::MerchantConnectorAccountNotFound {id } => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Merchant connector account does not exist in our records", Some(Extra {reason: Some(format!("{id} does not exist")), ..Default::default()})))
|
||||
}
|
||||
Self::BusinessProfileNotFound { id } => {
|
||||
AER::NotFound(ApiError::new("HE", 2, format!("Business profile with the given id {id} does not exist"), None))
|
||||
}
|
||||
Self::PollNotFound { .. } => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Poll does not exist in our records", None))
|
||||
},
|
||||
Self::ResourceIdNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Resource ID does not exist in our records", None))
|
||||
}
|
||||
Self::MandateNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Mandate does not exist in our records", None))
|
||||
}
|
||||
Self::AuthenticationNotFound { .. } => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Authentication does not exist in our records", None))
|
||||
},
|
||||
Self::MandateUpdateFailed => {
|
||||
AER::InternalServerError(ApiError::new("HE", 2, "Mandate update failed", None))
|
||||
},
|
||||
Self::ApiKeyNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "API Key does not exist in our records", None))
|
||||
}
|
||||
Self::PayoutNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Payout does not exist in our records", None))
|
||||
}
|
||||
Self::EventNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Event does not exist in our records", None))
|
||||
}
|
||||
Self::MandateSerializationFailed | Self::MandateDeserializationFailed => {
|
||||
AER::InternalServerError(ApiError::new("HE", 3, "Something went wrong", None))
|
||||
},
|
||||
Self::ReturnUrlUnavailable => AER::NotFound(ApiError::new("HE", 3, "Return URL is not configured and not passed in payments request", None)),
|
||||
Self::RefundNotPossible { connector } => {
|
||||
AER::BadRequest(ApiError::new("HE", 3, format!("This refund is not possible through Hyperswitch. Please raise the refund through {connector} dashboard"), None))
|
||||
}
|
||||
Self::MandateValidationFailed { reason } => {
|
||||
AER::BadRequest(ApiError::new("HE", 3, "Mandate Validation Failed", Some(Extra { reason: Some(reason.to_owned()), ..Default::default() })))
|
||||
}
|
||||
Self::PaymentNotSucceeded => AER::BadRequest(ApiError::new("HE", 3, "The payment has not succeeded yet. Please pass a successful payment to initiate refund", None)),
|
||||
Self::MerchantConnectorAccountDisabled => {
|
||||
AER::BadRequest(ApiError::new("HE", 3, "The selected merchant connector account is disabled", None))
|
||||
}
|
||||
Self::PaymentBlockedError {
|
||||
message,
|
||||
reason,
|
||||
..
|
||||
} => AER::DomainError(ApiError::new("HE", 3, message, Some(Extra { reason: Some(reason.clone()), ..Default::default() }))),
|
||||
Self::FileValidationFailed { reason } => {
|
||||
AER::BadRequest(ApiError::new("HE", 3, format!("File validation failed {reason}"), None))
|
||||
}
|
||||
Self::DisputeStatusValidationFailed { .. } => {
|
||||
AER::BadRequest(ApiError::new("HE", 3, "Dispute status validation failed", None))
|
||||
}
|
||||
Self::SuccessfulPaymentNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 4, "Successful payment not found for the given payment id", None))
|
||||
}
|
||||
Self::IncorrectConnectorNameGiven => {
|
||||
AER::NotFound(ApiError::new("HE", 4, "The connector provided in the request is incorrect or not available", None))
|
||||
}
|
||||
Self::AddressNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 4, "Address does not exist in our records", None))
|
||||
},
|
||||
Self::DisputeNotFound { .. } => {
|
||||
AER::NotFound(ApiError::new("HE", 4, "Dispute does not exist in our records", None))
|
||||
},
|
||||
Self::FileNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 4, "File does not exist in our records", None))
|
||||
}
|
||||
Self::FileNotAvailable => {
|
||||
AER::NotFound(ApiError::new("HE", 4, "File not available", None))
|
||||
}
|
||||
Self::MissingTenantId => {
|
||||
AER::InternalServerError(ApiError::new("HE", 5, "Missing Tenant ID in the request".to_string(), None))
|
||||
}
|
||||
Self::InvalidTenant { tenant_id } => {
|
||||
AER::InternalServerError(ApiError::new("HE", 5, format!("Invalid Tenant {tenant_id}"), None))
|
||||
}
|
||||
Self::AmountConversionFailed { amount_type } => {
|
||||
AER::InternalServerError(ApiError::new("HE", 6, format!("Failed to convert amount to {amount_type} type"), None))
|
||||
}
|
||||
|
||||
Self::NotImplemented { message } => {
|
||||
AER::NotImplemented(ApiError::new("IR", 0, format!("{message:?}"), None))
|
||||
}
|
||||
@ -364,12 +528,14 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorRespon
|
||||
8,
|
||||
"client_secret was not provided", None
|
||||
)),
|
||||
Self::ClientSecretExpired => AER::BadRequest(ApiError::new(
|
||||
"IR",
|
||||
8,
|
||||
"The provided client_secret has expired", None
|
||||
)),
|
||||
Self::ClientSecretInvalid => {
|
||||
AER::BadRequest(ApiError::new("IR", 9, "The client_secret provided does not match the client_secret associated with the Payment", None))
|
||||
}
|
||||
Self::CurrencyNotSupported { message } => {
|
||||
AER::BadRequest(ApiError::new("IR", 9, message, None))
|
||||
}
|
||||
Self::MandateActive => {
|
||||
AER::BadRequest(ApiError::new("IR", 10, "Customer has active mandate/subsciption", None))
|
||||
}
|
||||
@ -394,11 +560,12 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorRespon
|
||||
Self::GenericUnauthorized { message } => {
|
||||
AER::Unauthorized(ApiError::new("IR", 18, message.to_string(), None))
|
||||
},
|
||||
Self::ClientSecretExpired => AER::BadRequest(ApiError::new(
|
||||
"IR",
|
||||
19,
|
||||
"The provided client_secret has expired", None
|
||||
)),
|
||||
Self::NotSupported { message } => {
|
||||
AER::BadRequest(ApiError::new("IR", 19, "Payment method type not supported", Some(Extra {reason: Some(message.to_owned()), ..Default::default()})))
|
||||
},
|
||||
Self::FlowNotSupported { flow, connector } => {
|
||||
AER::BadRequest(ApiError::new("IR", 20, format!("{flow} flow not supported"), Some(Extra {connector: Some(connector.to_owned()), ..Default::default()}))) //FIXME: error message
|
||||
}
|
||||
Self::MissingRequiredFields { field_names } => AER::BadRequest(
|
||||
ApiError::new("IR", 21, "Missing required params".to_string(), Some(Extra {data: Some(serde_json::json!(field_names)), ..Default::default() })),
|
||||
),
|
||||
@ -408,206 +575,11 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorRespon
|
||||
Self::FileProviderNotSupported { message } => {
|
||||
AER::BadRequest(ApiError::new("IR", 23, message.to_string(), None))
|
||||
},
|
||||
Self::UnprocessableEntity {message} => AER::Unprocessable(ApiError::new("IR", 23, message.to_string(), None)),
|
||||
Self::InvalidWalletToken { wallet_name} => AER::Unprocessable(ApiError::new(
|
||||
"IR",
|
||||
24,
|
||||
format!("Invalid {wallet_name} wallet token"), None
|
||||
)),
|
||||
Self::ExternalConnectorError {
|
||||
code,
|
||||
message,
|
||||
connector,
|
||||
reason,
|
||||
status_code,
|
||||
} => AER::ConnectorError(ApiError::new("CE", 0, format!("{code}: {message}"), Some(Extra {connector: Some(connector.clone()), reason: reason.to_owned().map(Into::into), ..Default::default()})), StatusCode::from_u16(*status_code).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)),
|
||||
Self::PaymentAuthorizationFailed { data } => {
|
||||
AER::BadRequest(ApiError::new("CE", 1, "Payment failed during authorization with connector. Retry payment", Some(Extra { data: data.clone(), ..Default::default()})))
|
||||
}
|
||||
Self::PaymentAuthenticationFailed { data } => {
|
||||
AER::BadRequest(ApiError::new("CE", 2, "Payment failed during authentication with connector. Retry payment", Some(Extra { data: data.clone(), ..Default::default()})))
|
||||
}
|
||||
Self::PaymentCaptureFailed { data } => {
|
||||
AER::BadRequest(ApiError::new("CE", 3, "Capture attempt failed while processing with connector", Some(Extra { data: data.clone(), ..Default::default()})))
|
||||
}
|
||||
Self::DisputeFailed { data } => {
|
||||
AER::BadRequest(ApiError::new("CE", 1, "Dispute operation failed while processing with connector. Retry operation", Some(Extra { data: data.clone(), ..Default::default()})))
|
||||
}
|
||||
Self::InvalidCardData { data } => AER::BadRequest(ApiError::new("CE", 4, "The card data is invalid", Some(Extra { data: data.clone(), ..Default::default()}))),
|
||||
Self::CardExpired { data } => AER::BadRequest(ApiError::new("CE", 5, "The card has expired", Some(Extra { data: data.clone(), ..Default::default()}))),
|
||||
Self::RefundFailed { data } => AER::BadRequest(ApiError::new("CE", 6, "Refund failed while processing with connector. Retry refund", Some(Extra { data: data.clone(), ..Default::default()}))),
|
||||
Self::VerificationFailed { data } => {
|
||||
AER::BadRequest(ApiError::new("CE", 7, "Verification failed while processing with connector. Retry operation", Some(Extra { data: data.clone(), ..Default::default()})))
|
||||
},
|
||||
Self::MandateUpdateFailed | Self::MandateSerializationFailed | Self::MandateDeserializationFailed | Self::InternalServerError => {
|
||||
AER::InternalServerError(ApiError::new("HE", 0, "Something went wrong", None))
|
||||
},
|
||||
Self::HealthCheckError { message,component } => {
|
||||
AER::InternalServerError(ApiError::new("HE",0,format!("{} health check failed with error: {}",component,message),None))
|
||||
},
|
||||
Self::PayoutFailed { data } => {
|
||||
AER::BadRequest(ApiError::new("CE", 4, "Payout failed while processing with connector.", Some(Extra { data: data.clone(), ..Default::default()})))
|
||||
},
|
||||
Self::DuplicateRefundRequest => AER::BadRequest(ApiError::new("HE", 1, "Duplicate refund request. Refund already attempted with the refund ID", None)),
|
||||
Self::DuplicateMandate => AER::BadRequest(ApiError::new("HE", 1, "Duplicate mandate request. Mandate already attempted with the Mandate ID", None)),
|
||||
Self::DuplicateMerchantAccount => AER::BadRequest(ApiError::new("HE", 1, "The merchant account with the specified details already exists in our records", None)),
|
||||
Self::DuplicateMerchantConnectorAccount { profile_id, connector_label: connector_name } => {
|
||||
AER::BadRequest(ApiError::new("HE", 1, format!("The merchant connector account with the specified profile_id '{profile_id}' and connector_label '{connector_name}' already exists in our records"), None))
|
||||
}
|
||||
Self::DuplicatePaymentMethod => AER::BadRequest(ApiError::new("HE", 1, "The payment method with the specified details already exists in our records", None)),
|
||||
Self::DuplicatePayment { payment_id } => {
|
||||
AER::BadRequest(ApiError::new("HE", 1, "The payment with the specified payment_id already exists in our records", Some(Extra {reason: Some(format!("{payment_id} already exists")), ..Default::default()})))
|
||||
}
|
||||
Self::DuplicatePayout { payout_id } => {
|
||||
AER::BadRequest(ApiError::new("HE", 1, format!("The payout with the specified payout_id '{payout_id}' already exists in our records"), None))
|
||||
}
|
||||
Self::GenericDuplicateError { message } => {
|
||||
AER::BadRequest(ApiError::new("HE", 1, message, None))
|
||||
}
|
||||
Self::RefundNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Refund does not exist in our records.", None))
|
||||
}
|
||||
Self::CustomerNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Customer does not exist in our records", None))
|
||||
}
|
||||
Self::ConfigNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Config key does not exist in our records.", None))
|
||||
},
|
||||
Self::DuplicateConfig => {
|
||||
AER::BadRequest(ApiError::new("HE", 1, "The config with the specified key already exists in our records", None))
|
||||
}
|
||||
Self::PaymentNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Payment does not exist in our records", None))
|
||||
}
|
||||
Self::PaymentMethodNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Payment method does not exist in our records", None))
|
||||
}
|
||||
Self::MerchantAccountNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Merchant account does not exist in our records", None))
|
||||
}
|
||||
Self::MerchantConnectorAccountNotFound {id } => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Merchant connector account does not exist in our records", Some(Extra {reason: Some(format!("{id} does not exist")), ..Default::default()})))
|
||||
}
|
||||
Self::MerchantConnectorAccountDisabled => {
|
||||
AER::BadRequest(ApiError::new("HE", 3, "The selected merchant connector account is disabled", None))
|
||||
}
|
||||
Self::ResourceIdNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Resource ID does not exist in our records", None))
|
||||
}
|
||||
Self::MandateNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Mandate does not exist in our records", None))
|
||||
}
|
||||
Self::PayoutNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Payout does not exist in our records", None))
|
||||
}
|
||||
Self::EventNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Event does not exist in our records", None))
|
||||
}
|
||||
Self::ReturnUrlUnavailable => AER::NotFound(ApiError::new("HE", 3, "Return URL is not configured and not passed in payments request", None)),
|
||||
Self::RefundNotPossible { connector } => {
|
||||
AER::BadRequest(ApiError::new("HE", 3, format!("This refund is not possible through Hyperswitch. Please raise the refund through {connector} dashboard"), None))
|
||||
}
|
||||
Self::MandateValidationFailed { reason } => {
|
||||
AER::BadRequest(ApiError::new("HE", 3, "Mandate Validation Failed", Some(Extra { reason: Some(reason.to_owned()), ..Default::default() })))
|
||||
}
|
||||
Self::PaymentNotSucceeded => AER::BadRequest(ApiError::new("HE", 3, "The payment has not succeeded yet. Please pass a successful payment to initiate refund", None)),
|
||||
Self::PaymentBlockedError {
|
||||
message,
|
||||
reason,
|
||||
..
|
||||
} => AER::DomainError(ApiError::new("HE", 3, message, Some(Extra { reason: Some(reason.clone()), ..Default::default() }))),
|
||||
Self::SuccessfulPaymentNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 4, "Successful payment not found for the given payment id", None))
|
||||
}
|
||||
Self::IncorrectConnectorNameGiven => {
|
||||
AER::NotFound(ApiError::new("HE", 4, "The connector provided in the request is incorrect or not available", None))
|
||||
}
|
||||
Self::AddressNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 4, "Address does not exist in our records", None))
|
||||
},
|
||||
Self::GenericNotFoundError { message } => {
|
||||
AER::NotFound(ApiError::new("HE", 5, message, None))
|
||||
},
|
||||
Self::ApiKeyNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "API Key does not exist in our records", None))
|
||||
}
|
||||
Self::NotSupported { message } => {
|
||||
AER::BadRequest(ApiError::new("HE", 3, "Payment method type not supported", Some(Extra {reason: Some(message.to_owned()), ..Default::default()})))
|
||||
},
|
||||
Self::InvalidCardIin => AER::BadRequest(ApiError::new("HE", 3, "The provided card IIN does not exist", None)),
|
||||
Self::InvalidCardIinLength => AER::BadRequest(ApiError::new("HE", 3, "The provided card IIN length is invalid, please provide an IIN with 6 digits", None)),
|
||||
Self::FlowNotSupported { flow, connector } => {
|
||||
AER::BadRequest(ApiError::new("IR", 20, format!("{flow} flow not supported"), Some(Extra {connector: Some(connector.to_owned()), ..Default::default()}))) //FIXME: error message
|
||||
}
|
||||
Self::DisputeNotFound { .. } => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Dispute does not exist in our records", None))
|
||||
},
|
||||
Self::AuthenticationNotFound { .. } => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Authentication does not exist in our records", None))
|
||||
},
|
||||
Self::BusinessProfileNotFound { id } => {
|
||||
AER::NotFound(ApiError::new("HE", 2, format!("Business profile with the given id {id} does not exist"), None))
|
||||
}
|
||||
Self::FileNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "File does not exist in our records", None))
|
||||
}
|
||||
Self::PollNotFound { .. } => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Poll does not exist in our records", None))
|
||||
},
|
||||
Self::FileNotAvailable => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "File not available", None))
|
||||
}
|
||||
Self::DisputeStatusValidationFailed { .. } => {
|
||||
AER::BadRequest(ApiError::new("HE", 2, "Dispute status validation failed", None))
|
||||
}
|
||||
Self::FileValidationFailed { reason } => {
|
||||
AER::BadRequest(ApiError::new("HE", 2, format!("File validation failed {reason}"), None))
|
||||
}
|
||||
Self::MissingFile => {
|
||||
AER::BadRequest(ApiError::new("HE", 2, "File not found in the request", None))
|
||||
}
|
||||
Self::MissingFilePurpose => {
|
||||
AER::BadRequest(ApiError::new("HE", 2, "File purpose not found in the request or is invalid", None))
|
||||
}
|
||||
Self::MissingFileContentType => {
|
||||
AER::BadRequest(ApiError::new("HE", 2, "File content type not found", None))
|
||||
}
|
||||
Self::MissingDisputeId => {
|
||||
AER::BadRequest(ApiError::new("HE", 2, "Dispute id not found in the request", None))
|
||||
}
|
||||
Self::WebhookAuthenticationFailed => {
|
||||
AER::Unauthorized(ApiError::new("WE", 1, "Webhook authentication failed", None))
|
||||
}
|
||||
Self::WebhookResourceNotFound => {
|
||||
AER::NotFound(ApiError::new("WE", 4, "Webhook resource was not found", None))
|
||||
}
|
||||
Self::WebhookBadRequest => {
|
||||
AER::BadRequest(ApiError::new("WE", 2, "Bad request body received", None))
|
||||
}
|
||||
Self::WebhookProcessingFailure => {
|
||||
AER::InternalServerError(ApiError::new("WE", 3, "There was an issue processing the webhook", None))
|
||||
},
|
||||
Self::WebhookInvalidMerchantSecret => {
|
||||
AER::BadRequest(ApiError::new("WE", 2, "Merchant Secret set for webhook source verificartion is invalid", None))
|
||||
}
|
||||
Self::IncorrectPaymentMethodConfiguration => {
|
||||
AER::BadRequest(ApiError::new("HE", 4, "No eligible connector was found for the current payment method configuration", None))
|
||||
}
|
||||
Self::WebhookUnprocessableEntity => {
|
||||
AER::Unprocessable(ApiError::new("WE", 5, "There was an issue processing the webhook body", None))
|
||||
},
|
||||
Self::ResourceBusy => {
|
||||
AER::Unprocessable(ApiError::new("WE", 5, "There was an issue processing the webhook body", None))
|
||||
}
|
||||
Self::PaymentLinkNotFound => {
|
||||
AER::NotFound(ApiError::new("HE", 2, "Payment Link does not exist in our records", None))
|
||||
}
|
||||
Self::InvalidConnectorConfiguration {config} => {
|
||||
AER::BadRequest(ApiError::new("IR", 24, format!("Merchant connector account is configured with invalid {config}"), None))
|
||||
}
|
||||
Self::CurrencyConversionFailed => {
|
||||
AER::Unprocessable(ApiError::new("HE", 2, "Failed to convert currency to minor unit", None))
|
||||
}
|
||||
Self::PaymentMethodDeleteFailed => {
|
||||
AER::BadRequest(ApiError::new("IR", 25, "Cannot delete the default payment method", None))
|
||||
}
|
||||
@ -617,9 +589,61 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorRespon
|
||||
Self::ExtendedCardInfoNotFound => {
|
||||
AER::NotFound(ApiError::new("IR", 27, "Extended card info does not exist", None))
|
||||
}
|
||||
Self::LinkConfigurationError { message } => {
|
||||
Self::CurrencyNotSupported { message } => {
|
||||
AER::BadRequest(ApiError::new("IR", 28, message, None))
|
||||
}
|
||||
Self::UnprocessableEntity {message} => AER::Unprocessable(ApiError::new("IR", 29, message.to_string(), None)),
|
||||
Self::InvalidConnectorConfiguration {config} => {
|
||||
AER::BadRequest(ApiError::new("IR", 30, format!("Merchant connector account is configured with invalid {config}"), None))
|
||||
}
|
||||
Self::InvalidCardIin => AER::BadRequest(ApiError::new("IR", 31, "The provided card IIN does not exist", None)),
|
||||
Self::InvalidCardIinLength => AER::BadRequest(ApiError::new("IR", 32, "The provided card IIN length is invalid, please provide an IIN with 6 digits", None)),
|
||||
Self::MissingFile => {
|
||||
AER::BadRequest(ApiError::new("IR", 33, "File not found in the request", None))
|
||||
}
|
||||
Self::MissingDisputeId => {
|
||||
AER::BadRequest(ApiError::new("IR", 34, "Dispute id not found in the request", None))
|
||||
}
|
||||
Self::MissingFilePurpose => {
|
||||
AER::BadRequest(ApiError::new("IR", 35, "File purpose not found in the request or is invalid", None))
|
||||
}
|
||||
Self::MissingFileContentType => {
|
||||
AER::BadRequest(ApiError::new("IR", 36, "File content type not found", None))
|
||||
}
|
||||
Self::GenericNotFoundError { message } => {
|
||||
AER::NotFound(ApiError::new("IR", 37, message, None))
|
||||
},
|
||||
Self::GenericDuplicateError { message } => {
|
||||
AER::BadRequest(ApiError::new("IR", 38, message, None))
|
||||
}
|
||||
Self::IncorrectPaymentMethodConfiguration => {
|
||||
AER::BadRequest(ApiError::new("IR", 39, "No eligible connector was found for the current payment method configuration", None))
|
||||
}
|
||||
Self::LinkConfigurationError { message } => {
|
||||
AER::BadRequest(ApiError::new("IR", 40, message, None))
|
||||
},
|
||||
Self::PayoutFailed { data } => {
|
||||
AER::BadRequest(ApiError::new("IR", 41, "Payout failed while processing with connector.", Some(Extra { data: data.clone(), ..Default::default()})))
|
||||
},
|
||||
|
||||
Self::WebhookAuthenticationFailed => {
|
||||
AER::Unauthorized(ApiError::new("WE", 1, "Webhook authentication failed", None))
|
||||
}
|
||||
Self::WebhookBadRequest => {
|
||||
AER::BadRequest(ApiError::new("WE", 2, "Bad request body received", None))
|
||||
}
|
||||
Self::WebhookProcessingFailure => {
|
||||
AER::InternalServerError(ApiError::new("WE", 3, "There was an issue processing the webhook", None))
|
||||
},
|
||||
Self::WebhookResourceNotFound => {
|
||||
AER::NotFound(ApiError::new("WE", 4, "Webhook resource was not found", None))
|
||||
}
|
||||
Self::WebhookUnprocessableEntity => {
|
||||
AER::Unprocessable(ApiError::new("WE", 5, "There was an issue processing the webhook body", None))
|
||||
},
|
||||
Self::WebhookInvalidMerchantSecret => {
|
||||
AER::BadRequest(ApiError::new("WE", 6, "Merchant Secret set for webhook source verificartion is invalid", None))
|
||||
}
|
||||
Self::IntegrityCheckFailed {
|
||||
reason,
|
||||
field_names,
|
||||
@ -633,15 +657,6 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorRespon
|
||||
..Default::default()
|
||||
})
|
||||
)),
|
||||
Self::MissingTenantId => {
|
||||
AER::InternalServerError(ApiError::new("HE", 6, "Missing Tenant ID in the request".to_string(), None))
|
||||
}
|
||||
Self::InvalidTenant { tenant_id } => {
|
||||
AER::InternalServerError(ApiError::new("HE", 6, format!("Invalid Tenant {tenant_id}"), None))
|
||||
}
|
||||
Self::AmountConversionFailed { amount_type } => {
|
||||
AER::InternalServerError(ApiError::new("HE", 6, format!("Failed to convert amount to {amount_type} type"), None))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user