Skip to content

Commit

Permalink
chore: merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Narayanbhat166 committed Dec 21, 2024
1 parent 7ae9fb4 commit 5bc9c59
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions crates/router/src/routes/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,78 @@ pub async fn payments_finish_redirection(
.await
}

#[cfg(feature = "v2")]
#[instrument(skip(state, req), fields(flow, payment_id))]
pub async fn payments_capture(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
payload: web::Json<api_models::payments::PaymentsCaptureRequest>,
path: web::Path<common_utils::id_type::GlobalPaymentId>,
) -> impl Responder {
use hyperswitch_domain_models::payments::PaymentCaptureData;
let flow = Flow::PaymentsCapture;

let global_payment_id = path.into_inner();
tracing::Span::current().record("payment_id", global_payment_id.get_string_repr());

let internal_payload = internal_payload_types::PaymentsGenericRequestWithResourceId {
global_payment_id,
payload: payload.into_inner(),
};

let header_payload = match HeaderPayload::foreign_try_from(req.headers()) {
Ok(headers) => headers,
Err(err) => {
return api::log_and_return_error_response(err);
}
};

let locking_action = internal_payload.get_locking_input(flow.clone());

Box::pin(api::server_wrap(
flow,
state,
&req,
internal_payload,
|state, auth: auth::AuthenticationData, req, req_state| async {
let payment_id = req.global_payment_id;
let request = req.payload;

let operation = payments::operations::payment_capture_v2::PaymentsCapture;

Box::pin(payments::payments_core::<
api_types::Capture,
api_models::payments::PaymentsCaptureResponse,
_,
_,
_,
PaymentCaptureData<api_types::Capture>,
>(
state,
req_state,
auth.merchant_account,
auth.profile,
auth.key_store,
operation,
request,
payment_id,
payments::CallConnectorAction::Trigger,
header_payload.clone(),
))
.await
},
auth::auth_type(
&auth::HeaderAuth(auth::ApiKeyAuth),
&auth::JWTAuth {
permission: Permission::ProfileAccountWrite,
},
req.headers(),
),
locking_action,
))
.await
}

#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodsList))]
pub async fn list_payment_methods(
Expand Down

0 comments on commit 5bc9c59

Please sign in to comment.