mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
refactor(router): make stripe compatibility and certain core routes public (#190)
This commit is contained in:
@ -10,7 +10,7 @@ use crate::routes;
|
|||||||
pub struct StripeApis;
|
pub struct StripeApis;
|
||||||
|
|
||||||
impl StripeApis {
|
impl StripeApis {
|
||||||
pub(crate) fn server(state: routes::AppState) -> Scope {
|
pub fn server(state: routes::AppState) -> Scope {
|
||||||
let max_depth = 10;
|
let max_depth = 10;
|
||||||
let strict = false;
|
let strict = false;
|
||||||
web::scope("/vs/v1")
|
web::scope("/vs/v1")
|
||||||
|
|||||||
@ -23,13 +23,21 @@ pub async fn customer_create(
|
|||||||
let payload: types::CreateCustomerRequest = match qs_config.deserialize_bytes(&form_payload) {
|
let payload: types::CreateCustomerRequest = match qs_config.deserialize_bytes(&form_payload) {
|
||||||
Ok(p) => p,
|
Ok(p) => p,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return api::log_and_return_error_response(report!(errors::ErrorCode::from(err)))
|
return api::log_and_return_error_response(report!(errors::StripeErrorCode::from(err)))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let create_cust_req: customer_types::CustomerRequest = payload.into();
|
let create_cust_req: customer_types::CustomerRequest = payload.into();
|
||||||
|
|
||||||
wrap::compatibility_api_wrap::<_, _, _, _, _, types::CreateCustomerResponse, errors::ErrorCode>(
|
wrap::compatibility_api_wrap::<
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
types::CreateCustomerResponse,
|
||||||
|
errors::StripeErrorCode,
|
||||||
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
create_cust_req,
|
create_cust_req,
|
||||||
@ -52,7 +60,15 @@ pub async fn customer_retrieve(
|
|||||||
customer_id: path.into_inner(),
|
customer_id: path.into_inner(),
|
||||||
};
|
};
|
||||||
|
|
||||||
wrap::compatibility_api_wrap::<_, _, _, _, _, types::CustomerRetrieveResponse, errors::ErrorCode>(
|
wrap::compatibility_api_wrap::<
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
types::CustomerRetrieveResponse,
|
||||||
|
errors::StripeErrorCode,
|
||||||
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
payload,
|
payload,
|
||||||
@ -76,7 +92,7 @@ pub async fn customer_update(
|
|||||||
let payload: types::CustomerUpdateRequest = match qs_config.deserialize_bytes(&form_payload) {
|
let payload: types::CustomerUpdateRequest = match qs_config.deserialize_bytes(&form_payload) {
|
||||||
Ok(p) => p,
|
Ok(p) => p,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return api::log_and_return_error_response(report!(errors::ErrorCode::from(err)))
|
return api::log_and_return_error_response(report!(errors::StripeErrorCode::from(err)))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -84,7 +100,15 @@ pub async fn customer_update(
|
|||||||
let mut cust_update_req: customer_types::CustomerRequest = payload.into();
|
let mut cust_update_req: customer_types::CustomerRequest = payload.into();
|
||||||
cust_update_req.customer_id = customer_id;
|
cust_update_req.customer_id = customer_id;
|
||||||
|
|
||||||
wrap::compatibility_api_wrap::<_, _, _, _, _, types::CustomerUpdateResponse, errors::ErrorCode>(
|
wrap::compatibility_api_wrap::<
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
types::CustomerUpdateResponse,
|
||||||
|
errors::StripeErrorCode,
|
||||||
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
cust_update_req,
|
cust_update_req,
|
||||||
@ -107,7 +131,15 @@ pub async fn customer_delete(
|
|||||||
customer_id: path.into_inner(),
|
customer_id: path.into_inner(),
|
||||||
};
|
};
|
||||||
|
|
||||||
wrap::compatibility_api_wrap::<_, _, _, _, _, types::CustomerDeleteResponse, errors::ErrorCode>(
|
wrap::compatibility_api_wrap::<
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
types::CustomerDeleteResponse,
|
||||||
|
errors::StripeErrorCode,
|
||||||
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
payload,
|
payload,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use crate::core::errors;
|
|||||||
|
|
||||||
#[derive(Debug, router_derive::ApiError)]
|
#[derive(Debug, router_derive::ApiError)]
|
||||||
#[error(error_type_enum = StripeErrorType)]
|
#[error(error_type_enum = StripeErrorType)]
|
||||||
pub(crate) enum ErrorCode {
|
pub enum StripeErrorCode {
|
||||||
/*
|
/*
|
||||||
"error": {
|
"error": {
|
||||||
"message": "Invalid API Key provided: sk_jkjgs****nlgs",
|
"message": "Invalid API Key provided: sk_jkjgs****nlgs",
|
||||||
@ -291,7 +291,7 @@ pub(crate) enum ErrorCode {
|
|||||||
// TransfersNotAllowed,
|
// TransfersNotAllowed,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Display for ErrorCode {
|
impl ::core::fmt::Display for StripeErrorCode {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
@ -304,21 +304,21 @@ impl ::core::fmt::Display for ErrorCode {
|
|||||||
#[derive(Clone, Debug, serde::Serialize)]
|
#[derive(Clone, Debug, serde::Serialize)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
#[allow(clippy::enum_variant_names)]
|
#[allow(clippy::enum_variant_names)]
|
||||||
pub(crate) enum StripeErrorType {
|
pub enum StripeErrorType {
|
||||||
ApiError,
|
ApiError,
|
||||||
CardError,
|
CardError,
|
||||||
InvalidRequestError,
|
InvalidRequestError,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<errors::ApiErrorResponse> for ErrorCode {
|
impl From<errors::ApiErrorResponse> for StripeErrorCode {
|
||||||
fn from(value: errors::ApiErrorResponse) -> Self {
|
fn from(value: errors::ApiErrorResponse) -> Self {
|
||||||
match value {
|
match value {
|
||||||
errors::ApiErrorResponse::Unauthorized
|
errors::ApiErrorResponse::Unauthorized
|
||||||
| errors::ApiErrorResponse::InvalidEphermeralKey => ErrorCode::Unauthorized,
|
| errors::ApiErrorResponse::InvalidEphermeralKey => StripeErrorCode::Unauthorized,
|
||||||
errors::ApiErrorResponse::InvalidRequestUrl
|
errors::ApiErrorResponse::InvalidRequestUrl
|
||||||
| errors::ApiErrorResponse::InvalidHttpMethod => ErrorCode::InvalidRequestUrl,
|
| errors::ApiErrorResponse::InvalidHttpMethod => StripeErrorCode::InvalidRequestUrl,
|
||||||
errors::ApiErrorResponse::MissingRequiredField { field_name } => {
|
errors::ApiErrorResponse::MissingRequiredField { field_name } => {
|
||||||
ErrorCode::ParameterMissing {
|
StripeErrorCode::ParameterMissing {
|
||||||
field_name: field_name.to_owned(),
|
field_name: field_name.to_owned(),
|
||||||
param: field_name,
|
param: field_name,
|
||||||
}
|
}
|
||||||
@ -327,88 +327,98 @@ impl From<errors::ApiErrorResponse> for ErrorCode {
|
|||||||
errors::ApiErrorResponse::InvalidDataFormat {
|
errors::ApiErrorResponse::InvalidDataFormat {
|
||||||
field_name,
|
field_name,
|
||||||
expected_format,
|
expected_format,
|
||||||
} => ErrorCode::ParameterUnknown {
|
} => StripeErrorCode::ParameterUnknown {
|
||||||
field_name,
|
field_name,
|
||||||
expected_format,
|
expected_format,
|
||||||
},
|
},
|
||||||
errors::ApiErrorResponse::RefundAmountExceedsPaymentAmount => {
|
errors::ApiErrorResponse::RefundAmountExceedsPaymentAmount => {
|
||||||
ErrorCode::RefundAmountExceedsPaymentAmount {
|
StripeErrorCode::RefundAmountExceedsPaymentAmount {
|
||||||
param: "amount".to_owned(),
|
param: "amount".to_owned(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
errors::ApiErrorResponse::PaymentAuthorizationFailed { data }
|
errors::ApiErrorResponse::PaymentAuthorizationFailed { data }
|
||||||
| errors::ApiErrorResponse::PaymentAuthenticationFailed { data } => {
|
| errors::ApiErrorResponse::PaymentAuthenticationFailed { data } => {
|
||||||
ErrorCode::PaymentIntentAuthenticationFailure { data }
|
StripeErrorCode::PaymentIntentAuthenticationFailure { data }
|
||||||
}
|
}
|
||||||
errors::ApiErrorResponse::VerificationFailed { data } => {
|
errors::ApiErrorResponse::VerificationFailed { data } => {
|
||||||
ErrorCode::VerificationFailed { data }
|
StripeErrorCode::VerificationFailed { data }
|
||||||
}
|
}
|
||||||
errors::ApiErrorResponse::PaymentCaptureFailed { data } => {
|
errors::ApiErrorResponse::PaymentCaptureFailed { data } => {
|
||||||
ErrorCode::PaymentIntentPaymentAttemptFailed { data }
|
StripeErrorCode::PaymentIntentPaymentAttemptFailed { data }
|
||||||
}
|
}
|
||||||
errors::ApiErrorResponse::InvalidCardData { data } => ErrorCode::InvalidCardType, // Maybe it is better to de generalize this router error
|
errors::ApiErrorResponse::InvalidCardData { data } => StripeErrorCode::InvalidCardType, // Maybe it is better to de generalize this router error
|
||||||
errors::ApiErrorResponse::CardExpired { data } => ErrorCode::ExpiredCard,
|
errors::ApiErrorResponse::CardExpired { data } => StripeErrorCode::ExpiredCard,
|
||||||
errors::ApiErrorResponse::RefundFailed { data } => ErrorCode::RefundFailed, // Nothing at stripe to map
|
errors::ApiErrorResponse::RefundFailed { data } => StripeErrorCode::RefundFailed, // Nothing at stripe to map
|
||||||
|
|
||||||
errors::ApiErrorResponse::InternalServerError => ErrorCode::InternalServerError, // not a stripe code
|
errors::ApiErrorResponse::InternalServerError => StripeErrorCode::InternalServerError, // not a stripe code
|
||||||
errors::ApiErrorResponse::IncorrectConnectorNameGiven => ErrorCode::InternalServerError,
|
errors::ApiErrorResponse::IncorrectConnectorNameGiven => {
|
||||||
errors::ApiErrorResponse::MandateActive => ErrorCode::MandateActive, //not a stripe code
|
StripeErrorCode::InternalServerError
|
||||||
errors::ApiErrorResponse::CustomerRedacted => ErrorCode::CustomerRedacted, //not a stripe code
|
}
|
||||||
errors::ApiErrorResponse::DuplicateRefundRequest => ErrorCode::DuplicateRefundRequest,
|
errors::ApiErrorResponse::MandateActive => StripeErrorCode::MandateActive, //not a stripe code
|
||||||
errors::ApiErrorResponse::RefundNotFound => ErrorCode::RefundNotFound,
|
errors::ApiErrorResponse::CustomerRedacted => StripeErrorCode::CustomerRedacted, //not a stripe code
|
||||||
errors::ApiErrorResponse::CustomerNotFound => ErrorCode::CustomerNotFound,
|
errors::ApiErrorResponse::DuplicateRefundRequest => {
|
||||||
errors::ApiErrorResponse::PaymentNotFound => ErrorCode::PaymentNotFound,
|
StripeErrorCode::DuplicateRefundRequest
|
||||||
errors::ApiErrorResponse::PaymentMethodNotFound => ErrorCode::PaymentMethodNotFound,
|
}
|
||||||
errors::ApiErrorResponse::ClientSecretNotGiven => ErrorCode::ClientSecretNotFound,
|
errors::ApiErrorResponse::RefundNotFound => StripeErrorCode::RefundNotFound,
|
||||||
errors::ApiErrorResponse::MerchantAccountNotFound => ErrorCode::MerchantAccountNotFound,
|
errors::ApiErrorResponse::CustomerNotFound => StripeErrorCode::CustomerNotFound,
|
||||||
errors::ApiErrorResponse::ResourceIdNotFound => ErrorCode::ResourceIdNotFound,
|
errors::ApiErrorResponse::PaymentNotFound => StripeErrorCode::PaymentNotFound,
|
||||||
|
errors::ApiErrorResponse::PaymentMethodNotFound => {
|
||||||
|
StripeErrorCode::PaymentMethodNotFound
|
||||||
|
}
|
||||||
|
errors::ApiErrorResponse::ClientSecretNotGiven => StripeErrorCode::ClientSecretNotFound,
|
||||||
|
errors::ApiErrorResponse::MerchantAccountNotFound => {
|
||||||
|
StripeErrorCode::MerchantAccountNotFound
|
||||||
|
}
|
||||||
|
errors::ApiErrorResponse::ResourceIdNotFound => StripeErrorCode::ResourceIdNotFound,
|
||||||
errors::ApiErrorResponse::MerchantConnectorAccountNotFound => {
|
errors::ApiErrorResponse::MerchantConnectorAccountNotFound => {
|
||||||
ErrorCode::MerchantConnectorAccountNotFound
|
StripeErrorCode::MerchantConnectorAccountNotFound
|
||||||
}
|
}
|
||||||
errors::ApiErrorResponse::MandateNotFound => ErrorCode::MandateNotFound,
|
errors::ApiErrorResponse::MandateNotFound => StripeErrorCode::MandateNotFound,
|
||||||
errors::ApiErrorResponse::MandateValidationFailed { reason } => {
|
errors::ApiErrorResponse::MandateValidationFailed { reason } => {
|
||||||
ErrorCode::PaymentIntentMandateInvalid { message: reason }
|
StripeErrorCode::PaymentIntentMandateInvalid { message: reason }
|
||||||
}
|
}
|
||||||
errors::ApiErrorResponse::ReturnUrlUnavailable => ErrorCode::ReturnUrlUnavailable,
|
errors::ApiErrorResponse::ReturnUrlUnavailable => StripeErrorCode::ReturnUrlUnavailable,
|
||||||
errors::ApiErrorResponse::DuplicateMerchantAccount => {
|
errors::ApiErrorResponse::DuplicateMerchantAccount => {
|
||||||
ErrorCode::DuplicateMerchantAccount
|
StripeErrorCode::DuplicateMerchantAccount
|
||||||
}
|
}
|
||||||
errors::ApiErrorResponse::DuplicateMerchantConnectorAccount => {
|
errors::ApiErrorResponse::DuplicateMerchantConnectorAccount => {
|
||||||
ErrorCode::DuplicateMerchantConnectorAccount
|
StripeErrorCode::DuplicateMerchantConnectorAccount
|
||||||
|
}
|
||||||
|
errors::ApiErrorResponse::DuplicatePaymentMethod => {
|
||||||
|
StripeErrorCode::DuplicatePaymentMethod
|
||||||
}
|
}
|
||||||
errors::ApiErrorResponse::DuplicatePaymentMethod => ErrorCode::DuplicatePaymentMethod,
|
|
||||||
errors::ApiErrorResponse::ClientSecretInvalid => {
|
errors::ApiErrorResponse::ClientSecretInvalid => {
|
||||||
ErrorCode::PaymentIntentInvalidParameter {
|
StripeErrorCode::PaymentIntentInvalidParameter {
|
||||||
param: "client_secret".to_owned(),
|
param: "client_secret".to_owned(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
errors::ApiErrorResponse::InvalidRequestData { message } => {
|
errors::ApiErrorResponse::InvalidRequestData { message } => {
|
||||||
ErrorCode::InvalidRequestData { message }
|
StripeErrorCode::InvalidRequestData { message }
|
||||||
}
|
}
|
||||||
errors::ApiErrorResponse::PreconditionFailed { message } => {
|
errors::ApiErrorResponse::PreconditionFailed { message } => {
|
||||||
ErrorCode::PreconditionFailed { message }
|
StripeErrorCode::PreconditionFailed { message }
|
||||||
}
|
}
|
||||||
errors::ApiErrorResponse::BadCredentials => ErrorCode::Unauthorized,
|
errors::ApiErrorResponse::BadCredentials => StripeErrorCode::Unauthorized,
|
||||||
errors::ApiErrorResponse::InvalidDataValue { field_name } => {
|
errors::ApiErrorResponse::InvalidDataValue { field_name } => {
|
||||||
ErrorCode::ParameterMissing {
|
StripeErrorCode::ParameterMissing {
|
||||||
field_name: field_name.to_owned(),
|
field_name: field_name.to_owned(),
|
||||||
param: field_name.to_owned(),
|
param: field_name.to_owned(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
errors::ApiErrorResponse::MaximumRefundCount => ErrorCode::MaximumRefundCount,
|
errors::ApiErrorResponse::MaximumRefundCount => StripeErrorCode::MaximumRefundCount,
|
||||||
errors::ApiErrorResponse::PaymentNotSucceeded => ErrorCode::PaymentFailed,
|
errors::ApiErrorResponse::PaymentNotSucceeded => StripeErrorCode::PaymentFailed,
|
||||||
errors::ApiErrorResponse::DuplicateMandate => ErrorCode::DuplicateMandate,
|
errors::ApiErrorResponse::DuplicateMandate => StripeErrorCode::DuplicateMandate,
|
||||||
errors::ApiErrorResponse::SuccessfulPaymentNotFound => {
|
errors::ApiErrorResponse::SuccessfulPaymentNotFound => {
|
||||||
ErrorCode::SuccessfulPaymentNotFound
|
StripeErrorCode::SuccessfulPaymentNotFound
|
||||||
}
|
}
|
||||||
errors::ApiErrorResponse::AddressNotFound => ErrorCode::AddressNotFound,
|
errors::ApiErrorResponse::AddressNotFound => StripeErrorCode::AddressNotFound,
|
||||||
errors::ApiErrorResponse::NotImplemented => ErrorCode::Unauthorized,
|
errors::ApiErrorResponse::NotImplemented => StripeErrorCode::Unauthorized,
|
||||||
errors::ApiErrorResponse::PaymentUnexpectedState {
|
errors::ApiErrorResponse::PaymentUnexpectedState {
|
||||||
current_flow,
|
current_flow,
|
||||||
field_name,
|
field_name,
|
||||||
current_value,
|
current_value,
|
||||||
states,
|
states,
|
||||||
} => ErrorCode::PaymentIntentUnexpectedState {
|
} => StripeErrorCode::PaymentIntentUnexpectedState {
|
||||||
current_flow,
|
current_flow,
|
||||||
field_name,
|
field_name,
|
||||||
current_value,
|
current_value,
|
||||||
@ -418,50 +428,50 @@ impl From<errors::ApiErrorResponse> for ErrorCode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl actix_web::ResponseError for ErrorCode {
|
impl actix_web::ResponseError for StripeErrorCode {
|
||||||
fn status_code(&self) -> reqwest::StatusCode {
|
fn status_code(&self) -> reqwest::StatusCode {
|
||||||
use reqwest::StatusCode;
|
use reqwest::StatusCode;
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
ErrorCode::Unauthorized => StatusCode::UNAUTHORIZED,
|
StripeErrorCode::Unauthorized => StatusCode::UNAUTHORIZED,
|
||||||
ErrorCode::InvalidRequestUrl => StatusCode::NOT_FOUND,
|
StripeErrorCode::InvalidRequestUrl => StatusCode::NOT_FOUND,
|
||||||
ErrorCode::ParameterUnknown { .. } => StatusCode::UNPROCESSABLE_ENTITY,
|
StripeErrorCode::ParameterUnknown { .. } => StatusCode::UNPROCESSABLE_ENTITY,
|
||||||
ErrorCode::ParameterMissing { .. }
|
StripeErrorCode::ParameterMissing { .. }
|
||||||
| ErrorCode::RefundAmountExceedsPaymentAmount { .. }
|
| StripeErrorCode::RefundAmountExceedsPaymentAmount { .. }
|
||||||
| ErrorCode::PaymentIntentAuthenticationFailure { .. }
|
| StripeErrorCode::PaymentIntentAuthenticationFailure { .. }
|
||||||
| ErrorCode::PaymentIntentPaymentAttemptFailed { .. }
|
| StripeErrorCode::PaymentIntentPaymentAttemptFailed { .. }
|
||||||
| ErrorCode::ExpiredCard
|
| StripeErrorCode::ExpiredCard
|
||||||
| ErrorCode::InvalidCardType
|
| StripeErrorCode::InvalidCardType
|
||||||
| ErrorCode::DuplicateRefundRequest
|
| StripeErrorCode::DuplicateRefundRequest
|
||||||
| ErrorCode::RefundNotFound
|
| StripeErrorCode::RefundNotFound
|
||||||
| ErrorCode::CustomerNotFound
|
| StripeErrorCode::CustomerNotFound
|
||||||
| ErrorCode::ClientSecretNotFound
|
| StripeErrorCode::ClientSecretNotFound
|
||||||
| ErrorCode::PaymentNotFound
|
| StripeErrorCode::PaymentNotFound
|
||||||
| ErrorCode::PaymentMethodNotFound
|
| StripeErrorCode::PaymentMethodNotFound
|
||||||
| ErrorCode::MerchantAccountNotFound
|
| StripeErrorCode::MerchantAccountNotFound
|
||||||
| ErrorCode::MerchantConnectorAccountNotFound
|
| StripeErrorCode::MerchantConnectorAccountNotFound
|
||||||
| ErrorCode::MandateNotFound
|
| StripeErrorCode::MandateNotFound
|
||||||
| ErrorCode::DuplicateMerchantAccount
|
| StripeErrorCode::DuplicateMerchantAccount
|
||||||
| ErrorCode::DuplicateMerchantConnectorAccount
|
| StripeErrorCode::DuplicateMerchantConnectorAccount
|
||||||
| ErrorCode::DuplicatePaymentMethod
|
| StripeErrorCode::DuplicatePaymentMethod
|
||||||
| ErrorCode::PaymentFailed
|
| StripeErrorCode::PaymentFailed
|
||||||
| ErrorCode::VerificationFailed { .. }
|
| StripeErrorCode::VerificationFailed { .. }
|
||||||
| ErrorCode::MaximumRefundCount
|
| StripeErrorCode::MaximumRefundCount
|
||||||
| ErrorCode::PaymentIntentInvalidParameter { .. }
|
| StripeErrorCode::PaymentIntentInvalidParameter { .. }
|
||||||
| ErrorCode::SerdeQsError { .. }
|
| StripeErrorCode::SerdeQsError { .. }
|
||||||
| ErrorCode::InvalidRequestData { .. }
|
| StripeErrorCode::InvalidRequestData { .. }
|
||||||
| ErrorCode::PreconditionFailed { .. }
|
| StripeErrorCode::PreconditionFailed { .. }
|
||||||
| ErrorCode::DuplicateMandate
|
| StripeErrorCode::DuplicateMandate
|
||||||
| ErrorCode::SuccessfulPaymentNotFound
|
| StripeErrorCode::SuccessfulPaymentNotFound
|
||||||
| ErrorCode::AddressNotFound
|
| StripeErrorCode::AddressNotFound
|
||||||
| ErrorCode::ResourceIdNotFound
|
| StripeErrorCode::ResourceIdNotFound
|
||||||
| ErrorCode::PaymentIntentMandateInvalid { .. }
|
| StripeErrorCode::PaymentIntentMandateInvalid { .. }
|
||||||
| ErrorCode::PaymentIntentUnexpectedState { .. } => StatusCode::BAD_REQUEST,
|
| StripeErrorCode::PaymentIntentUnexpectedState { .. } => StatusCode::BAD_REQUEST,
|
||||||
ErrorCode::RefundFailed
|
StripeErrorCode::RefundFailed
|
||||||
| ErrorCode::InternalServerError
|
| StripeErrorCode::InternalServerError
|
||||||
| ErrorCode::MandateActive
|
| StripeErrorCode::MandateActive
|
||||||
| ErrorCode::CustomerRedacted => StatusCode::INTERNAL_SERVER_ERROR,
|
| StripeErrorCode::CustomerRedacted => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
ErrorCode::ReturnUrlUnavailable => StatusCode::SERVICE_UNAVAILABLE,
|
StripeErrorCode::ReturnUrlUnavailable => StatusCode::SERVICE_UNAVAILABLE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,36 +485,36 @@ impl actix_web::ResponseError for ErrorCode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<serde_qs::Error> for ErrorCode {
|
impl From<serde_qs::Error> for StripeErrorCode {
|
||||||
fn from(item: serde_qs::Error) -> Self {
|
fn from(item: serde_qs::Error) -> Self {
|
||||||
match item {
|
match item {
|
||||||
serde_qs::Error::Custom(s) => ErrorCode::SerdeQsError {
|
serde_qs::Error::Custom(s) => StripeErrorCode::SerdeQsError {
|
||||||
error_message: s,
|
error_message: s,
|
||||||
param: None,
|
param: None,
|
||||||
},
|
},
|
||||||
serde_qs::Error::Parse(param, position) => ErrorCode::SerdeQsError {
|
serde_qs::Error::Parse(param, position) => StripeErrorCode::SerdeQsError {
|
||||||
error_message: format!(
|
error_message: format!(
|
||||||
"parsing failed with error: '{param}' at position: {position}"
|
"parsing failed with error: '{param}' at position: {position}"
|
||||||
),
|
),
|
||||||
param: Some(param),
|
param: Some(param),
|
||||||
},
|
},
|
||||||
serde_qs::Error::Unsupported => ErrorCode::SerdeQsError {
|
serde_qs::Error::Unsupported => StripeErrorCode::SerdeQsError {
|
||||||
error_message: "Given request format is not supported".to_owned(),
|
error_message: "Given request format is not supported".to_owned(),
|
||||||
param: None,
|
param: None,
|
||||||
},
|
},
|
||||||
serde_qs::Error::FromUtf8(_) => ErrorCode::SerdeQsError {
|
serde_qs::Error::FromUtf8(_) => StripeErrorCode::SerdeQsError {
|
||||||
error_message: "Failed to parse request to from utf-8".to_owned(),
|
error_message: "Failed to parse request to from utf-8".to_owned(),
|
||||||
param: None,
|
param: None,
|
||||||
},
|
},
|
||||||
serde_qs::Error::Io(_) => ErrorCode::SerdeQsError {
|
serde_qs::Error::Io(_) => StripeErrorCode::SerdeQsError {
|
||||||
error_message: "Failed to parse request".to_owned(),
|
error_message: "Failed to parse request".to_owned(),
|
||||||
param: None,
|
param: None,
|
||||||
},
|
},
|
||||||
serde_qs::Error::ParseInt(_) => ErrorCode::SerdeQsError {
|
serde_qs::Error::ParseInt(_) => StripeErrorCode::SerdeQsError {
|
||||||
error_message: "Failed to parse integer in request".to_owned(),
|
error_message: "Failed to parse integer in request".to_owned(),
|
||||||
param: None,
|
param: None,
|
||||||
},
|
},
|
||||||
serde_qs::Error::Utf8(_) => ErrorCode::SerdeQsError {
|
serde_qs::Error::Utf8(_) => StripeErrorCode::SerdeQsError {
|
||||||
error_message: "Failed to convert utf8 to string".to_owned(),
|
error_message: "Failed to convert utf8 to string".to_owned(),
|
||||||
param: None,
|
param: None,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -21,13 +21,14 @@ pub async fn payment_intents_create(
|
|||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
form_payload: web::Bytes,
|
form_payload: web::Bytes,
|
||||||
) -> HttpResponse {
|
) -> HttpResponse {
|
||||||
let payload: types::StripePaymentIntentRequest =
|
let payload: types::StripePaymentIntentRequest = match qs_config
|
||||||
match qs_config.deserialize_bytes(&form_payload) {
|
.deserialize_bytes(&form_payload)
|
||||||
Ok(p) => p,
|
{
|
||||||
Err(err) => {
|
Ok(p) => p,
|
||||||
return api::log_and_return_error_response(report!(errors::ErrorCode::from(err)))
|
Err(err) => {
|
||||||
}
|
return api::log_and_return_error_response(report!(errors::StripeErrorCode::from(err)))
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let create_payment_req: payment_types::PaymentsRequest = payload.into();
|
let create_payment_req: payment_types::PaymentsRequest = payload.into();
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ pub async fn payment_intents_create(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripePaymentIntentResponse,
|
types::StripePaymentIntentResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
@ -88,7 +89,7 @@ pub async fn payment_intents_retrieve(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripePaymentIntentResponse,
|
types::StripePaymentIntentResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
@ -119,13 +120,14 @@ pub async fn payment_intents_update(
|
|||||||
path: web::Path<String>,
|
path: web::Path<String>,
|
||||||
) -> HttpResponse {
|
) -> HttpResponse {
|
||||||
let payment_id = path.into_inner();
|
let payment_id = path.into_inner();
|
||||||
let stripe_payload: types::StripePaymentIntentRequest =
|
let stripe_payload: types::StripePaymentIntentRequest = match qs_config
|
||||||
match qs_config.deserialize_bytes(&form_payload) {
|
.deserialize_bytes(&form_payload)
|
||||||
Ok(p) => p,
|
{
|
||||||
Err(err) => {
|
Ok(p) => p,
|
||||||
return api::log_and_return_error_response(report!(errors::ErrorCode::from(err)))
|
Err(err) => {
|
||||||
}
|
return api::log_and_return_error_response(report!(errors::StripeErrorCode::from(err)))
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let mut payload: payment_types::PaymentsRequest = stripe_payload.into();
|
let mut payload: payment_types::PaymentsRequest = stripe_payload.into();
|
||||||
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(payment_id));
|
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(payment_id));
|
||||||
@ -143,7 +145,7 @@ pub async fn payment_intents_update(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripePaymentIntentResponse,
|
types::StripePaymentIntentResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
@ -175,13 +177,14 @@ pub async fn payment_intents_confirm(
|
|||||||
path: web::Path<String>,
|
path: web::Path<String>,
|
||||||
) -> HttpResponse {
|
) -> HttpResponse {
|
||||||
let payment_id = path.into_inner();
|
let payment_id = path.into_inner();
|
||||||
let stripe_payload: types::StripePaymentIntentRequest =
|
let stripe_payload: types::StripePaymentIntentRequest = match qs_config
|
||||||
match qs_config.deserialize_bytes(&form_payload) {
|
.deserialize_bytes(&form_payload)
|
||||||
Ok(p) => p,
|
{
|
||||||
Err(err) => {
|
Ok(p) => p,
|
||||||
return api::log_and_return_error_response(report!(errors::ErrorCode::from(err)))
|
Err(err) => {
|
||||||
}
|
return api::log_and_return_error_response(report!(errors::StripeErrorCode::from(err)))
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let mut payload: payment_types::PaymentsRequest = stripe_payload.into();
|
let mut payload: payment_types::PaymentsRequest = stripe_payload.into();
|
||||||
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(payment_id));
|
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(payment_id));
|
||||||
@ -200,7 +203,7 @@ pub async fn payment_intents_confirm(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripePaymentIntentResponse,
|
types::StripePaymentIntentResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
@ -230,13 +233,14 @@ pub async fn payment_intents_capture(
|
|||||||
form_payload: web::Bytes,
|
form_payload: web::Bytes,
|
||||||
path: web::Path<String>,
|
path: web::Path<String>,
|
||||||
) -> HttpResponse {
|
) -> HttpResponse {
|
||||||
let stripe_payload: payment_types::PaymentsCaptureRequest =
|
let stripe_payload: payment_types::PaymentsCaptureRequest = match qs_config
|
||||||
match qs_config.deserialize_bytes(&form_payload) {
|
.deserialize_bytes(&form_payload)
|
||||||
Ok(p) => p,
|
{
|
||||||
Err(err) => {
|
Ok(p) => p,
|
||||||
return api::log_and_return_error_response(report!(errors::ErrorCode::from(err)))
|
Err(err) => {
|
||||||
}
|
return api::log_and_return_error_response(report!(errors::StripeErrorCode::from(err)))
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let capture_payload = payment_types::PaymentsCaptureRequest {
|
let capture_payload = payment_types::PaymentsCaptureRequest {
|
||||||
payment_id: Some(path.into_inner()),
|
payment_id: Some(path.into_inner()),
|
||||||
@ -250,7 +254,7 @@ pub async fn payment_intents_capture(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripePaymentIntentResponse,
|
types::StripePaymentIntentResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
@ -281,13 +285,14 @@ pub async fn payment_intents_cancel(
|
|||||||
path: web::Path<String>,
|
path: web::Path<String>,
|
||||||
) -> HttpResponse {
|
) -> HttpResponse {
|
||||||
let payment_id = path.into_inner();
|
let payment_id = path.into_inner();
|
||||||
let stripe_payload: types::StripePaymentCancelRequest =
|
let stripe_payload: types::StripePaymentCancelRequest = match qs_config
|
||||||
match qs_config.deserialize_bytes(&form_payload) {
|
.deserialize_bytes(&form_payload)
|
||||||
Ok(p) => p,
|
{
|
||||||
Err(err) => {
|
Ok(p) => p,
|
||||||
return api::log_and_return_error_response(report!(errors::ErrorCode::from(err)))
|
Err(err) => {
|
||||||
}
|
return api::log_and_return_error_response(report!(errors::StripeErrorCode::from(err)))
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let mut payload: payment_types::PaymentsCancelRequest = stripe_payload.into();
|
let mut payload: payment_types::PaymentsCancelRequest = stripe_payload.into();
|
||||||
payload.payment_id = payment_id;
|
payload.payment_id = payment_id;
|
||||||
@ -304,7 +309,7 @@ pub async fn payment_intents_cancel(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripePaymentIntentResponse,
|
types::StripePaymentIntentResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
@ -343,7 +348,7 @@ pub async fn payment_intent_list(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripePaymentIntentListResponse,
|
types::StripePaymentIntentListResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
|
|||||||
@ -13,7 +13,7 @@ use crate::{
|
|||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[post("")]
|
#[post("")]
|
||||||
pub(crate) async fn refund_create(
|
pub async fn refund_create(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
form_payload: web::Form<types::StripeCreateRefundRequest>,
|
form_payload: web::Form<types::StripeCreateRefundRequest>,
|
||||||
@ -28,7 +28,7 @@ pub(crate) async fn refund_create(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripeCreateRefundResponse,
|
types::StripeCreateRefundResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
@ -41,7 +41,7 @@ pub(crate) async fn refund_create(
|
|||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[get("/{refund_id}")]
|
#[get("/{refund_id}")]
|
||||||
pub(crate) async fn refund_retrieve(
|
pub async fn refund_retrieve(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
path: web::Path<String>,
|
path: web::Path<String>,
|
||||||
@ -54,7 +54,7 @@ pub(crate) async fn refund_retrieve(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripeCreateRefundResponse,
|
types::StripeCreateRefundResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
@ -74,7 +74,7 @@ pub(crate) async fn refund_retrieve(
|
|||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[post("/{refund_id}")]
|
#[post("/{refund_id}")]
|
||||||
pub(crate) async fn refund_update(
|
pub async fn refund_update(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
path: web::Path<String>,
|
path: web::Path<String>,
|
||||||
@ -91,7 +91,7 @@ pub(crate) async fn refund_update(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripeCreateRefundResponse,
|
types::StripeCreateRefundResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
|
|||||||
@ -5,24 +5,24 @@ use serde::{Deserialize, Serialize};
|
|||||||
use crate::types::api::refunds;
|
use crate::types::api::refunds;
|
||||||
|
|
||||||
#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
|
#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
pub(crate) struct StripeCreateRefundRequest {
|
pub struct StripeCreateRefundRequest {
|
||||||
pub(crate) amount: Option<i64>,
|
pub amount: Option<i64>,
|
||||||
pub(crate) payment_intent: String,
|
pub payment_intent: String,
|
||||||
pub(crate) reason: Option<String>,
|
pub reason: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, PartialEq, Eq)]
|
#[derive(Clone, Serialize, PartialEq, Eq)]
|
||||||
pub(crate) struct StripeCreateRefundResponse {
|
pub struct StripeCreateRefundResponse {
|
||||||
pub(crate) id: String,
|
pub id: String,
|
||||||
pub(crate) amount: i64,
|
pub amount: i64,
|
||||||
pub(crate) currency: String,
|
pub currency: String,
|
||||||
pub(crate) payment_intent: String,
|
pub payment_intent: String,
|
||||||
pub(crate) status: StripeRefundStatus,
|
pub status: StripeRefundStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, Eq, PartialEq)]
|
#[derive(Clone, Serialize, Deserialize, Eq, PartialEq)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub(crate) enum StripeRefundStatus {
|
pub enum StripeRefundStatus {
|
||||||
Succeeded,
|
Succeeded,
|
||||||
Failed,
|
Failed,
|
||||||
Pending,
|
Pending,
|
||||||
|
|||||||
@ -10,7 +10,7 @@ use crate::{
|
|||||||
core::payments,
|
core::payments,
|
||||||
routes,
|
routes,
|
||||||
services::api,
|
services::api,
|
||||||
types::api::{self as api_types},
|
types::api as api_types,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[post("")]
|
#[post("")]
|
||||||
@ -25,7 +25,7 @@ pub async fn setup_intents_create(
|
|||||||
{
|
{
|
||||||
Ok(p) => p,
|
Ok(p) => p,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return api::log_and_return_error_response(report!(errors::ErrorCode::from(err)))
|
return api::log_and_return_error_response(report!(errors::StripeErrorCode::from(err)))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ pub async fn setup_intents_create(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripeSetupIntentResponse,
|
types::StripeSetupIntentResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
@ -88,7 +88,7 @@ pub async fn setup_intents_retrieve(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripeSetupIntentResponse,
|
types::StripeSetupIntentResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
@ -119,13 +119,14 @@ pub async fn setup_intents_update(
|
|||||||
path: web::Path<String>,
|
path: web::Path<String>,
|
||||||
) -> HttpResponse {
|
) -> HttpResponse {
|
||||||
let setup_id = path.into_inner();
|
let setup_id = path.into_inner();
|
||||||
let stripe_payload: types::StripeSetupIntentRequest =
|
let stripe_payload: types::StripeSetupIntentRequest = match qs_config
|
||||||
match qs_config.deserialize_bytes(&form_payload) {
|
.deserialize_bytes(&form_payload)
|
||||||
Ok(p) => p,
|
{
|
||||||
Err(err) => {
|
Ok(p) => p,
|
||||||
return api::log_and_return_error_response(report!(errors::ErrorCode::from(err)))
|
Err(err) => {
|
||||||
}
|
return api::log_and_return_error_response(report!(errors::StripeErrorCode::from(err)))
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let mut payload: payment_types::PaymentsRequest = stripe_payload.into();
|
let mut payload: payment_types::PaymentsRequest = stripe_payload.into();
|
||||||
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(setup_id));
|
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(setup_id));
|
||||||
@ -143,7 +144,7 @@ pub async fn setup_intents_update(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripeSetupIntentResponse,
|
types::StripeSetupIntentResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
@ -175,13 +176,14 @@ pub async fn setup_intents_confirm(
|
|||||||
path: web::Path<String>,
|
path: web::Path<String>,
|
||||||
) -> HttpResponse {
|
) -> HttpResponse {
|
||||||
let setup_id = path.into_inner();
|
let setup_id = path.into_inner();
|
||||||
let stripe_payload: types::StripeSetupIntentRequest =
|
let stripe_payload: types::StripeSetupIntentRequest = match qs_config
|
||||||
match qs_config.deserialize_bytes(&form_payload) {
|
.deserialize_bytes(&form_payload)
|
||||||
Ok(p) => p,
|
{
|
||||||
Err(err) => {
|
Ok(p) => p,
|
||||||
return api::log_and_return_error_response(report!(errors::ErrorCode::from(err)))
|
Err(err) => {
|
||||||
}
|
return api::log_and_return_error_response(report!(errors::StripeErrorCode::from(err)))
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let mut payload: payment_types::PaymentsRequest = stripe_payload.into();
|
let mut payload: payment_types::PaymentsRequest = stripe_payload.into();
|
||||||
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(setup_id));
|
payload.payment_id = Some(api_types::PaymentIdType::PaymentIntentId(setup_id));
|
||||||
@ -200,7 +202,7 @@ pub async fn setup_intents_confirm(
|
|||||||
_,
|
_,
|
||||||
_,
|
_,
|
||||||
types::StripeSetupIntentResponse,
|
types::StripeSetupIntentResponse,
|
||||||
errors::ErrorCode,
|
errors::StripeErrorCode,
|
||||||
>(
|
>(
|
||||||
&state,
|
&state,
|
||||||
&req,
|
&req,
|
||||||
|
|||||||
@ -13,7 +13,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[instrument(skip(request, payload, state, func))]
|
#[instrument(skip(request, payload, state, func))]
|
||||||
pub(crate) async fn compatibility_api_wrap<'a, 'b, A, T, Q, F, Fut, S, E>(
|
pub async fn compatibility_api_wrap<'a, 'b, A, T, Q, F, Fut, S, E>(
|
||||||
state: &'b routes::AppState,
|
state: &'b routes::AppState,
|
||||||
request: &'a HttpRequest,
|
request: &'a HttpRequest,
|
||||||
payload: T,
|
payload: T,
|
||||||
|
|||||||
@ -249,7 +249,7 @@ pub async fn payments_confirm(
|
|||||||
|
|
||||||
#[instrument(skip_all, fields(flow = ?Flow::PaymentsCapture))]
|
#[instrument(skip_all, fields(flow = ?Flow::PaymentsCapture))]
|
||||||
// #[post("/{payment_id}/capture")]
|
// #[post("/{payment_id}/capture")]
|
||||||
pub(crate) async fn payments_capture(
|
pub async fn payments_capture(
|
||||||
state: web::Data<AppState>,
|
state: web::Data<AppState>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
json_payload: web::Json<PaymentsCaptureRequest>,
|
json_payload: web::Json<PaymentsCaptureRequest>,
|
||||||
@ -281,7 +281,7 @@ pub(crate) async fn payments_capture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all, fields(flow = ?Flow::PaymentsSessionToken))]
|
#[instrument(skip_all, fields(flow = ?Flow::PaymentsSessionToken))]
|
||||||
pub(crate) async fn payments_connector_session(
|
pub async fn payments_connector_session(
|
||||||
state: web::Data<AppState>,
|
state: web::Data<AppState>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
json_payload: web::Json<PaymentsSessionRequest>,
|
json_payload: web::Json<PaymentsSessionRequest>,
|
||||||
|
|||||||
Reference in New Issue
Block a user