feat: handle no connector txn id (#39)

This commit is contained in:
Sangamesh Kulkarni
2022-12-01 16:53:30 +05:30
committed by GitHub
parent 473d8f7a1b
commit f47c06a517
13 changed files with 94 additions and 27 deletions

View File

@ -67,6 +67,9 @@ pub(crate) enum ErrorCode {
#[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such merchant account")]
MerchantAccountNotFound,
#[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such resource ID")]
ResourceIdNotFound,
#[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such merchant connector account")]
MerchantConnectorAccountNotFound,
@ -327,6 +330,7 @@ impl From<ApiErrorResponse> for ErrorCode {
ApiErrorResponse::PaymentNotFound => ErrorCode::PaymentNotFound,
ApiErrorResponse::PaymentMethodNotFound => ErrorCode::PaymentMethodNotFound,
ApiErrorResponse::MerchantAccountNotFound => ErrorCode::MerchantAccountNotFound,
ApiErrorResponse::ResourceIdNotFound => ErrorCode::ResourceIdNotFound,
ApiErrorResponse::MerchantConnectorAccountNotFound => {
ErrorCode::MerchantConnectorAccountNotFound
}
@ -402,6 +406,7 @@ impl actix_web::ResponseError for ErrorCode {
| ErrorCode::DuplicateMandate
| ErrorCode::SuccessfulPaymentNotFound
| ErrorCode::AddressNotFound
| ErrorCode::ResourceIdNotFound
| ErrorCode::PaymentIntentUnexpectedState { .. } => StatusCode::BAD_REQUEST,
ErrorCode::RefundFailed | ErrorCode::InternalServerError => {
StatusCode::INTERNAL_SERVER_ERROR