mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
chore(router): clippy::use_self (#203)
This commit is contained in:
@ -90,12 +90,12 @@ impl Default for RefundStatus {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<self::RefundStatus> for enums::RefundStatus {
|
||||
fn from(item: self::RefundStatus) -> Self {
|
||||
impl From<RefundStatus> for enums::RefundStatus {
|
||||
fn from(item: RefundStatus) -> Self {
|
||||
match item {
|
||||
self::RefundStatus::Succeeded => enums::RefundStatus::Success,
|
||||
self::RefundStatus::Failed => enums::RefundStatus::Failure,
|
||||
self::RefundStatus::Processing => enums::RefundStatus::Pending,
|
||||
RefundStatus::Succeeded => Self::Success,
|
||||
RefundStatus::Failed => Self::Failure,
|
||||
RefundStatus::Processing => Self::Pending,
|
||||
//TODO: Review mapping
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,11 +314,11 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
|
||||
fn from(value: errors::ApiErrorResponse) -> Self {
|
||||
match value {
|
||||
errors::ApiErrorResponse::Unauthorized
|
||||
| errors::ApiErrorResponse::InvalidEphermeralKey => StripeErrorCode::Unauthorized,
|
||||
| errors::ApiErrorResponse::InvalidEphermeralKey => Self::Unauthorized,
|
||||
errors::ApiErrorResponse::InvalidRequestUrl
|
||||
| errors::ApiErrorResponse::InvalidHttpMethod => StripeErrorCode::InvalidRequestUrl,
|
||||
| errors::ApiErrorResponse::InvalidHttpMethod => Self::InvalidRequestUrl,
|
||||
errors::ApiErrorResponse::MissingRequiredField { field_name } => {
|
||||
StripeErrorCode::ParameterMissing {
|
||||
Self::ParameterMissing {
|
||||
field_name: field_name.to_owned(),
|
||||
param: field_name,
|
||||
}
|
||||
@ -327,98 +327,80 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
|
||||
errors::ApiErrorResponse::InvalidDataFormat {
|
||||
field_name,
|
||||
expected_format,
|
||||
} => StripeErrorCode::ParameterUnknown {
|
||||
} => Self::ParameterUnknown {
|
||||
field_name,
|
||||
expected_format,
|
||||
},
|
||||
errors::ApiErrorResponse::RefundAmountExceedsPaymentAmount => {
|
||||
StripeErrorCode::RefundAmountExceedsPaymentAmount {
|
||||
Self::RefundAmountExceedsPaymentAmount {
|
||||
param: "amount".to_owned(),
|
||||
}
|
||||
}
|
||||
errors::ApiErrorResponse::PaymentAuthorizationFailed { data }
|
||||
| errors::ApiErrorResponse::PaymentAuthenticationFailed { data } => {
|
||||
StripeErrorCode::PaymentIntentAuthenticationFailure { data }
|
||||
Self::PaymentIntentAuthenticationFailure { data }
|
||||
}
|
||||
errors::ApiErrorResponse::VerificationFailed { data } => {
|
||||
StripeErrorCode::VerificationFailed { data }
|
||||
Self::VerificationFailed { data }
|
||||
}
|
||||
errors::ApiErrorResponse::PaymentCaptureFailed { data } => {
|
||||
StripeErrorCode::PaymentIntentPaymentAttemptFailed { data }
|
||||
Self::PaymentIntentPaymentAttemptFailed { data }
|
||||
}
|
||||
errors::ApiErrorResponse::InvalidCardData { data } => StripeErrorCode::InvalidCardType, // Maybe it is better to de generalize this router error
|
||||
errors::ApiErrorResponse::CardExpired { data } => StripeErrorCode::ExpiredCard,
|
||||
errors::ApiErrorResponse::RefundFailed { data } => StripeErrorCode::RefundFailed, // Nothing at stripe to map
|
||||
errors::ApiErrorResponse::InvalidCardData { data } => Self::InvalidCardType, // Maybe it is better to de generalize this router error
|
||||
errors::ApiErrorResponse::CardExpired { data } => Self::ExpiredCard,
|
||||
errors::ApiErrorResponse::RefundFailed { data } => Self::RefundFailed, // Nothing at stripe to map
|
||||
|
||||
errors::ApiErrorResponse::InternalServerError => StripeErrorCode::InternalServerError, // not a stripe code
|
||||
errors::ApiErrorResponse::IncorrectConnectorNameGiven => {
|
||||
StripeErrorCode::InternalServerError
|
||||
}
|
||||
errors::ApiErrorResponse::MandateActive => StripeErrorCode::MandateActive, //not a stripe code
|
||||
errors::ApiErrorResponse::CustomerRedacted => StripeErrorCode::CustomerRedacted, //not a stripe code
|
||||
errors::ApiErrorResponse::DuplicateRefundRequest => {
|
||||
StripeErrorCode::DuplicateRefundRequest
|
||||
}
|
||||
errors::ApiErrorResponse::RefundNotFound => StripeErrorCode::RefundNotFound,
|
||||
errors::ApiErrorResponse::CustomerNotFound => StripeErrorCode::CustomerNotFound,
|
||||
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::InternalServerError => Self::InternalServerError, // not a stripe code
|
||||
errors::ApiErrorResponse::IncorrectConnectorNameGiven => Self::InternalServerError,
|
||||
errors::ApiErrorResponse::MandateActive => Self::MandateActive, //not a stripe code
|
||||
errors::ApiErrorResponse::CustomerRedacted => Self::CustomerRedacted, //not a stripe code
|
||||
errors::ApiErrorResponse::DuplicateRefundRequest => Self::DuplicateRefundRequest,
|
||||
errors::ApiErrorResponse::RefundNotFound => Self::RefundNotFound,
|
||||
errors::ApiErrorResponse::CustomerNotFound => Self::CustomerNotFound,
|
||||
errors::ApiErrorResponse::PaymentNotFound => Self::PaymentNotFound,
|
||||
errors::ApiErrorResponse::PaymentMethodNotFound => Self::PaymentMethodNotFound,
|
||||
errors::ApiErrorResponse::ClientSecretNotGiven => Self::ClientSecretNotFound,
|
||||
errors::ApiErrorResponse::MerchantAccountNotFound => Self::MerchantAccountNotFound,
|
||||
errors::ApiErrorResponse::ResourceIdNotFound => Self::ResourceIdNotFound,
|
||||
errors::ApiErrorResponse::MerchantConnectorAccountNotFound => {
|
||||
StripeErrorCode::MerchantConnectorAccountNotFound
|
||||
Self::MerchantConnectorAccountNotFound
|
||||
}
|
||||
errors::ApiErrorResponse::MandateNotFound => StripeErrorCode::MandateNotFound,
|
||||
errors::ApiErrorResponse::MandateNotFound => Self::MandateNotFound,
|
||||
errors::ApiErrorResponse::MandateValidationFailed { reason } => {
|
||||
StripeErrorCode::PaymentIntentMandateInvalid { message: reason }
|
||||
}
|
||||
errors::ApiErrorResponse::ReturnUrlUnavailable => StripeErrorCode::ReturnUrlUnavailable,
|
||||
errors::ApiErrorResponse::DuplicateMerchantAccount => {
|
||||
StripeErrorCode::DuplicateMerchantAccount
|
||||
Self::PaymentIntentMandateInvalid { message: reason }
|
||||
}
|
||||
errors::ApiErrorResponse::ReturnUrlUnavailable => Self::ReturnUrlUnavailable,
|
||||
errors::ApiErrorResponse::DuplicateMerchantAccount => Self::DuplicateMerchantAccount,
|
||||
errors::ApiErrorResponse::DuplicateMerchantConnectorAccount => {
|
||||
StripeErrorCode::DuplicateMerchantConnectorAccount
|
||||
}
|
||||
errors::ApiErrorResponse::DuplicatePaymentMethod => {
|
||||
StripeErrorCode::DuplicatePaymentMethod
|
||||
}
|
||||
errors::ApiErrorResponse::ClientSecretInvalid => {
|
||||
StripeErrorCode::PaymentIntentInvalidParameter {
|
||||
param: "client_secret".to_owned(),
|
||||
}
|
||||
Self::DuplicateMerchantConnectorAccount
|
||||
}
|
||||
errors::ApiErrorResponse::DuplicatePaymentMethod => Self::DuplicatePaymentMethod,
|
||||
errors::ApiErrorResponse::ClientSecretInvalid => Self::PaymentIntentInvalidParameter {
|
||||
param: "client_secret".to_owned(),
|
||||
},
|
||||
errors::ApiErrorResponse::InvalidRequestData { message } => {
|
||||
StripeErrorCode::InvalidRequestData { message }
|
||||
Self::InvalidRequestData { message }
|
||||
}
|
||||
errors::ApiErrorResponse::PreconditionFailed { message } => {
|
||||
StripeErrorCode::PreconditionFailed { message }
|
||||
Self::PreconditionFailed { message }
|
||||
}
|
||||
errors::ApiErrorResponse::BadCredentials => StripeErrorCode::Unauthorized,
|
||||
errors::ApiErrorResponse::InvalidDataValue { field_name } => {
|
||||
StripeErrorCode::ParameterMissing {
|
||||
field_name: field_name.to_owned(),
|
||||
param: field_name.to_owned(),
|
||||
}
|
||||
}
|
||||
errors::ApiErrorResponse::MaximumRefundCount => StripeErrorCode::MaximumRefundCount,
|
||||
errors::ApiErrorResponse::PaymentNotSucceeded => StripeErrorCode::PaymentFailed,
|
||||
errors::ApiErrorResponse::DuplicateMandate => StripeErrorCode::DuplicateMandate,
|
||||
errors::ApiErrorResponse::SuccessfulPaymentNotFound => {
|
||||
StripeErrorCode::SuccessfulPaymentNotFound
|
||||
}
|
||||
errors::ApiErrorResponse::AddressNotFound => StripeErrorCode::AddressNotFound,
|
||||
errors::ApiErrorResponse::NotImplemented => StripeErrorCode::Unauthorized,
|
||||
errors::ApiErrorResponse::BadCredentials => Self::Unauthorized,
|
||||
errors::ApiErrorResponse::InvalidDataValue { field_name } => Self::ParameterMissing {
|
||||
field_name: field_name.to_owned(),
|
||||
param: field_name.to_owned(),
|
||||
},
|
||||
errors::ApiErrorResponse::MaximumRefundCount => Self::MaximumRefundCount,
|
||||
errors::ApiErrorResponse::PaymentNotSucceeded => Self::PaymentFailed,
|
||||
errors::ApiErrorResponse::DuplicateMandate => Self::DuplicateMandate,
|
||||
errors::ApiErrorResponse::SuccessfulPaymentNotFound => Self::SuccessfulPaymentNotFound,
|
||||
errors::ApiErrorResponse::AddressNotFound => Self::AddressNotFound,
|
||||
errors::ApiErrorResponse::NotImplemented => Self::Unauthorized,
|
||||
errors::ApiErrorResponse::PaymentUnexpectedState {
|
||||
current_flow,
|
||||
field_name,
|
||||
current_value,
|
||||
states,
|
||||
} => StripeErrorCode::PaymentIntentUnexpectedState {
|
||||
} => Self::PaymentIntentUnexpectedState {
|
||||
current_flow,
|
||||
field_name,
|
||||
current_value,
|
||||
@ -433,45 +415,45 @@ impl actix_web::ResponseError for StripeErrorCode {
|
||||
use reqwest::StatusCode;
|
||||
|
||||
match self {
|
||||
StripeErrorCode::Unauthorized => StatusCode::UNAUTHORIZED,
|
||||
StripeErrorCode::InvalidRequestUrl => StatusCode::NOT_FOUND,
|
||||
StripeErrorCode::ParameterUnknown { .. } => StatusCode::UNPROCESSABLE_ENTITY,
|
||||
StripeErrorCode::ParameterMissing { .. }
|
||||
| StripeErrorCode::RefundAmountExceedsPaymentAmount { .. }
|
||||
| StripeErrorCode::PaymentIntentAuthenticationFailure { .. }
|
||||
| StripeErrorCode::PaymentIntentPaymentAttemptFailed { .. }
|
||||
| StripeErrorCode::ExpiredCard
|
||||
| StripeErrorCode::InvalidCardType
|
||||
| StripeErrorCode::DuplicateRefundRequest
|
||||
| StripeErrorCode::RefundNotFound
|
||||
| StripeErrorCode::CustomerNotFound
|
||||
| StripeErrorCode::ClientSecretNotFound
|
||||
| StripeErrorCode::PaymentNotFound
|
||||
| StripeErrorCode::PaymentMethodNotFound
|
||||
| StripeErrorCode::MerchantAccountNotFound
|
||||
| StripeErrorCode::MerchantConnectorAccountNotFound
|
||||
| StripeErrorCode::MandateNotFound
|
||||
| StripeErrorCode::DuplicateMerchantAccount
|
||||
| StripeErrorCode::DuplicateMerchantConnectorAccount
|
||||
| StripeErrorCode::DuplicatePaymentMethod
|
||||
| StripeErrorCode::PaymentFailed
|
||||
| StripeErrorCode::VerificationFailed { .. }
|
||||
| StripeErrorCode::MaximumRefundCount
|
||||
| StripeErrorCode::PaymentIntentInvalidParameter { .. }
|
||||
| StripeErrorCode::SerdeQsError { .. }
|
||||
| StripeErrorCode::InvalidRequestData { .. }
|
||||
| StripeErrorCode::PreconditionFailed { .. }
|
||||
| StripeErrorCode::DuplicateMandate
|
||||
| StripeErrorCode::SuccessfulPaymentNotFound
|
||||
| StripeErrorCode::AddressNotFound
|
||||
| StripeErrorCode::ResourceIdNotFound
|
||||
| StripeErrorCode::PaymentIntentMandateInvalid { .. }
|
||||
| StripeErrorCode::PaymentIntentUnexpectedState { .. } => StatusCode::BAD_REQUEST,
|
||||
StripeErrorCode::RefundFailed
|
||||
| StripeErrorCode::InternalServerError
|
||||
| StripeErrorCode::MandateActive
|
||||
| StripeErrorCode::CustomerRedacted => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
StripeErrorCode::ReturnUrlUnavailable => StatusCode::SERVICE_UNAVAILABLE,
|
||||
Self::Unauthorized => StatusCode::UNAUTHORIZED,
|
||||
Self::InvalidRequestUrl => StatusCode::NOT_FOUND,
|
||||
Self::ParameterUnknown { .. } => StatusCode::UNPROCESSABLE_ENTITY,
|
||||
Self::ParameterMissing { .. }
|
||||
| Self::RefundAmountExceedsPaymentAmount { .. }
|
||||
| Self::PaymentIntentAuthenticationFailure { .. }
|
||||
| Self::PaymentIntentPaymentAttemptFailed { .. }
|
||||
| Self::ExpiredCard
|
||||
| Self::InvalidCardType
|
||||
| Self::DuplicateRefundRequest
|
||||
| Self::RefundNotFound
|
||||
| Self::CustomerNotFound
|
||||
| Self::ClientSecretNotFound
|
||||
| Self::PaymentNotFound
|
||||
| Self::PaymentMethodNotFound
|
||||
| Self::MerchantAccountNotFound
|
||||
| Self::MerchantConnectorAccountNotFound
|
||||
| Self::MandateNotFound
|
||||
| Self::DuplicateMerchantAccount
|
||||
| Self::DuplicateMerchantConnectorAccount
|
||||
| Self::DuplicatePaymentMethod
|
||||
| Self::PaymentFailed
|
||||
| Self::VerificationFailed { .. }
|
||||
| Self::MaximumRefundCount
|
||||
| Self::PaymentIntentInvalidParameter { .. }
|
||||
| Self::SerdeQsError { .. }
|
||||
| Self::InvalidRequestData { .. }
|
||||
| Self::PreconditionFailed { .. }
|
||||
| Self::DuplicateMandate
|
||||
| Self::SuccessfulPaymentNotFound
|
||||
| Self::AddressNotFound
|
||||
| Self::ResourceIdNotFound
|
||||
| Self::PaymentIntentMandateInvalid { .. }
|
||||
| Self::PaymentIntentUnexpectedState { .. } => StatusCode::BAD_REQUEST,
|
||||
Self::RefundFailed
|
||||
| Self::InternalServerError
|
||||
| Self::MandateActive
|
||||
| Self::CustomerRedacted => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Self::ReturnUrlUnavailable => StatusCode::SERVICE_UNAVAILABLE,
|
||||
}
|
||||
}
|
||||
|
||||
@ -488,33 +470,33 @@ impl actix_web::ResponseError for StripeErrorCode {
|
||||
impl From<serde_qs::Error> for StripeErrorCode {
|
||||
fn from(item: serde_qs::Error) -> Self {
|
||||
match item {
|
||||
serde_qs::Error::Custom(s) => StripeErrorCode::SerdeQsError {
|
||||
serde_qs::Error::Custom(s) => Self::SerdeQsError {
|
||||
error_message: s,
|
||||
param: None,
|
||||
},
|
||||
serde_qs::Error::Parse(param, position) => StripeErrorCode::SerdeQsError {
|
||||
serde_qs::Error::Parse(param, position) => Self::SerdeQsError {
|
||||
error_message: format!(
|
||||
"parsing failed with error: '{param}' at position: {position}"
|
||||
),
|
||||
param: Some(param),
|
||||
},
|
||||
serde_qs::Error::Unsupported => StripeErrorCode::SerdeQsError {
|
||||
serde_qs::Error::Unsupported => Self::SerdeQsError {
|
||||
error_message: "Given request format is not supported".to_owned(),
|
||||
param: None,
|
||||
},
|
||||
serde_qs::Error::FromUtf8(_) => StripeErrorCode::SerdeQsError {
|
||||
serde_qs::Error::FromUtf8(_) => Self::SerdeQsError {
|
||||
error_message: "Failed to parse request to from utf-8".to_owned(),
|
||||
param: None,
|
||||
},
|
||||
serde_qs::Error::Io(_) => StripeErrorCode::SerdeQsError {
|
||||
serde_qs::Error::Io(_) => Self::SerdeQsError {
|
||||
error_message: "Failed to parse request".to_owned(),
|
||||
param: None,
|
||||
},
|
||||
serde_qs::Error::ParseInt(_) => StripeErrorCode::SerdeQsError {
|
||||
serde_qs::Error::ParseInt(_) => Self::SerdeQsError {
|
||||
error_message: "Failed to parse integer in request".to_owned(),
|
||||
param: None,
|
||||
},
|
||||
serde_qs::Error::Utf8(_) => StripeErrorCode::SerdeQsError {
|
||||
serde_qs::Error::Utf8(_) => Self::SerdeQsError {
|
||||
error_message: "Failed to convert utf8 to string".to_owned(),
|
||||
param: None,
|
||||
},
|
||||
|
||||
@ -42,7 +42,7 @@ pub(crate) enum StripePaymentMethodType {
|
||||
impl From<StripePaymentMethodType> for api_enums::PaymentMethodType {
|
||||
fn from(item: StripePaymentMethodType) -> Self {
|
||||
match item {
|
||||
StripePaymentMethodType::Card => api_enums::PaymentMethodType::Card,
|
||||
StripePaymentMethodType::Card => Self::Card,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -78,10 +78,8 @@ impl From<StripeCard> for payments::CCard {
|
||||
impl From<StripePaymentMethodDetails> for payments::PaymentMethod {
|
||||
fn from(item: StripePaymentMethodDetails) -> Self {
|
||||
match item {
|
||||
StripePaymentMethodDetails::Card(card) => {
|
||||
payments::PaymentMethod::Card(payments::CCard::from(card))
|
||||
}
|
||||
StripePaymentMethodDetails::BankTransfer => payments::PaymentMethod::BankTransfer,
|
||||
StripePaymentMethodDetails::Card(card) => Self::Card(payments::CCard::from(card)),
|
||||
StripePaymentMethodDetails::BankTransfer => Self::BankTransfer,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,7 +129,7 @@ pub(crate) struct StripePaymentIntentRequest {
|
||||
|
||||
impl From<StripePaymentIntentRequest> for payments::PaymentsRequest {
|
||||
fn from(item: StripePaymentIntentRequest) -> Self {
|
||||
payments::PaymentsRequest {
|
||||
Self {
|
||||
amount: item.amount.map(|amount| amount.into()),
|
||||
connector: item.connector,
|
||||
currency: item.currency.as_ref().map(|c| c.to_uppercase()),
|
||||
@ -193,18 +191,14 @@ pub(crate) enum StripePaymentStatus {
|
||||
impl From<api_enums::IntentStatus> for StripePaymentStatus {
|
||||
fn from(item: api_enums::IntentStatus) -> Self {
|
||||
match item {
|
||||
api_enums::IntentStatus::Succeeded => StripePaymentStatus::Succeeded,
|
||||
api_enums::IntentStatus::Failed => StripePaymentStatus::Canceled, // TODO: should we show canceled or processing
|
||||
api_enums::IntentStatus::Processing => StripePaymentStatus::Processing,
|
||||
api_enums::IntentStatus::RequiresCustomerAction => StripePaymentStatus::RequiresAction,
|
||||
api_enums::IntentStatus::RequiresPaymentMethod => {
|
||||
StripePaymentStatus::RequiresPaymentMethod
|
||||
}
|
||||
api_enums::IntentStatus::RequiresConfirmation => {
|
||||
StripePaymentStatus::RequiresConfirmation
|
||||
}
|
||||
api_enums::IntentStatus::RequiresCapture => StripePaymentStatus::RequiresCapture,
|
||||
api_enums::IntentStatus::Cancelled => StripePaymentStatus::Canceled,
|
||||
api_enums::IntentStatus::Succeeded => Self::Succeeded,
|
||||
api_enums::IntentStatus::Failed => Self::Canceled, // TODO: should we show canceled or processing
|
||||
api_enums::IntentStatus::Processing => Self::Processing,
|
||||
api_enums::IntentStatus::RequiresCustomerAction => Self::RequiresAction,
|
||||
api_enums::IntentStatus::RequiresPaymentMethod => Self::RequiresPaymentMethod,
|
||||
api_enums::IntentStatus::RequiresConfirmation => Self::RequiresConfirmation,
|
||||
api_enums::IntentStatus::RequiresCapture => Self::RequiresCapture,
|
||||
api_enums::IntentStatus::Cancelled => Self::Canceled,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ pub(crate) enum StripePaymentMethodType {
|
||||
impl From<StripePaymentMethodType> for api_enums::PaymentMethodType {
|
||||
fn from(item: StripePaymentMethodType) -> Self {
|
||||
match item {
|
||||
StripePaymentMethodType::Card => api_enums::PaymentMethodType::Card,
|
||||
StripePaymentMethodType::Card => Self::Card,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,10 +82,8 @@ impl From<StripeCard> for payments::CCard {
|
||||
impl From<StripePaymentMethodDetails> for payments::PaymentMethod {
|
||||
fn from(item: StripePaymentMethodDetails) -> Self {
|
||||
match item {
|
||||
StripePaymentMethodDetails::Card(card) => {
|
||||
payments::PaymentMethod::Card(payments::CCard::from(card))
|
||||
}
|
||||
StripePaymentMethodDetails::BankTransfer => payments::PaymentMethod::BankTransfer,
|
||||
StripePaymentMethodDetails::Card(card) => Self::Card(payments::CCard::from(card)),
|
||||
StripePaymentMethodDetails::BankTransfer => Self::BankTransfer,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,7 +127,7 @@ pub(crate) struct StripeSetupIntentRequest {
|
||||
|
||||
impl From<StripeSetupIntentRequest> for payments::PaymentsRequest {
|
||||
fn from(item: StripeSetupIntentRequest) -> Self {
|
||||
payments::PaymentsRequest {
|
||||
Self {
|
||||
amount: Some(api_types::Amount::Zero),
|
||||
currency: Some(api_enums::Currency::default().to_string()),
|
||||
capture_method: None,
|
||||
@ -189,21 +187,17 @@ pub(crate) enum StripeSetupStatus {
|
||||
impl From<api_enums::IntentStatus> for StripeSetupStatus {
|
||||
fn from(item: api_enums::IntentStatus) -> Self {
|
||||
match item {
|
||||
api_enums::IntentStatus::Succeeded => StripeSetupStatus::Succeeded,
|
||||
api_enums::IntentStatus::Failed => StripeSetupStatus::Canceled, // TODO: should we show canceled or processing
|
||||
api_enums::IntentStatus::Processing => StripeSetupStatus::Processing,
|
||||
api_enums::IntentStatus::RequiresCustomerAction => StripeSetupStatus::RequiresAction,
|
||||
api_enums::IntentStatus::RequiresPaymentMethod => {
|
||||
StripeSetupStatus::RequiresPaymentMethod
|
||||
}
|
||||
api_enums::IntentStatus::RequiresConfirmation => {
|
||||
StripeSetupStatus::RequiresConfirmation
|
||||
}
|
||||
api_enums::IntentStatus::Succeeded => Self::Succeeded,
|
||||
api_enums::IntentStatus::Failed => Self::Canceled, // TODO: should we show canceled or processing
|
||||
api_enums::IntentStatus::Processing => Self::Processing,
|
||||
api_enums::IntentStatus::RequiresCustomerAction => Self::RequiresAction,
|
||||
api_enums::IntentStatus::RequiresPaymentMethod => Self::RequiresPaymentMethod,
|
||||
api_enums::IntentStatus::RequiresConfirmation => Self::RequiresConfirmation,
|
||||
api_enums::IntentStatus::RequiresCapture => {
|
||||
logger::error!("Invalid status change");
|
||||
StripeSetupStatus::Canceled
|
||||
Self::Canceled
|
||||
}
|
||||
api_enums::IntentStatus::Cancelled => StripeSetupStatus::Canceled,
|
||||
api_enums::IntentStatus::Cancelled => Self::Canceled,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ impl TryFrom<&types::ConnectorAuthType> for AciAuthType {
|
||||
type Error = error_stack::Report<errors::ConnectorError>;
|
||||
fn try_from(item: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
|
||||
if let types::ConnectorAuthType::BodyKey { api_key, key1 } = item {
|
||||
Ok(AciAuthType {
|
||||
Ok(Self {
|
||||
api_key: api_key.to_string(),
|
||||
entity_id: key1.to_string(),
|
||||
})
|
||||
@ -117,7 +117,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AciPaymentsRequest {
|
||||
};
|
||||
|
||||
let auth = AciAuthType::try_from(&item.connector_auth_type)?;
|
||||
let aci_payment_request = AciPaymentsRequest {
|
||||
let aci_payment_request = Self {
|
||||
payment_method: payment_details,
|
||||
entity_id: auth.entity_id,
|
||||
amount: item.request.amount,
|
||||
@ -132,7 +132,7 @@ impl TryFrom<&types::PaymentsCancelRouterData> for AciCancelRequest {
|
||||
type Error = error_stack::Report<errors::ConnectorError>;
|
||||
fn try_from(item: &types::PaymentsCancelRouterData) -> Result<Self, Self::Error> {
|
||||
let auth = AciAuthType::try_from(&item.connector_auth_type)?;
|
||||
let aci_payment_request = AciCancelRequest {
|
||||
let aci_payment_request = Self {
|
||||
entity_id: auth.entity_id,
|
||||
payment_type: AciPaymentType::Reversal,
|
||||
};
|
||||
@ -152,9 +152,9 @@ pub enum AciPaymentStatus {
|
||||
impl From<AciPaymentStatus> for enums::AttemptStatus {
|
||||
fn from(item: AciPaymentStatus) -> Self {
|
||||
match item {
|
||||
AciPaymentStatus::Succeeded => enums::AttemptStatus::Charged,
|
||||
AciPaymentStatus::Failed => enums::AttemptStatus::Failure,
|
||||
AciPaymentStatus::Pending => enums::AttemptStatus::Authorizing,
|
||||
AciPaymentStatus::Succeeded => Self::Charged,
|
||||
AciPaymentStatus::Failed => Self::Failure,
|
||||
AciPaymentStatus::Pending => Self::Authorizing,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -209,7 +209,7 @@ impl<F, T>
|
||||
fn try_from(
|
||||
item: types::ResponseRouterData<F, AciPaymentsResponse, T, types::PaymentsResponseData>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
status: enums::AttemptStatus::from(AciPaymentStatus::from_str(
|
||||
&item.response.result.code,
|
||||
)?),
|
||||
@ -241,7 +241,7 @@ impl<F> TryFrom<&types::RefundsRouterData<F>> for AciRefundRequest {
|
||||
let payment_type = AciPaymentType::Refund;
|
||||
let auth = AciAuthType::try_from(&item.connector_auth_type)?;
|
||||
|
||||
Ok(AciRefundRequest {
|
||||
Ok(Self {
|
||||
amount,
|
||||
currency: currency.to_string(),
|
||||
payment_type,
|
||||
@ -275,12 +275,12 @@ impl FromStr for AciRefundStatus {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<self::AciRefundStatus> for enums::RefundStatus {
|
||||
fn from(item: self::AciRefundStatus) -> Self {
|
||||
impl From<AciRefundStatus> for enums::RefundStatus {
|
||||
fn from(item: AciRefundStatus) -> Self {
|
||||
match item {
|
||||
self::AciRefundStatus::Succeeded => enums::RefundStatus::Success,
|
||||
self::AciRefundStatus::Failed => enums::RefundStatus::Failure,
|
||||
self::AciRefundStatus::Pending => enums::RefundStatus::Pending,
|
||||
AciRefundStatus::Succeeded => Self::Success,
|
||||
AciRefundStatus::Failed => Self::Failure,
|
||||
AciRefundStatus::Pending => Self::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -304,7 +304,7 @@ impl<F> TryFrom<types::RefundsResponseRouterData<F, AciRefundResponse>>
|
||||
fn try_from(
|
||||
item: types::RefundsResponseRouterData<F, AciRefundResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::RefundsResponseData {
|
||||
connector_refund_id: item.response.id,
|
||||
refund_status: enums::RefundStatus::from(AciRefundStatus::from_str(
|
||||
|
||||
@ -363,7 +363,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AdyenPaymentRequest {
|
||||
None
|
||||
};
|
||||
|
||||
Ok(AdyenPaymentRequest {
|
||||
Ok(Self {
|
||||
amount,
|
||||
merchant_account: auth_type.merchant_account,
|
||||
payment_method,
|
||||
@ -384,7 +384,7 @@ impl TryFrom<&types::PaymentsCancelRouterData> for AdyenCancelRequest {
|
||||
type Error = error_stack::Report<errors::ConnectorError>;
|
||||
fn try_from(item: &types::PaymentsCancelRouterData) -> Result<Self, Self::Error> {
|
||||
let auth_type = AdyenAuthType::try_from(&item.connector_auth_type)?;
|
||||
Ok(AdyenCancelRequest {
|
||||
Ok(Self {
|
||||
merchant_account: auth_type.merchant_account,
|
||||
original_reference: item.request.connector_transaction_id.to_string(),
|
||||
reference: item.payment_id.to_string(),
|
||||
@ -404,7 +404,7 @@ impl TryFrom<types::PaymentsCancelResponseRouterData<AdyenCancelResponse>>
|
||||
"processing" => storage_enums::AttemptStatus::Pending,
|
||||
_ => storage_enums::AttemptStatus::VoidFailed,
|
||||
};
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
status,
|
||||
response: Ok(types::PaymentsResponseData::TransactionResponse {
|
||||
resource_id: types::ResponseId::ConnectorTransactionId(item.response.psp_reference),
|
||||
@ -536,7 +536,7 @@ impl<F, Req>
|
||||
}
|
||||
};
|
||||
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
status,
|
||||
response: error.map_or_else(|| Ok(payment_response_data), Err),
|
||||
|
||||
@ -583,7 +583,7 @@ impl<F> TryFrom<&types::RefundsRouterData<F>> for AdyenRefundRequest {
|
||||
type Error = error_stack::Report<errors::ConnectorError>;
|
||||
fn try_from(item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
|
||||
let auth_type = AdyenAuthType::try_from(&item.connector_auth_type)?;
|
||||
Ok(AdyenRefundRequest {
|
||||
Ok(Self {
|
||||
merchant_account: auth_type.merchant_account,
|
||||
reference: item.request.refund_id.clone(),
|
||||
})
|
||||
@ -604,7 +604,7 @@ impl<F> TryFrom<types::RefundsResponseRouterData<F, AdyenRefundResponse>>
|
||||
"received" => storage_enums::RefundStatus::Success,
|
||||
_ => storage_enums::RefundStatus::Pending,
|
||||
};
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::RefundsResponseData {
|
||||
connector_refund_id: item.response.reference,
|
||||
refund_status,
|
||||
|
||||
@ -76,7 +76,7 @@ impl<F, T>
|
||||
fn try_from(
|
||||
item: types::ResponseRouterData<F, ApplepaySessionResponse, T, types::PaymentsResponseData>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::PaymentsResponseData::SessionResponse {
|
||||
session_token: {
|
||||
api_models::payments::SessionToken::Applepay {
|
||||
|
||||
@ -28,7 +28,7 @@ impl TryFrom<&types::ConnectorAuthType> for MerchantAuthentication {
|
||||
|
||||
fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
|
||||
if let types::ConnectorAuthType::BodyKey { api_key, key1 } = auth_type {
|
||||
Ok(MerchantAuthentication {
|
||||
Ok(Self {
|
||||
name: api_key.clone(),
|
||||
transaction_key: key1.clone(),
|
||||
})
|
||||
@ -164,7 +164,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for CreateTransactionRequest {
|
||||
|
||||
let merchant_authentication = MerchantAuthentication::try_from(&item.connector_auth_type)?;
|
||||
|
||||
Ok(CreateTransactionRequest {
|
||||
Ok(Self {
|
||||
create_transaction_request: AuthorizedotnetPaymentsRequest {
|
||||
merchant_authentication,
|
||||
transaction_request,
|
||||
@ -209,11 +209,11 @@ pub type AuthorizedotnetRefundStatus = AuthorizedotnetPaymentStatus;
|
||||
impl From<AuthorizedotnetPaymentStatus> for enums::AttemptStatus {
|
||||
fn from(item: AuthorizedotnetPaymentStatus) -> Self {
|
||||
match item {
|
||||
AuthorizedotnetPaymentStatus::Approved => enums::AttemptStatus::Charged,
|
||||
AuthorizedotnetPaymentStatus::Approved => Self::Charged,
|
||||
AuthorizedotnetPaymentStatus::Declined | AuthorizedotnetPaymentStatus::Error => {
|
||||
enums::AttemptStatus::Failure
|
||||
Self::Failure
|
||||
}
|
||||
AuthorizedotnetPaymentStatus::HeldForReview => enums::AttemptStatus::Pending,
|
||||
AuthorizedotnetPaymentStatus::HeldForReview => Self::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -293,7 +293,7 @@ impl<F, T>
|
||||
})
|
||||
});
|
||||
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
status,
|
||||
response: match error {
|
||||
Some(err) => Err(err),
|
||||
@ -369,7 +369,7 @@ impl<F> TryFrom<&types::RefundsRouterData<F>> for CreateRefundRequest {
|
||||
reference_transaction_id: item.request.connector_transaction_id.clone(),
|
||||
};
|
||||
|
||||
Ok(CreateRefundRequest {
|
||||
Ok(Self {
|
||||
create_transaction_request: AuthorizedotnetRefundRequest {
|
||||
merchant_authentication,
|
||||
transaction_request,
|
||||
@ -381,11 +381,11 @@ impl<F> TryFrom<&types::RefundsRouterData<F>> for CreateRefundRequest {
|
||||
impl From<self::AuthorizedotnetPaymentStatus> for enums::RefundStatus {
|
||||
fn from(item: self::AuthorizedotnetRefundStatus) -> Self {
|
||||
match item {
|
||||
AuthorizedotnetPaymentStatus::Approved => enums::RefundStatus::Success,
|
||||
AuthorizedotnetPaymentStatus::Approved => Self::Success,
|
||||
AuthorizedotnetPaymentStatus::Declined | AuthorizedotnetPaymentStatus::Error => {
|
||||
enums::RefundStatus::Failure
|
||||
Self::Failure
|
||||
}
|
||||
AuthorizedotnetPaymentStatus::HeldForReview => enums::RefundStatus::Pending,
|
||||
AuthorizedotnetPaymentStatus::HeldForReview => Self::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -414,7 +414,7 @@ impl<F> TryFrom<types::RefundsResponseRouterData<F, AuthorizedotnetRefundRespons
|
||||
})
|
||||
});
|
||||
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: match error {
|
||||
Some(err) => Err(err),
|
||||
None => Ok(types::RefundsResponseData {
|
||||
@ -451,7 +451,7 @@ impl<F> TryFrom<&types::RefundsRouterData<F>> for AuthorizedotnetCreateSyncReque
|
||||
.ok();
|
||||
let merchant_authentication = MerchantAuthentication::try_from(&item.connector_auth_type)?;
|
||||
|
||||
let payload = AuthorizedotnetCreateSyncRequest {
|
||||
let payload = Self {
|
||||
get_transaction_details_request: TransactionDetails {
|
||||
merchant_authentication,
|
||||
transaction_id,
|
||||
@ -484,7 +484,7 @@ impl TryFrom<&types::PaymentsSyncRouterData> for AuthorizedotnetCreateSyncReques
|
||||
|
||||
let merchant_authentication = MerchantAuthentication::try_from(&item.connector_auth_type)?;
|
||||
|
||||
let payload = AuthorizedotnetCreateSyncRequest {
|
||||
let payload = Self {
|
||||
get_transaction_details_request: TransactionDetails {
|
||||
merchant_authentication,
|
||||
transaction_id,
|
||||
@ -523,9 +523,9 @@ pub struct AuthorizedotnetSyncResponse {
|
||||
impl From<SyncStatus> for enums::RefundStatus {
|
||||
fn from(transaction_status: SyncStatus) -> Self {
|
||||
match transaction_status {
|
||||
SyncStatus::RefundSettledSuccessfully => enums::RefundStatus::Success,
|
||||
SyncStatus::RefundPendingSettlement => enums::RefundStatus::Pending,
|
||||
_ => enums::RefundStatus::Failure,
|
||||
SyncStatus::RefundSettledSuccessfully => Self::Success,
|
||||
SyncStatus::RefundPendingSettlement => Self::Pending,
|
||||
_ => Self::Failure,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -534,13 +534,13 @@ impl From<SyncStatus> for enums::AttemptStatus {
|
||||
fn from(transaction_status: SyncStatus) -> Self {
|
||||
match transaction_status {
|
||||
SyncStatus::SettledSuccessfully | SyncStatus::CapturedPendingSettlement => {
|
||||
enums::AttemptStatus::Charged
|
||||
Self::Charged
|
||||
}
|
||||
SyncStatus::Declined => enums::AttemptStatus::AuthenticationFailed,
|
||||
SyncStatus::Voided => enums::AttemptStatus::Voided,
|
||||
SyncStatus::CouldNotVoid => enums::AttemptStatus::VoidFailed,
|
||||
SyncStatus::GeneralError => enums::AttemptStatus::Failure,
|
||||
_ => enums::AttemptStatus::Pending,
|
||||
SyncStatus::Declined => Self::AuthenticationFailed,
|
||||
SyncStatus::Voided => Self::Voided,
|
||||
SyncStatus::CouldNotVoid => Self::VoidFailed,
|
||||
SyncStatus::GeneralError => Self::Failure,
|
||||
_ => Self::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -554,7 +554,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, AuthorizedotnetSyncRes
|
||||
item: types::RefundsResponseRouterData<api::RSync, AuthorizedotnetSyncResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
let refund_status = enums::RefundStatus::from(item.response.transaction.transaction_status);
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::RefundsResponseData {
|
||||
connector_refund_id: item.response.transaction.transaction_id.clone(),
|
||||
refund_status,
|
||||
@ -581,7 +581,7 @@ impl<F, Req>
|
||||
) -> Result<Self, Self::Error> {
|
||||
let payment_status =
|
||||
enums::AttemptStatus::from(item.response.transaction.transaction_status);
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::PaymentsResponseData::TransactionResponse {
|
||||
resource_id: types::ResponseId::ConnectorTransactionId(
|
||||
item.response.transaction.transaction_id,
|
||||
|
||||
@ -121,7 +121,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BraintreePaymentsRequest {
|
||||
payment_method_data_type,
|
||||
kind,
|
||||
};
|
||||
Ok(BraintreePaymentsRequest {
|
||||
Ok(Self {
|
||||
transaction: braintree_transaction_body,
|
||||
})
|
||||
}
|
||||
@ -146,7 +146,7 @@ impl TryFrom<&types::ConnectorAuthType> for BraintreeAuthType {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Eq, PartialEq)]
|
||||
#[derive(Debug, Default, Clone, Deserialize, Eq, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum BraintreePaymentStatus {
|
||||
Succeeded,
|
||||
@ -157,6 +157,7 @@ pub enum BraintreePaymentStatus {
|
||||
GatewayRejected,
|
||||
Voided,
|
||||
SubmittedForSettlement,
|
||||
#[default]
|
||||
Settling,
|
||||
Settled,
|
||||
SettlementPending,
|
||||
@ -164,26 +165,20 @@ pub enum BraintreePaymentStatus {
|
||||
SettlementConfirmed,
|
||||
}
|
||||
|
||||
impl Default for BraintreePaymentStatus {
|
||||
fn default() -> Self {
|
||||
BraintreePaymentStatus::Settling
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BraintreePaymentStatus> for enums::AttemptStatus {
|
||||
fn from(item: BraintreePaymentStatus) -> Self {
|
||||
match item {
|
||||
BraintreePaymentStatus::Succeeded | BraintreePaymentStatus::SubmittedForSettlement => {
|
||||
enums::AttemptStatus::Charged
|
||||
Self::Charged
|
||||
}
|
||||
BraintreePaymentStatus::AuthorizedExpired => enums::AttemptStatus::AuthorizationFailed,
|
||||
BraintreePaymentStatus::AuthorizedExpired => Self::AuthorizationFailed,
|
||||
BraintreePaymentStatus::Failed
|
||||
| BraintreePaymentStatus::GatewayRejected
|
||||
| BraintreePaymentStatus::ProcessorDeclined
|
||||
| BraintreePaymentStatus::SettlementDeclined => enums::AttemptStatus::Failure,
|
||||
BraintreePaymentStatus::Authorized => enums::AttemptStatus::Authorized,
|
||||
BraintreePaymentStatus::Voided => enums::AttemptStatus::Voided,
|
||||
_ => enums::AttemptStatus::Pending,
|
||||
| BraintreePaymentStatus::SettlementDeclined => Self::Failure,
|
||||
BraintreePaymentStatus::Authorized => Self::Authorized,
|
||||
BraintreePaymentStatus::Voided => Self::Voided,
|
||||
_ => Self::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -201,7 +196,7 @@ impl<F, T>
|
||||
types::PaymentsResponseData,
|
||||
>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
status: enums::AttemptStatus::from(item.response.transaction.status),
|
||||
response: Ok(types::PaymentsResponseData::TransactionResponse {
|
||||
resource_id: types::ResponseId::ConnectorTransactionId(
|
||||
@ -230,7 +225,7 @@ impl<F, T>
|
||||
types::PaymentsResponseData,
|
||||
>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::PaymentsResponseData::SessionResponse {
|
||||
session_token: types::api::SessionToken::Paypal {
|
||||
session_token: item.response.client_token.value,
|
||||
@ -292,32 +287,27 @@ pub struct Amount {
|
||||
impl<F> TryFrom<&types::RefundsRouterData<F>> for BraintreeRefundRequest {
|
||||
type Error = error_stack::Report<errors::ConnectorError>;
|
||||
fn try_from(_item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
|
||||
Ok(BraintreeRefundRequest {
|
||||
Ok(Self {
|
||||
transaction: Amount { amount: None },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[derive(Debug, Default, Deserialize, Clone)]
|
||||
pub enum RefundStatus {
|
||||
Succeeded,
|
||||
Failed,
|
||||
#[default]
|
||||
Processing,
|
||||
}
|
||||
|
||||
impl Default for RefundStatus {
|
||||
fn default() -> Self {
|
||||
RefundStatus::Processing
|
||||
}
|
||||
}
|
||||
|
||||
impl From<self::RefundStatus> for enums::RefundStatus {
|
||||
fn from(item: self::RefundStatus) -> Self {
|
||||
impl From<RefundStatus> for enums::RefundStatus {
|
||||
fn from(item: RefundStatus) -> Self {
|
||||
match item {
|
||||
self::RefundStatus::Succeeded => enums::RefundStatus::Success,
|
||||
self::RefundStatus::Failed => enums::RefundStatus::Failure,
|
||||
self::RefundStatus::Processing => enums::RefundStatus::Pending,
|
||||
RefundStatus::Succeeded => Self::Success,
|
||||
RefundStatus::Failed => Self::Failure,
|
||||
RefundStatus::Processing => Self::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -335,7 +325,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, RefundResponse>>
|
||||
fn try_from(
|
||||
item: types::RefundsResponseRouterData<api::Execute, RefundResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::RefundsResponseData {
|
||||
connector_refund_id: item.response.id,
|
||||
refund_status: enums::RefundStatus::from(item.response.status),
|
||||
@ -352,7 +342,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, RefundResponse>>
|
||||
fn try_from(
|
||||
item: types::RefundsResponseRouterData<api::RSync, RefundResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::RefundsResponseData {
|
||||
connector_refund_id: item.response.id,
|
||||
refund_status: enums::RefundStatus::from(item.response.status),
|
||||
|
||||
@ -117,7 +117,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaymentsRequest {
|
||||
let connector_auth = &item.connector_auth_type;
|
||||
let auth_type: CheckoutAuthType = connector_auth.try_into()?;
|
||||
let processing_channel_id = auth_type.processing_channel_id;
|
||||
Ok(PaymentsRequest {
|
||||
Ok(Self {
|
||||
source: source_var,
|
||||
amount: item.request.amount,
|
||||
currency: item.request.currency.to_string(),
|
||||
@ -210,7 +210,7 @@ impl TryFrom<types::PaymentsResponseRouterData<PaymentsResponse>>
|
||||
.map(|(k, v)| (k.to_string(), v.to_string())),
|
||||
),
|
||||
});
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
status: enums::AttemptStatus::foreign_from((
|
||||
item.response.status,
|
||||
item.data.request.capture_method,
|
||||
@ -252,7 +252,7 @@ impl TryFrom<types::PaymentsSyncResponseRouterData<PaymentsResponse>>
|
||||
),
|
||||
});
|
||||
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
status: enums::AttemptStatus::foreign_from((item.response.status, None)),
|
||||
response: Ok(types::PaymentsResponseData::TransactionResponse {
|
||||
resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),
|
||||
@ -277,7 +277,7 @@ pub struct PaymentVoidResponse {
|
||||
reference: String,
|
||||
}
|
||||
impl From<&PaymentVoidResponse> for enums::AttemptStatus {
|
||||
fn from(item: &PaymentVoidResponse) -> enums::AttemptStatus {
|
||||
fn from(item: &PaymentVoidResponse) -> Self {
|
||||
if item.status == 202 {
|
||||
Self::Voided
|
||||
} else {
|
||||
@ -294,7 +294,7 @@ impl TryFrom<types::PaymentsCancelResponseRouterData<PaymentVoidResponse>>
|
||||
item: types::PaymentsCancelResponseRouterData<PaymentVoidResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
let response = &item.response;
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::PaymentsResponseData::TransactionResponse {
|
||||
resource_id: types::ResponseId::ConnectorTransactionId(response.action_id.clone()),
|
||||
redirect: false,
|
||||
@ -364,7 +364,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, CheckoutRefundRespon
|
||||
item: types::RefundsResponseRouterData<api::Execute, CheckoutRefundResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
let refund_status = enums::RefundStatus::from(&item.response);
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::RefundsResponseData {
|
||||
connector_refund_id: item.response.response.action_id.clone(),
|
||||
refund_status,
|
||||
@ -382,7 +382,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, CheckoutRefundResponse
|
||||
item: types::RefundsResponseRouterData<api::RSync, CheckoutRefundResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
let refund_status = enums::RefundStatus::from(&item.response);
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::RefundsResponseData {
|
||||
connector_refund_id: item.response.response.action_id.clone(),
|
||||
refund_status,
|
||||
@ -455,7 +455,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, &ActionResponse>>
|
||||
item: types::RefundsResponseRouterData<api::Execute, &ActionResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
let refund_status = enums::RefundStatus::from(item.response);
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::RefundsResponseData {
|
||||
connector_refund_id: item.response.action_id.clone(),
|
||||
refund_status,
|
||||
@ -473,7 +473,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, &ActionResponse>>
|
||||
item: types::RefundsResponseRouterData<api::RSync, &ActionResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
let refund_status = enums::RefundStatus::from(item.response);
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::RefundsResponseData {
|
||||
connector_refund_id: item.response.action_id.clone(),
|
||||
refund_status,
|
||||
@ -486,13 +486,9 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, &ActionResponse>>
|
||||
impl From<CheckoutRedirectResponseStatus> for enums::AttemptStatus {
|
||||
fn from(item: CheckoutRedirectResponseStatus) -> Self {
|
||||
match item {
|
||||
CheckoutRedirectResponseStatus::Success => {
|
||||
types::storage::enums::AttemptStatus::VbvSuccessful
|
||||
}
|
||||
CheckoutRedirectResponseStatus::Success => Self::VbvSuccessful,
|
||||
|
||||
CheckoutRedirectResponseStatus::Failure => {
|
||||
types::storage::enums::AttemptStatus::Failure
|
||||
}
|
||||
CheckoutRedirectResponseStatus::Failure => Self::Failure,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ impl TryFrom<types::PaymentsSessionResponseRouterData<KlarnaSessionResponse>>
|
||||
item: types::PaymentsSessionResponseRouterData<KlarnaSessionResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
let response = &item.response;
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::PaymentsResponseData::SessionResponse {
|
||||
session_token: types::api::SessionToken::Klarna {
|
||||
session_token: response.client_token.clone(),
|
||||
@ -109,9 +109,9 @@ pub enum KlarnaPaymentStatus {
|
||||
impl From<KlarnaPaymentStatus> for enums::AttemptStatus {
|
||||
fn from(item: KlarnaPaymentStatus) -> Self {
|
||||
match item {
|
||||
KlarnaPaymentStatus::Succeeded => enums::AttemptStatus::Charged,
|
||||
KlarnaPaymentStatus::Failed => enums::AttemptStatus::Failure,
|
||||
KlarnaPaymentStatus::Processing => enums::AttemptStatus::Authorizing,
|
||||
KlarnaPaymentStatus::Succeeded => Self::Charged,
|
||||
KlarnaPaymentStatus::Failed => Self::Failure,
|
||||
KlarnaPaymentStatus::Processing => Self::Authorizing,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaymentIntentRequest {
|
||||
None => Address::default(),
|
||||
};
|
||||
|
||||
Ok(PaymentIntentRequest {
|
||||
Ok(Self {
|
||||
amount: item.request.amount, //hopefully we don't loose some cents here
|
||||
currency: item.request.currency.to_string(), //we need to copy the value and not transfer ownership
|
||||
statement_descriptor_suffix: item.request.statement_descriptor_suffix.clone(),
|
||||
@ -292,16 +292,14 @@ pub enum StripePaymentStatus {
|
||||
impl From<StripePaymentStatus> for enums::AttemptStatus {
|
||||
fn from(item: StripePaymentStatus) -> Self {
|
||||
match item {
|
||||
StripePaymentStatus::Succeeded => enums::AttemptStatus::Charged,
|
||||
StripePaymentStatus::Failed => enums::AttemptStatus::Failure,
|
||||
StripePaymentStatus::Processing => enums::AttemptStatus::Authorizing,
|
||||
StripePaymentStatus::RequiresCustomerAction => enums::AttemptStatus::PendingVbv,
|
||||
StripePaymentStatus::RequiresPaymentMethod => {
|
||||
enums::AttemptStatus::PaymentMethodAwaited
|
||||
}
|
||||
StripePaymentStatus::RequiresConfirmation => enums::AttemptStatus::ConfirmationAwaited,
|
||||
StripePaymentStatus::Canceled => enums::AttemptStatus::Voided,
|
||||
StripePaymentStatus::RequiresCapture => enums::AttemptStatus::Authorized,
|
||||
StripePaymentStatus::Succeeded => Self::Charged,
|
||||
StripePaymentStatus::Failed => Self::Failure,
|
||||
StripePaymentStatus::Processing => Self::Authorizing,
|
||||
StripePaymentStatus::RequiresCustomerAction => Self::PendingVbv,
|
||||
StripePaymentStatus::RequiresPaymentMethod => Self::PaymentMethodAwaited,
|
||||
StripePaymentStatus::RequiresConfirmation => Self::ConfirmationAwaited,
|
||||
StripePaymentStatus::Canceled => Self::Voided,
|
||||
StripePaymentStatus::RequiresCapture => Self::Authorized,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -375,7 +373,7 @@ impl<F, T>
|
||||
StripePaymentMethodOptions::Klarna {} => None,
|
||||
});
|
||||
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
status: enums::AttemptStatus::from(item.response.status),
|
||||
// client_secret: Some(item.response.client_secret.clone().as_str()),
|
||||
// description: item.response.description.map(|x| x.as_str()),
|
||||
@ -427,7 +425,7 @@ impl<F, T>
|
||||
StripePaymentMethodOptions::Klarna {} => None,
|
||||
});
|
||||
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
status: enums::AttemptStatus::from(item.response.status),
|
||||
response: Ok(types::PaymentsResponseData::TransactionResponse {
|
||||
resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),
|
||||
@ -494,7 +492,7 @@ impl<F> TryFrom<&types::RefundsRouterData<F>> for RefundRequest {
|
||||
let metadata_txn_id = "Fetch txn_id from DB".to_string();
|
||||
let metadata_txn_uuid = "Fetch txn_id from DB".to_string();
|
||||
let payment_intent = item.request.connector_transaction_id.clone();
|
||||
Ok(RefundRequest {
|
||||
Ok(Self {
|
||||
amount: Some(amount),
|
||||
payment_intent,
|
||||
metadata_order_id: item.payment_id.clone(),
|
||||
@ -545,7 +543,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, RefundResponse>>
|
||||
fn try_from(
|
||||
item: types::RefundsResponseRouterData<api::Execute, RefundResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::RefundsResponseData {
|
||||
connector_refund_id: item.response.id,
|
||||
refund_status: enums::RefundStatus::from(item.response.status),
|
||||
@ -562,7 +560,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, RefundResponse>>
|
||||
fn try_from(
|
||||
item: types::RefundsResponseRouterData<api::RSync, RefundResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
Ok(types::RouterData {
|
||||
Ok(Self {
|
||||
response: Ok(types::RefundsResponseData {
|
||||
connector_refund_id: item.response.id,
|
||||
refund_status: enums::RefundStatus::from(item.response.status),
|
||||
@ -753,7 +751,7 @@ pub struct StripeWebhookObjectId {
|
||||
impl From<(api::PaymentMethod, enums::AuthenticationType)> for StripePaymentMethodData {
|
||||
fn from((pm_data, auth_type): (api::PaymentMethod, enums::AuthenticationType)) -> Self {
|
||||
match pm_data {
|
||||
api::PaymentMethod::Card(ref ccard) => StripePaymentMethodData::Card({
|
||||
api::PaymentMethod::Card(ref ccard) => Self::Card({
|
||||
let payment_method_auth_type = match auth_type {
|
||||
enums::AuthenticationType::ThreeDs => Auth3ds::Any,
|
||||
enums::AuthenticationType::NoThreeDs => Auth3ds::Automatic,
|
||||
@ -768,17 +766,15 @@ impl From<(api::PaymentMethod, enums::AuthenticationType)> for StripePaymentMeth
|
||||
payment_method_auth_type,
|
||||
}
|
||||
}),
|
||||
api::PaymentMethod::BankTransfer => StripePaymentMethodData::Bank,
|
||||
api::PaymentMethod::PayLater(ref klarna_data) => {
|
||||
StripePaymentMethodData::Klarna(StripeKlarnaData {
|
||||
payment_method_types: "klarna".to_string(),
|
||||
payment_method_data_type: "klarna".to_string(),
|
||||
billing_email: klarna_data.billing_email.clone(),
|
||||
billing_country: klarna_data.country.clone(),
|
||||
})
|
||||
}
|
||||
api::PaymentMethod::Wallet(_) => StripePaymentMethodData::Wallet,
|
||||
api::PaymentMethod::Paypal => StripePaymentMethodData::Paypal,
|
||||
api::PaymentMethod::BankTransfer => Self::Bank,
|
||||
api::PaymentMethod::PayLater(ref klarna_data) => Self::Klarna(StripeKlarnaData {
|
||||
payment_method_types: "klarna".to_string(),
|
||||
payment_method_data_type: "klarna".to_string(),
|
||||
billing_email: klarna_data.billing_email.clone(),
|
||||
billing_country: klarna_data.country.clone(),
|
||||
}),
|
||||
api::PaymentMethod::Wallet(_) => Self::Wallet,
|
||||
api::PaymentMethod::Paypal => Self::Paypal,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,17 +205,17 @@ fn error_response<T: Display>(err: &T) -> actix_web::HttpResponse {
|
||||
impl ResponseError for BachError {
|
||||
fn status_code(&self) -> StatusCode {
|
||||
match self {
|
||||
BachError::EParsingError(_)
|
||||
| BachError::EAuthenticationError(_)
|
||||
| BachError::EAuthorisationError(_) => StatusCode::BAD_REQUEST,
|
||||
Self::EParsingError(_)
|
||||
| Self::EAuthenticationError(_)
|
||||
| Self::EAuthorisationError(_) => StatusCode::BAD_REQUEST,
|
||||
|
||||
BachError::EDatabaseError(_)
|
||||
| BachError::NotImplementedByConnector(_)
|
||||
| BachError::EMetrics(_)
|
||||
| BachError::EIo(_)
|
||||
| BachError::ConfigurationError(_)
|
||||
| BachError::EEncryptionError(_)
|
||||
| BachError::EUnexpectedError(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Self::EDatabaseError(_)
|
||||
| Self::NotImplementedByConnector(_)
|
||||
| Self::EMetrics(_)
|
||||
| Self::EIo(_)
|
||||
| Self::ConfigurationError(_)
|
||||
| Self::EEncryptionError(_)
|
||||
| Self::EUnexpectedError(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -148,53 +148,55 @@ impl actix_web::ResponseError for ApiErrorResponse {
|
||||
use reqwest::StatusCode;
|
||||
|
||||
match self {
|
||||
ApiErrorResponse::Unauthorized
|
||||
| ApiErrorResponse::BadCredentials
|
||||
| ApiErrorResponse::InvalidEphermeralKey => StatusCode::UNAUTHORIZED, // 401
|
||||
ApiErrorResponse::InvalidRequestUrl => StatusCode::NOT_FOUND, // 404
|
||||
ApiErrorResponse::InvalidHttpMethod => StatusCode::METHOD_NOT_ALLOWED, // 405
|
||||
ApiErrorResponse::MissingRequiredField { .. }
|
||||
| ApiErrorResponse::InvalidDataValue { .. } => StatusCode::BAD_REQUEST, // 400
|
||||
ApiErrorResponse::InvalidDataFormat { .. }
|
||||
| ApiErrorResponse::InvalidRequestData { .. } => StatusCode::UNPROCESSABLE_ENTITY, // 422
|
||||
ApiErrorResponse::RefundAmountExceedsPaymentAmount => StatusCode::BAD_REQUEST, // 400
|
||||
ApiErrorResponse::MaximumRefundCount => StatusCode::BAD_REQUEST, // 400
|
||||
ApiErrorResponse::PreconditionFailed { .. } => StatusCode::BAD_REQUEST, // 400
|
||||
Self::Unauthorized | Self::BadCredentials | Self::InvalidEphermeralKey => {
|
||||
StatusCode::UNAUTHORIZED
|
||||
} // 401
|
||||
Self::InvalidRequestUrl => StatusCode::NOT_FOUND, // 404
|
||||
Self::InvalidHttpMethod => StatusCode::METHOD_NOT_ALLOWED, // 405
|
||||
Self::MissingRequiredField { .. } | Self::InvalidDataValue { .. } => {
|
||||
StatusCode::BAD_REQUEST
|
||||
} // 400
|
||||
Self::InvalidDataFormat { .. } | Self::InvalidRequestData { .. } => {
|
||||
StatusCode::UNPROCESSABLE_ENTITY
|
||||
} // 422
|
||||
Self::RefundAmountExceedsPaymentAmount => StatusCode::BAD_REQUEST, // 400
|
||||
Self::MaximumRefundCount => StatusCode::BAD_REQUEST, // 400
|
||||
Self::PreconditionFailed { .. } => StatusCode::BAD_REQUEST, // 400
|
||||
|
||||
ApiErrorResponse::PaymentAuthorizationFailed { .. }
|
||||
| ApiErrorResponse::PaymentAuthenticationFailed { .. }
|
||||
| ApiErrorResponse::PaymentCaptureFailed { .. }
|
||||
| ApiErrorResponse::InvalidCardData { .. }
|
||||
| ApiErrorResponse::CardExpired { .. }
|
||||
| ApiErrorResponse::RefundFailed { .. }
|
||||
| ApiErrorResponse::VerificationFailed { .. }
|
||||
| ApiErrorResponse::PaymentUnexpectedState { .. }
|
||||
| ApiErrorResponse::MandateValidationFailed { .. } => StatusCode::BAD_REQUEST, // 400
|
||||
Self::PaymentAuthorizationFailed { .. }
|
||||
| Self::PaymentAuthenticationFailed { .. }
|
||||
| Self::PaymentCaptureFailed { .. }
|
||||
| Self::InvalidCardData { .. }
|
||||
| Self::CardExpired { .. }
|
||||
| Self::RefundFailed { .. }
|
||||
| Self::VerificationFailed { .. }
|
||||
| Self::PaymentUnexpectedState { .. }
|
||||
| Self::MandateValidationFailed { .. } => StatusCode::BAD_REQUEST, // 400
|
||||
|
||||
ApiErrorResponse::InternalServerError => StatusCode::INTERNAL_SERVER_ERROR, // 500
|
||||
ApiErrorResponse::DuplicateRefundRequest => StatusCode::BAD_REQUEST, // 400
|
||||
ApiErrorResponse::RefundNotFound
|
||||
| ApiErrorResponse::CustomerNotFound
|
||||
| ApiErrorResponse::MandateActive
|
||||
| ApiErrorResponse::CustomerRedacted
|
||||
| ApiErrorResponse::PaymentNotFound
|
||||
| ApiErrorResponse::PaymentMethodNotFound
|
||||
| ApiErrorResponse::MerchantAccountNotFound
|
||||
| ApiErrorResponse::MerchantConnectorAccountNotFound
|
||||
| ApiErrorResponse::MandateNotFound
|
||||
| ApiErrorResponse::ClientSecretNotGiven
|
||||
| ApiErrorResponse::ClientSecretInvalid
|
||||
| ApiErrorResponse::SuccessfulPaymentNotFound
|
||||
| ApiErrorResponse::IncorrectConnectorNameGiven
|
||||
| ApiErrorResponse::ResourceIdNotFound
|
||||
| ApiErrorResponse::AddressNotFound => StatusCode::BAD_REQUEST, // 400
|
||||
ApiErrorResponse::DuplicateMerchantAccount
|
||||
| ApiErrorResponse::DuplicateMerchantConnectorAccount
|
||||
| ApiErrorResponse::DuplicatePaymentMethod
|
||||
| ApiErrorResponse::DuplicateMandate => StatusCode::BAD_REQUEST, // 400
|
||||
ApiErrorResponse::ReturnUrlUnavailable => StatusCode::SERVICE_UNAVAILABLE, // 503
|
||||
ApiErrorResponse::PaymentNotSucceeded => StatusCode::BAD_REQUEST, // 400
|
||||
ApiErrorResponse::NotImplemented => StatusCode::NOT_IMPLEMENTED, // 501
|
||||
Self::InternalServerError => StatusCode::INTERNAL_SERVER_ERROR, // 500
|
||||
Self::DuplicateRefundRequest => StatusCode::BAD_REQUEST, // 400
|
||||
Self::RefundNotFound
|
||||
| Self::CustomerNotFound
|
||||
| Self::MandateActive
|
||||
| Self::CustomerRedacted
|
||||
| Self::PaymentNotFound
|
||||
| Self::PaymentMethodNotFound
|
||||
| Self::MerchantAccountNotFound
|
||||
| Self::MerchantConnectorAccountNotFound
|
||||
| Self::MandateNotFound
|
||||
| Self::ClientSecretNotGiven
|
||||
| Self::ClientSecretInvalid
|
||||
| Self::SuccessfulPaymentNotFound
|
||||
| Self::IncorrectConnectorNameGiven
|
||||
| Self::ResourceIdNotFound
|
||||
| Self::AddressNotFound => StatusCode::BAD_REQUEST, // 400
|
||||
Self::DuplicateMerchantAccount
|
||||
| Self::DuplicateMerchantConnectorAccount
|
||||
| Self::DuplicatePaymentMethod
|
||||
| Self::DuplicateMandate => StatusCode::BAD_REQUEST, // 400
|
||||
Self::ReturnUrlUnavailable => StatusCode::SERVICE_UNAVAILABLE, // 503
|
||||
Self::PaymentNotSucceeded => StatusCode::BAD_REQUEST, // 400
|
||||
Self::NotImplemented => StatusCode::NOT_IMPLEMENTED, // 501
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ impl PaymentsAuthorizeRouterData {
|
||||
confirm: Option<bool>,
|
||||
call_connector_action: payments::CallConnectorAction,
|
||||
_storage_scheme: storage_enums::MerchantStorageScheme,
|
||||
) -> RouterResult<PaymentsAuthorizeRouterData> {
|
||||
) -> RouterResult<Self> {
|
||||
match confirm {
|
||||
Some(true) => {
|
||||
let connector_integration: services::BoxedConnectorIntegration<
|
||||
|
||||
@ -67,7 +67,7 @@ impl PaymentsCancelRouterData {
|
||||
_maybe_customer: &Option<storage::Customer>,
|
||||
_confirm: Option<bool>,
|
||||
call_connector_action: payments::CallConnectorAction,
|
||||
) -> RouterResult<PaymentsCancelRouterData> {
|
||||
) -> RouterResult<Self> {
|
||||
let connector_integration: services::BoxedConnectorIntegration<
|
||||
api::Void,
|
||||
types::PaymentsCancelData,
|
||||
|
||||
@ -68,7 +68,7 @@ impl PaymentsCaptureRouterData {
|
||||
_maybe_customer: &Option<storage::Customer>,
|
||||
_confirm: Option<bool>,
|
||||
call_connector_action: payments::CallConnectorAction,
|
||||
) -> RouterResult<PaymentsCaptureRouterData> {
|
||||
) -> RouterResult<Self> {
|
||||
let connector_integration: services::BoxedConnectorIntegration<
|
||||
api::Capture,
|
||||
PaymentsCaptureData,
|
||||
|
||||
@ -68,7 +68,7 @@ impl PaymentsSyncRouterData {
|
||||
_maybe_customer: &Option<storage::Customer>,
|
||||
_confirm: Option<bool>,
|
||||
call_connector_action: payments::CallConnectorAction,
|
||||
) -> RouterResult<PaymentsSyncRouterData> {
|
||||
) -> RouterResult<Self> {
|
||||
let connector_integration: services::BoxedConnectorIntegration<
|
||||
api::PSync,
|
||||
PaymentsSyncData,
|
||||
|
||||
@ -105,7 +105,7 @@ impl types::PaymentsSessionRouterData {
|
||||
_customer: &Option<storage::Customer>,
|
||||
_confirm: Option<bool>,
|
||||
call_connector_action: payments::CallConnectorAction,
|
||||
) -> RouterResult<types::PaymentsSessionRouterData> {
|
||||
) -> RouterResult<Self> {
|
||||
match connector.get_token {
|
||||
api::GetToken::Metadata => create_gpay_session_token(self),
|
||||
api::GetToken::Connector => {
|
||||
|
||||
@ -497,6 +497,7 @@ fn mk_new_refund(
|
||||
|
||||
impl<F> TryFrom<types::RefundsRouterData<F>> for refunds::RefundResponse {
|
||||
type Error = error_stack::Report<errors::ApiErrorResponse>;
|
||||
|
||||
fn try_from(data: types::RefundsRouterData<F>) -> RouterResult<Self> {
|
||||
let refund_id = data.request.refund_id.to_string();
|
||||
let response = data.response;
|
||||
@ -506,7 +507,7 @@ impl<F> TryFrom<types::RefundsRouterData<F>> for refunds::RefundResponse {
|
||||
Err(error_response) => (api::RefundStatus::Pending, Some(error_response.message)),
|
||||
};
|
||||
|
||||
Ok(refunds::RefundResponse {
|
||||
Ok(Self {
|
||||
payment_id: data.payment_id,
|
||||
refund_id,
|
||||
amount: data.request.amount / 100,
|
||||
|
||||
@ -16,7 +16,8 @@
|
||||
clippy::todo,
|
||||
clippy::unreachable,
|
||||
clippy::unwrap_in_result,
|
||||
clippy::unwrap_used
|
||||
clippy::unwrap_used,
|
||||
clippy::use_self
|
||||
)]
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ pub struct AppState {
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
pub async fn with_storage(conf: Settings, storage_impl: StorageImpl) -> AppState {
|
||||
pub async fn with_storage(conf: Settings, storage_impl: StorageImpl) -> Self {
|
||||
let testable = storage_impl == StorageImpl::PostgresqlTest;
|
||||
let store: Box<dyn StorageInterface> = match storage_impl {
|
||||
StorageImpl::Postgresql | StorageImpl::PostgresqlTest => {
|
||||
@ -27,7 +27,7 @@ impl AppState {
|
||||
StorageImpl::Mock => Box::new(MockDb::new(&conf).await),
|
||||
};
|
||||
|
||||
AppState {
|
||||
Self {
|
||||
flow_name: String::from("default"),
|
||||
store,
|
||||
conf,
|
||||
@ -35,8 +35,8 @@ impl AppState {
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub async fn new(conf: Settings) -> AppState {
|
||||
AppState::with_storage(conf, StorageImpl::Postgresql).await
|
||||
pub async fn new(conf: Settings) -> Self {
|
||||
Self::with_storage(conf, StorageImpl::Postgresql).await
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,10 +20,10 @@ impl ProxyType {
|
||||
use std::env::var;
|
||||
|
||||
match self {
|
||||
ProxyType::Http => var(HTTP_PROXY)
|
||||
Self::Http => var(HTTP_PROXY)
|
||||
.or_else(|_| proxy.http_url.clone().ok_or(()))
|
||||
.ok(),
|
||||
ProxyType::Https => var(HTTPS_PROXY)
|
||||
Self::Https => var(HTTPS_PROXY)
|
||||
.or_else(|_| proxy.https_url.clone().ok_or(()))
|
||||
.ok(),
|
||||
}
|
||||
|
||||
@ -42,8 +42,8 @@ pub struct Request {
|
||||
}
|
||||
|
||||
impl Request {
|
||||
pub fn new(method: Method, url: &str) -> Request {
|
||||
Request {
|
||||
pub fn new(method: Method, url: &str) -> Self {
|
||||
Self {
|
||||
method,
|
||||
url: String::from(url),
|
||||
headers: Vec::new(),
|
||||
@ -87,8 +87,8 @@ pub struct RequestBuilder {
|
||||
}
|
||||
|
||||
impl RequestBuilder {
|
||||
pub fn new() -> RequestBuilder {
|
||||
RequestBuilder {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
method: Method::Get,
|
||||
url: String::with_capacity(1024),
|
||||
headers: Vec::new(),
|
||||
@ -99,44 +99,44 @@ impl RequestBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn url(mut self, url: &str) -> RequestBuilder {
|
||||
pub fn url(mut self, url: &str) -> Self {
|
||||
self.url = url.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn method(mut self, method: Method) -> RequestBuilder {
|
||||
pub fn method(mut self, method: Method) -> Self {
|
||||
self.method = method;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn header(mut self, header: &str, value: &str) -> RequestBuilder {
|
||||
pub fn header(mut self, header: &str, value: &str) -> Self {
|
||||
self.headers.push((header.into(), value.into()));
|
||||
self
|
||||
}
|
||||
|
||||
pub fn headers(mut self, headers: Vec<(String, String)>) -> RequestBuilder {
|
||||
pub fn headers(mut self, headers: Vec<(String, String)>) -> Self {
|
||||
// Fixme add union property
|
||||
let mut h = headers.into_iter().map(|(h, v)| (h, v)).collect();
|
||||
self.headers.append(&mut h);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn body(mut self, body: Option<String>) -> RequestBuilder {
|
||||
pub fn body(mut self, body: Option<String>) -> Self {
|
||||
self.payload = body.map(From::from);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn content_type(mut self, content_type: ContentType) -> RequestBuilder {
|
||||
pub fn content_type(mut self, content_type: ContentType) -> Self {
|
||||
self.content_type = Some(content_type);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn add_certificate(mut self, certificate: Option<String>) -> RequestBuilder {
|
||||
pub fn add_certificate(mut self, certificate: Option<String>) -> Self {
|
||||
self.certificate = certificate;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn add_certificate_key(mut self, certificate_key: Option<String>) -> RequestBuilder {
|
||||
pub fn add_certificate_key(mut self, certificate_key: Option<String>) -> Self {
|
||||
self.certificate_key = certificate_key;
|
||||
self
|
||||
}
|
||||
|
||||
@ -92,14 +92,14 @@ impl ConnectorData {
|
||||
connectors: &Connectors,
|
||||
name: &str,
|
||||
connector_type: GetToken,
|
||||
) -> CustomResult<ConnectorData, errors::ApiErrorResponse> {
|
||||
) -> CustomResult<Self, errors::ApiErrorResponse> {
|
||||
let connector = Self::convert_connector(connectors, name)?;
|
||||
let connector_name = api_enums::Connector::from_str(name)
|
||||
.into_report()
|
||||
.change_context(errors::ConnectorError::InvalidConnectorName)
|
||||
.attach_printable_lazy(|| format!("unable to parse connector name {connector:?}"))
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)?;
|
||||
Ok(ConnectorData {
|
||||
Ok(Self {
|
||||
connector,
|
||||
connector_name,
|
||||
get_token: connector_type,
|
||||
|
||||
@ -38,7 +38,7 @@ impl PaymentIntentDbExt for PaymentIntent {
|
||||
|
||||
//TODO: Replace this with Boxable Expression and pass it into generic filter
|
||||
// when https://github.com/rust-lang/rust/issues/52662 becomes stable
|
||||
let mut filter = <PaymentIntent as HasTable>::table()
|
||||
let mut filter = <Self as HasTable>::table()
|
||||
.filter(dsl::merchant_id.eq(merchant_id.to_owned()))
|
||||
.order_by(dsl::id)
|
||||
.into_boxed();
|
||||
|
||||
@ -90,25 +90,25 @@ where
|
||||
|
||||
impl From<F<api_enums::RoutingAlgorithm>> for F<storage_enums::RoutingAlgorithm> {
|
||||
fn from(algo: F<api_enums::RoutingAlgorithm>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(algo.0))
|
||||
Self(frunk::labelled_convert_from(algo.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<storage_enums::RoutingAlgorithm>> for F<api_enums::RoutingAlgorithm> {
|
||||
fn from(algo: F<storage_enums::RoutingAlgorithm>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(algo.0))
|
||||
Self(frunk::labelled_convert_from(algo.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<api_enums::ConnectorType>> for F<storage_enums::ConnectorType> {
|
||||
fn from(conn: F<api_enums::ConnectorType>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(conn.0))
|
||||
Self(frunk::labelled_convert_from(conn.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<storage_enums::ConnectorType>> for F<api_enums::ConnectorType> {
|
||||
fn from(conn: F<storage_enums::ConnectorType>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(conn.0))
|
||||
Self(frunk::labelled_convert_from(conn.0))
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,49 +124,49 @@ impl From<F<api_models::refunds::RefundType>> for F<storage_enums::RefundType> {
|
||||
|
||||
impl From<F<storage_enums::MandateStatus>> for F<api_enums::MandateStatus> {
|
||||
fn from(status: F<storage_enums::MandateStatus>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(status.0))
|
||||
Self(frunk::labelled_convert_from(status.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<api_enums::PaymentMethodType>> for F<storage_enums::PaymentMethodType> {
|
||||
fn from(pm_type: F<api_enums::PaymentMethodType>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(pm_type.0))
|
||||
Self(frunk::labelled_convert_from(pm_type.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<storage_enums::PaymentMethodType>> for F<api_enums::PaymentMethodType> {
|
||||
fn from(pm_type: F<storage_enums::PaymentMethodType>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(pm_type.0))
|
||||
Self(frunk::labelled_convert_from(pm_type.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<api_enums::PaymentMethodSubType>> for F<storage_enums::PaymentMethodSubType> {
|
||||
fn from(pm_subtype: F<api_enums::PaymentMethodSubType>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(pm_subtype.0))
|
||||
Self(frunk::labelled_convert_from(pm_subtype.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<storage_enums::PaymentMethodSubType>> for F<api_enums::PaymentMethodSubType> {
|
||||
fn from(pm_subtype: F<storage_enums::PaymentMethodSubType>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(pm_subtype.0))
|
||||
Self(frunk::labelled_convert_from(pm_subtype.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<storage_enums::PaymentMethodIssuerCode>> for F<api_enums::PaymentMethodIssuerCode> {
|
||||
fn from(issuer_code: F<storage_enums::PaymentMethodIssuerCode>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(issuer_code.0))
|
||||
Self(frunk::labelled_convert_from(issuer_code.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<storage_enums::IntentStatus>> for F<api_enums::IntentStatus> {
|
||||
fn from(status: F<storage_enums::IntentStatus>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(status.0))
|
||||
Self(frunk::labelled_convert_from(status.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<api_enums::IntentStatus>> for F<storage_enums::IntentStatus> {
|
||||
fn from(status: F<api_enums::IntentStatus>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(status.0))
|
||||
Self(frunk::labelled_convert_from(status.0))
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,55 +228,55 @@ impl TryFrom<F<api_enums::IntentStatus>> for F<storage_enums::EventType> {
|
||||
|
||||
impl From<F<storage_enums::EventType>> for F<api_enums::EventType> {
|
||||
fn from(event_type: F<storage_enums::EventType>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(event_type.0))
|
||||
Self(frunk::labelled_convert_from(event_type.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<api_enums::FutureUsage>> for F<storage_enums::FutureUsage> {
|
||||
fn from(future_usage: F<api_enums::FutureUsage>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(future_usage.0))
|
||||
Self(frunk::labelled_convert_from(future_usage.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<storage_enums::FutureUsage>> for F<api_enums::FutureUsage> {
|
||||
fn from(future_usage: F<storage_enums::FutureUsage>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(future_usage.0))
|
||||
Self(frunk::labelled_convert_from(future_usage.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<storage_enums::RefundStatus>> for F<api_enums::RefundStatus> {
|
||||
fn from(status: F<storage_enums::RefundStatus>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(status.0))
|
||||
Self(frunk::labelled_convert_from(status.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<api_enums::CaptureMethod>> for F<storage_enums::CaptureMethod> {
|
||||
fn from(capture_method: F<api_enums::CaptureMethod>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(capture_method.0))
|
||||
Self(frunk::labelled_convert_from(capture_method.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<storage_enums::CaptureMethod>> for F<api_enums::CaptureMethod> {
|
||||
fn from(capture_method: F<storage_enums::CaptureMethod>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(capture_method.0))
|
||||
Self(frunk::labelled_convert_from(capture_method.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<api_enums::AuthenticationType>> for F<storage_enums::AuthenticationType> {
|
||||
fn from(auth_type: F<api_enums::AuthenticationType>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(auth_type.0))
|
||||
Self(frunk::labelled_convert_from(auth_type.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<storage_enums::AuthenticationType>> for F<api_enums::AuthenticationType> {
|
||||
fn from(auth_type: F<storage_enums::AuthenticationType>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(auth_type.0))
|
||||
Self(frunk::labelled_convert_from(auth_type.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<F<api_enums::Currency>> for F<storage_enums::Currency> {
|
||||
fn from(currency: F<api_enums::Currency>) -> Self {
|
||||
Foreign(frunk::labelled_convert_from(currency.0))
|
||||
Self(frunk::labelled_convert_from(currency.0))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ where
|
||||
value.parse_value(type_name)
|
||||
}
|
||||
|
||||
fn update_value(&mut self, value: Option<T>) {
|
||||
fn update_value(&mut self, value: Self) {
|
||||
if let Some(a) = value {
|
||||
*self = Some(a)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user