mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
feat: add payout service (#1665)
Co-authored-by: Kashif <mohammed.kashif@juspay.in> Co-authored-by: Manoj Ghorela <manoj.ghorela@juspay.in> Co-authored-by: Manoj Ghorela <118727120+manoj-juspay@users.noreply.github.com>
This commit is contained in:
@ -52,6 +52,9 @@ pub enum StripeErrorCode {
|
||||
#[error(error_type = StripeErrorType::ApiError, code = "refund_failed", message = "refund has failed")]
|
||||
RefundFailed, // stripe error code
|
||||
|
||||
#[error(error_type = StripeErrorType::ApiError, code = "payout_failed", message = "payout has failed")]
|
||||
PayoutFailed,
|
||||
|
||||
#[error(error_type = StripeErrorType::ApiError, code = "internal_server_error", message = "Server is down")]
|
||||
InternalServerError,
|
||||
|
||||
@ -103,6 +106,12 @@ pub enum StripeErrorCode {
|
||||
#[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such API key")]
|
||||
ApiKeyNotFound,
|
||||
|
||||
#[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such payout")]
|
||||
PayoutNotFound,
|
||||
|
||||
#[error(error_type = StripeErrorType::InvalidRequestError, code = "token_already_used", message = "Duplicate payout request")]
|
||||
DuplicatePayout { payout_id: String },
|
||||
|
||||
#[error(error_type = StripeErrorType::InvalidRequestError, code = "parameter_missing", message = "Return url is not available")]
|
||||
ReturnUrlUnavailable,
|
||||
|
||||
@ -427,6 +436,7 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
|
||||
errors::ApiErrorResponse::CardExpired { data } => Self::ExpiredCard,
|
||||
errors::ApiErrorResponse::RefundNotPossible { connector } => Self::RefundFailed,
|
||||
errors::ApiErrorResponse::RefundFailed { data } => Self::RefundFailed, // Nothing at stripe to map
|
||||
errors::ApiErrorResponse::PayoutFailed { data } => Self::PayoutFailed,
|
||||
|
||||
errors::ApiErrorResponse::MandateUpdateFailed
|
||||
| errors::ApiErrorResponse::MandateSerializationFailed
|
||||
@ -451,6 +461,9 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
|
||||
errors::ApiErrorResponse::CustomerRedacted => Self::CustomerRedacted, //not a stripe code
|
||||
errors::ApiErrorResponse::ConfigNotFound => Self::ConfigNotFound, // not a stripe code
|
||||
errors::ApiErrorResponse::DuplicateRefundRequest => Self::DuplicateRefundRequest,
|
||||
errors::ApiErrorResponse::DuplicatePayout { payout_id } => {
|
||||
Self::DuplicatePayout { payout_id }
|
||||
}
|
||||
errors::ApiErrorResponse::RefundNotFound => Self::RefundNotFound,
|
||||
errors::ApiErrorResponse::CustomerNotFound => Self::CustomerNotFound,
|
||||
errors::ApiErrorResponse::PaymentNotFound => Self::PaymentNotFound,
|
||||
@ -464,6 +477,7 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
|
||||
}
|
||||
errors::ApiErrorResponse::MandateNotFound => Self::MandateNotFound,
|
||||
errors::ApiErrorResponse::ApiKeyNotFound => Self::ApiKeyNotFound,
|
||||
errors::ApiErrorResponse::PayoutNotFound => Self::PayoutNotFound,
|
||||
errors::ApiErrorResponse::MandateValidationFailed { reason } => {
|
||||
Self::PaymentIntentMandateInvalid { message: reason }
|
||||
}
|
||||
@ -557,6 +571,7 @@ impl actix_web::ResponseError for StripeErrorCode {
|
||||
| Self::ExpiredCard
|
||||
| Self::InvalidCardType
|
||||
| Self::DuplicateRefundRequest
|
||||
| Self::DuplicatePayout { .. }
|
||||
| Self::RefundNotFound
|
||||
| Self::CustomerNotFound
|
||||
| Self::ConfigNotFound
|
||||
@ -568,6 +583,7 @@ impl actix_web::ResponseError for StripeErrorCode {
|
||||
| Self::MerchantConnectorAccountDisabled
|
||||
| Self::MandateNotFound
|
||||
| Self::ApiKeyNotFound
|
||||
| Self::PayoutNotFound
|
||||
| Self::DuplicateMerchantAccount
|
||||
| Self::DuplicateMerchantConnectorAccount { .. }
|
||||
| Self::DuplicatePaymentMethod
|
||||
@ -598,6 +614,7 @@ impl actix_web::ResponseError for StripeErrorCode {
|
||||
| Self::FileProviderNotSupported
|
||||
| Self::PaymentMethodUnactivated => StatusCode::BAD_REQUEST,
|
||||
Self::RefundFailed
|
||||
| Self::PayoutFailed
|
||||
| Self::InternalServerError
|
||||
| Self::MandateActive
|
||||
| Self::CustomerRedacted
|
||||
|
||||
@ -263,7 +263,11 @@ impl TryFrom<StripePaymentIntentRequest> for payments::PaymentsRequest {
|
||||
type Error = error_stack::Report<errors::ApiErrorResponse>;
|
||||
fn try_from(item: StripePaymentIntentRequest) -> errors::RouterResult<Self> {
|
||||
let routable_connector: Option<api_enums::RoutableConnectors> =
|
||||
item.connector.and_then(|v| v.into_iter().next());
|
||||
item.connector.and_then(|v| {
|
||||
v.into_iter()
|
||||
.next()
|
||||
.map(api_enums::RoutableConnectors::from)
|
||||
});
|
||||
|
||||
let routing = routable_connector
|
||||
.map(crate::types::api::RoutingAlgorithm::Single)
|
||||
|
||||
@ -154,7 +154,11 @@ impl TryFrom<StripeSetupIntentRequest> for payments::PaymentsRequest {
|
||||
type Error = error_stack::Report<errors::ApiErrorResponse>;
|
||||
fn try_from(item: StripeSetupIntentRequest) -> errors::RouterResult<Self> {
|
||||
let routable_connector: Option<api_enums::RoutableConnectors> =
|
||||
item.connector.and_then(|v| v.into_iter().next());
|
||||
item.connector.and_then(|v| {
|
||||
v.into_iter()
|
||||
.next()
|
||||
.map(api_enums::RoutableConnectors::from)
|
||||
});
|
||||
|
||||
let routing = routable_connector
|
||||
.map(api_types::RoutingAlgorithm::Single)
|
||||
|
||||
Reference in New Issue
Block a user