mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 12:06:56 +08:00
feat(payment_methods_v2): Update and Retrieve payment method APIs for v2 (#5939)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -15,7 +15,7 @@ use super::app::{AppState, SessionState};
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
use crate::core::payment_methods::{
|
||||
create_payment_method, list_customer_payment_method_util, payment_method_intent_confirm,
|
||||
payment_method_intent_create,
|
||||
payment_method_intent_create, retrieve_payment_method, update_payment_method,
|
||||
};
|
||||
use crate::{
|
||||
core::{
|
||||
@ -180,6 +180,65 @@ pub async fn confirm_payment_method_intent_api(
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodsUpdate))]
|
||||
pub async fn payment_method_update_api(
|
||||
state: web::Data<AppState>,
|
||||
req: HttpRequest,
|
||||
path: web::Path<String>,
|
||||
json_payload: web::Json<payment_methods::PaymentMethodUpdate>,
|
||||
) -> HttpResponse {
|
||||
let flow = Flow::PaymentMethodsUpdate;
|
||||
let payment_method_id = path.into_inner();
|
||||
let payload = json_payload.into_inner();
|
||||
|
||||
Box::pin(api::server_wrap(
|
||||
flow,
|
||||
state,
|
||||
&req,
|
||||
payload,
|
||||
|state, auth, req, _| {
|
||||
update_payment_method(
|
||||
state,
|
||||
auth.merchant_account,
|
||||
req,
|
||||
&payment_method_id,
|
||||
auth.key_store,
|
||||
)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodsRetrieve))]
|
||||
pub async fn payment_method_retrieve_api(
|
||||
state: web::Data<AppState>,
|
||||
req: HttpRequest,
|
||||
path: web::Path<String>,
|
||||
) -> HttpResponse {
|
||||
let flow = Flow::PaymentMethodsRetrieve;
|
||||
let payload = web::Json(PaymentMethodId {
|
||||
payment_method_id: path.into_inner(),
|
||||
})
|
||||
.into_inner();
|
||||
|
||||
Box::pin(api::server_wrap(
|
||||
flow,
|
||||
state,
|
||||
&req,
|
||||
payload,
|
||||
|state, auth, pm, _| {
|
||||
retrieve_payment_method(state, pm, auth.key_store, auth.merchant_account)
|
||||
},
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
}
|
||||
|
||||
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodsMigrate))]
|
||||
pub async fn migrate_payment_method_api(
|
||||
state: web::Data<AppState>,
|
||||
@ -667,6 +726,10 @@ pub async fn render_pm_collect_link(
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodsRetrieve))]
|
||||
pub async fn payment_method_retrieve_api(
|
||||
state: web::Data<AppState>,
|
||||
@ -693,6 +756,10 @@ pub async fn payment_method_retrieve_api(
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodsUpdate))]
|
||||
pub async fn payment_method_update_api(
|
||||
state: web::Data<AppState>,
|
||||
|
||||
Reference in New Issue
Block a user