Skip to content

Commit

Permalink
refactor: rename operation and fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Narayanbhat166 committed Oct 23, 2024
1 parent e8efec5 commit 4deff35
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions crates/router/src/core/payments/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ use error_stack::{report, ResultExt};
use router_env::{instrument, tracing};

#[cfg(feature = "v2")]
pub use self::payment_confirm_intent::PaymentsIntentConfirm;
pub use self::payment_confirm_intent::PaymentIntentConfirm;
#[cfg(feature = "v2")]
pub use self::payment_create_intent::PaymentCreateIntent;
pub use self::payment_create_intent::PaymentIntentCreate;
pub use self::payment_response::PaymentResponse;
#[cfg(feature = "v1")]
pub use self::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ use crate::{
};

#[derive(Debug, Clone, Copy)]
pub struct PaymentsIntentConfirm;
pub struct PaymentIntentConfirm;

impl ValidateStatusForOperation for PaymentsIntentConfirm {
impl ValidateStatusForOperation for PaymentIntentConfirm {
/// Validate if the current operation can be performed on the current status of the payment intent
fn validate_status_for_operation(
&self,
Expand All @@ -56,10 +56,10 @@ impl ValidateStatusForOperation for PaymentsIntentConfirm {
| common_enums::IntentStatus::RequiresConfirmation
| common_enums::IntentStatus::PartiallyCapturedAndCapturable => {
Err(errors::ApiErrorResponse::PaymentUnexpectedState {
current_flow: "cofirm_intent".to_string(),
current_flow: format!("{self:?}"),
field_name: "status".to_string(),
current_value: intent_status.to_string(),
states: vec!["requires_payment_method".to_string()].join(", "),
states: ["requires_payment_method".to_string()].join(", "),
})
}
}
Expand All @@ -71,7 +71,7 @@ type BoxedConfirmOperation<'b, F> =

// TODO: change the macro to include changes for v2
// TODO: PaymentData in the macro should be an input
impl<F: Send + Clone> Operation<F, PaymentsConfirmIntentRequest> for &PaymentsIntentConfirm {
impl<F: Send + Clone> Operation<F, PaymentsConfirmIntentRequest> for &PaymentIntentConfirm {
type Data = PaymentConfirmData<F>;
fn to_validate_request(
&self,
Expand Down Expand Up @@ -99,7 +99,7 @@ impl<F: Send + Clone> Operation<F, PaymentsConfirmIntentRequest> for &PaymentsIn
}
}
#[automatically_derived]
impl<F: Send + Clone> Operation<F, PaymentsConfirmIntentRequest> for PaymentsIntentConfirm {
impl<F: Send + Clone> Operation<F, PaymentsConfirmIntentRequest> for PaymentIntentConfirm {
type Data = PaymentConfirmData<F>;
fn to_validate_request(
&self,
Expand All @@ -126,7 +126,7 @@ impl<F: Send + Clone> Operation<F, PaymentsConfirmIntentRequest> for PaymentsInt
}

impl<F: Send + Clone> ValidateRequest<F, PaymentsConfirmIntentRequest, PaymentConfirmData<F>>
for PaymentsIntentConfirm
for PaymentIntentConfirm
{
#[instrument(skip_all)]
fn validate_request<'a, 'b>(
Expand All @@ -146,7 +146,7 @@ impl<F: Send + Clone> ValidateRequest<F, PaymentsConfirmIntentRequest, PaymentCo

#[async_trait]
impl<F: Send + Clone> GetTracker<F, PaymentConfirmData<F>, PaymentsConfirmIntentRequest>
for PaymentsIntentConfirm
for PaymentIntentConfirm
{
#[instrument(skip_all)]
async fn get_trackers<'a>(
Expand Down Expand Up @@ -176,7 +176,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentConfirmData<F>, PaymentsConfirmIntent
.client_secret
.as_ref()
.get_required_value("client_secret header")?;
payment_intent.validate_client_secret(&client_secret)?;
payment_intent.validate_client_secret(client_secret)?;

let cell_id = state.conf.cell_information.id.clone();

Expand Down Expand Up @@ -224,7 +224,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentConfirmData<F>, PaymentsConfirmIntent

#[async_trait]
impl<F: Clone + Send> Domain<F, PaymentsConfirmIntentRequest, PaymentConfirmData<F>>
for PaymentsIntentConfirm
for PaymentIntentConfirm
{
async fn get_customer_details<'a>(
&'a self,
Expand Down Expand Up @@ -284,7 +284,7 @@ impl<F: Clone + Send> Domain<F, PaymentsConfirmIntentRequest, PaymentConfirmData

#[async_trait]
impl<F: Clone> UpdateTracker<F, PaymentConfirmData<F>, PaymentsConfirmIntentRequest>
for PaymentsIntentConfirm
for PaymentIntentConfirm
{
#[instrument(skip_all)]
async fn update_trackers<'b>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use crate::{
};

#[derive(Debug, Clone, Copy)]
pub struct PaymentCreateIntent;
pub struct PaymentIntentCreate;

impl<F: Send + Clone> Operation<F, PaymentsCreateIntentRequest> for &PaymentCreateIntent {
impl<F: Send + Clone> Operation<F, PaymentsCreateIntentRequest> for &PaymentIntentCreate {
type Data = payments::PaymentIntentData<F>;
fn to_validate_request(
&self,
Expand All @@ -52,7 +52,7 @@ impl<F: Send + Clone> Operation<F, PaymentsCreateIntentRequest> for &PaymentCrea
}
}

impl<F: Send + Clone> Operation<F, PaymentsCreateIntentRequest> for PaymentCreateIntent {
impl<F: Send + Clone> Operation<F, PaymentsCreateIntentRequest> for PaymentIntentCreate {
type Data = payments::PaymentIntentData<F>;
fn to_validate_request(
&self,
Expand Down Expand Up @@ -83,7 +83,7 @@ type PaymentsCreateIntentOperation<'b, F> =

#[async_trait]
impl<F: Send + Clone> GetTracker<F, payments::PaymentIntentData<F>, PaymentsCreateIntentRequest>
for PaymentCreateIntent
for PaymentIntentCreate
{
#[instrument(skip_all)]
async fn get_trackers<'a>(
Expand Down Expand Up @@ -187,7 +187,7 @@ impl<F: Send + Clone> GetTracker<F, payments::PaymentIntentData<F>, PaymentsCrea

#[async_trait]
impl<F: Clone> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsCreateIntentRequest>
for PaymentCreateIntent
for PaymentIntentCreate
{
#[instrument(skip_all)]
async fn update_trackers<'b>(
Expand All @@ -214,7 +214,7 @@ impl<F: Clone> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsCreateIn

impl<F: Send + Clone>
ValidateRequest<F, PaymentsCreateIntentRequest, payments::PaymentIntentData<F>>
for PaymentCreateIntent
for PaymentIntentCreate
{
#[instrument(skip_all)]
fn validate_request<'a, 'b>(
Expand All @@ -238,7 +238,7 @@ impl<F: Send + Clone>

#[async_trait]
impl<F: Clone + Send> Domain<F, PaymentsCreateIntentRequest, payments::PaymentIntentData<F>>
for PaymentCreateIntent
for PaymentIntentCreate
{
#[instrument(skip_all)]
async fn get_customer_details<'a>(
Expand Down
4 changes: 2 additions & 2 deletions crates/router/src/routes/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub async fn payments_create_intent(
auth.merchant_account,
auth.profile,
auth.key_store,
payments::operations::PaymentCreateIntent,
payments::operations::PaymentIntentCreate,
req,
header_payload.clone(),
)
Expand Down Expand Up @@ -2071,7 +2071,7 @@ pub async fn payment_confirm_intent(
let payment_id = req.global_payment_id;
let request = req.payload;

let operation = payments::operations::PaymentsIntentConfirm;
let operation = payments::operations::PaymentIntentConfirm;

Box::pin(payments::payments_core::<
api_types::Authorize,
Expand Down

0 comments on commit 4deff35

Please sign in to comment.