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:
Kashif
2023-07-19 23:32:05 +05:30
committed by GitHub
parent e0f4507b10
commit 763e2df3bd
86 changed files with 9326 additions and 221 deletions

View File

@ -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