chore: intoduce GenericError enum variant in enum ConnectorError (#6143)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Hrithikesh
2024-10-01 15:37:01 +05:30
committed by GitHub
parent 4dae29221f
commit b694171bab
10 changed files with 19 additions and 90 deletions

View File

@ -0,0 +1,3 @@
---
openapi: get /v2/profiles/{profile_id}/connector_accounts
---

View File

@ -0,0 +1,3 @@
---
openapi: get /v2/merchant_accounts/{account_id}/profiles
---

View File

@ -46,7 +46,7 @@
"api-reference/organization/organization--create", "api-reference/organization/organization--create",
"api-reference/organization/organization--retrieve", "api-reference/organization/organization--retrieve",
"api-reference/organization/organization--update", "api-reference/organization/organization--update",
"api-reference/organization/merchant-account--list" "api-reference/organization/organization--merchant-account--list"
] ]
}, },
{ {

View File

@ -169,7 +169,7 @@
"tags": [ "tags": [
"Organization" "Organization"
], ],
"summary": "Merchant Account - List", "summary": "Organization - Merchant Account - List",
"description": "List merchant accounts for an Organization", "description": "List merchant accounts for an Organization",
"operationId": "List Merchant Accounts", "operationId": "List Merchant Accounts",
"parameters": [ "parameters": [

View File

@ -119,6 +119,11 @@ pub enum ConnectorError {
InvalidConnectorConfig { config: &'static str }, InvalidConnectorConfig { config: &'static str },
#[error("Failed to convert amount to required type")] #[error("Failed to convert amount to required type")]
AmountConversionFailed, AmountConversionFailed,
#[error("Generic Error")]
GenericError {
error_message: String,
error_object: serde_json::Value,
},
} }
impl ConnectorError { impl ConnectorError {

View File

@ -145,7 +145,7 @@ pub async fn organization_retrieve() {}
pub async fn organization_update() {} pub async fn organization_update() {}
#[cfg(feature = "v2")] #[cfg(feature = "v2")]
/// Merchant Account - List /// Organization - Merchant Account - List
/// ///
/// List merchant accounts for an Organization /// List merchant accounts for an Organization
#[utoipa::path( #[utoipa::path(

View File

@ -218,7 +218,8 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError>
| errors::ConnectorError::RequestTimeoutReceived | errors::ConnectorError::RequestTimeoutReceived
| errors::ConnectorError::CurrencyNotSupported { .. } | errors::ConnectorError::CurrencyNotSupported { .. }
| errors::ConnectorError::InvalidConnectorConfig { .. } | errors::ConnectorError::InvalidConnectorConfig { .. }
| errors::ConnectorError::AmountConversionFailed { .. } => { | errors::ConnectorError::AmountConversionFailed { .. }
| errors::ConnectorError::GenericError { .. } => {
err.change_context(errors::ApiErrorResponse::RefundFailed { data: None }) err.change_context(errors::ApiErrorResponse::RefundFailed { data: None })
} }
}) })
@ -314,6 +315,7 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError>
errors::ConnectorError::InSufficientBalanceInPaymentMethod | errors::ConnectorError::InSufficientBalanceInPaymentMethod |
errors::ConnectorError::RequestTimeoutReceived | errors::ConnectorError::RequestTimeoutReceived |
errors::ConnectorError::ProcessingStepFailed(None)| errors::ConnectorError::ProcessingStepFailed(None)|
errors::ConnectorError::GenericError {..} |
errors::ConnectorError::AmountConversionFailed => errors::ApiErrorResponse::InternalServerError errors::ConnectorError::AmountConversionFailed => errors::ApiErrorResponse::InternalServerError
}; };
err.change_context(error) err.change_context(error)
@ -407,7 +409,8 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError>
| errors::ConnectorError::RequestTimeoutReceived | errors::ConnectorError::RequestTimeoutReceived
| errors::ConnectorError::CurrencyNotSupported { .. } | errors::ConnectorError::CurrencyNotSupported { .. }
| errors::ConnectorError::ProcessingStepFailed(None) | errors::ConnectorError::ProcessingStepFailed(None)
| errors::ConnectorError::AmountConversionFailed { .. } => { | errors::ConnectorError::AmountConversionFailed { .. }
| errors::ConnectorError::GenericError { .. } => {
logger::error!(%error,"Setup Mandate flow failed"); logger::error!(%error,"Setup Mandate flow failed");
errors::ApiErrorResponse::PaymentAuthorizationFailed { data: None } errors::ApiErrorResponse::PaymentAuthorizationFailed { data: None }
} }

View File

@ -439,71 +439,6 @@ impl api::ConnectorCommon for ConnectorEnum {
} }
} }
impl<T, ResourceCommonData, Req, Resp> api::ConnectorCommon
for ConnectorIntegrationEnum<'_, T, ResourceCommonData, Req, Resp>
{
fn id(&self) -> &'static str {
match self {
ConnectorIntegrationEnum::Old(old_integration) => old_integration.id(),
ConnectorIntegrationEnum::New(new_integration) => new_integration.id(),
}
}
fn get_currency_unit(&self) -> CurrencyUnit {
match self {
ConnectorIntegrationEnum::Old(old_integration) => old_integration.get_currency_unit(),
ConnectorIntegrationEnum::New(new_integration) => new_integration.get_currency_unit(),
}
}
fn get_auth_header(
&self,
auth_type: &types::ConnectorAuthType,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
match self {
ConnectorIntegrationEnum::Old(old_integration) => {
old_integration.get_auth_header(auth_type)
}
ConnectorIntegrationEnum::New(new_integration) => {
new_integration.get_auth_header(auth_type)
}
}
}
fn common_get_content_type(&self) -> &'static str {
match self {
ConnectorIntegrationEnum::Old(old_integration) => {
old_integration.common_get_content_type()
}
ConnectorIntegrationEnum::New(new_integration) => {
new_integration.common_get_content_type()
}
}
}
fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {
match self {
ConnectorIntegrationEnum::Old(old_integration) => old_integration.base_url(connectors),
ConnectorIntegrationEnum::New(new_integration) => new_integration.base_url(connectors),
}
}
fn build_error_response(
&self,
res: types::Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<types::ErrorResponse, errors::ConnectorError> {
match self {
ConnectorIntegrationEnum::Old(old_integration) => {
old_integration.build_error_response(res, event_builder)
}
ConnectorIntegrationEnum::New(new_integration) => {
new_integration.build_error_response(res, event_builder)
}
}
}
}
pub trait ConnectorIntegrationInterface<F, ResourceCommonData, Req, Resp>: Send + Sync { pub trait ConnectorIntegrationInterface<F, ResourceCommonData, Req, Resp>: Send + Sync {
fn clone_box( fn clone_box(
&self, &self,

View File

@ -94,57 +94,37 @@ pub trait Router {}
pub trait Connector: pub trait Connector:
Send Send
+ Refund + Refund
+ RefundV2
+ Payment + Payment
+ PaymentV2
+ ConnectorRedirectResponse + ConnectorRedirectResponse
+ IncomingWebhook + IncomingWebhook
+ ConnectorAccessToken + ConnectorAccessToken
+ ConnectorAccessTokenV2
+ Dispute + Dispute
+ DisputeV2
+ FileUpload + FileUpload
+ FileUploadV2
+ ConnectorTransactionId + ConnectorTransactionId
+ Payouts + Payouts
+ PayoutsV2
+ ConnectorVerifyWebhookSource + ConnectorVerifyWebhookSource
+ ConnectorVerifyWebhookSourceV2
+ FraudCheck + FraudCheck
+ FraudCheckV2
+ ConnectorMandateRevoke + ConnectorMandateRevoke
+ ConnectorMandateRevokeV2
+ ExternalAuthentication + ExternalAuthentication
+ ExternalAuthenticationV2
+ TaxCalculation + TaxCalculation
{ {
} }
impl< impl<
T: Refund T: Refund
+ RefundV2
+ Payment + Payment
+ PaymentV2
+ ConnectorRedirectResponse + ConnectorRedirectResponse
+ Send + Send
+ IncomingWebhook + IncomingWebhook
+ ConnectorAccessToken + ConnectorAccessToken
+ ConnectorAccessTokenV2
+ Dispute + Dispute
+ DisputeV2
+ FileUpload + FileUpload
+ FileUploadV2
+ ConnectorTransactionId + ConnectorTransactionId
+ Payouts + Payouts
+ PayoutsV2
+ ConnectorVerifyWebhookSource + ConnectorVerifyWebhookSource
+ ConnectorVerifyWebhookSourceV2
+ FraudCheck + FraudCheck
+ FraudCheckV2
+ ConnectorMandateRevoke + ConnectorMandateRevoke
+ ConnectorMandateRevokeV2
+ ExternalAuthentication + ExternalAuthentication
+ ExternalAuthenticationV2
+ TaxCalculation, + TaxCalculation,
> Connector for T > Connector for T
{ {